Skip to content

feat(cli-test): include a verbose global option for cli commands #2147

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

Merged
merged 4 commits into from
Feb 12, 2025

Conversation

zimeg
Copy link
Member

@zimeg zimeg commented Feb 11, 2025

Summary

This PR adds a verbose option to @slack/cli-test to add additional output information to specific commands.

Preview

    const createOutput = await SlackCLI.create({
      template: 'slack-samples/deno-starter-template',
      branch: 'main',
      appPath,
+     verbose: true
    });

Requirements

@zimeg zimeg added semver:minor pkg:cli-test applies to `@slack/cli-test` labels Feb 11, 2025
@zimeg zimeg added this to the cli-test@2.1.0 milestone Feb 11, 2025
@zimeg zimeg self-assigned this Feb 11, 2025
Copy link

codecov bot commented Feb 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.94%. Comparing base (2874654) to head (d689fa3).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2147   +/-   ##
=======================================
  Coverage   91.93%   91.94%           
=======================================
  Files          38       38           
  Lines       10322    10330    +8     
  Branches      651      652    +1     
=======================================
+ Hits         9490     9498    +8     
  Misses        820      820           
  Partials       12       12           
Flag Coverage Δ
cli-hooks 95.24% <ø> (ø)
cli-test 94.76% <100.00%> (+0.02%) ⬆️
oauth 77.39% <ø> (ø)
socket-mode 61.82% <ø> (ø)
web-api 96.88% <ø> (ø)
webhook 96.65% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Copy link
Contributor

@WilliamBergamin WilliamBergamin left a comment

Choose a reason for hiding this comment

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

lgtm thanks for working on this 💯

@@ -144,6 +146,9 @@ export class SlackCLIProcess {
if (opts.token) {
cmd = cmd.concat(['--token', opts.token]);
}
if (opts.verbose) {
cmd = cmd.concat(['--verbose']);
Copy link
Contributor

Choose a reason for hiding this comment

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

Using concat alines with the syntax of this function and makes it readable, but looking at this line alone made me ask why push was not used instead 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

IIRC push and concat are doing similar things but with different returns and underlying happenings - instead of adding to the existing array, concat creates a new one and returns this as a value while push returns the new length instead 📚 ✨

FWIW I think push is a reasonable substitution, but concat gives me confidence in fewer side effects.

@zimeg
Copy link
Member Author

zimeg commented Feb 11, 2025

@WilliamBergamin and thanks for a fast review!

I'm looking into implementing this in our testing suites now - once I'm feeling good about that I'll merge this and will follow up with a release of @slack/cli-test@2.1.0 🚢 💨

Copy link
Member

@mwbrooks mwbrooks left a comment

Choose a reason for hiding this comment

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

👌🏻 Beauty

Copy link
Member Author

@zimeg zimeg left a comment

Choose a reason for hiding this comment

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

@WilliamBergamin @mwbrooks thank y'all both for the reviews! 🙏 ✨

I made one more change after some findings in local testing that would be helpful to include, but I'm not certain on the approach. If this still looks good I'll plan on merging and following up with a release soon!

}

export type SlackCLIHostTargetOptions = Pick<SlackCLIGlobalOptions, 'qa' | 'dev' | 'apihost'>;
export type SlackCLIHostTargetOptions = Pick<SlackCLIGlobalOptions, 'qa' | 'dev' | 'apihost' | 'verbose'>;
Copy link
Member Author

Choose a reason for hiding this comment

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

📝 This was added to support the login helper commands:

    const { authTicket, authTicketSlashCommand, output } = await SlackCLI.auth.loginNoPrompt({
      apihost,
+     verbose: true,
    });

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not thrilled with having this added to the SlackCLIHostTargetOptions type, but I think it makes sense as a possible argument.

Super open to suggestions here, but will plan on merging this soon-ish otherwise!

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm this does feel off 🤔 Maybe we can rename SlackCLIHostTargetOptions to AuthLoginNoPromptOptions

Or create a new type named AuthLoginNoPromptGlobalOptions that is Pick<SlackCLIGlobalOptions, 'verbose'> and make the args of loginNoPrompt be something like

type AuthLoginNoPromptGlobalOptions = Pick<SlackCLIGlobalOptions, 'verbose'>;
type AuthLoginNoPromptOptions = SlackCLIHostTargetOptions & AuthLoginNoPromptGlobalOptions;

loginNoPrompt: async function loginNoPrompt(args?: AuthLoginNoPromptOptions): Promise<{...

Copy link
Member Author

Choose a reason for hiding this comment

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

@WilliamBergamin Nice call! When making this update I noticed a few other commands have a similar pattern for specific, additional, arguments.

The d689fa3 change creates similar arguments for each of the login helpers, which seems better to me 🎉

Let me know what you think though! I left the logout arguments unchanged, but these don't need to be updated to use verbose 😉

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good 💯 ship it!

Copy link
Contributor

@WilliamBergamin WilliamBergamin left a comment

Choose a reason for hiding this comment

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

Nice 💯 LGTM

@zimeg
Copy link
Member Author

zimeg commented Feb 12, 2025

@WilliamBergamin Sweeeeeeet! Thanks for checking this out again! 🚀

And @mwbrooks thank you too for reviewing this! I'm excited to follow up with our testing improvements and a @slack/cli-test release 🚢 💨

@zimeg zimeg merged commit 9554a5f into main Feb 12, 2025
57 checks passed
@zimeg zimeg deleted the zimeg-feat-cli-test-verbose branch February 12, 2025 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg:cli-test applies to `@slack/cli-test` semver:minor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants