Skip to content

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:

OptionDescription
bumpResultBumpResultTruthy, the result of bump(): publishes the bumped packages
registry, registriesThe registry, and the additional registries
tagThe 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
buildCmdCommand run before publishing
tokenRegistry token, for npm, pnpm and bun
skipExistingVersionsSkips the versions already on the registry instead of failing
checkWorkspaceDependenciesOverrides publish.checkWorkspaceDependencies
safetyCheckfalse skips the registry access check
argsOverrides publish.args
packageManagerOverrides publish.packageManager
safetyCheckTimeoutOverrides publish.safetyCheckTimeout
force, suffixWithout 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))
}

See Also ​