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: upgrade oclif to v2 #161

Merged
merged 9 commits into from
May 23, 2023
Merged

chore: upgrade oclif to v2 #161

merged 9 commits into from
May 23, 2023

Conversation

thomaswhyyou
Copy link
Contributor

@thomaswhyyou thomaswhyyou commented May 23, 2023

Description

Oclif, the cli framework library we use, had a major version bump to v2 earlier this year.

It included a few breaking changes, which are explained in the migration guide here: https://github.com/oclif/core/blob/main/MIGRATION.md

Some notable changes captured in this PR:

  • Args are now configured using Args instead of a list of objects (i.e. similar to how flags are configured).
  • CliUx module is renamed to ux.
  • Some type definitions were removed from the export, so we now add some additional type definitions for Props in base-command.ts.
  • "Global flags" is renamed to "Base flags".

This PR contains no code changes outside of the oclif v2 upgrade.

Tasks

KNO-3195

@@ -6,7 +6,7 @@ import { KnockEnv } from "@/lib/helpers/const";
import { withSpinner } from "@/lib/helpers/request";
import { promptToConfirm } from "@/lib/helpers/ux";

export default class Commit extends BaseCommand {
export default class Commit extends BaseCommand<typeof Commit> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change allows us to type this.props more precisely for each command.

description: Translation.translationRefDescription,
required: true,
}),
};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the main changes in oclif v2. Args are now defined with Args, just like for flags.

required: true,
aliases: ["recipient"],
summary:
"One or more recipient ids for this workflow run, separated by comma.",
multiple: true,
delimiter: ",",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@meryldakin Sooo it turns out oclif v2 added a delimiter option that would parse the string value into an array, which is the same thing we were doing with commaSeparatedStr 😅 (but you have to set multiple: true).

I removed the helper in favor of using the built-in delimiter option, but wanted to give you a heads up!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

totally missed this!! gotcha thanks!

// Global flags are inherited by any command that extends BaseCommand.
static globalFlags = {
// Base flags are inherited by any command that extends BaseCommand.
static baseFlags = {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

globalFlags has been renamed to baseFlags.

const expectedArgs = {
translationRef: undefined,
};
const expectedArgs = {};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears the behavior changed with args when an arg was defined but not provided — before we used to get {arg: undefined} vs nothing at all.

Copy link
Contributor

@brentjanderson brentjanderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 💯

@@ -96,7 +100,7 @@ export default class WorkflowGet extends BaseCommand {
this.log("");

if (workflow.steps.length === 0) {
return CliUx.ux.log(" This workflow has no steps to display.");
return ux.log(" This workflow has no steps to display.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit:

Suggested change
return ux.log(" This workflow has no steps to display.");
return ux.log("This workflow has no steps to display.");

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah the leading space is there intentionally to align the left spacing in the display. Will add a quick comment.

@thomaswhyyou thomaswhyyou merged commit 1242067 into main May 23, 2023
@thomaswhyyou thomaswhyyou deleted the thomas-kno-3195-only-oclif branch May 23, 2023 19:25
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.

3 participants