2024-03-13 06:37:18 -07:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2024-07-27 02:09:15 -07:00
|
|
|
import { execa } from 'execa';
|
|
|
|
import { writeFileSync, existsSync } from "node:fs";
|
2023-11-22 00:08:56 -08:00
|
|
|
|
2024-07-27 02:09:15 -07:00
|
|
|
async function main() {
|
|
|
|
if (!process.argv.includes('--no-build')) {
|
|
|
|
await execa('pnpm', ['run', 'build'], {
|
|
|
|
stdout: process.stdout,
|
|
|
|
stderr: process.stderr,
|
|
|
|
});
|
|
|
|
}
|
2023-11-22 00:08:56 -08:00
|
|
|
|
2024-07-27 02:09:15 -07: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);
|
|
|
|
});
|