Working on multiple related packages? Dependency tree look something like this?
******MyPackageA******
^ ^ ^
| | |
| MyPackageB MyPackageC
| ^
| |
MyPackageD
Allene can help. It keeps your packages in sync across your whole project:
- always use latest versions of your packages
- uniformly update third-party dependencies
- find unused dependencies
This is an alternative to using a monorepo with lerna and yarn workspaces. You get many of the same benefits, but you can continue using a separate repo for each package.
- Install dependencies:
bash
,parallel
,sed
,jq
,Node.js
andNPM
/Yarn
- Get repo:
git clone https://github.com/ariutta/allene.git
- Add
allene
to PATH:export PATH="allene:$PATH"
-
Login:
npm login
oryarn login
(to let Allene know which packages belong to you) -
In an empty directory of your choosing, initialize for your package:
allene init '<your-package-name>'
Your specified package and any of its dependencies that are also yours will be organized like this:
|--node_modules (third-party) |--packages (yours) | |--MyPackageA | | |--package.json | | |--... | |--MyPackageB | | |--package.json | | |--... | |--MyPackageC | | |--package.json | | |--... | |--MyPackageD | | |--package.json | | |--... |--...
You can
cd
into your packages, edit files and git push/pull just like normal. -
Update dependencies:
allene update
-
Find unused dependencies:
allene depcheck
Run allene --help
to see all available commands.
If you have yarn
installed, allene
will use it instead of npm
.
To force usage of npm
, set the ALLENE_PACMAN_CLI
env var:
export ALLENE_PACMAN_CLI="npm"
If you're on the Pvjs team, you can create a dev environment for package @wikipathways/pvjs
:
- Login:
npm login
- Create workspaces structure for package
@wikipathways/pvjs
:ALLENE_PACMAN_CLI="npm"; ../../allene/allene init '@wikipathways/pvjs'
- Update:
ALLENE_PACMAN_CLI="npm"; ../../allene/allene update
- Find unused dependencies:
../../allene/allene depcheck
handle the case where all deps are namespaced or all are not
Do we want to specify rootDirs
for the top-level package.json?
"^1.9 || ^2 || ^2.1.0-beta || ^2.2.0-rc || ^3.0.0"
Get the path to any peerDependencies
keys:
cat npm-ls-out.json | jq 'path(..|.peerDependencies? | select(. != null))'