yeoman-environment 4.4.2 → 5.0.0-beta.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/cli/index.js +7 -7
- package/dist/cli/utils.js +5 -5
- package/dist/commands.js +6 -7
- package/dist/commit.d.ts +1 -1
- package/dist/commit.js +0 -2
- package/dist/composed-store.d.ts +1 -1
- package/dist/composed-store.js +2 -2
- package/dist/constants.js +0 -2
- package/dist/environment-base.d.ts +6 -1
- package/dist/environment-base.js +61 -64
- package/dist/environment-full.d.ts +2 -2
- package/dist/environment-full.js +19 -16
- package/dist/generator-lookup.js +5 -5
- package/dist/module-lookup.d.ts +1 -1
- package/dist/module-lookup.js +5 -9
- package/dist/store.d.ts +3 -3
- package/dist/store.js +6 -9
- package/dist/util/command.d.ts +1 -1
- package/dist/util/command.js +7 -7
- package/dist/util/namespace.js +2 -2
- package/dist/util/resolve.js +4 -2
- package/dist/util/util.d.ts +2 -3
- package/dist/util/util.js +17 -15
- package/package.json +43 -44
package/dist/cli/index.js
CHANGED
|
@@ -3,8 +3,8 @@ import process from 'node:process';
|
|
|
3
3
|
import { dirname, resolve } from 'node:path';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
5
|
import YeomanCommand, { addEnvironmentOptions } from '../util/command.js';
|
|
6
|
-
import { createEnv } from '../index.js';
|
|
7
|
-
import {
|
|
6
|
+
import { createEnv as createEnvironment } from '../index.js';
|
|
7
|
+
import { environmentAction, printGroupedGenerator } from './utils.js';
|
|
8
8
|
const program = new YeomanCommand();
|
|
9
9
|
const packageJson = JSON.parse(readFileSync(resolve(dirname(fileURLToPath(import.meta.url)), '../../package.json')).toString());
|
|
10
10
|
program.version(packageJson.version).allowExcessArguments(false).enablePositionalOptions();
|
|
@@ -21,16 +21,16 @@ program
|
|
|
21
21
|
.command('find')
|
|
22
22
|
.description('Find installed generators')
|
|
23
23
|
.action(async () => {
|
|
24
|
-
const
|
|
25
|
-
printGroupedGenerator(await
|
|
24
|
+
const environment = createEnvironment();
|
|
25
|
+
printGroupedGenerator(await environment.lookup());
|
|
26
26
|
});
|
|
27
27
|
program
|
|
28
28
|
.command('list')
|
|
29
29
|
.description('List generators available to be used')
|
|
30
30
|
.action(async () => {
|
|
31
|
-
const
|
|
32
|
-
await
|
|
33
|
-
printGroupedGenerator(Object.values(
|
|
31
|
+
const environment = createEnvironment();
|
|
32
|
+
await environment.lookup();
|
|
33
|
+
printGroupedGenerator(Object.values(environment.getGeneratorsMeta()));
|
|
34
34
|
});
|
|
35
35
|
try {
|
|
36
36
|
await program.parseAsync(process.argv);
|
package/dist/cli/utils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { requireNamespace } from '@yeoman/namespace';
|
|
2
2
|
import { groupBy } from 'lodash-es';
|
|
3
3
|
import createLogger from 'debug';
|
|
4
|
-
import { createEnv } from '../index.js';
|
|
4
|
+
import { createEnv as createEnvironment } from '../index.js';
|
|
5
5
|
const debug = createLogger('yeoman:yoe');
|
|
6
6
|
export const printGroupedGenerator = (generators) => {
|
|
7
7
|
const grouped = groupBy(generators, 'packagePath');
|
|
@@ -27,8 +27,8 @@ export const environmentAction = async function (generatorNamespace, options, co
|
|
|
27
27
|
if (!generatorNamespace) {
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
|
-
const
|
|
31
|
-
this.env =
|
|
32
|
-
await
|
|
33
|
-
return
|
|
30
|
+
const environment = createEnvironment({ ...options, command: this });
|
|
31
|
+
this.env = environment;
|
|
32
|
+
await environment.lookupLocalPackages();
|
|
33
|
+
return environment.execute(generatorNamespace, command.args.splice(1));
|
|
34
34
|
};
|
package/dist/commands.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import YeomanCommand, { addEnvironmentOptions } from './util/command.js';
|
|
2
|
-
import { createEnv } from './index.js';
|
|
2
|
+
import { createEnv as createEnvironment } from './index.js';
|
|
3
3
|
/**
|
|
4
4
|
* Prepare a commander instance for cli support.
|
|
5
5
|
*
|
|
@@ -8,27 +8,26 @@ import { createEnv } from './index.js';
|
|
|
8
8
|
* @return {Command} return command
|
|
9
9
|
*/
|
|
10
10
|
export const prepareGeneratorCommand = async ({ command = addEnvironmentOptions(new YeomanCommand()), resolved, generator, namespace, }) => {
|
|
11
|
-
const
|
|
11
|
+
const environment = createEnvironment();
|
|
12
12
|
let meta;
|
|
13
13
|
if (generator && namespace) {
|
|
14
|
-
meta =
|
|
14
|
+
meta = environment.register(generator, { namespace, resolved });
|
|
15
15
|
}
|
|
16
16
|
else if (resolved) {
|
|
17
|
-
meta =
|
|
17
|
+
meta = environment.register(resolved, { namespace });
|
|
18
18
|
}
|
|
19
19
|
else {
|
|
20
20
|
throw new Error(`A generator with namespace or a generator path is required`);
|
|
21
21
|
}
|
|
22
|
-
command.env =
|
|
22
|
+
command.env = environment;
|
|
23
23
|
command.registerGenerator(await meta.instantiateHelp());
|
|
24
24
|
command.action(async function () {
|
|
25
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
26
25
|
let rootCommand = this;
|
|
27
26
|
while (rootCommand.parent) {
|
|
28
27
|
rootCommand = rootCommand.parent;
|
|
29
28
|
}
|
|
30
29
|
const generator = await meta.instantiate(this.args, this.opts());
|
|
31
|
-
await
|
|
30
|
+
await environment.runGenerator(generator);
|
|
32
31
|
});
|
|
33
32
|
return command;
|
|
34
33
|
};
|
package/dist/commit.d.ts
CHANGED
|
@@ -7,6 +7,6 @@ import { type MemFsEditorFile } from 'mem-fs-editor';
|
|
|
7
7
|
*/
|
|
8
8
|
export declare const commitSharedFsTask: ({ adapter, conflicterOptions, sharedFs, }: {
|
|
9
9
|
adapter: InputOutputAdapter;
|
|
10
|
-
conflicterOptions?: ConflicterOptions
|
|
10
|
+
conflicterOptions?: ConflicterOptions;
|
|
11
11
|
sharedFs: Store<MemFsEditorFile>;
|
|
12
12
|
}) => Promise<void>;
|
package/dist/commit.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createConflicterTransform, createYoResolveTransform, forceYoFiles } from '@yeoman/conflicter';
|
|
2
2
|
import createdLogger from 'debug';
|
|
3
|
-
import { create as createMemFsEditor } from 'mem-fs-editor';
|
|
4
3
|
import { createCommitTransform } from 'mem-fs-editor/transform';
|
|
5
4
|
import { isFilePending } from 'mem-fs-editor/state';
|
|
6
5
|
const debug = createdLogger('yeoman:environment:commit');
|
|
@@ -9,6 +8,5 @@ const debug = createdLogger('yeoman:environment:commit');
|
|
|
9
8
|
*/
|
|
10
9
|
export const commitSharedFsTask = async ({ adapter, conflicterOptions, sharedFs, }) => {
|
|
11
10
|
debug('Running commitSharedFsTask');
|
|
12
|
-
const editor = createMemFsEditor(sharedFs);
|
|
13
11
|
await sharedFs.pipeline({ filter: (file) => isFilePending(file) || file.path.endsWith('.yo-resolve') }, createYoResolveTransform(), forceYoFiles(), createConflicterTransform(adapter, conflicterOptions), createCommitTransform());
|
|
14
12
|
};
|
package/dist/composed-store.d.ts
CHANGED
package/dist/composed-store.js
CHANGED
|
@@ -68,10 +68,10 @@ export class ComposedStore {
|
|
|
68
68
|
if (providedFeatures.length > 1) {
|
|
69
69
|
this.log?.info?.(`Multiple ${featureName} tasks found (${providedFeatures.map(({ generatorId }) => generatorId).join(', ')}). Using the first.`);
|
|
70
70
|
}
|
|
71
|
-
const { generatorId, feature } = providedFeatures
|
|
71
|
+
const [{ generatorId, feature }] = providedFeatures;
|
|
72
72
|
debug(`Feature ${featureName} provided by ${generatorId}`);
|
|
73
73
|
return feature;
|
|
74
74
|
}
|
|
75
|
-
return
|
|
75
|
+
return;
|
|
76
76
|
}
|
|
77
77
|
}
|
package/dist/constants.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2
1
|
export const UNKNOWN_NAMESPACE = 'unknownnamespace';
|
|
3
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
4
2
|
export const UNKNOWN_RESOLVED = 'unknown';
|
|
5
3
|
export const defaultQueues = [
|
|
6
4
|
'environment:run',
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
1
|
import EventEmitter from 'node:events';
|
|
3
2
|
import { QueuedAdapter, type TerminalAdapterOptions } from '@yeoman/adapter';
|
|
4
3
|
import type { ApplyTransformsOptions, BaseEnvironment, BaseEnvironmentOptions, BaseGenerator, BaseGeneratorConstructor, BaseGeneratorMeta, ComposeOptions, GeneratorMeta, GetGeneratorConstructor, InputOutputAdapter, InstantiateOptions, LookupGeneratorMeta } from '@yeoman/types';
|
|
@@ -54,6 +53,7 @@ export default class EnvironmentBase extends EventEmitter implements BaseEnviron
|
|
|
54
53
|
protected experimental: boolean;
|
|
55
54
|
protected _rootGenerator?: BaseGenerator;
|
|
56
55
|
protected compatibilityMode?: false | 'v4';
|
|
56
|
+
private contextStore;
|
|
57
57
|
constructor(options?: EnvironmentOptions);
|
|
58
58
|
findFeature(featureName: string): Array<{
|
|
59
59
|
generatorId: string;
|
|
@@ -277,4 +277,9 @@ export default class EnvironmentBase extends EventEmitter implements BaseEnviron
|
|
|
277
277
|
* @param packagePath - The generator's package path
|
|
278
278
|
*/
|
|
279
279
|
protected registerStub(Generator: any, namespace: string, resolved?: string, packagePath?: string): GeneratorMeta;
|
|
280
|
+
/**
|
|
281
|
+
* @experimental
|
|
282
|
+
* Get a map to store shared data, usually a generator root path to share a map by path.
|
|
283
|
+
*/
|
|
284
|
+
getContextMap(key: string, factory?: () => Map<string, any>): Map<string, any>;
|
|
280
285
|
}
|
package/dist/environment-base.js
CHANGED
|
@@ -10,7 +10,7 @@ import createdLogger from 'debug';
|
|
|
10
10
|
// @ts-expect-error grouped-queue don't have types
|
|
11
11
|
import GroupedQueue from 'grouped-queue';
|
|
12
12
|
import { isFilePending } from 'mem-fs-editor/state';
|
|
13
|
-
import {
|
|
13
|
+
import { filePipeline, transform } from '@yeoman/transform';
|
|
14
14
|
import { toNamespace } from '@yeoman/namespace';
|
|
15
15
|
import chalk from 'chalk';
|
|
16
16
|
import { defaults, pick } from 'lodash-es';
|
|
@@ -22,23 +22,21 @@ import { UNKNOWN_NAMESPACE, UNKNOWN_RESOLVED, defaultQueues } from './constants.
|
|
|
22
22
|
import { resolveModulePath } from './util/resolve.js';
|
|
23
23
|
import { commitSharedFsTask } from './commit.js';
|
|
24
24
|
import { packageManagerInstallTask } from './package-manager.js';
|
|
25
|
-
|
|
26
|
-
import { splitArgsFromString } from './util/util.js';
|
|
25
|
+
import { splitArgsFromString as splitArgumentsFromString } from './util/util.js';
|
|
27
26
|
const require = createRequire(import.meta.url);
|
|
28
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
29
27
|
const ENVIRONMENT_VERSION = require('../package.json').version;
|
|
30
28
|
const debug = createdLogger('yeoman:environment');
|
|
31
|
-
const getInstantiateOptions = (
|
|
32
|
-
if (Array.isArray(
|
|
33
|
-
return { generatorArgs:
|
|
29
|
+
const getInstantiateOptions = (arguments_, options) => {
|
|
30
|
+
if (Array.isArray(arguments_) || typeof arguments_ === 'string') {
|
|
31
|
+
return { generatorArgs: splitArgumentsFromString(arguments_), generatorOptions: options };
|
|
34
32
|
}
|
|
35
|
-
if (
|
|
36
|
-
if ('generatorOptions' in
|
|
37
|
-
return
|
|
33
|
+
if (arguments_ !== undefined) {
|
|
34
|
+
if ('generatorOptions' in arguments_ || 'generatorArgs' in arguments_) {
|
|
35
|
+
return arguments_;
|
|
38
36
|
}
|
|
39
|
-
if ('options' in
|
|
40
|
-
const { args:
|
|
41
|
-
return { generatorArgs:
|
|
37
|
+
if ('options' in arguments_ || 'arguments' in arguments_ || 'args' in arguments_) {
|
|
38
|
+
const { args: insideArguments, arguments: generatorArguments = insideArguments, options: generatorOptions, ...remainingOptions } = arguments_;
|
|
39
|
+
return { generatorArgs: splitArgumentsFromString(generatorArguments), generatorOptions: generatorOptions ?? remainingOptions };
|
|
42
40
|
}
|
|
43
41
|
}
|
|
44
42
|
return { generatorOptions: options };
|
|
@@ -46,32 +44,32 @@ const getInstantiateOptions = (args, options) => {
|
|
|
46
44
|
const getComposeOptions = (...varargs) => {
|
|
47
45
|
if (varargs.filter(Boolean).length === 0)
|
|
48
46
|
return {};
|
|
49
|
-
const [
|
|
50
|
-
if (typeof
|
|
51
|
-
return { schedule:
|
|
47
|
+
const [arguments_, options, composeOptions] = varargs;
|
|
48
|
+
if (typeof arguments_ === 'boolean') {
|
|
49
|
+
return { schedule: arguments_ };
|
|
52
50
|
}
|
|
53
|
-
let
|
|
51
|
+
let generatorArguments;
|
|
54
52
|
let generatorOptions;
|
|
55
|
-
if (
|
|
56
|
-
if (Array.isArray(
|
|
57
|
-
|
|
53
|
+
if (arguments_ !== undefined) {
|
|
54
|
+
if (Array.isArray(arguments_)) {
|
|
55
|
+
generatorArguments = arguments_;
|
|
58
56
|
}
|
|
59
|
-
else if (typeof
|
|
60
|
-
|
|
57
|
+
else if (typeof arguments_ === 'string') {
|
|
58
|
+
generatorArguments = splitArgumentsFromString(String(arguments_));
|
|
61
59
|
}
|
|
62
|
-
else if (typeof
|
|
63
|
-
if ('generatorOptions' in
|
|
64
|
-
return
|
|
60
|
+
else if (typeof arguments_ === 'object') {
|
|
61
|
+
if ('generatorOptions' in arguments_ || 'generatorArgs' in arguments_ || 'schedule' in arguments_) {
|
|
62
|
+
return arguments_;
|
|
65
63
|
}
|
|
66
|
-
generatorOptions =
|
|
64
|
+
generatorOptions = arguments_;
|
|
67
65
|
}
|
|
68
66
|
}
|
|
69
67
|
if (typeof options === 'boolean') {
|
|
70
|
-
return { generatorArgs, generatorOptions, schedule: options };
|
|
68
|
+
return { generatorArgs: generatorArguments, generatorOptions, schedule: options };
|
|
71
69
|
}
|
|
72
70
|
generatorOptions = generatorOptions ?? options;
|
|
73
71
|
if (typeof composeOptions === 'boolean') {
|
|
74
|
-
return { generatorArgs, generatorOptions, schedule: composeOptions };
|
|
72
|
+
return { generatorArgs: generatorArguments, generatorOptions, schedule: composeOptions };
|
|
75
73
|
}
|
|
76
74
|
return {};
|
|
77
75
|
};
|
|
@@ -102,6 +100,7 @@ export default class EnvironmentBase extends EventEmitter {
|
|
|
102
100
|
experimental;
|
|
103
101
|
_rootGenerator;
|
|
104
102
|
compatibilityMode;
|
|
103
|
+
contextStore = new Map();
|
|
105
104
|
constructor(options = {}) {
|
|
106
105
|
super();
|
|
107
106
|
this.setMaxListeners(100);
|
|
@@ -131,7 +130,6 @@ export default class EnvironmentBase extends EventEmitter {
|
|
|
131
130
|
registry: arboristRegistry,
|
|
132
131
|
},
|
|
133
132
|
});
|
|
134
|
-
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
135
133
|
this.experimental = experimental || process.argv.includes('--experimental');
|
|
136
134
|
this.alias(/^([^:]+)$/, '$1:app');
|
|
137
135
|
}
|
|
@@ -148,6 +146,7 @@ export default class EnvironmentBase extends EventEmitter {
|
|
|
148
146
|
...transformStreams,
|
|
149
147
|
transform(file => {
|
|
150
148
|
step('Completed', relative(this.logCwd, file.path));
|
|
149
|
+
// eslint-disable-next-line unicorn/no-useless-undefined
|
|
151
150
|
return undefined;
|
|
152
151
|
}),
|
|
153
152
|
]);
|
|
@@ -177,7 +176,9 @@ export default class EnvironmentBase extends EventEmitter {
|
|
|
177
176
|
return this.store.add({ resolved, namespace: this.namespace(resolved) });
|
|
178
177
|
}
|
|
179
178
|
}
|
|
180
|
-
catch {
|
|
179
|
+
catch {
|
|
180
|
+
// ignore error
|
|
181
|
+
}
|
|
181
182
|
return undefined;
|
|
182
183
|
}
|
|
183
184
|
/**
|
|
@@ -194,7 +195,7 @@ export default class EnvironmentBase extends EventEmitter {
|
|
|
194
195
|
const meta = await this.findMeta(namespaceOrPath);
|
|
195
196
|
return meta?.importGenerator();
|
|
196
197
|
}
|
|
197
|
-
async create(namespaceOrPath, ...
|
|
198
|
+
async create(namespaceOrPath, ...arguments_) {
|
|
198
199
|
let constructor;
|
|
199
200
|
const namespace = typeof namespaceOrPath === 'string' ? toNamespace(namespaceOrPath) : undefined;
|
|
200
201
|
const checkGenerator = (Generator) => {
|
|
@@ -209,33 +210,18 @@ export default class EnvironmentBase extends EventEmitter {
|
|
|
209
210
|
}
|
|
210
211
|
}
|
|
211
212
|
if (typeof Generator !== 'function') {
|
|
212
|
-
throw new TypeError(chalk.red(`You don't seem to have a generator with the name “${namespace?.generatorHint}” installed.`) +
|
|
213
|
-
|
|
214
|
-
'
|
|
215
|
-
|
|
216
|
-
chalk.yellow('
|
|
217
|
-
'
|
|
218
|
-
chalk.yellow('
|
|
219
|
-
'. \n' +
|
|
220
|
-
'Install them with ' +
|
|
221
|
-
chalk.yellow(`npm install ${namespace?.generatorHint}`) +
|
|
222
|
-
'.\n\n' +
|
|
223
|
-
'To see all your installed generators run ' +
|
|
224
|
-
chalk.yellow('yo --generators') +
|
|
225
|
-
'. ' +
|
|
226
|
-
'Adding the ' +
|
|
227
|
-
chalk.yellow('--help') +
|
|
228
|
-
' option will also show subgenerators. \n\n' +
|
|
229
|
-
'If ' +
|
|
230
|
-
chalk.yellow('yo') +
|
|
231
|
-
' cannot find the generator, run ' +
|
|
232
|
-
chalk.yellow('yo doctor') +
|
|
233
|
-
' to troubleshoot your system.');
|
|
213
|
+
throw new TypeError(`${chalk.red(`You don't seem to have a generator with the name “${namespace?.generatorHint}” installed.`)}\n` +
|
|
214
|
+
`But help is on the way:\n\n` +
|
|
215
|
+
`You can see available generators via ${chalk.yellow('npm search yeoman-generator')} or via ${chalk.yellow('http://yeoman.io/generators/')}. \n` +
|
|
216
|
+
`Install them with ${chalk.yellow(`npm install ${namespace?.generatorHint}`)}.\n\n` +
|
|
217
|
+
`To see all your installed generators run ${chalk.yellow('yo --generators')}. ` +
|
|
218
|
+
`Adding the ${chalk.yellow('--help')} option will also show subgenerators. \n\n` +
|
|
219
|
+
`If ${chalk.yellow('yo')} cannot find the generator, run ${chalk.yellow('yo doctor')} to troubleshoot your system.`);
|
|
234
220
|
}
|
|
235
221
|
return Generator;
|
|
236
222
|
};
|
|
237
223
|
if (typeof namespaceOrPath !== 'string') {
|
|
238
|
-
return this.instantiate(checkGenerator(namespaceOrPath), ...
|
|
224
|
+
return this.instantiate(checkGenerator(namespaceOrPath), ...arguments_);
|
|
239
225
|
}
|
|
240
226
|
if (typeof namespaceOrPath === 'string') {
|
|
241
227
|
const meta = await this.findMeta(namespaceOrPath);
|
|
@@ -251,10 +237,10 @@ export default class EnvironmentBase extends EventEmitter {
|
|
|
251
237
|
else {
|
|
252
238
|
constructor = namespaceOrPath;
|
|
253
239
|
}
|
|
254
|
-
return this.instantiate(checkGenerator(constructor), ...
|
|
240
|
+
return this.instantiate(checkGenerator(constructor), ...arguments_);
|
|
255
241
|
}
|
|
256
|
-
async instantiate(constructor, ...
|
|
257
|
-
const composeOptions =
|
|
242
|
+
async instantiate(constructor, ...arguments_) {
|
|
243
|
+
const composeOptions = arguments_.length > 0 ? getInstantiateOptions(...arguments_) : {};
|
|
258
244
|
const { namespace = UNKNOWN_NAMESPACE, resolved = UNKNOWN_RESOLVED, _meta } = constructor;
|
|
259
245
|
const environmentOptions = { env: this, resolved, namespace };
|
|
260
246
|
const generator = new constructor(composeOptions.generatorArgs ?? [], {
|
|
@@ -273,8 +259,8 @@ export default class EnvironmentBase extends EventEmitter {
|
|
|
273
259
|
}
|
|
274
260
|
return generator;
|
|
275
261
|
}
|
|
276
|
-
async composeWith(generator, ...
|
|
277
|
-
const options = getComposeOptions(...
|
|
262
|
+
async composeWith(generator, ...arguments_) {
|
|
263
|
+
const options = getComposeOptions(...arguments_);
|
|
278
264
|
const { schedule: passedSchedule = true, ...instantiateOptions } = options;
|
|
279
265
|
const generatorInstance = await this.create(generator, instantiateOptions);
|
|
280
266
|
// Convert to function to keep type compatibility with old @yeoman/types where schedule is boolean only
|
|
@@ -323,7 +309,7 @@ export default class EnvironmentBase extends EventEmitter {
|
|
|
323
309
|
* @return {Generator} The generator or singleton instance.
|
|
324
310
|
*/
|
|
325
311
|
async queueGenerator(generator, queueOptions) {
|
|
326
|
-
const schedule = typeof queueOptions === 'boolean' ? queueOptions : queueOptions?.schedule ?? false;
|
|
312
|
+
const schedule = typeof queueOptions === 'boolean' ? queueOptions : (queueOptions?.schedule ?? false);
|
|
327
313
|
const { added, identifier, generator: composedGenerator } = this.composedStore.addGenerator(generator);
|
|
328
314
|
if (!added) {
|
|
329
315
|
debug(`Using existing generator for namespace ${identifier}`);
|
|
@@ -366,20 +352,20 @@ export default class EnvironmentBase extends EventEmitter {
|
|
|
366
352
|
this._rootGenerator = this._rootGenerator ?? generator;
|
|
367
353
|
return this.start(generator.options);
|
|
368
354
|
}
|
|
369
|
-
register(pathOrStub, meta, ...
|
|
355
|
+
register(pathOrStub, meta, ...arguments_) {
|
|
370
356
|
if (typeof pathOrStub === 'string') {
|
|
371
357
|
if (typeof meta === 'object') {
|
|
372
358
|
return this.registerGeneratorPath(pathOrStub, meta.namespace, meta.packagePath);
|
|
373
359
|
}
|
|
374
360
|
// Backward compatibility
|
|
375
|
-
return this.registerGeneratorPath(pathOrStub, meta, ...
|
|
361
|
+
return this.registerGeneratorPath(pathOrStub, meta, ...arguments_);
|
|
376
362
|
}
|
|
377
363
|
if (pathOrStub) {
|
|
378
364
|
if (typeof meta === 'object') {
|
|
379
365
|
return this.registerStub(pathOrStub, meta.namespace, meta.resolved, meta.packagePath);
|
|
380
366
|
}
|
|
381
367
|
// Backward compatibility
|
|
382
|
-
return this.registerStub(pathOrStub, meta, ...
|
|
368
|
+
return this.registerStub(pathOrStub, meta, ...arguments_);
|
|
383
369
|
}
|
|
384
370
|
throw new TypeError('You must provide a generator name to register.');
|
|
385
371
|
}
|
|
@@ -499,7 +485,6 @@ export default class EnvironmentBase extends EventEmitter {
|
|
|
499
485
|
if (!meta) {
|
|
500
486
|
return;
|
|
501
487
|
}
|
|
502
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
503
488
|
return { ...meta };
|
|
504
489
|
}
|
|
505
490
|
alias(match, value) {
|
|
@@ -695,4 +680,16 @@ export default class EnvironmentBase extends EventEmitter {
|
|
|
695
680
|
debug('Registered %s (%s) on package (%s)', namespace, resolved, packagePath);
|
|
696
681
|
return meta;
|
|
697
682
|
}
|
|
683
|
+
/**
|
|
684
|
+
* @experimental
|
|
685
|
+
* Get a map to store shared data, usually a generator root path to share a map by path.
|
|
686
|
+
*/
|
|
687
|
+
getContextMap(key, factory = () => new Map()) {
|
|
688
|
+
if (this.contextStore.has(key)) {
|
|
689
|
+
return this.contextStore.get(key);
|
|
690
|
+
}
|
|
691
|
+
const context = factory();
|
|
692
|
+
this.contextStore.set(key, context);
|
|
693
|
+
return context;
|
|
694
|
+
}
|
|
698
695
|
}
|
|
@@ -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,
|
|
65
|
+
execute(generatorNamespace: string, arguments_?: never[]): Promise<void>;
|
|
66
66
|
requireGenerator(namespace: string): Promise<BaseGeneratorConstructor | undefined>;
|
|
67
67
|
/**
|
|
68
68
|
* Install generators at the custom local repository and register.
|
|
@@ -111,6 +111,6 @@ declare class FullEnvironment extends EnvironmentBase {
|
|
|
111
111
|
* @param {String|Array} args
|
|
112
112
|
* @param {Object} [options]
|
|
113
113
|
*/
|
|
114
|
-
run(
|
|
114
|
+
run(arguments_?: string[], options?: any): Promise<void>;
|
|
115
115
|
}
|
|
116
116
|
export default FullEnvironment;
|
package/dist/environment-full.js
CHANGED
|
@@ -3,10 +3,10 @@ import { join, resolve } from 'node:path';
|
|
|
3
3
|
import { requireNamespace, toNamespace } from '@yeoman/namespace';
|
|
4
4
|
import { flyImport } from 'fly-import';
|
|
5
5
|
import { defaults, pick, uniq } from 'lodash-es';
|
|
6
|
-
import
|
|
6
|
+
import { valid } from 'semver';
|
|
7
7
|
import YeomanCommand from './util/command.js';
|
|
8
8
|
import EnvironmentBase from './environment-base.js';
|
|
9
|
-
import { splitArgsFromString } from './util/util.js';
|
|
9
|
+
import { splitArgsFromString as splitArgumentsFromString } from './util/util.js';
|
|
10
10
|
class FullEnvironment extends EnvironmentBase {
|
|
11
11
|
constructor(options = {}, adapterCompat) {
|
|
12
12
|
if (adapterCompat) {
|
|
@@ -138,7 +138,7 @@ class FullEnvironment extends EnvironmentBase {
|
|
|
138
138
|
* @param {string} generatorNamespace
|
|
139
139
|
* @param {string[]} args
|
|
140
140
|
*/
|
|
141
|
-
async execute(generatorNamespace,
|
|
141
|
+
async execute(generatorNamespace, arguments_ = []) {
|
|
142
142
|
const namespace = requireNamespace(generatorNamespace);
|
|
143
143
|
if (!(await this.get(namespace.namespace))) {
|
|
144
144
|
await this.lookup({
|
|
@@ -156,7 +156,7 @@ class FullEnvironment extends EnvironmentBase {
|
|
|
156
156
|
// Instantiate the generator for options
|
|
157
157
|
const generator = await this.create(namespace.namespace, { generatorArgs: [], generatorOptions: { help: true } });
|
|
158
158
|
namespaceCommand.registerGenerator(generator);
|
|
159
|
-
namespaceCommand._parseCommand([],
|
|
159
|
+
namespaceCommand._parseCommand([], arguments_);
|
|
160
160
|
return this.run([namespace.namespace, ...namespaceCommand.args], {
|
|
161
161
|
...namespaceCommand.opts(),
|
|
162
162
|
});
|
|
@@ -164,21 +164,22 @@ class FullEnvironment extends EnvironmentBase {
|
|
|
164
164
|
async requireGenerator(namespace) {
|
|
165
165
|
if (namespace === undefined) {
|
|
166
166
|
try {
|
|
167
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
167
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
168
168
|
// @ts-ignore
|
|
169
|
-
|
|
169
|
+
// eslint-disable-next-line import-x/no-unresolved
|
|
170
|
+
const { default: Generator } = await import('yeoman-generator');
|
|
170
171
|
return Generator;
|
|
171
172
|
}
|
|
172
|
-
catch {
|
|
173
|
-
|
|
173
|
+
catch {
|
|
174
|
+
// ignore error
|
|
175
|
+
}
|
|
174
176
|
const { default: Generator } = await flyImport('yeoman-generator');
|
|
175
177
|
return Generator;
|
|
176
178
|
}
|
|
177
179
|
// Namespace is a version
|
|
178
|
-
if (
|
|
180
|
+
if (valid(namespace)) {
|
|
179
181
|
// Create a hash to install any version range in the local repository
|
|
180
182
|
const hash = createHash('shake256', { outputLength: 2 }).update(namespace, 'utf8').digest('hex');
|
|
181
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
182
183
|
const { default: Generator } = await flyImport(`@yeoman/generator-impl-${hash}@npm:yeoman-generator@${namespace}`);
|
|
183
184
|
return Generator;
|
|
184
185
|
}
|
|
@@ -290,10 +291,10 @@ class FullEnvironment extends EnvironmentBase {
|
|
|
290
291
|
* @param {String|Array} args
|
|
291
292
|
* @param {Object} [options]
|
|
292
293
|
*/
|
|
293
|
-
async run(
|
|
294
|
-
|
|
294
|
+
async run(arguments_, options) {
|
|
295
|
+
arguments_ = Array.isArray(arguments_) ? arguments_ : splitArgumentsFromString(arguments_);
|
|
295
296
|
options = { ...options };
|
|
296
|
-
let name =
|
|
297
|
+
let name = arguments_.shift();
|
|
297
298
|
if (!name) {
|
|
298
299
|
throw new Error('Must provide at least one argument, the generator namespace to invoke.');
|
|
299
300
|
}
|
|
@@ -305,10 +306,12 @@ class FullEnvironment extends EnvironmentBase {
|
|
|
305
306
|
try {
|
|
306
307
|
await this.prepareEnvironment(name);
|
|
307
308
|
}
|
|
308
|
-
catch {
|
|
309
|
+
catch {
|
|
310
|
+
// ignore error
|
|
311
|
+
}
|
|
309
312
|
}
|
|
310
313
|
const generator = await this.create(name, {
|
|
311
|
-
generatorArgs:
|
|
314
|
+
generatorArgs: arguments_,
|
|
312
315
|
generatorOptions: {
|
|
313
316
|
...options,
|
|
314
317
|
initialGenerator: true,
|
|
@@ -316,7 +319,7 @@ class FullEnvironment extends EnvironmentBase {
|
|
|
316
319
|
});
|
|
317
320
|
if (options.help) {
|
|
318
321
|
console.log(generator.help());
|
|
319
|
-
return
|
|
322
|
+
return;
|
|
320
323
|
}
|
|
321
324
|
return this.runGenerator(generator);
|
|
322
325
|
}
|
package/dist/generator-lookup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { extname, isAbsolute, join, posix } from 'node:path';
|
|
2
2
|
import { pathToFileURL } from 'node:url';
|
|
3
3
|
import { requireNamespace, toNamespace } from '@yeoman/namespace';
|
|
4
|
-
import {
|
|
4
|
+
import { findPackagesIn, getNpmPaths, moduleLookupSync } from './module-lookup.js';
|
|
5
5
|
import { asNamespace, defaultLookups } from './util/namespace.js';
|
|
6
6
|
export const defaultExtensions = ['.ts', '.cts', '.mts', '.js', '.cjs', '.mjs'];
|
|
7
7
|
/**
|
|
@@ -32,7 +32,7 @@ export async function lookupGenerators(options = {}, register) {
|
|
|
32
32
|
const { lookups = defaultLookups } = options;
|
|
33
33
|
options = {
|
|
34
34
|
// Js generators should be after, last will override registered one.
|
|
35
|
-
filePatterns: lookups.flatMap(prefix => defaultExtensions.map(
|
|
35
|
+
filePatterns: lookups.flatMap(prefix => defaultExtensions.map(extension => `${prefix}/*/index${extension}`)),
|
|
36
36
|
filterPaths: false,
|
|
37
37
|
packagePatterns: ['generator-*'],
|
|
38
38
|
reverse: !options.singleResult,
|
|
@@ -48,7 +48,7 @@ export async function lookupGenerators(options = {}, register) {
|
|
|
48
48
|
return filePath;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
return
|
|
51
|
+
return;
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
@@ -64,7 +64,7 @@ export async function lookupGenerators(options = {}, register) {
|
|
|
64
64
|
* @return {String} generator
|
|
65
65
|
*/
|
|
66
66
|
export function lookupGenerator(namespace, options) {
|
|
67
|
-
options = typeof options === 'boolean' ? { localOnly: options } : options ?? {};
|
|
67
|
+
options = typeof options === 'boolean' ? { localOnly: options } : (options ?? {});
|
|
68
68
|
options.singleResult = options.singleResult ?? true;
|
|
69
69
|
options.filePatterns = options.filePatterns ?? defaultLookups.map(prefix => join(prefix, '*/index.{js,ts}'));
|
|
70
70
|
const ns = requireNamespace(namespace);
|
|
@@ -87,7 +87,7 @@ export function lookupGenerator(namespace, options) {
|
|
|
87
87
|
paths.push(returnPath);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
-
return
|
|
90
|
+
return;
|
|
91
91
|
});
|
|
92
92
|
if (options.singleResult) {
|
|
93
93
|
const generatorPath = paths;
|
package/dist/module-lookup.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export type ModuleLookupOptions = {
|
|
|
21
21
|
/**
|
|
22
22
|
* Search for npm packages.
|
|
23
23
|
*/
|
|
24
|
-
export declare function moduleLookupSync(options: ModuleLookupOptions, find: (
|
|
24
|
+
export declare function moduleLookupSync(options: ModuleLookupOptions, find: (argument: {
|
|
25
25
|
files: string[];
|
|
26
26
|
packagePath: string;
|
|
27
27
|
}) => string | undefined): {
|
package/dist/module-lookup.js
CHANGED
|
@@ -3,16 +3,14 @@ import { delimiter, dirname, join, resolve, sep } from 'node:path';
|
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
4
|
import process from 'node:process';
|
|
5
5
|
import arrify from 'arrify';
|
|
6
|
-
import {
|
|
6
|
+
import { compact, uniq } from 'lodash-es';
|
|
7
7
|
import { globbySync } from 'globby';
|
|
8
8
|
import slash from 'slash';
|
|
9
9
|
import createdLogger from 'debug';
|
|
10
10
|
import { execaOutput } from './util/util.js';
|
|
11
11
|
const __filename = fileURLToPath(import.meta.url);
|
|
12
12
|
const __dirname = dirname(__filename);
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
14
13
|
const PROJECT_ROOT = join(__dirname, '..');
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
16
14
|
const PACKAGE_NAME_PATTERN = [JSON.parse(readFileSync(join(PROJECT_ROOT, 'package.json')).toString()).name];
|
|
17
15
|
const win32 = process.platform === 'win32';
|
|
18
16
|
const nvm = process.env.NVM_HOME;
|
|
@@ -156,8 +154,8 @@ function getLocalNpmPaths() {
|
|
|
156
154
|
process
|
|
157
155
|
.cwd()
|
|
158
156
|
.split(sep)
|
|
159
|
-
.forEach((part,
|
|
160
|
-
let lookup = join(...parts.slice(0,
|
|
157
|
+
.forEach((part, index, parts) => {
|
|
158
|
+
let lookup = join(...parts.slice(0, index + 1), 'node_modules');
|
|
161
159
|
if (!win32) {
|
|
162
160
|
lookup = `/${lookup}`;
|
|
163
161
|
}
|
|
@@ -207,15 +205,13 @@ function getGlobalNpmPaths(filterPaths = true) {
|
|
|
207
205
|
// Ex: /usr/another_global/node_modules/yeoman-environment/lib (installed directly)
|
|
208
206
|
paths.push(join(PROJECT_ROOT, '..'));
|
|
209
207
|
// Get yarn global directory and infer the module paths from there
|
|
210
|
-
const yarnBase = execaOutput('yarn', ['global', 'dir']
|
|
208
|
+
const yarnBase = execaOutput('yarn', ['global', 'dir']);
|
|
211
209
|
if (yarnBase) {
|
|
212
210
|
paths.push(resolve(yarnBase, 'node_modules'));
|
|
213
211
|
paths.push(resolve(yarnBase, '../link/'));
|
|
214
212
|
}
|
|
215
213
|
// Get npm global prefix and infer the module paths from there
|
|
216
|
-
const globalInstall = execaOutput('npm', ['root', '-g']
|
|
217
|
-
encoding: 'utf8',
|
|
218
|
-
});
|
|
214
|
+
const globalInstall = execaOutput('npm', ['root', '-g']);
|
|
219
215
|
if (globalInstall) {
|
|
220
216
|
paths.push(resolve(globalInstall));
|
|
221
217
|
}
|
package/dist/store.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BaseEnvironment,
|
|
1
|
+
import type { BaseEnvironment, BaseGeneratorMeta, GeneratorMeta, GetGeneratorConstructor } from '@yeoman/types';
|
|
2
2
|
/**
|
|
3
3
|
* The Generator store
|
|
4
4
|
* This is used to store generator (npm packages) reference and instantiate them when
|
|
@@ -7,11 +7,11 @@ import type { BaseEnvironment, GetGeneratorConstructor, GeneratorMeta, BaseGener
|
|
|
7
7
|
* @private
|
|
8
8
|
*/
|
|
9
9
|
export default class Store {
|
|
10
|
-
private readonly
|
|
10
|
+
private readonly environment;
|
|
11
11
|
private readonly _meta;
|
|
12
12
|
private readonly _packagesPaths;
|
|
13
13
|
private readonly _packagesNS;
|
|
14
|
-
constructor(
|
|
14
|
+
constructor(environment: BaseEnvironment);
|
|
15
15
|
/**
|
|
16
16
|
* Store a module under the namespace key
|
|
17
17
|
* @param meta
|
package/dist/store.js
CHANGED
|
@@ -13,15 +13,14 @@ const require = createRequire(import.meta.url);
|
|
|
13
13
|
* @private
|
|
14
14
|
*/
|
|
15
15
|
export default class Store {
|
|
16
|
-
|
|
16
|
+
environment;
|
|
17
17
|
_meta = {};
|
|
18
18
|
// Store packages paths by ns
|
|
19
19
|
_packagesPaths = {};
|
|
20
20
|
// Store packages ns
|
|
21
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
22
21
|
_packagesNS = [];
|
|
23
|
-
constructor(
|
|
24
|
-
this.
|
|
22
|
+
constructor(environment) {
|
|
23
|
+
this.environment = environment;
|
|
25
24
|
}
|
|
26
25
|
/**
|
|
27
26
|
* Store a module under the namespace key
|
|
@@ -65,12 +64,12 @@ export default class Store {
|
|
|
65
64
|
}
|
|
66
65
|
const factory = this.getFactory(Generator);
|
|
67
66
|
if (typeof factory === 'function') {
|
|
68
|
-
importPromise = factory(this.
|
|
67
|
+
importPromise = factory(this.environment);
|
|
69
68
|
Generator = await importPromise;
|
|
70
69
|
}
|
|
71
70
|
return this._getGenerator(Generator, meta);
|
|
72
71
|
};
|
|
73
|
-
const instantiate = async (
|
|
72
|
+
const instantiate = async (arguments_ = [], options = {}) => this.environment.instantiate(await importGenerator(), { generatorArgs: arguments_, generatorOptions: options });
|
|
74
73
|
const instantiateHelp = async () => instantiate([], { help: true });
|
|
75
74
|
const { packageNamespace } = toNamespace(meta.namespace) ?? {};
|
|
76
75
|
const generatorMeta = {
|
|
@@ -163,7 +162,6 @@ export default class Store {
|
|
|
163
162
|
* Get the stored packages namespaces.
|
|
164
163
|
* @return {Array} Stored packages namespaces.
|
|
165
164
|
*/
|
|
166
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
167
165
|
getPackagesNS() {
|
|
168
166
|
return this._packagesNS;
|
|
169
167
|
}
|
|
@@ -172,10 +170,9 @@ export default class Store {
|
|
|
172
170
|
return module.createGenerator ?? module.default?.createGenerator ?? module.default?.default?.createGenerator;
|
|
173
171
|
}
|
|
174
172
|
_getGenerator(module, meta) {
|
|
175
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
176
173
|
const Generator = module.default?.default ?? module.default ?? module;
|
|
177
174
|
if (typeof Generator !== 'function') {
|
|
178
|
-
throw new TypeError("The generator doesn't
|
|
175
|
+
throw new TypeError("The generator doesn't provide a constructor.");
|
|
179
176
|
}
|
|
180
177
|
Object.assign(Generator, meta);
|
|
181
178
|
return Generator;
|
package/dist/util/command.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export default class YeomanCommand extends Command {
|
|
|
21
21
|
* @param {object[]} generatorArgs
|
|
22
22
|
* @return {YeomanCommand} this;
|
|
23
23
|
*/
|
|
24
|
-
addGeneratorArguments(
|
|
24
|
+
addGeneratorArguments(generatorArguments?: any[]): this;
|
|
25
25
|
/**
|
|
26
26
|
* Register options using generator._options structure.
|
|
27
27
|
* @param {object} options
|
package/dist/util/command.js
CHANGED
|
@@ -39,17 +39,17 @@ export default class YeomanCommand extends Command {
|
|
|
39
39
|
* @param {object[]} generatorArgs
|
|
40
40
|
* @return {YeomanCommand} this;
|
|
41
41
|
*/
|
|
42
|
-
addGeneratorArguments(
|
|
43
|
-
if (!
|
|
42
|
+
addGeneratorArguments(generatorArguments = []) {
|
|
43
|
+
if (!generatorArguments || generatorArguments.length === 0) {
|
|
44
44
|
return this;
|
|
45
45
|
}
|
|
46
|
-
const
|
|
46
|
+
const arguments_ = generatorArguments
|
|
47
47
|
.map(argument => {
|
|
48
|
-
const
|
|
49
|
-
return argument.required ? `<${
|
|
48
|
+
const argumentName = argument.type === Array ? `${argument.name}...` : argument.name;
|
|
49
|
+
return argument.required ? `<${argumentName}>` : `[${argumentName}]`;
|
|
50
50
|
})
|
|
51
51
|
.join(' ');
|
|
52
|
-
this.arguments(
|
|
52
|
+
this.arguments(arguments_);
|
|
53
53
|
return this;
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
@@ -67,7 +67,7 @@ export default class YeomanCommand extends Command {
|
|
|
67
67
|
}
|
|
68
68
|
_addGeneratorOption(optionName, optionDefinition, additionalDescription = '') {
|
|
69
69
|
if (optionName === 'help') {
|
|
70
|
-
return
|
|
70
|
+
return;
|
|
71
71
|
}
|
|
72
72
|
const longOption = `--${optionName}`;
|
|
73
73
|
const existingOption = this._findOption(longOption);
|
package/dist/util/namespace.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { parse } from 'node:path';
|
|
2
2
|
import slash from 'slash';
|
|
3
|
-
import {
|
|
3
|
+
import { escapeRegExp, findLast } from 'lodash-es';
|
|
4
4
|
export const defaultLookups = ['.', 'generators', 'lib/generators', 'dist/generators'];
|
|
5
5
|
/**
|
|
6
6
|
* Given a String `filepath`, tries to figure out the relative namespace.
|
|
@@ -31,7 +31,7 @@ export const asNamespace = (filepath, { lookups = defaultLookups }) => {
|
|
|
31
31
|
// Ignore path before latest node_modules
|
|
32
32
|
const nodeModulesPath = '/node_modules/';
|
|
33
33
|
if (ns.includes(nodeModulesPath)) {
|
|
34
|
-
ns = ns.slice(ns.lastIndexOf(nodeModulesPath) + nodeModulesPath.length
|
|
34
|
+
ns = ns.slice(ns.lastIndexOf(nodeModulesPath) + nodeModulesPath.length);
|
|
35
35
|
}
|
|
36
36
|
// Cleanup extension and normalize path for differents OS
|
|
37
37
|
const parsed = parse(ns);
|
package/dist/util/resolve.js
CHANGED
|
@@ -32,9 +32,11 @@ export async function resolveModulePath(specifier, resolvedOrigin) {
|
|
|
32
32
|
return maybeResolved;
|
|
33
33
|
}
|
|
34
34
|
if (specStat.isDirectory()) {
|
|
35
|
-
return await locatePath(defaultExtensions.map(
|
|
35
|
+
return await locatePath(defaultExtensions.map(extension => `index${extension}`).map(file => join(maybeResolved, file)));
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
catch {
|
|
38
|
+
catch {
|
|
39
|
+
// ignore error
|
|
40
|
+
}
|
|
39
41
|
throw new Error(`Error resolving ${specifier}`);
|
|
40
42
|
}
|
package/dist/util/util.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const execaOutput: (cmg: string, args: string[], options: SyncOptions) => string | undefined;
|
|
1
|
+
export declare const execaOutput: (cmg: string, arguments_: string[]) => string | undefined;
|
|
3
2
|
/**
|
|
4
3
|
* Two-step argument splitting function that first splits arguments in quotes,
|
|
5
4
|
* and then splits up the remaining arguments if they are not part of a quote.
|
|
6
5
|
*/
|
|
7
|
-
export declare function splitArgsFromString(
|
|
6
|
+
export declare function splitArgsFromString(argumentsString: string | string[]): string[];
|
package/dist/util/util.js
CHANGED
|
@@ -1,33 +1,35 @@
|
|
|
1
1
|
import { execaSync } from 'execa';
|
|
2
|
-
export const execaOutput = (cmg,
|
|
2
|
+
export const execaOutput = (cmg, arguments_) => {
|
|
3
3
|
try {
|
|
4
|
-
const
|
|
5
|
-
if (!
|
|
6
|
-
return
|
|
4
|
+
const { failed, stdout } = execaSync(cmg, arguments_, { encoding: 'utf8' });
|
|
5
|
+
if (!failed) {
|
|
6
|
+
return stdout;
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
catch {
|
|
10
|
-
|
|
9
|
+
catch {
|
|
10
|
+
// ignore error
|
|
11
|
+
}
|
|
12
|
+
return;
|
|
11
13
|
};
|
|
12
14
|
/**
|
|
13
15
|
* Two-step argument splitting function that first splits arguments in quotes,
|
|
14
16
|
* and then splits up the remaining arguments if they are not part of a quote.
|
|
15
17
|
*/
|
|
16
|
-
export function splitArgsFromString(
|
|
17
|
-
if (Array.isArray(
|
|
18
|
-
return
|
|
18
|
+
export function splitArgsFromString(argumentsString) {
|
|
19
|
+
if (Array.isArray(argumentsString)) {
|
|
20
|
+
return argumentsString;
|
|
19
21
|
}
|
|
20
22
|
let result = [];
|
|
21
|
-
if (!
|
|
23
|
+
if (!argumentsString) {
|
|
22
24
|
return result;
|
|
23
25
|
}
|
|
24
|
-
const
|
|
25
|
-
for (const
|
|
26
|
-
if (
|
|
27
|
-
result.push(
|
|
26
|
+
const quoteSeparatedArguments = argumentsString.split(/("[^"]*")/).filter(Boolean);
|
|
27
|
+
for (const argument of quoteSeparatedArguments) {
|
|
28
|
+
if (argument.includes('"')) {
|
|
29
|
+
result.push(argument.replaceAll('"', ''));
|
|
28
30
|
}
|
|
29
31
|
else {
|
|
30
|
-
result = result.concat(
|
|
32
|
+
result = result.concat(argument.trim().split(' '));
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
35
|
return result;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yeoman-environment",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0-beta.0",
|
|
4
4
|
"description": "Handles the lifecyle and bootstrapping of generators in a specific environment",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"development",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"exports": {
|
|
24
24
|
".": {
|
|
25
25
|
"types": "./dist/index.d.js",
|
|
26
|
-
"
|
|
26
|
+
"default": "./dist/index.js"
|
|
27
27
|
},
|
|
28
28
|
"./package.json": "./package.json"
|
|
29
29
|
},
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"doc:fix": "sed -i -e 's:^[[:space:]]*<!--[[:space:]]*$::g' -e 's:^[[:space:]]*-->[[:space:]]*$::g' $npm_package_config_doc_path/global.html || true",
|
|
45
45
|
"doc:generate": "jsdoc -c jsdoc.json -d $npm_package_config_doc_path",
|
|
46
46
|
"doc:prettier": "prettier $npm_package_config_doc_path --write --ignore-path .prettierignore-doc",
|
|
47
|
-
"fix": "
|
|
47
|
+
"fix": "eslint --fix && prettier . --write",
|
|
48
48
|
"prepare": "npm run build",
|
|
49
|
-
"pretest": "
|
|
49
|
+
"pretest": "eslint && prettier . --check",
|
|
50
50
|
"test": "c8 esmocha --forbid-only",
|
|
51
51
|
"test-base": "c8 esmocha test/environment*.js test/store.js test/util.js test/adapter.js",
|
|
52
52
|
"test-environment": "c8 esmocha test/environment.js",
|
|
@@ -57,45 +57,47 @@
|
|
|
57
57
|
"doc_path": "./yeoman-environment-doc"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@yeoman/adapter": "^1.
|
|
61
|
-
"@yeoman/conflicter": "^2.
|
|
62
|
-
"@yeoman/namespace": "^1.0.
|
|
63
|
-
"@yeoman/transform": "^1.
|
|
64
|
-
"@yeoman/types": "^1.
|
|
60
|
+
"@yeoman/adapter": "^2.1.1",
|
|
61
|
+
"@yeoman/conflicter": "^2.4.0",
|
|
62
|
+
"@yeoman/namespace": "^1.0.1",
|
|
63
|
+
"@yeoman/transform": "^2.1.0",
|
|
64
|
+
"@yeoman/types": "^1.6.0",
|
|
65
65
|
"arrify": "^3.0.0",
|
|
66
|
-
"chalk": "^5.
|
|
67
|
-
"commander": "^
|
|
68
|
-
"debug": "^4.
|
|
69
|
-
"execa": "^
|
|
70
|
-
"fly-import": "^0.4.
|
|
71
|
-
"globby": "^14.
|
|
66
|
+
"chalk": "^5.4.1",
|
|
67
|
+
"commander": "^13.1.0",
|
|
68
|
+
"debug": "^4.4.0",
|
|
69
|
+
"execa": "^9.5.3",
|
|
70
|
+
"fly-import": "^0.4.1",
|
|
71
|
+
"globby": "^14.1.0",
|
|
72
72
|
"grouped-queue": "^2.0.0",
|
|
73
73
|
"locate-path": "^7.2.0",
|
|
74
74
|
"lodash-es": "^4.17.21",
|
|
75
|
-
"mem-fs": "^4.
|
|
76
|
-
"mem-fs-editor": "^11.
|
|
77
|
-
"semver": "^7.
|
|
75
|
+
"mem-fs": "^4.1.2",
|
|
76
|
+
"mem-fs-editor": "^11.1.4",
|
|
77
|
+
"semver": "^7.7.2",
|
|
78
78
|
"slash": "^5.1.0",
|
|
79
79
|
"untildify": "^5.0.0",
|
|
80
|
-
"which-package-manager": "^
|
|
80
|
+
"which-package-manager": "^1.0.1"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
|
-
"@types/debug": "^4.1.
|
|
84
|
-
"@types/lodash-es": "^4.17.
|
|
85
|
-
"@types/
|
|
86
|
-
"
|
|
83
|
+
"@types/debug": "^4.1.12",
|
|
84
|
+
"@types/lodash-es": "^4.17.12",
|
|
85
|
+
"@types/node": "^18.19.100",
|
|
86
|
+
"@types/semver": "^7.7.0",
|
|
87
|
+
"@yeoman/eslint": "0.2.0",
|
|
88
|
+
"c8": "^10.1.3",
|
|
87
89
|
"cpy-cli": "^5.0.0",
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"prettier
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
"sinon
|
|
90
|
+
"eslint": "9.12.0",
|
|
91
|
+
"esmocha": "^3.0.0",
|
|
92
|
+
"fs-extra": "^11.3.0",
|
|
93
|
+
"jsdoc": "^4.0.4",
|
|
94
|
+
"prettier": "3.5.3",
|
|
95
|
+
"prettier-plugin-packagejson": "^2.5.12",
|
|
96
|
+
"rimraf": "^6.0.1",
|
|
97
|
+
"sinon": "^20.0.0",
|
|
98
|
+
"sinon-test": "^3.1.6",
|
|
96
99
|
"strip-ansi": "^7.1.0",
|
|
97
|
-
"typescript": "5.
|
|
98
|
-
"xo": "0.56.0",
|
|
100
|
+
"typescript": "5.8.3",
|
|
99
101
|
"yeoman-assert": "^3.1.1",
|
|
100
102
|
"yeoman-environment": "file:./",
|
|
101
103
|
"yeoman-generator-2": "npm:yeoman-generator@^2.0.5",
|
|
@@ -103,7 +105,14 @@
|
|
|
103
105
|
"yeoman-generator-5": "npm:yeoman-generator@^5.10.0",
|
|
104
106
|
"yeoman-generator-6": "npm:yeoman-generator@^6.0.1",
|
|
105
107
|
"yeoman-generator-7": "npm:yeoman-generator@^7.0.0",
|
|
106
|
-
"yeoman-test": "^
|
|
108
|
+
"yeoman-test": "^10.1.0"
|
|
109
|
+
},
|
|
110
|
+
"peerDependencies": {
|
|
111
|
+
"@yeoman/types": "^1.1.1",
|
|
112
|
+
"mem-fs": "^4.0.0"
|
|
113
|
+
},
|
|
114
|
+
"engines": {
|
|
115
|
+
"node": "^20.17.0 || >=22.9.0"
|
|
107
116
|
},
|
|
108
117
|
"overrides": {
|
|
109
118
|
"yeoman-generator-2": {
|
|
@@ -163,15 +172,5 @@
|
|
|
163
172
|
"yeoman-generator-6": {
|
|
164
173
|
"yeoman-environment": "*"
|
|
165
174
|
}
|
|
166
|
-
},
|
|
167
|
-
"peerDependencies": {
|
|
168
|
-
"@yeoman/types": "^1.1.1",
|
|
169
|
-
"mem-fs": "^4.0.0"
|
|
170
|
-
},
|
|
171
|
-
"acceptDependencies": {
|
|
172
|
-
"@yeoman/adapter": "^2.0.0"
|
|
173
|
-
},
|
|
174
|
-
"engines": {
|
|
175
|
-
"node": "^18.17.0 || >=20.5.0"
|
|
176
175
|
}
|
|
177
176
|
}
|