yeoman-generator
- Version 10.3.1
- Published
- 175 kB
- 16 dependencies
- BSD-2-Clause license
Install
npm i yeoman-generatoryarn add yeoman-generatorpnpm add yeoman-generatorOverview
Rails-inspired generator system that provides scaffolding for your apps
Index
Classes
Type Aliases
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( arguments_?: string[], options?: any, features?: Merge< { unique?: true | 'argument' | 'namespace'; tasksMatchingPriority?: boolean; taskPrefix?: string; customInstallTask?: | boolean | ((...args: any[]) => void | Promise<void>); customCommitTask?: | boolean | ((...args: any[]) => void | Promise<void>); skipParseOptions?: boolean; disableInGeneratorOptionsSupport?: boolean; customPriorities?: Priority[]; inheritTasks?: boolean; configTransform?: StorageTransform<Record<string, any>>; allowTemplatesOutsideRoot?: boolean; allowPackageTemplates?: boolean; allowDestinationOutsideRoot?: boolean; disableLodashProperty?: boolean; rootGeneratorNameFromNamespace?: boolean; templateContext?: 'warn' | 'throw' | 'none' | 'generator'; }, FeaturesApi >);property simpleGit
readonly simpleGit: any;method createSimpleGit
createSimpleGit: (options?: SimpleGitOptions) => SimpleGitWithConstants;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
Generatorclass instantiate the storage namedconfigby 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;Deprecated
Has no effect: the cache is dropped when the contents of the storage file change, whoever changes them.
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 defaultContent
defaultContent: () => StorageRecord;The store content of a storage file that does not exist, an empty object by default. the store content
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 parseContent
parseContent: (contents: string) => StorageRecord;Convert the contents of the storage file to the store, JSON by default. Override with
serializeContentanddefaultContentto store another format.Parameter contents
the contents of the storage file the store content
method readContent
readContent: () => StorageRecord;the store content
method save
save: () => void;Save a new object of values
method serializeContent
serializeContent: (fullStore: JsonValue) => string;Convert the store to the contents of the storage file, JSON by default.
Parameter fullStore
the store content the contents of the storage file
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 = Merge< { /** 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;
// Provided by @yeoman/types since v1.11.0 /** Provides a custom install task. Environment built-in task will not be executed */ customInstallTask?: boolean | ((...args: any[]) => void | Promise<void>);
// Provided by @yeoman/types since v1.11.0 /** 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>>;
/** * Allow `templatePath()` to resolve paths outside the source root. * By default a resulting path that is not inside the source root throws. * Can be overridden per call using the `allowOutsideRoot` option. */ allowTemplatesOutsideRoot?: boolean;
/** * Allow `templatePath()` to resolve paths anywhere inside the generator package. * The package root is the `packagePath` from the generator meta provided by the environment. * When the meta has no `packagePath`, the feature is ignored and only the source root is allowed. * Useful to share templates between generators of the same package. * Can be overridden per call using the `allowOutsideRoot` option. */ allowPackageTemplates?: boolean;
/** * Allow `destinationPath()` to resolve paths outside the destination root. * By default a resulting path that is not inside the destination root throws. * Can be overridden per call using the `allowOutsideRoot` option. */ allowDestinationOutsideRoot?: boolean;
/** * Do not provide lodash as the `_` property of the generator: reading it throws. lodash, which the property loads at * its first use, is then never loaded by the generator. */ disableLodashProperty?: boolean;
/** * Name the root generator after the namespace it was registered with (`foo:app` is `generator-foo`, `@scope/foo:app` * is `@scope/generator-foo`) instead of the name of its package.json. A package installed under an alias keeps the * config section of the alias. Without a namespace, the package.json name is used. */ rootGeneratorNameFromNamespace?: boolean;
/** * The context (`this`) of the templates of `renderTemplate`, `renderTemplateAsync`, `renderTemplates` and * `renderTemplatesAsync`: * - `'generator'` (default): the generator, without a warning. * - `'warn'`: the generator, with a warning once by template and property read from `this`. * - `'throw'`: no context, a template reads only its data, and reading a property of `this` throws, naming the * template. It will be the default in the next major. * - `'none'`: no context is passed, EJS gives the template its default `this`. * * A `context` passed in `transformOptions` is still used. Templates rendered with `this.fs.copyTpl` directly are not * affected. * * EJS keeps the context with the compiled template: with the EJS cache, a template rendered by several generators * has an unpredictable context, which `'throw'` and `'none'` avoid. */ templateContext?: 'warn' | 'throw' | 'none' | 'generator'; }, FeaturesApi>;type BaseOptions
type BaseOptions = OptionsApi & { destinationRoot?: string;
skipInstall?: boolean;
skipCheckEnv?: boolean;
ignoreVersionCheck?: boolean;
askAnswered?: boolean;
localConfigOnly?: boolean;
/** Do not use the global config storage (`~/.yo-rc-global.json`), the local config is used in its place. */ skipGlobalConfig?: boolean;
skipCache?: boolean;
skipLocalCache?: boolean;
description?: string;
/** * The namespace the generator was created for, complete with its version, instance id, methods and flags * (`namespace@semver@#id+method?`), passed by the environment. `namespace` stays the one of the generator, without * them. */ namespaceId?: 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 PathOptions
type PathOptions = { /** * Allow the resulting path to be outside the root, overriding the `allowTemplatesOutsideRoot`/`allowPackageTemplates`/`allowDestinationOutsideRoot` feature. */ allowOutsideRoot?: 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; /** * @deprecated Has no effect: the cache is dropped when the contents of the storage file change, whoever changes them. */ 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 (22)
Peer Dependencies (3)
Badge
To add a badge like this oneto 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[](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>
- Updated .
Package analyzed in 4307 ms. - Missing or incorrect documentation? Open an issue for this package.
