Files
apes-sidebar/scripts/verify-mount.cjs
T
figmar 0b79269b2c fix(apes-sidebar): inject 改空数组(修 DSH entry pending → 恢复模式)
根因:inject: ['logger'] 声明了 logger 为硬依赖 service,但 DSH host
没有 provider 注册 logger service → entry 永远 pending →
'1 entry did not activate' → 插件树加载失败 → 恢复模式循环。

对比 dsh-better-sidebar:其 inject 是 host 实际提供的 service
(webServer/sessions/webRuntime/tools)。apes-sidebar host half 只用
ctx.logger 做可选链调用(log?.info?.() 在 try/catch 里),logger 是
软便利不是硬依赖——不该出现在 inject 列表里。

修正:inject 改空数组 [],host half 不声明任何硬依赖 service。
同步更新 smoke.spec.ts 断言(inject toEqual([]))+
verify-mount.cjs 检查(inject === [])。

门禁:typecheck rc=0 · build rc=0 · test 29/29
2026-09-04 21:21:56 +08:00

81 lines
2.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 验收验证:模拟 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 === [] (无硬依赖 service)', JSON.stringify(host.inject) === '[]', 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)