nx 19.7.3 → 19.8.0-beta.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. package/package.json +12 -12
  2. package/schemas/nx-schema.json +2 -2
  3. package/src/command-line/generate/generator-utils.d.ts +2 -1
  4. package/src/command-line/import/command-object.js +1 -1
  5. package/src/command-line/import/import.js +9 -4
  6. package/src/command-line/import/utils/prepare-source-repo.js +7 -35
  7. package/src/command-line/init/init-v2.d.ts +1 -1
  8. package/src/command-line/init/init-v2.js +14 -4
  9. package/src/command-line/release/command-object.d.ts +2 -2
  10. package/src/command-line/release/config/config.js +10 -3
  11. package/src/command-line/release/utils/git.d.ts +2 -2
  12. package/src/command-line/release/utils/git.js +12 -2
  13. package/src/command-line/release/utils/shared.d.ts +1 -1
  14. package/src/command-line/release/version.js +4 -0
  15. package/src/command-line/sync/command-object.js +2 -2
  16. package/src/config/nx-json.d.ts +13 -5
  17. package/src/core/graph/main.js +1 -1
  18. package/src/core/graph/styles.css +1 -1
  19. package/src/daemon/client/client.d.ts +2 -1
  20. package/src/daemon/client/client.js +7 -0
  21. package/src/daemon/message-types/task-history.d.ts +9 -3
  22. package/src/daemon/message-types/task-history.js +10 -2
  23. package/src/daemon/server/handle-task-history.d.ts +5 -1
  24. package/src/daemon/server/handle-task-history.js +11 -9
  25. package/src/daemon/server/server.js +5 -2
  26. package/src/hasher/hash-task.js +2 -2
  27. package/src/native/index.d.ts +1 -0
  28. package/src/native/nx.wasi-browser.js +42 -54
  29. package/src/native/nx.wasi.cjs +42 -54
  30. package/src/native/nx.wasm32-wasi.wasm +0 -0
  31. package/src/plugins/js/utils/register.js +7 -0
  32. package/src/tasks-runner/cache.js +2 -1
  33. package/src/tasks-runner/init-tasks-runner.d.ts +1 -1
  34. package/src/tasks-runner/init-tasks-runner.js +5 -3
  35. package/src/tasks-runner/life-cycles/invoke-runner-terminal-output-life-cycle.d.ts +0 -2
  36. package/src/tasks-runner/life-cycles/invoke-runner-terminal-output-life-cycle.js +0 -5
  37. package/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.d.ts +2 -6
  38. package/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.d.ts +2 -6
  39. package/src/tasks-runner/life-cycles/store-run-information-life-cycle.d.ts +2 -7
  40. package/src/tasks-runner/life-cycles/task-history-life-cycle.js +1 -1
  41. package/src/tasks-runner/life-cycles/task-profiling-life-cycle.d.ts +2 -7
  42. package/src/tasks-runner/life-cycles/task-results-life-cycle.d.ts +6 -0
  43. package/src/tasks-runner/life-cycles/task-results-life-cycle.js +17 -0
  44. package/src/tasks-runner/life-cycles/task-timings-life-cycle.d.ts +2 -7
  45. package/src/tasks-runner/run-command.d.ts +12 -2
  46. package/src/tasks-runner/run-command.js +53 -60
  47. package/src/tasks-runner/task-orchestrator.d.ts +0 -1
  48. package/src/tasks-runner/task-orchestrator.js +7 -7
  49. package/src/tasks-runner/tasks-schedule.d.ts +3 -0
  50. package/src/tasks-runner/tasks-schedule.js +26 -4
  51. package/src/utils/git-utils.d.ts +4 -2
  52. package/src/utils/git-utils.index-filter.d.ts +0 -0
  53. package/src/utils/git-utils.index-filter.js +20 -0
  54. package/src/utils/git-utils.js +48 -13
  55. package/src/utils/git-utils.tree-filter.d.ts +11 -0
  56. package/src/utils/git-utils.tree-filter.js +43 -0
  57. package/src/utils/task-history.d.ts +12 -1
  58. package/src/utils/task-history.js +23 -0
