yeoman-environment 3.14.1 → 3.15.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/environment.js +12 -13
- package/lib/util/conflicter.js +14 -2
- package/package.json +1 -1
package/lib/environment.js
CHANGED
|
@@ -33,6 +33,9 @@ const {
|
|
|
33
33
|
createYoRcTransform,
|
|
34
34
|
createYoResolveTransform
|
|
35
35
|
} = require('./util/transform');
|
|
36
|
+
const {requireOrImport} = require('./util/esm');
|
|
37
|
+
|
|
38
|
+
const {isFilePending} = FileEditor.State;
|
|
36
39
|
|
|
37
40
|
/**
|
|
38
41
|
* Two-step argument splitting function that first splits arguments in quotes,
|
|
@@ -562,13 +565,15 @@ class Environment extends Base {
|
|
|
562
565
|
return;
|
|
563
566
|
}
|
|
564
567
|
|
|
565
|
-
|
|
566
|
-
const importModule = async () =>
|
|
567
|
-
const
|
|
568
|
+
const {importGenerator, resolved} = meta;
|
|
569
|
+
const importModule = async () => requireOrImport(resolved);
|
|
570
|
+
const importGeneratorClass = async () => this._findGeneratorClass(await importGenerator(), meta);
|
|
571
|
+
const instantiate = async (args, options) => this.instantiate(await importGeneratorClass(), args, options);
|
|
568
572
|
const instantiateHelp = async () => instantiate([], {help: true});
|
|
569
573
|
const newMeta = {
|
|
570
574
|
...meta,
|
|
571
575
|
importModule,
|
|
576
|
+
importGeneratorClass,
|
|
572
577
|
instantiate,
|
|
573
578
|
instantiateHelp
|
|
574
579
|
};
|
|
@@ -1230,12 +1235,13 @@ class Environment extends Base {
|
|
|
1230
1235
|
/**
|
|
1231
1236
|
* Apply transform streams to file in MemFs.
|
|
1232
1237
|
* @param {Transform[]} transformStreams - transform streams to be applied.
|
|
1233
|
-
* @param {Stream} [
|
|
1238
|
+
* @param {{ streamOptions: any; stream: Stream; name: string; log: boolean }} [options] - files stream, defaults to this.sharedFs.stream().
|
|
1234
1239
|
* @return {Promise}
|
|
1235
1240
|
*/
|
|
1236
1241
|
applyTransforms(transformStreams, options = {}) {
|
|
1237
1242
|
const {
|
|
1238
|
-
|
|
1243
|
+
streamOptions = {filter: file => isFilePending(file)},
|
|
1244
|
+
stream = this.sharedFs.stream(streamOptions),
|
|
1239
1245
|
name = 'Transforming'
|
|
1240
1246
|
} = options;
|
|
1241
1247
|
|
|
@@ -1279,14 +1285,7 @@ class Environment extends Base {
|
|
|
1279
1285
|
|
|
1280
1286
|
const conflicterStatus = {};
|
|
1281
1287
|
if (this.enableConflicterIgnore) {
|
|
1282
|
-
conflicterStatus.
|
|
1283
|
-
key: 'i',
|
|
1284
|
-
name: 'ignore, do not overwrite and remember (experimental)',
|
|
1285
|
-
value: ({relativeFilePath}) => {
|
|
1286
|
-
this.fs.append(`${this.cwd}/.yo-resolve`, `${relativeFilePath} skip`, {create: true});
|
|
1287
|
-
return 'skip';
|
|
1288
|
-
}
|
|
1289
|
-
}];
|
|
1288
|
+
conflicterStatus.fs = this.fs;
|
|
1290
1289
|
}
|
|
1291
1290
|
|
|
1292
1291
|
this.fs.commit([
|
package/lib/util/conflicter.js
CHANGED
|
@@ -315,8 +315,20 @@ class Conflicter {
|
|
|
315
315
|
value: 'edit'
|
|
316
316
|
}
|
|
317
317
|
);
|
|
318
|
-
if (conflicterStatus
|
|
319
|
-
|
|
318
|
+
if (conflicterStatus) {
|
|
319
|
+
if (conflicterStatus.fileActions) {
|
|
320
|
+
prompt.choices.push(...conflicterStatus.fileActions);
|
|
321
|
+
}
|
|
322
|
+
if (conflicterStatus.fs) {
|
|
323
|
+
prompt.choices.push({
|
|
324
|
+
key: 'i',
|
|
325
|
+
name: 'ignore, do not overwrite and remember (experimental)',
|
|
326
|
+
value: ({relativeFilePath}) => {
|
|
327
|
+
conflicterStatus.fs.append(`${this.cwd}/.yo-resolve`, `${relativeFilePath} skip`, {create: true});
|
|
328
|
+
return 'skip';
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
}
|
|
320
332
|
}
|
|
321
333
|
}
|
|
322
334
|
|