yeoman-environment 3.18.3 → 3.19.0
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 +45 -28
- package/package.json +2 -1
package/lib/environment.js
CHANGED
|
@@ -15,7 +15,10 @@ const npmlog = require('npmlog');
|
|
|
15
15
|
const semver = require('semver');
|
|
16
16
|
const slash = require('slash');
|
|
17
17
|
const {TrackerGroup} = require('are-we-there-yet');
|
|
18
|
-
const {
|
|
18
|
+
const {transform} = require('p-transform');
|
|
19
|
+
const readableStream = require('readable-stream');
|
|
20
|
+
|
|
21
|
+
const {pipeline} = readableStream.promises;
|
|
19
22
|
|
|
20
23
|
const ENVIRONMENT_VERSION = require('../package.json').version;
|
|
21
24
|
const Store = require('./store');
|
|
@@ -49,7 +52,7 @@ function splitArgsFromString(argsString) {
|
|
|
49
52
|
if (!argsString) {
|
|
50
53
|
return result;
|
|
51
54
|
}
|
|
52
|
-
const quoteSeparatedArgs = argsString.split(/("[^"]*")/).filter(
|
|
55
|
+
const quoteSeparatedArgs = argsString.split(/("[^"]*")/).filter(Boolean);
|
|
53
56
|
for (const arg of quoteSeparatedArgs) {
|
|
54
57
|
if (arg.match('\x22')) {
|
|
55
58
|
result.push(arg.replace(/"/g, ''));
|
|
@@ -850,15 +853,6 @@ class Environment extends Base {
|
|
|
850
853
|
create(namespaceOrPath, args, options) {
|
|
851
854
|
const namespace = this.toNamespace ? this.toNamespace(namespaceOrPath) : undefined;
|
|
852
855
|
|
|
853
|
-
let maybeGenerator;
|
|
854
|
-
if (namespace && this.getByNamespace) {
|
|
855
|
-
maybeGenerator = this.getByNamespace(namespace);
|
|
856
|
-
if (!maybeGenerator) {
|
|
857
|
-
this.lookupLocalNamespaces(namespace);
|
|
858
|
-
maybeGenerator = this.getByNamespace(namespace);
|
|
859
|
-
}
|
|
860
|
-
}
|
|
861
|
-
|
|
862
856
|
const checkGenerator = Generator => {
|
|
863
857
|
if (namespace && Generator && Generator.namespace && Generator.namespace !== namespace.namespace && Generator.namespace !== Environment.UNKNOWN_NAMESPACE) {
|
|
864
858
|
// Update namespace object in case of aliased namespace.
|
|
@@ -886,6 +880,19 @@ class Environment extends Base {
|
|
|
886
880
|
return Generator;
|
|
887
881
|
};
|
|
888
882
|
|
|
883
|
+
if (typeof namespaceOrPath !== 'string') {
|
|
884
|
+
return this.instantiate(checkGenerator(namespaceOrPath), args, options);
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
let maybeGenerator;
|
|
888
|
+
if (namespace && this.getByNamespace) {
|
|
889
|
+
maybeGenerator = this.getByNamespace(namespace);
|
|
890
|
+
if (!maybeGenerator) {
|
|
891
|
+
this.lookupLocalNamespaces(namespace);
|
|
892
|
+
maybeGenerator = this.getByNamespace(namespace);
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
|
|
889
896
|
maybeGenerator = maybeGenerator || this.get(namespaceOrPath);
|
|
890
897
|
if (maybeGenerator && maybeGenerator.then) {
|
|
891
898
|
return Promise.resolve(maybeGenerator)
|
|
@@ -1309,31 +1316,41 @@ class Environment extends Base {
|
|
|
1309
1316
|
|
|
1310
1317
|
let {log = true} = options;
|
|
1311
1318
|
|
|
1312
|
-
if (log) {
|
|
1313
|
-
npmlog.tracker = new TrackerGroup();
|
|
1314
|
-
npmlog.enableProgress();
|
|
1315
|
-
log = npmlog.newItem(name);
|
|
1316
|
-
}
|
|
1317
|
-
|
|
1318
1319
|
if (!Array.isArray(transformStreams)) {
|
|
1319
1320
|
transformStreams = [transformStreams];
|
|
1320
1321
|
}
|
|
1321
|
-
|
|
1322
|
+
|
|
1323
|
+
const progress = this.adapter.progress ? this.adapter.progress.bind(this.adapter) : (async callback => {
|
|
1324
|
+
if (log) {
|
|
1325
|
+
npmlog.tracker = new TrackerGroup();
|
|
1326
|
+
npmlog.enableProgress();
|
|
1327
|
+
log = npmlog.newItem(name);
|
|
1328
|
+
}
|
|
1329
|
+
try {
|
|
1330
|
+
await callback({
|
|
1331
|
+
step(prefix, message, ...args) {
|
|
1332
|
+
if (log) {
|
|
1333
|
+
log.completeWork(10);
|
|
1334
|
+
npmlog.info(prefix, message, ...args);
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
});
|
|
1338
|
+
} finally {
|
|
1339
|
+
if (log) {
|
|
1340
|
+
log.finish();
|
|
1341
|
+
npmlog.disableProgress();
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
});
|
|
1345
|
+
|
|
1346
|
+
return progress(({step}) => pipeline(
|
|
1322
1347
|
stream,
|
|
1323
1348
|
createModifiedTransform(),
|
|
1324
1349
|
...transformStreams,
|
|
1325
1350
|
transform(file => {
|
|
1326
|
-
|
|
1327
|
-
log.completeWork(10);
|
|
1328
|
-
npmlog.info('Completed', path.relative(this.logCwd, file.path));
|
|
1329
|
-
}
|
|
1351
|
+
step('Completed', path.relative(this.logCwd, file.path));
|
|
1330
1352
|
}, 'environment:log')
|
|
1331
|
-
)
|
|
1332
|
-
if (log) {
|
|
1333
|
-
log.finish();
|
|
1334
|
-
npmlog.disableProgress();
|
|
1335
|
-
}
|
|
1336
|
-
});
|
|
1353
|
+
));
|
|
1337
1354
|
}
|
|
1338
1355
|
|
|
1339
1356
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yeoman-environment",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.19.0",
|
|
4
4
|
"description": "Handles the lifecyle and bootstrapping of generators in a specific environment",
|
|
5
5
|
"homepage": "http://yeoman.io",
|
|
6
6
|
"author": "Yeoman",
|
|
@@ -91,6 +91,7 @@
|
|
|
91
91
|
"pacote": "^12.0.2",
|
|
92
92
|
"preferred-pm": "^3.0.3",
|
|
93
93
|
"pretty-bytes": "^5.3.0",
|
|
94
|
+
"readable-stream": "^4.3.0",
|
|
94
95
|
"semver": "^7.1.3",
|
|
95
96
|
"slash": "^3.0.0",
|
|
96
97
|
"strip-ansi": "^6.0.0",
|