From 3bac0e275d3c5c86d15e27326ce255e2ffc115f0 Mon Sep 17 00:00:00 2001 From: Kanad Gupta Date: Thu, 14 Sep 2023 16:02:09 -0500 Subject: [PATCH] chore: pr feedback Co-Authored-By: Jon Ursenbach --- src/cmds/categories/index.ts | 2 +- src/cmds/logout.ts | 2 +- src/cmds/oas.ts | 2 +- src/cmds/openapi/index.ts | 4 ++-- src/cmds/versions/delete.ts | 2 +- src/cmds/versions/index.ts | 2 +- src/cmds/whoami.ts | 2 +- src/index.ts | 6 +++--- src/lib/baseCommand.ts | 8 ++++---- src/lib/createGHA/index.ts | 6 +++--- src/lib/prompts.ts | 4 ++-- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/cmds/categories/index.ts b/src/cmds/categories/index.ts index 7fed9eb1e..492e54907 100644 --- a/src/cmds/categories/index.ts +++ b/src/cmds/categories/index.ts @@ -16,7 +16,7 @@ export default class CategoriesCommand extends Command { this.args = [this.getKeyArg(), this.getVersionArg()]; } - async run(opts: AuthenticatedCommandOptions<{}>) { + async run(opts: AuthenticatedCommandOptions) { await super.run(opts); const { key, version } = opts; diff --git a/src/cmds/logout.ts b/src/cmds/logout.ts index 4f6d93640..00b99cc9c 100644 --- a/src/cmds/logout.ts +++ b/src/cmds/logout.ts @@ -16,7 +16,7 @@ export default class LogoutCommand extends Command { this.args = []; } - async run(opts: ZeroAuthCommandOptions<{}>) { + async run(opts: ZeroAuthCommandOptions) { await super.run(opts); if (configStore.has('email') && configStore.has('project')) { diff --git a/src/cmds/oas.ts b/src/cmds/oas.ts index 889e5a388..9fdc57677 100644 --- a/src/cmds/oas.ts +++ b/src/cmds/oas.ts @@ -16,7 +16,7 @@ export default class OASCommand extends Command { this.args = []; } - async run(opts: ZeroAuthCommandOptions<{}>) { + async run(opts: ZeroAuthCommandOptions) { await super.run(opts); const message = [ diff --git a/src/cmds/openapi/index.ts b/src/cmds/openapi/index.ts index edd3da670..f4a6ba6dd 100644 --- a/src/cmds/openapi/index.ts +++ b/src/cmds/openapi/index.ts @@ -1,5 +1,5 @@ import type { AuthenticatedCommandOptions } from '../../lib/baseCommand'; -import type { OpenapiPromptOptions } from '../../lib/prompts'; +import type { OpenAPIPromptOptions } from '../../lib/prompts'; import type { RequestInit, Response } from 'node-fetch'; import chalk from 'chalk'; @@ -319,7 +319,7 @@ export default class OpenAPICommand extends Command { return updateSpec(specId); } - const { option }: { option: OpenapiPromptOptions } = await promptTerminal( + const { option }: { option: OpenAPIPromptOptions } = await promptTerminal( promptHandler.createOasPrompt(apiSettingsBody, parsedDocs, totalPages, getSpecs), ); Command.debug(`selection result: ${option}`); diff --git a/src/cmds/versions/delete.ts b/src/cmds/versions/delete.ts index c44174621..9c7dfe360 100644 --- a/src/cmds/versions/delete.ts +++ b/src/cmds/versions/delete.ts @@ -24,7 +24,7 @@ export default class DeleteVersionCommand extends Command { ]; } - async run(opts: AuthenticatedCommandOptions<{}>) { + async run(opts: AuthenticatedCommandOptions) { await super.run(opts); const { key, version } = opts; diff --git a/src/cmds/versions/index.ts b/src/cmds/versions/index.ts index 3e9c96f70..2b4eb2cad 100644 --- a/src/cmds/versions/index.ts +++ b/src/cmds/versions/index.ts @@ -33,7 +33,7 @@ export default class VersionsCommand extends Command { ]; } - async run(opts: AuthenticatedCommandOptions<{}>) { + async run(opts: AuthenticatedCommandOptions) { await super.run(opts); const { key, version } = opts; diff --git a/src/cmds/whoami.ts b/src/cmds/whoami.ts index c3e0fc7ab..c1191af4f 100644 --- a/src/cmds/whoami.ts +++ b/src/cmds/whoami.ts @@ -18,7 +18,7 @@ export default class WhoAmICommand extends Command { this.args = []; } - async run(opts: ZeroAuthCommandOptions<{}>) { + async run(opts: ZeroAuthCommandOptions) { await super.run(opts); const { email, project } = getCurrentConfig(); diff --git a/src/index.ts b/src/index.ts index aad0bb4e1..200c4926f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -83,7 +83,7 @@ export default function rdme(rawProcessArgv: NodeJS.Process['argv']) { } try { - let cmdArgv: CommandOptions<{}> | CommandLineOptions; + let cmdArgv: CommandOptions | CommandLineOptions; let bin: Command; // Handling for `rdme help` and `rdme help ` cases. @@ -135,9 +135,9 @@ export default function rdme(rawProcessArgv: NodeJS.Process['argv']) { cmdArgv = { key, ...cmdArgv }; - return bin.run(cmdArgv as CommandOptions<{}>).then((msg: string) => { + return bin.run(cmdArgv as CommandOptions).then((msg: string) => { if (bin.supportsGHA) { - return createGHA(msg, bin.command, bin.args, cmdArgv as CommandOptions<{}>); + return createGHA(msg, bin.command, bin.args, cmdArgv as CommandOptions); } return msg; }); diff --git a/src/lib/baseCommand.ts b/src/lib/baseCommand.ts index f6c7af221..bc00dc829 100644 --- a/src/lib/baseCommand.ts +++ b/src/lib/baseCommand.ts @@ -10,14 +10,14 @@ import isCI from './isCI'; import { debug, info, warn } from './logger'; import loginFlow from './loginFlow'; -export type CommandOptions = ZeroAuthCommandOptions | AuthenticatedCommandOptions; +export type CommandOptions = ZeroAuthCommandOptions | AuthenticatedCommandOptions; -export type AuthenticatedCommandOptions = Omit, 'key'> & { +export type AuthenticatedCommandOptions = Omit, 'key'> & { key: string; version?: string; }; -export type ZeroAuthCommandOptions = T & { +export type ZeroAuthCommandOptions = T & { github?: boolean; } & { key?: never }; @@ -88,7 +88,7 @@ export default class Command { */ args!: OptionDefinition[]; - async run(opts: CommandOptions<{}>): Promise { + async run(opts: CommandOptions): Promise { Command.debug(`command: ${this.command}`); Command.debug(`opts: ${JSON.stringify(opts)}`); diff --git a/src/lib/createGHA/index.ts b/src/lib/createGHA/index.ts index 32edd5f19..21cb6a018 100644 --- a/src/lib/createGHA/index.ts +++ b/src/lib/createGHA/index.ts @@ -48,7 +48,7 @@ export const getGHAFileName = (fileName: string) => { * Returns a redacted `key` if the current command uses authentication. * Otherwise, returns `false`. */ -function getKey(args: OptionDefinition[], opts: CommandOptions<{}>): string | false { +function getKey(args: OptionDefinition[], opts: CommandOptions): string | false { if (args.some(arg => arg.name === 'key')) { return `••••••••••••${opts.key?.slice(-5) || ''}`; } @@ -61,7 +61,7 @@ function getKey(args: OptionDefinition[], opts: CommandOptions<{}>): string | fa function constructCmdString( command: keyof typeof commands, args: OptionDefinition[], - opts: CommandOptions<{}>, + opts: CommandOptions, ): string { const optsString = args .sort(arg => (arg.defaultOption ? -1 : 0)) @@ -153,7 +153,7 @@ export default async function createGHA( msg: string, command: keyof typeof commands, args: OptionDefinition[], - opts: CommandOptions<{}>, + opts: CommandOptions, ) { debug(`running GHA onboarding for ${command} command`); debug(`opts used in createGHA: ${JSON.stringify(opts)}`); diff --git a/src/lib/prompts.ts b/src/lib/prompts.ts index 502158860..5f3ea676d 100644 --- a/src/lib/prompts.ts +++ b/src/lib/prompts.ts @@ -13,7 +13,7 @@ interface Spec { title: string; } -export type OpenapiPromptOptions = 'create' | 'update'; +export type OpenAPIPromptOptions = 'create' | 'update'; type SpecList = Spec[]; @@ -117,7 +117,7 @@ export function createOasPrompt( { title: 'Update existing', value: 'update' }, { title: 'Create a new spec', value: 'create' }, ], - async format(picked: OpenapiPromptOptions) { + async format(picked: OpenAPIPromptOptions) { if (picked === 'update') { const { specId }: { specId: string } = await promptTerminal( updateOasPrompt(specList, parsedDocs, 1, totalPages, getSpecs),