Files
qinglong/cli/test/integration/architecture.test.cjs
T
whyour 801a71d740 feat(cli): cover OpenAPI with a remote npm CLI and internal panel tools (#3074)
* feat(cli): add unified Commander CLI for QingLong 2.x

* fix(cli): publish via npm and address security review feedback

* ci(cli): package npm artifacts and remove evaluation collateral

* test(cli): use a fixed shell fixture for log retention

* refactor(cli): separate remote npm client from panel tools

* feat(cli): cover active panel OpenAPI resources

* docs(cli): unify authentication and skill guidance

* refactor(cli): isolate internal commands and generate Commander help

* refactor(cli): organize remote and internal modules by responsibility

* ci(cli): publish verified npm archives from master

* fix(cli): publish under the whyour npm scope

* ci: use npm trusted publishing for both packages

* docs: introduce the published CLI on the project homepage

* fix(cli): preserve server log truncation and correct login hints

* fix(cli): accept dashboard record request bodies

* fix(cli): preserve stdin for local task execution

* fix(cli): resolve task executables after changing directory

* fix(cli): preserve shell function tasks and sanitize test failures

* fix(cli): preserve shell hook state and resolve workdir after hooks

* fix(cli): preserve cleanup across shared shell task timeouts

* fix(cli): isolate shell control descriptors and reap timed-out descendants
2026-09-25 23:24:41 +08:00

61 lines
2.0 KiB
JavaScript

const test = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const ts = require('typescript');
const source = path.resolve(__dirname, '../../src');
function files(root) {
return fs.readdirSync(root, { withFileTypes: true }).flatMap((entry) => {
const file = path.join(root, entry.name);
return entry.isDirectory()
? files(file)
: file.endsWith('.ts')
? [file]
: [];
});
}
test('shared, remote and internal dependencies respect their source boundaries', () => {
for (const file of files(source)) {
const owner = path.relative(source, file).split(path.sep)[0];
const allowed = {
shared: ['shared'],
remote: ['remote', 'shared'],
internal: ['internal', 'shared'],
}[owner];
if (!allowed) continue;
const imports = ts.preProcessFile(
fs.readFileSync(file, 'utf8'),
true,
true,
).importedFiles;
for (const imported of imports) {
if (!imported.fileName.startsWith('.')) continue;
const target = path
.relative(source, path.resolve(path.dirname(file), imported.fileName))
.split(path.sep)[0];
assert.ok(
allowed.includes(target),
`${path.relative(source, file)} imports ${imported.fileName}`,
);
}
}
});
test('stable build aliases point to real modules and preserve exported entry functions', () => {
const entries = require('../../scripts/entrypoints.cjs');
for (const [name, entry] of Object.entries(entries)) {
const alias = path.resolve(__dirname, '../../dist', name);
const target = path.resolve(__dirname, '../../dist', entry.module);
assert.ok(fs.statSync(alias).isFile(), name);
assert.ok(fs.statSync(target).isFile(), entry.module);
// Auto-starting entry modules are exercised through child-process integration tests.
if (entry.method)
assert.equal(
require(alias)[entry.method],
require(target)[entry.method],
name,
);
}
});