UNPKG

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