nx 19.7.0-canary.20240821-2065033 → 19.7.0-canary.20240822-d6a0cfb

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. package/package.json +12 -12
  2. package/src/command-line/add/add.js +1 -5
  3. package/src/command-line/add/command-object.js +1 -5
  4. package/src/command-line/affected/affected.js +0 -3
  5. package/src/command-line/exec/exec.js +0 -3
  6. package/src/command-line/generate/command-object.js +2 -5
  7. package/src/command-line/generate/generate.js +4 -8
  8. package/src/command-line/import/command-object.js +1 -1
  9. package/src/command-line/migrate/command-object.js +3 -2
  10. package/src/command-line/migrate/migrate.js +0 -3
  11. package/src/command-line/release/changelog.js +0 -3
  12. package/src/command-line/release/command-object.js +1 -5
  13. package/src/command-line/release/plan-check.js +0 -3
  14. package/src/command-line/release/plan.js +0 -3
  15. package/src/command-line/release/publish.js +0 -6
  16. package/src/command-line/release/release.js +0 -3
  17. package/src/command-line/release/version.js +0 -3
  18. package/src/command-line/repair/command-object.js +2 -4
  19. package/src/command-line/repair/repair.js +2 -6
  20. package/src/command-line/run/run-one.js +0 -3
  21. package/src/command-line/show/command-object.js +2 -2
  22. package/src/command-line/sync/command-object.js +3 -8
  23. package/src/command-line/sync/sync.js +1 -5
  24. package/src/command-line/watch/command-object.js +1 -1
  25. package/src/command-line/watch/watch.js +0 -3
  26. package/src/command-line/yargs-utils/shared-options.js +3 -3
  27. package/src/daemon/client/client.d.ts +3 -6
  28. package/src/daemon/client/client.js +5 -4
  29. package/src/daemon/message-types/task-history.d.ts +9 -9
  30. package/src/daemon/message-types/task-history.js +7 -7
  31. package/src/daemon/server/handle-task-history.d.ts +9 -0
  32. package/src/daemon/server/handle-task-history.js +28 -0
  33. package/src/daemon/server/server.js +4 -5
  34. package/src/hasher/hash-task.js +36 -1
  35. package/src/native/assert-supported-platform.js +1 -1
  36. package/src/native/index.d.ts +45 -4
  37. package/src/native/native-bindings.js +4 -0
  38. package/src/native/nx.wasi-browser.js +50 -36
  39. package/src/native/nx.wasi.cjs +48 -36
  40. package/src/native/nx.wasm32-wasi.wasm +0 -0
  41. package/src/nx-cloud/update-manager.d.ts +2 -0
  42. package/src/nx-cloud/utilities/url-shorten.js +1 -1
  43. package/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +11 -6
  44. package/src/tasks-runner/cache.d.ts +21 -2
  45. package/src/tasks-runner/cache.js +118 -26
  46. package/src/tasks-runner/default-tasks-runner.d.ts +6 -0
  47. package/src/tasks-runner/default-tasks-runner.js +34 -1
  48. package/src/tasks-runner/life-cycles/task-history-life-cycle-old.d.ts +9 -0
  49. package/src/tasks-runner/life-cycles/task-history-life-cycle-old.js +54 -0
  50. package/src/tasks-runner/life-cycles/task-history-life-cycle.d.ts +1 -0
  51. package/src/tasks-runner/life-cycles/task-history-life-cycle.js +19 -21
  52. package/src/tasks-runner/run-command.js +3 -1
  53. package/src/tasks-runner/task-orchestrator.js +10 -1
  54. package/src/utils/cache-directory.d.ts +1 -0
  55. package/src/utils/cache-directory.js +7 -3
  56. package/src/utils/db-connection.d.ts +2 -0
  57. package/src/utils/db-connection.js +11 -0
  58. package/src/utils/legacy-task-history.d.ts +8 -0
  59. package/src/utils/legacy-task-history.js +87 -0
  60. package/src/utils/logger.js +1 -1
  61. package/src/utils/task-history.d.ts +6 -8
  62. package/src/utils/task-history.js +16 -88
  63. package/src/utils/workspace-context.js +1 -1
  64. package/src/daemon/server/handle-get-task-history.d.ts +0 -4
  65. package/src/daemon/server/handle-get-task-history.js +0 -11
  66. package/src/daemon/server/handle-write-task-runs-to-history.d.ts +0 -5
  67. package/src/daemon/server/handle-write-task-runs-to-history.js +0 -11
