yeoman-environment 6.0.0 → 6.1.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/dist/composed-store.d.ts +5 -5
- package/dist/composed-store.js +6 -3
- package/dist/environment-full.d.ts +1 -1
- package/dist/environment-full.js +17 -2
- package/dist/generator-lookup.js +1 -1
- package/dist/package-manager.d.ts +1 -1
- package/dist/package-manager.js +17 -4
- package/dist/util/namespace.js +1 -1
- package/package.json +22 -19
package/dist/composed-store.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BaseGenerator, Logger } from '@yeoman/types';
|
|
2
|
-
import type {
|
|
2
|
+
import type { PackageManagerInstallTaskOptions } from './package-manager.ts';
|
|
3
3
|
export declare class ComposedStore {
|
|
4
4
|
private readonly log?;
|
|
5
5
|
private readonly generators;
|
|
@@ -9,15 +9,15 @@ export declare class ComposedStore {
|
|
|
9
9
|
log?: Logger;
|
|
10
10
|
});
|
|
11
11
|
get customCommitTask(): (() => Promise<void> | void) | undefined;
|
|
12
|
-
get customInstallTask():
|
|
12
|
+
get customInstallTask(): PackageManagerInstallTaskOptions['customInstallTask'] | undefined;
|
|
13
13
|
getGenerators(): Record<string, BaseGenerator>;
|
|
14
14
|
addGenerator(generator: BaseGenerator): {
|
|
15
|
-
uniqueBy:
|
|
16
|
-
identifier:
|
|
15
|
+
uniqueBy: string;
|
|
16
|
+
identifier: string | undefined;
|
|
17
17
|
added: boolean;
|
|
18
18
|
generator: BaseGenerator | undefined;
|
|
19
19
|
} | {
|
|
20
|
-
identifier:
|
|
20
|
+
identifier: string | undefined;
|
|
21
21
|
added: boolean;
|
|
22
22
|
generator: BaseGenerator;
|
|
23
23
|
uniqueBy?: undefined;
|
package/dist/composed-store.js
CHANGED
|
@@ -2,6 +2,9 @@ import crypto from 'node:crypto';
|
|
|
2
2
|
import { toNamespace } from '@yeoman/namespace';
|
|
3
3
|
import createdLogger from 'debug';
|
|
4
4
|
const debug = createdLogger('yeoman:environment:composed-store');
|
|
5
|
+
const getFeaturesFromGenerator = (generator) => {
|
|
6
|
+
return generator.features ?? generator.getFeatures?.() ?? {};
|
|
7
|
+
};
|
|
5
8
|
export class ComposedStore {
|
|
6
9
|
log;
|
|
7
10
|
generators = {};
|
|
@@ -20,7 +23,7 @@ export class ComposedStore {
|
|
|
20
23
|
return { ...this.generators };
|
|
21
24
|
}
|
|
22
25
|
addGenerator(generator) {
|
|
23
|
-
const
|
|
26
|
+
const features = getFeaturesFromGenerator(generator);
|
|
24
27
|
let { uniqueBy } = features;
|
|
25
28
|
const { uniqueGlobally } = features;
|
|
26
29
|
let identifier = uniqueBy;
|
|
@@ -56,8 +59,8 @@ export class ComposedStore {
|
|
|
56
59
|
findFeature(featureName) {
|
|
57
60
|
return Object.entries(this.generators)
|
|
58
61
|
.map(([generatorId, generator]) => {
|
|
59
|
-
const
|
|
60
|
-
const feature = features
|
|
62
|
+
const features = getFeaturesFromGenerator(generator);
|
|
63
|
+
const feature = features[featureName];
|
|
61
64
|
return feature ? { generatorId, feature: feature } : undefined;
|
|
62
65
|
})
|
|
63
66
|
.filter(Boolean);
|
|
@@ -70,7 +70,7 @@ declare class FullEnvironment extends EnvironmentBase {
|
|
|
70
70
|
* @param {Object} packages - packages to install key(packageName): value(versionRange).
|
|
71
71
|
* @return {Boolean} - true if the install succeeded.
|
|
72
72
|
*/
|
|
73
|
-
installLocalGenerators(packages: Record<string, string | undefined
|
|
73
|
+
installLocalGenerators(packages: Record<string, string | undefined>, forceInstall?: boolean): Promise<boolean>;
|
|
74
74
|
/**
|
|
75
75
|
* Lookup and register generators from the custom local repository.
|
|
76
76
|
*
|
package/dist/environment-full.js
CHANGED
|
@@ -74,7 +74,7 @@ class FullEnvironment extends EnvironmentBase {
|
|
|
74
74
|
}
|
|
75
75
|
groups[base].push(namespace);
|
|
76
76
|
}
|
|
77
|
-
for (const key of Object.keys(groups).
|
|
77
|
+
for (const key of Object.keys(groups).toSorted()) {
|
|
78
78
|
const group = groups[key];
|
|
79
79
|
if (group.length > 0) {
|
|
80
80
|
out.push('', key.charAt(0).toUpperCase() + key.slice(1));
|
|
@@ -192,9 +192,24 @@ class FullEnvironment extends EnvironmentBase {
|
|
|
192
192
|
* @param {Object} packages - packages to install key(packageName): value(versionRange).
|
|
193
193
|
* @return {Boolean} - true if the install succeeded.
|
|
194
194
|
*/
|
|
195
|
-
async installLocalGenerators(packages) {
|
|
195
|
+
async installLocalGenerators(packages, forceInstall = false) {
|
|
196
196
|
const entries = Object.entries(packages);
|
|
197
197
|
const specs = entries.map(([packageName, version]) => `${packageName}${version ? `@${version}` : ''}`);
|
|
198
|
+
if (forceInstall) {
|
|
199
|
+
this.adapter.log.info(`Force install is enabled. Proceeding with installation.`);
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
const { aproveInstall } = await this.adapter.prompt({
|
|
203
|
+
message: `The following packages need to be installed in the local repository: ${specs.join(', ')}. Do you want to proceed?`,
|
|
204
|
+
type: 'confirm',
|
|
205
|
+
name: 'aproveInstall',
|
|
206
|
+
default: false,
|
|
207
|
+
});
|
|
208
|
+
if (!aproveInstall) {
|
|
209
|
+
throw new Error(`Installation of ${specs.join(', ')} is declined by the user. Install manually and try again.`);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
this.adapter.log.info(`The following packages will be installed in the local repository: ${specs.join(', ')}.`);
|
|
198
213
|
const installResult = await this.repository.install(specs);
|
|
199
214
|
const failToInstall = installResult.find(result => !result.path);
|
|
200
215
|
if (failToInstall) {
|
package/dist/generator-lookup.js
CHANGED
|
@@ -39,7 +39,7 @@ export async function lookupGenerators(options = {}, register) {
|
|
|
39
39
|
...options,
|
|
40
40
|
};
|
|
41
41
|
return moduleLookupSync(options, ({ packagePath, files }) => {
|
|
42
|
-
files = [...files].
|
|
42
|
+
files = [...files].toSorted((a, b) => {
|
|
43
43
|
return defaultExtensions.indexOf(extname(a)) - defaultExtensions.indexOf(extname(b));
|
|
44
44
|
});
|
|
45
45
|
for (const filePath of files) {
|
|
@@ -7,7 +7,7 @@ export type PackageManagerInstallTaskOptions = {
|
|
|
7
7
|
packageJsonLocation: string;
|
|
8
8
|
adapter: InputOutputAdapter;
|
|
9
9
|
nodePackageManager?: string;
|
|
10
|
-
customInstallTask?: boolean | InstallTask;
|
|
10
|
+
customInstallTask?: boolean | InstallTask | 'ask';
|
|
11
11
|
skipInstall?: boolean;
|
|
12
12
|
};
|
|
13
13
|
/**
|
package/dist/package-manager.js
CHANGED
|
@@ -23,7 +23,10 @@ export async function packageManagerInstallTask({ memFs, packageJsonLocation, cu
|
|
|
23
23
|
* @return {Vinyl | undefined} a Vinyl file.
|
|
24
24
|
*/
|
|
25
25
|
function getDestinationPackageJson() {
|
|
26
|
-
|
|
26
|
+
const packageJsonFile = join(packageJsonLocation, 'package.json');
|
|
27
|
+
if (memFs.existsInMemory(packageJsonFile)) {
|
|
28
|
+
return memFs.get(packageJsonFile);
|
|
29
|
+
}
|
|
27
30
|
}
|
|
28
31
|
/**
|
|
29
32
|
* @private
|
|
@@ -32,12 +35,12 @@ export async function packageManagerInstallTask({ memFs, packageJsonLocation, cu
|
|
|
32
35
|
*/
|
|
33
36
|
function isDestinationPackageJsonCommitted() {
|
|
34
37
|
const file = getDestinationPackageJson();
|
|
35
|
-
return file
|
|
38
|
+
return file?.committed;
|
|
36
39
|
}
|
|
37
40
|
if (!getDestinationPackageJson()) {
|
|
38
41
|
return false;
|
|
39
42
|
}
|
|
40
|
-
if (customInstallTask && typeof customInstallTask !== 'function') {
|
|
43
|
+
if (customInstallTask && typeof customInstallTask !== 'function' && customInstallTask !== 'ask') {
|
|
41
44
|
debug('Install disabled by customInstallTask');
|
|
42
45
|
return false;
|
|
43
46
|
}
|
|
@@ -68,8 +71,18 @@ Running ${packageManagerName} install for you to install the required dependenci
|
|
|
68
71
|
await execa(packageManagerName, ['install'], { stdio: 'inherit', cwd: packageJsonLocation });
|
|
69
72
|
return true;
|
|
70
73
|
};
|
|
71
|
-
if (customInstallTask) {
|
|
74
|
+
if (typeof customInstallTask === 'function') {
|
|
72
75
|
return customInstallTask(packageManagerName, execPackageManager);
|
|
73
76
|
}
|
|
77
|
+
if (customInstallTask === 'ask') {
|
|
78
|
+
const { runInstall } = await adapter.prompt({
|
|
79
|
+
type: 'confirm',
|
|
80
|
+
name: 'runInstall',
|
|
81
|
+
message: `Do you want to run ${packageManagerName} install now?`,
|
|
82
|
+
});
|
|
83
|
+
if (!runInstall) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
74
87
|
return execPackageManager();
|
|
75
88
|
}
|
package/dist/util/namespace.js
CHANGED
|
@@ -39,7 +39,7 @@ export const asNamespace = (filepath, { lookups = defaultLookups }) => {
|
|
|
39
39
|
// Sort lookups by length so biggest are removed first
|
|
40
40
|
const nsLookups = [...lookups, '..']
|
|
41
41
|
.map(found => slash(found))
|
|
42
|
-
.
|
|
42
|
+
.toSorted((a, b) => a.split('/').length - b.split('/').length)
|
|
43
43
|
.toReversed();
|
|
44
44
|
// If `ns` contains a lookup dir in its path, remove it.
|
|
45
45
|
for (const lookup of nsLookups) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yeoman-environment",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"description": "Handles the lifecyle and bootstrapping of generators in a specific environment",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"development",
|
|
@@ -16,7 +16,10 @@
|
|
|
16
16
|
"app"
|
|
17
17
|
],
|
|
18
18
|
"homepage": "http://yeoman.io",
|
|
19
|
-
"repository":
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/yeoman/environment.git"
|
|
22
|
+
},
|
|
20
23
|
"license": "BSD-2-Clause",
|
|
21
24
|
"author": "Yeoman",
|
|
22
25
|
"type": "module",
|
|
@@ -57,22 +60,22 @@
|
|
|
57
60
|
},
|
|
58
61
|
"dependencies": {
|
|
59
62
|
"@yeoman/adapter": "^4.0.2",
|
|
60
|
-
"@yeoman/conflicter": "^4.0
|
|
61
|
-
"@yeoman/namespace": "^1.0
|
|
62
|
-
"@yeoman/transform": "^2.1.
|
|
63
|
-
"@yeoman/types": "^1.
|
|
63
|
+
"@yeoman/conflicter": "^4.1.0",
|
|
64
|
+
"@yeoman/namespace": "^2.1.0",
|
|
65
|
+
"@yeoman/transform": "^2.1.1",
|
|
66
|
+
"@yeoman/types": "^1.11.0",
|
|
64
67
|
"arrify": "^3.0.0",
|
|
65
68
|
"chalk": "^5.6.2",
|
|
66
69
|
"commander": "^14.0.3",
|
|
67
70
|
"debug": "^4.4.3",
|
|
68
71
|
"execa": "^9.6.1",
|
|
69
72
|
"fly-import": "^1.0.0",
|
|
70
|
-
"globby": "^16.
|
|
73
|
+
"globby": "^16.2.0",
|
|
71
74
|
"grouped-queue": "^2.1.0",
|
|
72
75
|
"locate-path": "^8.0.0",
|
|
73
|
-
"lodash-es": "^4.
|
|
74
|
-
"mem-fs": "^4.1.
|
|
75
|
-
"mem-fs-editor": "^12.0.
|
|
76
|
+
"lodash-es": "^4.18.1",
|
|
77
|
+
"mem-fs": "^4.1.4",
|
|
78
|
+
"mem-fs-editor": "^12.0.4",
|
|
76
79
|
"semver": "^7.7.4",
|
|
77
80
|
"slash": "^5.1.0",
|
|
78
81
|
"untildify": "^6.0.0",
|
|
@@ -80,23 +83,23 @@
|
|
|
80
83
|
},
|
|
81
84
|
"devDependencies": {
|
|
82
85
|
"@node-loaders/esbuild": "^2.0.0",
|
|
83
|
-
"@types/debug": "^4.1.
|
|
86
|
+
"@types/debug": "^4.1.13",
|
|
84
87
|
"@types/lodash-es": "^4.17.12",
|
|
85
88
|
"@types/node": "^20.19.35",
|
|
86
89
|
"@types/semver": "^7.7.1",
|
|
87
|
-
"@yeoman/eslint": "1.
|
|
90
|
+
"@yeoman/eslint": "1.1.0",
|
|
88
91
|
"c8": "^11.0.0",
|
|
89
|
-
"eslint": "
|
|
92
|
+
"eslint": "10.2.1",
|
|
90
93
|
"esmocha": "^5.0.0",
|
|
91
|
-
"fs-extra": "^11.3.
|
|
94
|
+
"fs-extra": "^11.3.4",
|
|
92
95
|
"jsdoc": "^4.0.5",
|
|
93
|
-
"prettier": "3.8.
|
|
94
|
-
"prettier-plugin-packagejson": "^3.0.
|
|
96
|
+
"prettier": "3.8.3",
|
|
97
|
+
"prettier-plugin-packagejson": "^3.0.2",
|
|
95
98
|
"rimraf": "^6.1.3",
|
|
96
|
-
"sinon": "^21.
|
|
99
|
+
"sinon": "^21.1.2",
|
|
97
100
|
"sinon-test": "^3.1.6",
|
|
98
101
|
"strip-ansi": "^7.2.0",
|
|
99
|
-
"typescript": "
|
|
102
|
+
"typescript": "6.0.3",
|
|
100
103
|
"yeoman-assert": "^3.1.1",
|
|
101
104
|
"yeoman-environment": "file:./",
|
|
102
105
|
"yeoman-generator-2": "npm:yeoman-generator@^2.0.5",
|
|
@@ -105,7 +108,7 @@
|
|
|
105
108
|
"yeoman-generator-6": "npm:yeoman-generator@^6.0.1",
|
|
106
109
|
"yeoman-generator-7": "npm:yeoman-generator@^7.5.1",
|
|
107
110
|
"yeoman-generator-8": "npm:yeoman-generator@^8.0.0-beta.8",
|
|
108
|
-
"yeoman-test": "^11.
|
|
111
|
+
"yeoman-test": "^11.3.1"
|
|
109
112
|
},
|
|
110
113
|
"peerDependencies": {
|
|
111
114
|
"@yeoman/adapter": "^4.0.2",
|