rdme
Version:
ReadMe's official CLI and GitHub Action.
44 lines (43 loc) • 2.1 kB
TypeScript
import type { CreateGHAHookOptsInClass } from './hooks/createGHA.js';
import type { Config, Interfaces } from '@oclif/core';
import { Command as OclifCommand } from '@oclif/core';
import { info } from './logger.js';
import { handleAPIv2Res, readmeAPIv2Fetch, type ResponseBody } from './readmeAPIFetch.js';
type Flags<T extends typeof OclifCommand> = Interfaces.InferredFlags<(typeof BaseCommand)['baseFlags'] & T['flags']>;
type Args<T extends typeof OclifCommand> = Interfaces.InferredArgs<T['args']>;
/**
* This is a light wrapper around the oclif command class that adds some
* additional functionality and standardizes the way we handle logging, error handling,
* and API requests.
*
* @note This class is not meant to be used directly, but rather as a base class for other commands.
* It is also experimental and may change in the future.
*/
export default abstract class BaseCommand<T extends typeof OclifCommand> extends OclifCommand {
constructor(argv: string[], config: Config);
args: Args<T>;
flags: Flags<T>;
debug: (...args: unknown[]) => void;
protected info(input: Parameters<typeof info>[0], opts: Parameters<typeof info>[1]): void;
warn(input: Error | string): Error | string;
protected catch(err: Error & {
exitCode?: number;
}): Promise<any>;
/**
* This is a light wrapper around the oclif command's `_run` function
* that takes the result and sets a GitHub step output parameter to the result
* when being run from a GitHub Actions runner.
*/
protected _run<U>(): Promise<U>;
init(): Promise<void>;
/**
* Wrapper around `handleAPIv2Res` that binds the context of the class to the function.
*/
handleAPIRes<R extends ResponseBody = ResponseBody>(...args: Parameters<typeof handleAPIv2Res>): Promise<R>;
/**
* Wrapper around `readmeAPIv2Fetch` that binds the context of the class to the function.
*/
readmeAPIFetch(...args: Parameters<typeof readmeAPIv2Fetch>): Promise<Response>;
runCreateGHAHook(opts: CreateGHAHookOptsInClass): Promise<string>;
}
export {};