feat: integrate XSLT Tools with toolbox portal
This commit is contained in:
33
scripts/generate-toolbox-manifest.mjs
Normal file
33
scripts/generate-toolbox-manifest.mjs
Normal file
@@ -0,0 +1,33 @@
|
||||
import { readFile, writeFile } from 'node:fs/promises';
|
||||
import { dirname, join, resolve } from 'node:path';
|
||||
import process from 'node:process';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { format } from 'prettier';
|
||||
import { toolboxAppDefinition } from '../src/toolboxApp.ts';
|
||||
|
||||
const repositoryRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const packageJson = JSON.parse(
|
||||
await readFile(join(repositoryRoot, 'package.json'), 'utf8')
|
||||
);
|
||||
const manifestPath = join(repositoryRoot, 'public', 'toolbox-app.json');
|
||||
|
||||
if (toolboxAppDefinition.version !== packageJson.version) {
|
||||
throw new Error(
|
||||
`Version mismatch: package.json is ${packageJson.version}, while src/toolboxApp.ts is ${toolboxAppDefinition.version}.`
|
||||
);
|
||||
}
|
||||
|
||||
const output = await format(JSON.stringify(toolboxAppDefinition), {
|
||||
parser: 'json',
|
||||
});
|
||||
|
||||
if (process.argv.includes('--check')) {
|
||||
const existing = await readFile(manifestPath, 'utf8').catch(() => '');
|
||||
if (existing !== output) {
|
||||
throw new Error(
|
||||
'public/toolbox-app.json is out of date. Run `npm run manifest:generate`.'
|
||||
);
|
||||
}
|
||||
} else {
|
||||
await writeFile(manifestPath, output);
|
||||
}
|
||||
Reference in New Issue
Block a user