2024-03-13 08:37:18 -05:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2024-07-27 04:09:15 -05:00
|
|
|
import { execa } from 'execa';
|
|
|
|
import { writeFileSync, existsSync } from "node:fs";
|
2023-11-22 02:08:56 -06:00
|
|
|
|
2024-07-27 04:09:15 -05:00
|
|
|
async function main() {
|
|
|
|
if (!process.argv.includes('--no-build')) {
|
|
|
|
await execa('pnpm', ['run', 'build'], {
|
|
|
|
stdout: process.stdout,
|
|
|
|
stderr: process.stderr,
|
|
|
|
});
|
|
|
|
}
|
2023-11-22 02:08:56 -06:00
|
|
|
|
2024-07-27 04:09:15 -05:00
|
|
|
if (!existsSync('./built')) {
|
|
|
|
throw new Error('`built` directory does not exist.');
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @type {import('../src/config.js')} */
|
|
|
|
const { loadConfig } = await import('../built/config.js');
|
|
|
|
|
|
|
|
/** @type {import('../src/server/api/openapi/gen-spec.js')} */
|
|
|
|
const { genOpenapiSpec } = await import('../built/server/api/openapi/gen-spec.js');
|
|
|
|
|
|
|
|
const config = loadConfig();
|
|
|
|
const spec = genOpenapiSpec(config, true);
|
|
|
|
|
|
|
|
writeFileSync('./built/api.json', JSON.stringify(spec), 'utf-8');
|
|
|
|
}
|
|
|
|
|
|
|
|
main().catch(e => {
|
|
|
|
console.error(e);
|
|
|
|
process.exit(1);
|
|
|
|
});
|