nx 20.2.2 → 20.3.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 +13 -11
- package/src/adapter/ngcli-adapter.js +7 -7
- package/src/command-line/add/add.js +21 -45
- package/src/command-line/generate/generator-utils.js +2 -2
- package/src/command-line/import/import.js +60 -34
- package/src/command-line/init/configure-plugins.d.ts +35 -0
- package/src/command-line/init/configure-plugins.js +189 -0
- package/src/command-line/init/init-v2.d.ts +1 -2
- package/src/command-line/init/init-v2.js +4 -18
- package/src/command-line/run/executor-utils.js +4 -4
- package/src/config/schema-utils.d.ts +4 -3
- package/src/config/schema-utils.js +71 -4
- package/src/config/workspace-json-project-json.d.ts +5 -0
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/styles.js +1 -1
- package/src/daemon/client/client.js +9 -0
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.d.ts +2 -2
- package/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.js +6 -20
- package/src/plugins/js/project-graph/build-dependencies/target-project-locator.d.ts +3 -1
- package/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +12 -1
- package/src/plugins/js/utils/packages.d.ts +3 -0
- package/src/plugins/js/utils/packages.js +25 -0
- package/src/plugins/package-json/create-nodes.js +6 -0
- package/src/project-graph/build-project-graph.js +57 -1
- package/src/project-graph/plugins/internal-api.d.ts +4 -3
- package/src/project-graph/plugins/internal-api.js +2 -2
- package/src/project-graph/plugins/isolation/messaging.d.ts +2 -2
- package/src/project-graph/plugins/loader.js +13 -6
- package/src/project-graph/utils/project-configuration-utils.js +31 -1
- package/src/tasks-runner/forked-process-task-runner.js +30 -8
- package/src/utils/delayed-spinner.d.ts +40 -0
- package/src/utils/delayed-spinner.js +58 -0
- package/src/utils/package-json.d.ts +1 -0
- package/src/utils/package-json.js +5 -1
- package/src/command-line/import/utils/needs-install.d.ts +0 -3
- package/src/command-line/import/utils/needs-install.js +0 -31
@@ -1,15 +1,16 @@
|
|
1
|
+
import type { ProjectConfiguration } from './workspace-json-project-json';
|
1
2
|
/**
|
2
3
|
* This function is used to get the implementation factory of an executor or generator.
|
3
4
|
* @param implementation path to the implementation
|
4
5
|
* @param directory path to the directory
|
5
6
|
* @returns a function that returns the implementation
|
6
7
|
*/
|
7
|
-
export declare function getImplementationFactory<T>(implementation: string, directory: string): () => T;
|
8
|
+
export declare function getImplementationFactory<T>(implementation: string, directory: string, packageName: string, projects: Record<string, ProjectConfiguration>): () => T;
|
8
9
|
/**
|
9
10
|
* This function is used to resolve the implementation of an executor or generator.
|
10
11
|
* @param implementationModulePath
|
11
12
|
* @param directory
|
12
13
|
* @returns path to the implementation
|
13
14
|
*/
|
14
|
-
export declare function resolveImplementation(implementationModulePath: string, directory: string): string;
|
15
|
-
export declare function resolveSchema(schemaPath: string, directory: string): string;
|
15
|
+
export declare function resolveImplementation(implementationModulePath: string, directory: string, packageName: string, projects: Record<string, ProjectConfiguration>): string;
|
16
|
+
export declare function resolveSchema(schemaPath: string, directory: string, packageName: string, projects: Record<string, ProjectConfiguration>): string;
|
@@ -5,17 +5,20 @@ exports.resolveImplementation = resolveImplementation;
|
|
5
5
|
exports.resolveSchema = resolveSchema;
|
6
6
|
const fs_1 = require("fs");
|
7
7
|
const path_1 = require("path");
|
8
|
+
const resolve_exports_1 = require("resolve.exports");
|
9
|
+
const packages_1 = require("../plugins/js/utils/packages");
|
8
10
|
const plugins_1 = require("../project-graph/plugins");
|
11
|
+
const path_2 = require("../utils/path");
|
9
12
|
/**
|
10
13
|
* This function is used to get the implementation factory of an executor or generator.
|
11
14
|
* @param implementation path to the implementation
|
12
15
|
* @param directory path to the directory
|
13
16
|
* @returns a function that returns the implementation
|
14
17
|
*/
|
15
|
-
function getImplementationFactory(implementation, directory) {
|
18
|
+
function getImplementationFactory(implementation, directory, packageName, projects) {
|
16
19
|
const [implementationModulePath, implementationExportName] = implementation.split('#');
|
17
20
|
return () => {
|
18
|
-
const modulePath = resolveImplementation(implementationModulePath, directory);
|
21
|
+
const modulePath = resolveImplementation(implementationModulePath, directory, packageName, projects);
|
19
22
|
if ((0, path_1.extname)(modulePath) === '.ts') {
|
20
23
|
(0, plugins_1.registerPluginTSTranspiler)();
|
21
24
|
}
|
@@ -31,8 +34,19 @@ function getImplementationFactory(implementation, directory) {
|
|
31
34
|
* @param directory
|
32
35
|
* @returns path to the implementation
|
33
36
|
*/
|
34
|
-
function resolveImplementation(implementationModulePath, directory) {
|
37
|
+
function resolveImplementation(implementationModulePath, directory, packageName, projects) {
|
35
38
|
const validImplementations = ['', '.js', '.ts'].map((x) => implementationModulePath + x);
|
39
|
+
if (!directory.includes('node_modules')) {
|
40
|
+
// It might be a local plugin where the implementation path points to the
|
41
|
+
// outputs which might not exist or can be stale. We prioritize finding
|
42
|
+
// the implementation from the source over the outputs.
|
43
|
+
for (const maybeImplementation of validImplementations) {
|
44
|
+
const maybeImplementationFromSource = tryResolveFromSource(maybeImplementation, directory, packageName, projects);
|
45
|
+
if (maybeImplementationFromSource) {
|
46
|
+
return maybeImplementationFromSource;
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
36
50
|
for (const maybeImplementation of validImplementations) {
|
37
51
|
const maybeImplementationPath = (0, path_1.join)(directory, maybeImplementation);
|
38
52
|
if ((0, fs_1.existsSync)(maybeImplementationPath)) {
|
@@ -47,7 +61,16 @@ function resolveImplementation(implementationModulePath, directory) {
|
|
47
61
|
}
|
48
62
|
throw new Error(`Could not resolve "${implementationModulePath}" from "${directory}".`);
|
49
63
|
}
|
50
|
-
function resolveSchema(schemaPath, directory) {
|
64
|
+
function resolveSchema(schemaPath, directory, packageName, projects) {
|
65
|
+
if (!directory.includes('node_modules')) {
|
66
|
+
// It might be a local plugin where the schema path points to the outputs
|
67
|
+
// which might not exist or can be stale. We prioritize finding the schema
|
68
|
+
// from the source over the outputs.
|
69
|
+
const schemaPathFromSource = tryResolveFromSource(schemaPath, directory, packageName, projects);
|
70
|
+
if (schemaPathFromSource) {
|
71
|
+
return schemaPathFromSource;
|
72
|
+
}
|
73
|
+
}
|
51
74
|
const maybeSchemaPath = (0, path_1.join)(directory, schemaPath);
|
52
75
|
if ((0, fs_1.existsSync)(maybeSchemaPath)) {
|
53
76
|
return maybeSchemaPath;
|
@@ -56,3 +79,47 @@ function resolveSchema(schemaPath, directory) {
|
|
56
79
|
paths: [directory],
|
57
80
|
});
|
58
81
|
}
|
82
|
+
let packageEntryPointsToProjectMap;
|
83
|
+
function tryResolveFromSource(path, directory, packageName, projects) {
|
84
|
+
packageEntryPointsToProjectMap ??=
|
85
|
+
(0, packages_1.getPackageEntryPointsToProjectMap)(projects);
|
86
|
+
const localProject = packageEntryPointsToProjectMap[packageName];
|
87
|
+
if (!localProject) {
|
88
|
+
// it doesn't match any of the package names from the local projects
|
89
|
+
return null;
|
90
|
+
}
|
91
|
+
try {
|
92
|
+
const fromExports = (0, resolve_exports_1.resolve)({
|
93
|
+
name: localProject.metadata.js.packageName,
|
94
|
+
exports: localProject.metadata.js.packageExports,
|
95
|
+
}, path, { conditions: ['development'] });
|
96
|
+
if (fromExports && fromExports.length) {
|
97
|
+
for (const exportPath of fromExports) {
|
98
|
+
if ((0, fs_1.existsSync)((0, path_1.join)(directory, exportPath))) {
|
99
|
+
return (0, path_1.join)(directory, exportPath);
|
100
|
+
}
|
101
|
+
}
|
102
|
+
}
|
103
|
+
}
|
104
|
+
catch { }
|
105
|
+
/**
|
106
|
+
* Fall back to try to "guess" the source by checking the path in some common directories:
|
107
|
+
* - the root of the project
|
108
|
+
* - the src directory
|
109
|
+
* - the src/lib directory
|
110
|
+
*/
|
111
|
+
const segments = (0, path_2.normalizePath)(path).replace(/^\.\//, '').split('/');
|
112
|
+
for (let i = 1; i < segments.length; i++) {
|
113
|
+
const possiblePaths = [
|
114
|
+
(0, path_1.join)(directory, ...segments.slice(i)),
|
115
|
+
(0, path_1.join)(directory, 'src', ...segments.slice(i)),
|
116
|
+
(0, path_1.join)(directory, 'src', 'lib', ...segments.slice(i)),
|
117
|
+
];
|
118
|
+
for (const possiblePath of possiblePaths) {
|
119
|
+
if ((0, fs_1.existsSync)(possiblePath)) {
|
120
|
+
return possiblePath;
|
121
|
+
}
|
122
|
+
}
|
123
|
+
}
|
124
|
+
return null;
|
125
|
+
}
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import type { PackageJson } from '../utils/package-json';
|
1
2
|
import type { NxJsonConfiguration, NxReleaseVersionConfiguration } from './nx-json';
|
2
3
|
/**
|
3
4
|
* @deprecated use ProjectsConfigurations or NxJsonConfiguration
|
@@ -122,6 +123,10 @@ export interface ProjectMetadata {
|
|
122
123
|
}[];
|
123
124
|
};
|
124
125
|
};
|
126
|
+
js?: {
|
127
|
+
packageName: string;
|
128
|
+
packageExports: undefined | PackageJson['exports'];
|
129
|
+
};
|
125
130
|
}
|
126
131
|
export interface TargetMetadata {
|
127
132
|
[k: string]: any;
|