yeoman-generator

  • Version 8.1.2
  • Published
  • 141 kB
  • 16 dependencies
  • BSD-2-Clause license

Install

npm i yeoman-generator
yarn add yeoman-generator
pnpm add yeoman-generator

Overview

Rails-inspired generator system that provides scaffolding for your apps

Index

Classes

class Generator

class Generator<
C extends Record<any, any> = Record<any, any>,
O extends BaseOptions = BaseOptions,
F extends BaseFeatures = BaseFeatures
> extends BaseGenerator<C, O, F> {}

    constructor

    constructor(...args: any[]);

      property simpleGit

      readonly simpleGit: SimpleGit;

        class Storage

        class Storage<StorageRecord extends Record<string, any> = Record<string, any>> {}
        • Storage instances handle a json file where Generator authors can store data.

          The Generator class instantiate the storage named config by default.

          Parameter name

          The name of the new storage (this is a namespace)

          Parameter fs

          A mem-fs editor instance

          Parameter configPath

          The filepath used as a storage.

          Example 1

          class extend Generator { writing: function() { this.config.set('coffeescript', false); } }

        constructor

        constructor(
        name: string,
        fs: MemFsEditor,
        configPath: string,
        options?: StorageOptions
        );

          constructor

          constructor(fs: MemFsEditor, configPath: string, options?: StorageOptions);

            property disableCache

            disableCache: boolean;

              property disableCacheByFile

              disableCacheByFile: boolean;

                property existed

                existed: boolean;

                  property fs

                  fs: MemFsEditor;

                    property indent

                    indent: number;

                      property Key

                      Key: any;

                        property lodashPath

                        lodashPath: boolean;

                          property name

                          name?: string;

                            property path

                            path: string;

                              property sorted

                              sorted: boolean;

                                method get

                                get: () => any;
                                • Get a stored value

                                  Parameter key

                                  The key under which the value is stored. The stored value. Any JSON valid type could be returned

                                method readContent

                                readContent: () => StorageRecord;
                                • the store content

                                method save

                                save: () => void;
                                • Save a new object of values

                                method writeContent

                                writeContent: (fullStore: JsonValue) => string;
                                • the store content

                                Type Aliases

                                type ArgumentSpec

                                type ArgumentSpec = {
                                name: string;
                                /** Description for the argument. */
                                description?: string;
                                /** A value indicating whether the argument is required. */
                                required?: boolean;
                                /** A value indicating whether the argument is optional. */
                                optional?: boolean;
                                /** The type of the argument. */
                                type: typeof String | typeof Number | typeof Array | typeof Object;
                                /** The default value of the argument. */
                                default?: any;
                                };

                                  type BaseFeatures

                                  type BaseFeatures = FeaturesApi & {
                                  /** The Generator instance unique identifier. The Environment will ignore duplicated identifiers. */
                                  uniqueBy?: string;
                                  /** UniqueBy calculation method */
                                  unique?: true | 'argument' | 'namespace';
                                  /** Only queue methods that matches a priority. */
                                  tasksMatchingPriority?: boolean;
                                  /** Tasks methods starts with prefix. Allows api methods (non tasks) without prefix. */
                                  taskPrefix?: string;
                                  /** Provides a custom install task. Environment built-in task will not be executed */
                                  customInstallTask?: boolean | ((...args: any[]) => void | Promise<void>);
                                  /** Provides a custom commit task. */
                                  customCommitTask?: boolean | ((...args: any[]) => void | Promise<void>);
                                  /** Disable args/options parsing. Whenever options/arguments are provided parsed like using commander based parsing. */
                                  skipParseOptions?: boolean;
                                  /** Disable args/options support. Whenever options/arguments are provided parsed like using commander based parsing. */
                                  disableInGeneratorOptionsSupport?: boolean;
                                  /** Custom priorities for more fine tuned workflows. */
                                  customPriorities?: Priority[];
                                  /** Inherit tasks from parent prototypes, implies tasksMatchingPriority */
                                  inheritTasks?: boolean;
                                  /** Transform the configuration before reading. */
                                  configTransform?: StorageTransform<Record<string, any>>;
                                  };

                                    type BaseOptions

                                    type BaseOptions = OptionsApi & {
                                    destinationRoot?: string;
                                    skipInstall?: boolean;
                                    skipCheckEnv?: boolean;
                                    ignoreVersionCheck?: boolean;
                                    askAnswered?: boolean;
                                    localConfigOnly?: boolean;
                                    skipCache?: boolean;
                                    skipLocalCache?: boolean;
                                    description?: string;
                                    };

                                      type CliOptionSpec

                                      type CliOptionSpec = {
                                      name: string;
                                      /** The type of the option. */
                                      type: typeof Boolean | typeof String | typeof Number | ((opt: string) => any);
                                      required?: boolean;
                                      /** The option name alias (example `-h` and --help`). */
                                      alias?: string;
                                      /** The default value. */
                                      default?: any;
                                      /** The description for the option. */
                                      description?: string;
                                      /** A value indicating whether the option should be hidden from the help output. */
                                      hide?: boolean;
                                      /** The storage to persist the option */
                                      storage?: string | Storage<any>;
                                      };

                                        type ComposeOptions

                                        type ComposeOptions<G extends BaseGenerator = BaseGenerator> =
                                        EnvironmentComposeOptions<G> & {
                                        skipEnvRegister?: boolean;
                                        forceResolve?: boolean;
                                        forwardOptions?: boolean;
                                        };

                                          type GeneratorPipelineOptions

                                          type GeneratorPipelineOptions = PipelineOptions<MemFsEditorFile> &
                                          ProgressOptions & { pendingFiles?: boolean };

                                            type Priority

                                            type Priority = QueueOptions & {
                                            /** Name of the priority. */
                                            priorityName: string;
                                            /** The queue which this priority should be added before. */
                                            before?: string;
                                            };
                                            • Priority object.

                                            type PromptQuestion

                                            type PromptQuestion<T extends PromptAnswers = PromptAnswers> =
                                            PromptQuestionApi<T> & {
                                            name: string;
                                            /**
                                            * The storage to store the answer.
                                            */
                                            storage?: Storage<any>;
                                            /**
                                            * A value indicating whether to store the user's previous answer for others projects.
                                            */
                                            store?: boolean;
                                            };
                                            • Represents a question.

                                            type PromptQuestions

                                            type PromptQuestions<A extends PromptAnswers = PromptAnswers> =
                                            | PromptQuestion<A>
                                            | Array<PromptQuestion<A>>;
                                            • Provides a set of questions.

                                            type QuestionRegistrationOptions

                                            type QuestionRegistrationOptions<T extends PromptAnswers = PromptAnswers> =
                                            PromptQuestion<T> & {
                                            /**
                                            * A value indicating whether an option should be exported for this question.
                                            */
                                            exportOption?: boolean | Record<string, unknown>;
                                            };
                                            • Provides options for registering a prompt.

                                            type QueueOptions

                                            type QueueOptions = {
                                            /** Name of the queue. */
                                            queueName?: string;
                                            /** Execute only once by namespace and taskName. */
                                            once?: boolean;
                                            /** Run the queue if not running yet. */
                                            run?: boolean;
                                            /** Edit a priority */
                                            edit?: boolean;
                                            /** Queued manually only */
                                            skip?: boolean;
                                            /** Arguments to pass to tasks */
                                            args?: any[] | ((generator: Generator) => any[]);
                                            };
                                            • Queue options.

                                            type StorageOptions

                                            type StorageOptions = {
                                            name?: string;
                                            /**
                                            * Set true to treat name as a lodash path.
                                            */
                                            lodashPath?: boolean;
                                            /**
                                            * Set true to disable json object cache.
                                            */
                                            disableCache?: boolean;
                                            /**
                                            * Set true to cleanup cache for every fs change.
                                            */
                                            disableCacheByFile?: boolean;
                                            /**
                                            * Set true to write sorted json.
                                            */
                                            sorted?: boolean;
                                            /**
                                            * Transform the content of the storage when reading it. This can be used to sanitize or modify the data before it is returned.
                                            */
                                            transform?: StorageTransform<Record<string, any>>;
                                            };

                                              type StorageTransform

                                              type StorageTransform<A extends Record<string, any>> = (
                                              content: A,
                                              name?: string
                                              ) => A;

                                                type StorageValue

                                                type StorageValue = JsonValue;

                                                  type Task

                                                  type Task<TaskContext = any> = TaskOptions & {
                                                  /** Function to be queued. */
                                                  method: (this: TaskContext, ...args: any[]) => unknown | Promise<unknown>;
                                                  /** Name of the task. */
                                                  taskName: string;
                                                  };
                                                  • Complete Task object.

                                                  type TaskOptions

                                                  type TaskOptions = QueueOptions & {
                                                  /** Reject callback. */
                                                  reject?: (error: unknown) => void;
                                                  taskPrefix?: string;
                                                  auto?: boolean;
                                                  taskOrigin?: any;
                                                  cancellable?: boolean;
                                                  };
                                                  • Task options.

                                                  Package Files (4)

                                                  Dependencies (16)

                                                  Dev Dependencies (23)

                                                  Peer Dependencies (3)

                                                  Badge

                                                  To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                  You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/yeoman-generator.

                                                  • Markdown
                                                    [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/yeoman-generator)
                                                  • HTML
                                                    <a href="https://www.jsdocs.io/package/yeoman-generator"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>