yeoman-environment 6.1.0 → 6.2.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/bin/bin.cjs +0 -1
- package/dist/environment-base.js +2 -2
- package/dist/environment-full.d.ts +1 -1
- package/dist/generator-lookup.d.ts +9 -1
- package/dist/generator-lookup.js +0 -12
- package/dist/store.d.ts +5 -0
- package/dist/store.js +24 -0
- package/package.json +12 -83
package/bin/bin.cjs
CHANGED
package/dist/environment-base.js
CHANGED
|
@@ -242,13 +242,13 @@ export default class EnvironmentBase extends EventEmitter {
|
|
|
242
242
|
instantiate(constructor, ...arguments_) {
|
|
243
243
|
const composeOptions = arguments_.length > 0 ? getInstantiateOptions(...arguments_) : {};
|
|
244
244
|
const { namespace = UNKNOWN_NAMESPACE, resolved = UNKNOWN_RESOLVED, _meta } = constructor;
|
|
245
|
-
const environmentOptions = { env: this, resolved, namespace };
|
|
245
|
+
const environmentOptions = { env: this, resolved, namespace, _meta };
|
|
246
246
|
const generator = new constructor(composeOptions.generatorArgs ?? [], {
|
|
247
247
|
...this.sharedOptions,
|
|
248
248
|
...composeOptions.generatorOptions,
|
|
249
249
|
...environmentOptions,
|
|
250
250
|
});
|
|
251
|
-
generator._meta
|
|
251
|
+
generator._meta ??= _meta;
|
|
252
252
|
generator._environmentOptions = {
|
|
253
253
|
...this.options,
|
|
254
254
|
...this.sharedOptions,
|
|
@@ -62,7 +62,7 @@ declare class FullEnvironment extends EnvironmentBase {
|
|
|
62
62
|
* @param {string} generatorNamespace
|
|
63
63
|
* @param {string[]} args
|
|
64
64
|
*/
|
|
65
|
-
execute(generatorNamespace: string, arguments_?:
|
|
65
|
+
execute(generatorNamespace: string, arguments_?: string[]): Promise<void>;
|
|
66
66
|
requireGenerator(namespace: string): Promise<BaseGeneratorConstructor | undefined>;
|
|
67
67
|
/**
|
|
68
68
|
* Install generators at the custom local repository and register.
|
|
@@ -52,5 +52,13 @@ export declare function lookupGenerators(options?: LookupOptions, register?: (me
|
|
|
52
52
|
export declare function lookupGenerator(namespace: string, options?: ModuleLookupOptions & {
|
|
53
53
|
packagePath?: boolean;
|
|
54
54
|
generatorPath?: boolean;
|
|
55
|
-
}
|
|
55
|
+
} & {
|
|
56
|
+
singleResult?: true;
|
|
57
|
+
}): string;
|
|
58
|
+
export declare function lookupGenerator(namespace: string, options?: ModuleLookupOptions & {
|
|
59
|
+
packagePath?: boolean;
|
|
60
|
+
generatorPath?: boolean;
|
|
61
|
+
} & {
|
|
62
|
+
singleResult: false;
|
|
63
|
+
}): string[];
|
|
56
64
|
export {};
|
package/dist/generator-lookup.js
CHANGED
|
@@ -51,18 +51,6 @@ export async function lookupGenerators(options = {}, register) {
|
|
|
51
51
|
return;
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
|
-
/**
|
|
55
|
-
* Lookup for a specific generator.
|
|
56
|
-
*
|
|
57
|
-
* @param {String} namespace
|
|
58
|
-
* @param {Object} [options]
|
|
59
|
-
* @param {Boolean} [options.localOnly=false] - Set true to skip lookups of
|
|
60
|
-
* globally-installed generators.
|
|
61
|
-
* @param {Boolean} [options.packagePath=false] - Set true to return the package
|
|
62
|
-
* path instead of generators file.
|
|
63
|
-
* @param {Boolean} [options.singleResult=true] - Set false to return multiple values.
|
|
64
|
-
* @return {String} generator
|
|
65
|
-
*/
|
|
66
54
|
export function lookupGenerator(namespace, options) {
|
|
67
55
|
options = typeof options === 'boolean' ? { localOnly: options } : (options ?? {});
|
|
68
56
|
options.singleResult = options.singleResult ?? true;
|
package/dist/store.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type { BaseEnvironment, BaseGeneratorMeta, GeneratorMeta, GetGeneratorCon
|
|
|
8
8
|
*/
|
|
9
9
|
export default class Store {
|
|
10
10
|
private readonly _meta;
|
|
11
|
+
private readonly _packagesJson;
|
|
11
12
|
private readonly _packagesPaths;
|
|
12
13
|
private readonly _packagesNS;
|
|
13
14
|
private readonly environment;
|
|
@@ -61,6 +62,10 @@ export default class Store {
|
|
|
61
62
|
* @return {Array} Stored packages namespaces.
|
|
62
63
|
*/
|
|
63
64
|
getPackagesNS(): string[];
|
|
65
|
+
/**
|
|
66
|
+
* Read a package.json from packagePath. Parsed results are cached by packagePath.
|
|
67
|
+
*/
|
|
68
|
+
private getPackageJson;
|
|
64
69
|
private getFactory;
|
|
65
70
|
private _getGenerator;
|
|
66
71
|
}
|
package/dist/store.js
CHANGED
|
@@ -9,6 +9,7 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
|
|
|
9
9
|
import { pathToFileURL } from 'node:url';
|
|
10
10
|
import { extname, join } from 'node:path';
|
|
11
11
|
import { createRequire } from 'node:module';
|
|
12
|
+
import { readFileSync } from 'node:fs';
|
|
12
13
|
import { toNamespace } from '@yeoman/namespace';
|
|
13
14
|
import createDebug from 'debug';
|
|
14
15
|
const debug = createDebug('yeoman:environment:store');
|
|
@@ -22,6 +23,8 @@ const require = createRequire(import.meta.url);
|
|
|
22
23
|
*/
|
|
23
24
|
export default class Store {
|
|
24
25
|
_meta = {};
|
|
26
|
+
// Cache parsed package.json by packagePath
|
|
27
|
+
_packagesJson = new Map();
|
|
25
28
|
// Store packages paths by ns
|
|
26
29
|
_packagesPaths = {};
|
|
27
30
|
// Store packages ns
|
|
@@ -117,6 +120,7 @@ export default class Store {
|
|
|
117
120
|
};
|
|
118
121
|
const instantiate = async (arguments_ = [], options = {}) => this.environment.instantiate(await importGenerator(), { generatorArgs: arguments_, generatorOptions: options });
|
|
119
122
|
const instantiateHelp = async () => instantiate([], { help: true });
|
|
123
|
+
const getPackageJson = () => this.getPackageJson(meta.packagePath);
|
|
120
124
|
const { packageNamespace } = toNamespace(meta.namespace) ?? {};
|
|
121
125
|
generatorMeta = {
|
|
122
126
|
...meta,
|
|
@@ -124,6 +128,7 @@ export default class Store {
|
|
|
124
128
|
importModule,
|
|
125
129
|
instantiate,
|
|
126
130
|
instantiateHelp,
|
|
131
|
+
getPackageJson,
|
|
127
132
|
packageNamespace,
|
|
128
133
|
};
|
|
129
134
|
this._meta[meta.namespace] = generatorMeta;
|
|
@@ -211,6 +216,25 @@ export default class Store {
|
|
|
211
216
|
getPackagesNS() {
|
|
212
217
|
return this._packagesNS;
|
|
213
218
|
}
|
|
219
|
+
/**
|
|
220
|
+
* Read a package.json from packagePath. Parsed results are cached by packagePath.
|
|
221
|
+
*/
|
|
222
|
+
getPackageJson(packagePath) {
|
|
223
|
+
if (!packagePath) {
|
|
224
|
+
return undefined;
|
|
225
|
+
}
|
|
226
|
+
if (!this._packagesJson.has(packagePath)) {
|
|
227
|
+
let packageJson;
|
|
228
|
+
try {
|
|
229
|
+
packageJson = JSON.parse(readFileSync(join(packagePath, 'package.json'), 'utf8'));
|
|
230
|
+
}
|
|
231
|
+
catch {
|
|
232
|
+
packageJson = undefined;
|
|
233
|
+
}
|
|
234
|
+
this._packagesJson.set(packagePath, packageJson);
|
|
235
|
+
}
|
|
236
|
+
return this._packagesJson.get(packagePath);
|
|
237
|
+
}
|
|
214
238
|
getFactory(module) {
|
|
215
239
|
// CJS is imported in default, for backward compatibility we support a Generator exported as `module.exports = { default }`
|
|
216
240
|
return module.createGenerator ?? module.default?.createGenerator ?? module.default?.default?.createGenerator;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yeoman-environment",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.0",
|
|
4
4
|
"description": "Handles the lifecyle and bootstrapping of generators in a specific environment",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"development",
|
|
@@ -48,12 +48,8 @@
|
|
|
48
48
|
"doc:prettier": "prettier $npm_package_config_doc_path --write --ignore-path .prettierignore-doc",
|
|
49
49
|
"fix": "eslint --fix && prettier . --write",
|
|
50
50
|
"prepare": "npm run build",
|
|
51
|
-
"pretest": "eslint && prettier . --check",
|
|
52
|
-
"test": "c8 esmocha --forbid-only"
|
|
53
|
-
"test-base": "c8 esmocha test/environment*.js test/store.js test/util.js test/adapter.js",
|
|
54
|
-
"test-environment": "c8 esmocha test/environment.js",
|
|
55
|
-
"test-generators": "c8 esmocha test/generators.js",
|
|
56
|
-
"test-resolver": "c8 esmocha test/resolver.js"
|
|
51
|
+
"pretest": "eslint && prettier . --check && tsc -p tsconfig.test.json",
|
|
52
|
+
"test": "c8 --include 'src/**' esmocha --forbid-only"
|
|
57
53
|
},
|
|
58
54
|
"config": {
|
|
59
55
|
"doc_path": "./yeoman-environment-doc"
|
|
@@ -63,7 +59,7 @@
|
|
|
63
59
|
"@yeoman/conflicter": "^4.1.0",
|
|
64
60
|
"@yeoman/namespace": "^2.1.0",
|
|
65
61
|
"@yeoman/transform": "^2.1.1",
|
|
66
|
-
"@yeoman/types": "^1.11.
|
|
62
|
+
"@yeoman/types": "^1.11.1",
|
|
67
63
|
"arrify": "^3.0.0",
|
|
68
64
|
"chalk": "^5.6.2",
|
|
69
65
|
"commander": "^14.0.3",
|
|
@@ -91,23 +87,13 @@
|
|
|
91
87
|
"c8": "^11.0.0",
|
|
92
88
|
"eslint": "10.2.1",
|
|
93
89
|
"esmocha": "^5.0.0",
|
|
94
|
-
"fs-extra": "^11.3.4",
|
|
95
90
|
"jsdoc": "^4.0.5",
|
|
96
91
|
"prettier": "3.8.3",
|
|
97
92
|
"prettier-plugin-packagejson": "^3.0.2",
|
|
98
93
|
"rimraf": "^6.1.3",
|
|
99
|
-
"sinon": "^21.1.2",
|
|
100
|
-
"sinon-test": "^3.1.6",
|
|
101
94
|
"strip-ansi": "^7.2.0",
|
|
102
95
|
"typescript": "6.0.3",
|
|
103
|
-
"yeoman-assert": "^3.1.1",
|
|
104
96
|
"yeoman-environment": "file:./",
|
|
105
|
-
"yeoman-generator-2": "npm:yeoman-generator@^2.0.5",
|
|
106
|
-
"yeoman-generator-4": "npm:yeoman-generator@^4.13.0",
|
|
107
|
-
"yeoman-generator-5": "npm:yeoman-generator@^5.10.0",
|
|
108
|
-
"yeoman-generator-6": "npm:yeoman-generator@^6.0.1",
|
|
109
|
-
"yeoman-generator-7": "npm:yeoman-generator@^7.5.1",
|
|
110
|
-
"yeoman-generator-8": "npm:yeoman-generator@^8.0.0-beta.8",
|
|
111
97
|
"yeoman-test": "^11.3.1"
|
|
112
98
|
},
|
|
113
99
|
"peerDependencies": {
|
|
@@ -115,75 +101,18 @@
|
|
|
115
101
|
"@yeoman/types": "^1.10.3",
|
|
116
102
|
"mem-fs": "^4.1.4"
|
|
117
103
|
},
|
|
118
|
-
"acceptDependencies": {
|
|
119
|
-
"@yeoman/adapter": ">=4.0.2"
|
|
120
|
-
},
|
|
121
104
|
"engines": {
|
|
122
105
|
"node": "^20.17.0 || >=22.9.0"
|
|
123
106
|
},
|
|
107
|
+
"acceptDependencies": {
|
|
108
|
+
"@yeoman/adapter": ">=4.0.2"
|
|
109
|
+
},
|
|
124
110
|
"overrides": {
|
|
125
|
-
"yeoman-generator-
|
|
126
|
-
"chalk": "^4.1.0",
|
|
127
|
-
"dargs": "^7.0.0",
|
|
128
|
-
"debug": "^4.1.1",
|
|
129
|
-
"execa": "^5.1.1",
|
|
130
|
-
"github-username": "^6.0.0",
|
|
131
|
-
"lodash": "^4.17.11",
|
|
132
|
-
"mem-fs-editor": "^9.0.0",
|
|
133
|
-
"minimist": "^1.2.5",
|
|
134
|
-
"pacote": "^15.2.0",
|
|
135
|
-
"read-pkg-up": "^7.0.1",
|
|
136
|
-
"run-async": "^2.0.0",
|
|
137
|
-
"semver": "^7.2.1",
|
|
138
|
-
"shelljs": "^0.8.5",
|
|
139
|
-
"sort-keys": "^4.2.0",
|
|
140
|
-
"text-table": "^0.2.0",
|
|
141
|
-
"yeoman-environment": "file:./"
|
|
142
|
-
},
|
|
143
|
-
"yeoman-generator-4": {
|
|
144
|
-
"chalk": "^4.1.0",
|
|
145
|
-
"dargs": "^7.0.0",
|
|
146
|
-
"debug": "^4.1.1",
|
|
147
|
-
"execa": "^5.1.1",
|
|
148
|
-
"github-username": "^6.0.0",
|
|
149
|
-
"lodash": "^4.17.11",
|
|
150
|
-
"mem-fs-editor": "^9.0.0",
|
|
151
|
-
"minimist": "^1.2.5",
|
|
152
|
-
"pacote": "^15.2.0",
|
|
153
|
-
"read-pkg-up": "^7.0.1",
|
|
154
|
-
"run-async": "^2.0.0",
|
|
155
|
-
"semver": "^7.2.1",
|
|
156
|
-
"shelljs": "^0.8.5",
|
|
157
|
-
"sort-keys": "^4.2.0",
|
|
158
|
-
"text-table": "^0.2.0",
|
|
159
|
-
"yeoman-environment": "file:./"
|
|
160
|
-
},
|
|
161
|
-
"yeoman-generator-5": {
|
|
162
|
-
"chalk": "^4.1.0",
|
|
163
|
-
"dargs": "^7.0.0",
|
|
164
|
-
"debug": "^4.1.1",
|
|
165
|
-
"execa": "^5.1.1",
|
|
166
|
-
"github-username": "^6.0.0",
|
|
167
|
-
"lodash": "^4.17.11",
|
|
168
|
-
"mem-fs-editor": "^9.0.0",
|
|
169
|
-
"minimist": "^1.2.5",
|
|
170
|
-
"pacote": "^15.2.0",
|
|
171
|
-
"read-pkg-up": "^7.0.1",
|
|
172
|
-
"run-async": "^2.0.0",
|
|
173
|
-
"semver": "^7.2.1",
|
|
174
|
-
"shelljs": "^0.8.5",
|
|
175
|
-
"sort-keys": "^4.2.0",
|
|
176
|
-
"text-table": "^0.2.0",
|
|
177
|
-
"yeoman-environment": "file:./"
|
|
178
|
-
},
|
|
179
|
-
"yeoman-generator-6": {
|
|
180
|
-
"yeoman-environment": "file:./"
|
|
181
|
-
},
|
|
182
|
-
"yeoman-generator-7": {
|
|
183
|
-
"yeoman-environment": "file:./"
|
|
184
|
-
},
|
|
185
|
-
"yeoman-generator-8": {
|
|
111
|
+
"@yeoman-environment/generator-tests": {
|
|
186
112
|
"yeoman-environment": "file:./"
|
|
187
113
|
}
|
|
188
|
-
}
|
|
114
|
+
},
|
|
115
|
+
"workspaces": [
|
|
116
|
+
"test/generators"
|
|
117
|
+
]
|
|
189
118
|
}
|