@cirrusct/mr-command

Mr Command

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@cirrusct/mr-command
1.0.1244 years ago4 years agoMinified + gzip package size for @cirrusct/mr-command in KB

Readme

Command
The command system is completely extensible with Command handlers that conform to defined interfaces and are registered with mr-core when mr is initialized.

Command Handlers

Command handlers are exposed by a package with Command Manifests that define the handlers for a particular command.
A Manifest defines 2 types of handlers, each defining a map keyed on the name of the command:
export interface MrCommandManifest {
    packageHandlers?: { [name: string]: MrPackageCommandHandler };
    commandHandlers?: { [name: string]: MrCommandHandler };
}

MrPackageCommandHandler

A MrPackageCommandHandler defines a command the operates on a single package in the monorepo. Depending on cli options, the handler may be called separately for multiple packages, but the handler itself only executes for a single package.
export type MrPackageCommandHandler = <TOptions extends MrCommandOptions>(
    mrPackage: MonoRepoPackage,
    options: TOptions,
    buildConfig: BuildConfig,
    logger: Logger
) => Promise<void>;

MrCommandHandler

A MrCommandHandler defines a command that operates on the monorepo generally.
export interface MrCommandHandlerArgs<TOptions extends MrCommandOptions> {
    monoRepo: MonoRepo;
    packages: MonoRepoPackage[];
    cwd: string;
    entryPackage: MonoRepoPackage | null;
    options: TOptions;
    logger: Logger;
}

export type MrCommandHandler<TOptions extends MrCommandOptions = {}> = (
    args: MrCommandHandlerArgs<TOptions>
) => Promise<void>;