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

improve Upgrade command so -t accepts any string #1270

Merged
merged 7 commits into from
Oct 8, 2020

Conversation

thedavidprice
Copy link
Contributor

Previously the --tag option only accepted canary or rc. This PR allows user to pass any string as a tag option, which means you can now specific versions e.g. yarn rw upgrade -t 0.19.2-canary.37

I've updated the option description to the following:

Upgrade all @redwoodjs packages via interactive CLI

Options:
  --help         Show help                                             [boolean]
  --version      Show version number                                   [boolean]
  --dry-run, -d  Check for outdated packages without upgrading         [boolean]
  --tag, -t      [choices: "canary", "rc", or specific-version] WARNING:
                 "canary" and "rc" tags are unstable releases!          [string]

@thedavidprice
Copy link
Contributor Author

@jtoar I was hoping to find a way for yargs to suggest choices and also allow a string. No such luck. As you see here I'm now allowing user to pass any string. And I'm attempting to give good guidance via the description.

  • Is this still clear?
  • Any other Yargs ideas about how better to handle this?

@jtoar
Copy link
Contributor

jtoar commented Oct 5, 2020

@thedavidprice I think it's clear; here's a few thoughts:

  • In the description, provide an example of what a specific-version would look like, like the one you provided in your first comment: 0.19.2-canary.37, just to give people an idea of what goes
  • And/or link to where you can find specific-versions: https://www.npmjs.com/package/create-redwood-app (is that the right link?)
  • I need to try this first, but the options object takes a coerce property we could probably use (src: https://yargs.js.org/docs/#api-reference-coercekey-fn). It looks like we could check the specific-version against a regex and throw if it's incorrect. I'll try this locally to see if works. It'd be something like...
    .option('tag', {
      alias: 't',
      description:
        '[choices: "canary", "rc", or specific-version] WARNING: "canary" and "rc" tags are unstable releases!',
      type: 'string',
+     coerce('tag', (arg) => {
+       ...check to see if arg is a valid specific-version string
+     })
    })

@thedavidprice
Copy link
Contributor Author

@jtoar Updated copy and added example. New output:

Upgrade all @redwoodjs packages via interactive CLI

Options:
  --help         Show help                                             [boolean]
  --version      Show version number                                   [boolean]
  --dry-run, -d  Check for outdated packages without upgrading         [boolean]
  --tag, -t      [choices: "canary", "rc", or specific-version (see example
                 below)] WARNING: "canary" and "rc" tags are unstable releases!
                                                                        [string]

Examples:
  rw upgrade -t 0.20.1-canary.5  Specify a version. URL for Version History:
                                 https://www.npmjs.com/package/@redwoodjs/core

Thoughts?

@Tobbe
Copy link
Member

Tobbe commented Oct 6, 2020

This is great! Was looking for something like this the other day when I wanted to upgrade an old RW project to a newer version, but not the latest. So hoping this means something like this would also work yarn rw upgrade -t 0.18.0

@thedavidprice thedavidprice added this to the Next release milestone Oct 8, 2020
@thedavidprice
Copy link
Contributor Author

@jtoar @dac09
I'm merging this as is to get it in main. You both had some ideas about possible constraints, which could be helpful but likely aren't urgent. Anyway, please do a follow-up PR as needed.

@thedavidprice thedavidprice merged commit e69bb0b into main Oct 8, 2020
@thedavidprice thedavidprice deleted the dsp-change-upgrade-tag-string branch October 8, 2020 06:04
@dac09
Copy link
Collaborator

dac09 commented Oct 8, 2020

@thedavidprice @jtoar added validation in #1304

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants