nx 23.0.0-beta.4 → 23.0.0-beta.6

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.
@@ -8,6 +8,7 @@ const cache_directory_1 = require("../src/utils/cache-directory");
8
8
  const path_1 = require("path");
9
9
  const fileutils_1 = require("../src/utils/fileutils");
10
10
  const plugin_cache_utils_1 = require("../src/utils/plugin-cache-utils");
11
+ const package_manager_1 = require("../src/utils/package-manager");
11
12
  const cachePath = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, 'package-json.hash');
12
13
  let packageJsonPluginCache = null;
13
14
  function readPackageJsonConfigurationCache() {
@@ -16,7 +17,7 @@ function readPackageJsonConfigurationCache() {
16
17
  }
17
18
  function writeCache() {
18
19
  if (packageJsonPluginCache) {
19
- packageJsonPluginCache.writeToDisk(cachePath);
20
+ packageJsonPluginCache.writeToDisk();
20
21
  }
21
22
  }
22
23
  const plugin = {
@@ -27,7 +28,8 @@ const plugin = {
27
28
  const cache = readPackageJsonConfigurationCache();
28
29
  const patterns = (0, package_json_1.buildPackageJsonPatterns)(context.workspaceRoot, (f) => (0, fileutils_1.readJsonFile)((0, path_1.join)(context.workspaceRoot, f)));
29
30
  const isInPackageJsonWorkspaces = (0, package_json_1.buildPackageJsonWorkspacesMatcher)(patterns);
30
- const result = (0, plugins_1.createNodesFromFiles)((packageJsonPath) => (0, package_json_1.createNodeFromPackageJson)(packageJsonPath, workspace_root_1.workspaceRoot, cache, isInPackageJsonWorkspaces(packageJsonPath)), configFiles, options, context);
31
+ const packageManagerCommand = (0, package_manager_1.getPackageManagerCommand)((0, package_manager_1.detectPackageManager)(context.workspaceRoot), context.workspaceRoot);
32
+ const result = (0, plugins_1.createNodesFromFiles)((packageJsonPath) => (0, package_json_1.createNodeFromPackageJson)(packageJsonPath, workspace_root_1.workspaceRoot, cache, isInPackageJsonWorkspaces(packageJsonPath), packageManagerCommand), configFiles, options, context);
31
33
  writeCache();
32
34
  return result;
33
35
  },
@@ -16,6 +16,7 @@ const native_1 = require("../native");
16
16
  const package_manager_1 = require("../utils/package-manager");
17
17
  const semver_1 = require("semver");
18
18
  const os = tslib_1.__importStar(require("os"));
19
+ const crypto_1 = require("crypto");
19
20
  const machine_id_cache_1 = require("../utils/machine-id-cache");
20
21
  const is_ci_1 = require("../utils/is-ci");
21
22
  const analytics_prompt_1 = require("../utils/analytics-prompt");
@@ -56,7 +57,7 @@ async function startAnalytics() {
56
57
  return;
57
58
  }
58
59
  const isNxCloud = !!(nxJson?.nxCloudId ?? nxJson?.nxCloudAccessToken);
59
- const userId = await (0, machine_id_cache_1.getCurrentMachineId)();
60
+ const userId = await getTelemetryUserId(workspaceId);
60
61
  const packageManagerInfo = getPackageManagerInfo();
61
62
  const nodeVersion = (0, semver_1.parse)(process.version);
62
63
  const nodeVersionString = nodeVersion
@@ -225,3 +226,11 @@ function isAnalyticsEnabled() {
225
226
  const nxJson = (0, nx_json_1.readNxJson)(workspace_root_1.workspaceRoot);
226
227
  return nxJson?.analytics === true;
227
228
  }
229
+ // Mix workspace id in: shared Docker images (Gitpod, Cypress, etc.) bake
230
+ // in /etc/machine-id, so machine-id alone collapses many users into one.
231
+ async function getTelemetryUserId(workspaceId) {
232
+ const machineId = await (0, machine_id_cache_1.getCurrentMachineId)();
233
+ return (0, crypto_1.createHash)('sha256')
234
+ .update(`${machineId}|${workspaceId}`)
235
+ .digest('hex');
236
+ }
@@ -1,109 +1,6 @@
1
1
  /**
2
- * A representation of the invocation of an Executor
2
+ * `Task` and `TaskGraph` are defined as Rust structs in
3
+ * `packages/nx/src/native/tasks/types.rs` and exposed to TypeScript via NAPI.
4
+ * This file re-exports them so existing imports keep working.
3
5
  */
4
- export interface Task {
5
- /**
6
- * Unique ID
7
- */
8
- id: string;
9
- /**
10
- * Details about which project, target, and configuration to run.
11
- */
12
- target: {
13
- /**
14
- * The project for which the task belongs to
15
- */
16
- project: string;
17
- /**
18
- * The target name which the task should invoke
19
- */
20
- target: string;
21
- /**
22
- * The configuration of the target which the task invokes
23
- */
24
- configuration?: string;
25
- };
26
- /**
27
- * Overrides for the configured options of the target
28
- */
29
- overrides: any;
30
- /**
31
- * The outputs the task may produce
32
- */
33
- outputs: string[];
34
- /**
35
- * Root of the project the task belongs to
36
- */
37
- projectRoot?: string;
38
- /**
39
- * Hash of the task which is used for caching.
40
- */
41
- hash?: string;
42
- /**
43
- * Details about the composition of the hash
44
- */
45
- hashDetails?: {
46
- /**
47
- * Command of the task
48
- */
49
- command: string;
50
- /**
51
- * Hashes of inputs used in the hash
52
- */
53
- nodes: {
54
- [name: string]: string;
55
- };
56
- /**
57
- * Hashes of implicit dependencies which are included in the hash
58
- */
59
- implicitDeps?: {
60
- [fileName: string]: string;
61
- };
62
- /**
63
- * Hash of the runtime environment which the task was executed
64
- */
65
- runtime?: {
66
- [input: string]: string;
67
- };
68
- };
69
- /**
70
- *
71
- * Unix timestamp of when a Batch Task starts
72
- **/
73
- startTime?: number;
74
- /**
75
- *
76
- * Unix timestamp of when a Batch Task ends
77
- **/
78
- endTime?: number;
79
- /**
80
- * Determines if a given task should be cacheable.
81
- */
82
- cache?: boolean;
83
- /**
84
- * Determines if a given task should be parallelizable.
85
- */
86
- parallelism: boolean;
87
- /**
88
- * This denotes if the task runs continuously
89
- */
90
- continuous?: boolean;
91
- }
92
- /**
93
- * Graph of Tasks to be executed
94
- */
95
- export interface TaskGraph {
96
- /**
97
- * IDs of Tasks which do not have any dependencies and are thus ready to execute immediately
98
- */
99
- roots: string[];
100
- /**
101
- * Map of Task IDs to Tasks
102
- */
103
- tasks: Record<string, Task>;
104
- /**
105
- * Map of Task IDs to IDs of tasks which the task depends on
106
- */
107
- dependencies: Record<string, string[]>;
108
- continuousDependencies: Record<string, string[]>;
109
- }
6
+ export type { Task, TaskGraph, TaskTarget, TaskHashDetails } from '../native';