Skip to content

cloudratha/onerepo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Onerepo

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.

Requirements

Node >= 6.4.0

Installation

Install as a global node dependency from git (instead of NPM).

npm install -g git+ssh://git@github.com:cloudratha/onerepo.git

Usage

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.

Package Dependencies

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"
  }
}

Commands

npm run repo [args]

Bootstrap

Recursively runs through all the packages and installs all the package dependencies. Safe to run at any stage during development.

repo boot --[flags]

Run

Recursively runs through each package and executes npm scripts.

repo run [command] --[flags]

Publish

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]

Flags

There are a few helper flags:

Scope

Will run the command in context of the specific package.

--scope=[package-name]

No-Boot (Publish Only)

When publishing you can add the flag to prevent re-booting the packages.

repo publish --no-boot

No-NPM (Publish Only)

When publishing you can add the flag to prevent publishing to NPM.

repo publish --no-npm

No-GIT (Publish Only)

When publishing you can add the flag to prevent commiting to GIT.

repo publish --no-git

Verbose

Show verbose logging in the CLI

-v

About

One repo to rule them all, and in the npm, bind them.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published