diff --git a/apps/desktop/scripts/stage-harness.mjs b/apps/desktop/scripts/stage-harness.mjs index 74d9b960..7327d88e 100644 --- a/apps/desktop/scripts/stage-harness.mjs +++ b/apps/desktop/scripts/stage-harness.mjs @@ -164,9 +164,7 @@ if (keepIgnore) writeFileSync(join(out, '.gitignore'), keepIgnore); // --- proof 1: nothing the Harness imports by name was pruned ------------------------------------------------------------ // (2026-10-17: the other-OS rule once removed @deepseek-ai/dsh-win32-process, which every platform imports; Linux/Mac agent chats died.) const lost = missingHarnessImports(out); -if (lost.length) { console.error('staged Harness is missing imported packages: -' + lost.map(l => ` ${l.from} -> ${l.missing}`).join(' -')); process.exit(1); } +if (lost.length) { console.error(['staged Harness is missing imported packages:', ...lost.map(l => ` ${l.from} -> ${l.missing}`)].join(String.fromCharCode(10))); process.exit(1); } console.log('import check: every @deepseek-ai package the Harness imports is staged'); // --- proof 2: the staged copy answers --version and boots the web profile once ---------------------------------------- diff --git a/apps/host/tests/staging-scripts-syntax.test.mjs b/apps/host/tests/staging-scripts-syntax.test.mjs new file mode 100644 index 00000000..e18f8e85 --- /dev/null +++ b/apps/host/tests/staging-scripts-syntax.test.mjs @@ -0,0 +1,40 @@ +/** + * Every build and staging script must at least parse. A string literal broken over two lines in stage-harness.mjs (2026-10-17) made + * every Harness staging fail with a SyntaxError, on every operating system, and nothing noticed until a build was started. + */ +import test from 'node:test'; +import assert from 'node:assert/strict'; +import { readdirSync } from 'node:fs'; +import { spawnSync } from 'node:child_process'; +import { join, resolve } from 'node:path'; + +const scripts = resolve(import.meta.dirname, '..', '..', 'desktop', 'scripts'); +const packaging = resolve(import.meta.dirname, '..', '..', '..', 'packaging'); + +for (const file of readdirSync(scripts).filter(f => f.endsWith('.mjs'))) { + test(`node --check ${file}`, () => { + const r = spawnSync(process.execPath, ['--check', join(scripts, file)], { encoding: 'utf8' }); + assert.equal(r.status, 0, r.stderr); + }); +} + +for (const file of readdirSync(scripts).filter(f => f.endsWith('.sh'))) { + test(`bash -n ${file}`, t => { + const probe = spawnSync('bash', ['--version'], { encoding: 'utf8' }); + if (probe.error || probe.status !== 0) { t.skip('no bash here'); return; } + const r = spawnSync('bash', ['-n', join(scripts, file)], { encoding: 'utf8' }); + assert.equal(r.status, 0, r.stderr); + }); +} + +for (const dir of [scripts, packaging]) { + for (const file of readdirSync(dir).filter(f => f.endsWith('.py'))) { + test(`python compile ${file}`, t => { + const python = process.platform === 'win32' ? 'python' : 'python3'; + const probe = spawnSync(python, ['--version'], { encoding: 'utf8' }); + if (probe.error || probe.status !== 0) { t.skip('no python here'); return; } + const r = spawnSync(python, ['-c', 'import ast,sys; ast.parse(open(sys.argv[1], encoding="utf-8").read())', join(dir, file)], { encoding: 'utf8' }); + assert.equal(r.status, 0, r.stderr); + }); + } +}