A tool for managing JavaScript projects with multiple packages.
- Login to NPM (via your CLI)
- Clone this repository (pull latest changes)
-
This will use the merna audit command as an example
-
navigate to the command's folder (commands/audit) and run 'npm link'
- This will symlink your merna repo's version of the command for use in the merna cli
- repeat this for every command you want to test
-
navigate to the exported cli core module (core/lerna) and run 'npm link'
- This will symlink the merna cli which allows running newly created and unpublished commands
- This step is only necessary if testing an unpublished command not already handled by a merna cli
-
From the webapi-server repo (or whichever test repo) run 'npm link [command]' for each symlinked command
-
If the core cli module was symlinked, run 'npm link lerna'
-
The commands are now testable and VSCode Debugger can be used with no additional configuration
-
Symlink the merna repo to the monorepo you wish to run Audit over
- View "Debug Merna Commands with npm link" for steps on how to do this
-
The merna Audit command can be run with the following:
-
audit
- This will run the audit over the entire monorepo, but it will not make any changes packages
- If any available audit fixes or errors are found, they are caught and documented in the package dir
- After running "Audit", there are 3 files you can expect to see:
path/to/package/lerna-audit-fixes.txt
- containing any available audit fixespath/to/package/lerna-audit-err.txt
- containing any errors duringpath/to/package/audit.json
-package.json
with hoisted and local dependencies removed- if you wish to apply any of the fixes, rename
audit.json
topackage.json
.- Be sure to keep the copy of your original
package.json
. audit.json
is ONLY there to provide a means of quickly being able to manually apply changes.
- Be sure to keep the copy of your original
- if any dependencies or versions changed, add them back to your original
package.json
before committing any changesaudit --fix
&audit --force-fix
do this for you automatically
- if you wish to apply any of the fixes, rename
-
audit --fix
[RECOMMENDED
]- This will run the audit over the entire monorepo, applying any [non-breaking] fixes where it can.
- Once the audit has finished, navigate to source control and view any changes made in the
package.json
&package-lock.json
-
audit --force-fix
- This will run the audit over the entire monorepo, applying ALL fixes where it can.
- Once the audit has finished, navigate to source control and view any changes made in the
package.json
&package-lock.json
- Be sure to run tests to make sure no breaking changes were introduced
-
- In your CLI, navigate to the directory containing the package[.json] that you wish to publish
- Example "unhoist":
"merna/commands/unhoist/"
- Example "unhoist":
- Checkout the publish-packages branch
git checkout publish-packages
- Rebase from master (resolve any conflicts if necessary)
git rebase -i origin/master
- "Undogfood" all dependencies in the package.json
- To "Undogfood" simply means to replace any dependency paths in the package.json, with its current version
- i.e. "dependencies": {
"@lerna/child-process":"file:../../core/child-process"
,
} - To "undogfood" this, get the version of the package from its package.json
- In this case, we find that "@lerna/child-process" is located in the directory:
merna/core/child-process/
- Upon evaluating the package.json, we find that its current version is at:
3.16.5
- In this case, we find that "@lerna/child-process" is located in the directory:
- Now replace the path, with the version. Your new entry should look like this:
- "dependencies": {
"@lerna/child-process":"3.16.5"
,
}
- i.e. "dependencies": {
- Repeat this process for all dependencies in the package.json
- To "Undogfood" simply means to replace any dependency paths in the package.json, with its current version
- If you're updating a package, make sure to bump the version number in the package.json.
- i.e. merna/unhoist/package.json changes from
"version": "1.0.1"
to"version": "1.0.2"
- i.e. merna/unhoist/package.json changes from
- Commit your changes to the branch
- Publish the package by simply running the following
npm publish