nlink is a CLI utility to aid linking Node.js projects for development
- wrapper around
- analyzes multi-repo folder to create a map of interdependent projects
- links projects to bring mono-repo powers to multi-repos
- TypeScript friendly
- contextual actions to aid linking during development
The project is in beta phase. PRs are very welcome. As well as issues and suggestions ❤
If something isn't working for you, do raise an issue.
Work in progress:
- Typescript type safe linking
- Scope (wildcard) matching
- Watch mode (link and wait, then unlink on quit)
yarn global add @318h7/nlink
npm install -g @318h7/nlink
You will probably need to run the commands with
nlk [command] Commands: nlk setup Creates project map in the current location nlk link [name] Links project dependencies nlk unlink [name] Uninks project dependencies Options: --help Show help [boolean] --version Show version number [boolean]
To analyze a folder and link all developed projects together:
cd projects/my_multy_repo nlk setup nlk link
The setup command will traverse current directory in search of node projects,
and save a map in the file .nlink.json
Don't be afraid to edit the file manually according to your needs, it's just a plane JSON.
After creating the file it will run
yarn/npm link to register projects for linking.
link command without parameters will link together all developed projects.
Consequent runs of
setup will just prepare the links.
In order to regenerate the projects map:
nlk setup --force
nlink accepts the package name (name field in the package.json) or the folder name where the project is located as a dependency name.
nlink will detect if project is using
yarnas dependency manager and execute the appropriate command.
nlink will also detect if project is using TypeScript and check if any other project dependencies depend on the same package you are trying to link. It will link all related projects, to avoid type errors in case of incompatible type update in related projects.
To setup links for all project dependencies:
cd project_in_question nlk link
Note: If run from a projects that has no dependencies, creates links in all projects that depend on that package:
To link a dependency:
cd depending_project nlk link <dependency>
Note: If run from a project that has no named dependency, will try to link current directory project in the named one.
To link couple of packages:
cd depending_project nlk link <dependency_A> <dependency_B>
To link scoped packages:
cd depending_project nlk link @example/**
Will link all dependencies that have @example scope in the name.
🦄 To link all the dependencies in the multi-repo:
cd <folder with .nlink.json> nlk link