This project is a relatively-simplified approach to publishing multiple NPM packages from a monorepo. It handles these use cases:
monopub version
. This will modify each of the
sub-project package.json files and add them to the pending git commit that
npm version
creates.monopub delete devDependencies,scripts
.monopub exec 'npm publish'
.--private
.npm install @cto.af/monopub
Usage: monopub [options] [command]
Options:
--cwd <directory> Operate from given directory (default: cwd)
-h, --help display help for command
-p, --packages <glob> Glob to find names of sub-package directories. Can be
specified multiple times. (default: [])
-P, --private Include private packages
-V, --version output the version number
Commands:
delete <fields> Delete this set of comma-separated fields from all
package files.
exec <command> Run the given command in a shell for each package
file.
help [command] display help for command
order Output the order in which packages will be processed.
version Update version of all sub-repos to match the root.
Should be called from the npm "version" script.
Usage: monopub delete [options] <fields>
Delete this set of comma-separated fields from all package files.
Options:
-h, --help display help for command
Global Options:
--cwd <directory> Operate from given directory (default: cwd)
-p, --packages <glob> Glob to find names of sub-package directories. Can be
specified multiple times. (default: [])
-P, --private Include private packages
-V, --version output the version number
Usage: monopub exec [options] <command>
Run the given command in a shell for each package file.
Options:
-h, --help display help for command
Global Options:
--cwd <directory> Operate from given directory (default: cwd)
-p, --packages <glob> Glob to find names of sub-package directories. Can be
specified multiple times. (default: [])
-P, --private Include private packages
-V, --version output the version number
Usage: monopub order [options]
Output the order in which packages will be processed.
Options:
-h, --help display help for command
Global Options:
--cwd <directory> Operate from given directory (default: cwd)
-p, --packages <glob> Glob to find names of sub-package directories. Can be
specified multiple times. (default: [])
-P, --private Include private packages
-V, --version output the version number
Usage: monopub version [options]
Update version of all sub-repos to match the root. Should be called from the
npm "version" script.
Options:
-h, --help display help for command
Global Options:
--cwd <directory> Operate from given directory (default: cwd)
-p, --packages <glob> Glob to find names of sub-package directories. Can be
specified multiple times. (default: [])
-P, --private Include private packages
-V, --version output the version number
Full API documentation is available.
Example:
import {MonoRoot} from './index.js';
const m = await new MonoRoot(opts).init();
m.delete(['devDependencies', 'scripts']);
m.setVersions();
await m.execAll({stdio: 'inherit'}, 'npm publish');
await m.save(true); // True to do git add for changed files