yeoman-environment 4.0.0-alpha.5 → 4.0.0-alpha.7
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 +1 -0
- package/dist/cli/index.js +18 -15
- package/dist/cli/utils.d.ts +8 -0
- 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 +641 -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 -0
- 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 +18 -0
- package/dist/package-manager.js +52 -69
- package/dist/store.d.ts +66 -0
- package/dist/store.js +76 -47
- package/dist/util/command.d.ts +34 -0
- package/dist/util/command.js +32 -17
- package/dist/util/namespace.d.ts +26 -0
- 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 +7 -0
- package/dist/util/util.js +24 -23
- package/package.json +20 -33
- package/readme.md +2 -3
- 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.js +0 -74
- package/dist/command.js.map +0 -1
- package/dist/composability.js +0 -78
- package/dist/composability.js.map +0 -1
- package/dist/environment.js +0 -1221
- package/dist/environment.js.map +0 -1
- 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.js +0 -340
- package/dist/namespace-composability.js.map +0 -1
- package/dist/package-manager.js.map +0 -1
- package/dist/resolver.js +0 -421
- package/dist/resolver.js.map +0 -1
- 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.js +0 -36
- package/dist/util/binary-diff.js.map +0 -1
- package/dist/util/command.js.map +0 -1
- package/dist/util/conflicter.js +0 -346
- package/dist/util/conflicter.js.map +0 -1
- package/dist/util/esm.js +0 -22
- package/dist/util/esm.js.map +0 -1
- 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.js +0 -223
- package/dist/util/repository.js.map +0 -1
- package/dist/util/transform.js +0 -149
- package/dist/util/transform.js.map +0 -1
- package/dist/util/util.js.map +0 -1
package/dist/util/command.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Command, Option } from 'commander';
|
|
2
2
|
export default class YeomanCommand extends Command {
|
|
3
|
+
env;
|
|
3
4
|
createCommand(name) {
|
|
4
5
|
return new YeomanCommand(name);
|
|
5
6
|
}
|
|
@@ -24,13 +25,22 @@ export default class YeomanCommand extends Command {
|
|
|
24
25
|
}
|
|
25
26
|
return result;
|
|
26
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Load Generator options into a commander instance.
|
|
30
|
+
*
|
|
31
|
+
* @param {Generator} generator - Generator
|
|
32
|
+
* @return {Command} return command
|
|
33
|
+
*/
|
|
34
|
+
registerGenerator(generator) {
|
|
35
|
+
return this.addGeneratorOptions(generator._options).addGeneratorArguments(generator._arguments);
|
|
36
|
+
}
|
|
27
37
|
/**
|
|
28
38
|
* Register arguments using generator._arguments structure.
|
|
29
39
|
* @param {object[]} generatorArgs
|
|
30
40
|
* @return {YeomanCommand} this;
|
|
31
41
|
*/
|
|
32
42
|
addGeneratorArguments(generatorArgs = []) {
|
|
33
|
-
if (!generatorArgs) {
|
|
43
|
+
if (!generatorArgs || generatorArgs.length === 0) {
|
|
34
44
|
return this;
|
|
35
45
|
}
|
|
36
46
|
const args = generatorArgs
|
|
@@ -75,23 +85,28 @@ export default class YeomanCommand extends Command {
|
|
|
75
85
|
else if (optionDefinition.type === Array) {
|
|
76
86
|
cmdString = optionDefinition.required === false ? `${cmdString} [value...]` : `${cmdString} <value...>`;
|
|
77
87
|
}
|
|
78
|
-
return this.addOption(new Option(cmdString, optionDefinition.description
|
|
88
|
+
return this.addOption(new Option(cmdString, `${optionDefinition.description}${additionalDescription}`)
|
|
79
89
|
.default(optionDefinition.default)
|
|
80
90
|
.hideHelp(optionDefinition.hide));
|
|
81
91
|
}
|
|
82
|
-
/**
|
|
83
|
-
* Override to reject errors instead of throwing and add command to error.
|
|
84
|
-
* @return promise this
|
|
85
|
-
*/
|
|
86
|
-
parseAsync(argv, parseOptions) {
|
|
87
|
-
try {
|
|
88
|
-
this.parse(argv, parseOptions);
|
|
89
|
-
}
|
|
90
|
-
catch (commanderError) {
|
|
91
|
-
commanderError.command = this;
|
|
92
|
-
return Promise.reject(commanderError);
|
|
93
|
-
}
|
|
94
|
-
return Promise.all(this._actionResults).then(() => this);
|
|
95
|
-
}
|
|
96
92
|
}
|
|
97
|
-
|
|
93
|
+
/* Add Environment options */
|
|
94
|
+
export const addEnvironmentOptions = (command = new YeomanCommand()) => command
|
|
95
|
+
.option('--cwd', 'Path to use as current dir')
|
|
96
|
+
/* Environment options */
|
|
97
|
+
.option('--skip-install', 'Do not automatically install dependencies', false)
|
|
98
|
+
/* Generator options */
|
|
99
|
+
.option('--skip-cache', 'Do not remember prompt answers', false)
|
|
100
|
+
.option('--local-config-only', 'Generate .yo-rc-global.json locally', false)
|
|
101
|
+
.option('--ask-answered', 'Show prompts for already configured options', false)
|
|
102
|
+
/* Conflicter options */
|
|
103
|
+
.option('--force', 'Override every file', false)
|
|
104
|
+
.option('--dry-run', 'Print conflicts', false)
|
|
105
|
+
.option('--whitespace', 'Whitespace changes will not trigger conflicts', false)
|
|
106
|
+
.option('--bail', 'Fail on first conflict', false)
|
|
107
|
+
.option('--skip-yo-resolve', 'Ignore .yo-resolve files', false)
|
|
108
|
+
/* Hidden options, used for api */
|
|
109
|
+
.addOption(new Option('--skip-local-cache', 'Skip local answers cache').default(true).hideHelp())
|
|
110
|
+
.addOption(new Option('--skip-parse-options', 'Skip legacy options parsing').default(false).hideHelp())
|
|
111
|
+
.addOption(new Option('--experimental', 'Experimental features').default(false).hideHelp())
|
|
112
|
+
.addOption(new Option('--log-cwd', 'Path for log purpose').hideHelp());
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
type AsNamespaceOptions = {
|
|
2
|
+
lookups?: string[];
|
|
3
|
+
};
|
|
4
|
+
export declare const defaultLookups: string[];
|
|
5
|
+
/**
|
|
6
|
+
* Given a String `filepath`, tries to figure out the relative namespace.
|
|
7
|
+
*
|
|
8
|
+
* ### Examples:
|
|
9
|
+
*
|
|
10
|
+
* this.namespace('backbone/all/index.js');
|
|
11
|
+
* // => backbone:all
|
|
12
|
+
*
|
|
13
|
+
* this.namespace('generator-backbone/model');
|
|
14
|
+
* // => backbone:model
|
|
15
|
+
*
|
|
16
|
+
* this.namespace('backbone.js');
|
|
17
|
+
* // => backbone
|
|
18
|
+
*
|
|
19
|
+
* this.namespace('generator-mocha/backbone/model/index.js');
|
|
20
|
+
* // => mocha:backbone:model
|
|
21
|
+
*
|
|
22
|
+
* @param filepath
|
|
23
|
+
* @param lookups paths
|
|
24
|
+
*/
|
|
25
|
+
export declare const asNamespace: (filepath: string, { lookups }: AsNamespaceOptions) => string;
|
|
26
|
+
export {};
|
package/dist/util/namespace.js
CHANGED
|
@@ -1,197 +1,63 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
complete: 0,
|
|
7
|
-
scope: 1,
|
|
8
|
-
unscoped: 2,
|
|
9
|
-
generator: 3,
|
|
10
|
-
semver: 4,
|
|
11
|
-
instanceId: 5,
|
|
12
|
-
method: 6,
|
|
13
|
-
flags: 7,
|
|
14
|
-
};
|
|
15
|
-
const flags = { optional: '?' };
|
|
16
|
-
export class YeomanNamespace {
|
|
17
|
-
constructor(parsed) {
|
|
18
|
-
this._original = parsed.complete;
|
|
19
|
-
this.scope = parsed.scope;
|
|
20
|
-
this.unscoped = parsed.unscoped;
|
|
21
|
-
this.generator = parsed.generator;
|
|
22
|
-
this.instanceId = parsed.instanceId;
|
|
23
|
-
this.semver = parsed.semver;
|
|
24
|
-
this.methods = parsed.method ? parsed.method.split('+') : parsed.methods;
|
|
25
|
-
this.flags = parsed.flags;
|
|
26
|
-
// Populate flags
|
|
27
|
-
if (this.flags) {
|
|
28
|
-
for (const [name, value] of Object.entries(flags)) {
|
|
29
|
-
if (this.flags === value) {
|
|
30
|
-
this[name] = true;
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
delete this[name];
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
debug('Parsed namespace %o', this);
|
|
38
|
-
}
|
|
39
|
-
static parse(complete) {
|
|
40
|
-
const result = NAMESPACE_REGEX.exec(complete);
|
|
41
|
-
if (!result) {
|
|
42
|
-
debug('Namespace failed RegExp parse %s, using fallback', complete);
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
const parsed = { complete };
|
|
46
|
-
// Populate fields
|
|
47
|
-
for (const [name, value] of Object.entries(groups)) {
|
|
48
|
-
if (result[value]) {
|
|
49
|
-
parsed[name] = result[value];
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return parsed;
|
|
53
|
-
}
|
|
54
|
-
_update(parsed) {
|
|
55
|
-
this.scope = parsed.scope || this.scope;
|
|
56
|
-
this.unscoped = parsed.unscoped || this.unscoped;
|
|
57
|
-
this.generator = parsed.generator || this.generator;
|
|
58
|
-
this.instanceId = parsed.instanceId || this.instanceId;
|
|
59
|
-
this.command = parsed.command || this.command;
|
|
60
|
-
this.flags = parsed.flags || this.flags;
|
|
61
|
-
}
|
|
62
|
-
get _scopeAddition() {
|
|
63
|
-
return this.scope ? `${this.scope}/` : '';
|
|
64
|
-
}
|
|
65
|
-
get generatorName() {
|
|
66
|
-
return this.generator ? `:${this.generator}` : '';
|
|
67
|
-
}
|
|
68
|
-
_semverAddition(post) {
|
|
69
|
-
if (!this.semver) {
|
|
70
|
-
return post ?? '';
|
|
71
|
-
}
|
|
72
|
-
if (post) {
|
|
73
|
-
return `@${this.semver}@${post}`;
|
|
74
|
-
}
|
|
75
|
-
return `@${this.semver}`;
|
|
76
|
-
}
|
|
77
|
-
get instanceName() {
|
|
78
|
-
return this.instanceId ? `#${this.instanceId}` : '';
|
|
79
|
-
}
|
|
80
|
-
get complete() {
|
|
81
|
-
let methods = '';
|
|
82
|
-
if (this.methods && this.methods.length > 0) {
|
|
83
|
-
methods = '+' + this.methods.join('+');
|
|
84
|
-
}
|
|
85
|
-
const postSemver = `${this.instanceName}${methods}${this.flags || ''}`;
|
|
86
|
-
return `${this.namespace}${this._semverAddition(postSemver)}`;
|
|
87
|
-
}
|
|
88
|
-
get packageNamespace() {
|
|
89
|
-
return `${this._scopeAddition}${this.unscoped}`;
|
|
90
|
-
}
|
|
91
|
-
get namespace() {
|
|
92
|
-
return `${this.packageNamespace}${this.generatorName}`;
|
|
93
|
-
}
|
|
94
|
-
set namespace(namespace) {
|
|
95
|
-
const parsed = YeomanNamespace.parse(namespace);
|
|
96
|
-
if (!parsed) {
|
|
97
|
-
throw new Error(`Error parsing namespace ${namespace}`);
|
|
98
|
-
}
|
|
99
|
-
this._update(parsed);
|
|
100
|
-
}
|
|
101
|
-
get unscopedNamespace() {
|
|
102
|
-
return `${this.unscoped}${this.generatorName}`;
|
|
103
|
-
}
|
|
104
|
-
get id() {
|
|
105
|
-
return `${this.namespace}${this.instanceName}`;
|
|
106
|
-
}
|
|
107
|
-
get generatorHint() {
|
|
108
|
-
return `${this._scopeAddition}generator-${this.unscoped}`;
|
|
109
|
-
}
|
|
110
|
-
get versionedHint() {
|
|
111
|
-
return this.semver ? `${this.generatorHint}@"${this.semver}"` : this.generatorHint;
|
|
112
|
-
}
|
|
113
|
-
with(newValues) {
|
|
114
|
-
const self = this;
|
|
115
|
-
return new YeomanNamespace({
|
|
116
|
-
...self,
|
|
117
|
-
...newValues,
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
toString() {
|
|
121
|
-
return this.complete;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
1
|
+
import { parse } from 'node:path';
|
|
2
|
+
import slash from 'slash';
|
|
3
|
+
import { findLast } from 'lodash-es';
|
|
4
|
+
import escapeStringRegexp from 'escape-string-regexp';
|
|
5
|
+
export const defaultLookups = ['.', 'generators', 'lib/generators', 'dist/generators'];
|
|
124
6
|
/**
|
|
125
|
-
*
|
|
7
|
+
* Given a String `filepath`, tries to figure out the relative namespace.
|
|
126
8
|
*
|
|
127
|
-
*
|
|
128
|
-
* @param {String} namespace
|
|
129
|
-
* @return {Object} parsed
|
|
130
|
-
* @return {String} parsed.complete - Complete namespace
|
|
131
|
-
* @return {String} parsed.namespace - Namespace with format @scope/namespace:generator
|
|
132
|
-
* @return {String} parsed.generatorHint - Package name
|
|
133
|
-
* @return {String} parsed.id - Id of the instance.
|
|
134
|
-
* @return {String} parsed.instanceId - Instance id with format @scope/namespace:generator#id
|
|
135
|
-
* @return {String} parsed.method - Method id with format @scope/namespace:generator+foo+bar
|
|
136
|
-
* @return {String} parsed.scope - Scope name
|
|
137
|
-
* @return {String} parsed.packageNamespace - Package namespace with format @scope/namespace
|
|
138
|
-
* @return {String} parsed.generator - Original namespace
|
|
139
|
-
* @return {String} parsed.flags - Original namespace
|
|
140
|
-
*/
|
|
141
|
-
export function parseNamespace(complete) {
|
|
142
|
-
if (typeof complete !== 'string') {
|
|
143
|
-
return null;
|
|
144
|
-
}
|
|
145
|
-
const parsed = YeomanNamespace.parse(complete);
|
|
146
|
-
return parsed ? new YeomanNamespace(parsed) : null;
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Convert a namespace to a namespace object
|
|
9
|
+
* ### Examples:
|
|
150
10
|
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
* @return {YeomanNamespace}
|
|
154
|
-
*/
|
|
155
|
-
export function toNamespace(namespace) {
|
|
156
|
-
return isNamespace(namespace) ? namespace : parseNamespace(namespace);
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Convert a package name to a namespace object
|
|
11
|
+
* this.namespace('backbone/all/index.js');
|
|
12
|
+
* // => backbone:all
|
|
160
13
|
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
* @return {YeomanNamespace}
|
|
164
|
-
*/
|
|
165
|
-
export function namespaceFromPackageName(packageName) {
|
|
166
|
-
const namespace = this.parseNamespace(packageName);
|
|
167
|
-
if (!namespace.unscoped.startsWith('generator-')) {
|
|
168
|
-
throw new Error(`${packageName} is not a valid generator package name`);
|
|
169
|
-
}
|
|
170
|
-
namespace.unscoped = namespace.unscoped.replace(/^generator-/, '');
|
|
171
|
-
return namespace;
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Convert a namespace to a namespace object
|
|
14
|
+
* this.namespace('generator-backbone/model');
|
|
15
|
+
* // => backbone:model
|
|
175
16
|
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
const parsed = toNamespace(namespace);
|
|
182
|
-
if (!parsed) {
|
|
183
|
-
throw new Error(`Error parsing namespace ${namespace}`);
|
|
184
|
-
}
|
|
185
|
-
return parsed;
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Test if the object is an Namespace instance.
|
|
17
|
+
* this.namespace('backbone.js');
|
|
18
|
+
* // => backbone
|
|
19
|
+
*
|
|
20
|
+
* this.namespace('generator-mocha/backbone/model/index.js');
|
|
21
|
+
* // => mocha:backbone:model
|
|
189
22
|
*
|
|
190
|
-
* @
|
|
191
|
-
* @param
|
|
192
|
-
* @return {Boolean} True if namespace is a YeomanNamespace
|
|
23
|
+
* @param filepath
|
|
24
|
+
* @param lookups paths
|
|
193
25
|
*/
|
|
194
|
-
export
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
26
|
+
export const asNamespace = (filepath, { lookups = defaultLookups }) => {
|
|
27
|
+
if (!filepath) {
|
|
28
|
+
throw new Error('Missing file path');
|
|
29
|
+
}
|
|
30
|
+
// Normalize path
|
|
31
|
+
let ns = slash(filepath);
|
|
32
|
+
// Ignore path before latest node_modules
|
|
33
|
+
const nodeModulesPath = '/node_modules/';
|
|
34
|
+
if (ns.includes(nodeModulesPath)) {
|
|
35
|
+
ns = ns.slice(ns.lastIndexOf(nodeModulesPath) + nodeModulesPath.length, ns.length);
|
|
36
|
+
}
|
|
37
|
+
// Cleanup extension and normalize path for differents OS
|
|
38
|
+
const parsed = parse(ns);
|
|
39
|
+
ns = parsed.dir ? `${parsed.dir}/${parsed.name}` : parsed.name;
|
|
40
|
+
// Sort lookups by length so biggest are removed first
|
|
41
|
+
const nsLookups = [...lookups, '..']
|
|
42
|
+
.map(found => slash(found))
|
|
43
|
+
.sort((a, b) => a.split('/').length - b.split('/').length)
|
|
44
|
+
.reverse();
|
|
45
|
+
// If `ns` contains a lookup dir in its path, remove it.
|
|
46
|
+
for (const lookup of nsLookups) {
|
|
47
|
+
// Only match full directory (begin with leading slash or start of input, end with trailing slash)
|
|
48
|
+
ns = ns.replace(new RegExp(`(?:/|^)${escapeStringRegexp(lookup)}(?=/)`, 'g'), '');
|
|
49
|
+
}
|
|
50
|
+
const folders = ns.split('/');
|
|
51
|
+
const scope = findLast(folders, folder => folder.startsWith('@'));
|
|
52
|
+
// Cleanup `ns` from unwanted parts and then normalize slashes to `:`
|
|
53
|
+
ns = ns
|
|
54
|
+
.replace(/\/\//g, '') // Remove double `/`
|
|
55
|
+
.replace(/(.*generator-)/, '') // Remove before `generator-`
|
|
56
|
+
.replace(/\/(index|main)$/, '') // Remove `/index` or `/main`
|
|
57
|
+
.replace(/^\//, '') // Remove leading `/`
|
|
58
|
+
.replace(/\/+/g, ':'); // Replace slashes by `:`
|
|
59
|
+
if (scope) {
|
|
60
|
+
ns = `${scope}/${ns}`;
|
|
61
|
+
}
|
|
62
|
+
return ns;
|
|
63
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { dirname, extname, join, normalize, resolve, sep } from 'node:path';
|
|
2
|
+
import { realpath, stat } from 'node:fs/promises';
|
|
3
|
+
import untildify from 'untildify';
|
|
4
|
+
import { locatePath } from 'locate-path';
|
|
5
|
+
import { defaultExtensions } from '../generator-lookup.js';
|
|
6
|
+
/**
|
|
7
|
+
* Resolve a module path
|
|
8
|
+
* @param specifier - Filepath or module name
|
|
9
|
+
* @return - The resolved path leading to the module
|
|
10
|
+
*/
|
|
11
|
+
export async function resolveModulePath(specifier, resolvedOrigin) {
|
|
12
|
+
let maybeResolved = specifier;
|
|
13
|
+
if (maybeResolved.startsWith('.')) {
|
|
14
|
+
if (resolvedOrigin) {
|
|
15
|
+
maybeResolved = resolve(dirname(resolvedOrigin), '..', maybeResolved);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
throw new Error(`Specifier ${maybeResolved} could not be calculated`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
maybeResolved = untildify(maybeResolved);
|
|
22
|
+
maybeResolved = normalize(maybeResolved);
|
|
23
|
+
if (extname(maybeResolved) === '') {
|
|
24
|
+
maybeResolved += sep;
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
let specStat = await stat(maybeResolved);
|
|
28
|
+
if (specStat.isSymbolicLink()) {
|
|
29
|
+
specStat = await stat(await realpath(maybeResolved));
|
|
30
|
+
}
|
|
31
|
+
if (specStat.isFile()) {
|
|
32
|
+
return maybeResolved;
|
|
33
|
+
}
|
|
34
|
+
if (specStat.isDirectory()) {
|
|
35
|
+
return await locatePath(defaultExtensions.map(ext => `index${ext}`).map(file => join(maybeResolved, file)));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch { }
|
|
39
|
+
throw new Error(`Error resolving ${specifier}`);
|
|
40
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type SyncOptions } from 'execa';
|
|
2
|
+
export declare const execaOutput: (cmg: string, args: string[], options: SyncOptions) => string | undefined;
|
|
3
|
+
/**
|
|
4
|
+
* Two-step argument splitting function that first splits arguments in quotes,
|
|
5
|
+
* and then splits up the remaining arguments if they are not part of a quote.
|
|
6
|
+
*/
|
|
7
|
+
export declare function splitArgsFromString(argsString: string | string[]): string[];
|
package/dist/util/util.js
CHANGED
|
@@ -1,24 +1,5 @@
|
|
|
1
|
-
/** @module env/util */
|
|
2
1
|
import { execaSync } from 'execa';
|
|
3
|
-
|
|
4
|
-
import Environment from '../environment.js';
|
|
5
|
-
/**
|
|
6
|
-
* Create a "sloppy" copy of an initial Environment object. The focus of this method is on
|
|
7
|
-
* performance rather than correctly deep copying every property or recreating a correct
|
|
8
|
-
* instance. Use carefully and don't rely on `hasOwnProperty` of the copied environment.
|
|
9
|
-
*
|
|
10
|
-
* Every property are shared except the runLoop which is regenerated.
|
|
11
|
-
*
|
|
12
|
-
* @param {Environment} initialEnv - an Environment instance
|
|
13
|
-
* @return {Environment} sloppy copy of the initial Environment
|
|
14
|
-
*/
|
|
15
|
-
const duplicateEnv = initialEnv => {
|
|
16
|
-
// Hack: Create a clone of the environment with a new instance of `runLoop`
|
|
17
|
-
const env = Object.create(initialEnv);
|
|
18
|
-
env.runLoop = new GroupedQueue(Environment.queues, false);
|
|
19
|
-
return env;
|
|
20
|
-
};
|
|
21
|
-
const execaOutput = (cmg, args, options) => {
|
|
2
|
+
export const execaOutput = (cmg, args, options) => {
|
|
22
3
|
try {
|
|
23
4
|
const result = execaSync(cmg, args, options);
|
|
24
5
|
if (!result.failed) {
|
|
@@ -28,6 +9,26 @@ const execaOutput = (cmg, args, options) => {
|
|
|
28
9
|
catch { }
|
|
29
10
|
return undefined;
|
|
30
11
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Two-step argument splitting function that first splits arguments in quotes,
|
|
14
|
+
* and then splits up the remaining arguments if they are not part of a quote.
|
|
15
|
+
*/
|
|
16
|
+
export function splitArgsFromString(argsString) {
|
|
17
|
+
if (Array.isArray(argsString)) {
|
|
18
|
+
return argsString;
|
|
19
|
+
}
|
|
20
|
+
let result = [];
|
|
21
|
+
if (!argsString) {
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
const quoteSeparatedArgs = argsString.split(/("[^"]*")/).filter(Boolean);
|
|
25
|
+
for (const arg of quoteSeparatedArgs) {
|
|
26
|
+
if (arg.includes('"')) {
|
|
27
|
+
result.push(arg.replace(/"/g, ''));
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
result = result.concat(arg.trim().split(' '));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return result;
|
|
34
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yeoman-environment",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.7",
|
|
4
4
|
"description": "Handles the lifecyle and bootstrapping of generators in a specific environment",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"development",
|
|
@@ -22,21 +22,18 @@
|
|
|
22
22
|
"type": "module",
|
|
23
23
|
"exports": {
|
|
24
24
|
".": {
|
|
25
|
+
"types": "./dist/index.d.js",
|
|
25
26
|
"import": "./dist/index.js"
|
|
26
27
|
},
|
|
27
|
-
"./
|
|
28
|
-
"./lib/*": "./dist/*.js",
|
|
29
|
-
"./lib/util/*": "./dist/util/*.js",
|
|
30
|
-
"./transform": "./dist/util/transform.js",
|
|
31
|
-
"./package.json": "./package.json",
|
|
32
|
-
"./namespace": "./dist/util/namespace.js",
|
|
33
|
-
"./cli": "./dist/cli/index.js"
|
|
28
|
+
"./package.json": "./package.json"
|
|
34
29
|
},
|
|
35
30
|
"main": "./dist/index.js",
|
|
31
|
+
"types": "./dist/index.d.js",
|
|
36
32
|
"bin": {
|
|
37
|
-
"yoe": "
|
|
33
|
+
"yoe": "bin/bin.cjs"
|
|
38
34
|
},
|
|
39
35
|
"files": [
|
|
36
|
+
"bin",
|
|
40
37
|
"dist"
|
|
41
38
|
],
|
|
42
39
|
"scripts": {
|
|
@@ -54,8 +51,6 @@
|
|
|
54
51
|
"test-base": "c8 esmocha test/environment*.js test/store.js test/util.js test/adapter.js",
|
|
55
52
|
"test-environment": "c8 esmocha test/environment.js",
|
|
56
53
|
"test-generators": "c8 esmocha test/generators.js",
|
|
57
|
-
"test-namespace": "c8 esmocha test/namespace.js test/flags.js",
|
|
58
|
-
"test-repository": "c8 esmocha test/repository.js",
|
|
59
54
|
"test-resolver": "c8 esmocha test/resolver.js"
|
|
60
55
|
},
|
|
61
56
|
"config": {
|
|
@@ -63,61 +58,53 @@
|
|
|
63
58
|
},
|
|
64
59
|
"dependencies": {
|
|
65
60
|
"@npmcli/arborist": "^6.2.9",
|
|
66
|
-
"@yeoman/
|
|
67
|
-
"
|
|
61
|
+
"@yeoman/adapter": "^0.3.0",
|
|
62
|
+
"@yeoman/conflicter": "^0.6.0",
|
|
63
|
+
"@yeoman/namespace": "^1.0.0",
|
|
64
|
+
"@yeoman/transform": "^1.0.0",
|
|
65
|
+
"@yeoman/types": "^0.5.0",
|
|
68
66
|
"arrify": "^3.0.0",
|
|
69
|
-
"binaryextensions": "^4.18.0",
|
|
70
67
|
"chalk": "^5.2.0",
|
|
71
|
-
"
|
|
72
|
-
"commander": "7.1.0",
|
|
73
|
-
"dateformat": "^5.0.3",
|
|
68
|
+
"commander": "^10.0.1",
|
|
74
69
|
"debug": "^4.3.4",
|
|
75
|
-
"diff": "^5.1.0",
|
|
76
70
|
"escape-string-regexp": "^5.0.0",
|
|
77
71
|
"execa": "^7.1.1",
|
|
78
|
-
"
|
|
79
|
-
"globby": "^
|
|
72
|
+
"fly-import": "^0.2.0",
|
|
73
|
+
"globby": "^13.1.4",
|
|
80
74
|
"grouped-queue": "^2.0.0",
|
|
81
|
-
"
|
|
82
|
-
"is-scoped": "^3.0.0",
|
|
83
|
-
"isbinaryfile": "^5.0.0",
|
|
75
|
+
"locate-path": "^7.2.0",
|
|
84
76
|
"lodash-es": "^4.17.21",
|
|
85
77
|
"log-symbols": "^5.1.0",
|
|
86
78
|
"mem-fs": "^3.0.0",
|
|
87
79
|
"mem-fs-editor": "^10.0.1",
|
|
88
|
-
"minimatch": "^3.0.4",
|
|
89
80
|
"npmlog": "^7.0.1",
|
|
90
|
-
"p-queue": "^7.3.4",
|
|
91
|
-
"p-transform": "^2.0.1",
|
|
92
|
-
"pacote": "^15.1.3",
|
|
93
81
|
"preferred-pm": "^3.0.3",
|
|
94
|
-
"pretty-bytes": "^6.1.0",
|
|
95
82
|
"semver": "^7.5.0",
|
|
96
83
|
"slash": "^5.0.1",
|
|
97
|
-
"strip-ansi": "^7.0.1",
|
|
98
|
-
"text-table": "^0.2.0",
|
|
99
|
-
"textextensions": "^5.16.0",
|
|
100
84
|
"untildify": "^4.0.0",
|
|
101
85
|
"yeoman-generator": "^5.8.0"
|
|
102
86
|
},
|
|
103
87
|
"devDependencies": {
|
|
104
88
|
"@types/lodash-es": "^4.17.7",
|
|
89
|
+
"@types/semver": "^7.5.0",
|
|
105
90
|
"c8": "^7.13.0",
|
|
106
91
|
"cpy-cli": "^4.2.0",
|
|
107
|
-
"esmocha": "^0.1
|
|
92
|
+
"esmocha": "^1.0.1",
|
|
108
93
|
"fs-extra": "^11.1.1",
|
|
94
|
+
"inquirer": "^9.2.1",
|
|
109
95
|
"jsdoc": "^4.0.2",
|
|
110
96
|
"prettier": "^2.8.8",
|
|
111
97
|
"prettier-plugin-packagejson": "^2.4.3",
|
|
112
98
|
"rimraf": "^5.0.0",
|
|
113
99
|
"sinon": "^15.0.4",
|
|
114
100
|
"sinon-test": "^3.1.5",
|
|
101
|
+
"strip-ansi": "^7.0.1",
|
|
115
102
|
"tui-jsdoc-template": "^1.2.2",
|
|
116
103
|
"typescript": "^5.0.4",
|
|
117
104
|
"xo": "0.54.2",
|
|
118
105
|
"yeoman-assert": "^3.1.1",
|
|
119
106
|
"yeoman-generator": "^5.8.0",
|
|
120
|
-
"yeoman-test": "^8.0.0-
|
|
107
|
+
"yeoman-test": "^8.0.0-beta.5"
|
|
121
108
|
},
|
|
122
109
|
"peerDependencies": {
|
|
123
110
|
"mem-fs": "^3.0.0"
|
package/readme.md
CHANGED
|
@@ -17,12 +17,11 @@ $ npm install yeoman-environment
|
|
|
17
17
|
Full documentation available [here](http://yeoman.io/authoring/integrating-yeoman.html).
|
|
18
18
|
|
|
19
19
|
```js
|
|
20
|
-
import
|
|
21
|
-
const env = yeoman.createEnv();
|
|
20
|
+
import { createEnv } from 'yeoman-environment';
|
|
22
21
|
|
|
23
22
|
// The #lookup() method will search the user computer for installed generators
|
|
24
23
|
// The search if done from the current working directory
|
|
25
|
-
env.lookup();
|
|
24
|
+
await env.lookup();
|
|
26
25
|
await env.run('angular', { skipInstall: true });
|
|
27
26
|
```
|
|
28
27
|
|