mirror of
https://github.com/whyour/qinglong.git
synced 2026-12-01 01:39:52 +08:00
feat(cron): expose run receipts and modularize execution
Return committed trigger IDs and add CLI wait and trigger-specific logs while preserving API, CLI, transaction, deduplication and unknown-result semantics. Move scheduling, lifecycle, settlement, queries and legacy adapters into back/cron; remove obsolete internal import paths and circular dependencies. Apply project formatting across the repository, cover CJS/MJS in formatting hooks, add prettier:check and require formatting checks in AGENTS.md. Validation: backend build; 1398 backend/frontend tests passed (17 platform skips); 327 CLI tests passed (6 platform skips); 670 files pass format checks.
This commit is contained in:
1 parent
77ece406ac
commit
c5458596c8
346 files changed
+32133
-11556
No files matched your search
@@ -6,38 +6,87 @@ const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
|
||||
test('Commander adapter preserves literal values, option polarity, duplicate errors and IDs', () => {
|
||||
assert.equal(parse(['task','list','--search','00123']).values.search, '00123');
|
||||
assert.equal(parse(['local','start','--no-startup'], 'local').values['no-startup'], true);
|
||||
assert.equal(parse(['local','start'], 'local').values['no-startup'], undefined);
|
||||
assert.equal(parse(['auth','login','--url=--json']).values.url, '--json');
|
||||
assert.deepEqual(parse(['local','resetpwd','--','-literal'], 'local').positionals, ['-literal']);
|
||||
assert.equal(
|
||||
parse(['task', 'list', '--search', '00123']).values.search,
|
||||
'00123',
|
||||
);
|
||||
assert.equal(
|
||||
parse(['local', 'start', '--no-startup'], 'local').values['no-startup'],
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
parse(['local', 'start'], 'local').values['no-startup'],
|
||||
undefined,
|
||||
);
|
||||
assert.equal(parse(['auth', 'login', '--url=--json']).values.url, '--json');
|
||||
assert.deepEqual(
|
||||
parse(['local', 'resetpwd', '--', '-literal'], 'local').positionals,
|
||||
['-literal'],
|
||||
);
|
||||
for (const args of [
|
||||
['task','list','--search','--json'], ['auth','login','--url','--json'],
|
||||
['task','list','-p','2','--page','3'], ['task','list','--json','--json'],
|
||||
['--json','task','list','--json'], ['task','list','unexpected'],
|
||||
['task','run','0'], ['task','run','script.js'], ['task','list','--size','201'],
|
||||
['task','list','--json=false'],
|
||||
]) assert.throws(() => parse(args), { exitCode:2 }, JSON.stringify(args));
|
||||
assert.ok(parse(['auth','login','--help']).help);
|
||||
['task', 'list', '--search', '--json'],
|
||||
['auth', 'login', '--url', '--json'],
|
||||
['task', 'list', '-p', '2', '--page', '3'],
|
||||
['task', 'list', '--json', '--json'],
|
||||
['--json', 'task', 'list', '--json'],
|
||||
['task', 'list', 'unexpected'],
|
||||
['task', 'run', '0'],
|
||||
['task', 'run', 'script.js'],
|
||||
['task', 'list', '--size', '201'],
|
||||
['task', 'list', '--json=false'],
|
||||
])
|
||||
assert.throws(() => parse(args), { exitCode: 2 }, JSON.stringify(args));
|
||||
assert.ok(parse(['auth', 'login', '--help']).help);
|
||||
assert.ok(parse(['--help']).help);
|
||||
});
|
||||
|
||||
test('Commander task parsing stops at the script and preserves the execution separator', () => {
|
||||
const args = ['--root','/isolated','--json','script.sh','now','--','--json','--root','-literal'];
|
||||
const args = [
|
||||
'--root',
|
||||
'/isolated',
|
||||
'--json',
|
||||
'script.sh',
|
||||
'now',
|
||||
'--',
|
||||
'--json',
|
||||
'--root',
|
||||
'-literal',
|
||||
];
|
||||
const parsed = parseExecution(args);
|
||||
assert.equal(parsed.values.root, '/isolated');
|
||||
assert.equal(parsed.values.json, true);
|
||||
assert.deepEqual(parsed.execution.scriptArgs, ['--json','--root','-literal']);
|
||||
assert.deepEqual(parseExecution(['script.sh','--json']).execution.argv, ['script.sh','--json']);
|
||||
assert.deepEqual(parseExecution(['--','-script','--','-x']).execution.scriptArgs, ['-x']);
|
||||
assert.throws(() => parseExecution(['--root','--json','script.sh']), { exitCode:2 });
|
||||
assert.deepEqual(parsed.execution.scriptArgs, [
|
||||
'--json',
|
||||
'--root',
|
||||
'-literal',
|
||||
]);
|
||||
assert.deepEqual(parseExecution(['script.sh', '--json']).execution.argv, [
|
||||
'script.sh',
|
||||
'--json',
|
||||
]);
|
||||
assert.deepEqual(
|
||||
parseExecution(['--', '-script', '--', '-x']).execution.scriptArgs,
|
||||
['-x'],
|
||||
);
|
||||
assert.throws(() => parseExecution(['--root', '--json', 'script.sh']), {
|
||||
exitCode: 2,
|
||||
});
|
||||
});
|
||||
|
||||
test('Commander is bundled once with its license and has no external runtime resolution', () => {
|
||||
const manifest = require('../../package.json');
|
||||
assert.equal(manifest.devDependencies.commander, '15.0.0');
|
||||
assert.equal(Object.keys(manifest.dependencies || {}).length, 0);
|
||||
const bundled = fs.readFileSync(path.join(__dirname,'../../dist/shared/cli/commander.js'), 'utf8');
|
||||
const bundled = fs.readFileSync(
|
||||
path.join(__dirname, '../../dist/shared/cli/commander.js'),
|
||||
'utf8',
|
||||
);
|
||||
assert.doesNotMatch(bundled, /require\(["']commander["']\)/);
|
||||
assert.match(fs.readFileSync(path.join(__dirname,'../../dist/licenses/commander-LICENSE'), 'utf8'), /MIT/);
|
||||
assert.match(
|
||||
fs.readFileSync(
|
||||
path.join(__dirname, '../../dist/licenses/commander-LICENSE'),
|
||||
'utf8',
|
||||
),
|
||||
/MIT/,
|
||||
);
|
||||
});
|
||||
@@ -82,11 +82,7 @@ test('maintenance log banners honor Chinese fallback and English selection', asy
|
||||
});
|
||||
|
||||
test('standalone entry help supports both languages without panel or repository setup', () => {
|
||||
for (const entry of [
|
||||
'runner',
|
||||
'compat',
|
||||
'subscription-worker',
|
||||
]) {
|
||||
for (const entry of ['runner', 'compat', 'subscription-worker']) {
|
||||
for (const language of ['en', 'zh']) {
|
||||
const result = spawnSync(
|
||||
process.execPath,
|
||||
@@ -113,7 +109,9 @@ test('standalone entry help supports both languages without panel or repository
|
||||
test('task, maintenance and subscription failure warnings honor locale without failing completed work', async (t) => {
|
||||
const { LocalApi } = require('../../dist/internal/runtime/api');
|
||||
const { executeTask } = require('../../dist/internal/execution/taskRunner');
|
||||
const { syncRepository } = require('../../dist/internal/subscription/subscriptionRunner');
|
||||
const {
|
||||
syncRepository,
|
||||
} = require('../../dist/internal/subscription/subscriptionRunner');
|
||||
const { withOperationOutput } = require('../../dist/internal/runtime/output');
|
||||
const { execFileSync } = require('node:child_process');
|
||||
const git = process.platform === 'darwin' ? '/usr/bin/git' : 'git';
|
||||
|
||||
Reference in new issue
Block a user