nx 19.4.0-canary.20240622-963f753 → 19.4.0-canary.20240627-c2c6a13

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.
Files changed (62) hide show
  1. package/package.json +14 -14
  2. package/release/changelog-renderer/index.d.ts +6 -0
  3. package/release/changelog-renderer/index.js +1 -1
  4. package/src/command-line/connect/connect-to-nx-cloud.d.ts +1 -1
  5. package/src/command-line/connect/connect-to-nx-cloud.js +16 -25
  6. package/src/command-line/graph/graph.d.ts +1 -0
  7. package/src/command-line/graph/graph.js +12 -1
  8. package/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +5 -6
  9. package/src/command-line/release/changelog.js +6 -1
  10. package/src/command-line/release/config/config.js +3 -0
  11. package/src/command-line/run/command-object.js +2 -1
  12. package/src/config/workspace-json-project-json.d.ts +1 -0
  13. package/src/core/graph/main.js +1 -1
  14. package/src/core/graph/styles.css +1 -1
  15. package/src/daemon/client/client.d.ts +5 -0
  16. package/src/daemon/client/client.js +14 -0
  17. package/src/daemon/message-types/task-history.d.ts +13 -0
  18. package/src/daemon/message-types/task-history.js +19 -0
  19. package/src/daemon/server/handle-get-task-history.d.ts +4 -0
  20. package/src/daemon/server/handle-get-task-history.js +12 -0
  21. package/src/daemon/server/handle-write-task-runs-to-history.d.ts +5 -0
  22. package/src/daemon/server/handle-write-task-runs-to-history.js +12 -0
  23. package/src/daemon/server/plugins.js +12 -2
  24. package/src/daemon/server/server.js +9 -0
  25. package/src/daemon/socket-utils.d.ts +1 -0
  26. package/src/daemon/socket-utils.js +6 -1
  27. package/src/executors/run-commands/run-commands.impl.js +19 -14
  28. package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.d.ts +1 -0
  29. package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +68 -33
  30. package/src/nx-cloud/generators/connect-to-nx-cloud/schema.json +5 -0
  31. package/src/nx-cloud/utilities/url-shorten.d.ts +2 -1
  32. package/src/nx-cloud/utilities/url-shorten.js +47 -11
  33. package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.js +9 -2
  34. package/src/plugins/target-defaults/target-defaults-plugin.d.ts +5 -0
  35. package/src/project-graph/plugins/internal-api.js +1 -1
  36. package/src/project-graph/plugins/isolation/index.d.ts +1 -1
  37. package/src/project-graph/plugins/isolation/index.js +8 -13
  38. package/src/project-graph/plugins/isolation/messaging.d.ts +6 -3
  39. package/src/project-graph/plugins/isolation/messaging.js +9 -3
  40. package/src/project-graph/plugins/isolation/plugin-pool.d.ts +1 -1
  41. package/src/project-graph/plugins/isolation/plugin-pool.js +123 -43
  42. package/src/project-graph/plugins/isolation/plugin-worker.js +128 -107
  43. package/src/project-graph/project-graph.js +7 -1
  44. package/src/project-graph/utils/project-configuration-utils.js +1 -1
  45. package/src/project-graph/utils/retrieve-workspace-files.d.ts +3 -3
  46. package/src/tasks-runner/default-tasks-runner.js +2 -2
  47. package/src/tasks-runner/life-cycle.d.ts +10 -10
  48. package/src/tasks-runner/life-cycle.js +10 -10
  49. package/src/tasks-runner/life-cycles/task-history-life-cycle.d.ts +9 -0
  50. package/src/tasks-runner/life-cycles/task-history-life-cycle.js +54 -0
  51. package/src/tasks-runner/run-command.js +6 -0
  52. package/src/tasks-runner/task-env.d.ts +13 -0
  53. package/src/tasks-runner/task-env.js +41 -26
  54. package/src/tasks-runner/task-orchestrator.js +4 -4
  55. package/src/utils/git-utils.d.ts +1 -1
  56. package/src/utils/git-utils.js +13 -2
  57. package/src/utils/nx-cloud-utils.d.ts +1 -1
  58. package/src/utils/nx-cloud-utils.js +1 -1
  59. package/src/utils/serialize-target.d.ts +1 -0
  60. package/src/utils/serialize-target.js +7 -0
  61. package/src/utils/task-history.d.ts +8 -0
  62. package/src/utils/task-history.js +97 -0
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getLatestCommitSha = exports.commitChanges = exports.extractUserAndRepoFromGitHubUrl = exports.getGithubSlugOrNull = void 0;
4
4
  const child_process_1 = require("child_process");
