Fix/apiDocsBuild (#989)
* copy api json to docs * copy api json to docs * improvements * fix web build * mjs > js
This commit is contained in:
3
docs/.gitignore
vendored
3
docs/.gitignore
vendored
@@ -3,6 +3,9 @@ dist/
|
||||
# generated types
|
||||
.astro/
|
||||
|
||||
# generated OpenAPI schema
|
||||
wanderer.openapi.json
|
||||
|
||||
# dependencies
|
||||
node_modules/
|
||||
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
"scripts": {
|
||||
"dev": "astro dev",
|
||||
"start": "astro dev",
|
||||
"build": "astro check && astro build",
|
||||
"sync-openapi": "node scripts/sync-openapi.js",
|
||||
"build": "npm run sync-openapi && astro check && astro build",
|
||||
"preview": "astro preview",
|
||||
"astro": "astro"
|
||||
},
|
||||
|
||||
18
docs/scripts/sync-openapi.js
Normal file
18
docs/scripts/sync-openapi.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import { copyFileSync, existsSync } from 'node:fs';
|
||||
import { dirname, resolve } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const scriptDir = dirname(fileURLToPath(import.meta.url));
|
||||
const docsDir = resolve(scriptDir, '..');
|
||||
const repoDir = resolve(docsDir, '..');
|
||||
|
||||
const source = resolve(repoDir, 'web/static/docs/api/wanderer.openapi.json');
|
||||
const destination = resolve(docsDir, 'wanderer.openapi.json');
|
||||
|
||||
if (!existsSync(source)) {
|
||||
console.error(`OpenAPI schema not found at ${source}. Run the web build first so it can be generated.`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
copyFileSync(source, destination);
|
||||
console.log(`Synced OpenAPI schema to ${destination}`);
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user