Skip to content

Commit

Permalink
feat: add script to change patch of doc
Browse files Browse the repository at this point in the history
  • Loading branch information
ldhyen99 committed Dec 19, 2024
1 parent 33ca4f4 commit 146a1b0
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,15 @@ When documentation changes, the repository version should be incremented. Becaus

- PATCH version will be changed when the documentation is updated. It does not mean the code version is updated.
- For example, when a typo is fixed in the documentation, the PATCH version is updated.

To increment the MAJOR or MINOR version, update the `package.json` file in the root directory. Then run the following command to update the documentation version:

```bash
yarn run version:doc
```

To increment the PATCH version, run the following command:

```bash
yarn run version:doc:patch
```
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"version": "lerna version",
"prepare": "husky install",
"lint": "cross-env NODE_OPTIONS=--max-old-space-size=8192 yarn eslint packages",
"version:minor:doc": "node ./scripts/versioning/sync-docs-version.js"
"version:doc": "node ./scripts/versioning/sync-docs-version.js",
"version:doc:patch": "node ./scripts/versioning/update-docs-patch-version.js"
},
"devDependencies": {
"@jest/globals": "^29.7.0",
Expand Down
40 changes: 40 additions & 0 deletions scripts/versioning/update-docs-patch-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const path = require('path');
const { execSync } = require('child_process');

const versions = require(path.resolve(__dirname, '../..', 'documentation/versions.json'));

const getLatestDocVersion = () => {
return versions[0] || '1.0.0';
};

const updateDocVersion = async () => {
try {
const currentVersion = getLatestDocVersion();
console.log('Current doc version:', currentVersion);

// Parse version components
const [major, minor, patch] = currentVersion.split('.').map(Number);

// Create new version with incremented patch
const newVersion = `${major}.${minor}.${patch + 1}`;
console.log(`Updating documentation to version ${newVersion}...`);

try {
// Create new version using docusaurus command
execSync(`cd documentation && npm run docusaurus docs:version ${newVersion}`, {
stdio: 'inherit',
});

console.log('Documentation version updated successfully!');
} catch (error) {
console.error('Error updating documentation version:', error);
process.exit(1);
}
} catch (error) {
console.error('Error in update process:', error);
process.exit(1);
}
};

// Execute the update
updateDocVersion();

0 comments on commit 146a1b0

Please sign in to comment.