5
+ const devkit_exports_1 = require("../devkit-exports");
5
6
  function getGithubSlugOrNull() {
6
7
  try {
7
8
  const gitRemote = (0, child_process_1.execSync)('git remote -v').toString();
@@ -38,17 +39,27 @@ function parseGitHubUrl(url) {
38
39
  }
39
40
  return null;
40
41
  }
41
- function commitChanges(commitMessage) {
42
+ function commitChanges(commitMessage, directory) {
42
43
  try {
43
44
  (0, child_process_1.execSync)('git add -A', { encoding: 'utf8', stdio: 'pipe' });
44
45
  (0, child_process_1.execSync)('git commit --no-verify -F -', {
45
46
  encoding: 'utf8',
46
47
  stdio: 'pipe',
47
48
  input: commitMessage,
49
+ cwd: directory,
48
50
  });
49
51
  }
50
52
  catch (err) {
51
- throw new Error(`Error committing changes:\n${err.stderr}`);
53
+ if (directory) {
54
+ // We don't want to throw during create-nx-workspace
55
+ // because maybe there was an error when setting up git
56
+ // initially.
57
+ devkit_exports_1.logger.verbose(`Git may not be set up correctly for this new workspace.
58
+ ${err}`);
59
+ }
60
+ else {
61
+ throw new Error(`Error committing changes:\n${err.stderr}`);
62
+ }
52
63
  }
53
64
  return getLatestCommitSha();
54
65
  }
@@ -1,4 +1,4 @@
1
1
  import { NxJsonConfiguration } from '../config/nx-json';
2
- export declare function isNxCloudUsed(nxJson: NxJsonConfiguration): string | boolean;
2
+ export declare function isNxCloudUsed(nxJson: NxJsonConfiguration): boolean;
3
3
  export declare function getNxCloudUrl(nxJson: NxJsonConfiguration): string;
4
4
  export declare function getNxCloudToken(nxJson: NxJsonConfiguration): string;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getNxCloudToken = exports.getNxCloudUrl = exports.isNxCloudUsed = void 0;
4
4
  function isNxCloudUsed(nxJson) {
5
- return (process.env.NX_CLOUD_ACCESS_TOKEN ||
5
+ return (!!process.env.NX_CLOUD_ACCESS_TOKEN ||
6
6
  !!nxJson.nxCloudAccessToken ||
7
7
  !!Object.values(nxJson.tasksRunnerOptions ?? {}).find((r) => r.runner == '@nrwl/nx-cloud' || r.runner == 'nx-cloud'));
8
8
  }
@@ -0,0 +1 @@
1
+ export declare function serializeTarget(project: any, target: any, configuration: any): string;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serializeTarget = void 0;
4
+ function serializeTarget(project, target, configuration) {
5
+ return [project, target, configuration].filter((part) => !!part).join(':');
6
+ }
7
+ exports.serializeTarget = serializeTarget;
@@ -0,0 +1,8 @@
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 {};
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.taskHistoryFile = exports.writeTaskRunsToHistory = exports.getHistoryForHashes = void 0;
4
+ const fs_1 = require("fs");
5
+ const path_1 = require("path");
6
+ const client_1 = require("../daemon/client/client");
7
+ const is_on_daemon_1 = require("../daemon/is-on-daemon");
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 ((0, is_on_daemon_1.isOnDaemon)() || !client_1.daemonClient.enabled()) {
23
+ if (taskHistory === undefined) {
24
+ loadTaskHistoryFromDisk();
25
+ }
26
+ const result = {};
27
+ for (let hash of hashes) {
28
+ const indices = taskHashToIndicesMap.get(hash);
29
+ if (!indices) {
30
+ result[hash] = [];
31
+ }
32
+ else {
33
+ result[hash] = indices.map((index) => taskHistory[index]);
34
+ }
35
+ }
36
+ return result;
37
+ }
38
+ return await client_1.daemonClient.getTaskHistoryForHashes(hashes);
39
+ }
40
+ exports.getHistoryForHashes = getHistoryForHashes;
41
+ async function writeTaskRunsToHistory(taskRuns) {
42
+ if ((0, is_on_daemon_1.isOnDaemon)() || !client_1.daemonClient.enabled()) {
43
+ if (taskHistory === undefined) {
44
+ loadTaskHistoryFromDisk();
45
+ }
46
+ const serializedLines = [];
47
+ for (let taskRun of taskRuns) {
48
+ const serializedLine = taskRunKeys.map((key) => taskRun[key]).join(',');
49
+ serializedLines.push(serializedLine);
50
+ recordTaskRunInMemory(taskRun);
51
+ }
52
+ if (!(0, fs_1.existsSync)(exports.taskHistoryFile)) {
53
+ (0, fs_1.writeFileSync)(exports.taskHistoryFile, `${taskRunKeys.join(',')}\n`);
54
+ }
55
+ (0, fs_1.appendFileSync)(exports.taskHistoryFile, serializedLines.join('\n') + '\n');
56
+ }
57
+ else {
58
+ await client_1.daemonClient.writeTaskRunsToHistory(taskRuns);
59
+ }
60
+ }
61
+ exports.writeTaskRunsToHistory = writeTaskRunsToHistory;
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]);
96
+ }
97
+ }