yeoman-environment 4.0.0-beta.3 → 4.0.0-beta.5
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/dist/environment-base.d.ts +8 -4
- package/dist/environment-base.js +43 -29
- package/dist/environment-full.js +1 -1
- package/dist/util/namespace.js +3 -3
- package/dist/util/util.js +1 -1
- package/package.json +10 -11
|
@@ -227,6 +227,14 @@ export default class EnvironmentBase extends EventEmitter implements BaseEnviron
|
|
|
227
227
|
*/
|
|
228
228
|
alias(match: string | RegExp, value: string): this;
|
|
229
229
|
alias(value: string): string;
|
|
230
|
+
/**
|
|
231
|
+
* Watch for package.json and queue package manager install task.
|
|
232
|
+
*/
|
|
233
|
+
watchForPackageManagerInstall({ cwd, queueTask, installTask, }?: {
|
|
234
|
+
cwd?: string;
|
|
235
|
+
queueTask?: boolean;
|
|
236
|
+
installTask?: (nodePackageManager: string | undefined, defaultTask: () => Promise<boolean>) => void | Promise<void>;
|
|
237
|
+
}): void;
|
|
230
238
|
/**
|
|
231
239
|
* Start Environment queue
|
|
232
240
|
* @param {Object} options - Conflicter options.
|
|
@@ -236,10 +244,6 @@ export default class EnvironmentBase extends EventEmitter implements BaseEnviron
|
|
|
236
244
|
* Queue environment's commit task.
|
|
237
245
|
*/
|
|
238
246
|
protected queueCommit(): void;
|
|
239
|
-
/**
|
|
240
|
-
* Queue environment's package manager install task.
|
|
241
|
-
*/
|
|
242
|
-
protected queuePackageManagerInstall(): void;
|
|
243
247
|
/**
|
|
244
248
|
* Registers a specific `generator` to this environment. This generator is stored under
|
|
245
249
|
* provided namespace, or a default namespace format if none if available.
|
package/dist/environment-base.js
CHANGED
|
@@ -85,6 +85,7 @@ const getComposeOptions = (...varargs) => {
|
|
|
85
85
|
export function removePropertiesWithNullishValues(object) {
|
|
86
86
|
return Object.fromEntries(Object.entries(object).filter(([_key, value]) => value !== undefined && value !== null));
|
|
87
87
|
}
|
|
88
|
+
// eslint-disable-next-line unicorn/prefer-event-target
|
|
88
89
|
export default class EnvironmentBase extends EventEmitter {
|
|
89
90
|
cwd;
|
|
90
91
|
adapter;
|
|
@@ -508,6 +509,41 @@ export default class EnvironmentBase extends EventEmitter {
|
|
|
508
509
|
return resolved.replace(alias.match, alias.value);
|
|
509
510
|
}, match);
|
|
510
511
|
}
|
|
512
|
+
/**
|
|
513
|
+
* Watch for package.json and queue package manager install task.
|
|
514
|
+
*/
|
|
515
|
+
watchForPackageManagerInstall({ cwd, queueTask, installTask, } = {}) {
|
|
516
|
+
if (cwd && !installTask) {
|
|
517
|
+
throw new Error(`installTask is required when using a custom cwd`);
|
|
518
|
+
}
|
|
519
|
+
const npmCwd = cwd ?? this.cwd;
|
|
520
|
+
const queueInstallTask = () => {
|
|
521
|
+
this.queueTask('install', async () => {
|
|
522
|
+
if (this.compatibilityMode === 'v4') {
|
|
523
|
+
debug('Running in generator < 5 compatibility. Package manager install is done by the generator.');
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
const { adapter, sharedFs: memFs } = this;
|
|
527
|
+
const { skipInstall, nodePackageManager } = this.options;
|
|
528
|
+
await packageManagerInstallTask({
|
|
529
|
+
adapter,
|
|
530
|
+
memFs,
|
|
531
|
+
packageJsonLocation: npmCwd,
|
|
532
|
+
skipInstall,
|
|
533
|
+
nodePackageManager,
|
|
534
|
+
customInstallTask: installTask ?? this.composedStore.customInstallTask,
|
|
535
|
+
});
|
|
536
|
+
}, { once: `package manager install ${npmCwd}` });
|
|
537
|
+
};
|
|
538
|
+
this.sharedFs.on('change', file => {
|
|
539
|
+
if (file === join(npmCwd, 'package.json')) {
|
|
540
|
+
queueInstallTask();
|
|
541
|
+
}
|
|
542
|
+
});
|
|
543
|
+
if (queueTask) {
|
|
544
|
+
queueInstallTask();
|
|
545
|
+
}
|
|
546
|
+
}
|
|
511
547
|
/**
|
|
512
548
|
* Start Environment queue
|
|
513
549
|
* @param {Object} options - Conflicter options.
|
|
@@ -519,7 +555,10 @@ export default class EnvironmentBase extends EventEmitter {
|
|
|
519
555
|
this.conflicterOptions = pick(defaults({}, this.options, options), ['force', 'bail', 'ignoreWhitespace', 'dryRun', 'skipYoResolve']);
|
|
520
556
|
this.conflicterOptions.cwd = this.logCwd;
|
|
521
557
|
this.queueCommit();
|
|
522
|
-
this.
|
|
558
|
+
this.queueTask('install', () => {
|
|
559
|
+
// Postpone watchForPackageManagerInstall to install priority since env's cwd can be changed by generators
|
|
560
|
+
this.watchForPackageManagerInstall({ queueTask: true });
|
|
561
|
+
});
|
|
523
562
|
/*
|
|
524
563
|
* Listen to errors and reject if emmited.
|
|
525
564
|
* Some cases the generator relied at the behavior that the running process
|
|
@@ -570,6 +609,9 @@ export default class EnvironmentBase extends EventEmitter {
|
|
|
570
609
|
const queueCommit = () => {
|
|
571
610
|
debug('Queueing conflicts task');
|
|
572
611
|
this.queueTask('environment:conflicts', async () => {
|
|
612
|
+
debug('Adding queueCommit listener');
|
|
613
|
+
// Conflicter can change files add listener before commit task.
|
|
614
|
+
this.sharedFs.once('change', queueCommit);
|
|
573
615
|
debug('Running conflicts');
|
|
574
616
|
const { customCommitTask = () => commitSharedFsTask(this) } = this.composedStore;
|
|
575
617
|
if (typeof customCommitTask === 'function') {
|
|
@@ -578,40 +620,12 @@ export default class EnvironmentBase extends EventEmitter {
|
|
|
578
620
|
else {
|
|
579
621
|
debug('Ignoring commit, custom commit was provided');
|
|
580
622
|
}
|
|
581
|
-
debug('Adding queueCommit listener');
|
|
582
|
-
this.sharedFs.once('change', queueCommit);
|
|
583
623
|
}, {
|
|
584
624
|
once: 'write memory fs to disk',
|
|
585
625
|
});
|
|
586
626
|
};
|
|
587
627
|
queueCommit();
|
|
588
628
|
}
|
|
589
|
-
/**
|
|
590
|
-
* Queue environment's package manager install task.
|
|
591
|
-
*/
|
|
592
|
-
queuePackageManagerInstall() {
|
|
593
|
-
this.queueTask('install', async () => {
|
|
594
|
-
if (this.compatibilityMode === 'v4') {
|
|
595
|
-
debug('Running in generator < 5 compatibility. Package manager install is done by the generator.');
|
|
596
|
-
return;
|
|
597
|
-
}
|
|
598
|
-
const { adapter, sharedFs: memFs } = this;
|
|
599
|
-
const { skipInstall, nodePackageManager } = this.options;
|
|
600
|
-
const { customInstallTask } = this.composedStore;
|
|
601
|
-
await packageManagerInstallTask({
|
|
602
|
-
adapter,
|
|
603
|
-
memFs,
|
|
604
|
-
packageJsonLocation: this.cwd,
|
|
605
|
-
skipInstall,
|
|
606
|
-
nodePackageManager,
|
|
607
|
-
customInstallTask,
|
|
608
|
-
});
|
|
609
|
-
memFs.once('change', file => {
|
|
610
|
-
if (file === join(this.cwd, 'package.json'))
|
|
611
|
-
this.queuePackageManagerInstall();
|
|
612
|
-
});
|
|
613
|
-
}, { once: 'package manager install' });
|
|
614
|
-
}
|
|
615
629
|
/**
|
|
616
630
|
* Registers a specific `generator` to this environment. This generator is stored under
|
|
617
631
|
* provided namespace, or a default namespace format if none if available.
|
package/dist/environment-full.js
CHANGED
package/dist/util/namespace.js
CHANGED
|
@@ -44,17 +44,17 @@ export const asNamespace = (filepath, { lookups = defaultLookups }) => {
|
|
|
44
44
|
// If `ns` contains a lookup dir in its path, remove it.
|
|
45
45
|
for (const lookup of nsLookups) {
|
|
46
46
|
// Only match full directory (begin with leading slash or start of input, end with trailing slash)
|
|
47
|
-
ns = ns.
|
|
47
|
+
ns = ns.replaceAll(new RegExp(`(?:/|^)${escapeRegExp(lookup)}(?=/)`, 'g'), '');
|
|
48
48
|
}
|
|
49
49
|
const folders = ns.split('/');
|
|
50
50
|
const scope = findLast(folders, folder => folder.startsWith('@'));
|
|
51
51
|
// Cleanup `ns` from unwanted parts and then normalize slashes to `:`
|
|
52
52
|
ns = ns
|
|
53
|
-
.
|
|
53
|
+
.replaceAll('//', '') // Remove double `/`
|
|
54
54
|
.replace(/(.*generator-)/, '') // Remove before `generator-`
|
|
55
55
|
.replace(/\/(index|main)$/, '') // Remove `/index` or `/main`
|
|
56
56
|
.replace(/^\//, '') // Remove leading `/`
|
|
57
|
-
.
|
|
57
|
+
.replaceAll(/\/+/g, ':'); // Replace slashes by `:`
|
|
58
58
|
if (scope) {
|
|
59
59
|
ns = `${scope}/${ns}`;
|
|
60
60
|
}
|
package/dist/util/util.js
CHANGED
|
@@ -24,7 +24,7 @@ export function splitArgsFromString(argsString) {
|
|
|
24
24
|
const quoteSeparatedArgs = argsString.split(/("[^"]*")/).filter(Boolean);
|
|
25
25
|
for (const arg of quoteSeparatedArgs) {
|
|
26
26
|
if (arg.includes('"')) {
|
|
27
|
-
result.push(arg.
|
|
27
|
+
result.push(arg.replaceAll('"', ''));
|
|
28
28
|
}
|
|
29
29
|
else {
|
|
30
30
|
result = result.concat(arg.trim().split(' '));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yeoman-environment",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.5",
|
|
4
4
|
"description": "Handles the lifecyle and bootstrapping of generators in a specific environment",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"development",
|
|
@@ -58,14 +58,14 @@
|
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@yeoman/adapter": "^1.1.0",
|
|
61
|
-
"@yeoman/conflicter": "^1.0.
|
|
61
|
+
"@yeoman/conflicter": "^1.0.10",
|
|
62
62
|
"@yeoman/namespace": "^1.0.0",
|
|
63
63
|
"@yeoman/transform": "^1.2.0",
|
|
64
64
|
"arrify": "^3.0.0",
|
|
65
65
|
"chalk": "^5.2.0",
|
|
66
|
-
"commander": "^
|
|
66
|
+
"commander": "^11.0.0",
|
|
67
67
|
"debug": "^4.3.4",
|
|
68
|
-
"execa": "^
|
|
68
|
+
"execa": "^8.0.1",
|
|
69
69
|
"fly-import": "^0.3.0",
|
|
70
70
|
"globby": "^13.1.4",
|
|
71
71
|
"grouped-queue": "^2.0.0",
|
|
@@ -82,21 +82,20 @@
|
|
|
82
82
|
"@types/debug": "^4.1.8",
|
|
83
83
|
"@types/lodash-es": "^4.17.7",
|
|
84
84
|
"@types/semver": "^7.5.0",
|
|
85
|
-
"c8": "^
|
|
86
|
-
"cpy-cli": "^
|
|
85
|
+
"c8": "^8.0.0",
|
|
86
|
+
"cpy-cli": "^5.0.0",
|
|
87
87
|
"esmocha": "^1.0.1",
|
|
88
88
|
"fs-extra": "^11.1.1",
|
|
89
89
|
"inquirer": "^9.2.6",
|
|
90
90
|
"jsdoc": "^4.0.2",
|
|
91
|
-
"prettier": "
|
|
91
|
+
"prettier": "3.0.3",
|
|
92
92
|
"prettier-plugin-packagejson": "^2.4.3",
|
|
93
93
|
"rimraf": "^5.0.0",
|
|
94
94
|
"sinon": "^15.0.4",
|
|
95
95
|
"sinon-test": "^3.1.5",
|
|
96
96
|
"strip-ansi": "^7.0.1",
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
"xo": "0.54.2",
|
|
97
|
+
"typescript": "5.2.2",
|
|
98
|
+
"xo": "0.56.0",
|
|
100
99
|
"yeoman-assert": "^3.1.1",
|
|
101
100
|
"yeoman-generator": "^5.9.0",
|
|
102
101
|
"yeoman-test": "^8.0.0-rc.1"
|
|
@@ -106,6 +105,6 @@
|
|
|
106
105
|
"mem-fs": "^3.0.0"
|
|
107
106
|
},
|
|
108
107
|
"engines": {
|
|
109
|
-
"node": "^
|
|
108
|
+
"node": "^18.17.0 || >=20.5.0"
|
|
110
109
|
}
|
|
111
110
|
}
|