UNPKG

@sfdx-falcon/command

Version:

Contains SFDX-Falcon flavored extensions to @sfdx/command. Part of the SFDX-Falcon Library.

61 lines (60 loc) 3.66 kB
import { SfdxFalconResult } from '@sfdx-falcon/status'; import { JsonMap } from '@sfdx-falcon/types'; import { SfdxFalconCommand } from './sfdx-falcon-command'; /** * Interface. Specifies options used when spinning up an SFDX-Falcon Yeoman environment. */ export interface GeneratorOptions { /** Required. The name of the command that is executing a Generator, eg. `falcon:adk:clone`. */ commandName: string; /** Required. Relative path to the directory containing a Generator class file. This file MUST implement a default exported class that's derived from `SfdxFalconGenerator`. The path provided must use UNIX-style directory syntax, eg. `../../generators` */ generatorPath: string; /** Required. The name of the file containing the Generator class to be run. Must NOT include file extensions, eg. `clone-appx-demo-kit` */ generatorType: string; /** Required. Reference to package.json of the module that's implementing a command derived from `SfdxFalconGeneratorCommand` */ packageJson: JsonMap; /** Optional. A GENERATOR-type `SfdxFalconResult` object. If not provided, will be automatically created inside of the `SfdxFalconGeneratorCommand.runGenerator()` method. */ generatorResult?: SfdxFalconResult; /** Optional. An object containing all custom options that should be passed to the specified Generator when it is run. */ customOpts?: object; } /** * @class SfdxFalconGeneratorCommand * @extends SfdxFalconCommand * @summary Abstract base class class for building Salesforce CLI commands that use Yeoman. * @description Classes that extend `SfdxFalconGeneratorCommand` will be able to run any Generator * defined in the `src/generators` directory. The file name in `src/generators` should * match the `generatorType` string passed into `runYeomanGenerator()`. For example, * if `generatorType==='my-generator'`, then there MUST be a `.TS` script file located * at `src/generators/my-generator.ts`. * @public @abstract */ export declare abstract class SfdxFalconGeneratorCommand extends SfdxFalconCommand { /** * @constructs SfdxFalconGeneratorCommand * @param {any} argv Required. Part of the `oclif` command run process. * Must be passed **unmodified** to the superclass. * @param {any} config Required. Part of the `oclif` command run process. * Must be passed **unmodified** to the superclass. * @description Constructs an `SfdxFalconGeneratorCommand` object. * @private */ protected constructor(argv: any, config: any); /** * @function runGenerator * @param {GeneratorOptions} opts Required. Options object that * specifies which Generator to run and any additional custom * options that should be passed to the Generator, eg. user * supplied arguments and flags. * @returns {Promise<SfdxFalconResult>} Returns a promise that resolves * and rejects with an SFDX-Falcon Result. The output of this * function is intended to be consumed by the `onSuccess()` and * `onError()` methods. * @description Runs the `SfdxFalconGenerator` specified by the `generatorPath` * and `generatorType` values supplied by the caller in the * `GeneratorOptions` object. Will pass custom options to the * Generator, if provided. * @protected @async */ protected runGenerator(opts: GeneratorOptions): Promise<SfdxFalconResult>; }