-
Notifications
You must be signed in to change notification settings - Fork 4
YNU-620: Add a version switcher and lifecycle scripts #97
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # Versioning Guide | ||
|
|
||
| This project uses Docusaurus versioning to manage documentation for different releases of the Yellow Network protocol and SDK. | ||
|
|
||
| ## Structure | ||
|
|
||
| - **`docs/`**: functionality for the **upcoming/current** development version (labeled as "Next" or derived from `package.json`). | ||
| - **`versioned_docs/version-0.5.x/`**: Frozen documentation for the `0.5.x` stable release. | ||
|
|
||
| ## Workflows | ||
|
|
||
| ### 1. Releasing a New Version | ||
|
|
||
| When you are ready to release the current work, this process involves **freezing** the current version (e.g., `0.6.x`) and **creating** the next development version (e.g., `0.7.x`). | ||
|
|
||
| ```bash | ||
| npm run version:release 0.6.x 0.7.x | ||
| ``` | ||
|
|
||
| This single command will: | ||
| 1. Snapshot `docs/` to `versioned_docs/version-0.6.x`. | ||
| 2. Update `package.json` version to `0.7.x` (which updates the "Next" dropdown label). | ||
|
|
||
| ### 2. Updating an Old Version | ||
|
|
||
| To fix a typo or add a note to an old version (e.g., `0.5.x`): | ||
| - Edit the files in `versioned_docs/version-0.5.x/`. | ||
| - **Do not** edit files in `docs/` for old versions; `docs/` is always the *future* version. | ||
|
|
||
| ### 3. Removing an Old Version | ||
|
|
||
| To remove an old version that is no longer supported (e.g., `0.5.x`): | ||
|
|
||
| ```bash | ||
| npm run version:remove 0.5.x | ||
| ``` | ||
| This performs a safe, complete deletion of the version folder and config entry. | ||
|
|
||
| ### 4. Resetting to Single Version | ||
|
|
||
| To delete ALL history and return to a single-version project (e.g., just `0.5.x`): | ||
|
|
||
| ```bash | ||
| npm run version:reset 0.5.x | ||
| ``` | ||
| **Warning**: This deletes all `versioned_docs` folders. You will be left with only the current content in `docs/`, labeled as `0.5.x`. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| const { execSync } = require('child_process'); | ||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
|
|
||
| const versionToFreeze = process.argv[2]; | ||
| const nextDevVersion = process.argv[3]; | ||
|
|
||
| if (!versionToFreeze || !nextDevVersion) { | ||
| console.error('Usage: npm run version:release <version_to_freeze> <next_dev_version>'); | ||
| console.error('Example: npm run version:release 0.5.x 0.6.x'); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| const rootDir = path.resolve(__dirname, '..'); | ||
| const packageJsonPath = path.join(rootDir, 'package.json'); | ||
| const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')); | ||
|
|
||
| // Validation: Ensure the current project version matches the version being frozen. | ||
| // This prevents mistakes like being on 0.5.x but trying to freeze 0.6.x (skipping a version). | ||
| if (pkg.version !== versionToFreeze) { | ||
| console.error(`Error: Version mismatch.`); | ||
| console.error(`You are trying to freeze/release "${versionToFreeze}", but the current project version (in package.json) is "${pkg.version}".`); | ||
| console.error(`Please update package.json to "${versionToFreeze}" first, or check your release arguments.`); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| try { | ||
| // 1. Snapshot the current docs as the frozen version | ||
| console.log(`Freezing current docs as ${versionToFreeze}...`); | ||
| execSync(`npm run docusaurus docs:version ${versionToFreeze}`, { stdio: 'inherit' }); | ||
|
|
||
| // 2. Bump package.json to the new dev version | ||
| console.log(`Creating next version ${nextDevVersion} (updating package.json)...`); | ||
|
|
||
| // Update the version in the already loaded pkg object | ||
| pkg.version = nextDevVersion; | ||
| fs.writeFileSync(packageJsonPath, JSON.stringify(pkg, null, 2)); | ||
|
|
||
| console.log('---------------------------------------------------'); | ||
| console.log(`Release Complete!`); | ||
| console.log(`- Frozen Version: ${versionToFreeze} (saved in versioned_docs/)`); | ||
| console.log(`- Created Next Version: ${nextDevVersion} (active in docs/)`); | ||
|
|
||
| } catch (error) { | ||
| console.error('Release failed:', error.message); | ||
| process.exit(1); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
|
|
||
| const version = process.argv[2]; | ||
|
|
||
| if (!version) { | ||
| console.error('Please provide a version to remove. Usage: npm run version:remove <version>'); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| const rootDir = path.resolve(__dirname, '..'); | ||
| const versionsJsonPath = path.join(rootDir, 'versions.json'); | ||
| const versionedDocsPath = path.join(rootDir, 'versioned_docs', `version-${version}`); | ||
| const versionedSidebarsPath = path.join(rootDir, 'versioned_sidebars', `version-${version}-sidebars.json`); | ||
|
|
||
| console.log(`Removing version ${version}...`); | ||
|
|
||
| // 1. updates versions.json | ||
| if (fs.existsSync(versionsJsonPath)) { | ||
| const versions = JSON.parse(fs.readFileSync(versionsJsonPath, 'utf8')); | ||
| const newVersions = versions.filter(v => v !== version); | ||
| fs.writeFileSync(versionsJsonPath, JSON.stringify(newVersions, null, 2)); | ||
| console.log(`Updated versions.json`); | ||
| } else { | ||
| console.warn(`versions.json not found at ${versionsJsonPath}`); | ||
| } | ||
|
|
||
| // 2. Removes versioned_docs/version-<ver> | ||
| if (fs.existsSync(versionedDocsPath)) { | ||
| fs.rmSync(versionedDocsPath, { recursive: true, force: true }); | ||
| console.log(`Removed ${versionedDocsPath}`); | ||
| } else { | ||
| console.warn(`Versioned docs not found at ${versionedDocsPath}`); | ||
| } | ||
|
|
||
| // 3. Removes versioned_sidebars/version-<ver>-sidebars.json | ||
| if (fs.existsSync(versionedSidebarsPath)) { | ||
| fs.rmSync(versionedSidebarsPath); | ||
| console.log(`Removed ${versionedSidebarsPath}`); | ||
| } else { | ||
| console.warn(`Versioned sidebar not found at ${versionedSidebarsPath}`); | ||
| } | ||
|
|
||
| console.log(`Successfully removed version ${version}.`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
|
|
||
| const targetVersion = process.argv[2]; | ||
|
|
||
| if (!targetVersion) { | ||
| console.error('Usage: npm run version:reset <target_single_version>'); | ||
| console.error('Example: npm run version:reset 0.5.x'); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| const rootDir = path.resolve(__dirname, '..'); | ||
| const versionsJsonPath = path.join(rootDir, 'versions.json'); | ||
| const versionedDocsPath = path.join(rootDir, 'versioned_docs'); | ||
| const versionedSidebarsPath = path.join(rootDir, 'versioned_sidebars'); | ||
| const packageJsonPath = path.join(rootDir, 'package.json'); | ||
|
|
||
| console.log(`WARNING: This will delete ALL historical versions and reset the project to single version '${targetVersion}'.`); | ||
|
|
||
| // 1. Delete versioned folders | ||
| if (fs.existsSync(versionedDocsPath)) { | ||
| fs.rmSync(versionedDocsPath, { recursive: true, force: true }); | ||
| console.log('Removed versioned_docs/'); | ||
| } | ||
|
|
||
| if (fs.existsSync(versionedSidebarsPath)) { | ||
| fs.rmSync(versionedSidebarsPath, { recursive: true, force: true }); | ||
| console.log('Removed versioned_sidebars/'); | ||
| } | ||
|
|
||
| // 2. Delete versions.json | ||
| if (fs.existsSync(versionsJsonPath)) { | ||
| fs.rmSync(versionsJsonPath); | ||
| console.log('Removed versions.json'); | ||
| } | ||
|
|
||
| // 3. Update package.json version | ||
| if (fs.existsSync(packageJsonPath)) { | ||
| const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')); | ||
| pkg.version = targetVersion; | ||
| fs.writeFileSync(packageJsonPath, JSON.stringify(pkg, null, 2)); | ||
| console.log(`Updated package.json version to ${targetVersion}`); | ||
| } | ||
|
|
||
| console.log('---------------------------------------------------'); | ||
| console.log(`Reset Complete. The project is now single-version: ${targetVersion}`); | ||
| console.log('The "Next" version in the dropdown will now show this version.'); | ||
| console.log(''); | ||
| console.log('IMPORTANT: You must manually update docusaurus.config.ts to disable default versioning'); | ||
| console.log('configuration (comment out "lastVersion", "versions", etc.) until you serve a new version.'); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.