NB This experiement was a failure :(
One repo to rule them all, and in the npm, bind them.
Using the monorepo strategy it allows a single source for all the individual packages, hosted with npm.
Originally built to replace lerna, based off this issue lerna/lerna#927.
I needed a tool that could manage multiple packages' dependencies, with strong lock-in rules.
It's been some time since I deemed this a failure, but the main reason was around npm symlinking, which could possibly be fixed now.
Node >= 6.4.0
Install as a global node dependency from git (instead of NPM).
npm install -g git+ssh://[email protected]:cloudratha/onerepo.git
Create a Git Repo and initialise.
Create a config.json
file in the root of the repo.
{
"packages": [
"collection-1/*",
"collection-2/*"
]
}
packages
are the working directorys for your packages scoped from the root.
scope
is the npm user who the packages are published under. You will need to be authenticated with this user when publishing.
Setup the initial packages with their files and include in their package.json
.
Make sure to include the scope in the package name.
repo boot
will allow for the correct use of scoping the project, and can be run at anytime during development.
You will be unable to publish successfully without first committing the changes, as it will attempt to publish new tags.
Onerepo will handle collecting the correct dependencies for your packages. It will either fetch from npm, clone, or symlink packages that require other packages, based on the dependency version.
Onerepo will not do any smart linking on DevDependencies, so if a package is a dependency in another it should be a normal dependency.
If the version is tracking the latest release prefix'd with a caret (^), the package will be symlinked. This allows you to continue in development without needing to publish each change.
{
"name": "package-A",
"version": "3.4.22"
}
{
"name": "package-B",
"version": "2.2.1",
"dependencies": {
"package-A": "^3.4.22"
}
}
If the version is an exact match between the package and dependency, it will clone the package.
{
"name": "package-A",
"version": "3.4.22"
}
{
"name": "package-B",
"version": "2.2.1",
"dependencies": {
"package-A": "3.4.22"
}
}
If the version is lower it will npm install the package
{
"name": "package-A",
"version": "3.4.22"
}
{
"name": "package-B",
"version": "2.2.1",
"dependencies": {
"package-A": "2.4.10"
}
}
npm run repo [args]
Recursively runs through all the packages and installs all the package dependencies. Safe to run at any stage during development.
repo boot --[flags]
Recursively runs through each package and executes npm scripts.
repo run [command] --[flags]
Recursively run through each package to upgrade versions, git tag, and publish to NPM.
By default it will attempt to publish all packages, pass through the scope
flag to target a specific package.
repo publish --[flags]
There are a few helper flags:
Will run the command in context of the specific package.
--scope=[package-name]
When publishing you can add the flag to prevent re-booting the packages.
repo publish --no-boot
When publishing you can add the flag to prevent publishing to NPM.
repo publish --no-npm
When publishing you can add the flag to prevent commiting to GIT.
repo publish --no-git
Show verbose logging in the CLI
-v