A barebones bulk NPM publisher.
You can install the CLI from NPM as a devDependency for your project.
npm install mass-publish -D
Then automatically generate mass-publish.json
which will be used as the main configuration. It will also keep track of the last published commit for detecting changes.
npx mass-publish init
{
packages: ["packages/"], // Directories to check for changes
ignoreExtension: [".json"], // Ignore differneces with file extension of a certain type (Optional)
commitMessage: "chore: release new versions", // Commit message on publish
git: { // Git credentials (optional as it should try finding system gitconfig)
name: "DecliningLotus",
email: "[email protected]",
},
commitFrom: "fullsha", // Commit SHA to compare differences from. This is automatically updated on every publish
commitTo: "fullsha", // Commit SHA to compare differences to. Default is the head commit (Optional)
noVerify: false, // Refer to changed command flag
autobump: false, // Refer to bump command flag
yes: false, // Refer to bump command flag
}
Reference: config.ts
These can be saved in a .env
file or through your CI modifying process.env
as secrets.
NPM_TOKEN= //https://docs.npmjs.com/creating-and-viewing-access-tokens
GITHUB_TOKEN= //https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token
mass-publish init
Creates mass-publish.json
with default variables in the root folder.
mass-publish changed
Runs git diff
and lists all packages that have changes made to them.
changed --commit-from=fullgitsha
- Commit SHA to compare differences fromchanged --commit-to=fullgitsha
- Commit SHA to compare differences tochanged --commit-message="commit message"
- Change commit messagechanged --ignore-extension=.js,.ts
- Ignore extensionschanged --packages=./packages
- Package directory
mass-publish bump patch|minor|major|1.0.0
Bumps the package.json
of changed packages. A bump argument must be provided that follows semver.
bump patch --no-verify
- Skips verifying with NPM registry whether the package version isn't taken.bump major --force-publish
- Force bump ALL packages regardless if changed or not.bump 1.2.3 --yes
- Skips confirmation to write the bump changes topackage.json
. Useful in CI.
All previous flags from mass-publish changed
can be also be used.
mass-publish publish patch|minor|major|from-package|1.0.0
Publishes all packages to NPM.
All previous flags from changed
and bump
can be used.
- Use Git to compare the last known mass-publish commit (or custom hash) with the latest commits and determine the changes from the diff.
- Bump packages and validate they are publishable by comparing versions on the NPM registry using package-json.
- Use pacote and libnpmpublish to pack and publish the packages using an async queue.