1 | // Type definitions for yeoman-generator 5.2
|
2 | // Project: https://github.com/yeoman/generator, http://yeoman.io
|
3 | // Definitions by: Kentaro Okuno <https://github.com/armorik83>
|
4 | // Jay Anslow <https://github.com/janslow>
|
5 | // Ika <https://github.com/ikatyang>
|
6 | // Joshua Cherry <https://github.com/tasadar2>
|
7 | // Arthur Corenzan <https://github.com/haggen>
|
8 | // Richard Lea <https://github.com/chigix>
|
9 | // Manuel Thalmann <https://github.com/manuth>
|
10 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
11 | // TypeScript Version: 4.2
|
12 |
|
13 | import { spawn, SpawnOptions, SpawnSyncOptions } from 'child_process';
|
14 | import { Debugger } from 'debug';
|
15 | import { Data as TemplateData, Options as TemplateOptions } from 'ejs';
|
16 | import { EventEmitter } from 'events';
|
17 | import { Answers as InquirerAnswers, DistinctQuestion } from 'inquirer';
|
18 | import { Editor, CopyOptions } from 'mem-fs-editor';
|
19 | import { Observable } from 'rxjs';
|
20 | import { Transform } from 'stream';
|
21 | import Environment = require('yeoman-environment');
|
22 | import Storage = require('./lib/util/storage');
|
23 | import Logger = Environment.Logger;
|
24 |
|
25 | declare namespace Generator {
|
26 | /**
|
27 | * Provides a priority-specification for a custom queue.
|
28 | */
|
29 | interface Priority {
|
30 | /**
|
31 | * The name for identifying the queue.
|
32 | */
|
33 | queueName?: string | undefined;
|
34 |
|
35 | /**
|
36 | * The name of the method to execute.
|
37 | */
|
38 | priorityName: string;
|
39 |
|
40 | /**
|
41 | * The name of the queue which this priority should be added before.
|
42 | */
|
43 | before: string;
|
44 | }
|
45 |
|
46 | /**
|
47 | * Provides options for generators.
|
48 | */
|
49 | interface GeneratorOptions {
|
50 | /**
|
51 | * Gets or sets additional properties.
|
52 | */
|
53 | [name: string]: any;
|
54 |
|
55 | /**
|
56 | * The path to the generator.
|
57 | */
|
58 | resolved?: string;
|
59 |
|
60 | /**
|
61 | * Gets or sets a collection of custom priorities.
|
62 | */
|
63 | customPriorities?: Priority[] | undefined;
|
64 |
|
65 | /**
|
66 | * The environment to use for creating the generator.
|
67 | */
|
68 | env?: Environment | undefined;
|
69 |
|
70 | /**
|
71 | * The destination-root to write the files to.
|
72 | */
|
73 | destinationRoot?: string | undefined;
|
74 | }
|
75 |
|
76 | /**
|
77 | * Provides the functionality to handle callbacks.
|
78 | */
|
79 | type Callback =
|
80 | /**
|
81 | * Handles a callback.
|
82 | *
|
83 | * @param err The error that occurred.
|
84 | */
|
85 | (err: any) => void;
|
86 |
|
87 | /**
|
88 | * Represents a question.
|
89 | */
|
90 | type Question<T extends Answers = Answers> = DistinctQuestion<T> & {
|
91 | /**
|
92 | * A value indicating whether to store the user's previous answer.
|
93 | */
|
94 | store?: boolean | undefined;
|
95 | };
|
96 |
|
97 | /**
|
98 | * Provides options for registering a prompt.
|
99 | */
|
100 | type QuestionRegistrationOptions<T extends Answers = Answers> = Question<T> & {
|
101 | /**
|
102 | * The storage to store the answers.
|
103 | */
|
104 | storage?: Storage | undefined;
|
105 |
|
106 | /**
|
107 | * A value indicating whether an option should be exported for this question.
|
108 | */
|
109 | exportOption?: boolean | object | undefined;
|
110 | };
|
111 |
|
112 | /**
|
113 | * Represents an answer-hash.
|
114 | */
|
115 | type Answers = InquirerAnswers;
|
116 |
|
117 | /**
|
118 | * Provides a set of questions.
|
119 | */
|
120 | type Questions<A extends Answers = Answers> = Question<A> | Array<Question<A>> | Observable<Question<A>>;
|
121 |
|
122 | /**
|
123 | * Provides options for performing installations.
|
124 | */
|
125 | interface InstallOptions {
|
126 | /**
|
127 | * A value indicating whether to run `npm install` or options to pass to `dargs` as arguments.
|
128 | */
|
129 | npm?: boolean | object | undefined;
|
130 |
|
131 | /**
|
132 | * A value indicating whether to run `bower install` or options to pass to `dargs` as arguments.
|
133 | */
|
134 | bower?: boolean | object | undefined;
|
135 |
|
136 | /**
|
137 | * A value indicating whether to run `yarn install` or options to pass to `dargs` as arguments.
|
138 | */
|
139 | yarn?: boolean | object | undefined;
|
140 |
|
141 | /**
|
142 | * A value indicating whether messages should be logged.
|
143 | */
|
144 | skipMessage?: boolean | undefined;
|
145 | }
|
146 |
|
147 | /**
|
148 | * Provides options for creating a new argument.
|
149 | */
|
150 | interface ArgumentConfig {
|
151 | /**
|
152 | * Description for the argument.
|
153 | */
|
154 | description?: string | undefined;
|
155 |
|
156 | /**
|
157 | * A value indicating whether the argument is required.
|
158 | */
|
159 | required?: boolean | undefined;
|
160 |
|
161 | /**
|
162 | * A value indicating whether the argument is optional.
|
163 | */
|
164 | optional?: boolean | undefined;
|
165 |
|
166 | /**
|
167 | * The type of the argument.
|
168 | */
|
169 | type?: typeof String | typeof Number | typeof Array | typeof Object | undefined;
|
170 |
|
171 | /**
|
172 | * The default value of the argument.
|
173 | */
|
174 | default?: any;
|
175 | }
|
176 |
|
177 | /**
|
178 | * Provides settings for creating a new generator-option.
|
179 | */
|
180 | interface OptionConfig {
|
181 | /**
|
182 | * The type of the option.
|
183 | */
|
184 | type: typeof Boolean | typeof String | typeof Number;
|
185 |
|
186 | /**
|
187 | * The option name alias (example `-h` and --help`).
|
188 | */
|
189 | alias?: string | undefined;
|
190 |
|
191 | /**
|
192 | * The default value.
|
193 | */
|
194 | default?: any;
|
195 |
|
196 | /**
|
197 | * The description for the option.
|
198 | */
|
199 | description?: string | undefined;
|
200 |
|
201 | /**
|
202 | * A value indicating whether the option should be hidden from the help output.
|
203 | */
|
204 | hide?: boolean | undefined;
|
205 |
|
206 | /**
|
207 | * The storage to persist the option
|
208 | */
|
209 | storage?: Storage | undefined;
|
210 | }
|
211 |
|
212 | /**
|
213 | * Represents a generator-constructor.
|
214 | */
|
215 | interface GeneratorConstructor {
|
216 | new(...args: any[]): Generator<any>;
|
217 | }
|
218 |
|
219 | /**
|
220 | * Represents options for composing a generator.
|
221 | */
|
222 | interface CompositionOptions {
|
223 | /**
|
224 | * The constructor of the generator.
|
225 | */
|
226 | Generator: GeneratorConstructor;
|
227 |
|
228 | /**
|
229 | * The path to the file containing the generator.
|
230 | */
|
231 | path: string;
|
232 | }
|
233 |
|
234 | type GeneratorFeaturesUniqueBy = 'argument' | 'namespacep';
|
235 |
|
236 | /**
|
237 | * Represents generators feature
|
238 | */
|
239 | interface GeneratorFeatures {
|
240 | /**
|
241 | * uniqueBy calculation method (undefined/argument/namespace)
|
242 | */
|
243 | uniqueBy?: GeneratorFeaturesUniqueBy | undefined;
|
244 |
|
245 | /**
|
246 | * The Generator instance unique identifier.
|
247 | * The Environment will ignore duplicated identifiers.
|
248 | */
|
249 | unique?: string | undefined;
|
250 |
|
251 | /**
|
252 | * Only queue methods that matches a priority
|
253 | */
|
254 | tasksMatchingPriority?: boolean | undefined;
|
255 |
|
256 | /**
|
257 | * Tasks methods starts with prefix. Allows api methods (non tasks) without prefix.
|
258 | */
|
259 | taskPrefix?: string | undefined;
|
260 |
|
261 | /**
|
262 | * Enable customCommitTask()
|
263 | */
|
264 | customCommitTask?: boolean | undefined;
|
265 |
|
266 | /**
|
267 | * Enable customInstallTask()
|
268 | */
|
269 | customInstallTask?: boolean | undefined;
|
270 | }
|
271 |
|
272 | /**
|
273 | * Provides options for queues.
|
274 | */
|
275 | interface QueueOptions {
|
276 | /**
|
277 | * The name of the queue.
|
278 | */
|
279 | queueName?: string | undefined;
|
280 |
|
281 | /**
|
282 | * A value indicating whether the queue should be executed only once per namespace and task-name.
|
283 | */
|
284 | once?: boolean | undefined;
|
285 |
|
286 | /**
|
287 | * A value indicating whether the queue should be executed if not running yet.
|
288 | */
|
289 | run?: boolean | undefined;
|
290 | }
|
291 |
|
292 | /**
|
293 | * Provides options for tasks.
|
294 | */
|
295 | interface TaskOptions extends QueueOptions {
|
296 | /**
|
297 | * A method for handling errors.
|
298 | */
|
299 | reject?: Callback | undefined;
|
300 | }
|
301 |
|
302 | /**
|
303 | * Represents a task.
|
304 | */
|
305 | interface Task extends TaskOptions {
|
306 | /**
|
307 | * The function to queue.
|
308 | */
|
309 | method: (...args: any) => any;
|
310 |
|
311 | /**
|
312 | * The name of the task.
|
313 | */
|
314 | taskName: string;
|
315 | }
|
316 |
|
317 | /**
|
318 | * Provides settings for rendering a template.
|
319 | */
|
320 | interface TemplateRenderOptions<T extends Generator<any>> {
|
321 | /**
|
322 | * A method for determining whether the template should be rendered.
|
323 | */
|
324 | when?: ((templateData: TemplateData, generator: T) => boolean) | undefined;
|
325 |
|
326 | /**
|
327 | * The template file, absolute or relative to {@link Generator.templatePath `templatePath()`}.
|
328 | */
|
329 | source: string | string[];
|
330 |
|
331 | /**
|
332 | * The destination, absolute or relative to {@link Generator.destinationPath `destinationPath()`}.
|
333 | */
|
334 | destination?: string | string[] | undefined;
|
335 |
|
336 | /**
|
337 | * The `ejs` options.
|
338 | */
|
339 | templateOptions?: TemplateOptions | undefined;
|
340 |
|
341 | /**
|
342 | * The `mem-fs-editor` copy-options.
|
343 | */
|
344 | copyOptions?: CopyOptions | undefined;
|
345 | }
|
346 | }
|
347 |
|
348 | /**
|
349 | * The {@link Generator `Generator`} class provides the common API shared by all generators.
|
350 | * It define options, arguments, file, prompt, log, API, etc.
|
351 | *
|
352 | * Every generator should extend this base class.
|
353 | */
|
354 | declare class Generator<T extends Generator.GeneratorOptions = Generator.GeneratorOptions> extends EventEmitter {
|
355 | constructor(args: string | string[], options: T, features?: Generator.GeneratorFeatures);
|
356 |
|
357 | /**
|
358 | * The current Environment being run.
|
359 | */
|
360 | env: Environment;
|
361 |
|
362 | /**
|
363 | * Provides arguments at initialization.
|
364 | */
|
365 | args: string[];
|
366 |
|
367 | /**
|
368 | * The path to the current generator.
|
369 | */
|
370 | resolved: string;
|
371 |
|
372 | /**
|
373 | * The description to display in the `--help` output.
|
374 | */
|
375 | description: string;
|
376 |
|
377 | /**
|
378 | * The application name.
|
379 | */
|
380 | appname: string;
|
381 |
|
382 | /**
|
383 | * The `.yo-rc` config file manager.
|
384 | */
|
385 | config: Storage;
|
386 |
|
387 | /**
|
388 | * The storage containing the destination-`package.json`.
|
389 | */
|
390 | packageJson: Storage;
|
391 |
|
392 | /**
|
393 | * An instance of [`mem-fs-editor`](https://github.com/SBoudrias/mem-fs-editor).
|
394 | */
|
395 | fs: Editor;
|
396 |
|
397 | /**
|
398 | * Provides options at initialization.
|
399 | */
|
400 | options: T;
|
401 |
|
402 | /**
|
403 | * Provides the functionality to log messages.
|
404 | */
|
405 | log: Logger;
|
406 |
|
407 | /**
|
408 | * The path from where the user is running `yo`.
|
409 | */
|
410 | contextRoot: string;
|
411 |
|
412 | /**
|
413 | * Reads the options or a single option at the specified property-path from the `.yo-rc` config-store.
|
414 | *
|
415 | * @param path The property-path of the option to get.
|
416 | */
|
417 | _templateData(path?: string): any;
|
418 |
|
419 | /**
|
420 | * Adds an argument to the class and creates an attribute getter for it.
|
421 | *
|
422 | * Arguments are different from options in several aspects. The first one
|
423 | * is how they are parsed from the command line, arguments are retrieved
|
424 | * based on their position.
|
425 | *
|
426 | * Besides, arguments are used inside your code as a property ({@link Generator.args `this.args`}),
|
427 | * while options are all kept in a hash ({@link Generator.options `this.options`}).
|
428 | *
|
429 | *
|
430 | * @param name Argument name.
|
431 | * @param config Argument options.
|
432 | * @return This generator.
|
433 | */
|
434 | argument(name: string, config: Generator.ArgumentConfig): this;
|
435 |
|
436 | /**
|
437 | * Cancels all cancellable tasks.
|
438 | */
|
439 | cancelCancellableTasks(): void;
|
440 |
|
441 | /**
|
442 | * Compose this generator with another one.
|
443 | *
|
444 | * @param generator The path to the generator module or an object (see examples).
|
445 | * @param options The options passed to the Generator.
|
446 | * @param returnNewGenerator Returns the created generator instead of returning this.
|
447 | * @return This generator or the composed generator when {@link returnNewGenerator `returnNewGenerator`} is `true`.
|
448 | *
|
449 | * @example
|
450 | * this.composeWith('bootstrap', { sass: true });
|
451 | *
|
452 | * @example
|
453 | * this.composeWith(require.resolve('generator-bootstrap/app/main.js'), { sass: true });
|
454 | *
|
455 | * @example
|
456 | * this.composeWith({ Generator: MyGenerator, path: '../generator-bootstrap/app/main.js' }, { sass: true });
|
457 | *
|
458 | * @returns
|
459 | * Either returns this generator or the newly created generator.
|
460 | */
|
461 | composeWith(
|
462 | generators: Array<Generator.CompositionOptions | string> | Generator.CompositionOptions | string,
|
463 | options?: Generator.GeneratorOptions,
|
464 | returnNewGenerator?: false,
|
465 | ): this;
|
466 |
|
467 | /**
|
468 | * Compose this generator with another one.
|
469 | *
|
470 | * @param generator The path to the generator module or an object (see examples).
|
471 | * @param options The options passed to the Generator.
|
472 | * @param returnNewGenerator Returns the created generator instead of returning this.
|
473 | * @return This generator or the composed generator when returnNewGenerator=true
|
474 | *
|
475 | * @example
|
476 | * this.composeWith('bootstrap', { sass: true });
|
477 | *
|
478 | * @example
|
479 | * this.composeWith(require.resolve('generator-bootstrap/app/main.js'), { sass: true });
|
480 | *
|
481 | * @example
|
482 | * this.composeWith({ Generator: MyGenerator, path: '../generator-bootstrap/app/main.js' }, { sass: true });
|
483 | *
|
484 | * @returns
|
485 | * Either returns this generator or the newly created generator.
|
486 | */
|
487 | composeWith(
|
488 | generators: Generator.CompositionOptions | string,
|
489 | options: Generator.GeneratorOptions,
|
490 | returnNewGenerator: true,
|
491 | ): Generator;
|
492 |
|
493 | /**
|
494 | * Compose this generator with another one.
|
495 | *
|
496 | * @param generator The path to the generator module or an object (see examples).
|
497 | * @param options The options passed to the Generator.
|
498 | * @param returnNewGenerator Returns the created generator instead of returning this.
|
499 | * @return This generator or the composed generator when returnNewGenerator=true
|
500 | *
|
501 | * @example
|
502 | * this.composeWith('bootstrap', { sass: true });
|
503 | *
|
504 | * @example
|
505 | * this.composeWith(require.resolve('generator-bootstrap/app/main.js'), { sass: true });
|
506 | *
|
507 | * @example
|
508 | * this.composeWith({ Generator: MyGenerator, path: '../generator-bootstrap/app/main.js' }, { sass: true });
|
509 | *
|
510 | * @returns
|
511 | * Either returns this generator or the newly created generator.
|
512 | */
|
513 | composeWith(
|
514 | generators: Array<Generator.CompositionOptions | string>,
|
515 | options: Generator.GeneratorOptions,
|
516 | returnNewGenerator: true,
|
517 | ): Generator[];
|
518 |
|
519 | /**
|
520 | * Creates a new storage.
|
521 | *
|
522 | * @param storagePath The path to the `json`-file of the storage.
|
523 | * @param key The key in which the options are stored inside the `json`.
|
524 | * @param lodashPath A value indicating whether the {@link key `key`} argument should be treated as a lodash path.
|
525 | */
|
526 | createStorage(storagePath: string, key?: string, lodashPath?: boolean): Storage;
|
527 |
|
528 | /**
|
529 | * Convenience debug method.
|
530 | */
|
531 | debug: (...args: Parameters<Debugger>) => void;
|
532 |
|
533 | /**
|
534 | * Joins a path to the destination root.
|
535 | *
|
536 | * @param path The path parts.
|
537 | */
|
538 | destinationPath(...path: string[]): string;
|
539 |
|
540 | /**
|
541 | * Changes the generator destination root directory.
|
542 | *
|
543 | * This path is used to find storage, when using file system helper methods
|
544 | * (such as {@link Generator.writeDestination `this.writeDestination`} and {@link Generator.copyDestination `this.copyDestination`}).
|
545 | *
|
546 | * @param rootPath The new destination root path.
|
547 | * @param skipEnvironment A value indicating whether {@link Environment.cwd `this.env.cwd`} and the current working directory shouldn't be changed.
|
548 | */
|
549 | destinationRoot(rootPath?: string, skipEnvironment?: boolean): string;
|
550 |
|
551 | /**
|
552 | * Determines the name of the application.
|
553 | *
|
554 | * First checks for the name in `bower.json`, then checks for the name in `package.json`.
|
555 | * Finally defaults to the name of the current directory.
|
556 | *
|
557 | * @returns The name of the application.
|
558 | */
|
559 | determineAppname(): string;
|
560 |
|
561 | /**
|
562 | * Adds an option to the set of generator expected options, only used to generate generator usage.
|
563 | * By default, generators get all the cli options parsed by nopt as a {@link Generator.options `this.options`} hash object.
|
564 | *
|
565 | * @param name The name of the option.
|
566 | * @param config The configuration of the option.
|
567 | * @returns This generator
|
568 | */
|
569 | option(name: string, config?: Generator.OptionConfig): this;
|
570 |
|
571 | /**
|
572 | * Prompt user to answer questions.
|
573 | */
|
574 | prompt<T>(questions: Generator.Questions<T>): Promise<T>;
|
575 |
|
576 | /**
|
577 | * Queues the basic tasks of the generator.
|
578 | */
|
579 | queueBasicTasks(): void;
|
580 |
|
581 | /**
|
582 | * Schedules methods on a run queue.
|
583 | *
|
584 | * @param method The method or an object containing function properties to schedule.
|
585 | * @param methodName The name of the method to be scheduled.
|
586 | * @param queueName The name of the queue to schedule on.
|
587 | * @param reject A callback for handling rejections.
|
588 | */
|
589 | queueMethod(
|
590 | method: ((...args: any[]) => any) | Record<string, (...args: any[]) => any>,
|
591 | methodName?: string,
|
592 | queueName?: string,
|
593 | reject?: Generator.Callback,
|
594 | ): void;
|
595 |
|
596 | /**
|
597 | * Schedules a task on a run queue.
|
598 | *
|
599 | * @param task The task to queue.
|
600 | */
|
601 | queueTask(task: Generator.Task): void;
|
602 |
|
603 | /**
|
604 | * Schedules methods on a run queue.
|
605 | *
|
606 | * @param taskGroup An object containing tasks.
|
607 | * @param taskOptions The options for creating the tasks.
|
608 | */
|
609 | queueTaskGroup(taskGroup: Record<string, (...args: any[]) => any>, taskOptions?: Generator.TaskOptions): void;
|
610 |
|
611 | /**
|
612 | * Registers the specified {@link priorities `priorities`}.
|
613 | *
|
614 | * @param priorities
|
615 | * The priorities to register.
|
616 | */
|
617 | registerPriorities(priorities: Generator.Priority[]): void;
|
618 |
|
619 | /**
|
620 | * Registers stored config prompts and optional option alternatives.
|
621 | *
|
622 | * @param questions
|
623 | * The questions to register.
|
624 | */
|
625 | registerConfigPrompts<TAnswers>(
|
626 | questions:
|
627 | | Generator.QuestionRegistrationOptions<TAnswers>
|
628 | | Array<Generator.QuestionRegistrationOptions<TAnswers>>,
|
629 | ): void;
|
630 |
|
631 | /**
|
632 | * Adds a transform stream to the commit stream.
|
633 | *
|
634 | * @param stream An array of transform streams or a single one.
|
635 | */
|
636 | registerTransformStream(stream: Transform | Transform[]): this;
|
637 |
|
638 | /**
|
639 | * Determines the root generator name (the one who's extending this generator).
|
640 | */
|
641 | rootGeneratorName(): string;
|
642 |
|
643 | /**
|
644 | * Determines the root generator version (the one who's extending this generator).
|
645 | */
|
646 | rootGeneratorVersion(): string;
|
647 |
|
648 | /**
|
649 | * Runs the generator, scheduling prototype methods on a run queue.
|
650 | * Method names will determine the order each method is run.
|
651 | * Methods without special names will run in default queue.
|
652 | *
|
653 | * Any method named `constructor` and any methods prefixed by a `_` won't be scheduled.
|
654 | */
|
655 | run(): Promise<void>;
|
656 |
|
657 | /**
|
658 | * Runs the generator, scheduling prototype methods on a run queue.
|
659 | * Method names will determine the order each method is run.
|
660 | * Methods without special names will run in default queue.
|
661 | *
|
662 | * Any method named `constructor` and any methods prefixed by a `_` won't be scheduled.
|
663 | *
|
664 | * @param cb The callback.
|
665 | * @deprecated
|
666 | */
|
667 | // tslint:disable-next-line:unified-signatures
|
668 | run(cb: Generator.Callback): Promise<void>;
|
669 |
|
670 | /**
|
671 | * Changes the generator source root directory.
|
672 | * This path is used by multiple file system methods.
|
673 | *
|
674 | * @param rootPath The new source root path.
|
675 | */
|
676 | sourceRoot(rootPath?: string): string;
|
677 |
|
678 | /**
|
679 | * Joins a path to the source root.
|
680 | *
|
681 | * @param path The path parts.
|
682 | */
|
683 | templatePath(...path: string[]): string;
|
684 |
|
685 | /**
|
686 | * Starts the generator again.
|
687 | *
|
688 | * @param The options to assign.
|
689 | */
|
690 | startOver(options?: T): void;
|
691 |
|
692 | // actions/fs mixin
|
693 | /**
|
694 | * Copy file from destination folder to another destination folder.
|
695 | * `mem-fs-editor` method's shortcut, for more information see [mem-fs-editor](https://github.com/SBoudrias/mem-fs-editor).
|
696 | * Shortcut for:
|
697 | * ```js
|
698 | * this.fs.copy(this.destinationPath(from), this.destinationPath(to))
|
699 | * ```
|
700 | */
|
701 | copyDestination: Editor['copy'];
|
702 |
|
703 | /**
|
704 | * Copy file from templates folder to destination folder.
|
705 | * `mem-fs-editor` method's shortcut, for more information see [mem-fs-editor](https://github.com/SBoudrias/mem-fs-editor).
|
706 | * Shortcut for:
|
707 | * ```js
|
708 | * this.fs.copy(this.templatePath(from), this.destinationPath(to))
|
709 | * ```
|
710 | */
|
711 | copyTemplate: Editor['copy'];
|
712 |
|
713 | /**
|
714 | * Deletes file from destination folder.
|
715 | * `mem-fs-editor` method's shortcut, for more information see [mem-fs-editor](https://github.com/SBoudrias/mem-fs-editor).
|
716 | * Shortcut for:
|
717 | * ```js
|
718 | * this.fs.delete(this.destinationPath(filepath))
|
719 | * ```
|
720 | */
|
721 | deleteDestination: Editor['delete'];
|
722 |
|
723 | /**
|
724 | * Checks whether a file exists in the destination folder.
|
725 | * `mem-fs-editor` method's shortcut, for more information see [mem-fs-editor](https://github.com/SBoudrias/mem-fs-editor).
|
726 | * Shortcut for:
|
727 | * ```js
|
728 | * this.fs.exists(this.destinationPath(filepath))
|
729 | * ```
|
730 | */
|
731 | existsDestination: Editor['exists'];
|
732 |
|
733 | /**
|
734 | * Move file from destination folder to another destination folder.
|
735 | * `mem-fs-editor` method's shortcut, for more information see [mem-fs-editor](https://github.com/SBoudrias/mem-fs-editor).
|
736 | * Shortcut for:
|
737 | * ```js
|
738 | * this.fs.move(this.destinationPath(from), this.destinationPath(to))
|
739 | * ```
|
740 | */
|
741 | moveDestination: Editor['move'];
|
742 |
|
743 | /**
|
744 | * Read file from destination folder.
|
745 | * `mem-fs-editor` method's shortcut, for more information see [mem-fs-editor](https://github.com/SBoudrias/mem-fs-editor).
|
746 | * Shortcut for:
|
747 | * ```js
|
748 | * this.fs.read(this.destinationPath(filepath))
|
749 | * ```
|
750 | */
|
751 | readDestination: Editor['read'];
|
752 |
|
753 | /**
|
754 | * Read JSON file from destination folder.
|
755 | * `mem-fs-editor` method's shortcut, for more information see [mem-fs-editor](https://github.com/SBoudrias/mem-fs-editor).
|
756 | * Shortcut for:
|
757 | * ```js
|
758 | * this.fs.readJSON(this.destinationPath(filepath))
|
759 | * ```
|
760 | */
|
761 | readDestinationJSON: Editor['readJSON'];
|
762 |
|
763 | /**
|
764 | * Read file from templates folder.
|
765 | * `mem-fs-editor` method's shortcut, for more information see [mem-fs-editor](https://github.com/SBoudrias/mem-fs-editor).
|
766 | * Shortcut for:
|
767 | * ```js
|
768 | * this.fs.read(this.templatePath(filepath))
|
769 | * ```
|
770 | */
|
771 | readTemplate: Editor['read'];
|
772 |
|
773 | /**
|
774 | * Copies a template from templates folder to the destination.
|
775 | *
|
776 | * @param source The template file, absolute or relative to {@link Generator.templatePath `templatePath()`}.
|
777 | * @param destination The destination, absolute or relative to {@link Generator.destinationPath `destinationPath()`}.
|
778 | * @param templateData The `ejs`-data or the name of the storage-key to get the data from.
|
779 | * @param templateOptions The `ejs`-options.
|
780 | * @param copyOptions The `mem-fs-editor` copy options.
|
781 | */
|
782 | renderTemplate(
|
783 | source: string | string[],
|
784 | destination?: string | string[],
|
785 | templateData?: TemplateData | string,
|
786 | templateOptions?: TemplateOptions | string,
|
787 | copyOptions?: CopyOptions,
|
788 | ): void;
|
789 |
|
790 | /**
|
791 | * Copies templates from the `templates` folder to the destination.
|
792 | *
|
793 | * @param templates The template files to copy.
|
794 | * @param templateData The ejs data or the name of the storage-key to get the data from.
|
795 | */
|
796 | renderTemplates(
|
797 | templates: Array<Generator.TemplateRenderOptions<this>>,
|
798 | templateData?: TemplateData | string,
|
799 | ): void;
|
800 |
|
801 | /**
|
802 | * Write file to destination folder
|
803 | * `mem-fs-editor` method's shortcut, for more information see [mem-fs-editor](https://github.com/SBoudrias/mem-fs-editor).
|
804 | * Shortcut for:
|
805 | * ```js
|
806 | * this.fs.write(this.destinationPath(filepath))
|
807 | * ```
|
808 | */
|
809 | writeDestination: Editor['write'];
|
810 |
|
811 | /**
|
812 | * Write json file to destination folder
|
813 | * `mem-fs-editor` method's shortcut, for more information see [mem-fs-editor](https://github.com/SBoudrias/mem-fs-editor).
|
814 | * Shortcut for:
|
815 | * ```js
|
816 | * this.fs.writeJSON(this.destinationPath(filepath))
|
817 | * ```
|
818 | */
|
819 | writeDestinationJSON: Editor['writeJSON'];
|
820 |
|
821 | // actions/help mixin
|
822 | /**
|
823 | * Generates a help-text for the arguments.
|
824 | *
|
825 | * @returns A help-text for the arguments.
|
826 | */
|
827 | argumentsHelp(): string;
|
828 |
|
829 | /**
|
830 | * Sets a custom {@link description `description`} for the help output.
|
831 | *
|
832 | * @param description The new description.
|
833 | */
|
834 | desc(description: string): this;
|
835 |
|
836 | /**
|
837 | * Tries to get the description from a `USAGE` file one folder above the source root, otherwise uses a default description.
|
838 | */
|
839 | help(): string;
|
840 |
|
841 | /**
|
842 | * Gets help text for options.
|
843 | */
|
844 | optionsHelp(): string;
|
845 |
|
846 | /**
|
847 | * Gets usage information for this generator, depending on its arguments or options.
|
848 | */
|
849 | usage(): string;
|
850 |
|
851 | // actions/spawn_command mixin
|
852 | /**
|
853 | * Normalizes a command across OS and spawns it (asynchronously).
|
854 | *
|
855 | * @param command The program to execute.
|
856 | * @param args A list of arguments to pass to the program.
|
857 | * @param opt Any cross-spawn options.
|
858 | */
|
859 | spawnCommand(command: string, args: string[], opt?: SpawnOptions): any;
|
860 |
|
861 | /**
|
862 | * Normalizes a command across the OS and spawns it (synchronously).
|
863 | *
|
864 | * @param command The program to execute.
|
865 | * @param args A list of arguments to pass to the program
|
866 | * @param opt Any cross-spawn options.
|
867 | */
|
868 | spawnCommandSync(command: string, args: string[], opt?: SpawnSyncOptions): any;
|
869 |
|
870 | // actions/install mixin
|
871 | /**
|
872 | * @deprecated
|
873 | * Receives a list of {@link components `components`} and an {@link options `options`} object to install through bower.
|
874 | *
|
875 | * The installation will automatically run during the run loop `install` phase.
|
876 | *
|
877 | * @param components Components to install
|
878 | * @param options Options to pass to `dargs` as arguments
|
879 | * @param spawnOptions Options to pass {@link spawn `child_process.spawn`}.
|
880 | */
|
881 | bowerInstall(components?: string | string[], options?: object, spawnOptions?: SpawnOptions): void;
|
882 |
|
883 | /**
|
884 | * @deprecated
|
885 | * Runs `npm` and `bower`, in sequence, in the generated directory and prints a
|
886 | * message to let the user know.
|
887 | *
|
888 | * @example
|
889 | * this.installDependencies({
|
890 | * bower: true,
|
891 | * npm: true
|
892 | * }).then(() => console.log('Everything is ready!'));
|
893 | *
|
894 | * @example
|
895 | * this.installDependencies({
|
896 | * yarn: {force: true},
|
897 | * npm: false
|
898 | * }).then(() => console.log('Everything is ready!'));
|
899 | *
|
900 | */
|
901 | installDependencies(options?: Generator.InstallOptions): void;
|
902 |
|
903 | /**
|
904 | * @deprecated
|
905 | * Receives a list of {@link packages `packages`} and an {@link options `options`} object to install through npm.
|
906 | *
|
907 | * The installation will automatically run during the run loop `install` phase.
|
908 | *
|
909 | * @param packages Packages to install
|
910 | * @param options Options to pass to `dargs` as arguments
|
911 | * @param spawnOptions Options to pass {@link spawn `child_process.spawn`}.
|
912 | */
|
913 | npmInstall(packages?: string | string[], options?: object, spawnOptions?: SpawnOptions): void;
|
914 |
|
915 | /**
|
916 | * @deprecated
|
917 | * Combine package manager cmd line arguments and run the `install` command.
|
918 | *
|
919 | * During the `install` step, every command will be scheduled to run once, on the
|
920 | * run loop.
|
921 | *
|
922 | * @param installer Which package manager to use
|
923 | * @param paths Packages to install. Use an empty string for `npm install`
|
924 | * @param options Options to pass to `dargs` as arguments
|
925 | * @param spawnOptions Options to pass {@link spawn `child_process.spawn`}.
|
926 | */
|
927 | scheduleInstallTask(
|
928 | installer: string,
|
929 | paths?: string | string[],
|
930 | options?: object,
|
931 | spawnOptions?: SpawnOptions,
|
932 | ): void;
|
933 |
|
934 | /**
|
935 | * @deprecated
|
936 | * Receives a list of {@link packages `packages`} and an {@link options `options`} object to install through npm.
|
937 | *
|
938 | * The installation will automatically run during the run loop `install` phase.
|
939 | *
|
940 | * @param packages Packages to install
|
941 | * @param options Options to pass to `dargs` as arguments
|
942 | * @param spawnOptions Options to pass {@link spawn `child_process.spawn`}.
|
943 | */
|
944 | yarnInstall(packages?: string | string[], options?: object, spawnOptions?: SpawnOptions): void;
|
945 |
|
946 | // actions/package.json
|
947 | /**
|
948 | * Adds dependencies to the destination `package.json`.
|
949 | *
|
950 | * @param dependencies
|
951 | * The packages to add.
|
952 | *
|
953 | * @returns
|
954 | * The newly added dependencies.
|
955 | */
|
956 | addDependencies(dependencies: Record<string, string> | string | string[]): Promise<Record<string, string>>;
|
957 |
|
958 | /**
|
959 | * Adds development-dependencies to the destination `package.json`.
|
960 | *
|
961 | * @param devDependencies
|
962 | * The packages to add to the development-dependencies.
|
963 | *
|
964 | * @returns
|
965 | * The newly added development-dependencies.
|
966 | */
|
967 | addDevDependencies(devDependencies: Record<string, string> | string | string[]): Promise<Record<string, string>>;
|
968 |
|
969 | // actions/user mixin
|
970 | readonly user: {
|
971 | readonly git: {
|
972 | /**
|
973 | * Retrieves user's email from Git in the global scope or the project scope
|
974 | * (it'll take what Git will use in the current context)
|
975 | * @return configured git email or undefined
|
976 | */
|
977 | email(): string;
|
978 |
|
979 | /**
|
980 | * Retrieves user's name from Git in the global scope or the project scope
|
981 | * (it'll take what Git will use in the current context)
|
982 | * @return configured git name or undefined
|
983 | */
|
984 | name(): string;
|
985 | };
|
986 | readonly github: {
|
987 | /**
|
988 | * Retrieves GitHub's username from the GitHub API
|
989 | * @return Resolved with the GitHub username or rejected if unable to
|
990 | * get the information
|
991 | */
|
992 | username(): Promise<string>;
|
993 | };
|
994 | };
|
995 | }
|
996 | export = Generator;
|
997 |
|
\ | No newline at end of file |