Skip to content

Commit

Permalink
copy json schema on build
Browse files Browse the repository at this point in the history
  • Loading branch information
m4ttheweric committed Nov 5, 2024
1 parent 090cdcc commit b3ece53
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
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);
}

0 comments on commit b3ece53

Please sign in to comment.