nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.73k stars 2.37k forks source link

The nx release command doesn't accept the --otp CLI option #28996

Closed SokratisVidros closed 5 hours ago

SokratisVidros commented 18 hours ago

Current Behavior

Running nx release --otp returns an Unknown argument: otp error. As a result, the user is forced to run nx version, changelog, and releasesubcommands independently.

Expected Behavior

The expected behavior is for nx release to allow the specification of CLI arguments for each subcommand. That is --otp to be passed directly to the publish subcommand.

Since other subcommand CLI options have the same name, it is expected for the CLI options to apply to all subcommands. For example, passing --first-release should apply to version, changelog, and `publish.

GitHub Repo

No response

Steps to Reproduce

1.In an NX powered monorepo try pnpm nx publish --otp 123456.

Nx Report

Node           : 20.14.0
OS             : darwin-arm64
Native Target  : aarch64-macos
pnpm           : 9.11.0

nx                 : 20.1.2
lerna              : 5.6.2
@nx/js             : 20.1.2
@nx/jest           : 20.1.2
@nx/eslint         : 20.1.2
@nx/workspace      : 20.1.2
@nx/devkit         : 20.1.2
@nx/eslint-plugin  : 20.1.2
@nx/plugin         : 20.1.2
nx-cloud           : 19.1.0
typescript         : 5.6.2
---------------------------------------
Local workspace plugins:
         @novu/automation

Failure Logs

Package Manager Version

pnpm@9.11.0

Operating System

Additional Information

No response

JamesHenry commented 5 hours ago

Hi @SokratisVidros, I would recommend:

nx release --skip-publish # or let it prompt you and say no
nx release publish --otp=...

The versioning and changelog steps are potentially quite involved when optionally resolving versions from custom registries or manually editing changelogs in an interactive editor is done, so by the time OTP would be consumed it could have easily expired.

In general it is not a design goal of nx release to support all options for all subcommands, because that would scale horribly. --first-release is not a good comparison because it genuinely applies to multiple subcommands, --otp is specific to only publishing.

The alternative recommendation I would have is creating a release.js/release.ts script which you invoke with node/ts-node/tsx etc which leverages our first class programmatic API. You could then take in an --otp arg to your custom script and control how it is passed to await releasePublish({ otp: '...', ... })

Here is an example of using the programmatic API: https://nx.dev/features/manage-releases#using-the-programmatic-api-for-nx-release