@@ -38,8 +38,7 @@ const handle_get_files_in_directory_1 = require("./handle-get-files-in-directory
38
38
  const hash_glob_1 = require("../message-types/hash-glob");
39
39
  const handle_hash_glob_1 = require("./handle-hash-glob");
40
40
  const task_history_1 = require("../message-types/task-history");
41
- const handle_get_task_history_1 = require("./handle-get-task-history");
42
- const handle_write_task_runs_to_history_1 = require("./handle-write-task-runs-to-history");
41
+ const handle_task_history_1 = require("./handle-task-history");
43
42
  const force_shutdown_1 = require("../message-types/force-shutdown");
44
43
  const handle_force_shutdown_1 = require("./handle-force-shutdown");
45
44
  const get_sync_generator_changes_1 = require("../message-types/get-sync-generator-changes");
@@ -140,11 +139,11 @@ async function handleMessage(socket, data) {
140
139
  else if ((0, hash_glob_1.isHandleHashGlobMessage)(payload)) {
141
140
  await handleResult(socket, hash_glob_1.HASH_GLOB, () => (0, handle_hash_glob_1.handleHashGlob)(payload.globs, payload.exclude));
142
141
  }
143
- else if ((0, task_history_1.isHandleGetTaskHistoryForHashesMessage)(payload)) {
144
- await handleResult(socket, 'GET_TASK_HISTORY_FOR_HASHES', () => (0, handle_get_task_history_1.handleGetTaskHistoryForHashes)(payload.hashes));
142
+ else if ((0, task_history_1.isHandleGetFlakyTasksMessage)(payload)) {
143
+ await handleResult(socket, 'GET_TASK_HISTORY_FOR_HASHES', () => (0, handle_task_history_1.handleGetFlakyTasks)(payload.hashes));
145
144
  }
146
145
  else if ((0, task_history_1.isHandleWriteTaskRunsToHistoryMessage)(payload)) {
147
- await handleResult(socket, 'WRITE_TASK_RUNS_TO_HISTORY', () => (0, handle_write_task_runs_to_history_1.handleWriteTaskRunsToHistory)(payload.taskRuns));
146
+ await handleResult(socket, 'WRITE_TASK_RUNS_TO_HISTORY', () => (0, handle_task_history_1.handleRecordTaskRuns)(payload.taskRuns));
148
147
  }
149
148
  else if ((0, force_shutdown_1.isHandleForceShutdownMessage)(payload)) {
150
149
  await handleResult(socket, 'FORCE_SHUTDOWN', () => (0, handle_force_shutdown_1.handleForceShutdown)(server));
@@ -6,8 +6,22 @@ const utils_1 = require("../tasks-runner/utils");
6
6
  const project_graph_1 = require("../project-graph/project-graph");
7
7
  const task_hasher_1 = require("./task-hasher");
8
8
  const nx_json_1 = require("../config/nx-json");
9
+ const native_1 = require("../native");
10
+ const db_connection_1 = require("../utils/db-connection");
11
+ let taskDetails;
12
+ function getTaskDetails() {
13
+ // TODO: Remove when wasm supports sqlite
14
+ if (native_1.IS_WASM) {
15
+ return null;
16
+ }
17
+ if (!taskDetails) {
18
+ taskDetails = new native_1.TaskDetails((0, db_connection_1.getDbConnection)());
19
+ }
20
+ return taskDetails;
21
+ }
9
22
  async function hashTasksThatDoNotDependOnOutputsOfOtherTasks(hasher, projectGraph, taskGraph, nxJson) {
10
23
  performance.mark('hashMultipleTasks:start');
24
+ const taskDetails = getTaskDetails();
11
25
  const tasks = Object.values(taskGraph.tasks);
12
26
  const tasksWithHashers = await Promise.all(tasks.map(async (task) => {
13
27
  const customHasher = (0, utils_1.getCustomHasher)(task, projectGraph);
@@ -23,16 +37,26 @@ async function hashTasksThatDoNotDependOnOutputsOfOtherTasks(hasher, projectGrap
23
37
  (0, task_hasher_1.getInputs)(task, projectGraph, nxJson).depsOutputs.length > 0);
24
38
  })
25
39
  .map((t) => t.task);
26
- const hashes = await hasher.hashTasks(tasksToHash, taskGraph);
40
+ const hashes = await hasher.hashTasks(tasksToHash, taskGraph, process.env);
27
41
  for (let i = 0; i < tasksToHash.length; i++) {
28
42
  tasksToHash[i].hash = hashes[i].value;
29
43
  tasksToHash[i].hashDetails = hashes[i].details;
30
44
  }
45
+ // TODO: Remove if when wasm supports sqlite
46
+ if (taskDetails) {
47
+ taskDetails.recordTaskDetails(tasksToHash.map((task) => ({
48
+ hash: task.hash,
49
+ project: task.target.project,
50
+ target: task.target.target,
51
+ configuration: task.target.configuration,
52
+ })));
53
+ }
31
54
  performance.mark('hashMultipleTasks:end');
32
55
  performance.measure('hashMultipleTasks', 'hashMultipleTasks:start', 'hashMultipleTasks:end');
33
56
  }
34
57
  async function hashTask(hasher, projectGraph, taskGraph, task, env) {
35
58
  performance.mark('hashSingleTask:start');
59
+ const taskDetails = getTaskDetails();
36
60
  const customHasher = (0, utils_1.getCustomHasher)(task, projectGraph);
37
61
  const projectsConfigurations = (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph);
38
62
  const { value, details } = await (customHasher
@@ -48,6 +72,17 @@ async function hashTask(hasher, projectGraph, taskGraph, task, env) {
48
72
  : hasher.hashTask(task, taskGraph, env));
49
73
  task.hash = value;
50
74
  task.hashDetails = details;
75
+ // TODO: Remove if when wasm supports sqlite
76
+ if (taskDetails) {
77
+ taskDetails.recordTaskDetails([
78
+ {
79
+ hash: task.hash,
80
+ project: task.target.project,
81
+ target: task.target.target,
82
+ configuration: task.target.configuration,
83
+ },
84
+ ]);
85
+ }
51
86
  performance.mark('hashSingleTask:end');
52
87
  performance.measure('hashSingleTask', 'hashSingleTask:start', 'hashSingleTask:end');
53
88
  }
@@ -18,7 +18,7 @@ function assertSupportedPlatform() {
18
18
  `The Nx CLI could not find or load the native binary for your supported platform (${process.platform}-${process.arch}).`,
19
19
  'This likely means that optional dependencies were not installed correctly, or your system is missing some system dependencies.',
20
20
  ];
21
- if (process.env.NX_VERBOSE_LOGGING == 'true') {
21
+ if (process.env.NX_VERBOSE_LOGGING === 'true') {
22
22
  bodyLines.push('', 'Additional error information:', e.message);
23
23
  }
24
24
  }
@@ -26,6 +26,23 @@ export declare class ImportResult {
26
26
  staticImportExpressions: Array<string>
27
27
  }
28
28
 
29
+ export declare class NxCache {
30
+ cacheDirectory: string
31
+ constructor(workspaceRoot: string, cachePath: string, dbConnection: ExternalObject<Connection>)
32
+ get(hash: string): CachedResult | null
33
+ put(hash: string, terminalOutput: string, outputs: Array<string>, code: number): void
34
+ applyRemoteCacheResults(hash: string, result: CachedResult): void
35
+ getTaskOutputsPath(hash: string): string
36
+ copyFilesFromCache(cachedResult: CachedResult, outputs: Array<string>): void
37
+ removeOldCacheRecords(): void
38
+ }
39
+
40
+ export declare class NxTaskHistory {
41
+ constructor(db: ExternalObject<Connection>)
42
+ recordTaskRuns(taskRuns: Array<TaskRun>): void
43
+ getFlakyTasks(hashes: Array<string>): Array<string>
44
+ }
45
+
29
46
  export declare class RustPseudoTerminal {
30
47
  constructor()
31
48
  runCommand(command: string, commandDir?: string | undefined | null, jsEnv?: Record<string, string> | undefined | null, execArgv?: Array<string> | undefined | null, quiet?: boolean | undefined | null, tty?: boolean | undefined | null): ChildProcess
@@ -36,6 +53,11 @@ export declare class RustPseudoTerminal {
36
53
  fork(id: string, forkScript: string, pseudoIpcPath: string, commandDir: string | undefined | null, jsEnv: Record<string, string> | undefined | null, execArgv: Array<string> | undefined | null, quiet: boolean): ChildProcess
37
54
  }
38
55
 
56
+ export declare class TaskDetails {
57
+ constructor(db: ExternalObject<Connection>)
58
+ recordTaskDetails(tasks: Array<HashedTask>): void
59
+ }
60
+
39
61
  export declare class TaskHasher {
40
62
  constructor(workspaceRoot: string, projectGraph: ExternalObject<ProjectGraph>, projectFileMap: ExternalObject<ProjectFiles>, allWorkspaceFiles: ExternalObject<Array<FileData>>, tsConfig: Buffer, tsConfigPaths: Record<string, Array<string>>, options?: HasherOptions | undefined | null)
41
63
  hashPlans(hashPlans: ExternalObject<Record<string, Array<HashInstruction>>>, jsEnv: Record<string, string>): NapiDashMap
@@ -67,6 +89,14 @@ export declare class WorkspaceContext {
67
89
  getFilesInDirectory(directory: string): Array<string>
68
90
  }
69
91
 
92
+ export interface CachedResult {
93
+ code: number
94
+ terminalOutput: string
95
+ outputsPath: string
96
+ }
97
+
98
+ export declare export function connectToNxDb(cacheDir: string, nxVersion: string): ExternalObject<Connection>
99
+
70
100
  export declare export function copy(src: string, dest: string): void
71
101
 
72
102
  export interface DepsOutputsInput {
@@ -84,10 +114,6 @@ export declare const enum EventType {
84
114
  create = 'create'
85
115
  }
86
116
 
87
- /**
88
- * Expands the given entries into a list of existing directories and files.
89
- * This is used for copying outputs to and from the cache
90
- */
91
117
  export declare export function expandOutputs(directory: string, entries: Array<string>): Array<string>
92
118
 
93
119
  export interface ExternalDependenciesInput {
@@ -131,6 +157,13 @@ export interface HashDetails {
131
157
  details: Record<string, string>
132
158
  }
133
159
 
160
+ export interface HashedTask {
161
+ hash: string
162
+ project: string
163
+ target: string
164
+ configuration?: string
165
+ }
166
+
134
167
  export interface HasherOptions {
135
168
  selectivelyHashTsConfig: boolean
136
169
  }
@@ -203,6 +236,14 @@ export interface TaskGraph {
203
236
  dependencies: Record<string, Array<string>>
204
237
  }
205
238
 
239
+ export interface TaskRun {
240
+ hash: string
241
+ status: string
242
+ code: number
243
+ start: number
244
+ end: number
245
+ }
246
+
206
247
  export interface TaskTarget {
207
248
  project: string
208
249
  target: string
@@ -364,10 +364,14 @@ if (!nativeBinding) {
364
364
  module.exports.ChildProcess = nativeBinding.ChildProcess
365
365
  module.exports.HashPlanner = nativeBinding.HashPlanner
366
366
  module.exports.ImportResult = nativeBinding.ImportResult
367
+ module.exports.NxCache = nativeBinding.NxCache
368
+ module.exports.NxTaskHistory = nativeBinding.NxTaskHistory
367
369
  module.exports.RustPseudoTerminal = nativeBinding.RustPseudoTerminal
370
+ module.exports.TaskDetails = nativeBinding.TaskDetails
368
371
  module.exports.TaskHasher = nativeBinding.TaskHasher
369
372
  module.exports.Watcher = nativeBinding.Watcher
370
373
  module.exports.WorkspaceContext = nativeBinding.WorkspaceContext
374
+ module.exports.connectToNxDb = nativeBinding.connectToNxDb
371
375
  module.exports.copy = nativeBinding.copy
372
376
  module.exports.EventType = nativeBinding.EventType
373
377
  module.exports.expandOutputs = nativeBinding.expandOutputs
@@ -14,7 +14,7 @@ const __wasi = new __WASI({
14
14
  const __emnapiContext = __emnapiGetDefaultContext()
15
15
 
16
16
  const __sharedMemory = new WebAssembly.Memory({
17
- initial: 16384,
17
+ initial: 1024,
18
18
  maximum: 32768,
19
19
  shared: true,
20
20
  })
@@ -55,49 +55,63 @@ function __napi_rs_initialize_modules(__napiInstance) {
55
55
  __napiInstance.exports['__napi_register__get_files_for_outputs_1']?.()
56
56
  __napiInstance.exports['__napi_register__remove_2']?.()
57
57
  __napiInstance.exports['__napi_register__copy_3']?.()
58
- __napiInstance.exports['__napi_register__hash_array_4']?.()
59
- __napiInstance.exports['__napi_register__hash_file_5']?.()
60
- __napiInstance.exports['__napi_register__ImportResult_struct_6']?.()
61
- __napiInstance.exports['__napi_register__find_imports_7']?.()
62
- __napiInstance.exports['__napi_register__transfer_project_graph_8']?.()
63
- __napiInstance.exports['__napi_register__ExternalNode_struct_9']?.()
64
- __napiInstance.exports['__napi_register__Target_struct_10']?.()
65
- __napiInstance.exports['__napi_register__Project_struct_11']?.()
66
- __napiInstance.exports['__napi_register__ProjectGraph_struct_12']?.()
67
- __napiInstance.exports['__napi_register__HashPlanner_struct_13']?.()
68
- __napiInstance.exports['__napi_register__HashPlanner_impl_17']?.()
69
- __napiInstance.exports['__napi_register__HashDetails_struct_18']?.()
70
- __napiInstance.exports['__napi_register__HasherOptions_struct_19']?.()
71
- __napiInstance.exports['__napi_register__TaskHasher_struct_20']?.()
72
- __napiInstance.exports['__napi_register__TaskHasher_impl_23']?.()
73
- __napiInstance.exports['__napi_register__Task_struct_24']?.()
74
- __napiInstance.exports['__napi_register__TaskTarget_struct_25']?.()
75
- __napiInstance.exports['__napi_register__TaskGraph_struct_26']?.()
76
- __napiInstance.exports['__napi_register__FileData_struct_27']?.()
77
- __napiInstance.exports['__napi_register__InputsInput_struct_28']?.()
78
- __napiInstance.exports['__napi_register__FileSetInput_struct_29']?.()
79
- __napiInstance.exports['__napi_register__RuntimeInput_struct_30']?.()
80
- __napiInstance.exports['__napi_register__EnvironmentInput_struct_31']?.()
81
- __napiInstance.exports['__napi_register__ExternalDependenciesInput_struct_32']?.()
82
- __napiInstance.exports['__napi_register__DepsOutputsInput_struct_33']?.()
83
- __napiInstance.exports['__napi_register__NxJson_struct_34']?.()
84
- __napiInstance.exports['__napi_register__WorkspaceContext_struct_35']?.()
85
- __napiInstance.exports['__napi_register__WorkspaceContext_impl_44']?.()
86
- __napiInstance.exports['__napi_register__WorkspaceErrors_45']?.()
87
- __napiInstance.exports['__napi_register__NxWorkspaceFiles_struct_46']?.()
88
- __napiInstance.exports['__napi_register__NxWorkspaceFilesExternals_struct_47']?.()
89
- __napiInstance.exports['__napi_register__UpdatedWorkspaceFiles_struct_48']?.()
90
- __napiInstance.exports['__napi_register__FileMap_struct_49']?.()
91
- __napiInstance.exports['__napi_register____test_only_transfer_file_map_50']?.()
92
- __napiInstance.exports['__napi_register__IS_WASM_51']?.()
58
+ __napiInstance.exports['__napi_register__CachedResult_struct_4']?.()
59
+ __napiInstance.exports['__napi_register__NxCache_struct_5']?.()
60
+ __napiInstance.exports['__napi_register__NxCache_impl_13']?.()
61
+ __napiInstance.exports['__napi_register__hash_array_14']?.()
62
+ __napiInstance.exports['__napi_register__hash_file_15']?.()
63
+ __napiInstance.exports['__napi_register__IS_WASM_16']?.()
64
+ __napiInstance.exports['__napi_register__get_binary_target_17']?.()
65
+ __napiInstance.exports['__napi_register__ImportResult_struct_18']?.()
66
+ __napiInstance.exports['__napi_register__find_imports_19']?.()
67
+ __napiInstance.exports['__napi_register__transfer_project_graph_20']?.()
68
+ __napiInstance.exports['__napi_register__ExternalNode_struct_21']?.()
69
+ __napiInstance.exports['__napi_register__Target_struct_22']?.()
70
+ __napiInstance.exports['__napi_register__Project_struct_23']?.()
71
+ __napiInstance.exports['__napi_register__ProjectGraph_struct_24']?.()
72
+ __napiInstance.exports['__napi_register__HashedTask_struct_25']?.()
73
+ __napiInstance.exports['__napi_register__TaskDetails_struct_26']?.()
74
+ __napiInstance.exports['__napi_register__TaskDetails_impl_29']?.()
75
+ __napiInstance.exports['__napi_register__HashPlanner_struct_30']?.()
76
+ __napiInstance.exports['__napi_register__HashPlanner_impl_34']?.()
77
+ __napiInstance.exports['__napi_register__HashDetails_struct_35']?.()
78
+ __napiInstance.exports['__napi_register__HasherOptions_struct_36']?.()
79
+ __napiInstance.exports['__napi_register__TaskHasher_struct_37']?.()
80
+ __napiInstance.exports['__napi_register__TaskHasher_impl_40']?.()
81
+ __napiInstance.exports['__napi_register__TaskRun_struct_41']?.()
82
+ __napiInstance.exports['__napi_register__NxTaskHistory_struct_42']?.()
83
+ __napiInstance.exports['__napi_register__NxTaskHistory_impl_46']?.()
84
+ __napiInstance.exports['__napi_register__Task_struct_47']?.()
85
+ __napiInstance.exports['__napi_register__TaskTarget_struct_48']?.()
86
+ __napiInstance.exports['__napi_register__TaskGraph_struct_49']?.()
87
+ __napiInstance.exports['__napi_register__FileData_struct_50']?.()
88
+ __napiInstance.exports['__napi_register__InputsInput_struct_51']?.()
89
+ __napiInstance.exports['__napi_register__FileSetInput_struct_52']?.()
90
+ __napiInstance.exports['__napi_register__RuntimeInput_struct_53']?.()
91
+ __napiInstance.exports['__napi_register__EnvironmentInput_struct_54']?.()
92
+ __napiInstance.exports['__napi_register__ExternalDependenciesInput_struct_55']?.()
93
+ __napiInstance.exports['__napi_register__DepsOutputsInput_struct_56']?.()
94
+ __napiInstance.exports['__napi_register__NxJson_struct_57']?.()
95
+ __napiInstance.exports['__napi_register__WorkspaceContext_struct_58']?.()
96
+ __napiInstance.exports['__napi_register__WorkspaceContext_impl_67']?.()
97
+ __napiInstance.exports['__napi_register__WorkspaceErrors_68']?.()
98
+ __napiInstance.exports['__napi_register__NxWorkspaceFiles_struct_69']?.()
99
+ __napiInstance.exports['__napi_register__NxWorkspaceFilesExternals_struct_70']?.()
100
+ __napiInstance.exports['__napi_register__UpdatedWorkspaceFiles_struct_71']?.()
101
+ __napiInstance.exports['__napi_register__FileMap_struct_72']?.()
102
+ __napiInstance.exports['__napi_register____test_only_transfer_file_map_73']?.()
93
103
  }
94
104
  export const HashPlanner = __napiModule.exports.HashPlanner
95
105
  export const ImportResult = __napiModule.exports.ImportResult
106
+ export const NxCache = __napiModule.exports.NxCache
107
+ export const NxTaskHistory = __napiModule.exports.NxTaskHistory
108
+ export const TaskDetails = __napiModule.exports.TaskDetails
96
109
  export const TaskHasher = __napiModule.exports.TaskHasher
97
110
  export const WorkspaceContext = __napiModule.exports.WorkspaceContext
98
111
  export const copy = __napiModule.exports.copy
99
112
  export const expandOutputs = __napiModule.exports.expandOutputs
100
113
  export const findImports = __napiModule.exports.findImports
114
+ export const getBinaryTarget = __napiModule.exports.getBinaryTarget
101
115
  export const getFilesForOutputs = __napiModule.exports.getFilesForOutputs
102
116
  export const hashArray = __napiModule.exports.hashArray
103
117
  export const hashFile = __napiModule.exports.hashFile
@@ -86,45 +86,57 @@ function __napi_rs_initialize_modules(__napiInstance) {
86
86
  __napiInstance.exports['__napi_register__get_files_for_outputs_1']?.()
87
87
  __napiInstance.exports['__napi_register__remove_2']?.()
88
88
  __napiInstance.exports['__napi_register__copy_3']?.()
89
- __napiInstance.exports['__napi_register__hash_array_4']?.()
90
- __napiInstance.exports['__napi_register__hash_file_5']?.()
91
- __napiInstance.exports['__napi_register__IS_WASM_6']?.()
92
- __napiInstance.exports['__napi_register__get_binary_target_7']?.()
93
- __napiInstance.exports['__napi_register__ImportResult_struct_8']?.()
94
- __napiInstance.exports['__napi_register__find_imports_9']?.()
95
- __napiInstance.exports['__napi_register__transfer_project_graph_10']?.()
96
- __napiInstance.exports['__napi_register__ExternalNode_struct_11']?.()
97
- __napiInstance.exports['__napi_register__Target_struct_12']?.()
98
- __napiInstance.exports['__napi_register__Project_struct_13']?.()
99
- __napiInstance.exports['__napi_register__ProjectGraph_struct_14']?.()
100
- __napiInstance.exports['__napi_register__HashPlanner_struct_15']?.()
101
- __napiInstance.exports['__napi_register__HashPlanner_impl_19']?.()
102
- __napiInstance.exports['__napi_register__HashDetails_struct_20']?.()
103
- __napiInstance.exports['__napi_register__HasherOptions_struct_21']?.()
104
- __napiInstance.exports['__napi_register__TaskHasher_struct_22']?.()
105
- __napiInstance.exports['__napi_register__TaskHasher_impl_25']?.()
106
- __napiInstance.exports['__napi_register__Task_struct_26']?.()
107
- __napiInstance.exports['__napi_register__TaskTarget_struct_27']?.()
108
- __napiInstance.exports['__napi_register__TaskGraph_struct_28']?.()
109
- __napiInstance.exports['__napi_register__FileData_struct_29']?.()
110
- __napiInstance.exports['__napi_register__InputsInput_struct_30']?.()
111
- __napiInstance.exports['__napi_register__FileSetInput_struct_31']?.()
112
- __napiInstance.exports['__napi_register__RuntimeInput_struct_32']?.()
113
- __napiInstance.exports['__napi_register__EnvironmentInput_struct_33']?.()
114
- __napiInstance.exports['__napi_register__ExternalDependenciesInput_struct_34']?.()
115
- __napiInstance.exports['__napi_register__DepsOutputsInput_struct_35']?.()
116
- __napiInstance.exports['__napi_register__NxJson_struct_36']?.()
117
- __napiInstance.exports['__napi_register__WorkspaceContext_struct_37']?.()
118
- __napiInstance.exports['__napi_register__WorkspaceContext_impl_46']?.()
119
- __napiInstance.exports['__napi_register__WorkspaceErrors_47']?.()
120
- __napiInstance.exports['__napi_register__NxWorkspaceFiles_struct_48']?.()
121
- __napiInstance.exports['__napi_register__NxWorkspaceFilesExternals_struct_49']?.()
122
- __napiInstance.exports['__napi_register__UpdatedWorkspaceFiles_struct_50']?.()
123
- __napiInstance.exports['__napi_register__FileMap_struct_51']?.()
124
- __napiInstance.exports['__napi_register____test_only_transfer_file_map_52']?.()
89
+ __napiInstance.exports['__napi_register__CachedResult_struct_4']?.()
90
+ __napiInstance.exports['__napi_register__NxCache_struct_5']?.()
91
+ __napiInstance.exports['__napi_register__NxCache_impl_13']?.()
92
+ __napiInstance.exports['__napi_register__hash_array_14']?.()
93
+ __napiInstance.exports['__napi_register__hash_file_15']?.()
94
+ __napiInstance.exports['__napi_register__IS_WASM_16']?.()
95
+ __napiInstance.exports['__napi_register__get_binary_target_17']?.()
96
+ __napiInstance.exports['__napi_register__ImportResult_struct_18']?.()
97
+ __napiInstance.exports['__napi_register__find_imports_19']?.()
98
+ __napiInstance.exports['__napi_register__transfer_project_graph_20']?.()
99
+ __napiInstance.exports['__napi_register__ExternalNode_struct_21']?.()
100
+ __napiInstance.exports['__napi_register__Target_struct_22']?.()
101
+ __napiInstance.exports['__napi_register__Project_struct_23']?.()
102
+ __napiInstance.exports['__napi_register__ProjectGraph_struct_24']?.()
103
+ __napiInstance.exports['__napi_register__HashedTask_struct_25']?.()
104
+ __napiInstance.exports['__napi_register__TaskDetails_struct_26']?.()
105
+ __napiInstance.exports['__napi_register__TaskDetails_impl_29']?.()
106
+ __napiInstance.exports['__napi_register__HashPlanner_struct_30']?.()
107
+ __napiInstance.exports['__napi_register__HashPlanner_impl_34']?.()
108
+ __napiInstance.exports['__napi_register__HashDetails_struct_35']?.()
109
+ __napiInstance.exports['__napi_register__HasherOptions_struct_36']?.()
110
+ __napiInstance.exports['__napi_register__TaskHasher_struct_37']?.()
111
+ __napiInstance.exports['__napi_register__TaskHasher_impl_40']?.()
112
+ __napiInstance.exports['__napi_register__TaskRun_struct_41']?.()
113
+ __napiInstance.exports['__napi_register__NxTaskHistory_struct_42']?.()
114
+ __napiInstance.exports['__napi_register__NxTaskHistory_impl_46']?.()
115
+ __napiInstance.exports['__napi_register__Task_struct_47']?.()
116
+ __napiInstance.exports['__napi_register__TaskTarget_struct_48']?.()
117
+ __napiInstance.exports['__napi_register__TaskGraph_struct_49']?.()
118
+ __napiInstance.exports['__napi_register__FileData_struct_50']?.()
119
+ __napiInstance.exports['__napi_register__InputsInput_struct_51']?.()
120
+ __napiInstance.exports['__napi_register__FileSetInput_struct_52']?.()
121
+ __napiInstance.exports['__napi_register__RuntimeInput_struct_53']?.()
122
+ __napiInstance.exports['__napi_register__EnvironmentInput_struct_54']?.()
123
+ __napiInstance.exports['__napi_register__ExternalDependenciesInput_struct_55']?.()
124
+ __napiInstance.exports['__napi_register__DepsOutputsInput_struct_56']?.()
125
+ __napiInstance.exports['__napi_register__NxJson_struct_57']?.()
126
+ __napiInstance.exports['__napi_register__WorkspaceContext_struct_58']?.()
127
+ __napiInstance.exports['__napi_register__WorkspaceContext_impl_67']?.()
128
+ __napiInstance.exports['__napi_register__WorkspaceErrors_68']?.()
129
+ __napiInstance.exports['__napi_register__NxWorkspaceFiles_struct_69']?.()
130
+ __napiInstance.exports['__napi_register__NxWorkspaceFilesExternals_struct_70']?.()
131
+ __napiInstance.exports['__napi_register__UpdatedWorkspaceFiles_struct_71']?.()
132
+ __napiInstance.exports['__napi_register__FileMap_struct_72']?.()
133
+ __napiInstance.exports['__napi_register____test_only_transfer_file_map_73']?.()
125
134
  }
126
135
  module.exports.HashPlanner = __napiModule.exports.HashPlanner
127
136
  module.exports.ImportResult = __napiModule.exports.ImportResult
137
+ module.exports.NxCache = __napiModule.exports.NxCache
138
+ module.exports.NxTaskHistory = __napiModule.exports.NxTaskHistory
139
+ module.exports.TaskDetails = __napiModule.exports.TaskDetails
128
140
  module.exports.TaskHasher = __napiModule.exports.TaskHasher
129
141
  module.exports.WorkspaceContext = __napiModule.exports.WorkspaceContext
130
142
  module.exports.copy = __napiModule.exports.copy
Binary file
@@ -1,5 +1,6 @@
1
1
  import type { CloudTaskRunnerOptions } from './nx-cloud-tasks-runner-shell';
2
2
  import { TasksRunner } from '../tasks-runner/tasks-runner';
3
+ import { RemoteCacheV2 } from '../tasks-runner/default-tasks-runner';
3
4
  export declare class NxCloudEnterpriseOutdatedError extends Error {
4
5
  constructor(url: string);
5
6
  }
@@ -10,6 +11,7 @@ export interface NxCloudClient {
10
11
  configureLightClientRequire: () => (paths: string[]) => void;
11
12
  commands: Record<string, () => Promise<void>>;
12
13
  nxCloudTasksRunner: TasksRunner<CloudTaskRunnerOptions>;
14
+ remoteCache: RemoteCacheV2;
13
15
  }
14
16
  export declare function verifyOrUpdateNxCloudClient(options: CloudTaskRunnerOptions): Promise<{
15
17
  nxCloudClient: NxCloudClient;
@@ -95,7 +95,7 @@ async function getInstallationSupportsGitHub(apiUrl) {
95
95
  return !!response.data.isGithubIntegrationEnabled;
96
96
  }
97
97
  catch (e) {
98
- if (process.env.NX_VERBOSE_LOGGING) {
98
+ if (process.env.NX_VERBOSE_LOGGING === 'true') {
99
99
  devkit_exports_1.logger.warn(`Failed to access system features. GitHub integration assumed to be disabled.
100
100
  ${e}`);
101
101
  }
@@ -140,15 +140,20 @@ class TargetProjectLocator {
140
140
  return externalNodeName;
141
141
  }
142
142
  const version = (0, semver_1.clean)(externalPackageJson.version);
143
- const npmProjectKey = `npm:${externalPackageJson.name}@${version}`;
144
- let matchingExternalNode = this.npmProjects[npmProjectKey];
143
+ let matchingExternalNode = this.npmProjects[`npm:${externalPackageJson.name}@${version}`];
145
144
  if (!matchingExternalNode) {
146
145
  // check if it's a package alias, where the resolved package key is used as the version
147
- const aliasNpmProjectKey = `npm:${packageName}@${npmProjectKey}`;
146
+ const aliasNpmProjectKey = `npm:${packageName}@npm:${externalPackageJson.name}@${version}`;
148
147
  matchingExternalNode = this.npmProjects[aliasNpmProjectKey];
149
- if (!matchingExternalNode) {
150
- return null;
151
- }
148
+ }
149
+ if (!matchingExternalNode) {
150
+ // Fallback to package name as key. This can happen if the version in project graph is not the same as in the resolved package.json.
151
+ // e.g. Version in project graph is a git remote, but the resolved version is semver.
152
+ matchingExternalNode =
153
+ this.npmProjects[`npm:${externalPackageJson.name}`];
154
+ }
155
+ if (!matchingExternalNode) {
156
+ return null;
152
157
  }
153
158
  this.npmResolutionCache.set(npmImportForProject, matchingExternalNode.name);
154
159
  return matchingExternalNode.name;
@@ -1,4 +1,4 @@
1
- import { DefaultTasksRunnerOptions } from './default-tasks-runner';
1
+ import { DefaultTasksRunnerOptions, RemoteCache } from './default-tasks-runner';
2
2
  import { Task } from '../config/task-graph';
3
3
  export type CachedResult = {
4
4
  terminalOutput: string;
@@ -10,6 +10,26 @@ export type TaskWithCachedResult = {
10
10
  task: Task;
11
11
  cachedResult: CachedResult;
12
12
  };
13
+ export declare class DbCache {
14
+ private readonly options;
15
+ private cache;
16
+ private remoteCache;
17
+ private remoteCachePromise;
18
+ setup(): Promise<void>;
19
+ constructor(options: {
20
+ nxCloudRemoteCache: RemoteCache;
21
+ });
22
+ get(task: Task): Promise<CachedResult | null>;
23
+ put(task: Task, terminalOutput: string | null, outputs: string[], code: number): Promise<void>;
24
+ copyFilesFromCache(_: string, cachedResult: CachedResult, outputs: string[]): Promise<void>;
25
+ removeOldCacheRecords(): void;
26
+ temporaryOutputPath(task: Task): string;
27
+ private getRemoteCache;
28
+ private _getRemoteCache;
29
+ }
30
+ /**
31
+ * @deprecated Use the {@link DbCache} class instead. This will be removed in Nx 21.
32
+ */
13
33
  export declare class Cache {
14
34
  private readonly options;
15
35
  root: string;
@@ -32,5 +52,4 @@ export declare class Cache {
32
52
  private assertLocalCacheValidity;
33
53
  private createCacheDir;
34
54
  private createTerminalOutputsDir;
35
- private tryAndRetry;
36
55
  }