yeoman-environment 4.0.0-alpha.4 → 4.0.0-alpha.6
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 +4 -0
- package/dist/cli/index.d.ts +0 -1
- package/dist/cli/index.js +18 -15
- package/dist/cli/utils.js +6 -7
- package/dist/commands.d.ts +23 -0
- package/dist/commands.js +45 -0
- package/dist/commit.d.ts +17 -0
- package/dist/commit.js +22 -0
- package/dist/composed-store.d.ts +26 -0
- package/dist/composed-store.js +68 -0
- package/dist/constants.d.ts +3 -0
- package/dist/constants.js +17 -0
- package/dist/environment-base.d.ts +259 -0
- package/dist/environment-base.js +638 -0
- package/dist/environment-full.d.ts +115 -0
- package/dist/environment-full.js +321 -0
- package/dist/generator-lookup.d.ts +56 -0
- package/dist/generator-lookup.js +97 -0
- package/dist/index.d.ts +10 -4
- package/dist/index.js +9 -5
- package/dist/module-lookup.d.ts +59 -0
- package/dist/module-lookup.js +227 -0
- package/dist/package-manager.d.ts +17 -31
- package/dist/package-manager.js +52 -69
- package/dist/store.d.ts +19 -19
- package/dist/store.js +76 -47
- package/dist/util/command.d.ts +17 -14
- package/dist/util/command.js +32 -17
- package/dist/util/namespace.d.ts +19 -73
- package/dist/util/namespace.js +56 -190
- package/dist/util/resolve.d.ts +6 -0
- package/dist/util/resolve.js +40 -0
- package/dist/util/util.d.ts +5 -12
- package/dist/util/util.js +24 -23
- package/package.json +20 -33
- package/readme.md +2 -3
- package/dist/adapter.d.ts +0 -54
- package/dist/adapter.js +0 -97
- package/dist/adapter.js.map +0 -1
- package/dist/cli/index.js.map +0 -1
- package/dist/cli/utils.js.map +0 -1
- package/dist/command.d.ts +0 -24
- package/dist/command.js +0 -74
- package/dist/command.js.map +0 -1
- package/dist/composability.d.ts +0 -25
- package/dist/composability.js +0 -78
- package/dist/composability.js.map +0 -1
- package/dist/environment.d.ts +0 -409
- package/dist/environment.js +0 -1221
- package/dist/environment.js.map +0 -1
- package/dist/generator-features.d.ts +0 -39
- package/dist/generator-features.js +0 -69
- package/dist/generator-features.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/namespace-composability.d.ts +0 -36
- package/dist/namespace-composability.js +0 -340
- package/dist/namespace-composability.js.map +0 -1
- package/dist/package-manager.js.map +0 -1
- package/dist/resolver.d.ts +0 -146
- package/dist/resolver.js +0 -421
- package/dist/resolver.js.map +0 -1
- package/dist/spawn-command.d.ts +0 -21
- package/dist/spawn-command.js +0 -30
- package/dist/spawn-command.js.map +0 -1
- package/dist/store.js.map +0 -1
- package/dist/util/binary-diff.d.ts +0 -2
- package/dist/util/binary-diff.js +0 -36
- package/dist/util/binary-diff.js.map +0 -1
- package/dist/util/command.js.map +0 -1
- package/dist/util/conflicter.d.ts +0 -76
- package/dist/util/conflicter.js +0 -346
- package/dist/util/conflicter.js.map +0 -1
- package/dist/util/esm.d.ts +0 -1
- package/dist/util/esm.js +0 -22
- package/dist/util/esm.js.map +0 -1
- package/dist/util/log.d.ts +0 -12
- package/dist/util/log.js +0 -165
- package/dist/util/log.js.map +0 -1
- package/dist/util/namespace.js.map +0 -1
- package/dist/util/repository.d.ts +0 -116
- package/dist/util/repository.js +0 -223
- package/dist/util/repository.js.map +0 -1
- package/dist/util/transform.d.ts +0 -55
- package/dist/util/transform.js +0 -149
- package/dist/util/transform.js.map +0 -1
- package/dist/util/util.js.map +0 -1
package/bin/bin.cjs
ADDED
package/dist/cli/index.d.ts
CHANGED
package/dist/cli/index.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
2
|
import process from 'node:process';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
3
|
+
import { dirname, resolve } from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import YeomanCommand, { addEnvironmentOptions } from '../util/command.js';
|
|
6
|
+
import { createEnv } from '../index.js';
|
|
6
7
|
import { printGroupedGenerator, environmentAction } from './utils.js';
|
|
7
8
|
const program = new YeomanCommand();
|
|
9
|
+
const packageJson = JSON.parse(readFileSync(resolve(dirname(fileURLToPath(import.meta.url)), '../../package.json')).toString());
|
|
8
10
|
program.version(packageJson.version).allowExcessArguments(false).enablePositionalOptions();
|
|
9
|
-
|
|
11
|
+
addEnvironmentOptions(program
|
|
10
12
|
.command('run <namespace>')
|
|
11
|
-
.description('Run a generator'
|
|
13
|
+
.description('Run a generator')
|
|
14
|
+
.argument('<namespace>', 'Generator to run')
|
|
12
15
|
.passThroughOptions()
|
|
13
16
|
.allowUnknownOption()
|
|
14
17
|
.allowExcessArguments(true)
|
|
@@ -17,24 +20,24 @@ Env.addEnvironmentOptions(program
|
|
|
17
20
|
program
|
|
18
21
|
.command('find')
|
|
19
22
|
.description('Find installed generators')
|
|
20
|
-
.action(() => {
|
|
21
|
-
const env =
|
|
22
|
-
const generators = env.lookup();
|
|
23
|
-
printGroupedGenerator(generators
|
|
23
|
+
.action(async () => {
|
|
24
|
+
const env = createEnv();
|
|
25
|
+
const generators = await env.lookup();
|
|
26
|
+
printGroupedGenerator(generators);
|
|
24
27
|
});
|
|
25
28
|
program
|
|
26
29
|
.command('list')
|
|
27
30
|
.description('List generators available to be used')
|
|
28
|
-
.action(() => {
|
|
29
|
-
const env =
|
|
30
|
-
env.lookup();
|
|
31
|
-
printGroupedGenerator(Object.values(env.getGeneratorsMeta())
|
|
31
|
+
.action(async () => {
|
|
32
|
+
const env = createEnv();
|
|
33
|
+
await env.lookup();
|
|
34
|
+
printGroupedGenerator(Object.values(env.getGeneratorsMeta()));
|
|
32
35
|
});
|
|
33
36
|
try {
|
|
34
37
|
await program.parseAsync(process.argv);
|
|
35
38
|
}
|
|
36
39
|
catch (error) {
|
|
37
40
|
console.log(error);
|
|
41
|
+
// eslint-disable-next-line unicorn/no-process-exit
|
|
38
42
|
process.exit(1);
|
|
39
43
|
}
|
|
40
|
-
//# sourceMappingURL=index.js.map
|
package/dist/cli/utils.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
+
import { requireNamespace } from '@yeoman/namespace';
|
|
1
2
|
import { groupBy } from 'lodash-es';
|
|
2
3
|
import createLogger from 'debug';
|
|
3
|
-
import
|
|
4
|
-
import { toNamespace } from '../util/namespace.js';
|
|
4
|
+
import { createEnv } from '../index.js';
|
|
5
5
|
const debug = createLogger('yeoman:yoe');
|
|
6
6
|
export const printGroupedGenerator = (generators) => {
|
|
7
7
|
const grouped = groupBy(generators, 'packagePath');
|
|
8
8
|
for (const [packagePath, group] of Object.entries(grouped)) {
|
|
9
|
-
const namespace =
|
|
9
|
+
const namespace = requireNamespace(group[0].namespace);
|
|
10
10
|
console.log(` ${namespace.packageNamespace} at ${packagePath}`);
|
|
11
11
|
for (const generator of group) {
|
|
12
|
-
const generatorNamespace =
|
|
12
|
+
const generatorNamespace = requireNamespace(generator.namespace);
|
|
13
13
|
console.log(` :${generatorNamespace.generator || 'app'}`);
|
|
14
14
|
}
|
|
15
15
|
console.log('');
|
|
@@ -27,8 +27,7 @@ export const environmentAction = async function (generatorNamespace, options, co
|
|
|
27
27
|
if (!generatorNamespace) {
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
|
-
this.env =
|
|
31
|
-
this.env.lookupLocalPackages();
|
|
30
|
+
this.env = createEnv({ ...options, command: this });
|
|
31
|
+
await this.env.lookupLocalPackages();
|
|
32
32
|
return this.env.execute(generatorNamespace, command.args.splice(1));
|
|
33
33
|
};
|
|
34
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type BaseGeneratorConstructor } from '@yeoman/types';
|
|
2
|
+
import YeomanCommand from './util/command.js';
|
|
3
|
+
export type CommandPreparation = {
|
|
4
|
+
resolved?: string;
|
|
5
|
+
command?: YeomanCommand;
|
|
6
|
+
generator?: BaseGeneratorConstructor;
|
|
7
|
+
namespace?: string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Prepare a commander instance for cli support.
|
|
11
|
+
*
|
|
12
|
+
* @param {Command} command - Command to be prepared
|
|
13
|
+
* @param generatorPath - Generator to create Command
|
|
14
|
+
* @return {Command} return command
|
|
15
|
+
*/
|
|
16
|
+
export declare const prepareGeneratorCommand: ({ command, resolved, generator, namespace, }: CommandPreparation) => Promise<YeomanCommand>;
|
|
17
|
+
/**
|
|
18
|
+
* Prepare a commander instance for cli support.
|
|
19
|
+
*
|
|
20
|
+
* @param generatorPaht - Generator to create Command
|
|
21
|
+
* @return Return a Command instance
|
|
22
|
+
*/
|
|
23
|
+
export declare const prepareCommand: (options: CommandPreparation) => Promise<YeomanCommand>;
|
package/dist/commands.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import YeomanCommand, { addEnvironmentOptions } from './util/command.js';
|
|
2
|
+
import { createEnv } from './index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Prepare a commander instance for cli support.
|
|
5
|
+
*
|
|
6
|
+
* @param {Command} command - Command to be prepared
|
|
7
|
+
* @param generatorPath - Generator to create Command
|
|
8
|
+
* @return {Command} return command
|
|
9
|
+
*/
|
|
10
|
+
export const prepareGeneratorCommand = async ({ command = addEnvironmentOptions(new YeomanCommand()), resolved, generator, namespace, }) => {
|
|
11
|
+
const env = createEnv();
|
|
12
|
+
let meta;
|
|
13
|
+
if (generator && namespace) {
|
|
14
|
+
meta = env.register(generator, { namespace, resolved });
|
|
15
|
+
}
|
|
16
|
+
else if (resolved) {
|
|
17
|
+
meta = env.register(resolved, { namespace });
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
throw new Error(`A generator with namespace or a generator path is required`);
|
|
21
|
+
}
|
|
22
|
+
command.env = env;
|
|
23
|
+
command.registerGenerator(await meta.instantiateHelp());
|
|
24
|
+
command.action(async function () {
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
26
|
+
let rootCommand = this;
|
|
27
|
+
while (rootCommand.parent) {
|
|
28
|
+
rootCommand = rootCommand.parent;
|
|
29
|
+
}
|
|
30
|
+
const generator = await meta.instantiate(this.args, this.opts());
|
|
31
|
+
await env.runGenerator(generator);
|
|
32
|
+
});
|
|
33
|
+
return command;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Prepare a commander instance for cli support.
|
|
37
|
+
*
|
|
38
|
+
* @param generatorPaht - Generator to create Command
|
|
39
|
+
* @return Return a Command instance
|
|
40
|
+
*/
|
|
41
|
+
export const prepareCommand = async (options) => {
|
|
42
|
+
options.command = options.command ?? new YeomanCommand();
|
|
43
|
+
addEnvironmentOptions(options.command);
|
|
44
|
+
return prepareGeneratorCommand(options);
|
|
45
|
+
};
|
package/dist/commit.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import type { PassThrough } from 'node:stream';
|
|
3
|
+
import type { InputOutputAdapter } from '@yeoman/types';
|
|
4
|
+
import { type ConflicterOptions } from '@yeoman/conflicter';
|
|
5
|
+
import type { Store } from 'mem-fs';
|
|
6
|
+
import { type MemFsEditorFile } from 'mem-fs-editor';
|
|
7
|
+
/**
|
|
8
|
+
* Commits the MemFs to the disc.
|
|
9
|
+
* @param {Stream} [stream] - files stream, defaults to this.sharedFs.stream().
|
|
10
|
+
* @return {Promise}
|
|
11
|
+
*/
|
|
12
|
+
export declare const commitSharedFsTask: ({ adapter, conflicterOptions, sharedFs, stream, }: {
|
|
13
|
+
adapter: InputOutputAdapter;
|
|
14
|
+
conflicterOptions?: ConflicterOptions | undefined;
|
|
15
|
+
sharedFs: Store<MemFsEditorFile>;
|
|
16
|
+
stream?: PassThrough | undefined;
|
|
17
|
+
}) => any;
|
package/dist/commit.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createConflicterTransform, createYoResolveTransform, forceYoFiles } from '@yeoman/conflicter';
|
|
2
|
+
import { create as createMemFsEditor } from 'mem-fs-editor';
|
|
3
|
+
// eslint-disable-next-line n/file-extension-in-import
|
|
4
|
+
import { isFilePending } from 'mem-fs-editor/state';
|
|
5
|
+
// eslint-disable-next-line n/file-extension-in-import
|
|
6
|
+
import { createCommitTransform } from 'mem-fs-editor/transform';
|
|
7
|
+
/**
|
|
8
|
+
* Commits the MemFs to the disc.
|
|
9
|
+
* @param {Stream} [stream] - files stream, defaults to this.sharedFs.stream().
|
|
10
|
+
* @return {Promise}
|
|
11
|
+
*/
|
|
12
|
+
export const commitSharedFsTask = ({ adapter, conflicterOptions, sharedFs, stream, }) => {
|
|
13
|
+
const fs = createMemFsEditor(sharedFs);
|
|
14
|
+
stream = stream ?? fs.store.stream({ filter: file => isFilePending(file) });
|
|
15
|
+
return fs.commit([
|
|
16
|
+
createYoResolveTransform(),
|
|
17
|
+
forceYoFiles(),
|
|
18
|
+
createConflicterTransform(adapter, conflicterOptions),
|
|
19
|
+
// Use custom commit transform due to out of order transform.
|
|
20
|
+
createCommitTransform(fs),
|
|
21
|
+
], stream);
|
|
22
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Logger, BaseGenerator } from '@yeoman/types';
|
|
2
|
+
export declare class ComposedStore {
|
|
3
|
+
private readonly log?;
|
|
4
|
+
private readonly generators;
|
|
5
|
+
private readonly uniqueByPathMap;
|
|
6
|
+
private readonly uniqueGloballyMap;
|
|
7
|
+
private readonly uniqueFeatures;
|
|
8
|
+
constructor({ log }?: {
|
|
9
|
+
log?: Logger;
|
|
10
|
+
});
|
|
11
|
+
get customCommitTask(): true | (() => Promise<void>) | undefined;
|
|
12
|
+
get customInstallTask(): true | (() => Promise<void>) | undefined;
|
|
13
|
+
getGenerators(): Record<string, BaseGenerator>;
|
|
14
|
+
addGenerator(generator: any): {
|
|
15
|
+
uniqueBy: any;
|
|
16
|
+
added: boolean;
|
|
17
|
+
generator: BaseGenerator | undefined;
|
|
18
|
+
identifier?: undefined;
|
|
19
|
+
} | {
|
|
20
|
+
identifier: any;
|
|
21
|
+
added: boolean;
|
|
22
|
+
generator: any;
|
|
23
|
+
uniqueBy?: undefined;
|
|
24
|
+
};
|
|
25
|
+
getUniqueByPathMap(root: string): Map<string, BaseGenerator>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import crypto from 'node:crypto';
|
|
2
|
+
import { toNamespace } from '@yeoman/namespace';
|
|
3
|
+
const uniqueFeatureValues = ['customCommitTask', 'customInstallTask'];
|
|
4
|
+
export class ComposedStore {
|
|
5
|
+
log;
|
|
6
|
+
generators = {};
|
|
7
|
+
uniqueByPathMap = new Map();
|
|
8
|
+
uniqueGloballyMap = new Map();
|
|
9
|
+
uniqueFeatures = new Map();
|
|
10
|
+
constructor({ log } = {}) {
|
|
11
|
+
this.log = log;
|
|
12
|
+
}
|
|
13
|
+
get customCommitTask() {
|
|
14
|
+
return this.uniqueFeatures.get('customCommitTask');
|
|
15
|
+
}
|
|
16
|
+
get customInstallTask() {
|
|
17
|
+
return this.uniqueFeatures.get('customInstallTask');
|
|
18
|
+
}
|
|
19
|
+
getGenerators() {
|
|
20
|
+
return { ...this.generators };
|
|
21
|
+
}
|
|
22
|
+
addGenerator(generator) {
|
|
23
|
+
const features = generator.getFeatures?.() ?? {};
|
|
24
|
+
let { uniqueBy } = features;
|
|
25
|
+
const { uniqueGlobally } = features;
|
|
26
|
+
let identifier = uniqueBy;
|
|
27
|
+
if (!uniqueBy) {
|
|
28
|
+
const { namespace } = generator.options;
|
|
29
|
+
const instanceId = crypto.randomBytes(20).toString('hex');
|
|
30
|
+
let namespaceDefinition = toNamespace(namespace);
|
|
31
|
+
if (namespaceDefinition) {
|
|
32
|
+
namespaceDefinition = namespaceDefinition.with({ instanceId });
|
|
33
|
+
uniqueBy = namespaceDefinition.id;
|
|
34
|
+
identifier = namespaceDefinition.namespace;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
uniqueBy = `${namespace}#${instanceId}`;
|
|
38
|
+
identifier = namespace;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const generatorRoot = generator.destinationRoot();
|
|
42
|
+
const uniqueByMap = uniqueGlobally ? this.uniqueGloballyMap : this.getUniqueByPathMap(generatorRoot);
|
|
43
|
+
if (uniqueByMap.has(uniqueBy)) {
|
|
44
|
+
return { uniqueBy, added: false, generator: uniqueByMap.get(uniqueBy) };
|
|
45
|
+
}
|
|
46
|
+
uniqueByMap.set(uniqueBy, generator);
|
|
47
|
+
for (const featureName of uniqueFeatureValues) {
|
|
48
|
+
const feature = features[featureName];
|
|
49
|
+
if (feature) {
|
|
50
|
+
const existingFeature = this.uniqueFeatures.get(feature);
|
|
51
|
+
if (typeof existingFeature !== 'function') {
|
|
52
|
+
this.uniqueFeatures.set(featureName, feature);
|
|
53
|
+
}
|
|
54
|
+
else if (typeof feature === 'function') {
|
|
55
|
+
this.log?.info?.(`Multiple ${featureName} tasks found. Using the first.`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
this.generators[uniqueGlobally ? uniqueBy : `${generatorRoot}#${uniqueBy}`] = generator;
|
|
60
|
+
return { identifier, added: true, generator };
|
|
61
|
+
}
|
|
62
|
+
getUniqueByPathMap(root) {
|
|
63
|
+
if (!this.uniqueByPathMap.has(root)) {
|
|
64
|
+
this.uniqueByPathMap.set(root, new Map());
|
|
65
|
+
}
|
|
66
|
+
return this.uniqueByPathMap.get(root);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2
|
+
export const UNKNOWN_NAMESPACE = 'unknownnamespace';
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
4
|
+
export const UNKNOWN_RESOLVED = 'unknown';
|
|
5
|
+
export const defaultQueues = [
|
|
6
|
+
'environment:run',
|
|
7
|
+
'initializing',
|
|
8
|
+
'prompting',
|
|
9
|
+
'configuring',
|
|
10
|
+
'default',
|
|
11
|
+
'writing',
|
|
12
|
+
'transform',
|
|
13
|
+
'conflicts',
|
|
14
|
+
'environment:conflicts',
|
|
15
|
+
'install',
|
|
16
|
+
'end',
|
|
17
|
+
];
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
+
import EventEmitter from 'node:events';
|
|
4
|
+
import { type Transform } from 'node:stream';
|
|
5
|
+
import { QueuedAdapter, type TerminalAdapterOptions } from '@yeoman/adapter';
|
|
6
|
+
import type { ApplyTransformsOptions, BaseEnvironment, BaseEnvironmentOptions, BaseGenerator, BaseGeneratorConstructor, BaseGeneratorMeta, ComposeOptions, GeneratorMeta, GetGeneratorConstructor, InputOutputAdapter, InstantiateOptions, LookupGeneratorMeta } from '@yeoman/types';
|
|
7
|
+
import { type Store as MemFs } from 'mem-fs';
|
|
8
|
+
import { type MemFsEditor, type MemFsEditorFile } from 'mem-fs-editor';
|
|
9
|
+
import { FlyRepository } from 'fly-import';
|
|
10
|
+
import GroupedQueue from 'grouped-queue';
|
|
11
|
+
import { type YeomanNamespace } from '@yeoman/namespace';
|
|
12
|
+
import { type ConflicterOptions } from '@yeoman/conflicter';
|
|
13
|
+
import { ComposedStore } from './composed-store.js';
|
|
14
|
+
import Store from './store.js';
|
|
15
|
+
import type YeomanCommand from './util/command.js';
|
|
16
|
+
import { type LookupOptions } from './generator-lookup.js';
|
|
17
|
+
export type EnvironmentOptions = BaseEnvironmentOptions & Omit<TerminalAdapterOptions, 'promptModule'> & {
|
|
18
|
+
adapter?: InputOutputAdapter;
|
|
19
|
+
logCwd?: string;
|
|
20
|
+
command?: YeomanCommand;
|
|
21
|
+
yeomanRepository?: string;
|
|
22
|
+
arboristRegistry?: string;
|
|
23
|
+
nodePackageManager?: string;
|
|
24
|
+
};
|
|
25
|
+
export default class EnvironmentBase extends EventEmitter implements BaseEnvironment {
|
|
26
|
+
cwd: string;
|
|
27
|
+
adapter: QueuedAdapter;
|
|
28
|
+
sharedFs: MemFs<MemFsEditorFile>;
|
|
29
|
+
conflicterOptions?: ConflicterOptions;
|
|
30
|
+
protected logCwd: string;
|
|
31
|
+
protected readonly options: EnvironmentOptions;
|
|
32
|
+
protected readonly aliases: Array<{
|
|
33
|
+
match: RegExp;
|
|
34
|
+
value: string;
|
|
35
|
+
}>;
|
|
36
|
+
protected store: Store;
|
|
37
|
+
protected command?: YeomanCommand;
|
|
38
|
+
protected runLoop: GroupedQueue;
|
|
39
|
+
protected composedStore: ComposedStore;
|
|
40
|
+
protected fs: MemFsEditor;
|
|
41
|
+
protected lookups: string[];
|
|
42
|
+
protected sharedOptions: Record<string, any>;
|
|
43
|
+
protected repository: FlyRepository;
|
|
44
|
+
protected experimental: boolean;
|
|
45
|
+
protected _rootGenerator?: BaseGenerator;
|
|
46
|
+
protected compatibilityMode?: false | 'v4';
|
|
47
|
+
constructor(options?: EnvironmentOptions);
|
|
48
|
+
applyTransforms(transformStreams: Transform[], options?: ApplyTransformsOptions): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Get a single generator from the registered list of generators. The lookup is
|
|
51
|
+
* based on generator's namespace, "walking up" the namespaces until a matching
|
|
52
|
+
* is found. Eg. if an `angular:common` namespace is registered, and we try to
|
|
53
|
+
* get `angular:common:all` then we get `angular:common` as a fallback (unless
|
|
54
|
+
* an `angular:common:all` generator is registered).
|
|
55
|
+
*
|
|
56
|
+
* @param namespaceOrPath
|
|
57
|
+
* @return the generator registered under the namespace
|
|
58
|
+
*/
|
|
59
|
+
get<C extends BaseGeneratorConstructor = BaseGeneratorConstructor>(namespaceOrPath: string | YeomanNamespace): Promise<C | undefined>;
|
|
60
|
+
/**
|
|
61
|
+
* Create is the Generator factory. It takes a namespace to lookup and optional
|
|
62
|
+
* hash of options, that lets you define `arguments` and `options` to
|
|
63
|
+
* instantiate the generator with.
|
|
64
|
+
*
|
|
65
|
+
* An error is raised on invalid namespace.
|
|
66
|
+
*
|
|
67
|
+
* @param namespaceOrPath
|
|
68
|
+
* @param instantiateOptions
|
|
69
|
+
* @return The instantiated generator
|
|
70
|
+
*/
|
|
71
|
+
create<G extends BaseGenerator = BaseGenerator>(namespaceOrPath: string | GetGeneratorConstructor<G>, instantiateOptions?: InstantiateOptions<G>): Promise<G>;
|
|
72
|
+
/**
|
|
73
|
+
* Instantiate a Generator with metadatas
|
|
74
|
+
*
|
|
75
|
+
* @param generator Generator class
|
|
76
|
+
* @param instantiateOptions
|
|
77
|
+
* @return The instantiated generator
|
|
78
|
+
*/
|
|
79
|
+
instantiate<G extends BaseGenerator = BaseGenerator>(generator: GetGeneratorConstructor<G>, instantiateOptions?: InstantiateOptions<G>): Promise<G>;
|
|
80
|
+
/**
|
|
81
|
+
* @protected
|
|
82
|
+
* Compose with the generator.
|
|
83
|
+
*
|
|
84
|
+
* @param {String} namespaceOrPath
|
|
85
|
+
* @return {Generator} The instantiated generator or the singleton instance.
|
|
86
|
+
*/
|
|
87
|
+
composeWith<G extends BaseGenerator = BaseGenerator>(generator: string | GetGeneratorConstructor<G>, composeOptions?: ComposeOptions<G>): Promise<G>;
|
|
88
|
+
/**
|
|
89
|
+
* Given a String `filepath`, tries to figure out the relative namespace.
|
|
90
|
+
*
|
|
91
|
+
* ### Examples:
|
|
92
|
+
*
|
|
93
|
+
* this.namespace('backbone/all/index.js');
|
|
94
|
+
* // => backbone:all
|
|
95
|
+
*
|
|
96
|
+
* this.namespace('generator-backbone/model');
|
|
97
|
+
* // => backbone:model
|
|
98
|
+
*
|
|
99
|
+
* this.namespace('backbone.js');
|
|
100
|
+
* // => backbone
|
|
101
|
+
*
|
|
102
|
+
* this.namespace('generator-mocha/backbone/model/index.js');
|
|
103
|
+
* // => mocha:backbone:model
|
|
104
|
+
*
|
|
105
|
+
* @param {String} filepath
|
|
106
|
+
* @param {Array} lookups paths
|
|
107
|
+
*/
|
|
108
|
+
namespace(filepath: string, lookups?: string[]): string;
|
|
109
|
+
/**
|
|
110
|
+
* Returns the environment or dependency version.
|
|
111
|
+
* @param {String} packageName - Module to get version.
|
|
112
|
+
* @return {String} Environment version.
|
|
113
|
+
*/
|
|
114
|
+
getVersion(): string;
|
|
115
|
+
getVersion(dependency: string): string | undefined;
|
|
116
|
+
/**
|
|
117
|
+
* Queue generator run (queue itself tasks).
|
|
118
|
+
*
|
|
119
|
+
* @param {Generator} generator Generator instance
|
|
120
|
+
* @param {boolean} [schedule=false] Whether to schedule the generator run.
|
|
121
|
+
* @return {Generator} The generator or singleton instance.
|
|
122
|
+
*/
|
|
123
|
+
queueGenerator<G extends BaseGenerator = BaseGenerator>(generator: G, queueOptions?: {
|
|
124
|
+
schedule?: boolean;
|
|
125
|
+
}): Promise<G>;
|
|
126
|
+
/**
|
|
127
|
+
* Get the first generator that was queued to run in this environment.
|
|
128
|
+
*
|
|
129
|
+
* @return {Generator} generator queued to run in this environment.
|
|
130
|
+
*/
|
|
131
|
+
rootGenerator<G extends BaseGenerator = BaseGenerator>(): G;
|
|
132
|
+
runGenerator(generator: BaseGenerator): Promise<void>;
|
|
133
|
+
/**
|
|
134
|
+
* Start Environment queue
|
|
135
|
+
* @param {Object} options - Conflicter options.
|
|
136
|
+
*/
|
|
137
|
+
start(options: any): Promise<void>;
|
|
138
|
+
/**
|
|
139
|
+
* Registers a specific `generator` to this environment. This generator is stored under
|
|
140
|
+
* provided namespace, or a default namespace format if none if available.
|
|
141
|
+
*
|
|
142
|
+
* @param name - Filepath to the a generator or a npm package name
|
|
143
|
+
* @param namespace - Namespace under which register the generator (optional)
|
|
144
|
+
* @param packagePath - PackagePath to the generator npm package (optional)
|
|
145
|
+
* @return environment - This environment
|
|
146
|
+
*/
|
|
147
|
+
register(filePath: string, meta?: Partial<BaseGeneratorMeta> | undefined): GeneratorMeta;
|
|
148
|
+
register(generator: unknown, meta: BaseGeneratorMeta): GeneratorMeta;
|
|
149
|
+
/**
|
|
150
|
+
* Queue tasks
|
|
151
|
+
* @param {string} priority
|
|
152
|
+
* @param {(...args: any[]) => void | Promise<void>} task
|
|
153
|
+
* @param {{ once?: string, startQueue?: boolean }} [options]
|
|
154
|
+
*/
|
|
155
|
+
queueTask(priority: string, task: () => void | Promise<void>, options?: {
|
|
156
|
+
once?: string | undefined;
|
|
157
|
+
startQueue?: boolean | undefined;
|
|
158
|
+
} | undefined): void;
|
|
159
|
+
/**
|
|
160
|
+
* Add priority
|
|
161
|
+
* @param {string} priority
|
|
162
|
+
* @param {string} [before]
|
|
163
|
+
*/
|
|
164
|
+
addPriority(priority: string, before?: string | undefined): void;
|
|
165
|
+
/**
|
|
166
|
+
* Search for generators and their sub generators.
|
|
167
|
+
*
|
|
168
|
+
* A generator is a `:lookup/:name/index.js` file placed inside an npm package.
|
|
169
|
+
*
|
|
170
|
+
* Defaults lookups are:
|
|
171
|
+
* - ./
|
|
172
|
+
* - generators/
|
|
173
|
+
* - lib/generators/
|
|
174
|
+
*
|
|
175
|
+
* So this index file `node_modules/generator-dummy/lib/generators/yo/index.js` would be
|
|
176
|
+
* registered as `dummy:yo` generator.
|
|
177
|
+
*/
|
|
178
|
+
lookup(options?: LookupOptions & {
|
|
179
|
+
registerToScope?: string;
|
|
180
|
+
}): Promise<LookupGeneratorMeta[]>;
|
|
181
|
+
/**
|
|
182
|
+
* Verify if a package namespace already have been registered.
|
|
183
|
+
*
|
|
184
|
+
* @param packageNS - namespace of the package.
|
|
185
|
+
* @return true if any generator of the package has been registered
|
|
186
|
+
*/
|
|
187
|
+
isPackageRegistered(packageNamespace: string): boolean;
|
|
188
|
+
/**
|
|
189
|
+
* Get all registered packages namespaces.
|
|
190
|
+
*
|
|
191
|
+
* @return array of namespaces.
|
|
192
|
+
*/
|
|
193
|
+
getRegisteredPackages(): string[];
|
|
194
|
+
/**
|
|
195
|
+
* Returns stored generators meta
|
|
196
|
+
* @param namespace
|
|
197
|
+
*/
|
|
198
|
+
getGeneratorMeta(namespace: string): GeneratorMeta | undefined;
|
|
199
|
+
/**
|
|
200
|
+
* Get or create an alias.
|
|
201
|
+
*
|
|
202
|
+
* Alias allows the `get()` and `lookup()` methods to search in alternate
|
|
203
|
+
* filepath for a given namespaces. It's used for example to map `generator-*`
|
|
204
|
+
* npm package to their namespace equivalent (without the generator- prefix),
|
|
205
|
+
* or to default a single namespace like `angular` to `angular:app` or
|
|
206
|
+
* `angular:all`.
|
|
207
|
+
*
|
|
208
|
+
* Given a single argument, this method acts as a getter. When both name and
|
|
209
|
+
* value are provided, acts as a setter and registers that new alias.
|
|
210
|
+
*
|
|
211
|
+
* If multiple alias are defined, then the replacement is recursive, replacing
|
|
212
|
+
* each alias in reverse order.
|
|
213
|
+
*
|
|
214
|
+
* An alias can be a single String or a Regular Expression. The finding is done
|
|
215
|
+
* based on .match().
|
|
216
|
+
*
|
|
217
|
+
* @param {String|RegExp} match
|
|
218
|
+
* @param {String} value
|
|
219
|
+
*
|
|
220
|
+
* @example
|
|
221
|
+
*
|
|
222
|
+
* env.alias(/^([a-zA-Z0-9:\*]+)$/, 'generator-$1');
|
|
223
|
+
* env.alias(/^([^:]+)$/, '$1:app');
|
|
224
|
+
* env.alias(/^([^:]+)$/, '$1:all');
|
|
225
|
+
* env.alias('foo');
|
|
226
|
+
* // => generator-foo:all
|
|
227
|
+
*/
|
|
228
|
+
alias(match: string | RegExp, value: string): this;
|
|
229
|
+
alias(value: string): string;
|
|
230
|
+
/**
|
|
231
|
+
* Queue environment's commit task.
|
|
232
|
+
*/
|
|
233
|
+
protected queueCommit(): void;
|
|
234
|
+
/**
|
|
235
|
+
* Queue environment's package manager install task.
|
|
236
|
+
*/
|
|
237
|
+
protected queuePackageManagerInstall(): void;
|
|
238
|
+
/**
|
|
239
|
+
* Registers a specific `generator` to this environment. This generator is stored under
|
|
240
|
+
* provided namespace, or a default namespace format if none if available.
|
|
241
|
+
*
|
|
242
|
+
* @param name - Filepath to the a generator or a npm package name
|
|
243
|
+
* @param namespace - Namespace under which register the generator (optional)
|
|
244
|
+
* @param packagePath - PackagePath to the generator npm package (optional)
|
|
245
|
+
* @return environment - This environment
|
|
246
|
+
*/
|
|
247
|
+
protected registerGeneratorPath(generatorPath: string, namespace?: string, packagePath?: string): GeneratorMeta;
|
|
248
|
+
/**
|
|
249
|
+
* Register a stubbed generator to this environment. This method allow to register raw
|
|
250
|
+
* functions under the provided namespace. `registerStub` will enforce the function passed
|
|
251
|
+
* to extend the Base generator automatically.
|
|
252
|
+
*
|
|
253
|
+
* @param Generator - A Generator constructor or a simple function
|
|
254
|
+
* @param namespace - Namespace under which register the generator
|
|
255
|
+
* @param resolved - The file path to the generator
|
|
256
|
+
* @param packagePath - The generator's package path
|
|
257
|
+
*/
|
|
258
|
+
protected registerStub(Generator: any, namespace: string, resolved?: string, packagePath?: string): GeneratorMeta;
|
|
259
|
+
}
|