UNPKG

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