yeoman-generator 3.1.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/actions/install.js +9 -4
- package/lib/index.js +77 -35
- package/lib/util/prompt-suggestion.js +2 -2
- package/package.json +39 -35
package/lib/actions/install.js
CHANGED
|
@@ -41,7 +41,7 @@ install.scheduleInstallTask = function(installer, paths, options, spawnOptions)
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
// Return early if we're skipping installation
|
|
44
|
-
if (this.options.skipInstall) {
|
|
44
|
+
if (this.options.skipInstall || this.options['skip-install']) {
|
|
45
45
|
this.log(
|
|
46
46
|
'Skipping install command: ' + chalk.yellow(installer + ' ' + args.join(' '))
|
|
47
47
|
);
|
|
@@ -66,24 +66,29 @@ install.scheduleInstallTask = function(installer, paths, options, spawnOptions)
|
|
|
66
66
|
' is already installed, try running the following command manually: ' +
|
|
67
67
|
chalk.yellow(installer + ' ' + args.join(' '))
|
|
68
68
|
);
|
|
69
|
-
if (this.options.forceInstall) {
|
|
69
|
+
if (this.options.forceInstall || this.options['force-install']) {
|
|
70
70
|
this.emit('error', error);
|
|
71
71
|
}
|
|
72
|
+
|
|
72
73
|
done();
|
|
73
74
|
})
|
|
74
75
|
.on('exit', (code, signal) => {
|
|
75
76
|
this.emit(`${installer}Install:end`, paths);
|
|
76
|
-
if (
|
|
77
|
+
if (
|
|
78
|
+
(code || signal) &&
|
|
79
|
+
(this.options.forceInstall || this.options['force-install'])
|
|
80
|
+
) {
|
|
77
81
|
this.emit(
|
|
78
82
|
'error',
|
|
79
83
|
new Error(`Installation of ${installer} failed with code ${code || signal}`)
|
|
80
84
|
);
|
|
81
85
|
}
|
|
86
|
+
|
|
82
87
|
done();
|
|
83
88
|
});
|
|
84
89
|
},
|
|
85
90
|
{
|
|
86
|
-
once: installer + ' ' + args.join(' '),
|
|
91
|
+
once: installer + ' ' + args.join(' ') + ' ' + JSON.stringify(spawnOptions),
|
|
87
92
|
run: false
|
|
88
93
|
}
|
|
89
94
|
);
|
package/lib/index.js
CHANGED
|
@@ -167,7 +167,7 @@ class Generator extends EventEmitter {
|
|
|
167
167
|
questions = promptSuggestion.prefillQuestions(this.config, questions);
|
|
168
168
|
|
|
169
169
|
return this.env.adapter.prompt(questions).then(answers => {
|
|
170
|
-
if (!this.options['skip-cache']) {
|
|
170
|
+
if (!this.options['skip-cache'] && !this.options.skipCache) {
|
|
171
171
|
promptSuggestion.storeAnswers(this._globalConfig, questions, answers, false);
|
|
172
172
|
promptSuggestion.storeAnswers(this.config, questions, answers, true);
|
|
173
173
|
}
|
|
@@ -199,6 +199,7 @@ class Generator extends EventEmitter {
|
|
|
199
199
|
if ('defaults' in config) {
|
|
200
200
|
config.default = config.defaults;
|
|
201
201
|
}
|
|
202
|
+
|
|
202
203
|
config.description = config.description || config.desc;
|
|
203
204
|
|
|
204
205
|
_.defaults(config, {
|
|
@@ -261,6 +262,7 @@ class Generator extends EventEmitter {
|
|
|
261
262
|
if ('defaults' in config) {
|
|
262
263
|
config.default = config.defaults;
|
|
263
264
|
}
|
|
265
|
+
|
|
264
266
|
config.description = config.description || config.desc;
|
|
265
267
|
|
|
266
268
|
_.defaults(config, {
|
|
@@ -317,6 +319,7 @@ class Generator extends EventEmitter {
|
|
|
317
319
|
parsedOpts[name] = undefined;
|
|
318
320
|
return;
|
|
319
321
|
}
|
|
322
|
+
|
|
320
323
|
if (this._options[name] && option !== undefined) {
|
|
321
324
|
parsedOpts[name] = this._options[name].type(option);
|
|
322
325
|
}
|
|
@@ -486,67 +489,105 @@ class Generator extends EventEmitter {
|
|
|
486
489
|
_.invokeMap(this._composedWith, 'run');
|
|
487
490
|
});
|
|
488
491
|
|
|
489
|
-
|
|
492
|
+
// Maintain backward compatibility with the callback function
|
|
493
|
+
if (_.isFunction(cb)) {
|
|
494
|
+
promise.then(cb, cb);
|
|
495
|
+
}
|
|
496
|
+
|
|
490
497
|
return promise;
|
|
491
498
|
}
|
|
492
499
|
|
|
493
500
|
/**
|
|
494
501
|
* Compose this generator with another one.
|
|
495
|
-
* @param {String}
|
|
502
|
+
* @param {String|Object} generator The path to the generator module or an object (see examples)
|
|
496
503
|
* @param {Object} options The options passed to the Generator
|
|
497
|
-
* @
|
|
498
|
-
* @param {string} [settings.local] Path to a locally stored generator
|
|
499
|
-
* @param {String} [settings.link="weak"] If "strong", the composition will occured
|
|
500
|
-
* even when the composition is initialized by
|
|
501
|
-
* the end user
|
|
502
|
-
* @return {this}
|
|
504
|
+
* @return {this} This generator
|
|
503
505
|
*
|
|
504
506
|
* @example <caption>Using a peerDependency generator</caption>
|
|
505
507
|
* this.composeWith('bootstrap', { sass: true });
|
|
506
508
|
*
|
|
507
509
|
* @example <caption>Using a direct dependency generator</caption>
|
|
508
510
|
* this.composeWith(require.resolve('generator-bootstrap/app/main.js'), { sass: true });
|
|
511
|
+
*
|
|
512
|
+
* @example <caption>Passing a Generator class</caption>
|
|
513
|
+
* this.composeWith({ Generator: MyGenerator, path: '../generator-bootstrap/app/main.js' }, { sass: true });
|
|
509
514
|
*/
|
|
510
|
-
composeWith(
|
|
511
|
-
let
|
|
515
|
+
composeWith(generator, options) {
|
|
516
|
+
let instantiatedGenerator;
|
|
517
|
+
|
|
518
|
+
const instantiate = (Generator, path) => {
|
|
519
|
+
Generator.resolved = require.resolve(path);
|
|
520
|
+
Generator.namespace = this.env.namespace(path);
|
|
521
|
+
|
|
522
|
+
return this.env.instantiate(Generator, {
|
|
523
|
+
options,
|
|
524
|
+
arguments: options.arguments
|
|
525
|
+
});
|
|
526
|
+
};
|
|
527
|
+
|
|
512
528
|
options = options || {};
|
|
513
529
|
|
|
514
530
|
// Pass down the default options so they're correctly mirrored down the chain.
|
|
515
531
|
options = _.extend(
|
|
516
532
|
{
|
|
517
|
-
skipInstall: this.options.skipInstall,
|
|
518
|
-
'skip-install': this.options.skipInstall,
|
|
519
|
-
skipCache: this.options.skipCache,
|
|
520
|
-
'skip-cache': this.options.skipCache,
|
|
521
|
-
forceInstall: this.options.forceInstall,
|
|
522
|
-
'force-install': this.options.forceInstall
|
|
533
|
+
skipInstall: this.options.skipInstall || this.options['skip-install'],
|
|
534
|
+
'skip-install': this.options.skipInstall || this.options['skip-install'],
|
|
535
|
+
skipCache: this.options.skipCache || this.options['skip-cache'],
|
|
536
|
+
'skip-cache': this.options.skipCache || this.options['skip-cache'],
|
|
537
|
+
forceInstall: this.options.forceInstall || this.options['force-install'],
|
|
538
|
+
'force-install': this.options.forceInstall || this.options['force-install']
|
|
523
539
|
},
|
|
524
540
|
options
|
|
525
541
|
);
|
|
526
542
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
});
|
|
541
|
-
} else {
|
|
542
|
-
throw err;
|
|
543
|
+
if (typeof generator === 'string') {
|
|
544
|
+
try {
|
|
545
|
+
const Generator = require(generator); // eslint-disable-line import/no-dynamic-require
|
|
546
|
+
instantiatedGenerator = instantiate(Generator, generator);
|
|
547
|
+
} catch (err) {
|
|
548
|
+
if (err.code === 'MODULE_NOT_FOUND') {
|
|
549
|
+
instantiatedGenerator = this.env.create(generator, {
|
|
550
|
+
options,
|
|
551
|
+
arguments: options.arguments
|
|
552
|
+
});
|
|
553
|
+
} else {
|
|
554
|
+
throw err;
|
|
555
|
+
}
|
|
543
556
|
}
|
|
557
|
+
} else {
|
|
558
|
+
assert(
|
|
559
|
+
generator.Generator,
|
|
560
|
+
`${chalk.red('Missing Generator property')}\n` +
|
|
561
|
+
`When passing an object to Generator${chalk.cyan(
|
|
562
|
+
'#composeWith'
|
|
563
|
+
)} include the generator class to run in the ${chalk.cyan(
|
|
564
|
+
'Generator'
|
|
565
|
+
)} property\n\n` +
|
|
566
|
+
`this.composeWith({\n` +
|
|
567
|
+
` ${chalk.yellow('Generator')}: MyGenerator,\n` +
|
|
568
|
+
` ...\n` +
|
|
569
|
+
`});`
|
|
570
|
+
);
|
|
571
|
+
assert(
|
|
572
|
+
typeof generator.path === 'string',
|
|
573
|
+
`${chalk.red('path property is not a string')}\n` +
|
|
574
|
+
`When passing an object to Generator${chalk.cyan(
|
|
575
|
+
'#composeWith'
|
|
576
|
+
)} include the path to the generators files in the ${chalk.cyan(
|
|
577
|
+
'path'
|
|
578
|
+
)} property\n\n` +
|
|
579
|
+
`this.composeWith({\n` +
|
|
580
|
+
` ${chalk.yellow('path')}: '../my-generator',\n` +
|
|
581
|
+
` ...\n` +
|
|
582
|
+
`});`
|
|
583
|
+
);
|
|
584
|
+
instantiatedGenerator = instantiate(generator.Generator, generator.path);
|
|
544
585
|
}
|
|
545
586
|
|
|
546
587
|
if (this._running) {
|
|
547
|
-
|
|
588
|
+
instantiatedGenerator.run();
|
|
548
589
|
} else {
|
|
549
|
-
this._composedWith.push(
|
|
590
|
+
this._composedWith.push(instantiatedGenerator);
|
|
550
591
|
}
|
|
551
592
|
|
|
552
593
|
return this;
|
|
@@ -696,6 +737,7 @@ class Generator extends EventEmitter {
|
|
|
696
737
|
if (!Array.isArray(streams)) {
|
|
697
738
|
streams = [streams];
|
|
698
739
|
}
|
|
740
|
+
|
|
699
741
|
this._transformStreams = this._transformStreams.concat(streams);
|
|
700
742
|
return this;
|
|
701
743
|
}
|
|
@@ -36,8 +36,8 @@ const getCheckboxDefault = (question, defaultValue) => {
|
|
|
36
36
|
* @private
|
|
37
37
|
*/
|
|
38
38
|
const getListDefault = (question, defaultValue) => {
|
|
39
|
-
const choiceValues = question.choices.map(
|
|
40
|
-
|
|
39
|
+
const choiceValues = question.choices.map(choice =>
|
|
40
|
+
typeof choice === 'object' ? choice.value : choice
|
|
41
41
|
);
|
|
42
42
|
return choiceValues.indexOf(defaultValue);
|
|
43
43
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yeoman-generator",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "Rails-inspired generator system that provides scaffolding for your apps",
|
|
5
5
|
"homepage": "http://yeoman.io",
|
|
6
6
|
"author": "Yeoman",
|
|
@@ -22,25 +22,25 @@
|
|
|
22
22
|
"app"
|
|
23
23
|
],
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"coveralls": "^3.0.
|
|
26
|
-
"eslint": "^5.0
|
|
27
|
-
"eslint-config-prettier": "^
|
|
28
|
-
"eslint-config-xo": "^0.
|
|
29
|
-
"eslint-plugin-prettier": "^
|
|
30
|
-
"husky": "^
|
|
31
|
-
"inquirer": "^6.
|
|
32
|
-
"jsdoc": "^3.
|
|
33
|
-
"lint-staged": "^
|
|
34
|
-
"mocha": "^
|
|
25
|
+
"coveralls": "^3.0.3",
|
|
26
|
+
"eslint": "^5.16.0",
|
|
27
|
+
"eslint-config-prettier": "^4.3.0",
|
|
28
|
+
"eslint-config-xo": "^0.26.0",
|
|
29
|
+
"eslint-plugin-prettier": "^3.1.0",
|
|
30
|
+
"husky": "^2.3.0",
|
|
31
|
+
"inquirer": "^6.3.1",
|
|
32
|
+
"jsdoc": "^3.6.2",
|
|
33
|
+
"lint-staged": "^8.1.7",
|
|
34
|
+
"mocha": "^6.1.4",
|
|
35
35
|
"mockery": "^2.1.0",
|
|
36
|
-
"nock": "^
|
|
37
|
-
"nyc": "^
|
|
38
|
-
"prettier": "^1.
|
|
39
|
-
"proxyquire": "^2.0
|
|
40
|
-
"sinon": "^
|
|
36
|
+
"nock": "^10.0.6",
|
|
37
|
+
"nyc": "^14.1.1",
|
|
38
|
+
"prettier": "^1.17.1",
|
|
39
|
+
"proxyquire": "^2.1.0",
|
|
40
|
+
"sinon": "^7.3.2",
|
|
41
41
|
"tui-jsdoc-template": "^1.2.2",
|
|
42
42
|
"yeoman-assert": "^3.1.1",
|
|
43
|
-
"yeoman-test": "^1.
|
|
43
|
+
"yeoman-test": "^1.9.1"
|
|
44
44
|
},
|
|
45
45
|
"license": "BSD-2-Clause",
|
|
46
46
|
"repository": "yeoman/generator",
|
|
@@ -51,35 +51,34 @@
|
|
|
51
51
|
"pretest": "eslint .",
|
|
52
52
|
"test": "nyc mocha",
|
|
53
53
|
"doc": "jsdoc -c jsdoc.json",
|
|
54
|
-
"coverage": "nyc report --reporter=text-lcov | coveralls"
|
|
55
|
-
"precommit": "lint-staged"
|
|
54
|
+
"coverage": "nyc report --reporter=text-lcov | coveralls"
|
|
56
55
|
},
|
|
57
56
|
"dependencies": {
|
|
58
|
-
"async": "^2.6.
|
|
59
|
-
"chalk": "^2.
|
|
57
|
+
"async": "^2.6.2",
|
|
58
|
+
"chalk": "^2.4.2",
|
|
60
59
|
"cli-table": "^0.3.1",
|
|
61
60
|
"cross-spawn": "^6.0.5",
|
|
62
|
-
"dargs": "^6.
|
|
61
|
+
"dargs": "^6.1.0",
|
|
63
62
|
"dateformat": "^3.0.3",
|
|
64
|
-
"debug": "^
|
|
63
|
+
"debug": "^4.1.1",
|
|
65
64
|
"detect-conflict": "^1.0.0",
|
|
66
65
|
"error": "^7.0.2",
|
|
67
66
|
"find-up": "^3.0.0",
|
|
68
|
-
"github-username": "^
|
|
69
|
-
"istextorbinary": "^2.
|
|
70
|
-
"lodash": "^4.17.
|
|
71
|
-
"make-dir": "^
|
|
72
|
-
"mem-fs-editor": "^
|
|
67
|
+
"github-username": "^3.0.0",
|
|
68
|
+
"istextorbinary": "^2.5.1",
|
|
69
|
+
"lodash": "^4.17.11",
|
|
70
|
+
"make-dir": "^3.0.0",
|
|
71
|
+
"mem-fs-editor": "^6.0.0",
|
|
73
72
|
"minimist": "^1.2.0",
|
|
74
|
-
"pretty-bytes": "^5.
|
|
75
|
-
"read-chunk": "^2.
|
|
76
|
-
"read-pkg-up": "^
|
|
77
|
-
"rimraf": "^2.6.
|
|
73
|
+
"pretty-bytes": "^5.2.0",
|
|
74
|
+
"read-chunk": "^3.2.0",
|
|
75
|
+
"read-pkg-up": "^5.0.0",
|
|
76
|
+
"rimraf": "^2.6.3",
|
|
78
77
|
"run-async": "^2.0.0",
|
|
79
|
-
"shelljs": "^0.8.
|
|
78
|
+
"shelljs": "^0.8.3",
|
|
80
79
|
"text-table": "^0.2.0",
|
|
81
|
-
"through2": "^
|
|
82
|
-
"yeoman-environment": "^2.
|
|
80
|
+
"through2": "^3.0.1",
|
|
81
|
+
"yeoman-environment": "^2.3.4"
|
|
83
82
|
},
|
|
84
83
|
"lint-staged": {
|
|
85
84
|
"*.js": [
|
|
@@ -112,5 +111,10 @@
|
|
|
112
111
|
"plugins": [
|
|
113
112
|
"prettier"
|
|
114
113
|
]
|
|
114
|
+
},
|
|
115
|
+
"husky": {
|
|
116
|
+
"hooks": {
|
|
117
|
+
"pre-commit": "lint-staged"
|
|
118
|
+
}
|
|
115
119
|
}
|
|
116
120
|
}
|