{"id":20397142,"url":"https://github.com/elasticpath/docusaurus-snapshot-version","last_synced_at":"2025-06-24T00:34:54.904Z","repository":{"id":45489676,"uuid":"290242674","full_name":"elasticpath/docusaurus-snapshot-version","owner":"elasticpath","description":"A tool to perform snapshot versioning in Docusaurus V1","archived":false,"fork":false,"pushed_at":"2021-12-10T21:02:56.000Z","size":149,"stargazers_count":1,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-12T01:46:47.181Z","etag":null,"topics":["documentation","docusaurus"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elasticpath.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-25T14:49:23.000Z","updated_at":"2023-03-20T15:48:29.000Z","dependencies_parsed_at":"2022-07-15T06:46:58.945Z","dependency_job_id":null,"html_url":"https://github.com/elasticpath/docusaurus-snapshot-version","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/elasticpath/docusaurus-snapshot-version","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elasticpath%2Fdocusaurus-snapshot-version","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elasticpath%2Fdocusaurus-snapshot-version/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elasticpath%2Fdocusaurus-snapshot-version/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elasticpath%2Fdocusaurus-snapshot-version/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elasticpath","download_url":"https://codeload.github.com/elasticpath/docusaurus-snapshot-version/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elasticpath%2Fdocusaurus-snapshot-version/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261583278,"owners_count":23180641,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["documentation","docusaurus"],"created_at":"2024-11-15T04:11:58.052Z","updated_at":"2025-06-24T00:34:54.867Z","avatar_url":"https://github.com/elasticpath.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## DocusaurusV1-SnapshotVersion\n\nElastic Path uses [Docusaurus - V1](https://docusaurus.io/) for generating documentation site. Docusaurus is a great tool that has been useful in delivering our documentation easily and quickly.\n\nDocusaurus has a versioning feature, which is needed for any software project documentation. The Elastic Path DevOps team found that the versioning feature, which uses a fallback approach, was not sufficient and decided to implement a snapshot approach instead.\n\n## Usage\n\n1. Add this module to your Docusaurus project:\n\n   - Yarn: `yarn add https://github.com/elasticpath/docusaurus-snapshot-version.git --dev`\n   - Npm: `npm install https://github.com/elasticpath/docusaurus-snapshot-version.git --save-dev`\n\n   \u003e **Note**: At the moment, this tool is not published to npm registry. We can add a git repository as a dependency.\n\n2. Run the following command to create a new version from \"next release\" docs.\n\n    ```sh\n    $ ./node_modules/.bin/docusaurus-snapshot-version create --version \u003cversion-number\u003e --siteDir \u003csiteDir\u003e --staticDir \u003cstaticDir\u003e\n    ```\n\n   - `version` - Required. The value of the new version to create, such as `1.1.x` or `2.0.0`.\n\n   - `siteDir` - Optional. The absolute or relative path to the `website` directory of the Docusaurus V1 project. The default value is `.`.\n\n   - `staticDir` - Optional. The name of the static asset directory to be versioned under the `website/static` directory. The option can be repeated multiple times. The default value is an empty array.\n\n## Concepts\n\n### Why was this tool created?\n\nDocusaurus provides a feature for managing versions. It uses [Fallback functionality](https://docusaurus.io/docs/en/versioning#fallback-functionality) when creating new versions of docs. The concept/architecture of a “new version” in Docusaurus V1 has some issues and limitations that make it very difficult to maintain a documentation site that is constantly changing across different versions.\n\n**Assets are not versioned** - Assets include images, which are a part of most documentation sites. Docusaurus does not provide any guidance, conventions, or features for managing assets. There isn't a straightforward way of managing images used in different versions of the documentation.\n\n**Fallback-based versioning is not practical** - A new version of a file is created if and only if the file content has changed from the previous version. The following issues arise:\n\n- When a new version is created, `doc1.md` may not have had any changes compared to the previous version. So, `doc1.md` is not created for the new version, but the `doc1.md` file is included when the new version of the documentation site is built. After the version is created, Docusaurus is not clear about how to make changes to `doc1.md` in the new version when the file wasn't copied to the new version.\n\n- When a file needs a change that affects version `1.0.0` of the site, the change might not be suitable for version `2.0.0`. However, version `2.0.0` uses that file. Docusaurus is not clear about how to resolve this situation.\n\n### How does this tool work?\n\nThis tool was created to solve the problems mentioned above. It provides a new package, `docusaurus-snapshot-version`, for creating new versions. It's a wrapper for the built-in command Docusaurus uses to create new versions.\n\nThe command uses the following conventions for managing static assets:\n\n#### Docs-Specific Static Assets\n\n- All static assets for the \"next release\" are at the root of the `docs/assets/` directory as a flat structure, that is, there are no sub-directories.\n- All static assets for \"versioned docs\" are at the root of the directory `docs/assets/version-\u003cversion-number\u003e/` in a flat structure, that is, there are no sub-directories.\n\n  Ideally, the versioned assets would reside with the versioned documents (i.e. `website/versioned_docs/version-\u003cversion-number\u003e/assets/`), but this cannot be achieved without changing the core logic of Docusaurus V1.\n\n#### Site-Specific Static Assets\n\nSite-specific static asset files are in the `website/static/` directory, and static directories at this location can be versioned.\n\n- If a static directory is versioned for the first time, everything in the static directory is copied into the `\u003cversion-number\u003e` and the `next` (for next release) directories. These new directories are under the same static directory.\n- If a static directory has been versioned before, everything in the `next` directory is copied into the `\u003cnew-version-number\u003e` directory.\n\ne.g. Once `website/static/javadocs` directory is versioned, files from that directory are in the following directories:\n- `website/static/javadocs/next`\n- `website/static/javadocs/\u003cversion-number\u003e`\n\n   \u003e Any subsequent versioning will copy files from \"next\" release (`website/static/javadocs/next`) into the new release (`website/static/javadocs/\u003cnew-version-number\u003e`)\n\nWhen you execute the `docusaurus-snapshot-version` command, the following steps are performed:\n\n1. In the \"next release\" directory:\n\n   - Adds a new line to the end of all `*.md` files.\n   - Adds a new line to the end of the `website/sidebars.json` file\n\n2. Creates a new version in the `website/versioned_docs/` directory by running the following command: `docusaurus-version`\n\n   Because all the Markdown files and the `sidebars.json` file contain a change (the new line), Docusaurus copies all the files from the \"next release\" location to the \"new version\" location.\n\n3. Removes the new lines that were added in step 1 for both the \"next release\" and the \"new version\".\n\n4. Copies all the files from the `docs/assets/` directory (without any sub-directories) into the `docs/assets/version-\u003cnew-version\u003e/` directory.\n\n5. In the `website/versioned_docs/version-\u003cversion-number\u003e/` directory, updates all the documents containing image references to point to the new assets directory created in the previous step.\n\n6. If site-specific static assets are included in the versioning:\n   1. The appropriate directories are generated based on whether the static asset directories have been versioned before or not.\n   2. File path references to the static asset files in the `docs` and `versioned_docs` directories are updated accordingly.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felasticpath%2Fdocusaurus-snapshot-version","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felasticpath%2Fdocusaurus-snapshot-version","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felasticpath%2Fdocusaurus-snapshot-version/lists"}