nx 19.7.0-canary.20240821-2065033 → 19.7.0-canary.20240823-1824267

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) 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/core/graph/main.js +1 -1
  28. package/src/daemon/client/client.d.ts +3 -6
  29. package/src/daemon/client/client.js +9 -6
  30. package/src/daemon/message-types/task-history.d.ts +9 -9
  31. package/src/daemon/message-types/task-history.js +7 -7
  32. package/src/daemon/server/handle-task-history.d.ts +9 -0
  33. package/src/daemon/server/handle-task-history.js +28 -0
  34. package/src/daemon/server/server.js +4 -5
  35. package/src/hasher/hash-task.js +36 -1
  36. package/src/native/assert-supported-platform.js +1 -1
  37. package/src/native/index.d.ts +45 -4
  38. package/src/native/native-bindings.js +4 -0
  39. package/src/native/nx.wasi-browser.js +50 -36
  40. package/src/native/nx.wasi.cjs +48 -36
  41. package/src/native/nx.wasm32-wasi.wasm +0 -0
  42. package/src/nx-cloud/update-manager.d.ts +2 -0
  43. package/src/nx-cloud/utilities/url-shorten.js +1 -1
  44. package/src/plugins/js/package-json/create-package-json.d.ts +1 -0
  45. package/src/plugins/js/package-json/create-package-json.js +24 -0
  46. package/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +11 -6
  47. package/src/tasks-runner/cache.d.ts +21 -2
  48. package/src/tasks-runner/cache.js +118 -26
  49. package/src/tasks-runner/default-tasks-runner.d.ts +6 -0
  50. package/src/tasks-runner/default-tasks-runner.js +34 -1
  51. package/src/tasks-runner/life-cycles/task-history-life-cycle-old.d.ts +9 -0
  52. package/src/tasks-runner/life-cycles/task-history-life-cycle-old.js +54 -0
  53. package/src/tasks-runner/life-cycles/task-history-life-cycle.d.ts +1 -0
  54. package/src/tasks-runner/life-cycles/task-history-life-cycle.js +19 -21
  55. package/src/tasks-runner/run-command.js +3 -1
  56. package/src/tasks-runner/task-orchestrator.js +10 -1
  57. package/src/utils/cache-directory.d.ts +1 -0
  58. package/src/utils/cache-directory.js +7 -3
  59. package/src/utils/db-connection.d.ts +2 -0
  60. package/src/utils/db-connection.js +11 -0
  61. package/src/utils/legacy-task-history.d.ts +8 -0
  62. package/src/utils/legacy-task-history.js +87 -0
  63. package/src/utils/logger.js +1 -1
  64. package/src/utils/package-json.d.ts +3 -0
  65. package/src/utils/task-history.d.ts +6 -8
  66. package/src/utils/task-history.js +16 -88
  67. package/src/utils/workspace-context.js +1 -1
  68. package/src/daemon/server/handle-get-task-history.d.ts +0 -4
  69. package/src/daemon/server/handle-get-task-history.js +0 -11
  70. package/src/daemon/server/handle-write-task-runs-to-history.d.ts +0 -5
  71. package/src/daemon/server/handle-write-task-runs-to-history.js +0 -11
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.taskHistoryFile = void 0;
4
+ exports.getHistoryForHashes = getHistoryForHashes;
5
+ exports.writeTaskRunsToHistory = writeTaskRunsToHistory;
6
+ const fs_1 = require("fs");
7
+ const path_1 = require("path");
8
+ const cache_directory_1 = require("./cache-directory");
9
+ const taskRunKeys = [
10
+ 'project',
11
+ 'target',
12
+ 'configuration',
13
+ 'hash',
14
+ 'code',
15
+ 'status',
16
+ 'start',
17
+ 'end',
18
+ ];
19
+ let taskHistory = undefined;
20
+ let taskHashToIndicesMap = new Map();
21
+ async function getHistoryForHashes(hashes) {
22
+ if (taskHistory === undefined) {
23
+ loadTaskHistoryFromDisk();
24
+ }
25
+ const result = {};
26
+ for (let hash of hashes) {
27
+ const indices = taskHashToIndicesMap.get(hash);
28
+ if (!indices) {
29
+ result[hash] = [];
30
+ }
31
+ else {
32
+ result[hash] = indices.map((index) => taskHistory[index]);
33
+ }
34
+ }
35
+ return result;
36
+ }
37
+ async function writeTaskRunsToHistory(taskRuns) {
38
+ if (taskHistory === undefined) {
39
+ loadTaskHistoryFromDisk();
40
+ }
41
+ const serializedLines = [];
42
+ for (let taskRun of taskRuns) {
43
+ const serializedLine = taskRunKeys.map((key) => taskRun[key]).join(',');
44
+ serializedLines.push(serializedLine);
45
+ recordTaskRunInMemory(taskRun);
46
+ }
47
+ if (!(0, fs_1.existsSync)(exports.taskHistoryFile)) {
48
+ (0, fs_1.writeFileSync)(exports.taskHistoryFile, `${taskRunKeys.join(',')}\n`);
49
+ }
50
+ (0, fs_1.appendFileSync)(exports.taskHistoryFile, serializedLines.join('\n') + '\n');
51
+ }
52
+ exports.taskHistoryFile = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, 'task-history.csv');
53
+ function loadTaskHistoryFromDisk() {
54
+ taskHashToIndicesMap.clear();
55
+ taskHistory = [];
56
+ if (!(0, fs_1.existsSync)(exports.taskHistoryFile)) {
57
+ return;
58
+ }
59
+ const fileContent = (0, fs_1.readFileSync)(exports.taskHistoryFile, 'utf8');
60
+ if (!fileContent) {
61
+ return;
62
+ }
63
+ const lines = fileContent.split('\n');
64
+ // if there are no lines or just the header, return
65
+ if (lines.length <= 1) {
66
+ return;
67
+ }
68
+ const contentLines = lines.slice(1).filter((l) => l.trim() !== '');
69
+ // read the values from csv format where each header is a key and the value is the value
70
+ for (let line of contentLines) {
71
+ const values = line.trim().split(',');
72
+ const run = {};
73
+ taskRunKeys.forEach((header, index) => {
74
+ run[header] = values[index];
75
+ });
76
+ recordTaskRunInMemory(run);
77
+ }
78
+ }
79
+ function recordTaskRunInMemory(taskRun) {
80
+ const index = taskHistory.push(taskRun) - 1;
81
+ if (taskHashToIndicesMap.has(taskRun.hash)) {
82
+ taskHashToIndicesMap.get(taskRun.hash).push(index);
83
+ }
84
+ else {
85
+ taskHashToIndicesMap.set(taskRun.hash, [index]);
86
+ }
87
+ }
@@ -36,7 +36,7 @@ exports.logger = {
36
36
  console.error(...s);
37
37
  },
