A package for versioning your next.js application.
What it will do:
- Clones the entire contents of the
src
directory (except pages) for your specified versions to thesrc/versions/<VERSION>/*
directory; - Clones all pages for your specified versions from the
src/pages
path to thesrc/pages/versions/<VERSION>/*
directory; - Clones all pages for your specified versions from the
src/app
path to thesrc/app/versions/<VERSION>/*
directory; - Updates the import paths from src to versioned for pages.
At the moment, the package does not cover all needs.
For example: it does not update the link hrefs to versioned pages, works with files inside src and does not know how to update dynamic imports to versioned.
Overall, this is more of an experiment to see how versioning can be done in a next.js application. If you think this approach is viable - please star it and write about your ideas or wishes in the package's issues or discussions.
In general, I would prefer the build in different branches and subsequent deployment to subdomains. If in your case there is a need for all versions as a single application - please also tell about your case. All your ideas will definitely be processed and thought over!
Install package globally:
npm i @nimpl/versioner -g
Run package:
versioner
Before launching the package, you need to set up the configuration. For this, create a versioner.config.js
file at the root of your next.js application.
Example of a file:
module.exports = {
git: {
token: "example-git-token",
userName: "vordgi",
projectName: "nimpl-docs",
},
versionsDir: "versions",
versions: [
{
ref: "ea9ec25870071d1cfa0ea83121a3a5979fa34baa",
version: "0.1.3",
},
],
aliases: {
"@/*": ["./src/*"],
},
};
git.token
- personal access token for the github project;
git.userName
and git.project
- user name and project key in github;
versionsDir
- the subpath into which versions will be recorded;
versions
- the list of versions for which files need to be cloned;
versions[number].ref
- the commit hash or branch of the required version;
versions[number].version
- version key, by which files will be saved;
aliases
- object of aliases for automatic import replacement.