Skip to content

Commit

Permalink
refactor: separate auth login arguments into separate types
Browse files Browse the repository at this point in the history
  • Loading branch information
zimeg committed Feb 12, 2025
1 parent 48d54f0 commit d689fa3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/cli-test/src/cli/cli-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export interface SlackCLIGlobalOptions {
verbose?: boolean;
}

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

export type SlackCLICommandOptions = Record<string, string | boolean | number | undefined>;

Expand Down
17 changes: 10 additions & 7 deletions packages/cli-test/src/cli/commands/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,21 @@ import {

import type { ShellProcess } from '../../types/shell';

type AuthLoginNoPromptArguments = SlackCLIHostTargetOptions & Pick<SlackCLIGlobalOptions, 'verbose'>;
type AuthLoginChallengeExchangeArugments = SlackCLIHostTargetOptions & {
/** @description Challenge string extracted from the Slack client UI after submitting the auth slash command. */
challenge: string;
/** @description The `authTicket` output from `loginNoPrompt`; required to complete the login flow. */
authTicket: string;
} & Pick<SlackCLIGlobalOptions, 'verbose'>;

export default {
/**
* `slack login --no-prompt`; initiates a CLI login flow. The `authTicketSlashCommand` returned should be entered
* into the Slack client, and the challenge code retrieved and fed into the `loginChallengeExchange` method to
* complete the CLI login flow.
*/
loginNoPrompt: async function loginNoPrompt(args?: SlackCLIHostTargetOptions): Promise<{
loginNoPrompt: async function loginNoPrompt(args?: AuthLoginNoPromptArguments): Promise<{
/** @description Command output */
output: ShellProcess['output'];
/**
Expand Down Expand Up @@ -57,12 +65,7 @@ export default {
* @returns
*/
loginChallengeExchange: async function loginChallengeExchange(
args: SlackCLIHostTargetOptions & {
/** @description Challenge string extracted from the Slack client UI after submitting the auth slash command. */
challenge: string;
/** @description The `authTicket` output from `loginNoPrompt`; required to complete the login flow. */
authTicket: string;
},
args: AuthLoginChallengeExchangeArugments,
): Promise<string> {
const cmd = new SlackCLIProcess(['login'], args, {
'--no-prompt': true,
Expand Down

0 comments on commit d689fa3

Please sign in to comment.