mirror of
https://github.com/whyour/qinglong.git
synced 2026-12-01 09:45:36 +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
@@ -10,9 +10,15 @@ test('development launcher preserves cluster loading, decorator metadata and sou
|
||||
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'ql-dev-start-'));
|
||||
t.after(() => fs.rmSync(root, { recursive: true, force: true }));
|
||||
fs.mkdirSync(path.join(root, 'back'));
|
||||
fs.symlinkSync(path.resolve('node_modules'), path.join(root, 'node_modules'), 'dir');
|
||||
fs.symlinkSync(
|
||||
path.resolve('node_modules'),
|
||||
path.join(root, 'node_modules'),
|
||||
'dir',
|
||||
);
|
||||
fs.copyFileSync('back/tsconfig.json', path.join(root, 'back/tsconfig.json'));
|
||||
fs.writeFileSync(path.join(root, 'back/app.ts'), `
|
||||
fs.writeFileSync(
|
||||
path.join(root, 'back/app.ts'),
|
||||
`
|
||||
import 'reflect-metadata';
|
||||
import cluster from 'node:cluster';
|
||||
class Dependency {}
|
||||
@@ -29,18 +35,24 @@ test('development launcher preserves cluster loading, decorator metadata and sou
|
||||
stack: new Error('source location').stack }));
|
||||
process.disconnect!();
|
||||
}
|
||||
`);
|
||||
`,
|
||||
);
|
||||
const config = JSON.parse(fs.readFileSync('nodemon.json', 'utf8'));
|
||||
const [command, ...args] = config.execMap.ts.split(' ');
|
||||
assert.equal(command, 'node');
|
||||
const env = { ...process.env, ...config.env };
|
||||
delete env.NODE_OPTIONS;
|
||||
const result = spawnSync(process.execPath, [...args, 'back/app.ts'], {
|
||||
cwd: root, env, encoding: 'utf8', timeout: 20000,
|
||||
cwd: root,
|
||||
env,
|
||||
encoding: 'utf8',
|
||||
timeout: 20000,
|
||||
});
|
||||
assert.ifError(result.error);
|
||||
assert.equal(result.status, 0, result.stdout + result.stderr);
|
||||
const output = JSON.parse(result.stdout.split('FIXTURE_RESULT=')[1].split('\n')[0]);
|
||||
const output = JSON.parse(
|
||||
result.stdout.split('FIXTURE_RESULT=')[1].split('\n')[0],
|
||||
);
|
||||
assert.equal(output.value, 42);
|
||||
assert.equal(output.metadata, true);
|
||||
assert.match(output.stack, /back[/\\]app\.ts:\d+:\d+/);
|
||||
@@ -67,16 +79,41 @@ test('startup timing preserves results and failures with timing enabled or disab
|
||||
const value = {};
|
||||
const failure = new Error('startup failed');
|
||||
let calls = 0;
|
||||
assert.equal(await startupStage('success', async () => { calls++; return value; }), value);
|
||||
await assert.rejects(startupStage('failure', async () => { calls++; throw failure; }),
|
||||
(error) => error === failure);
|
||||
await assert.rejects(startupStage('sync-failure', () => { calls++; throw failure; }),
|
||||
(error) => error === failure);
|
||||
assert.equal(
|
||||
await startupStage('success', async () => {
|
||||
calls++;
|
||||
return value;
|
||||
}),
|
||||
value,
|
||||
);
|
||||
await assert.rejects(
|
||||
startupStage('failure', async () => {
|
||||
calls++;
|
||||
throw failure;
|
||||
}),
|
||||
(error) => error === failure,
|
||||
);
|
||||
await assert.rejects(
|
||||
startupStage('sync-failure', () => {
|
||||
calls++;
|
||||
throw failure;
|
||||
}),
|
||||
(error) => error === failure,
|
||||
);
|
||||
assert.equal(calls, 3);
|
||||
assert.equal(logs.length, enabled === '1' ? 3 : 0);
|
||||
if (enabled === '1') {
|
||||
for (const [index, stage] of ['success', 'failure', 'sync-failure'].entries()) {
|
||||
assert.match(logs[index], new RegExp('^\\[boot:timing\\] grpc:' + stage + ' \\d+ms \\(PID: \\d+\\)$'));
|
||||
for (const [index, stage] of [
|
||||
'success',
|
||||
'failure',
|
||||
'sync-failure',
|
||||
].entries()) {
|
||||
assert.match(
|
||||
logs[index],
|
||||
new RegExp(
|
||||
'^\\[boot:timing\\] grpc:' + stage + ' \\d+ms \\(PID: \\d+\\)$',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,18 +121,33 @@ test('startup timing preserves results and failures with timing enabled or disab
|
||||
|
||||
test('frontend gzip assets are enabled for production only', () => {
|
||||
const source = ts.transpileModule(fs.readFileSync('.umirc.ts', 'utf8'), {
|
||||
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
|
||||
compilerOptions: {
|
||||
module: ts.ModuleKind.CommonJS,
|
||||
target: ts.ScriptTarget.ES2020,
|
||||
},
|
||||
}).outputText;
|
||||
for (const mode of ['development', 'production']) {
|
||||
const module = { exports: {} };
|
||||
class Compression { constructor(options) { this.options = options; } }
|
||||
class Compression {
|
||||
constructor(options) {
|
||||
this.options = options;
|
||||
}
|
||||
}
|
||||
new Function('require', 'module', 'exports', 'process', source)(
|
||||
(name) => name === '@umijs/max' ? { defineConfig: (config) => config } : Compression,
|
||||
module, module.exports, { env: { NODE_ENV: mode } },
|
||||
(name) =>
|
||||
name === '@umijs/max'
|
||||
? { defineConfig: (config) => config }
|
||||
: Compression,
|
||||
module,
|
||||
module.exports,
|
||||
{ env: { NODE_ENV: mode } },
|
||||
);
|
||||
const plugins = [];
|
||||
module.exports.default.chainWebpack({ plugin: (name) => ({ use: (plugin) => plugins.push({ name, plugin }) }) });
|
||||
module.exports.default.chainWebpack({
|
||||
plugin: (name) => ({ use: (plugin) => plugins.push({ name, plugin }) }),
|
||||
});
|
||||
assert.equal(plugins.length, mode === 'production' ? 1 : 0);
|
||||
if (mode === 'production') assert.equal(plugins[0].plugin.options.algorithm, 'gzip');
|
||||
if (mode === 'production')
|
||||
assert.equal(plugins[0].plugin.options.algorithm, 'gzip');
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user