nx 21.2.0-beta.3 → 21.2.0-beta.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/package.json +11 -11
- package/src/core/graph/main.js +1 -1
- package/src/hasher/hash-plan-inspector.d.ts +25 -0
- package/src/hasher/hash-plan-inspector.js +54 -0
- package/src/native/index.d.ts +5 -2
- package/src/native/native-bindings.js +1 -1
- package/src/native/nx.wasi.cjs +40 -39
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/tasks-runner/run-command.js +1 -1
- package/src/utils/workspace-context.d.ts +1 -1
- package/src/utils/workspace-context.js +2 -2
@@ -0,0 +1,25 @@
|
|
1
|
+
import { NxJsonConfiguration } from '../config/nx-json';
|
2
|
+
import { ProjectGraph } from '../config/project-graph';
|
3
|
+
import type { Target } from '../command-line/run/run';
|
4
|
+
import { TargetDependencies } from '../config/nx-json';
|
5
|
+
import { TargetDependencyConfig } from '../config/workspace-json-project-json';
|
6
|
+
export declare class HashPlanInspector {
|
7
|
+
private projectGraph;
|
8
|
+
private readonly workspaceRootPath;
|
9
|
+
private readonly projectGraphRef;
|
10
|
+
private planner;
|
11
|
+
private inspector;
|
12
|
+
private readonly nxJson;
|
13
|
+
constructor(projectGraph: ProjectGraph, workspaceRootPath?: string, nxJson?: NxJsonConfiguration);
|
14
|
+
init(): Promise<void>;
|
15
|
+
/**
|
16
|
+
* This is a lower level method which will inspect the hash plan for a set of tasks.
|
17
|
+
*/
|
18
|
+
inspectHashPlan(projectNames: string[], targets: string[], configuration?: string, overrides?: Object, extraTargetDependencies?: TargetDependencies, excludeTaskDependencies?: boolean): Record<string, string[]>;
|
19
|
+
/**
|
20
|
+
* This inspects tasks involved in the execution of a task, including its dependencies by default.
|
21
|
+
*/
|
22
|
+
inspectTask({ project, target, configuration }: Target, parsedArgs?: {
|
23
|
+
[k: string]: any;
|
24
|
+
}, extraTargetDependencies?: Record<string, (TargetDependencyConfig | string)[]>, excludeTaskDependencies?: boolean): Record<string, string[]>;
|
25
|
+
}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.HashPlanInspector = void 0;
|
4
|
+
const native_1 = require("../native");
|
5
|
+
const nx_json_1 = require("../config/nx-json");
|
6
|
+
const transform_objects_1 = require("../native/transform-objects");
|
7
|
+
const workspace_root_1 = require("../utils/workspace-root");
|
8
|
+
const find_project_for_path_1 = require("../project-graph/utils/find-project-for-path");
|
9
|
+
const create_task_graph_1 = require("../tasks-runner/create-task-graph");
|
10
|
+
const command_line_utils_1 = require("../utils/command-line-utils");
|
11
|
+
const workspace_context_1 = require("../utils/workspace-context");
|
12
|
+
class HashPlanInspector {
|
13
|
+
constructor(projectGraph, workspaceRootPath = workspace_root_1.workspaceRoot, nxJson) {
|
14
|
+
this.projectGraph = projectGraph;
|
15
|
+
this.workspaceRootPath = workspaceRootPath;
|
16
|
+
this.nxJson = nxJson ?? (0, nx_json_1.readNxJson)(this.workspaceRootPath);
|
17
|
+
this.projectGraphRef = (0, native_1.transferProjectGraph)((0, transform_objects_1.transformProjectGraphForRust)(this.projectGraph));
|
18
|
+
this.planner = new native_1.HashPlanner(this.nxJson, this.projectGraphRef);
|
19
|
+
}
|
20
|
+
async init() {
|
21
|
+
const projectRootMap = (0, find_project_for_path_1.createProjectRootMappings)(this.projectGraph.nodes);
|
22
|
+
const map = Object.fromEntries(projectRootMap.entries());
|
23
|
+
const { externalReferences } = await (0, workspace_context_1.getNxWorkspaceFilesFromContext)(this.workspaceRootPath, map, false);
|
24
|
+
this.inspector = new native_1.HashPlanInspector(externalReferences.allWorkspaceFiles, this.projectGraphRef, externalReferences.projectFiles);
|
25
|
+
}
|
26
|
+
/**
|
27
|
+
* This is a lower level method which will inspect the hash plan for a set of tasks.
|
28
|
+
*/
|
29
|
+
inspectHashPlan(projectNames, targets, configuration, overrides = {}, extraTargetDependencies = {}, excludeTaskDependencies = false) {
|
30
|
+
const taskGraph = (0, create_task_graph_1.createTaskGraph)(this.projectGraph, extraTargetDependencies, projectNames, targets, configuration, overrides, excludeTaskDependencies);
|
31
|
+
// Generate task IDs for ALL tasks in the task graph (including dependencies)
|
32
|
+
const taskIds = Object.keys(taskGraph.tasks);
|
33
|
+
const plansReference = this.planner.getPlansReference(taskIds, taskGraph);
|
34
|
+
return this.inspector.inspect(plansReference);
|
35
|
+
}
|
36
|
+
/**
|
37
|
+
* This inspects tasks involved in the execution of a task, including its dependencies by default.
|
38
|
+
*/
|
39
|
+
inspectTask({ project, target, configuration }, parsedArgs = {}, extraTargetDependencies = {}, excludeTaskDependencies = false) {
|
40
|
+
// Mirror the exact flow from run-one.ts
|
41
|
+
const { nxArgs, overrides } = (0, command_line_utils_1.splitArgsIntoNxArgsAndOverrides)({
|
42
|
+
...parsedArgs,
|
43
|
+
configuration: configuration,
|
44
|
+
targets: [target],
|
45
|
+
}, 'run-one', { printWarnings: false }, this.nxJson);
|
46
|
+
// Create task graph exactly like run-one.ts does via createTaskGraphAndRunValidations
|
47
|
+
const taskGraph = (0, create_task_graph_1.createTaskGraph)(this.projectGraph, extraTargetDependencies, [project], nxArgs.targets, nxArgs.configuration, overrides, excludeTaskDependencies);
|
48
|
+
// Generate task IDs for ALL tasks in the task graph (including dependencies)
|
49
|
+
const taskIds = Object.keys(taskGraph.tasks);
|
50
|
+
const plansReference = this.planner.getPlansReference(taskIds, taskGraph);
|
51
|
+
return this.inspector.inspect(plansReference);
|
52
|
+
}
|
53
|
+
}
|
54
|
+
exports.HashPlanInspector = HashPlanInspector;
|
package/src/native/index.d.ts
CHANGED
@@ -41,6 +41,11 @@ export declare class FileLock {
|
|
41
41
|
lock(): void
|
42
42
|
}
|
43
43
|
|
44
|
+
export declare class HashPlanInspector {
|
45
|
+
constructor(allWorkspaceFiles: ExternalObject<Array<FileData>>, projectGraph: ExternalObject<ProjectGraph>, projectFileMap: ExternalObject<Record<string, Array<FileData>>>)
|
46
|
+
inspect(hashPlans: ExternalObject<Record<string, Array<HashInstruction>>>): Record<string, string[]>
|
47
|
+
}
|
48
|
+
|
44
49
|
export declare class HashPlanner {
|
45
50
|
constructor(nxJson: NxJson, projectGraph: ExternalObject<ProjectGraph>)
|
46
51
|
getPlans(taskIds: Array<string>, taskGraph: TaskGraph): Record<string, string[]>
|
@@ -249,8 +254,6 @@ export const IS_WASM: boolean
|
|
249
254
|
|
250
255
|
export declare export declare function logDebug(message: string): void
|
251
256
|
|
252
|
-
export declare export declare function logError(message: string): void
|
253
|
-
|
254
257
|
/** Stripped version of the NxJson interface for use in rust */
|
255
258
|
export interface NxJson {
|
256
259
|
namedInputs?: Record<string, Array<JsInputs>>
|
@@ -364,6 +364,7 @@ if (!nativeBinding) {
|
|
364
364
|
module.exports.AppLifeCycle = nativeBinding.AppLifeCycle
|
365
365
|
module.exports.ChildProcess = nativeBinding.ChildProcess
|
366
366
|
module.exports.FileLock = nativeBinding.FileLock
|
367
|
+
module.exports.HashPlanInspector = nativeBinding.HashPlanInspector
|
367
368
|
module.exports.HashPlanner = nativeBinding.HashPlanner
|
368
369
|
module.exports.HttpRemoteCache = nativeBinding.HttpRemoteCache
|
369
370
|
module.exports.ImportResult = nativeBinding.ImportResult
|
@@ -392,7 +393,6 @@ module.exports.hashFile = nativeBinding.hashFile
|
|
392
393
|
module.exports.installNxConsole = nativeBinding.installNxConsole
|
393
394
|
module.exports.IS_WASM = nativeBinding.IS_WASM
|
394
395
|
module.exports.logDebug = nativeBinding.logDebug
|
395
|
-
module.exports.logError = nativeBinding.logError
|
396
396
|
module.exports.parseTaskStatus = nativeBinding.parseTaskStatus
|
397
397
|
module.exports.remove = nativeBinding.remove
|
398
398
|
module.exports.restoreTerminal = nativeBinding.restoreTerminal
|
package/src/native/nx.wasi.cjs
CHANGED
@@ -95,46 +95,48 @@ function __napi_rs_initialize_modules(__napiInstance) {
|
|
95
95
|
__napiInstance.exports['__napi_register__NxConsolePreferences_struct_10']?.()
|
96
96
|
__napiInstance.exports['__napi_register__NxConsolePreferences_impl_14']?.()
|
97
97
|
__napiInstance.exports['__napi_register__log_debug_15']?.()
|
98
|
-
__napiInstance.exports['
|
99
|
-
__napiInstance.exports['
|
100
|
-
__napiInstance.exports['
|
101
|
-
__napiInstance.exports['
|
102
|
-
__napiInstance.exports['
|
103
|
-
__napiInstance.exports['
|
104
|
-
__napiInstance.exports['
|
105
|
-
__napiInstance.exports['
|
106
|
-
__napiInstance.exports['
|
107
|
-
__napiInstance.exports['
|
108
|
-
__napiInstance.exports['
|
109
|
-
__napiInstance.exports['
|
110
|
-
__napiInstance.exports['
|
111
|
-
__napiInstance.exports['
|
112
|
-
__napiInstance.exports['
|
113
|
-
__napiInstance.exports['
|
114
|
-
__napiInstance.exports['
|
115
|
-
__napiInstance.exports['
|
116
|
-
__napiInstance.exports['
|
117
|
-
__napiInstance.exports['
|
118
|
-
__napiInstance.exports['
|
119
|
-
__napiInstance.exports['
|
120
|
-
__napiInstance.exports['
|
121
|
-
__napiInstance.exports['
|
122
|
-
__napiInstance.exports['
|
123
|
-
__napiInstance.exports['
|
124
|
-
__napiInstance.exports['
|
125
|
-
__napiInstance.exports['
|
126
|
-
__napiInstance.exports['
|
127
|
-
__napiInstance.exports['
|
128
|
-
__napiInstance.exports['
|
129
|
-
__napiInstance.exports['
|
130
|
-
__napiInstance.exports['
|
131
|
-
__napiInstance.exports['
|
132
|
-
__napiInstance.exports['
|
133
|
-
__napiInstance.exports['
|
134
|
-
__napiInstance.exports['
|
135
|
-
__napiInstance.exports['
|
98
|
+
__napiInstance.exports['__napi_register__IS_WASM_16']?.()
|
99
|
+
__napiInstance.exports['__napi_register__get_binary_target_17']?.()
|
100
|
+
__napiInstance.exports['__napi_register__ImportResult_struct_18']?.()
|
101
|
+
__napiInstance.exports['__napi_register__find_imports_19']?.()
|
102
|
+
__napiInstance.exports['__napi_register__transfer_project_graph_20']?.()
|
103
|
+
__napiInstance.exports['__napi_register__ExternalNode_struct_21']?.()
|
104
|
+
__napiInstance.exports['__napi_register__Target_struct_22']?.()
|
105
|
+
__napiInstance.exports['__napi_register__Project_struct_23']?.()
|
106
|
+
__napiInstance.exports['__napi_register__ProjectGraph_struct_24']?.()
|
107
|
+
__napiInstance.exports['__napi_register__HashPlanInspector_struct_25']?.()
|
108
|
+
__napiInstance.exports['__napi_register__HashPlanInspector_impl_28']?.()
|
109
|
+
__napiInstance.exports['__napi_register__HashPlanner_struct_29']?.()
|
110
|
+
__napiInstance.exports['__napi_register__HashPlanner_impl_33']?.()
|
111
|
+
__napiInstance.exports['__napi_register__HashDetails_struct_34']?.()
|
112
|
+
__napiInstance.exports['__napi_register__HasherOptions_struct_35']?.()
|
113
|
+
__napiInstance.exports['__napi_register__TaskHasher_struct_36']?.()
|
114
|
+
__napiInstance.exports['__napi_register__TaskHasher_impl_39']?.()
|
115
|
+
__napiInstance.exports['__napi_register__Task_struct_40']?.()
|
116
|
+
__napiInstance.exports['__napi_register__TaskTarget_struct_41']?.()
|
117
|
+
__napiInstance.exports['__napi_register__TaskResult_struct_42']?.()
|
118
|
+
__napiInstance.exports['__napi_register__TaskGraph_struct_43']?.()
|
119
|
+
__napiInstance.exports['__napi_register__FileData_struct_44']?.()
|
120
|
+
__napiInstance.exports['__napi_register__InputsInput_struct_45']?.()
|
121
|
+
__napiInstance.exports['__napi_register__FileSetInput_struct_46']?.()
|
122
|
+
__napiInstance.exports['__napi_register__RuntimeInput_struct_47']?.()
|
123
|
+
__napiInstance.exports['__napi_register__EnvironmentInput_struct_48']?.()
|
124
|
+
__napiInstance.exports['__napi_register__ExternalDependenciesInput_struct_49']?.()
|
125
|
+
__napiInstance.exports['__napi_register__DepsOutputsInput_struct_50']?.()
|
126
|
+
__napiInstance.exports['__napi_register__NxJson_struct_51']?.()
|
127
|
+
__napiInstance.exports['__napi_register__FileLock_struct_52']?.()
|
128
|
+
__napiInstance.exports['__napi_register__FileLock_impl_54']?.()
|
129
|
+
__napiInstance.exports['__napi_register__WorkspaceContext_struct_55']?.()
|
130
|
+
__napiInstance.exports['__napi_register__WorkspaceContext_impl_66']?.()
|
131
|
+
__napiInstance.exports['__napi_register__WorkspaceErrors_67']?.()
|
132
|
+
__napiInstance.exports['__napi_register__NxWorkspaceFiles_struct_68']?.()
|
133
|
+
__napiInstance.exports['__napi_register__NxWorkspaceFilesExternals_struct_69']?.()
|
134
|
+
__napiInstance.exports['__napi_register__UpdatedWorkspaceFiles_struct_70']?.()
|
135
|
+
__napiInstance.exports['__napi_register__FileMap_struct_71']?.()
|
136
|
+
__napiInstance.exports['__napi_register____test_only_transfer_file_map_72']?.()
|
136
137
|
}
|
137
138
|
module.exports.FileLock = __napiModule.exports.FileLock
|
139
|
+
module.exports.HashPlanInspector = __napiModule.exports.HashPlanInspector
|
138
140
|
module.exports.HashPlanner = __napiModule.exports.HashPlanner
|
139
141
|
module.exports.ImportResult = __napiModule.exports.ImportResult
|
140
142
|
module.exports.NxConsolePreferences = __napiModule.exports.NxConsolePreferences
|
@@ -152,7 +154,6 @@ module.exports.hashFile = __napiModule.exports.hashFile
|
|
152
154
|
module.exports.installNxConsole = __napiModule.exports.installNxConsole
|
153
155
|
module.exports.IS_WASM = __napiModule.exports.IS_WASM
|
154
156
|
module.exports.logDebug = __napiModule.exports.logDebug
|
155
|
-
module.exports.logError = __napiModule.exports.logError
|
156
157
|
module.exports.remove = __napiModule.exports.remove
|
157
158
|
module.exports.testOnlyTransferFileMap = __napiModule.exports.testOnlyTransferFileMap
|
158
159
|
module.exports.transferProjectGraph = __napiModule.exports.transferProjectGraph
|
Binary file
|
@@ -137,7 +137,7 @@ async function getTerminalOutputLifeCycle(initiatingProject, initiatingTasks, pr
|
|
137
137
|
// @ts-ignore
|
138
138
|
return (chunk, encoding, callback) => {
|
139
139
|
if (isError) {
|
140
|
-
(0, native_1.
|
140
|
+
(0, native_1.logDebug)(Buffer.isBuffer(chunk)
|
141
141
|
? chunk.toString(encoding)
|
142
142
|
: chunk.toString());
|
143
143
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { NxWorkspaceFilesExternals } from '../native';
|
2
2
|
export declare function setupWorkspaceContext(workspaceRoot: string): void;
|
3
|
-
export declare function getNxWorkspaceFilesFromContext(workspaceRoot: string, projectRootMap: Record<string, string
|
3
|
+
export declare function getNxWorkspaceFilesFromContext(workspaceRoot: string, projectRootMap: Record<string, string>, useDaemonProcess?: boolean): Promise<import("../native").NxWorkspaceFiles>;
|
4
4
|
/**
|
5
5
|
* Sync method to get files matching globs from workspace context.
|
6
6
|
* NOTE: This method will create the workspace context if it doesn't exist.
|
@@ -25,8 +25,8 @@ function setupWorkspaceContext(workspaceRoot) {
|
|
25
25
|
perf_hooks_1.performance.mark('workspace-context:end');
|
26
26
|
perf_hooks_1.performance.measure('workspace context init', 'workspace-context', 'workspace-context:end');
|
27
27
|
}
|
28
|
-
async function getNxWorkspaceFilesFromContext(workspaceRoot, projectRootMap) {
|
29
|
-
if ((0, is_on_daemon_1.isOnDaemon)() || !client_1.daemonClient.enabled()) {
|
28
|
+
async function getNxWorkspaceFilesFromContext(workspaceRoot, projectRootMap, useDaemonProcess = true) {
|
29
|
+
if (!useDaemonProcess || (0, is_on_daemon_1.isOnDaemon)() || !client_1.daemonClient.enabled()) {
|
30
30
|
ensureContextAvailable(workspaceRoot);
|
31
31
|
return workspaceContext.getWorkspaceFiles(projectRootMap);
|
32
32
|
}
|