nx 20.4.0-beta.0 → 20.4.0-beta.2
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/package.json +11 -11
- package/src/command-line/import/import.js +32 -5
- package/src/command-line/init/implementation/angular/standalone-workspace.js +2 -1
- package/src/command-line/init/implementation/check-compatible-with-plugins.d.ts +15 -0
- package/src/command-line/init/implementation/check-compatible-with-plugins.js +128 -0
- package/src/command-line/release/config/conventional-commits.js +7 -0
- package/src/command-line/release/utils/git.js +6 -1
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/styles.js +1 -1
- package/src/generators/utils/project-configuration.js +13 -3
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/plugins/js/lock-file/utils/package-json.d.ts +1 -1
- package/src/plugins/js/lock-file/utils/package-json.js +2 -1
- package/src/plugins/js/lock-file/yarn-parser.js +15 -4
- package/src/plugins/js/utils/register.d.ts +2 -0
- package/src/plugins/js/versions.d.ts +1 -1
- package/src/plugins/js/versions.js +1 -1
- package/src/plugins/package-json/create-nodes.d.ts +1 -1
- package/src/plugins/package-json/create-nodes.js +5 -4
- package/src/project-graph/error-types.d.ts +4 -1
- package/src/project-graph/error-types.js +5 -2
- package/src/project-graph/utils/project-configuration-utils.js +5 -3
- package/src/tasks-runner/default-tasks-runner.js +20 -2
- package/src/tasks-runner/run-command.js +6 -1
package/src/core/graph/styles.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[532],{
|
1
|
+
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[532],{69552:()=>{}},s=>{var e;e=69552,s(s.s=e)}]);
|
@@ -80,9 +80,15 @@ function updateProjectConfigurationInPackageJson(tree, projectName, projectConfi
|
|
80
80
|
packageJson.nx = {
|
81
81
|
...packageJson.nx,
|
82
82
|
...projectConfiguration,
|
83
|
-
root: undefined,
|
84
83
|
};
|
85
|
-
|
84
|
+
// We don't want to ever this since it is inferred
|
85
|
+
delete packageJson.nx.root;
|
86
|
+
// Only set `nx` property in `package.json` if it is a root project (necessary to mark it as Nx project),
|
87
|
+
// or if there are properties to be set. If it is empty, then avoid it so we don't add unnecessary boilerplate.
|
88
|
+
if (projectConfiguration.root === '.' ||
|
89
|
+
Object.keys(packageJson.nx).length > 0) {
|
90
|
+
(0, json_1.writeJson)(tree, packageJsonFile, packageJson);
|
91
|
+
}
|
86
92
|
}
|
87
93
|
function updateProjectConfigurationInProjectJson(tree, projectName, projectConfiguration) {
|
88
94
|
const projectConfigFile = (0, path_2.joinPathFragments)(projectConfiguration.root, 'project.json');
|
@@ -158,7 +164,11 @@ function readAndCombineAllProjectConfigurations(tree) {
|
|
158
164
|
const patterns = [
|
159
165
|
'**/project.json',
|
160
166
|
'project.json',
|
161
|
-
...(0, package_json_1.getGlobPatternsFromPackageManagerWorkspaces)(tree.root, (p) => (0, json_1.readJson)(tree, p, { expectComments: true }))
|
167
|
+
...(0, package_json_1.getGlobPatternsFromPackageManagerWorkspaces)(tree.root, (p) => (0, json_1.readJson)(tree, p, { expectComments: true }), (p) => {
|
168
|
+
const content = tree.read(p, 'utf-8');
|
169
|
+
const { load } = require('@zkochan/js-yaml');
|
170
|
+
return load(content, { filename: p });
|
171
|
+
}, (p) => tree.exists(p)),
|
162
172
|
];
|
163
173
|
const globbedFiles = (0, workspace_context_1.globWithWorkspaceContextSync)(tree.root, patterns);
|
164
174
|
const createdFiles = findCreatedProjectFiles(tree, patterns);
|
Binary file
|
@@ -3,7 +3,7 @@ import { PackageJson } from '../../../../utils/package-json';
|
|
3
3
|
* Get version of hoisted package if available
|
4
4
|
*/
|
5
5
|
export declare function getHoistedPackageVersion(packageName: string): string;
|
6
|
-
export type NormalizedPackageJson = Pick<PackageJson, 'name' | 'version' | 'license' | 'dependencies' | 'devDependencies' | 'peerDependencies' | 'peerDependenciesMeta' | 'optionalDependencies'>;
|
6
|
+
export type NormalizedPackageJson = Pick<PackageJson, 'name' | 'version' | 'license' | 'dependencies' | 'devDependencies' | 'peerDependencies' | 'peerDependenciesMeta' | 'optionalDependencies' | 'packageManager'>;
|
7
7
|
/**
|
8
8
|
* Strip off non-pruning related fields from package.json
|
9
9
|
*/
|
@@ -19,7 +19,7 @@ function getHoistedPackageVersion(packageName) {
|
|
19
19
|
* Strip off non-pruning related fields from package.json
|
20
20
|
*/
|
21
21
|
function normalizePackageJson(packageJson) {
|
22
|
-
const { name, version, license, dependencies, devDependencies, peerDependencies, peerDependenciesMeta, optionalDependencies, } = packageJson;
|
22
|
+
const { name, version, license, dependencies, devDependencies, peerDependencies, peerDependenciesMeta, optionalDependencies, packageManager, } = packageJson;
|
23
23
|
return {
|
24
24
|
name,
|
25
25
|
version,
|
@@ -29,5 +29,6 @@ function normalizePackageJson(packageJson) {
|
|
29
29
|
peerDependencies,
|
30
30
|
peerDependenciesMeta,
|
31
31
|
optionalDependencies,
|
32
|
+
packageManager,
|
32
33
|
};
|
33
34
|
}
|
@@ -418,18 +418,29 @@ function findPatchedKeys(dependencies, node) {
|
|
418
418
|
}
|
419
419
|
const BERRY_LOCK_FILE_DISCLAIMER = `# This file is generated by running "yarn install" inside your project.\n# Manual changes might be lost - proceed with caution!\n\n`;
|
420
420
|
function generateRootWorkspacePackage(packageJson) {
|
421
|
+
let isVersion4 = false;
|
422
|
+
if (!!packageJson.packageManager) {
|
423
|
+
const [_, version] = packageJson.packageManager.split('@');
|
424
|
+
isVersion4 = !!version && (0, semver_1.satisfies)(version, '>=4.0.0');
|
425
|
+
}
|
426
|
+
const reducer = (acc, [name, version]) => {
|
427
|
+
acc[name] = isVersion4 ? `npm:${version}` : version;
|
428
|
+
return acc;
|
429
|
+
};
|
421
430
|
return {
|
422
431
|
version: '0.0.0-use.local',
|
423
432
|
resolution: `${packageJson.name}@workspace:.`,
|
424
|
-
...(packageJson.dependencies && {
|
433
|
+
...(packageJson.dependencies && {
|
434
|
+
dependencies: Object.entries(packageJson.dependencies).reduce(reducer, {}),
|
435
|
+
}),
|
425
436
|
...(packageJson.peerDependencies && {
|
426
|
-
peerDependencies: packageJson.peerDependencies,
|
437
|
+
peerDependencies: Object.entries(packageJson.peerDependencies).reduce(reducer, {}),
|
427
438
|
}),
|
428
439
|
...(packageJson.devDependencies && {
|
429
|
-
devDependencies: packageJson.devDependencies,
|
440
|
+
devDependencies: Object.entries(packageJson.devDependencies).reduce(reducer, {}),
|
430
441
|
}),
|
431
442
|
...(packageJson.optionalDependencies && {
|
432
|
-
optionalDependencies: packageJson.optionalDependencies,
|
443
|
+
optionalDependencies: Object.entries(packageJson.optionalDependencies).reduce(reducer, {}),
|
433
444
|
}),
|
434
445
|
languageName: 'unknown',
|
435
446
|
linkType: 'soft',
|
@@ -91,6 +91,7 @@ export declare function getTsNodeCompilerOptions(compilerOptions: CompilerOption
|
|
91
91
|
moduleDetection?: any;
|
92
92
|
newLine?: any;
|
93
93
|
noEmit?: any;
|
94
|
+
noCheck?: any;
|
94
95
|
noEmitHelpers?: any;
|
95
96
|
noEmitOnError?: any;
|
96
97
|
noErrorTruncation?: any;
|
@@ -126,6 +127,7 @@ export declare function getTsNodeCompilerOptions(compilerOptions: CompilerOption
|
|
126
127
|
removeComments?: any;
|
127
128
|
resolvePackageJsonExports?: any;
|
128
129
|
resolvePackageJsonImports?: any;
|
130
|
+
rewriteRelativeImportExtensions?: any;
|
129
131
|
rootDir?: any;
|
130
132
|
rootDirs?: any;
|
131
133
|
skipLibCheck?: any;
|
@@ -1 +1 @@
|
|
1
|
-
export declare const typescriptVersion = "~5.
|
1
|
+
export declare const typescriptVersion = "~5.7.2";
|
@@ -16,4 +16,4 @@ export declare function buildProjectConfigurationFromPackageJson(packageJson: Pa
|
|
16
16
|
/**
|
17
17
|
* Get the package.json globs from package manager workspaces
|
18
18
|
*/
|
19
|
-
export declare function getGlobPatternsFromPackageManagerWorkspaces(root: string, readJson?: <T extends Object>(path: string) => T): string[];
|
19
|
+
export declare function getGlobPatternsFromPackageManagerWorkspaces(root: string, readJson?: <T extends Object>(path: string) => T, readYaml?: <T extends Object>(path: string) => T, exists?: (path: string) => boolean): string[];
|
@@ -151,17 +151,18 @@ function buildProjectConfigurationFromPackageJson(packageJson, workspaceRoot, pa
|
|
151
151
|
/**
|
152
152
|
* Get the package.json globs from package manager workspaces
|
153
153
|
*/
|
154
|
-
function getGlobPatternsFromPackageManagerWorkspaces(root,
|
155
|
-
|
154
|
+
function getGlobPatternsFromPackageManagerWorkspaces(root,
|
155
|
+
// allow overwriting these args so we can use them in devkit
|
156
|
+
readJson = (path) => (0, fileutils_1.readJsonFile)((0, node_path_1.join)(root, path)), readYaml = (path) => (0, fileutils_1.readYamlFile)((0, node_path_1.join)(root, path)), exists = (p) => (0, node_fs_1.existsSync)((0, node_path_1.join)(root, p))) {
|
156
157
|
try {
|
157
158
|
const patterns = [];
|
158
159
|
const packageJson = readJson('package.json');
|
159
160
|
patterns.push(...normalizePatterns(Array.isArray(packageJson.workspaces)
|
160
161
|
? packageJson.workspaces
|
161
162
|
: packageJson.workspaces?.packages ?? []));
|
162
|
-
if ((
|
163
|
+
if (exists('pnpm-workspace.yaml')) {
|
163
164
|
try {
|
164
|
-
const { packages } = (
|
165
|
+
const { packages } = readYaml('pnpm-workspace.yaml') ?? {};
|
165
166
|
patterns.push(...normalizePatterns(packages || []));
|
166
167
|
}
|
167
168
|
catch (e) {
|
@@ -57,6 +57,7 @@ export declare function isProjectConfigurationsError(e: unknown): e is ProjectCo
|
|
57
57
|
export declare class AggregateCreateNodesError extends Error {
|
58
58
|
readonly errors: Array<[file: string | null, error: Error]>;
|
59
59
|
readonly partialResults: Awaited<ReturnType<CreateNodesFunctionV2>>;
|
60
|
+
pluginIndex: number | undefined;
|
60
61
|
/**
|
61
62
|
* Throwing this error from a `createNodesV2` function will allow Nx to continue processing and recieve partial results from your plugin.
|
62
63
|
* @example
|
@@ -88,10 +89,12 @@ export declare function formatAggregateCreateNodesError(error: AggregateCreateNo
|
|
88
89
|
export declare class MergeNodesError extends Error {
|
89
90
|
file: string;
|
90
91
|
pluginName: string;
|
91
|
-
|
92
|
+
pluginIndex: number;
|
93
|
+
constructor({ file, pluginName, error, pluginIndex, }: {
|
92
94
|
file: string;
|
93
95
|
pluginName: string;
|
94
96
|
error: Error;
|
97
|
+
pluginIndex?: number;
|
95
98
|
});
|
96
99
|
}
|
97
100
|
export declare class CreateMetadataError extends Error {
|
@@ -232,12 +232,15 @@ function formatAggregateCreateNodesError(error, pluginName) {
|
|
232
232
|
error.message = errorBodyLines.join('\n');
|
233
233
|
}
|
234
234
|
class MergeNodesError extends Error {
|
235
|
-
constructor({ file, pluginName, error, }) {
|
236
|
-
const msg = `The nodes created from ${file} by the "${pluginName}"
|
235
|
+
constructor({ file, pluginName, error, pluginIndex, }) {
|
236
|
+
const msg = `The nodes created from ${file} by the "${pluginName}" ${pluginIndex === undefined
|
237
|
+
? ''
|
238
|
+
: `at index ${pluginIndex} in nx.json#plugins `}could not be merged into the project graph.`;
|
237
239
|
super(msg, { cause: error });
|
238
240
|
this.name = this.constructor.name;
|
239
241
|
this.file = file;
|
240
242
|
this.pluginName = pluginName;
|
243
|
+
this.pluginIndex = pluginIndex;
|
241
244
|
this.stack = `${this.message}\n${indentString(formatErrorStackAndCause(error), 2)}`;
|
242
245
|
}
|
243
246
|
}
|
@@ -248,7 +248,7 @@ plugins) {
|
|
248
248
|
const results = [];
|
249
249
|
const errors = [];
|
250
250
|
// We iterate over plugins first - this ensures that plugins specified first take precedence.
|
251
|
-
for (const { createNodes: createNodesTuple, include, exclude, name: pluginName
|
251
|
+
for (const [index, { createNodes: createNodesTuple, include, exclude, name: pluginName },] of plugins.entries()) {
|
252
252
|
const [pattern, createNodes] = createNodesTuple ?? [];
|
253
253
|
if (!pattern) {
|
254
254
|
continue;
|
@@ -266,10 +266,11 @@ plugins) {
|
|
266
266
|
: // This represents a single plugin erroring out with a hard error.
|
267
267
|
new error_types_1.AggregateCreateNodesError([[null, e]], []);
|
268
268
|
(0, error_types_1.formatAggregateCreateNodesError)(error, pluginName);
|
269
|
+
error.pluginIndex = index;
|
269
270
|
// This represents a single plugin erroring out with a hard error.
|
270
271
|
errors.push(error);
|
271
272
|
// The plugin didn't return partial results, so we return an empty array.
|
272
|
-
return error.partialResults.map((r) => [pluginName, r[0], r[1]]);
|
273
|
+
return error.partialResults.map((r) => [pluginName, r[0], r[1], index]);
|
273
274
|
})
|
274
275
|
.finally(() => {
|
275
276
|
inProgressPlugins.delete(pluginName);
|
@@ -308,7 +309,7 @@ function mergeCreateNodesResults(results, nxJsonConfiguration, errors) {
|
|
308
309
|
const externalNodes = {};
|
309
310
|
const configurationSourceMaps = {};
|
310
311
|
for (const result of results.flat()) {
|
311
|
-
const [pluginName, file, nodes] = result;
|
312
|
+
const [pluginName, file, nodes, index] = result;
|
312
313
|
const { projects: projectNodes, externalNodes: pluginExternalNodes } = nodes;
|
313
314
|
const sourceInfo = [file, pluginName];
|
314
315
|
for (const node in projectNodes) {
|
@@ -328,6 +329,7 @@ function mergeCreateNodesResults(results, nxJsonConfiguration, errors) {
|
|
328
329
|
file,
|
329
330
|
pluginName,
|
330
331
|
error,
|
332
|
+
pluginIndex: index,
|
331
333
|
}));
|
332
334
|
}
|
333
335
|
}
|
@@ -18,7 +18,7 @@ class RemoteCacheV2 {
|
|
18
18
|
(0, promises_1.readFile)((0, path_1.join)(cacheDirectory, hash, 'code'), 'utf-8').then((s) => +s),
|
19
19
|
]);
|
20
20
|
return {
|
21
|
-
outputsPath: cacheDirectory,
|
21
|
+
outputsPath: (0, path_1.join)(cacheDirectory, hash, 'outputs'),
|
22
22
|
terminalOutput: terminalOutput ?? oldTerminalOutput,
|
23
23
|
code,
|
24
24
|
};
|
@@ -27,8 +27,26 @@ class RemoteCacheV2 {
|
|
27
27
|
return null;
|
28
28
|
}
|
29
29
|
},
|
30
|
-
store: async (hash, cacheDirectory,
|
30
|
+
store: async (hash, cacheDirectory, terminalOutput, code) => {
|
31
|
+
// The new db cache places the outputs directly into the cacheDirectory + hash.
|
32
|
+
// old instances of Nx Cloud expect these outputs to be in cacheDirectory + hash + outputs
|
33
|
+
// this ensures that everything that was in the cache directory is moved to the outputs directory
|
34
|
+
const cacheDir = (0, path_1.join)(cacheDirectory, hash);
|
35
|
+
const outputDir = (0, path_1.join)(cacheDir, 'outputs');
|
36
|
+
await (0, promises_1.mkdir)(outputDir, { recursive: true });
|
37
|
+
const files = await (0, promises_1.readdir)(cacheDir);
|
38
|
+
await Promise.all(files.map(async (file) => {
|
39
|
+
const filePath = (0, path_1.join)(cacheDir, file);
|
40
|
+
// we don't want to move these files to the outputs directory because they are not artifacts of the task
|
41
|
+
if (filePath === outputDir ||
|
42
|
+
file === 'code' ||
|
43
|
+
file === 'terminalOutput') {
|
44
|
+
return;
|
45
|
+
}
|
46
|
+
await (0, promises_1.rename)(filePath, (0, path_1.join)(outputDir, file));
|
47
|
+
}));
|
31
48
|
await (0, promises_1.writeFile)((0, path_1.join)(cacheDirectory, hash, 'code'), code.toString());
|
49
|
+
await (0, promises_1.writeFile)((0, path_1.join)(cacheDirectory, hash, 'terminalOutput'), terminalOutput);
|
32
50
|
return cache.store(hash, cacheDirectory);
|
33
51
|
},
|
34
52
|
};
|
@@ -599,5 +599,10 @@ function getRunnerOptions(runner, nxJson, nxArgs, isCloudDefault) {
|
|
599
599
|
return result;
|
600
600
|
}
|
601
601
|
function isCustomRunnerPath(modulePath) {
|
602
|
-
return ![
|
602
|
+
return ![
|
603
|
+
'nx-cloud',
|
604
|
+
'@nrwl/nx-cloud',
|
605
|
+
'nx/tasks-runners/default',
|
606
|
+
defaultTasksRunnerPath,
|
607
|
+
].includes(modulePath);
|
603
608
|
}
|