mirror of
https://github.com/nexu-io/openmotion.git
synced 2026-12-02 04:40:32 +08:00
* fix: complete automatic onboarding across installation entry points * test: run onboarding regressions in CI and align host guidance * test: isolate bootstrap onboarding from ambient Codex sessions * test: publish synthetic account credentials atomically * fix: rebind a vanished source registration during install preflight The source preflight aborted the whole install with a raw realpath ENOENT when the previously registered checkout had been deleted or moved, which is exactly the uninstalled-source state sourceMarketplacePlan exists to rebind. Resolve the recorded source defensively: a missing or non-directory path is reported as a stale registration to replace, and rollback skips restoring a path that no longer exists. Refusals for foreign, non-local, ambiguous or actively installed sources are unchanged. Generated-By: looper 0.16.2 (runner=fixer, agent=pi) * fix: preserve installed marketplace sources on inventory failures * fix: recover verified stale sources and preserve onboarding delivery state --------- Co-authored-by: bone3deep1962-collab <bone3deep1962@gmail.com> Co-authored-by: 罗高 <luogao@users.noreply.github.com>
60 lines
3.8 KiB
TypeScript
60 lines
3.8 KiB
TypeScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { mkdtemp, mkdir, writeFile, readFile, rm } from 'node:fs/promises';
|
|
import { spawnSync } from 'node:child_process';
|
|
import { tmpdir } from 'node:os';
|
|
import path from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { execFileSync } from 'node:child_process';
|
|
|
|
test('public Motion sources contain no company endpoints, workstation paths or embedded upstream ingest keys', async () => {
|
|
const root = fileURLToPath(new URL('../', import.meta.url));
|
|
const files = execFileSync('git', ['ls-files', '--cached', '--others', '--exclude-standard', '-z', '--', '.'], { cwd: root, encoding: 'utf8' }).split('\0').filter(Boolean);
|
|
for (const file of files) {
|
|
if (!/\.(?:md|txt|ts|tsx|js|mjs|json|yml|yaml|html|css|sh|ps1|command)$/.test(file)) continue;
|
|
let content: string;
|
|
try { content = await readFile(path.join(root, file), 'utf8'); }
|
|
catch (error) { if ((error as NodeJS.ErrnoException).code === 'ENOENT') continue; throw error; }
|
|
// Report the filename only: an accidentally introduced secret must not reach CI logs.
|
|
assert(!/https?:\/\/[^\s/]*(?:powerformer\.(?:net|com)|powerformer\.feishu\.cn)(?:[/:]|$)/i.test(content), 'Company endpoint in ' + file);
|
|
if (file === 'shared/tracking-config.json') {
|
|
const config = JSON.parse(content);
|
|
assert.deepEqual(Object.keys(config).sort(), ['geoip', 'host', 'projectId', 'token']);
|
|
assert.equal(config.projectId, 420348); assert.equal(config.host, 'https://us.i.posthog.com');
|
|
assert.equal(config.geoip, true); assert.match(config.token, /^phc_[A-Za-z0-9_]+$/);
|
|
} else assert(!/phc_[A-Za-z0-9]{20,}/.test(content), 'Embedded upstream ingest identifier in ' + file);
|
|
const users = [...content.matchAll(/\/Users\/([\w.-]+)\//g)].map(match => match[1]);
|
|
assert(users.every(name => ['me', 'a', 'someone'].includes(name)), 'Workstation path in ' + file);
|
|
}
|
|
});
|
|
|
|
for (const ref of [undefined, 'migration-review']) test(`source installation clones openmotion ${ref || 'main by default'} and invokes its installer`, { skip: process.platform === 'win32' }, async () => {
|
|
const directory = await mkdtemp(path.join(tmpdir(), 'motion source install '));
|
|
try {
|
|
const bin = path.join(directory, 'bin'), log = path.join(directory, 'git.jsonl');
|
|
await mkdir(bin);
|
|
await writeFile(path.join(bin, 'codex'), '#!/bin/sh\nexit 0\n', { mode: 0o755 });
|
|
await writeFile(path.join(bin, 'git'), `#!${process.execPath}
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
const args = process.argv.slice(2);
|
|
fs.appendFileSync(process.env.MOTION_GIT_LOG, JSON.stringify(args) + '\\n');
|
|
if (args.includes('clone')) {
|
|
const scripts = path.join(args.at(-1), 'scripts');
|
|
fs.mkdirSync(scripts, { recursive: true });
|
|
fs.writeFileSync(path.join(scripts, 'install-motion.command'), '#!/bin/sh\\necho nested-motion-installer\\n');
|
|
}
|
|
`, { mode: 0o755 });
|
|
const destination = path.join(directory, 'selected install');
|
|
const result = spawnSync('bash', [fileURLToPath(new URL('../install.sh', import.meta.url))], {
|
|
encoding: 'utf8', env: { ...process.env, PATH: bin + path.delimiter + process.env.PATH,
|
|
MOTION_GIT_LOG: log, OPENMOTION_INSTALL_DIR: destination, OPENMOTION_REF: ref },
|
|
});
|
|
assert.equal(result.status, 0, result.stderr);
|
|
assert.match(result.stdout, /nested-motion-installer/);
|
|
const calls = (await readFile(log, 'utf8')).trim().split('\n').map(line => JSON.parse(line));
|
|
assert.deepEqual(calls[0], ['-c', 'filter.lfs.process=', '-c', 'filter.lfs.smudge=', '-c', 'filter.lfs.required=false', 'clone', '--depth', '1', '--single-branch', '--branch', ref || 'main', '--', 'https://github.com/nexu-io/openmotion.git', destination]);
|
|
assert.equal(calls.length, 1);
|
|
} finally { await rm(directory, { recursive: true, force: true }); }
|
|
});
|