mirror of
https://github.com/whyour/qinglong.git
synced 2026-12-01 01:39:52 +08:00
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.
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import { readFileSync } from 'fs';
|
|
import path from 'path';
|
|
import { createHash, randomUUID } from 'crypto';
|
|
|
|
function read(filename: string): Buffer | undefined {
|
|
try {
|
|
return readFileSync(filename);
|
|
} catch {
|
|
return undefined;
|
|
}
|
|
}
|
|
|
|
function manifest(): { sourceCommit?: string } {
|
|
try {
|
|
const value = JSON.parse(
|
|
read(path.resolve(__dirname, '../../build-info.json'))?.toString() ||
|
|
'{}',
|
|
);
|
|
return value && typeof value === 'object' ? value : {};
|
|
} catch {
|
|
return {};
|
|
}
|
|
}
|
|
|
|
// Capture before serving requests. Reading the installed files on each request
|
|
// would let an old process claim the identity of a newly copied build.
|
|
const backend = read(path.resolve(__dirname, '../app.js'));
|
|
const root = process.env.QL_DIR || path.resolve(__dirname, '../../..');
|
|
const version = read(path.join(root, 'version.yaml'))
|
|
?.toString()
|
|
.match(
|
|
/^\uFEFF?version:\s*["']?(\d+\.\d+\.\d+(?:-[\w.-]+)?(?:\+[\w.-]+)?)/m,
|
|
)?.[1];
|
|
|
|
export const runtimeBuild = Object.freeze({
|
|
instanceId: randomUUID(),
|
|
parentPid: process.ppid,
|
|
version,
|
|
sourceCommit: manifest().sourceCommit,
|
|
backendSha256: backend
|
|
? createHash('sha256').update(backend).digest('hex')
|
|
: undefined,
|
|
});
|