nx 19.0.4 → 19.0.5
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/.eslintrc.json +2 -1
- package/package.json +13 -14
- package/src/adapter/ngcli-adapter.js +6 -3
- package/src/command-line/migrate/migrate.js +16 -6
- package/src/command-line/release/utils/github.js +1 -1
- package/src/command-line/release/utils/shared.js +5 -3
- package/src/command-line/run/executor-utils.js +5 -0
- package/src/config/misc-interfaces.d.ts +2 -1
- package/src/core/graph/main.js +1 -1
- package/src/daemon/server/server.js +1 -1
- package/src/generators/utils/json.js +2 -1
- package/src/plugins/js/lock-file/npm-parser.js +10 -1
- package/src/plugins/js/lock-file/utils/pnpm-normalizer.js +3 -3
- package/src/utils/find-matching-projects.js +1 -13
- package/src/utils/json.js +1 -1
- package/src/utils/package-manager.js +14 -5
- package/src/utils/plugins/plugin-capabilities.js +24 -1
@@ -198,7 +198,7 @@ const handleWorkspaceChanges = async (err, changeEvents) => {
|
|
198
198
|
});
|
199
199
|
return;
|
200
200
|
}
|
201
|
-
if (err
|
201
|
+
if (err) {
|
202
202
|
let error = typeof err === 'string' ? new Error(err) : err;
|
203
203
|
logger_1.serverLogger.watcherLog('Unexpected workspace watcher error', error.message);
|
204
204
|
console.error(error);
|
@@ -30,7 +30,8 @@ exports.readJson = readJson;
|
|
30
30
|
* @param options Optional JSON Serialize Options
|
31
31
|
*/
|
32
32
|
function writeJson(tree, path, value, options) {
|
33
|
-
|
33
|
+
const serialized = (0, json_1.serializeJson)(value, options);
|
34
|
+
tree.write(path, `${serialized}\n`);
|
34
35
|
}
|
35
36
|
exports.writeJson = writeJson;
|
36
37
|
/**
|
@@ -175,7 +175,16 @@ function findTarget(sourcePath, keyMap, targetName, versionRange) {
|
|
175
175
|
const searchPath = `${sourcePath}node_modules/${targetName}`;
|
176
176
|
if (keyMap.has(searchPath)) {
|
177
177
|
const child = keyMap.get(searchPath);
|
178
|
-
if
|
178
|
+
// if the version is alias to another package we need to parse the versions to compare
|
179
|
+
if (child.data.version.startsWith('npm:') &&
|
180
|
+
versionRange.startsWith('npm:')) {
|
181
|
+
const nodeVersion = child.data.version.slice(child.data.version.indexOf('@', 5) + 1);
|
182
|
+
const depVersion = versionRange.slice(versionRange.indexOf('@', 5) + 1);
|
183
|
+
if (nodeVersion === depVersion || (0, semver_1.satisfies)(nodeVersion, depVersion)) {
|
184
|
+
return child;
|
185
|
+
}
|
186
|
+
}
|
187
|
+
else if (child.data.version === versionRange ||
|
179
188
|
(0, semver_1.satisfies)(child.data.version, versionRange)) {
|
180
189
|
return child;
|
181
190
|
}
|
@@ -16,7 +16,7 @@ function loadPnpmHoistedDepsDefinition() {
|
|
16
16
|
const fullPath = `${workspace_root_1.workspaceRoot}/node_modules/.modules.yaml`;
|
17
17
|
if ((0, fs_1.existsSync)(fullPath)) {
|
18
18
|
const content = (0, fs_1.readFileSync)(fullPath, 'utf-8');
|
19
|
-
const { load } = require('
|
19
|
+
const { load } = require('js-yaml');
|
20
20
|
return load(content)?.hoistedDependencies ?? {};
|
21
21
|
}
|
22
22
|
else {
|
@@ -32,7 +32,7 @@ exports.loadPnpmHoistedDepsDefinition = loadPnpmHoistedDepsDefinition;
|
|
32
32
|
* https://github.com/pnpm/pnpm/blob/af3e5559d377870d4c3d303429b3ed1a4e64fedc/lockfile/lockfile-file/src/read.ts#L91
|
33
33
|
*/
|
34
34
|
function parseAndNormalizePnpmLockfile(content) {
|
35
|
-
const { load } = require('
|
35
|
+
const { load } = require('js-yaml');
|
36
36
|
const lockFileData = load(content);
|
37
37
|
return revertFromInlineSpecifiersFormatIfNecessary(convertFromLockfileFileMutable(lockFileData));
|
38
38
|
}
|
@@ -77,7 +77,7 @@ function stringifyToPnpmYaml(lockfile) {
|
|
77
77
|
const adaptedLockfile = isLockfileV6
|
78
78
|
? convertToInlineSpecifiersFormat(lockfile)
|
79
79
|
: lockfile;
|
80
|
-
const { dump } = require('
|
80
|
+
const { dump } = require('js-yaml');
|
81
81
|
return dump(sortLockfileKeys(normalizeLockfile(adaptedLockfile, isLockfileV6)), LOCKFILE_YAML_FORMAT);
|
82
82
|
}
|
83
83
|
exports.stringifyToPnpmYaml = stringifyToPnpmYaml;
|
@@ -22,15 +22,6 @@ function findMatchingProjects(patterns = [], projects) {
|
|
22
22
|
}
|
23
23
|
const projectNames = Object.keys(projects);
|
24
24
|
const matchedProjects = new Set();
|
25
|
-
// If the first pattern is an exclude pattern,
|
26
|
-
// we add a wildcard pattern at the first to select
|
27
|
-
// all projects, except the ones that match the exclude pattern.
|
28
|
-
// e.g. ['!tag:someTag', 'project2'] will match all projects except
|
29
|
-
// the ones with the tag 'someTag', and also match the project 'project2',
|
30
|
-
// regardless of its tags.
|
31
|
-
if (isExcludePattern(patterns[0])) {
|
32
|
-
patterns.unshift('*');
|
33
|
-
}
|
34
25
|
for (const stringPattern of patterns) {
|
35
26
|
if (!stringPattern.length) {
|
36
27
|
continue;
|
@@ -148,11 +139,8 @@ function addMatchingProjectsByTag(projectNames, projects, pattern, matchedProjec
|
|
148
139
|
}
|
149
140
|
}
|
150
141
|
}
|
151
|
-
function isExcludePattern(pattern) {
|
152
|
-
return pattern.startsWith('!');
|
153
|
-
}
|
154
142
|
function parseStringPattern(pattern, projects) {
|
155
|
-
const isExclude =
|
143
|
+
const isExclude = pattern.startsWith('!');
|
156
144
|
// Support for things like: `!{type}:value`
|
157
145
|
if (isExclude) {
|
158
146
|
pattern = pattern.substring(1);
|
package/src/utils/json.js
CHANGED
@@ -57,6 +57,6 @@ function formatParseError(input, parseError) {
|
|
57
57
|
* @returns the formatted JSON representation of the object
|
58
58
|
*/
|
59
59
|
function serializeJson(input, options) {
|
60
|
-
return JSON.stringify(input, null, options?.spaces ?? 2)
|
60
|
+
return JSON.stringify(input, null, options?.spaces ?? 2);
|
61
61
|
}
|
62
62
|
exports.serializeJson = serializeJson;
|
@@ -254,11 +254,20 @@ async function resolvePackageVersionUsingRegistry(packageName, version) {
|
|
254
254
|
if (!result) {
|
255
255
|
throw new Error(`Unable to resolve version ${packageName}@${version}.`);
|
256
256
|
}
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
257
|
+
const lines = result.split('\n');
|
258
|
+
if (lines.length === 1) {
|
259
|
+
return lines[0];
|
260
|
+
}
|
261
|
+
/**
|
262
|
+
* The output contains multiple lines ordered by release date, so the last
|
263
|
+
* version might not be the last one in the list. We need to sort it. Each
|
264
|
+
* line looks like:
|
265
|
+
*
|
266
|
+
* <package>@<version> '<version>'
|
267
|
+
*/
|
268
|
+
const resolvedVersion = lines
|
269
|
+
.map((line) => line.split(' ')[1])
|
270
|
+
.sort()
|
262
271
|
.pop()
|
263
272
|
.replace(/'/g, '');
|
264
273
|
return resolvedVersion;
|
@@ -114,7 +114,7 @@ async function listPluginCapabilities(pluginName, projects) {
|
|
114
114
|
if (hasBuilders) {
|
115
115
|
bodyLines.push(chalk.bold(chalk.green('EXECUTORS/BUILDERS')));
|
116
116
|
bodyLines.push('');
|
117
|
-
bodyLines.push(...Object.keys(plugin.executors).map((name) => `${chalk.bold(name)} : ${plugin.executors[name]
|
117
|
+
bodyLines.push(...Object.keys(plugin.executors).map((name) => `${chalk.bold(name)} : ${resolveExecutorDescription(plugin.executors[name], projects)}`));
|
118
118
|
}
|
119
119
|
if (hasProjectGraphExtension) {
|
120
120
|
bodyLines.push(`✔️ Project Graph Extension`);
|
@@ -128,3 +128,26 @@ async function listPluginCapabilities(pluginName, projects) {
|
|
128
128
|
});
|
129
129
|
}
|
130
130
|
exports.listPluginCapabilities = listPluginCapabilities;
|
131
|
+
function resolveExecutorDescription(executorJsonEntry, projects) {
|
132
|
+
try {
|
133
|
+
if (typeof executorJsonEntry === 'string') {
|
134
|
+
// it points to another executor, resolve it
|
135
|
+
const [pkgName, executor] = executorJsonEntry.split(':');
|
136
|
+
const collection = loadExecutorsCollection(workspace_root_1.workspaceRoot, pkgName, projects);
|
137
|
+
return resolveExecutorDescription(collection[executor], projects);
|
138
|
+
}
|
139
|
+
return executorJsonEntry.description;
|
140
|
+
}
|
141
|
+
catch {
|
142
|
+
return 'No description available';
|
143
|
+
}
|
144
|
+
}
|
145
|
+
function loadExecutorsCollection(workspaceRoot, pluginName, projects) {
|
146
|
+
const { json: packageJson, path: packageJsonPath } = (0, plugins_1.readPluginPackageJson)(pluginName, projects, (0, installation_directory_1.getNxRequirePaths)(workspaceRoot));
|
147
|
+
return {
|
148
|
+
...tryGetCollection(packageJsonPath, packageJson.builders, 'builders'),
|
149
|
+
...tryGetCollection(packageJsonPath, packageJson.executors, 'builders'),
|
150
|
+
...tryGetCollection(packageJsonPath, packageJson.builders, 'executors'),
|
151
|
+
...tryGetCollection(packageJsonPath, packageJson.executors, 'executors'),
|
152
|
+
};
|
153
|
+
}
|