yeoman-environment 4.4.3 → 5.0.0-beta.1
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 +1 -0
- package/dist/cli/index.js +8 -8
- package/dist/cli/utils.d.ts +1 -1
- package/dist/cli/utils.js +5 -5
- package/dist/commands.d.ts +2 -2
- package/dist/commands.js +7 -8
- package/dist/commit.d.ts +1 -1
- package/dist/commit.js +1 -2
- package/dist/composed-store.d.ts +6 -5
- package/dist/composed-store.js +3 -3
- package/dist/constants.js +0 -2
- package/dist/environment-base.d.ts +16 -10
- package/dist/environment-base.js +95 -95
- package/dist/environment-full.d.ts +6 -9
- package/dist/environment-full.js +23 -26
- package/dist/generator-lookup.d.ts +2 -2
- package/dist/generator-lookup.js +7 -7
- package/dist/index.d.ts +10 -9
- package/dist/index.js +11 -8
- package/dist/module-lookup.d.ts +1 -1
- package/dist/module-lookup.js +12 -16
- package/dist/package-manager.d.ts +4 -3
- package/dist/store.d.ts +3 -3
- package/dist/store.js +61 -23
- package/dist/util/command.d.ts +4 -3
- package/dist/util/command.js +12 -9
- package/dist/util/namespace.js +3 -3
- package/dist/util/resolve.d.ts +1 -1
- package/dist/util/resolve.js +10 -8
- package/dist/util/util.d.ts +2 -3
- package/dist/util/util.js +17 -15
- package/package.json +56 -51
package/bin/bin.cjs
CHANGED
package/dist/cli/index.js
CHANGED
|
@@ -2,9 +2,9 @@ import { readFileSync } from 'node:fs';
|
|
|
2
2
|
import process from 'node:process';
|
|
3
3
|
import { dirname, resolve } from 'node:path';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
|
-
import YeomanCommand, { addEnvironmentOptions } from
|
|
6
|
-
import { createEnv } from
|
|
7
|
-
import {
|
|
5
|
+
import YeomanCommand, { addEnvironmentOptions } from "../util/command.js";
|
|
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.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BaseGeneratorMeta } from '@yeoman/types';
|
|
2
|
-
import type YeomanCommand from '../util/command.
|
|
2
|
+
import type YeomanCommand from '../util/command.ts';
|
|
3
3
|
export declare const printGroupedGenerator: (generators: BaseGeneratorMeta[]) => void;
|
|
4
4
|
/**
|
|
5
5
|
* @param {string} generatorNamespace
|
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
|
|
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.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import YeomanCommand from './util/command.
|
|
1
|
+
import type { BaseGeneratorConstructor } from '@yeoman/types';
|
|
2
|
+
import YeomanCommand from './util/command.ts';
|
|
3
3
|
export type CommandPreparation = {
|
|
4
4
|
resolved?: string;
|
|
5
5
|
command?: YeomanCommand;
|
package/dist/commands.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import YeomanCommand, { addEnvironmentOptions } from
|
|
2
|
-
import { createEnv } from
|
|
1
|
+
import YeomanCommand, { addEnvironmentOptions } from "./util/command.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,6 @@
|
|
|
1
1
|
import { createConflicterTransform, createYoResolveTransform, forceYoFiles } from '@yeoman/conflicter';
|
|
2
2
|
import createdLogger from 'debug';
|
|
3
|
-
import {
|
|
3
|
+
import {} from 'mem-fs-editor';
|
|
4
4
|
import { createCommitTransform } from 'mem-fs-editor/transform';
|
|
5
5
|
import { isFilePending } from 'mem-fs-editor/state';
|
|
6
6
|
const debug = createdLogger('yeoman:environment:commit');
|
|
@@ -9,6 +9,5 @@ const debug = createdLogger('yeoman:environment:commit');
|
|
|
9
9
|
*/
|
|
10
10
|
export const commitSharedFsTask = async ({ adapter, conflicterOptions, sharedFs, }) => {
|
|
11
11
|
debug('Running commitSharedFsTask');
|
|
12
|
-
const editor = createMemFsEditor(sharedFs);
|
|
13
12
|
await sharedFs.pipeline({ filter: (file) => isFilePending(file) || file.path.endsWith('.yo-resolve') }, createYoResolveTransform(), forceYoFiles(), createConflicterTransform(adapter, conflicterOptions), createCommitTransform());
|
|
14
13
|
};
|
package/dist/composed-store.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BaseGenerator, Logger } from '@yeoman/types';
|
|
2
|
+
import type { InstallTask } from './package-manager.ts';
|
|
2
3
|
export declare class ComposedStore {
|
|
3
4
|
private readonly log?;
|
|
4
5
|
private readonly generators;
|
|
@@ -7,8 +8,8 @@ export declare class ComposedStore {
|
|
|
7
8
|
constructor({ log }?: {
|
|
8
9
|
log?: Logger;
|
|
9
10
|
});
|
|
10
|
-
get customCommitTask():
|
|
11
|
-
get customInstallTask():
|
|
11
|
+
get customCommitTask(): (() => Promise<void> | void) | undefined;
|
|
12
|
+
get customInstallTask(): InstallTask | undefined;
|
|
12
13
|
getGenerators(): Record<string, BaseGenerator>;
|
|
13
14
|
addGenerator(generator: BaseGenerator): {
|
|
14
15
|
uniqueBy: any;
|
|
@@ -22,9 +23,9 @@ export declare class ComposedStore {
|
|
|
22
23
|
uniqueBy?: undefined;
|
|
23
24
|
};
|
|
24
25
|
getUniqueByPathMap(root: string): Map<string, BaseGenerator>;
|
|
25
|
-
findFeature(featureName: string): Array<{
|
|
26
|
+
findFeature<T = unknown>(featureName: string): Array<{
|
|
26
27
|
generatorId: string;
|
|
27
|
-
feature:
|
|
28
|
+
feature: T;
|
|
28
29
|
}>;
|
|
29
30
|
private findUniqueFeature;
|
|
30
31
|
}
|
package/dist/composed-store.js
CHANGED
|
@@ -58,7 +58,7 @@ export class ComposedStore {
|
|
|
58
58
|
.map(([generatorId, generator]) => {
|
|
59
59
|
const { features = generator.getFeatures?.() } = generator;
|
|
60
60
|
const feature = features?.[featureName];
|
|
61
|
-
return feature ? { generatorId, feature } : undefined;
|
|
61
|
+
return feature ? { generatorId, feature: feature } : undefined;
|
|
62
62
|
})
|
|
63
63
|
.filter(Boolean);
|
|
64
64
|
}
|
|
@@ -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,7 +1,6 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
1
|
import EventEmitter from 'node:events';
|
|
3
2
|
import { QueuedAdapter, type TerminalAdapterOptions } from '@yeoman/adapter';
|
|
4
|
-
import type { ApplyTransformsOptions, BaseEnvironment, BaseEnvironmentOptions, BaseGenerator,
|
|
3
|
+
import type { ApplyTransformsOptions, BaseEnvironment, BaseEnvironmentOptions, BaseGenerator, BaseGeneratorConstructorMeta, BaseGeneratorMeta, ComposeOptions, GeneratorMeta, GetGeneratorConstructor, InputOutputAdapter, InstantiateOptions, LookupGeneratorMeta } from '@yeoman/types';
|
|
5
4
|
import { type Store as MemFs } from 'mem-fs';
|
|
6
5
|
import { type MemFsEditorFile } from 'mem-fs-editor';
|
|
7
6
|
import { FlyRepository } from 'fly-import';
|
|
@@ -9,10 +8,11 @@ import GroupedQueue from 'grouped-queue';
|
|
|
9
8
|
import { type FilePipelineTransform } from '@yeoman/transform';
|
|
10
9
|
import { type YeomanNamespace } from '@yeoman/namespace';
|
|
11
10
|
import { type ConflicterOptions } from '@yeoman/conflicter';
|
|
12
|
-
import { ComposedStore } from './composed-store.
|
|
13
|
-
import Store from './store.
|
|
14
|
-
import type YeomanCommand from './util/command.
|
|
15
|
-
import { type LookupOptions } from './generator-lookup.
|
|
11
|
+
import { ComposedStore } from './composed-store.ts';
|
|
12
|
+
import Store from './store.ts';
|
|
13
|
+
import type YeomanCommand from './util/command.ts';
|
|
14
|
+
import { type LookupOptions } from './generator-lookup.ts';
|
|
15
|
+
import { type InstallTask } from './package-manager.ts';
|
|
16
16
|
export type EnvironmentLookupOptions = LookupOptions & {
|
|
17
17
|
/** Add a scope to the namespace if there is no scope */
|
|
18
18
|
registerToScope?: string;
|
|
@@ -54,6 +54,7 @@ export default class EnvironmentBase extends EventEmitter implements BaseEnviron
|
|
|
54
54
|
protected experimental: boolean;
|
|
55
55
|
protected _rootGenerator?: BaseGenerator;
|
|
56
56
|
protected compatibilityMode?: false | 'v4';
|
|
57
|
+
private contextStore;
|
|
57
58
|
constructor(options?: EnvironmentOptions);
|
|
58
59
|
findFeature(featureName: string): Array<{
|
|
59
60
|
generatorId: string;
|
|
@@ -64,7 +65,7 @@ export default class EnvironmentBase extends EventEmitter implements BaseEnviron
|
|
|
64
65
|
* @param namespaceOrPath
|
|
65
66
|
* @return the generator meta registered under the namespace
|
|
66
67
|
*/
|
|
67
|
-
findMeta(namespaceOrPath: string | YeomanNamespace):
|
|
68
|
+
findMeta(namespaceOrPath: string | YeomanNamespace): GeneratorMeta | undefined;
|
|
68
69
|
/**
|
|
69
70
|
* Get a single generator from the registered list of generators. The lookup is
|
|
70
71
|
* based on generator's namespace, "walking up" the namespaces until a matching
|
|
@@ -75,7 +76,7 @@ export default class EnvironmentBase extends EventEmitter implements BaseEnviron
|
|
|
75
76
|
* @param namespaceOrPath
|
|
76
77
|
* @return the generator registered under the namespace
|
|
77
78
|
*/
|
|
78
|
-
get<
|
|
79
|
+
get<G extends BaseGenerator = BaseGenerator>(namespaceOrPath: string | YeomanNamespace): Promise<(GetGeneratorConstructor<G> & BaseGeneratorConstructorMeta) | undefined> | ((GetGeneratorConstructor<G> & BaseGeneratorConstructorMeta) | undefined);
|
|
79
80
|
/**
|
|
80
81
|
* Create is the Generator factory. It takes a namespace to lookup and optional
|
|
81
82
|
* hash of options, that lets you define `arguments` and `options` to
|
|
@@ -87,7 +88,7 @@ export default class EnvironmentBase extends EventEmitter implements BaseEnviron
|
|
|
87
88
|
* @param instantiateOptions
|
|
88
89
|
* @return The instantiated generator
|
|
89
90
|
*/
|
|
90
|
-
create<G extends BaseGenerator = BaseGenerator>(namespaceOrPath: string | GetGeneratorConstructor<G
|
|
91
|
+
create<G extends BaseGenerator = BaseGenerator>(namespaceOrPath: string | (GetGeneratorConstructor<G> & Partial<BaseGeneratorConstructorMeta>), instantiateOptions?: InstantiateOptions<G>): Promise<G>;
|
|
91
92
|
/**
|
|
92
93
|
* Instantiate a Generator with metadatas
|
|
93
94
|
*
|
|
@@ -245,7 +246,7 @@ export default class EnvironmentBase extends EventEmitter implements BaseEnviron
|
|
|
245
246
|
watchForPackageManagerInstall({ cwd, queueTask, installTask, }?: {
|
|
246
247
|
cwd?: string;
|
|
247
248
|
queueTask?: boolean;
|
|
248
|
-
installTask?:
|
|
249
|
+
installTask?: InstallTask;
|
|
249
250
|
}): void;
|
|
250
251
|
/**
|
|
251
252
|
* Start Environment queue
|
|
@@ -277,4 +278,9 @@ export default class EnvironmentBase extends EventEmitter implements BaseEnviron
|
|
|
277
278
|
* @param packagePath - The generator's package path
|
|
278
279
|
*/
|
|
279
280
|
protected registerStub(Generator: any, namespace: string, resolved?: string, packagePath?: string): GeneratorMeta;
|
|
281
|
+
/**
|
|
282
|
+
* @experimental
|
|
283
|
+
* Get a map to store shared data, usually a generator root path to share a map by path.
|
|
284
|
+
*/
|
|
285
|
+
getContextMap(key: string, factory?: () => Map<string, any>): Map<string, any>;
|
|
280
286
|
}
|