Skip to main content

@repo-toolkit/publish-all

Build, stage, and publish every package in a monorepo to npm in dependency order.

Install

npm install --save-dev @repo-toolkit/publish-all

CLI

repo-toolkit-publish-all --tag v1.2.3

Run the binary from the monorepo root. The tool locates the root package.json, reads shared metadata (author, bugs, engines, license, repository), then iterates over every package under packages/*, builds it, copies README.md / llms.txt from each package and the configured root files (default LICENSE) into the publish directory, rewrites the package manifest for publish, and runs npm publish.

Flags

FlagDescriptionDefault
--config <path>Config file with publish options (JSON, .mjs, or .cjs default export). CLI flags override config values.
--cwd <path>Monorepo root directoryprocess.cwd()
--tag <version>Target version (required). A leading v is stripped.
--npm-tag <dist-tag>npm dist-taginferred from the prerelease preid
--filter <name>[,<name>]Only publish matching packages (by name or directory). Applied before --from.
--from <name>Start publishing from the first package matching this selector, computed against the post---filter list.
--root-files <file>[,<file>]Files to copy from the monorepo root into each publish dir. Missing files are skipped.['LICENSE']
--publish-dir <path>Publish directory inside each package.dist
--version-placeholder <text>Placeholder rewritten to the target version.0.0.0-PLACEHOLDER
--dry-runForward --dry-run to npm publish.false
-h, --helpShow help

Config File

Use --config when you want repo-specific options without spelling them on the command line. JSON, .mjs, and .cjs (module.exports) configs are all supported; use a JS file when you need non-JSON values.

/** @type {import('@repo-toolkit/publish-all').PublishAllOptions} */
export default {
tag: '1.2.3',
filters: ['changelog'],
rootFiles: ['LICENSE', 'NOTICE'],
publishDir: 'dist',
versionPlaceholder: '0.0.0-PLACEHOLDER',
dryRun: true,
};
repo-toolkit-publish-all --config publish.config.mjs

CLI flags override values from the config file.

JavaScript API

import { publishAll } from '@repo-toolkit/publish-all';

publishAll({
tag: '1.2.3',
cwd: '/path/to/monorepo',
filters: ['changelog'],
rootFiles: ['LICENSE', 'NOTICE'],
publishDir: 'dist',
versionPlaceholder: '0.0.0-PLACEHOLDER',
dryRun: true,
});

Exports

Pure helpers (no filesystem or process side effects):

  • inferNpmTag(version) — derive the npm dist-tag from a version string.
  • createPublishPackageJson(...) — rewrite a package manifest for publish.
  • sortPackagesByInternalDependencies(...) — topologically sort internal packages (throws on cycles).

Pipeline (side-effectful):

  • resolvePublishPlan(options) — resolve a publish plan (reads filesystem) without publishing. Useful for previewing which packages would be selected.
  • publishAll(options) — run the full build + publish pipeline.

Options

OptionTypeDescription
tagstring (required)Target version. A leading v is stripped.
cwdstringMonorepo root directory. Defaults to process.cwd().
npmTagstringnpm dist-tag. Defaults to the prerelease preid.
filtersstring[]Only publish matching packages (by name or directory).
fromstringStart publishing from the first matching package.
rootFilesstring[]Files to copy from the monorepo root into each publish dir. Missing files are skipped. Default: ['LICENSE'].
publishDirstringPublish directory inside each package. Default: dist.
versionPlaceholderstringPlaceholder rewritten to the target version. Default: 0.0.0-PLACEHOLDER.
dryRunbooleanForward --dry-run to npm publish.

Version Placeholders

Dependency ranges set to 0.0.0-PLACEHOLDER are replaced with the target version by default. Override this with versionPlaceholder / --version-placeholder when your workspace uses a different sentinel value.

workspace: ranges on internal packages are resolved to the target version (or kept verbatim when pinned to an explicit version).