38
38
  verbose: (...s) => {
39
- if (process.env.NX_VERBOSE_LOGGING) {
39
+ if (process.env.NX_VERBOSE_LOGGING === 'true') {
40
40
  console.log(...s);
41
41
  }
42
42
  },
@@ -42,6 +42,9 @@ export interface PackageJson {
42
42
  optional: boolean;
43
43
  }>;
44
44
  resolutions?: Record<string, string>;
45
+ pnpm?: {
46
+ overrides?: PackageOverride;
47
+ };
45
48
  overrides?: PackageOverride;
46
49
  bin?: Record<string, string> | string;
47
50
  workspaces?: string[] | {
@@ -1,8 +1,6 @@
1
- declare const taskRunKeys: readonly ["project", "target", "configuration", "hash", "code", "status", "start", "end"];
2
- export type TaskRun = Record<(typeof taskRunKeys)[number], string>;
3
- export declare function getHistoryForHashes(hashes: string[]): Promise<{
4
- [hash: string]: TaskRun[];
5
- }>;
6
- export declare function writeTaskRunsToHistory(taskRuns: TaskRun[]): Promise<void>;
7
- export declare const taskHistoryFile: string;
8
- export {};
1
+ import { NxTaskHistory, TaskRun } from '../native';
2
+ export declare class TaskHistory {
3
+ taskHistory: NxTaskHistory;
4
+ getFlakyTasks(hashes: string[]): Promise<string[]>;
5
+ recordTaskRuns(taskRuns: TaskRun[]): Promise<void>;
6
+ }
@@ -1,97 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.taskHistoryFile = void 0;
4
- exports.getHistoryForHashes = getHistoryForHashes;
5
- exports.writeTaskRunsToHistory = writeTaskRunsToHistory;
6
- const fs_1 = require("fs");
7
- const path_1 = require("path");
3
+ exports.TaskHistory = void 0;
8
4
  const client_1 = require("../daemon/client/client");
9
5
  const is_on_daemon_1 = require("../daemon/is-on-daemon");
10
- const cache_directory_1 = require("./cache-directory");
11
- const taskRunKeys = [
12
- 'project',
13
- 'target',
14
- 'configuration',
15
- 'hash',
16
- 'code',
17
- 'status',
18
- 'start',
19
- 'end',
20
- ];
21
- let taskHistory = undefined;
22
- let taskHashToIndicesMap = new Map();
23
- async function getHistoryForHashes(hashes) {
24
- if ((0, is_on_daemon_1.isOnDaemon)() || !client_1.daemonClient.enabled()) {
25
- if (taskHistory === undefined) {
26
- loadTaskHistoryFromDisk();
6
+ const native_1 = require("../native");
7
+ const db_connection_1 = require("./db-connection");
8
+ class TaskHistory {
9
+ constructor() {
10
+ this.taskHistory = new native_1.NxTaskHistory((0, db_connection_1.getDbConnection)());
11
+ }
12
+ async getFlakyTasks(hashes) {
13
+ if ((0, is_on_daemon_1.isOnDaemon)() || !client_1.daemonClient.enabled()) {
14
+ return this.taskHistory.getFlakyTasks(hashes);
27
15
  }
28
- const result = {};
29
- for (let hash of hashes) {
30
- const indices = taskHashToIndicesMap.get(hash);
31
- if (!indices) {
32
- result[hash] = [];
33
- }
34
- else {
35
- result[hash] = indices.map((index) => taskHistory[index]);
36
- }
37
- }
38
- return result;
16
+ return await client_1.daemonClient.getFlakyTasks(hashes);
39
17
  }
40
- return await client_1.daemonClient.getTaskHistoryForHashes(hashes);
41
- }
42
- async function writeTaskRunsToHistory(taskRuns) {
43
- if ((0, is_on_daemon_1.isOnDaemon)() || !client_1.daemonClient.enabled()) {
44
- if (taskHistory === undefined) {
45
- loadTaskHistoryFromDisk();
46
- }
47
- const serializedLines = [];
48
- for (let taskRun of taskRuns) {
49
- const serializedLine = taskRunKeys.map((key) => taskRun[key]).join(',');
50
- serializedLines.push(serializedLine);
51
- recordTaskRunInMemory(taskRun);
52
- }
53
- if (!(0, fs_1.existsSync)(exports.taskHistoryFile)) {
54
- (0, fs_1.writeFileSync)(exports.taskHistoryFile, `${taskRunKeys.join(',')}\n`);
18
+ async recordTaskRuns(taskRuns) {
19
+ if ((0, is_on_daemon_1.isOnDaemon)() || !client_1.daemonClient.enabled()) {
20
+ return this.taskHistory.recordTaskRuns(taskRuns);
55
21
  }
56
- (0, fs_1.appendFileSync)(exports.taskHistoryFile, serializedLines.join('\n') + '\n');
57
- }
58
- else {
59
- await client_1.daemonClient.writeTaskRunsToHistory(taskRuns);
60
- }
61
- }
62
- exports.taskHistoryFile = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, 'task-history.csv');
63
- function loadTaskHistoryFromDisk() {
64
- taskHashToIndicesMap.clear();
65
- taskHistory = [];
66
- if (!(0, fs_1.existsSync)(exports.taskHistoryFile)) {
67
- return;
68
- }
69
- const fileContent = (0, fs_1.readFileSync)(exports.taskHistoryFile, 'utf8');
70
- if (!fileContent) {
71
- return;
72
- }
73
- const lines = fileContent.split('\n');
74
- // if there are no lines or just the header, return
75
- if (lines.length <= 1) {
76
- return;
77
- }
78
- const contentLines = lines.slice(1).filter((l) => l.trim() !== '');
79
- // read the values from csv format where each header is a key and the value is the value
80
- for (let line of contentLines) {
81
- const values = line.trim().split(',');
82
- const run = {};
83
- taskRunKeys.forEach((header, index) => {
84
- run[header] = values[index];
85
- });
86
- recordTaskRunInMemory(run);
87
- }
88
- }
89
- function recordTaskRunInMemory(taskRun) {
90
- const index = taskHistory.push(taskRun) - 1;
91
- if (taskHashToIndicesMap.has(taskRun.hash)) {
92
- taskHashToIndicesMap.get(taskRun.hash).push(index);
93
- }
94
- else {
95
- taskHashToIndicesMap.set(taskRun.hash, [index]);
22
+ return client_1.daemonClient.recordTaskRuns(taskRuns);
96
23
  }
97
24
  }
25
+ exports.TaskHistory = TaskHistory;
@@ -19,7 +19,7 @@ let workspaceContext;
19
19
  function setupWorkspaceContext(workspaceRoot) {
20
20
  const { WorkspaceContext } = require('../native');
21
21
  perf_hooks_1.performance.mark('workspace-context');
22
- workspaceContext = new WorkspaceContext(workspaceRoot, (0, cache_directory_1.cacheDirectoryForWorkspace)(workspaceRoot));
22
+ workspaceContext = new WorkspaceContext(workspaceRoot, (0, cache_directory_1.workspaceDataDirectoryForWorkspace)(workspaceRoot));
23
23
  perf_hooks_1.performance.mark('workspace-context:end');
24
24
  perf_hooks_1.performance.measure('workspace context init', 'workspace-context', 'workspace-context:end');
25
25
  }
@@ -1,4 +0,0 @@
1
- export declare function handleGetTaskHistoryForHashes(hashes: string[]): Promise<{
2
- response: string;
3
- description: string;
4
- }>;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.handleGetTaskHistoryForHashes = handleGetTaskHistoryForHashes;
4
- const task_history_1 = require("../../utils/task-history");
5
- async function handleGetTaskHistoryForHashes(hashes) {
6
- const history = await (0, task_history_1.getHistoryForHashes)(hashes);
7
- return {
8
- response: JSON.stringify(history),
9
- description: 'handleGetTaskHistoryForHashes',
10
- };
11
- }
@@ -1,5 +0,0 @@
1
- import { TaskRun } from '../../utils/task-history';
2
- export declare function handleWriteTaskRunsToHistory(taskRuns: TaskRun[]): Promise<{
3
- response: string;
4
- description: string;
5
- }>;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.handleWriteTaskRunsToHistory = handleWriteTaskRunsToHistory;
4
- const task_history_1 = require("../../utils/task-history");
5
- async function handleWriteTaskRunsToHistory(taskRuns) {
6
- await (0, task_history_1.writeTaskRunsToHistory)(taskRuns);
7
- return {
8
- response: 'true',
9
- description: 'handleWriteTaskRunsToHistory',
10
- };
11
- }