@@ -0,0 +1,11 @@
1
+ /**
2
+ * This is meant to be used with `git filter-branch --tree-filter` to rewrite
3
+ * history to only include commits related to the source project folder. If the
4
+ * destination folder is different, this script also moves the files over.
5
+ *
6
+ * Example:
7
+ * NX_IMPORT_SOURCE=<source> NX_IMPORT_DESTINATION=<destination> git filter-branch --tree-filter 'node git-utils.tree-filter.js' --prune-empty -- --all
8
+ */
9
+ declare const execSync: any;
10
+ declare const existsSync: any, mkdirSync: any, renameSync: any, rmSync: any;
11
+ declare const posix: any;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * This is meant to be used with `git filter-branch --tree-filter` to rewrite
3
+ * history to only include commits related to the source project folder. If the
4
+ * destination folder is different, this script also moves the files over.
5
+ *
6
+ * Example:
7
+ * NX_IMPORT_SOURCE=<source> NX_IMPORT_DESTINATION=<destination> git filter-branch --tree-filter 'node git-utils.tree-filter.js' --prune-empty -- --all
8
+ */
9
+ const { execSync } = require('child_process');
10
+ const { existsSync, mkdirSync, renameSync, rmSync } = require('fs');
11
+ // NOTE: The path passed to `git filter-branch` is POSIX, so we need to use the `posix` module.
12
+ const { posix } = require('path');
13
+ try {
14
+ // NOTE: Using env vars because Windows PowerShell has its own handling of quotes (") messes up quotes in args, even if escaped.
15
+ const src = process.env.NX_IMPORT_SOURCE;
16
+ const dest = process.env.NX_IMPORT_DESTINATION;
17
+ const files = execSync(`git ls-files -z ${src}`)
18
+ .toString()
19
+ .trim()
20
+ .split('\x00')
21
+ .map((s) => s.trim())
22
+ .filter(Boolean);
23
+ for (const file of files) {
24
+ if (src === '' || file.startsWith(src)) {
25
+ // If source and destination are the same, then keep the file as is.
26
+ if (src === dest)
27
+ continue;
28
+ const destFile = posix.join(dest, file.replace(src, ''));
29
+ const dir = posix.dirname(destFile);
30
+ if (!existsSync(dir))
31
+ mkdirSync(dir, { recursive: true });
32
+ renameSync(file, destFile);
33
+ }
34
+ else {
35
+ // If not matching the source we are filtering, remove it.
36
+ rmSync(file);
37
+ }
38
+ }
39
+ }
40
+ catch (error) {
41
+ console.error(`Error executing Git commands: ${error}`);
42
+ process.exit(1);
43
+ }
@@ -1,6 +1,17 @@
1
- import { NxTaskHistory, TaskRun } from '../native';
1
+ import { NxTaskHistory, TaskRun, TaskTarget } from '../native';
2
2
  export declare class TaskHistory {
3
3
  taskHistory: NxTaskHistory;
4
+ /**
5
+ * This function returns estimated timings per task
6
+ * @param targets
7
+ * @returns a map where key is task id (project:target:configuration), value is average time of historical runs
8
+ */
9
+ getEstimatedTaskTimings(targets: TaskTarget[]): Promise<Record<string, number>>;
4
10
  getFlakyTasks(hashes: string[]): Promise<string[]>;
5
11
  recordTaskRuns(taskRuns: TaskRun[]): Promise<void>;
6
12
  }
13
+ /**
14
+ * This function returns the singleton instance of TaskHistory
15
+ * @returns singleton instance of TaskHistory
16
+ */
17
+ export declare function getTaskHistory(): TaskHistory;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TaskHistory = void 0;
4
+ exports.getTaskHistory = getTaskHistory;
4
5
  const client_1 = require("../daemon/client/client");
5
6
  const is_on_daemon_1 = require("../daemon/is-on-daemon");
6
7
  const native_1 = require("../native");
@@ -9,6 +10,17 @@ class TaskHistory {
9
10
  constructor() {
10
11
  this.taskHistory = new native_1.NxTaskHistory((0, db_connection_1.getDbConnection)());
11
12
  }
13
+ /**
14
+ * This function returns estimated timings per task
15
+ * @param targets
16
+ * @returns a map where key is task id (project:target:configuration), value is average time of historical runs
17
+ */
18
+ async getEstimatedTaskTimings(targets) {
19
+ if ((0, is_on_daemon_1.isOnDaemon)() || !client_1.daemonClient.enabled()) {
20
+ return this.taskHistory.getEstimatedTaskTimings(targets);
21
+ }
22
+ return await client_1.daemonClient.getEstimatedTaskTimings(targets);
23
+ }
12
24
  async getFlakyTasks(hashes) {
13
25
  if ((0, is_on_daemon_1.isOnDaemon)() || !client_1.daemonClient.enabled()) {
14
26
  return this.taskHistory.getFlakyTasks(hashes);
@@ -23,3 +35,14 @@ class TaskHistory {
23
35
  }
24
36
  }
25
37
  exports.TaskHistory = TaskHistory;
38
+ let taskHistory;
39
+ /**
40
+ * This function returns the singleton instance of TaskHistory
41
+ * @returns singleton instance of TaskHistory
42
+ */
43
+ function getTaskHistory() {
44
+ if (!taskHistory) {
45
+ taskHistory = new TaskHistory();
46
+ }
47
+ return taskHistory;
48
+ }