17 lines
688 B
JavaScript
17 lines
688 B
JavaScript
import { execFileSync } from 'node:child_process';
|
|
import { mkdirSync, writeFileSync } from 'node:fs';
|
|
import { dirname, resolve } from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
const backend = resolve(root, '../../backend/api');
|
|
const output = resolve(root, 'src/contracts/delivery-resources.json');
|
|
const contract = execFileSync('go', ['run', './cmd/cli', 'delivery-resource-contract'], {
|
|
cwd: backend,
|
|
encoding: 'utf8',
|
|
});
|
|
JSON.parse(contract);
|
|
mkdirSync(dirname(output), { recursive: true });
|
|
writeFileSync(output, `${contract.trim()}\n`);
|
|
console.log(`已同步后端资源契约:${output}`);
|