Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(cli): Enable 'next' and 'experimental' tags for rw upgrade #8024

Merged
merged 8 commits into from
Apr 7, 2023
2 changes: 1 addition & 1 deletion docs/docs/cli-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -2043,7 +2043,7 @@ A canary release is published to npm every time a PR is merged to the `main` bra
| Option | Description |
| :-------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--dry-run, -d` | Check for outdated packages without upgrading |
| `--tag, -t` | Choices are "canary", "rc", or a specific version (e.g. "0.19.3"). WARNING: Unstable releases in the case of "canary" and "rc", which will force upgrade packages to the most recent release of the specified tag. |
| `--tag, -t` | Choices are "rc", "canary", "latest", "next", "experimental", or a specific version (e.g. "0.19.3"). WARNING: Unstable releases in the case of "canary", "rc", "next", and "experimental". And "canary" releases include breaking changes often requiring codemods if upgrading a project. |

**Example**

Expand Down
8 changes: 3 additions & 5 deletions packages/cli/src/commands/upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const builder = (yargs) => {
.option('tag', {
alias: 't',
description:
'[choices: "canary", "rc", or specific-version (see example below)] WARNING: "canary" and "rc" tags are unstable releases!',
'[choices: "rc", "canary", "latest", "next", "experimental", or a specific-version (see example below)] WARNING: "canary", "rc" and "experimental" are unstable releases! And "canary" releases include breaking changes often requiring codemods if upgrading a project.',
thedavidprice marked this conversation as resolved.
Show resolved Hide resolved
requiresArg: true,
type: 'string',
coerce: validateTag,
Expand Down Expand Up @@ -67,16 +67,14 @@ const SEMVER_REGEX =
/(?<=^v?|\sv?)(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-(?:0|[1-9]\d*|[\da-z-]*[a-z-][\da-z-]*)(?:\.(?:0|[1-9]\d*|[\da-z-]*[a-z-][\da-z-]*))*)?(?:\+[\da-z-]+(?:\.[\da-z-]+)*)?(?=$|\s)/i
export const validateTag = (tag) => {
const isTagValid =
tag === 'rc' ||
tag === 'canary' ||
tag === 'latest' ||
['rc', 'canary', 'latest', 'next', 'experimental'].includes(tag) ||
SEMVER_REGEX.test(tag)

if (!isTagValid) {
// Stop execution
throw new Error(
c.error(
'Invalid tag supplied. Supported values: rc, canary, latest, or valid semver version\n'
"Invalid tag supplied. Supported values: 'rc', 'canary', 'latest', 'next', 'experimental', or a valid semver version\n"
)
)
}
Expand Down