package-installed-update.ts 1.8 KB

123456789101112131415161718192021222324252627282930
  1. /** Operator-only signed packaging; default checks do not launch children, sign, install, or publish. */
  2. import { createInterface } from 'node:readline/promises'
  3. import { stdin, stdout } from 'node:process'
  4. import { InstalledUpdateSigningHoldError, packageInstalledUpdate } from './installed-update-packaging.ts'
  5. async function main(): Promise<void> {
  6. const [manifest, version, mode, ...extra] = process.argv.slice(2)
  7. if (!manifest || !version || extra.length !== 0 || (mode !== undefined && mode !== '--check' && mode !== '--execute')) {
  8. throw new Error('invalid invocation')
  9. }
  10. const result = await packageInstalledUpdate(manifest, version, { execute: mode === '--execute',
  11. confirm: async (id, selectedVersion) => {
  12. if (!stdin.isTTY || !stdout.isTTY) return false
  13. const terminal = createInterface({ input: stdin, output: stdout })
  14. try {
  15. console.log('仅在管理员已审核并恢复签名保护后继续。确认已注销令牌、剩余 5/5、PIN 正确且无其他签名任务。')
  16. console.log('本次打包会有多次签名;不重试失败操作,驱动内部认证次数无法保证。出现密码弹窗请取消,不要补输。')
  17. console.log('PIN 只从 .env.windows 读取;签名接口要求它短暂出现在 SignTool 参数中。不会安装或上传。')
  18. const expected = `PACKAGE ${selectedVersion} ${id}`
  19. return (await terminal.question(`仅授权这个版本,请输入 ${expected}:`)) === expected
  20. } finally { terminal.close() }
  21. } })
  22. console.log(JSON.stringify(result, null, 2))
  23. }
  24. main().catch((error: unknown) => {
  25. console.error(error instanceof InstalledUpdateSigningHoldError ? error.message
  26. : 'installed update packaging stopped. Check prepared files and the retained record; do not retry or remove protection automatically.')
  27. process.exitCode = 1
  28. })