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/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
|
-
import { execaOutput } from
|
|
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;
|
|
@@ -27,13 +25,13 @@ export function moduleLookupSync(options, find) {
|
|
|
27
25
|
if (options.packagePaths) {
|
|
28
26
|
options.packagePaths = arrify(options.packagePaths);
|
|
29
27
|
if (options.reverse) {
|
|
30
|
-
options.packagePaths = options.packagePaths.
|
|
28
|
+
options.packagePaths = options.packagePaths.toReversed();
|
|
31
29
|
}
|
|
32
30
|
}
|
|
33
31
|
else {
|
|
34
32
|
options.npmPaths = options.npmPaths ?? getNpmPaths(options);
|
|
35
33
|
if (options.reverse && Array.isArray(options.npmPaths)) {
|
|
36
|
-
options.npmPaths = options.npmPaths.
|
|
34
|
+
options.npmPaths = options.npmPaths.toReversed();
|
|
37
35
|
}
|
|
38
36
|
options.packagePatterns = arrify(options.packagePatterns ?? PACKAGE_NAME_PATTERN).map(packagePattern => slash(packagePattern));
|
|
39
37
|
options.packagePaths = findPackagesIn(options.npmPaths, options.packagePatterns);
|
|
@@ -156,14 +154,14 @@ 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
|
}
|
|
164
162
|
paths.push(lookup);
|
|
165
163
|
});
|
|
166
|
-
return uniq(paths.
|
|
164
|
+
return uniq(paths.toReversed());
|
|
167
165
|
}
|
|
168
166
|
/**
|
|
169
167
|
* Get the global npm lookup directories
|
|
@@ -205,17 +203,15 @@ function getGlobalNpmPaths(filterPaths = true) {
|
|
|
205
203
|
// Ex: /usr/another_global/node_modules/yeoman-denerator/node_modules/yeoman-environment/lib (1 level dependency)
|
|
206
204
|
paths.push(...filterValidNpmPath(join(PROJECT_ROOT, '../../..'), !filterPaths));
|
|
207
205
|
// Ex: /usr/another_global/node_modules/yeoman-environment/lib (installed directly)
|
|
206
|
+
// eslint-disable-next-line unicorn/prefer-single-call
|
|
208
207
|
paths.push(join(PROJECT_ROOT, '..'));
|
|
209
208
|
// Get yarn global directory and infer the module paths from there
|
|
210
|
-
const yarnBase = execaOutput('yarn', ['global', 'dir']
|
|
209
|
+
const yarnBase = execaOutput('yarn', ['global', 'dir']);
|
|
211
210
|
if (yarnBase) {
|
|
212
|
-
paths.push(resolve(yarnBase, 'node_modules'));
|
|
213
|
-
paths.push(resolve(yarnBase, '../link/'));
|
|
211
|
+
paths.push(resolve(yarnBase, 'node_modules'), 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
|
}
|
|
@@ -223,5 +219,5 @@ function getGlobalNpmPaths(filterPaths = true) {
|
|
|
223
219
|
if (process.argv[1]) {
|
|
224
220
|
paths.push(...filterValidNpmPath(join(dirname(process.argv[1]), '../..'), !filterPaths));
|
|
225
221
|
}
|
|
226
|
-
return uniq(paths.filter(Boolean).
|
|
222
|
+
return uniq(paths.filter(Boolean).toReversed());
|
|
227
223
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { MemFsEditorFile } from 'mem-fs-editor';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import type { InputOutputAdapter } from '@yeoman/types';
|
|
3
|
+
import type { Store } from 'mem-fs';
|
|
4
|
+
export type InstallTask = (nodePackageManager: string | undefined, defaultTask: () => Promise<boolean>) => void | Promise<void>;
|
|
4
5
|
export type PackageManagerInstallTaskOptions = {
|
|
5
6
|
memFs: Store<MemFsEditorFile>;
|
|
6
7
|
packageJsonLocation: string;
|
|
7
8
|
adapter: InputOutputAdapter;
|
|
8
9
|
nodePackageManager?: string;
|
|
9
|
-
customInstallTask?: boolean |
|
|
10
|
+
customInstallTask?: boolean | InstallTask;
|
|
10
11
|
skipInstall?: boolean;
|
|
11
12
|
};
|
|
12
13
|
/**
|
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 env;
|
|
11
10
|
private readonly _meta;
|
|
12
11
|
private readonly _packagesPaths;
|
|
13
12
|
private readonly _packagesNS;
|
|
14
|
-
|
|
13
|
+
private readonly environment;
|
|
14
|
+
constructor(environment: BaseEnvironment);
|
|
15
15
|
/**
|
|
16
16
|
* Store a module under the namespace key
|
|
17
17
|
* @param meta
|
package/dist/store.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
1
9
|
import { pathToFileURL } from 'node:url';
|
|
2
10
|
import { extname, join } from 'node:path';
|
|
3
11
|
import { createRequire } from 'node:module';
|
|
@@ -13,15 +21,14 @@ const require = createRequire(import.meta.url);
|
|
|
13
21
|
* @private
|
|
14
22
|
*/
|
|
15
23
|
export default class Store {
|
|
16
|
-
env;
|
|
17
24
|
_meta = {};
|
|
18
25
|
// Store packages paths by ns
|
|
19
26
|
_packagesPaths = {};
|
|
20
27
|
// Store packages ns
|
|
21
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
22
28
|
_packagesNS = [];
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
environment;
|
|
30
|
+
constructor(environment) {
|
|
31
|
+
this.environment = environment;
|
|
25
32
|
}
|
|
26
33
|
/**
|
|
27
34
|
* Store a module under the namespace key
|
|
@@ -52,28 +59,60 @@ export default class Store {
|
|
|
52
59
|
if (!meta.resolved) {
|
|
53
60
|
throw new Error(`Generator Stub or resolved path is required for ${meta.namespace}`);
|
|
54
61
|
}
|
|
55
|
-
importModule =
|
|
62
|
+
importModule = () => {
|
|
63
|
+
try {
|
|
64
|
+
return require(meta.resolved);
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return import(__rewriteRelativeImportExtension(pathToFileURL(meta.resolved).href));
|
|
68
|
+
}
|
|
69
|
+
};
|
|
56
70
|
}
|
|
57
71
|
let importPromise;
|
|
58
|
-
|
|
72
|
+
// eslint-disable-next-line prefer-const
|
|
73
|
+
let generatorMeta;
|
|
74
|
+
const importGenerator = () => {
|
|
75
|
+
const handleImport = () => {
|
|
76
|
+
if (importModule && !Generator) {
|
|
77
|
+
const maybeModule = importModule();
|
|
78
|
+
if (maybeModule.then) {
|
|
79
|
+
importPromise = maybeModule;
|
|
80
|
+
return maybeModule.then((mod) => {
|
|
81
|
+
Generator = mod;
|
|
82
|
+
importPromise = undefined;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
Generator = maybeModule;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const handleModule = () => {
|
|
91
|
+
const factory = this.getFactory(Generator);
|
|
92
|
+
if (typeof factory === 'function') {
|
|
93
|
+
importPromise = factory(this.environment);
|
|
94
|
+
return Promise.resolve(importPromise).then((mod) => {
|
|
95
|
+
const generator = this._getGenerator(mod, meta, generatorMeta);
|
|
96
|
+
Generator = generator;
|
|
97
|
+
importPromise = undefined;
|
|
98
|
+
return generator;
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
return this._getGenerator(Generator, meta, generatorMeta);
|
|
102
|
+
};
|
|
59
103
|
if (importPromise) {
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
if (importModule && !Generator) {
|
|
63
|
-
importPromise = importModule();
|
|
64
|
-
Generator = await importPromise;
|
|
104
|
+
return importPromise.then(() => Promise.resolve(handleImport()).then(() => handleModule()));
|
|
65
105
|
}
|
|
66
|
-
const
|
|
67
|
-
if (
|
|
68
|
-
|
|
69
|
-
Generator = await importPromise;
|
|
106
|
+
const maybeImportPromise = handleImport();
|
|
107
|
+
if (maybeImportPromise?.then) {
|
|
108
|
+
return maybeImportPromise.then(() => handleModule());
|
|
70
109
|
}
|
|
71
|
-
return
|
|
110
|
+
return handleModule();
|
|
72
111
|
};
|
|
73
|
-
const instantiate = async (
|
|
112
|
+
const instantiate = async (arguments_ = [], options = {}) => this.environment.instantiate(await importGenerator(), { generatorArgs: arguments_, generatorOptions: options });
|
|
74
113
|
const instantiateHelp = async () => instantiate([], { help: true });
|
|
75
114
|
const { packageNamespace } = toNamespace(meta.namespace) ?? {};
|
|
76
|
-
|
|
115
|
+
generatorMeta = {
|
|
77
116
|
...meta,
|
|
78
117
|
importGenerator,
|
|
79
118
|
importModule,
|
|
@@ -133,7 +172,7 @@ export default class Store {
|
|
|
133
172
|
debug('Overriding a package with namespace %s and path %s, with path %s', packageNS, this._packagesPaths[packageNS][0], packagePath);
|
|
134
173
|
// Remove old packagePath
|
|
135
174
|
const index = packagePaths.indexOf(packagePath);
|
|
136
|
-
if (index
|
|
175
|
+
if (index !== -1) {
|
|
137
176
|
packagePaths.splice(index, 1);
|
|
138
177
|
}
|
|
139
178
|
packagePaths.splice(0, 0, packagePath);
|
|
@@ -163,7 +202,6 @@ export default class Store {
|
|
|
163
202
|
* Get the stored packages namespaces.
|
|
164
203
|
* @return {Array} Stored packages namespaces.
|
|
165
204
|
*/
|
|
166
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
167
205
|
getPackagesNS() {
|
|
168
206
|
return this._packagesNS;
|
|
169
207
|
}
|
|
@@ -171,13 +209,13 @@ export default class Store {
|
|
|
171
209
|
// CJS is imported in default, for backward compatibility we support a Generator exported as `module.exports = { default }`
|
|
172
210
|
return module.createGenerator ?? module.default?.createGenerator ?? module.default?.default?.createGenerator;
|
|
173
211
|
}
|
|
174
|
-
_getGenerator(module, meta) {
|
|
175
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
212
|
+
_getGenerator(module, meta, generatorMeta) {
|
|
176
213
|
const Generator = module.default?.default ?? module.default ?? module;
|
|
177
214
|
if (typeof Generator !== 'function') {
|
|
178
|
-
throw new TypeError("The generator doesn't
|
|
215
|
+
throw new TypeError("The generator doesn't provide a constructor.");
|
|
179
216
|
}
|
|
180
217
|
Object.assign(Generator, meta);
|
|
218
|
+
Generator._meta = generatorMeta;
|
|
181
219
|
return Generator;
|
|
182
220
|
}
|
|
183
221
|
}
|
package/dist/util/command.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Command, Option } from 'commander';
|
|
2
|
-
import type BaseEnvironment from '../environment-base.
|
|
2
|
+
import type BaseEnvironment from '../environment-base.ts';
|
|
3
3
|
export default class YeomanCommand extends Command {
|
|
4
|
+
#private;
|
|
4
5
|
env?: BaseEnvironment;
|
|
5
6
|
createCommand(name?: string): YeomanCommand;
|
|
6
7
|
/**
|
|
@@ -21,7 +22,7 @@ export default class YeomanCommand extends Command {
|
|
|
21
22
|
* @param {object[]} generatorArgs
|
|
22
23
|
* @return {YeomanCommand} this;
|
|
23
24
|
*/
|
|
24
|
-
addGeneratorArguments(
|
|
25
|
+
addGeneratorArguments(generatorArguments?: any[]): this;
|
|
25
26
|
/**
|
|
26
27
|
* Register options using generator._options structure.
|
|
27
28
|
* @param {object} options
|
|
@@ -29,6 +30,6 @@ export default class YeomanCommand extends Command {
|
|
|
29
30
|
* @return {YeomanCommand} this;
|
|
30
31
|
*/
|
|
31
32
|
addGeneratorOptions(options: Record<string, any>): this;
|
|
32
|
-
_addGeneratorOption(optionName: string, optionDefinition: any, additionalDescription?: string):
|
|
33
|
+
_addGeneratorOption(optionName: string, optionDefinition: any, additionalDescription?: string): Option | this | undefined;
|
|
33
34
|
}
|
|
34
35
|
export declare const addEnvironmentOptions: (command?: YeomanCommand) => YeomanCommand;
|
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
|
/**
|
|
@@ -65,13 +65,16 @@ export default class YeomanCommand extends Command {
|
|
|
65
65
|
}
|
|
66
66
|
return this;
|
|
67
67
|
}
|
|
68
|
+
#findOption(arg) {
|
|
69
|
+
return this.options.find(option => option.short === arg || option.long === arg);
|
|
70
|
+
}
|
|
68
71
|
_addGeneratorOption(optionName, optionDefinition, additionalDescription = '') {
|
|
69
72
|
if (optionName === 'help') {
|
|
70
|
-
return
|
|
73
|
+
return;
|
|
71
74
|
}
|
|
72
75
|
const longOption = `--${optionName}`;
|
|
73
|
-
const existingOption = this
|
|
74
|
-
if (this
|
|
76
|
+
const existingOption = this.#findOption(longOption);
|
|
77
|
+
if (this.#findOption(longOption)) {
|
|
75
78
|
return existingOption;
|
|
76
79
|
}
|
|
77
80
|
let cmdString = '';
|
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);
|
|
@@ -40,7 +40,7 @@ export const asNamespace = (filepath, { lookups = defaultLookups }) => {
|
|
|
40
40
|
const nsLookups = [...lookups, '..']
|
|
41
41
|
.map(found => slash(found))
|
|
42
42
|
.sort((a, b) => a.split('/').length - b.split('/').length)
|
|
43
|
-
.
|
|
43
|
+
.toReversed();
|
|
44
44
|
// If `ns` contains a lookup dir in its path, remove it.
|
|
45
45
|
for (const lookup of nsLookups) {
|
|
46
46
|
// Only match full directory (begin with leading slash or start of input, end with trailing slash)
|
package/dist/util/resolve.d.ts
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* @param specifier - Filepath or module name
|
|
4
4
|
* @return - The resolved path leading to the module
|
|
5
5
|
*/
|
|
6
|
-
export declare function resolveModulePath(specifier: string, resolvedOrigin?: string):
|
|
6
|
+
export declare function resolveModulePath(specifier: string, resolvedOrigin?: string): string | undefined;
|
package/dist/util/resolve.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { dirname, extname, join, normalize, resolve, sep } from 'node:path';
|
|
2
|
-
import {
|
|
2
|
+
import { realpathSync, statSync } from 'node:fs';
|
|
3
3
|
import untildify from 'untildify';
|
|
4
|
-
import {
|
|
5
|
-
import { defaultExtensions } from
|
|
4
|
+
import { locatePathSync } from 'locate-path';
|
|
5
|
+
import { defaultExtensions } from "../generator-lookup.js";
|
|
6
6
|
/**
|
|
7
7
|
* Resolve a module path
|
|
8
8
|
* @param specifier - Filepath or module name
|
|
9
9
|
* @return - The resolved path leading to the module
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
11
|
+
export function resolveModulePath(specifier, resolvedOrigin) {
|
|
12
12
|
let maybeResolved = specifier;
|
|
13
13
|
if (maybeResolved.startsWith('.')) {
|
|
14
14
|
if (resolvedOrigin) {
|
|
@@ -24,17 +24,19 @@ export async function resolveModulePath(specifier, resolvedOrigin) {
|
|
|
24
24
|
maybeResolved += sep;
|
|
25
25
|
}
|
|
26
26
|
try {
|
|
27
|
-
let specStat =
|
|
27
|
+
let specStat = statSync(maybeResolved);
|
|
28
28
|
if (specStat.isSymbolicLink()) {
|
|
29
|
-
specStat =
|
|
29
|
+
specStat = statSync(realpathSync(maybeResolved));
|
|
30
30
|
}
|
|
31
31
|
if (specStat.isFile()) {
|
|
32
32
|
return maybeResolved;
|
|
33
33
|
}
|
|
34
34
|
if (specStat.isDirectory()) {
|
|
35
|
-
return
|
|
35
|
+
return locatePathSync(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.1",
|
|
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": "^
|
|
62
|
-
"@yeoman/namespace": "^1.0.
|
|
63
|
-
"@yeoman/transform": "^1.
|
|
64
|
-
"@yeoman/types": "^1.
|
|
60
|
+
"@yeoman/adapter": "^2.1.1",
|
|
61
|
+
"@yeoman/conflicter": "^3.0.0",
|
|
62
|
+
"@yeoman/namespace": "^1.0.1",
|
|
63
|
+
"@yeoman/transform": "^2.1.0",
|
|
64
|
+
"@yeoman/types": "^1.7.1",
|
|
65
65
|
"arrify": "^3.0.0",
|
|
66
|
-
"chalk": "^5.
|
|
67
|
-
"commander": "^
|
|
68
|
-
"debug": "^4.
|
|
69
|
-
"execa": "^
|
|
70
|
-
"fly-import": "^0.
|
|
71
|
-
"globby": "^14.
|
|
72
|
-
"grouped-queue": "^2.
|
|
66
|
+
"chalk": "^5.5.0",
|
|
67
|
+
"commander": "^14.0.0",
|
|
68
|
+
"debug": "^4.4.1",
|
|
69
|
+
"execa": "^9.6.0",
|
|
70
|
+
"fly-import": "^1.0.0",
|
|
71
|
+
"globby": "^14.1.0",
|
|
72
|
+
"grouped-queue": "^2.1.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
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
"
|
|
83
|
+
"@types/debug": "^4.1.12",
|
|
84
|
+
"@types/lodash-es": "^4.17.12",
|
|
85
|
+
"@types/node": "^20.19.11",
|
|
86
|
+
"@types/semver": "^7.7.0",
|
|
87
|
+
"@yeoman/eslint": "1.0.0",
|
|
88
|
+
"c8": "^10.1.3",
|
|
89
|
+
"cpy-cli": "^6.0.0",
|
|
90
|
+
"eslint": "9.33.0",
|
|
91
|
+
"esmocha": "^4.0.0",
|
|
92
|
+
"fs-extra": "^11.3.1",
|
|
93
|
+
"jsdoc": "^4.0.4",
|
|
94
|
+
"prettier": "3.6.2",
|
|
95
|
+
"prettier-plugin-packagejson": "^2.5.19",
|
|
96
|
+
"rimraf": "^6.0.1",
|
|
97
|
+
"sinon": "^21.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.9.2",
|
|
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,15 @@
|
|
|
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-
|
|
108
|
+
"yeoman-generator-8": "npm:yeoman-generator@^8.0.0-beta.0",
|
|
109
|
+
"yeoman-test": "^10.1.1"
|
|
110
|
+
},
|
|
111
|
+
"peerDependencies": {
|
|
112
|
+
"@yeoman/types": "^1.7.1",
|
|
113
|
+
"mem-fs": "^4.1.2"
|
|
114
|
+
},
|
|
115
|
+
"engines": {
|
|
116
|
+
"node": "^20.17.0 || >=22.9.0"
|
|
107
117
|
},
|
|
108
118
|
"overrides": {
|
|
109
119
|
"yeoman-generator-2": {
|
|
@@ -122,7 +132,7 @@
|
|
|
122
132
|
"shelljs": "^0.8.5",
|
|
123
133
|
"sort-keys": "^4.2.0",
|
|
124
134
|
"text-table": "^0.2.0",
|
|
125
|
-
"yeoman-environment": "
|
|
135
|
+
"yeoman-environment": "file:./"
|
|
126
136
|
},
|
|
127
137
|
"yeoman-generator-4": {
|
|
128
138
|
"chalk": "^4.1.0",
|
|
@@ -140,7 +150,7 @@
|
|
|
140
150
|
"shelljs": "^0.8.5",
|
|
141
151
|
"sort-keys": "^4.2.0",
|
|
142
152
|
"text-table": "^0.2.0",
|
|
143
|
-
"yeoman-environment": "
|
|
153
|
+
"yeoman-environment": "file:./"
|
|
144
154
|
},
|
|
145
155
|
"yeoman-generator-5": {
|
|
146
156
|
"chalk": "^4.1.0",
|
|
@@ -158,21 +168,16 @@
|
|
|
158
168
|
"shelljs": "^0.8.5",
|
|
159
169
|
"sort-keys": "^4.2.0",
|
|
160
170
|
"text-table": "^0.2.0",
|
|
161
|
-
"yeoman-environment": "
|
|
171
|
+
"yeoman-environment": "file:./"
|
|
162
172
|
},
|
|
163
173
|
"yeoman-generator-6": {
|
|
164
|
-
"yeoman-environment": "
|
|
174
|
+
"yeoman-environment": "file:./"
|
|
175
|
+
},
|
|
176
|
+
"yeoman-generator-7": {
|
|
177
|
+
"yeoman-environment": "file:./"
|
|
178
|
+
},
|
|
179
|
+
"yeoman-generator-8": {
|
|
180
|
+
"yeoman-environment": "file:./"
|
|
165
181
|
}
|
|
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
|
-
"@yeoman/transform": "^2.1.0"
|
|
174
|
-
},
|
|
175
|
-
"engines": {
|
|
176
|
-
"node": "^18.17.0 || >=20.5.0"
|
|
177
182
|
}
|
|
178
183
|
}
|