yeoman-generator

  • Version 7.1.1
  • Published
  • 137 kB
  • 17 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<
O extends BaseOptions = BaseOptions,
F extends BaseFeatures = BaseFeatures
> extends BaseGenerator<O, F> {}

    constructor

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

      property simpleGit

      readonly simpleGit: SimpleGit;

        class Storage

        class Storage {}
        • 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 lodashPath

                      lodashPath: boolean;

                        property name

                        name?: string;

                          property path

                          path: string;

                            property sorted

                            sorted: boolean;

                              method createProxy

                              createProxy: () => StorageRecord;
                              • Creates a proxy object. proxy.

                              method createStorage

                              createStorage: (path: string) => Storage;
                              • Create a child storage.

                                Parameter path

                                relative path of the key to create a new storage. Some paths need to be escaped. Eg: ["dotted.path"] Returns a new Storage.

                              method defaults

                              defaults: (defaults: StorageRecord) => StorageRecord;
                              • Setup the store with defaults value and schedule a save. If keys already exist, the initial value is kept.

                                Parameter defaults

                                Key-value object to store. val Returns the merged options.

                              method delete

                              delete: (key: string) => void;
                              • Delete a key from the store and schedule a save.

                                Parameter key

                                The key under which the value is stored.

                              method get

                              get: <T extends JSONSchema7Type = JSONSchema7Type>(key: string) => T;
                              • 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 getAll

                              getAll: () => StorageRecord;
                              • Get all the stored values key-value object

                              method getPath

                              getPath: <T extends JSONSchema7Type = JSONSchema7Type>(path: string) => T;
                              • Get a stored value from a lodash path

                                Parameter path

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

                              method merge

                              merge: (source: StorageRecord) => StorageRecord;
                              • Parameter defaults

                                Key-value object to store. val Returns the merged object.

                              method readContent

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

                              method save

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

                              method set

                              set: {
                              <V = JSONSchema7Type>(value: V): V;
                              <V = JSONSchema7Type>(key: string | number, value?: V): V;
                              };
                              • Assign a key to a value and schedule a save.

                                Parameter key

                                The key under which the value is stored

                                Parameter val

                                Any valid JSON type value (String, Number, Array, Object). val Whatever was passed in as val.

                              method setPath

                              setPath: (path: string | number, value: JSONSchema7Type) => any;
                              • Assign a lodash path to a value and schedule a save.

                                Parameter path

                                The key under which the value is stored

                                Parameter val

                                Any valid JSON type value (String, Number, Array, Object). val Whatever was passed in as val.

                              method writeContent

                              writeContent: (fullStore: JSONSchema7Type) => 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;
                                /** Custom priorities for more fine tuned workflows. */
                                customPriorities?: Priority[];
                                };

                                  type BaseOptions

                                  type BaseOptions = OptionsApi & {
                                  destinationRoot?: string;
                                  skipInstall?: boolean;
                                  skipCheckEnv?: boolean;
                                  ignoreVersionCheck?: boolean;
                                  askAnswered?: boolean;
                                  localConfigOnly?: boolean;
                                  skipCache?: boolean;
                                  skipLocalCache?: boolean;
                                  description?: string;
                                  /** @deprecated moved to features */
                                  skipParseOptions?: boolean;
                                  /** @deprecated moved to features */
                                  customPriorities?: Priority[];
                                  };

                                    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;
                                    };

                                      type ComposeOptions

                                      type ComposeOptions<G extends BaseGenerator = BaseGenerator> =
                                      EnvironmentComposeOptions<G> & {
                                      destinationRoot?: string;
                                      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 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;
                                          };

                                            type StorageRecord

                                            type StorageRecord = Record<string, StorageValue>;

                                              type StorageValue

                                              type StorageValue = JSONSchema7Type;

                                                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 (3)

                                                Dependencies (17)

                                                Dev Dependencies (25)

                                                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>