Skip to content

Commit

Permalink
chore: pr feedback
Browse files Browse the repository at this point in the history
Co-Authored-By: Jon Ursenbach <[email protected]>
  • Loading branch information
kanadgupta and erunion committed Sep 14, 2023
1 parent b7dfaba commit 3bac0e2
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/cmds/categories/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/cmds/logout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand Down
2 changes: 1 addition & 1 deletion src/cmds/oas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
4 changes: 2 additions & 2 deletions src/cmds/openapi/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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}`);
Expand Down
2 changes: 1 addition & 1 deletion src/cmds/versions/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/cmds/versions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/cmds/whoami.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 <command>` cases.
Expand Down Expand Up @@ -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;
});
Expand Down
8 changes: 4 additions & 4 deletions src/lib/baseCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import isCI from './isCI';
import { debug, info, warn } from './logger';
import loginFlow from './loginFlow';

export type CommandOptions<T> = ZeroAuthCommandOptions<T> | AuthenticatedCommandOptions<T>;
export type CommandOptions<T = {}> = ZeroAuthCommandOptions<T> | AuthenticatedCommandOptions<T>;

export type AuthenticatedCommandOptions<T> = Omit<ZeroAuthCommandOptions<T>, 'key'> & {
export type AuthenticatedCommandOptions<T = {}> = Omit<ZeroAuthCommandOptions<T>, 'key'> & {
key: string;
version?: string;
};

export type ZeroAuthCommandOptions<T> = T & {
export type ZeroAuthCommandOptions<T = {}> = T & {
github?: boolean;
} & { key?: never };

Expand Down Expand Up @@ -88,7 +88,7 @@ export default class Command {
*/
args!: OptionDefinition[];

async run(opts: CommandOptions<{}>): Promise<string> {
async run(opts: CommandOptions): Promise<string> {
Command.debug(`command: ${this.command}`);
Command.debug(`opts: ${JSON.stringify(opts)}`);

Expand Down
6 changes: 3 additions & 3 deletions src/lib/createGHA/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) || ''}`;
}
Expand All @@ -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))
Expand Down Expand Up @@ -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)}`);
Expand Down
4 changes: 2 additions & 2 deletions src/lib/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface Spec {
title: string;
}

export type OpenapiPromptOptions = 'create' | 'update';
export type OpenAPIPromptOptions = 'create' | 'update';

type SpecList = Spec[];

Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 3bac0e2

Please sign in to comment.