Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copy json schema on build #762

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs-schema.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"docusaurus": "docusaurus",
"start": "docusaurus start --port 3001 --host 0.0.0.0",
"build": "docusaurus build",
"build": "node ./scripts/build.cjs",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
"clear": "docusaurus clear",
Expand Down
30 changes: 30 additions & 0 deletions scripts/build.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Find the docs JSON file
const path = require('path');
const fs = require('fs');
const execSync = require('child_process').execSync;
const rootDir = path.join(__dirname, '..');

function copyJsonSchema() {
// copy the JSON schema file to the root of the project
const docsDir = path.join(__dirname, '../.docusaurus/docusaurus-plugin-content-docs/default/p');

const docsFile = fs.readdirSync(docsDir).find(file => file.startsWith('docs') && file.endsWith('.json'));

if (!docsFile) {
throw new Error('Could not find the docs JSON file');
}

// copy the docs file to the root of the project
// rename the file to docs-schema.json
fs.copyFileSync(path.join(docsDir, docsFile), path.join(__dirname, '../docs-schema.json'));
}

// execute the docusaurus build:
execSync(`docusaurus build`, { cwd: rootDir, stdio: 'inherit' });

try {
copyJsonSchema();
console.log('\nSuccessfully copied the docs JSON schema file to project root!\n');
} catch (e) {
console.error(e);
}
Loading