publish()
Publish the packages to npm or another registry from Node.js with publish(), with registry checks, build command, dist-tag and dependency order.
ts
function publish(options?: Partial<PublishOptions>): Promise<PublishResponse | undefined>publish() runs relizy publish: it checks the registry access and the workspace: dependencies, runs the build command when one is set, and publishes the public packages in dependency order. It returns { publishedPackages }, or undefined when there is no package to publish. With onProgress, each package is followed live (step:item) and the publish step gives the status of each one (published, skipped, failed) as data.
Options
The flags of relizy publish, camelCased, and the shared options. Each overrides its publish config option:
| Option | Description |
|---|---|
bumpResult | BumpResultTruthy, the result of bump(): publishes the bumped packages |
registry, registries | The registry, and the additional registries |
tag | The dist-tag: latest for a stable version, next for a prerelease by default |
access, otp | 'public' or 'restricted', and the one-time password of the registry |
onOtp | ({ registry, packageName }) => string | Promise<string>: gives the one-time password the registry asks for, instead of the prompt (asked once per registry). An empty password cancels the publish (a RelizyCancelError; the packages already published stay published), an error it throws fails it |
buildCmd | Command run before publishing |
token | Registry token, for npm, pnpm and bun |
skipExistingVersions | Skips the versions already on the registry instead of failing |
checkWorkspaceDependencies | Overrides publish.checkWorkspaceDependencies |
safetyCheck | false skips the registry access check |
args | Overrides publish.args |
packageManager | Overrides publish.packageManager |
safetyCheckTimeout | Overrides publish.safetyCheckTimeout |
force, suffix | Without bumpResult, as for bump() |
See PublishOptions.
Examples
ts
import { bump, publish } from 'relizy'
const bumpResult = await bump({ yes: true })
if (bumpResult.bumped) {
const response = await publish({ bumpResult, tag: 'next', buildCmd: 'pnpm build' })
console.log(response?.publishedPackages.map(pkg => pkg.name))
}