nx 19.4.1 → 19.5.0-beta.0
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 +30 -26
- package/src/command-line/graph/graph.js +7 -2
- package/src/command-line/watch/watch.js +6 -0
- package/src/core/graph/main.js +1 -1
- package/src/daemon/client/client.d.ts +1 -0
- package/src/daemon/client/client.js +14 -2
- package/src/devkit-exports.d.ts +1 -0
- package/src/devkit-exports.js +3 -1
- package/src/native/browser.js +1 -0
- package/src/native/index.d.ts +178 -138
- package/src/native/index.js +16 -0
- package/src/native/native-bindings.js +352 -238
- package/src/native/nx.wasi-browser.js +108 -0
- package/src/native/nx.wasi.cjs +139 -0
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/native/wasi-worker-browser.mjs +32 -0
- package/src/native/wasi-worker.mjs +63 -0
- package/src/project-graph/plugins/internal-api.js +0 -1
- package/src/project-graph/utils/project-configuration-utils.d.ts +8 -6
- package/src/project-graph/utils/project-configuration-utils.js +109 -44
- package/src/project-graph/utils/retrieve-workspace-files.d.ts +3 -3
- package/src/tasks-runner/pseudo-terminal.js +3 -0
- package/src/utils/nx-plugin.deprecated.js +0 -2
- package/src/plugins/target-defaults/symbols.d.ts +0 -17
- package/src/plugins/target-defaults/symbols.js +0 -20
- package/src/plugins/target-defaults/target-defaults-plugin.d.ts +0 -121
- package/src/plugins/target-defaults/target-defaults-plugin.js +0 -176
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getDefaultPluginsSync = void 0;
|
4
4
|
const angular_json_1 = require("../adapter/angular-json");
|
5
5
|
const project_json_1 = require("../plugins/project-json/build-nodes/project-json");
|
6
|
-
const target_defaults_plugin_1 = require("../plugins/target-defaults/target-defaults-plugin");
|
7
6
|
const PackageJsonWorkspacesPlugin = require("../plugins/package-json-workspaces");
|
8
7
|
/**
|
9
8
|
* @todo(@agentender) v20: Remove this fn when we remove readWorkspaceConfig
|
@@ -14,7 +13,6 @@ function getDefaultPluginsSync(root) {
|
|
14
13
|
...((0, angular_json_1.shouldMergeAngularProjects)(root, false)
|
15
14
|
? [require('../adapter/angular-json').NxAngularJsonPlugin]
|
16
15
|
: []),
|
17
|
-
target_defaults_plugin_1.default,
|
18
16
|
PackageJsonWorkspacesPlugin,
|
19
17
|
project_json_1.default,
|
20
18
|
];
|
@@ -1,17 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* This marks that a target provides information which should modify a target already registered
|
3
|
-
* on the project via other plugins. If the target has not already been registered, and this symbol is true,
|
4
|
-
* the information provided by it will be discarded.
|
5
|
-
*
|
6
|
-
* NOTE: This cannot be a symbol, as they are not serialized in JSON the communication
|
7
|
-
* between the plugin-worker and the main process.
|
8
|
-
*/
|
9
|
-
export declare const ONLY_MODIFIES_EXISTING_TARGET = "NX_ONLY_MODIFIES_EXISTING_TARGET";
|
10
|
-
/**
|
11
|
-
* This is used to override the source file for the target defaults plugin.
|
12
|
-
* This allows the plugin to use the project files as the context, but point to nx.json as the source file.
|
13
|
-
*
|
14
|
-
* NOTE: This cannot be a symbol, as they are not serialized in JSON the communication
|
15
|
-
* between the plugin-worker and the main process.
|
16
|
-
*/
|
17
|
-
export declare const OVERRIDE_SOURCE_FILE = "NX_OVERRIDE_SOURCE_FILE";
|
@@ -1,20 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.OVERRIDE_SOURCE_FILE = exports.ONLY_MODIFIES_EXISTING_TARGET = void 0;
|
4
|
-
/**
|
5
|
-
* This marks that a target provides information which should modify a target already registered
|
6
|
-
* on the project via other plugins. If the target has not already been registered, and this symbol is true,
|
7
|
-
* the information provided by it will be discarded.
|
8
|
-
*
|
9
|
-
* NOTE: This cannot be a symbol, as they are not serialized in JSON the communication
|
10
|
-
* between the plugin-worker and the main process.
|
11
|
-
*/
|
12
|
-
exports.ONLY_MODIFIES_EXISTING_TARGET = 'NX_ONLY_MODIFIES_EXISTING_TARGET';
|
13
|
-
/**
|
14
|
-
* This is used to override the source file for the target defaults plugin.
|
15
|
-
* This allows the plugin to use the project files as the context, but point to nx.json as the source file.
|
16
|
-
*
|
17
|
-
* NOTE: This cannot be a symbol, as they are not serialized in JSON the communication
|
18
|
-
* between the plugin-worker and the main process.
|
19
|
-
*/
|
20
|
-
exports.OVERRIDE_SOURCE_FILE = 'NX_OVERRIDE_SOURCE_FILE';
|
@@ -1,121 +0,0 @@
|
|
1
|
-
import { TargetConfiguration } from '../../config/workspace-json-project-json';
|
2
|
-
import { NxPluginV2 } from '../../project-graph/plugins';
|
3
|
-
export declare const TargetDefaultsPlugin: NxPluginV2;
|
4
|
-
export default TargetDefaultsPlugin;
|
5
|
-
/**
|
6
|
-
* This fn gets target info that would make a target uniquely compatible
|
7
|
-
* with what is described by project.json or package.json. As the merge process
|
8
|
-
* for config happens, without this, the target defaults may be compatible
|
9
|
-
* with a config from a plugin and then that combined target be incompatible
|
10
|
-
* with the project json configuration resulting in the target default values
|
11
|
-
* being scrapped. By adding enough information from the project.json / package.json,
|
12
|
-
* we can make sure that the target after merging is compatible with the defined target.
|
13
|
-
*/
|
14
|
-
export declare function getTargetInfo(target: string, projectJsonTargets: Record<string, TargetConfiguration>, packageJsonTargets: Record<string, TargetConfiguration>): {
|
15
|
-
command: string;
|
16
|
-
metadata: {
|
17
|
-
[x: string]: any;
|
18
|
-
description?: string;
|
19
|
-
technologies?: string[];
|
20
|
-
nonAtomizedTarget?: string;
|
21
|
-
help?: {
|
22
|
-
command: string;
|
23
|
-
example: {
|
24
|
-
options?: Record<string, unknown>;
|
25
|
-
args?: string[];
|
26
|
-
};
|
27
|
-
};
|
28
|
-
};
|
29
|
-
executor?: undefined;
|
30
|
-
options?: undefined;
|
31
|
-
} | {
|
32
|
-
executor: string;
|
33
|
-
options: {
|
34
|
-
command: any;
|
35
|
-
commands?: undefined;
|
36
|
-
script?: undefined;
|
37
|
-
};
|
38
|
-
metadata: {
|
39
|
-
[x: string]: any;
|
40
|
-
description?: string;
|
41
|
-
technologies?: string[];
|
42
|
-
nonAtomizedTarget?: string;
|
43
|
-
help?: {
|
44
|
-
command: string;
|
45
|
-
example: {
|
46
|
-
options?: Record<string, unknown>;
|
47
|
-
args?: string[];
|
48
|
-
};
|
49
|
-
};
|
50
|
-
};
|
51
|
-
command?: undefined;
|
52
|
-
} | {
|
53
|
-
executor: string;
|
54
|
-
options: {
|
55
|
-
commands: any;
|
56
|
-
command?: undefined;
|
57
|
-
script?: undefined;
|
58
|
-
};
|
59
|
-
metadata: {
|
60
|
-
[x: string]: any;
|
61
|
-
description?: string;
|
62
|
-
technologies?: string[];
|
63
|
-
nonAtomizedTarget?: string;
|
64
|
-
help?: {
|
65
|
-
command: string;
|
66
|
-
example: {
|
67
|
-
options?: Record<string, unknown>;
|
68
|
-
args?: string[];
|
69
|
-
};
|
70
|
-
};
|
71
|
-
};
|
72
|
-
command?: undefined;
|
73
|
-
} | {
|
74
|
-
executor: string;
|
75
|
-
metadata: {
|
76
|
-
[x: string]: any;
|
77
|
-
description?: string;
|
78
|
-
technologies?: string[];
|
79
|
-
nonAtomizedTarget?: string;
|
80
|
-
help?: {
|
81
|
-
command: string;
|
82
|
-
example: {
|
83
|
-
options?: Record<string, unknown>;
|
84
|
-
args?: string[];
|
85
|
-
};
|
86
|
-
};
|
87
|
-
};
|
88
|
-
command?: undefined;
|
89
|
-
options?: undefined;
|
90
|
-
} | {
|
91
|
-
executor: string;
|
92
|
-
options: {
|
93
|
-
script: any;
|
94
|
-
command?: undefined;
|
95
|
-
commands?: undefined;
|
96
|
-
};
|
97
|
-
metadata: {
|
98
|
-
[x: string]: any;
|
99
|
-
description?: string;
|
100
|
-
technologies?: string[];
|
101
|
-
nonAtomizedTarget?: string;
|
102
|
-
help?: {
|
103
|
-
command: string;
|
104
|
-
example: {
|
105
|
-
options?: Record<string, unknown>;
|
106
|
-
args?: string[];
|
107
|
-
};
|
108
|
-
};
|
109
|
-
};
|
110
|
-
command?: undefined;
|
111
|
-
} | {
|
112
|
-
executor: string;
|
113
|
-
command?: undefined;
|
114
|
-
metadata?: undefined;
|
115
|
-
options?: undefined;
|
116
|
-
} | {
|
117
|
-
command?: undefined;
|
118
|
-
metadata?: undefined;
|
119
|
-
executor?: undefined;
|
120
|
-
options?: undefined;
|
121
|
-
};
|
@@ -1,176 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.getTargetInfo = exports.TargetDefaultsPlugin = void 0;
|
4
|
-
const minimatch_1 = require("minimatch");
|
5
|
-
const node_fs_1 = require("node:fs");
|
6
|
-
const node_path_1 = require("node:path");
|
7
|
-
const fileutils_1 = require("../../utils/fileutils");
|
8
|
-
const globs_1 = require("../../utils/globs");
|
9
|
-
const package_json_1 = require("../../utils/package-json");
|
10
|
-
const package_json_workspaces_1 = require("../package-json-workspaces");
|
11
|
-
const symbols_1 = require("./symbols");
|
12
|
-
exports.TargetDefaultsPlugin = {
|
13
|
-
name: 'nx/core/target-defaults',
|
14
|
-
createNodes: [
|
15
|
-
'{package.json,**/package.json,project.json,**/project.json}',
|
16
|
-
(configFile, _, ctx) => {
|
17
|
-
const fileName = (0, node_path_1.basename)(configFile);
|
18
|
-
const root = (0, node_path_1.dirname)(configFile);
|
19
|
-
const packageManagerWorkspacesGlob = (0, globs_1.combineGlobPatterns)((0, package_json_workspaces_1.getGlobPatternsFromPackageManagerWorkspaces)(ctx.workspaceRoot));
|
20
|
-
// Only process once if package.json + project.json both exist
|
21
|
-
if (fileName === 'package.json' &&
|
22
|
-
(0, node_fs_1.existsSync)((0, node_path_1.join)(ctx.workspaceRoot, root, 'project.json'))) {
|
23
|
-
return {};
|
24
|
-
}
|
25
|
-
else if (fileName === 'package.json' &&
|
26
|
-
!(0, minimatch_1.minimatch)(configFile, packageManagerWorkspacesGlob)) {
|
27
|
-
return {};
|
28
|
-
}
|
29
|
-
// If no target defaults, this does nothing
|
30
|
-
const targetDefaults = ctx.nxJsonConfiguration?.targetDefaults;
|
31
|
-
if (!targetDefaults) {
|
32
|
-
return {};
|
33
|
-
}
|
34
|
-
const projectJson = readJsonOrNull((0, node_path_1.join)(ctx.workspaceRoot, root, 'project.json'));
|
35
|
-
const packageJson = readJsonOrNull((0, node_path_1.join)(ctx.workspaceRoot, root, 'package.json'));
|
36
|
-
const packageJsonTargets = (0, package_json_1.readTargetsFromPackageJson)(packageJson);
|
37
|
-
const projectDefinedTargets = new Set([
|
38
|
-
...Object.keys(projectJson?.targets ?? {}),
|
39
|
-
...(packageJson ? Object.keys(packageJsonTargets) : []),
|
40
|
-
]);
|
41
|
-
const executorToTargetMap = getExecutorToTargetMap(packageJsonTargets, projectJson?.targets);
|
42
|
-
const modifiedTargets = {};
|
43
|
-
for (const defaultSpecifier in targetDefaults) {
|
44
|
-
const targetNames = executorToTargetMap.get(defaultSpecifier) ?? new Set();
|
45
|
-
targetNames.add(defaultSpecifier);
|
46
|
-
for (const targetName of targetNames) {
|
47
|
-
// Prevents `build` from overwriting `@nx/js:tsc` if both are present
|
48
|
-
// and build is specified later in the ordering.
|
49
|
-
if (!modifiedTargets[targetName] || targetName !== defaultSpecifier) {
|
50
|
-
const defaults = JSON.parse(JSON.stringify(targetDefaults[defaultSpecifier]));
|
51
|
-
modifiedTargets[targetName] = {
|
52
|
-
...getTargetInfo(targetName, projectJson?.targets, packageJsonTargets),
|
53
|
-
...defaults,
|
54
|
-
};
|
55
|
-
}
|
56
|
-
// TODO: Remove this after we figure out a way to define new targets
|
57
|
-
// in target defaults
|
58
|
-
if (!projectDefinedTargets.has(targetName)) {
|
59
|
-
modifiedTargets[targetName][symbols_1.ONLY_MODIFIES_EXISTING_TARGET] = true;
|
60
|
-
}
|
61
|
-
}
|
62
|
-
}
|
63
|
-
return {
|
64
|
-
projects: {
|
65
|
-
[root]: {
|
66
|
-
targets: modifiedTargets,
|
67
|
-
},
|
68
|
-
},
|
69
|
-
[symbols_1.OVERRIDE_SOURCE_FILE]: 'nx.json',
|
70
|
-
};
|
71
|
-
},
|
72
|
-
],
|
73
|
-
};
|
74
|
-
exports.default = exports.TargetDefaultsPlugin;
|
75
|
-
function getExecutorToTargetMap(packageJsonTargets, projectJsonTargets) {
|
76
|
-
const executorToTargetMap = new Map();
|
77
|
-
const targets = Object.keys({
|
78
|
-
...projectJsonTargets,
|
79
|
-
...packageJsonTargets,
|
80
|
-
});
|
81
|
-
for (const target of targets) {
|
82
|
-
const executor = getTargetExecutor(target, projectJsonTargets, packageJsonTargets);
|
83
|
-
const targetsForExecutor = executorToTargetMap.get(executor) ?? new Set();
|
84
|
-
targetsForExecutor.add(target);
|
85
|
-
executorToTargetMap.set(executor, targetsForExecutor);
|
86
|
-
}
|
87
|
-
return executorToTargetMap;
|
88
|
-
}
|
89
|
-
function readJsonOrNull(path) {
|
90
|
-
if ((0, node_fs_1.existsSync)(path)) {
|
91
|
-
return (0, fileutils_1.readJsonFile)(path);
|
92
|
-
}
|
93
|
-
else {
|
94
|
-
return null;
|
95
|
-
}
|
96
|
-
}
|
97
|
-
/**
|
98
|
-
* This fn gets target info that would make a target uniquely compatible
|
99
|
-
* with what is described by project.json or package.json. As the merge process
|
100
|
-
* for config happens, without this, the target defaults may be compatible
|
101
|
-
* with a config from a plugin and then that combined target be incompatible
|
102
|
-
* with the project json configuration resulting in the target default values
|
103
|
-
* being scrapped. By adding enough information from the project.json / package.json,
|
104
|
-
* we can make sure that the target after merging is compatible with the defined target.
|
105
|
-
*/
|
106
|
-
function getTargetInfo(target, projectJsonTargets, packageJsonTargets) {
|
107
|
-
const projectJsonTarget = projectJsonTargets?.[target];
|
108
|
-
const packageJsonTarget = packageJsonTargets?.[target];
|
109
|
-
const executor = getTargetExecutor(target, projectJsonTargets, packageJsonTargets);
|
110
|
-
const targetOptions = {
|
111
|
-
...packageJsonTarget?.options,
|
112
|
-
...projectJsonTarget?.options,
|
113
|
-
};
|
114
|
-
const metadata = {
|
115
|
-
...packageJsonTarget?.metadata,
|
116
|
-
...projectJsonTarget?.metadata,
|
117
|
-
};
|
118
|
-
if (projectJsonTarget?.command) {
|
119
|
-
return {
|
120
|
-
command: projectJsonTarget?.command,
|
121
|
-
metadata,
|
122
|
-
};
|
123
|
-
}
|
124
|
-
if (executor === 'nx:run-commands') {
|
125
|
-
if (targetOptions?.command) {
|
126
|
-
return {
|
127
|
-
executor: 'nx:run-commands',
|
128
|
-
options: {
|
129
|
-
command: targetOptions?.command,
|
130
|
-
},
|
131
|
-
metadata,
|
132
|
-
};
|
133
|
-
}
|
134
|
-
else if (targetOptions?.commands) {
|
135
|
-
return {
|
136
|
-
executor: 'nx:run-commands',
|
137
|
-
options: {
|
138
|
-
commands: targetOptions.commands,
|
139
|
-
},
|
140
|
-
metadata,
|
141
|
-
};
|
142
|
-
}
|
143
|
-
return {
|
144
|
-
executor: 'nx:run-commands',
|
145
|
-
metadata,
|
146
|
-
};
|
147
|
-
}
|
148
|
-
if (executor === 'nx:run-script') {
|
149
|
-
return {
|
150
|
-
executor: 'nx:run-script',
|
151
|
-
options: {
|
152
|
-
script: targetOptions?.script ?? target,
|
153
|
-
},
|
154
|
-
metadata,
|
155
|
-
};
|
156
|
-
}
|
157
|
-
if (executor) {
|
158
|
-
return { executor };
|
159
|
-
}
|
160
|
-
return {};
|
161
|
-
}
|
162
|
-
exports.getTargetInfo = getTargetInfo;
|
163
|
-
function getTargetExecutor(target, projectJsonTargets, packageJsonTargets) {
|
164
|
-
const projectJsonTargetConfiguration = projectJsonTargets?.[target];
|
165
|
-
const packageJsonTargetConfiguration = packageJsonTargets?.[target];
|
166
|
-
if (!projectJsonTargetConfiguration && packageJsonTargetConfiguration) {
|
167
|
-
return packageJsonTargetConfiguration?.executor;
|
168
|
-
}
|
169
|
-
if (projectJsonTargetConfiguration?.executor) {
|
170
|
-
return projectJsonTargetConfiguration.executor;
|
171
|
-
}
|
172
|
-
if (projectJsonTargetConfiguration?.command) {
|
173
|
-
return 'nx:run-commands';
|
174
|
-
}
|
175
|
-
return null;
|
176
|
-
}
|