chore(apes-sidebar): 挂载验收脚本 scripts/verify-mount.cjs

模拟 DSH host 的 bundle 解析,验证 apes-sidebar 在 profile node_modules:
- package.json 可解析 (name=apes-sidebar v2.0.0)
- host entry 命名导出 { name, inject:['logger'], apply } 无 default
- invariant surface 可用 (assert)
- client entry 是 __ModuleLoader__ browser bundle(line 1 window)
- peer dsh-better-sidebar 满足 ^0.18.0

用法:node scripts/verify-mount.cjs(或 pnpm verify:mount)
依赖 profile 环境(~/.dsh/profiles/desktop 已装 apes-sidebar),
非单测门禁的一部分——CI 无 DSH profile 时跳过。

验收结果:14/14 通过(apes-sidebar 2.0.0 已挂载进
~/.dsh/profiles/desktop,dsh-better-sidebar 升级 ^0.17.1→0.18.0,
无新增 peer 冲突——所有 warning 为预存 runtime-provided peer)

门禁:typecheck rc=0 · build rc=0 · test 29/29
This commit is contained in:
figmar
2026-09-04 20:54:53 +08:00
parent a94c43343d
commit 4e60dde18d
2 changed files with 81 additions and 0 deletions
+80
View File
@@ -0,0 +1,80 @@
/**
* 验收验证:模拟 DSH host 的 resolveOverlayPackage + bundle 加载
* - 确认 apes-sidebar 在 profile node_modules 可解析
* - 确认 host entry (lib/index.js) 的命名导出 shape { name, inject, apply }
* - 确认 client entry (lib/client.js) 存在且是 __ModuleLoader__ bundle(browser artifact)
* - 确认 invariant surface 可用
*/
const path = require('path')
const fs = require('fs')
const { createRequire } = require('module')
const PROFILE = process.env.HOME + '/.dsh/profiles/desktop'
const req = createRequire(path.join(PROFILE, 'noop.js'))
let pass = 0, fail = 0
const check = (label, cond, detail = '') => {
if (cond) { pass++; console.log(' ✓', label) }
else { fail++; console.log(' ✗', label, detail) }
}
console.log('### apes-sidebar 挂载验收')
// 1. 包可解析
try {
const pkgPath = req.resolve('apes-sidebar/package.json')
const pkg = req('apes-sidebar/package.json')
check('package.json 可解析', true, pkgPath)
check('name=apes-sidebar', pkg.name === 'apes-sidebar')
check('version=2.0.0', pkg.version === '2.0.0')
} catch (e) {
check('package.json 可解析', false, e.message)
}
// 2. host entry 加载 + shape
try {
const host = req('apes-sidebar')
check('host entry 加载成功', true)
check('导出 name (string)', typeof host.name === 'string', 'got ' + typeof host.name)
check('导出 inject (string[])', Array.isArray(host.inject), 'got ' + typeof host.inject)
check('inject === [logger]', JSON.stringify(host.inject) === '["logger"]', JSON.stringify(host.inject))
check('导出 apply (function)', typeof host.apply === 'function')
check('无 default export(namespace 规则)', !('default' in host))
console.log(' name =', JSON.stringify(host.name))
} catch (e) {
check('host entry 加载', false, e.message)
}
// 3. invariant surface
try {
const inv = req('apes-sidebar/invariant')
check('invariant 可加载', true)
check('invariant.assert 是函数', typeof inv.assert === 'function')
} catch (e) {
check('invariant 可加载', false, e.message)
}
// 4. client entry 存在 + 是 browser artifact
try {
const clientPath = req.resolve('apes-sidebar/client')
const clientSrc = fs.readFileSync(clientPath, 'utf8')
check('client entry 文件存在', true, clientPath)
check('client 是 __ModuleLoader__ bundle(line 1 window)',
clientSrc.split('\n')[0].includes('window.__ModuleLoader__.load'),
'line1=' + clientSrc.split('\n')[0].slice(0, 50))
} catch (e) {
check('client entry', false, e.message)
}
// 5. peer dep dsh-better-sidebar 版本满足 ^0.18.0
try {
const bs = req('dsh-better-sidebar/package.json')
const v = bs.version
check('dsh-better-sidebar 版本满足 ^0.18.0',
v === '0.18.0', 'got ' + v)
} catch (e) {
check('dsh-better-sidebar 版本', false, e.message)
}
console.log('\n=== 验收结果: ' + pass + ' passed, ' + fail + ' failed ===')
process.exit(fail > 0 ? 1 : 0)