UNPKG

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