nx 20.5.0-beta.0 → 20.5.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/package.json +11 -11
- package/plugins/package-json.js +2 -1
- package/schemas/nx-schema.json +7 -0
- package/src/config/schema-utils.js +4 -4
- package/src/config/workspace-json-project-json.d.ts +2 -0
- package/src/executors/run-commands/run-commands.impl.d.ts +1 -0
- package/src/executors/run-commands/run-commands.impl.js +10 -3
- package/src/executors/run-commands/schema.json +14 -0
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/plugins/js/project-graph/build-dependencies/target-project-locator.d.ts +2 -1
- package/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +11 -3
- package/src/plugins/js/utils/packages.d.ts +6 -1
- package/src/plugins/js/utils/packages.js +59 -12
- package/src/plugins/js/utils/register.d.ts +1 -1
- package/src/plugins/js/utils/register.js +1 -1
- package/src/plugins/js/utils/typescript.d.ts +1 -0
- package/src/plugins/js/utils/typescript.js +1 -0
- package/src/plugins/package-json/create-nodes.d.ts +3 -3
- package/src/plugins/package-json/create-nodes.js +8 -12
- package/src/project-graph/file-utils.js +2 -1
- package/src/project-graph/plugins/loaded-nx-plugin.js +3 -3
- package/src/project-graph/plugins/resolve-plugin.js +11 -2
- package/src/project-graph/plugins/transpiler.js +4 -4
- package/src/tasks-runner/cache.js +3 -2
- package/src/utils/package-json.d.ts +1 -1
- package/src/utils/package-json.js +4 -2
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "nx",
|
3
|
-
"version": "20.5.0-beta.
|
3
|
+
"version": "20.5.0-beta.1",
|
4
4
|
"private": false,
|
5
5
|
"description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
|
6
6
|
"repository": {
|
@@ -82,16 +82,16 @@
|
|
82
82
|
}
|
83
83
|
},
|
84
84
|
"optionalDependencies": {
|
85
|
-
"@nx/nx-darwin-arm64": "20.5.0-beta.
|
86
|
-
"@nx/nx-darwin-x64": "20.5.0-beta.
|
87
|
-
"@nx/nx-freebsd-x64": "20.5.0-beta.
|
88
|
-
"@nx/nx-linux-arm-gnueabihf": "20.5.0-beta.
|
89
|
-
"@nx/nx-linux-arm64-gnu": "20.5.0-beta.
|
90
|
-
"@nx/nx-linux-arm64-musl": "20.5.0-beta.
|
91
|
-
"@nx/nx-linux-x64-gnu": "20.5.0-beta.
|
92
|
-
"@nx/nx-linux-x64-musl": "20.5.0-beta.
|
93
|
-
"@nx/nx-win32-arm64-msvc": "20.5.0-beta.
|
94
|
-
"@nx/nx-win32-x64-msvc": "20.5.0-beta.
|
85
|
+
"@nx/nx-darwin-arm64": "20.5.0-beta.1",
|
86
|
+
"@nx/nx-darwin-x64": "20.5.0-beta.1",
|
87
|
+
"@nx/nx-freebsd-x64": "20.5.0-beta.1",
|
88
|
+
"@nx/nx-linux-arm-gnueabihf": "20.5.0-beta.1",
|
89
|
+
"@nx/nx-linux-arm64-gnu": "20.5.0-beta.1",
|
90
|
+
"@nx/nx-linux-arm64-musl": "20.5.0-beta.1",
|
91
|
+
"@nx/nx-linux-x64-gnu": "20.5.0-beta.1",
|
92
|
+
"@nx/nx-linux-x64-musl": "20.5.0-beta.1",
|
93
|
+
"@nx/nx-win32-arm64-msvc": "20.5.0-beta.1",
|
94
|
+
"@nx/nx-win32-x64-msvc": "20.5.0-beta.1"
|
95
95
|
},
|
96
96
|
"nx-migrations": {
|
97
97
|
"migrations": "./migrations.json",
|
package/plugins/package-json.js
CHANGED
@@ -25,7 +25,8 @@ const plugin = {
|
|
25
25
|
'*/**/package.json',
|
26
26
|
(configFiles, options, context) => {
|
27
27
|
const cache = readPackageJsonConfigurationCache();
|
28
|
-
const
|
28
|
+
const isInPackageJsonWorkspaces = (0, package_json_1.buildPackageJsonWorkspacesMatcher)(context.workspaceRoot, (f) => (0, fileutils_1.readJsonFile)((0, path_1.join)(context.workspaceRoot, f)));
|
29
|
+
const result = (0, plugins_1.createNodesFromFiles)((packageJsonPath) => (0, package_json_1.createNodeFromPackageJson)(packageJsonPath, workspace_root_1.workspaceRoot, cache, isInPackageJsonWorkspaces(packageJsonPath)), configFiles, options, context);
|
29
30
|
writeCache(cache);
|
30
31
|
return result;
|
31
32
|
},
|
package/schemas/nx-schema.json
CHANGED
@@ -569,6 +569,13 @@
|
|
569
569
|
"cache": {
|
570
570
|
"type": "boolean",
|
571
571
|
"description": "Specifies if the given target should be cacheable"
|
572
|
+
},
|
573
|
+
"syncGenerators": {
|
574
|
+
"type": "array",
|
575
|
+
"items": {
|
576
|
+
"type": "string"
|
577
|
+
},
|
578
|
+
"description": "List of generators to run before the target to ensure the workspace is up to date"
|
572
579
|
}
|
573
580
|
},
|
574
581
|
"additionalProperties": false
|
@@ -79,11 +79,11 @@ function resolveSchema(schemaPath, directory, packageName, projects) {
|
|
79
79
|
paths: [directory],
|
80
80
|
});
|
81
81
|
}
|
82
|
-
let
|
82
|
+
let packageToProjectMap;
|
83
83
|
function tryResolveFromSource(path, directory, packageName, projects) {
|
84
|
-
|
85
|
-
(0, packages_1.
|
86
|
-
const localProject =
|
84
|
+
packageToProjectMap ??=
|
85
|
+
(0, packages_1.getWorkspacePackagesMetadata)(projects).packageToProjectMap;
|
86
|
+
const localProject = packageToProjectMap[packageName];
|
87
87
|
if (!localProject) {
|
88
88
|
// it doesn't match any of the package names from the local projects
|
89
89
|
return null;
|
@@ -46,9 +46,9 @@ async function default_1(options, context) {
|
|
46
46
|
if (normalized.readyWhenStatus.length && !normalized.parallel) {
|
47
47
|
throw new Error('ERROR: Bad executor config for run-commands - "readyWhen" can only be used when "parallel=true".');
|
48
48
|
}
|
49
|
-
if (options.commands.find((c) => c.prefix || c.color || c.bgColor) &&
|
49
|
+
if (options.commands.find((c) => c.prefix || c.prefixColor || c.color || c.bgColor) &&
|
50
50
|
!options.parallel) {
|
51
|
-
throw new Error('ERROR: Bad executor config for run-commands - "prefix", "color" and "bgColor" can only be set when "parallel=true".');
|
51
|
+
throw new Error('ERROR: Bad executor config for run-commands - "prefix", "prefixColor", "color" and "bgColor" can only be set when "parallel=true".');
|
52
52
|
}
|
53
53
|
try {
|
54
54
|
const result = options.parallel
|
@@ -263,7 +263,14 @@ function addColorAndPrefix(out, config) {
|
|
263
263
|
if (config.prefix) {
|
264
264
|
out = out
|
265
265
|
.split('\n')
|
266
|
-
.map((l) =>
|
266
|
+
.map((l) => {
|
267
|
+
let prefixText = config.prefix;
|
268
|
+
if (config.prefixColor && chalk[config.prefixColor]) {
|
269
|
+
prefixText = chalk[config.prefixColor](prefixText);
|
270
|
+
}
|
271
|
+
prefixText = chalk.bold(prefixText);
|
272
|
+
return l.trim().length > 0 ? `${prefixText} ${l}` : l;
|
273
|
+
})
|
267
274
|
.join('\n');
|
268
275
|
}
|
269
276
|
if (config.color && chalk[config.color]) {
|
@@ -40,6 +40,20 @@
|
|
40
40
|
"type": "string",
|
41
41
|
"description": "Prefix in front of every line out of the output"
|
42
42
|
},
|
43
|
+
"prefixColor": {
|
44
|
+
"type": "string",
|
45
|
+
"description": "Color of the prefix",
|
46
|
+
"enum": [
|
47
|
+
"black",
|
48
|
+
"red",
|
49
|
+
"green",
|
50
|
+
"yellow",
|
51
|
+
"blue",
|
52
|
+
"magenta",
|
53
|
+
"cyan",
|
54
|
+
"white"
|
55
|
+
]
|
56
|
+
},
|
43
57
|
"color": {
|
44
58
|
"type": "string",
|
45
59
|
"description": "Color of the output",
|
Binary file
|
@@ -15,7 +15,7 @@ export declare class TargetProjectLocator {
|
|
15
15
|
private tsConfig;
|
16
16
|
private paths;
|
17
17
|
private typescriptResolutionCache;
|
18
|
-
private
|
18
|
+
private packagesMetadata;
|
19
19
|
constructor(nodes: Record<string, ProjectGraphProjectNode>, externalNodes?: Record<string, ProjectGraphExternalNode>, npmResolutionCache?: NpmResolutionCache);
|
20
20
|
/**
|
21
21
|
* Resolve any workspace or external project that matches the given import expression,
|
@@ -39,6 +39,7 @@ export declare class TargetProjectLocator {
|
|
39
39
|
* @returns
|
40
40
|
*/
|
41
41
|
findPaths(normalizedImportExpr: string): string[] | undefined;
|
42
|
+
findImportInWorkspaceProjects(importPath: string): string | null;
|
42
43
|
findDependencyInWorkspaceProjects(dep: string): string | null;
|
43
44
|
private resolveImportWithTypescript;
|
44
45
|
private resolveImportWithRequire;
|
@@ -101,7 +101,7 @@ class TargetProjectLocator {
|
|
101
101
|
catch { }
|
102
102
|
// fall back to see if it's a locally linked workspace project where the
|
103
103
|
// output might not exist yet
|
104
|
-
const localProject = this.
|
104
|
+
const localProject = this.findImportInWorkspaceProjects(importExpr);
|
105
105
|
if (localProject) {
|
106
106
|
return localProject;
|
107
107
|
}
|
@@ -189,9 +189,17 @@ class TargetProjectLocator {
|
|
189
189
|
}
|
190
190
|
return undefined;
|
191
191
|
}
|
192
|
+
findImportInWorkspaceProjects(importPath) {
|
193
|
+
this.packagesMetadata ??= (0, packages_1.getWorkspacePackagesMetadata)(this.nodes);
|
194
|
+
if (this.packagesMetadata.entryPointsToProjectMap[importPath]) {
|
195
|
+
return this.packagesMetadata.entryPointsToProjectMap[importPath].name;
|
196
|
+
}
|
197
|
+
const project = (0, packages_1.matchImportToWildcardEntryPointsToProjectMap)(this.packagesMetadata.wildcardEntryPointsToProjectMap, importPath);
|
198
|
+
return project?.name;
|
199
|
+
}
|
192
200
|
findDependencyInWorkspaceProjects(dep) {
|
193
|
-
this.
|
194
|
-
return this.
|
201
|
+
this.packagesMetadata ??= (0, packages_1.getWorkspacePackagesMetadata)(this.nodes);
|
202
|
+
return this.packagesMetadata.packageToProjectMap[dep]?.name;
|
195
203
|
}
|
196
204
|
resolveImportWithTypescript(normalizedImportExpr, filePath) {
|
197
205
|
let resolvedModule;
|
@@ -1,3 +1,8 @@
|
|
1
1
|
import type { ProjectGraphProjectNode } from '../../../config/project-graph';
|
2
2
|
import type { ProjectConfiguration } from '../../../config/workspace-json-project-json';
|
3
|
-
export declare function
|
3
|
+
export declare function getWorkspacePackagesMetadata<T extends ProjectGraphProjectNode | ProjectConfiguration>(projects: Record<string, T>): {
|
4
|
+
entryPointsToProjectMap: Record<string, T>;
|
5
|
+
wildcardEntryPointsToProjectMap: Record<string, T>;
|
6
|
+
packageToProjectMap: Record<string, T>;
|
7
|
+
};
|
8
|
+
export declare function matchImportToWildcardEntryPointsToProjectMap<T extends ProjectGraphProjectNode | ProjectConfiguration>(wildcardEntryPointsToProjectMap: Record<string, T>, importPath: string): T | null;
|
@@ -1,25 +1,72 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.getWorkspacePackagesMetadata = getWorkspacePackagesMetadata;
|
4
|
+
exports.matchImportToWildcardEntryPointsToProjectMap = matchImportToWildcardEntryPointsToProjectMap;
|
5
|
+
const minimatch_1 = require("minimatch");
|
4
6
|
const posix_1 = require("node:path/posix");
|
5
|
-
function
|
6
|
-
const
|
7
|
+
function getWorkspacePackagesMetadata(projects) {
|
8
|
+
const entryPointsToProjectMap = {};
|
9
|
+
const wildcardEntryPointsToProjectMap = {};
|
10
|
+
const packageToProjectMap = {};
|
7
11
|
for (const project of Object.values(projects)) {
|
8
12
|
const metadata = 'data' in project ? project.data.metadata : project.metadata;
|
9
13
|
if (!metadata?.js) {
|
10
14
|
continue;
|
11
15
|
}
|
12
|
-
const { packageName, packageExports } = metadata.js;
|
13
|
-
|
14
|
-
|
15
|
-
//
|
16
|
-
|
16
|
+
const { packageName, packageExports, packageMain, isInPackageManagerWorkspaces, } = metadata.js;
|
17
|
+
packageToProjectMap[packageName] = project;
|
18
|
+
if (!isInPackageManagerWorkspaces) {
|
19
|
+
// it is not included in the package manager workspaces config, so we
|
20
|
+
// skip it since the exports information wouldn't be used by the Node.js
|
21
|
+
// resolution
|
22
|
+
continue;
|
17
23
|
}
|
18
|
-
|
19
|
-
|
20
|
-
|
24
|
+
if (packageExports) {
|
25
|
+
if (typeof packageExports === 'string') {
|
26
|
+
// it points to a file, which would be the equivalent of an '.' export,
|
27
|
+
// in which case the package name is the entry point
|
28
|
+
entryPointsToProjectMap[packageName] = project;
|
29
|
+
}
|
30
|
+
else {
|
31
|
+
for (const entryPoint of Object.keys(packageExports)) {
|
32
|
+
if (packageExports[entryPoint] === null) {
|
33
|
+
// if the entry point is restricted, we skip it
|
34
|
+
continue;
|
35
|
+
}
|
36
|
+
if (entryPoint.startsWith('.')) {
|
37
|
+
// it is a relative subpath export
|
38
|
+
if (entryPoint.includes('*')) {
|
39
|
+
wildcardEntryPointsToProjectMap[(0, posix_1.join)(packageName, entryPoint)] =
|
40
|
+
project;
|
41
|
+
}
|
42
|
+
else {
|
43
|
+
entryPointsToProjectMap[(0, posix_1.join)(packageName, entryPoint)] = project;
|
44
|
+
}
|
45
|
+
}
|
46
|
+
else {
|
47
|
+
// it's a conditional export, so we use the package name as the entry point
|
48
|
+
// https://nodejs.org/api/packages.html#conditional-exports
|
49
|
+
entryPointsToProjectMap[packageName] = project;
|
50
|
+
}
|
51
|
+
}
|
21
52
|
}
|
22
53
|
}
|
54
|
+
else if (packageMain) {
|
55
|
+
// if there is no exports, but there is a main, the package name is the
|
56
|
+
// entry point
|
57
|
+
entryPointsToProjectMap[packageName] = project;
|
58
|
+
}
|
59
|
+
}
|
60
|
+
return {
|
61
|
+
entryPointsToProjectMap,
|
62
|
+
wildcardEntryPointsToProjectMap,
|
63
|
+
packageToProjectMap,
|
64
|
+
};
|
65
|
+
}
|
66
|
+
function matchImportToWildcardEntryPointsToProjectMap(wildcardEntryPointsToProjectMap, importPath) {
|
67
|
+
if (!Object.keys(wildcardEntryPointsToProjectMap).length) {
|
68
|
+
return null;
|
23
69
|
}
|
24
|
-
|
70
|
+
const matchingPair = Object.entries(wildcardEntryPointsToProjectMap).find(([key]) => (0, minimatch_1.minimatch)(importPath, key));
|
71
|
+
return matchingPair?.[1];
|
25
72
|
}
|
@@ -33,7 +33,7 @@ export declare function getTranspiler(compilerOptions: CompilerOptions, tsConfig
|
|
33
33
|
*
|
34
34
|
* @returns cleanup method
|
35
35
|
*/
|
36
|
-
export declare function registerTranspiler(compilerOptions: CompilerOptions
|
36
|
+
export declare function registerTranspiler(compilerOptions: CompilerOptions): () => void;
|
37
37
|
/**
|
38
38
|
* @param tsConfigPath Adds the paths from a tsconfig file into node resolutions
|
39
39
|
* @returns cleanup function
|
@@ -203,7 +203,7 @@ function getTranspiler(compilerOptions, tsConfigRaw) {
|
|
203
203
|
*
|
204
204
|
* @returns cleanup method
|
205
205
|
*/
|
206
|
-
function registerTranspiler(compilerOptions
|
206
|
+
function registerTranspiler(compilerOptions) {
|
207
207
|
// Function to register transpiler that returns cleanup function
|
208
208
|
const transpiler = getTranspiler(compilerOptions);
|
209
209
|
if (!transpiler) {
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import type * as ts from 'typescript';
|
2
2
|
import type { Node, SyntaxKind } from 'typescript';
|
3
3
|
export declare function readTsConfig(tsConfigPath: string): ts.ParsedCommandLine;
|
4
|
+
export declare function readTsConfigOptions(tsConfigPath: string): ts.CompilerOptions;
|
4
5
|
/**
|
5
6
|
* Find a module based on its import
|
6
7
|
*
|
@@ -1,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.readTsConfig = readTsConfig;
|
4
|
+
exports.readTsConfigOptions = readTsConfigOptions;
|
4
5
|
exports.resolveModuleByImport = resolveModuleByImport;
|
5
6
|
exports.getRootTsConfigFileName = getRootTsConfigFileName;
|
6
7
|
exports.getRootTsConfigPath = getRootTsConfigPath;
|
@@ -4,13 +4,13 @@ import { PackageJson } from '../../utils/package-json';
|
|
4
4
|
import { CreateNodesV2 } from '../../project-graph/plugins';
|
5
5
|
import { PackageJsonConfigurationCache } from '../../../plugins/package-json';
|
6
6
|
export declare const createNodesV2: CreateNodesV2;
|
7
|
-
export declare function buildPackageJsonWorkspacesMatcher(workspaceRoot: string, readJson: (
|
8
|
-
export declare function createNodeFromPackageJson(pkgJsonPath: string, workspaceRoot: string, cache: PackageJsonConfigurationCache): {
|
7
|
+
export declare function buildPackageJsonWorkspacesMatcher(workspaceRoot: string, readJson: (path: string) => any): (p: string) => boolean;
|
8
|
+
export declare function createNodeFromPackageJson(pkgJsonPath: string, workspaceRoot: string, cache: PackageJsonConfigurationCache, isInPackageManagerWorkspaces: boolean): {
|
9
9
|
projects: {
|
10
10
|
[x: string]: ProjectConfiguration;
|
11
11
|
};
|
12
12
|
};
|
13
|
-
export declare function buildProjectConfigurationFromPackageJson(packageJson: PackageJson, workspaceRoot: string, packageJsonPath: string, nxJson: NxJsonConfiguration): ProjectConfiguration & {
|
13
|
+
export declare function buildProjectConfigurationFromPackageJson(packageJson: PackageJson, workspaceRoot: string, packageJsonPath: string, nxJson: NxJsonConfiguration, isInPackageManagerWorkspaces: boolean): ProjectConfiguration & {
|
14
14
|
name: string;
|
15
15
|
};
|
16
16
|
/**
|
@@ -31,12 +31,13 @@ exports.createNodesV2 = [
|
|
31
31
|
};
|
32
32
|
const cache = (0, package_json_2.readPackageJsonConfigurationCache)();
|
33
33
|
return (0, plugins_1.createNodesFromFiles)((packageJsonPath, options, context) => {
|
34
|
-
|
34
|
+
const isInPackageManagerWorkspaces = isInPackageJsonWorkspaces(packageJsonPath);
|
35
|
+
if (!isInPackageManagerWorkspaces &&
|
35
36
|
!isNextToProjectJson(packageJsonPath)) {
|
36
37
|
// Skip if package.json is not part of the package.json workspaces and not next to a project.json.
|
37
38
|
return null;
|
38
39
|
}
|
39
|
-
return createNodeFromPackageJson(packageJsonPath, context.workspaceRoot, cache);
|
40
|
+
return createNodeFromPackageJson(packageJsonPath, context.workspaceRoot, cache, isInPackageManagerWorkspaces);
|
40
41
|
}, packageJsons, _, context);
|
41
42
|
},
|
42
43
|
];
|
@@ -78,18 +79,13 @@ function buildPackageJsonWorkspacesMatcher(workspaceRoot, readJson) {
|
|
78
79
|
*/
|
79
80
|
negativePatterns.every((negative) => (0, minimatch_1.minimatch)(p, negative));
|
80
81
|
}
|
81
|
-
function createNodeFromPackageJson(pkgJsonPath, workspaceRoot, cache) {
|
82
|
+
function createNodeFromPackageJson(pkgJsonPath, workspaceRoot, cache, isInPackageManagerWorkspaces) {
|
82
83
|
const json = (0, fileutils_1.readJsonFile)((0, node_path_1.join)(workspaceRoot, pkgJsonPath));
|
83
84
|
const projectRoot = (0, node_path_1.dirname)(pkgJsonPath);
|
84
85
|
const hash = (0, file_hasher_1.hashObject)({
|
85
86
|
...json,
|
86
87
|
root: projectRoot,
|
87
|
-
|
88
|
-
* Increment this number to force processing the package.json again. Do it
|
89
|
-
* when the implementation of this plugin is changed and results in different
|
90
|
-
* results for the same package.json contents.
|
91
|
-
*/
|
92
|
-
bust: 1,
|
88
|
+
isInPackageManagerWorkspaces,
|
93
89
|
});
|
94
90
|
const cached = cache[hash];
|
95
91
|
if (cached) {
|
@@ -99,7 +95,7 @@ function createNodeFromPackageJson(pkgJsonPath, workspaceRoot, cache) {
|
|
99
95
|
},
|
100
96
|
};
|
101
97
|
}
|
102
|
-
const project = buildProjectConfigurationFromPackageJson(json, workspaceRoot, pkgJsonPath, (0, nx_json_1.readNxJson)(workspaceRoot));
|
98
|
+
const project = buildProjectConfigurationFromPackageJson(json, workspaceRoot, pkgJsonPath, (0, nx_json_1.readNxJson)(workspaceRoot), isInPackageManagerWorkspaces);
|
103
99
|
cache[hash] = project;
|
104
100
|
return {
|
105
101
|
projects: {
|
@@ -107,7 +103,7 @@ function createNodeFromPackageJson(pkgJsonPath, workspaceRoot, cache) {
|
|
107
103
|
},
|
108
104
|
};
|
109
105
|
}
|
110
|
-
function buildProjectConfigurationFromPackageJson(packageJson, workspaceRoot, packageJsonPath, nxJson) {
|
106
|
+
function buildProjectConfigurationFromPackageJson(packageJson, workspaceRoot, packageJsonPath, nxJson, isInPackageManagerWorkspaces) {
|
111
107
|
const normalizedPath = packageJsonPath.split('\\').join('/');
|
112
108
|
const projectRoot = (0, node_path_1.dirname)(normalizedPath);
|
113
109
|
const siblingProjectJson = tryReadJson((0, node_path_1.join)(workspaceRoot, projectRoot, 'project.json'));
|
@@ -135,7 +131,7 @@ function buildProjectConfigurationFromPackageJson(packageJson, workspaceRoot, pa
|
|
135
131
|
...packageJson.nx,
|
136
132
|
targets: (0, package_json_1.readTargetsFromPackageJson)(packageJson, nxJson),
|
137
133
|
tags: (0, package_json_1.getTagsFromPackageJson)(packageJson),
|
138
|
-
metadata: (0, package_json_1.getMetadataFromPackageJson)(packageJson),
|
134
|
+
metadata: (0, package_json_1.getMetadataFromPackageJson)(packageJson, isInPackageManagerWorkspaces),
|
139
135
|
};
|
140
136
|
if (nxJson?.workspaceLayout?.appsDir != nxJson?.workspaceLayout?.libsDir &&
|
141
137
|
nxJson?.workspaceLayout?.appsDir &&
|
@@ -154,6 +154,7 @@ function getProjectsSync(root, nxJson) {
|
|
154
154
|
...(0, package_json_1.getGlobPatternsFromPackageManagerWorkspaces)(root, fileutils_1.readJsonFile),
|
155
155
|
];
|
156
156
|
const projectFiles = (0, workspace_context_1.globWithWorkspaceContextSync)(root, patterns);
|
157
|
+
const isInPackageJsonWorkspaces = (0, package_json_1.buildPackageJsonWorkspacesMatcher)(root, (f) => (0, fileutils_1.readJsonFile)((0, path_1.join)(root, f)));
|
157
158
|
const rootMap = {};
|
158
159
|
for (const projectFile of projectFiles) {
|
159
160
|
if ((0, path_1.basename)(projectFile) === 'project.json') {
|
@@ -163,7 +164,7 @@ function getProjectsSync(root, nxJson) {
|
|
163
164
|
}
|
164
165
|
else if ((0, path_1.basename)(projectFile) === 'package.json') {
|
165
166
|
const packageJson = (0, fileutils_1.readJsonFile)(projectFile);
|
166
|
-
const config = (0, package_json_1.buildProjectConfigurationFromPackageJson)(packageJson, root, projectFile, nxJson);
|
167
|
+
const config = (0, package_json_1.buildProjectConfigurationFromPackageJson)(packageJson, root, projectFile, nxJson, isInPackageJsonWorkspaces(projectFile));
|
167
168
|
if (!rootMap[config.root]) {
|
168
169
|
(0, project_configuration_utils_1.mergeProjectConfigurationIntoRootMap)(rootMap,
|
169
170
|
// Inferred targets, tags, etc don't show up when running generators
|
@@ -75,9 +75,9 @@ class LoadedNxPlugin {
|
|
75
75
|
}
|
76
76
|
return updates;
|
77
77
|
};
|
78
|
-
|
79
|
-
|
80
|
-
|
78
|
+
}
|
79
|
+
if (plugin.postTasksExecution) {
|
80
|
+
this.postTasksExecution = async (context) => plugin.postTasksExecution(this.options, context);
|
81
81
|
}
|
82
82
|
}
|
83
83
|
}
|
@@ -83,6 +83,7 @@ function lookupLocalPlugin(importPath, projects, root = workspace_root_1.workspa
|
|
83
83
|
return { path: path.join(root, projectConfig.root), projectConfig };
|
84
84
|
}
|
85
85
|
let packageEntryPointsToProjectMap;
|
86
|
+
let wildcardEntryPointsToProjectMap;
|
86
87
|
function findNxProjectForImportPath(importPath, projects, root = workspace_root_1.workspaceRoot) {
|
87
88
|
const tsConfigPaths = readTsConfigPaths(root);
|
88
89
|
const possibleTsPaths = tsConfigPaths[importPath]?.map((p) => (0, path_1.normalizePath)(path.relative(root, path.join(root, p)))) ?? [];
|
@@ -101,11 +102,19 @@ function findNxProjectForImportPath(importPath, projects, root = workspace_root_
|
|
101
102
|
}
|
102
103
|
}
|
103
104
|
}
|
104
|
-
packageEntryPointsToProjectMap
|
105
|
-
(
|
105
|
+
if (!packageEntryPointsToProjectMap && !wildcardEntryPointsToProjectMap) {
|
106
|
+
({
|
107
|
+
entryPointsToProjectMap: packageEntryPointsToProjectMap,
|
108
|
+
wildcardEntryPointsToProjectMap,
|
109
|
+
} = (0, packages_1.getWorkspacePackagesMetadata)(projects));
|
110
|
+
}
|
106
111
|
if (packageEntryPointsToProjectMap[importPath]) {
|
107
112
|
return packageEntryPointsToProjectMap[importPath];
|
108
113
|
}
|
114
|
+
const project = (0, packages_1.matchImportToWildcardEntryPointsToProjectMap)(wildcardEntryPointsToProjectMap, importPath);
|
115
|
+
if (project) {
|
116
|
+
return project;
|
117
|
+
}
|
109
118
|
logger_1.logger.verbose('Unable to find local plugin', possibleTsPaths, projectRootMappings);
|
110
119
|
throw new Error('Unable to resolve local plugin with import path ' + importPath);
|
111
120
|
}
|
@@ -23,16 +23,16 @@ function registerPluginTSTranspiler() {
|
|
23
23
|
if (!tsConfigName) {
|
24
24
|
return;
|
25
25
|
}
|
26
|
-
const
|
27
|
-
? (0, typescript_1.
|
26
|
+
const tsConfigOptions = tsConfigName
|
27
|
+
? (0, typescript_1.readTsConfigOptions)(tsConfigName)
|
28
28
|
: {};
|
29
29
|
const cleanupFns = [
|
30
30
|
(0, register_1.registerTsConfigPaths)(tsConfigName),
|
31
31
|
(0, register_1.registerTranspiler)({
|
32
32
|
experimentalDecorators: true,
|
33
33
|
emitDecoratorMetadata: true,
|
34
|
-
...
|
35
|
-
}
|
34
|
+
...tsConfigOptions,
|
35
|
+
}),
|
36
36
|
];
|
37
37
|
exports.unregisterPluginTSTranspiler = () => {
|
38
38
|
cleanupFns.forEach((fn) => fn?.());
|
@@ -437,18 +437,19 @@ function tryAndRetry(fn) {
|
|
437
437
|
let attempts = 0;
|
438
438
|
// Generate a random number between 2 and 4 to raise to the power of attempts
|
439
439
|
const baseExponent = Math.random() * 2 + 2;
|
440
|
+
const baseTimeout = 15;
|
440
441
|
const _try = async () => {
|
441
442
|
try {
|
442
443
|
attempts++;
|
443
444
|
return await fn();
|
444
445
|
}
|
445
446
|
catch (e) {
|
446
|
-
// Max time is
|
447
|
+
// Max time is 15 * (4 + 4² + 4³ + 4⁴ + 4⁵) = 20460ms
|
447
448
|
if (attempts === 6) {
|
448
449
|
// After enough attempts, throw the error
|
449
450
|
throw e;
|
450
451
|
}
|
451
|
-
await new Promise((res) => setTimeout(res, baseExponent ** attempts));
|
452
|
+
await new Promise((res) => setTimeout(res, baseTimeout * baseExponent ** attempts));
|
452
453
|
return await _try();
|
453
454
|
}
|
454
455
|
};
|
@@ -72,7 +72,7 @@ export declare function readNxMigrateConfig(json: Partial<PackageJson>): NxMigra
|
|
72
72
|
packageGroup?: ArrayPackageGroup;
|
73
73
|
};
|
74
74
|
export declare function buildTargetFromScript(script: string, scripts: Record<string, string>, packageManagerCommand: PackageManagerCommands): TargetConfiguration;
|
75
|
-
export declare function getMetadataFromPackageJson(packageJson: PackageJson): ProjectMetadata;
|
75
|
+
export declare function getMetadataFromPackageJson(packageJson: PackageJson, isInPackageManagerWorkspaces: boolean): ProjectMetadata;
|
76
76
|
export declare function getTagsFromPackageJson(packageJson: PackageJson): string[];
|
77
77
|
export declare function readTargetsFromPackageJson(packageJson: PackageJson, nxJson: NxJsonConfiguration): Record<string, TargetConfiguration<any>>;
|
78
78
|
/**
|
@@ -57,8 +57,8 @@ function buildTargetFromScript(script, scripts = {}, packageManagerCommand) {
|
|
57
57
|
};
|
58
58
|
}
|
59
59
|
let packageManagerCommand;
|
60
|
-
function getMetadataFromPackageJson(packageJson) {
|
61
|
-
const { scripts, nx, description, name, exports } = packageJson;
|
60
|
+
function getMetadataFromPackageJson(packageJson, isInPackageManagerWorkspaces) {
|
61
|
+
const { scripts, nx, description, name, exports, main } = packageJson;
|
62
62
|
const includedScripts = nx?.includedScripts || Object.keys(scripts ?? {});
|
63
63
|
return {
|
64
64
|
targetGroups: {
|
@@ -68,6 +68,8 @@ function getMetadataFromPackageJson(packageJson) {
|
|
68
68
|
js: {
|
69
69
|
packageName: name,
|
70
70
|
packageExports: exports,
|
71
|
+
packageMain: main,
|
72
|
+
isInPackageManagerWorkspaces,
|
71
73
|
},
|
72
74
|
};
|
73
75
|
}
|