nx 18.3.1 → 18.3.2

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 (31) hide show
  1. package/.eslintrc.json +4 -0
  2. package/bin/nx.js +7 -19
  3. package/package.json +12 -12
  4. package/src/command-line/add/add.js +3 -1
  5. package/src/command-line/add/command-object.d.ts +1 -0
  6. package/src/command-line/add/command-object.js +6 -1
  7. package/src/command-line/init/implementation/react/check-for-uncommitted-changes.js +6 -3
  8. package/src/daemon/cache.js +18 -0
  9. package/src/daemon/client/client.js +3 -4
  10. package/src/daemon/server/handle-hash-tasks.js +2 -2
  11. package/src/daemon/server/project-graph-incremental-recomputation.js +1 -2
  12. package/src/daemon/socket-utils.js +2 -2
  13. package/src/native/index.d.ts +1 -4
  14. package/src/native/index.js +67 -259
  15. package/src/native/native-bindings.js +268 -0
  16. package/src/native/transform-objects.js +1 -0
  17. package/src/project-graph/error-types.d.ts +27 -1
  18. package/src/project-graph/error-types.js +52 -1
  19. package/src/project-graph/plugins/isolation/index.js +8 -4
  20. package/src/project-graph/plugins/isolation/plugin-pool.d.ts +1 -1
  21. package/src/project-graph/plugins/isolation/plugin-pool.js +4 -10
  22. package/src/project-graph/project-graph.d.ts +2 -24
  23. package/src/project-graph/project-graph.js +11 -52
  24. package/src/project-graph/utils/retrieve-workspace-files.d.ts +3 -3
  25. package/src/tasks-runner/init-tasks-runner.js +2 -0
  26. package/src/tasks-runner/task-orchestrator.js +47 -29
  27. package/src/utils/dotenv.d.ts +7 -0
  28. package/src/utils/dotenv.js +22 -0
  29. package/src/utils/params.js +20 -17
  30. package/src/daemon/daemon-project-graph-error.d.ts +0 -8
  31. package/src/daemon/daemon-project-graph-error.js +0 -13
@@ -0,0 +1,268 @@
1
+ const { existsSync, readFileSync } = require('fs')
2
+ const { join } = require('path')
3
+
4
+ const { platform, arch } = process
5
+
6
+ let nativeBinding = null
7
+ let localFileExisted = false
8
+ let loadError = null
9
+
10
+ function isMusl() {
11
+ // For Node 10
12
+ if (!process.report || typeof process.report.getReport !== 'function') {
13
+ try {
14
+ const lddPath = require('child_process').execSync('which ldd').toString().trim();
15
+ return readFileSync(lddPath, 'utf8').includes('musl')
16
+ } catch (e) {
17
+ return true
18
+ }
19
+ } else {
20
+ const { glibcVersionRuntime } = process.report.getReport().header
21
+ return !glibcVersionRuntime
22
+ }
23
+ }
24
+
25
+ switch (platform) {
26
+ case 'android':
27
+ switch (arch) {
28
+ case 'arm64':
29
+ localFileExisted = existsSync(join(__dirname, 'nx.android-arm64.node'))
30
+ try {
31
+ if (localFileExisted) {
32
+ nativeBinding = require('./nx.android-arm64.node')
33
+ } else {
34
+ nativeBinding = require('@nx/nx-android-arm64')
35
+ }
36
+ } catch (e) {
37
+ loadError = e
38
+ }
39
+ break
40
+ case 'arm':
41
+ localFileExisted = existsSync(join(__dirname, 'nx.android-arm-eabi.node'))
42
+ try {
43
+ if (localFileExisted) {
44
+ nativeBinding = require('./nx.android-arm-eabi.node')
45
+ } else {
46
+ nativeBinding = require('@nx/nx-android-arm-eabi')
47
+ }
48
+ } catch (e) {
49
+ loadError = e
50
+ }
51
+ break
52
+ default:
53
+ throw new Error(`Unsupported architecture on Android ${arch}`)
54
+ }
55
+ break
56
+ case 'win32':
57
+ switch (arch) {
58
+ case 'x64':
59
+ localFileExisted = existsSync(
60
+ join(__dirname, 'nx.win32-x64-msvc.node')
61
+ )
62
+ try {
63
+ if (localFileExisted) {
64
+ nativeBinding = require('./nx.win32-x64-msvc.node')
65
+ } else {
66
+ nativeBinding = require('@nx/nx-win32-x64-msvc')
67
+ }
68
+ } catch (e) {
69
+ loadError = e
70
+ }
71
+ break
72
+ case 'ia32':
73
+ localFileExisted = existsSync(
74
+ join(__dirname, 'nx.win32-ia32-msvc.node')
75
+ )
76
+ try {
77
+ if (localFileExisted) {
78
+ nativeBinding = require('./nx.win32-ia32-msvc.node')
79
+ } else {
80
+ nativeBinding = require('@nx/nx-win32-ia32-msvc')
81
+ }
82
+ } catch (e) {
83
+ loadError = e
84
+ }
85
+ break
86
+ case 'arm64':
87
+ localFileExisted = existsSync(
88
+ join(__dirname, 'nx.win32-arm64-msvc.node')
89
+ )
90
+ try {
91
+ if (localFileExisted) {
92
+ nativeBinding = require('./nx.win32-arm64-msvc.node')
93
+ } else {
94
+ nativeBinding = require('@nx/nx-win32-arm64-msvc')
95
+ }
96
+ } catch (e) {
97
+ loadError = e
98
+ }
99
+ break
100
+ default:
101
+ throw new Error(`Unsupported architecture on Windows: ${arch}`)
102
+ }
103
+ break
104
+ case 'darwin':
105
+ localFileExisted = existsSync(join(__dirname, 'nx.darwin-universal.node'))
106
+ try {
107
+ if (localFileExisted) {
108
+ nativeBinding = require('./nx.darwin-universal.node')
109
+ } else {
110
+ nativeBinding = require('@nx/nx-darwin-universal')
111
+ }
112
+ break
113
+ } catch {}
114
+ switch (arch) {
115
+ case 'x64':
116
+ localFileExisted = existsSync(join(__dirname, 'nx.darwin-x64.node'))
117
+ try {
118
+ if (localFileExisted) {
119
+ nativeBinding = require('./nx.darwin-x64.node')
120
+ } else {
121
+ nativeBinding = require('@nx/nx-darwin-x64')
122
+ }
123
+ } catch (e) {
124
+ loadError = e
125
+ }
126
+ break
127
+ case 'arm64':
128
+ localFileExisted = existsSync(
129
+ join(__dirname, 'nx.darwin-arm64.node')
130
+ )
131
+ try {
132
+ if (localFileExisted) {
133
+ nativeBinding = require('./nx.darwin-arm64.node')
134
+ } else {
135
+ nativeBinding = require('@nx/nx-darwin-arm64')
136
+ }
137
+ } catch (e) {
138
+ loadError = e
139
+ }
140
+ break
141
+ default:
142
+ throw new Error(`Unsupported architecture on macOS: ${arch}`)
143
+ }
144
+ break
145
+ case 'freebsd':
146
+ if (arch !== 'x64') {
147
+ throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
148
+ }
149
+ localFileExisted = existsSync(join(__dirname, 'nx.freebsd-x64.node'))
150
+ try {
151
+ if (localFileExisted) {
152
+ nativeBinding = require('./nx.freebsd-x64.node')
153
+ } else {
154
+ nativeBinding = require('@nx/nx-freebsd-x64')
155
+ }
156
+ } catch (e) {
157
+ loadError = e
158
+ }
159
+ break
160
+ case 'linux':
161
+ switch (arch) {
162
+ case 'x64':
163
+ if (isMusl()) {
164
+ localFileExisted = existsSync(
165
+ join(__dirname, 'nx.linux-x64-musl.node')
166
+ )
167
+ try {
168
+ if (localFileExisted) {
169
+ nativeBinding = require('./nx.linux-x64-musl.node')
170
+ } else {
171
+ nativeBinding = require('@nx/nx-linux-x64-musl')
172
+ }
173
+ } catch (e) {
174
+ loadError = e
175
+ }
176
+ } else {
177
+ localFileExisted = existsSync(
178
+ join(__dirname, 'nx.linux-x64-gnu.node')
179
+ )
180
+ try {
181
+ if (localFileExisted) {
182
+ nativeBinding = require('./nx.linux-x64-gnu.node')
183
+ } else {
184
+ nativeBinding = require('@nx/nx-linux-x64-gnu')
185
+ }
186
+ } catch (e) {
187
+ loadError = e
188
+ }
189
+ }
190
+ break
191
+ case 'arm64':
192
+ if (isMusl()) {
193
+ localFileExisted = existsSync(
194
+ join(__dirname, 'nx.linux-arm64-musl.node')
195
+ )
196
+ try {
197
+ if (localFileExisted) {
198
+ nativeBinding = require('./nx.linux-arm64-musl.node')
199
+ } else {
200
+ nativeBinding = require('@nx/nx-linux-arm64-musl')
201
+ }
202
+ } catch (e) {
203
+ loadError = e
204
+ }
205
+ } else {
206
+ localFileExisted = existsSync(
207
+ join(__dirname, 'nx.linux-arm64-gnu.node')
208
+ )
209
+ try {
210
+ if (localFileExisted) {
211
+ nativeBinding = require('./nx.linux-arm64-gnu.node')
212
+ } else {
213
+ nativeBinding = require('@nx/nx-linux-arm64-gnu')
214
+ }
215
+ } catch (e) {
216
+ loadError = e
217
+ }
218
+ }
219
+ break
220
+ case 'arm':
221
+ localFileExisted = existsSync(
222
+ join(__dirname, 'nx.linux-arm-gnueabihf.node')
223
+ )
224
+ try {
225
+ if (localFileExisted) {
226
+ nativeBinding = require('./nx.linux-arm-gnueabihf.node')
227
+ } else {
228
+ nativeBinding = require('@nx/nx-linux-arm-gnueabihf')
229
+ }
230
+ } catch (e) {
231
+ loadError = e
232
+ }
233
+ break
234
+ default:
235
+ throw new Error(`Unsupported architecture on Linux: ${arch}`)
236
+ }
237
+ break
238
+ default:
239
+ throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
240
+ }
241
+
242
+ if (!nativeBinding) {
243
+ if (loadError) {
244
+ throw loadError
245
+ }
246
+ throw new Error(`Failed to load native binding`)
247
+ }
248
+
249
+ const { expandOutputs, getFilesForOutputs, remove, copy, hashArray, hashFile, ImportResult, findImports, transferProjectGraph, ChildProcess, RustPseudoTerminal, HashPlanner, TaskHasher, EventType, Watcher, WorkspaceContext, WorkspaceErrors, testOnlyTransferFileMap } = nativeBinding
250
+
251
+ module.exports.expandOutputs = expandOutputs
252
+ module.exports.getFilesForOutputs = getFilesForOutputs
253
+ module.exports.remove = remove
254
+ module.exports.copy = copy
255
+ module.exports.hashArray = hashArray
256
+ module.exports.hashFile = hashFile
257
+ module.exports.ImportResult = ImportResult
258
+ module.exports.findImports = findImports
259
+ module.exports.transferProjectGraph = transferProjectGraph
260
+ module.exports.ChildProcess = ChildProcess
261
+ module.exports.RustPseudoTerminal = RustPseudoTerminal
262
+ module.exports.HashPlanner = HashPlanner
263
+ module.exports.TaskHasher = TaskHasher
264
+ module.exports.EventType = EventType
265
+ module.exports.Watcher = Watcher
266
+ module.exports.WorkspaceContext = WorkspaceContext
267
+ module.exports.WorkspaceErrors = WorkspaceErrors
268
+ module.exports.testOnlyTransferFileMap = testOnlyTransferFileMap
@@ -31,6 +31,7 @@ function transformProjectGraphForRust(graph) {
31
31
  }
32
32
  for (const [projectName, externalNode] of Object.entries(graph.externalNodes ?? {})) {
33
33
  externalNodes[projectName] = {
34
+ packageName: externalNode.data.packageName,
34
35
  hash: externalNode.data.hash,
35
36
  version: externalNode.data.version,
36
37
  };
@@ -1,6 +1,26 @@
1
1
  import { CreateNodesResultWithContext } from './plugins/internal-api';
2
- import { ConfigurationResult } from './utils/project-configuration-utils';
2
+ import { ConfigurationResult, ConfigurationSourceMaps } from './utils/project-configuration-utils';
3
3
  import { ProjectConfiguration } from '../config/workspace-json-project-json';
4
+ import { ProcessDependenciesError, ProcessProjectGraphError } from './build-project-graph';
5
+ import { ProjectGraph } from '../config/project-graph';
6
+ export declare class ProjectGraphError extends Error {
7
+ #private;
8
+ constructor(errors: Array<CreateNodesError | MergeNodesError | ProjectsWithNoNameError | ProjectsWithConflictingNamesError | ProcessDependenciesError | ProcessProjectGraphError>, partialProjectGraph: ProjectGraph, partialSourceMaps: ConfigurationSourceMaps);
9
+ /**
10
+ * The daemon cannot throw errors which contain methods as they are not serializable.
11
+ *
12
+ * This method creates a new {@link ProjectGraphError} from a {@link DaemonProjectGraphError} with the methods based on the same serialized data.
13
+ */
14
+ static fromDaemonProjectGraphError(e: DaemonProjectGraphError): ProjectGraphError;
15
+ /**
16
+ * This gets the partial project graph despite the errors which occured.
17
+ * This partial project graph may be missing nodes, properties of nodes, or dependencies.
18
+ * This is useful mostly for visualization/debugging. It should not be used for running tasks.
19
+ */
20
+ getPartialProjectGraph(): ProjectGraph;
21
+ getPartialSourcemaps(): ConfigurationSourceMaps;
22
+ getErrors(): (CreateNodesError | MergeNodesError | ProjectsWithNoNameError | ProjectsWithConflictingNamesError | ProcessDependenciesError | ProcessProjectGraphError)[];
23
+ }
4
24
  export declare class ProjectsWithConflictingNamesError extends Error {
5
25
  projects: Record<string, ProjectConfiguration>;
6
26
  constructor(conflicts: Map<string, string[]>, projects: Record<string, ProjectConfiguration>);
@@ -43,3 +63,9 @@ export declare class MergeNodesError extends Error {
43
63
  export declare function isCreateNodesError(e: unknown): e is CreateNodesError;
44
64
  export declare function isAggregateCreateNodesError(e: unknown): e is AggregateCreateNodesError;
45
65
  export declare function isMergeNodesError(e: unknown): e is MergeNodesError;
66
+ export declare class DaemonProjectGraphError extends Error {
67
+ errors: any[];
68
+ readonly projectGraph: ProjectGraph;
69
+ readonly sourceMaps: ConfigurationSourceMaps;
70
+ constructor(errors: any[], projectGraph: ProjectGraph, sourceMaps: ConfigurationSourceMaps);
71
+ }
@@ -1,6 +1,47 @@
1
1
  "use strict";
2
+ var _ProjectGraphError_errors, _ProjectGraphError_partialProjectGraph, _ProjectGraphError_partialSourceMaps;
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isMergeNodesError = exports.isAggregateCreateNodesError = exports.isCreateNodesError = exports.MergeNodesError = exports.AggregateCreateNodesError = exports.CreateNodesError = exports.ProjectConfigurationsError = exports.isProjectsWithNoNameError = exports.ProjectsWithNoNameError = exports.isProjectsWithConflictingNamesError = exports.ProjectsWithConflictingNamesError = void 0;
4
+ exports.DaemonProjectGraphError = exports.isMergeNodesError = exports.isAggregateCreateNodesError = exports.isCreateNodesError = exports.MergeNodesError = exports.AggregateCreateNodesError = exports.CreateNodesError = exports.ProjectConfigurationsError = exports.isProjectsWithNoNameError = exports.ProjectsWithNoNameError = exports.isProjectsWithConflictingNamesError = exports.ProjectsWithConflictingNamesError = exports.ProjectGraphError = void 0;
5
+ const tslib_1 = require("tslib");
6
+ class ProjectGraphError extends Error {
7
+ constructor(errors, partialProjectGraph, partialSourceMaps) {
8
+ super(`Failed to process project graph.`);
9
+ _ProjectGraphError_errors.set(this, void 0);
10
+ _ProjectGraphError_partialProjectGraph.set(this, void 0);
11
+ _ProjectGraphError_partialSourceMaps.set(this, void 0);
12
+ this.name = this.constructor.name;
13
+ tslib_1.__classPrivateFieldSet(this, _ProjectGraphError_errors, errors, "f");
14
+ tslib_1.__classPrivateFieldSet(this, _ProjectGraphError_partialProjectGraph, partialProjectGraph, "f");
15
+ tslib_1.__classPrivateFieldSet(this, _ProjectGraphError_partialSourceMaps, partialSourceMaps, "f");
16
+ this.stack = `${this.message}\n ${errors
17
+ .map((error) => error.stack.split('\n').join('\n '))
18
+ .join('\n')}`;
19
+ }
20
+ /**
21
+ * The daemon cannot throw errors which contain methods as they are not serializable.
22
+ *
23
+ * This method creates a new {@link ProjectGraphError} from a {@link DaemonProjectGraphError} with the methods based on the same serialized data.
24
+ */
25
+ static fromDaemonProjectGraphError(e) {
26
+ return new ProjectGraphError(e.errors, e.projectGraph, e.sourceMaps);
27
+ }
28
+ /**
29
+ * This gets the partial project graph despite the errors which occured.
30
+ * This partial project graph may be missing nodes, properties of nodes, or dependencies.
31
+ * This is useful mostly for visualization/debugging. It should not be used for running tasks.
32
+ */
33
+ getPartialProjectGraph() {
34
+ return tslib_1.__classPrivateFieldGet(this, _ProjectGraphError_partialProjectGraph, "f");
35
+ }
36
+ getPartialSourcemaps() {
37
+ return tslib_1.__classPrivateFieldGet(this, _ProjectGraphError_partialSourceMaps, "f");
38
+ }
39
+ getErrors() {
40
+ return tslib_1.__classPrivateFieldGet(this, _ProjectGraphError_errors, "f");
41
+ }
42
+ }
43
+ exports.ProjectGraphError = ProjectGraphError;
44
+ _ProjectGraphError_errors = new WeakMap(), _ProjectGraphError_partialProjectGraph = new WeakMap(), _ProjectGraphError_partialSourceMaps = new WeakMap();
4
45
  class ProjectsWithConflictingNamesError extends Error {
5
46
  constructor(conflicts, projects) {
6
47
  super([
@@ -94,3 +135,13 @@ function isMergeNodesError(e) {
94
135
  (typeof e === 'object' && 'name' in e && e?.name === MergeNodesError.name));
95
136
  }
96
137
  exports.isMergeNodesError = isMergeNodesError;
138
+ class DaemonProjectGraphError extends Error {
139
+ constructor(errors, projectGraph, sourceMaps) {
140
+ super(`The Daemon Process threw an error while calculating the project graph. Convert this error to a ProjectGraphError to get more information.`);
141
+ this.errors = errors;
142
+ this.projectGraph = projectGraph;
143
+ this.sourceMaps = sourceMaps;
144
+ this.name = this.constructor.name;
145
+ }
146
+ }
147
+ exports.DaemonProjectGraphError = DaemonProjectGraphError;
@@ -3,14 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.loadNxPluginInIsolation = void 0;
4
4
  const workspace_root_1 = require("../../../utils/workspace-root");
5
5
  const plugin_pool_1 = require("./plugin-pool");
6
+ /**
7
+ * Used to ensure 1 plugin : 1 worker
8
+ */
6
9
  const remotePluginCache = new Map();
7
10
  function loadNxPluginInIsolation(plugin, root = workspace_root_1.workspaceRoot) {
8
11
  const cacheKey = JSON.stringify(plugin);
9
12
  if (remotePluginCache.has(cacheKey)) {
10
- return remotePluginCache.get(cacheKey);
13
+ return [remotePluginCache.get(cacheKey), () => { }];
11
14
  }
12
- const [loadingPlugin, cleanup] = (0, plugin_pool_1.loadRemoteNxPlugin)(plugin, root);
13
- remotePluginCache.set(cacheKey, [loadingPlugin, cleanup]);
14
- return [loadingPlugin, cleanup];
15
+ const loadingPlugin = (0, plugin_pool_1.loadRemoteNxPlugin)(plugin, root);
16
+ remotePluginCache.set(cacheKey, loadingPlugin);
17
+ // We clean up plugin workers when Nx process completes.
18
+ return [loadingPlugin, () => { }];
15
19
  }
16
20
  exports.loadNxPluginInIsolation = loadNxPluginInIsolation;
@@ -1,3 +1,3 @@
1
1
  import { PluginConfiguration } from '../../../config/nx-json';
2
2
  import { LoadedNxPlugin } from '../internal-api';
3
- export declare function loadRemoteNxPlugin(plugin: PluginConfiguration, root: string): [Promise<LoadedNxPlugin>, () => void];
3
+ export declare function loadRemoteNxPlugin(plugin: PluginConfiguration, root: string): Promise<LoadedNxPlugin>;
@@ -41,16 +41,10 @@ function loadRemoteNxPlugin(plugin, root) {
41
41
  shutdownPluginWorker(worker, pendingPromises);
42
42
  };
43
43
  cleanupFunctions.add(cleanupFunction);
44
- return [
45
- new Promise((res, rej) => {
46
- worker.on('message', createWorkerHandler(worker, pendingPromises, res, rej));
47
- worker.on('exit', exitHandler);
48
- }),
49
- () => {
50
- cleanupFunction();
51
- cleanupFunctions.delete(cleanupFunction);
52
- },
53
- ];
44
+ return new Promise((res, rej) => {
45
+ worker.on('message', createWorkerHandler(worker, pendingPromises, res, rej));
46
+ worker.on('exit', exitHandler);
47
+ });
54
48
  }
55
49
  exports.loadRemoteNxPlugin = loadRemoteNxPlugin;
56
50
  async function shutdownPluginWorker(worker, pendingPromises) {
@@ -1,9 +1,5 @@
1
- import { ProcessDependenciesError, ProcessProjectGraphError } from './build-project-graph';
2
1
  import { ProjectGraph } from '../config/project-graph';
3
2
  import { ProjectConfiguration, ProjectsConfigurations } from '../config/workspace-json-project-json';
4
- import { ConfigurationSourceMaps } from './utils/project-configuration-utils';
5
- import { CreateNodesError, MergeNodesError, ProjectsWithNoNameError, ProjectsWithConflictingNamesError } from './error-types';
6
- import { DaemonProjectGraphError } from '../daemon/daemon-project-graph-error';
7
3
  /**
8
4
  * Synchronously reads the latest cached copy of the workspace's ProjectGraph.
9
5
  * @throws {Error} if there is no cached ProjectGraph to read from
@@ -16,26 +12,8 @@ export declare function readCachedProjectConfiguration(projectName: string): Pro
16
12
  export declare function readProjectsConfigurationFromProjectGraph(projectGraph: ProjectGraph): ProjectsConfigurations;
17
13
  export declare function buildProjectGraphAndSourceMapsWithoutDaemon(): Promise<{
18
14
  projectGraph: ProjectGraph;
19
- sourceMaps: ConfigurationSourceMaps;
15
+ sourceMaps: import("./utils/project-configuration-utils").ConfigurationSourceMaps;
20
16
  }>;
21
- export declare class ProjectGraphError extends Error {
22
- #private;
23
- constructor(errors: Array<CreateNodesError | MergeNodesError | ProjectsWithNoNameError | ProjectsWithConflictingNamesError | ProcessDependenciesError | ProcessProjectGraphError>, partialProjectGraph: ProjectGraph, partialSourceMaps: ConfigurationSourceMaps);
24
- /**
25
- * The daemon cannot throw errors which contain methods as they are not serializable.
26
- *
27
- * This method creates a new {@link ProjectGraphError} from a {@link DaemonProjectGraphError} with the methods based on the same serialized data.
28
- */
29
- static fromDaemonProjectGraphError(e: DaemonProjectGraphError): ProjectGraphError;
30
- /**
31
- * This gets the partial project graph despite the errors which occured.
32
- * This partial project graph may be missing nodes, properties of nodes, or dependencies.
33
- * This is useful mostly for visualization/debugging. It should not be used for running tasks.
34
- */
35
- getPartialProjectGraph(): ProjectGraph;
36
- getPartialSourcemaps(): ConfigurationSourceMaps;
37
- getErrors(): (ProjectsWithConflictingNamesError | ProjectsWithNoNameError | MergeNodesError | CreateNodesError | ProcessDependenciesError | ProcessProjectGraphError)[];
38
- }
39
17
  /**
40
18
  * Computes and returns a ProjectGraph.
41
19
  *
@@ -66,5 +44,5 @@ export declare function createProjectGraphAndSourceMapsAsync(opts?: {
66
44
  resetDaemonClient?: boolean;
67
45
  }): Promise<{
68
46
  projectGraph: ProjectGraph;
69
- sourceMaps: ConfigurationSourceMaps;
47
+ sourceMaps: import("./utils/project-configuration-utils").ConfigurationSourceMaps;
70
48
  }>;
@@ -1,21 +1,19 @@
1
1
  "use strict";
2
- var _ProjectGraphError_errors, _ProjectGraphError_partialProjectGraph, _ProjectGraphError_partialSourceMaps;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.createProjectGraphAndSourceMapsAsync = exports.createProjectGraphAsync = exports.ProjectGraphError = exports.buildProjectGraphAndSourceMapsWithoutDaemon = exports.readProjectsConfigurationFromProjectGraph = exports.readCachedProjectConfiguration = exports.readCachedProjectGraph = void 0;
5
- const tslib_1 = require("tslib");
6
- const nx_deps_cache_1 = require("./nx-deps-cache");
7
- const build_project_graph_1 = require("./build-project-graph");
8
- const output_1 = require("../utils/output");
9
- const tmp_dir_1 = require("../daemon/tmp-dir");
10
- const strip_indents_1 = require("../utils/strip-indents");
3
+ exports.createProjectGraphAndSourceMapsAsync = exports.createProjectGraphAsync = exports.buildProjectGraphAndSourceMapsWithoutDaemon = exports.readProjectsConfigurationFromProjectGraph = exports.readCachedProjectConfiguration = exports.readCachedProjectGraph = void 0;
4
+ const perf_hooks_1 = require("perf_hooks");
5
+ const nx_json_1 = require("../config/nx-json");
11
6
  const client_1 = require("../daemon/client/client");
7
+ const tmp_dir_1 = require("../daemon/tmp-dir");
12
8
  const fileutils_1 = require("../utils/fileutils");
9
+ const output_1 = require("../utils/output");
10
+ const strip_indents_1 = require("../utils/strip-indents");
13
11
  const workspace_root_1 = require("../utils/workspace-root");
14
- const perf_hooks_1 = require("perf_hooks");
15
- const retrieve_workspace_files_1 = require("./utils/retrieve-workspace-files");
16
- const nx_json_1 = require("../config/nx-json");
12
+ const build_project_graph_1 = require("./build-project-graph");
13
+ const nx_deps_cache_1 = require("./nx-deps-cache");
17
14
  const error_types_1 = require("./error-types");
18
15
  const internal_api_1 = require("./plugins/internal-api");
16
+ const retrieve_workspace_files_1 = require("./utils/retrieve-workspace-files");
19
17
  /**
20
18
  * Synchronously reads the latest cached copy of the workspace's ProjectGraph.
21
19
  * @throws {Error} if there is no cached ProjectGraph to read from
@@ -122,7 +120,7 @@ async function buildProjectGraphAndSourceMapsWithoutDaemon() {
122
120
  ...(createDependenciesError?.errors ?? []),
123
121
  ];
124
122
  if (errors.length > 0) {
125
- throw new ProjectGraphError(errors, projectGraph, sourceMaps);
123
+ throw new error_types_1.ProjectGraphError(errors, projectGraph, sourceMaps);
126
124
  }
127
125
  else {
128
126
  if (cacheEnabled) {
@@ -132,49 +130,10 @@ async function buildProjectGraphAndSourceMapsWithoutDaemon() {
132
130
  }
133
131
  }
134
132
  exports.buildProjectGraphAndSourceMapsWithoutDaemon = buildProjectGraphAndSourceMapsWithoutDaemon;
135
- class ProjectGraphError extends Error {
136
- constructor(errors, partialProjectGraph, partialSourceMaps) {
137
- super(`Failed to process project graph.`);
138
- _ProjectGraphError_errors.set(this, void 0);
139
- _ProjectGraphError_partialProjectGraph.set(this, void 0);
140
- _ProjectGraphError_partialSourceMaps.set(this, void 0);
141
- this.name = this.constructor.name;
142
- tslib_1.__classPrivateFieldSet(this, _ProjectGraphError_errors, errors, "f");
143
- tslib_1.__classPrivateFieldSet(this, _ProjectGraphError_partialProjectGraph, partialProjectGraph, "f");
144
- tslib_1.__classPrivateFieldSet(this, _ProjectGraphError_partialSourceMaps, partialSourceMaps, "f");
145
- this.stack = `${this.message}\n ${errors
146
- .map((error) => error.stack.split('\n').join('\n '))
147
- .join('\n')}`;
148
- }
149
- /**
150
- * The daemon cannot throw errors which contain methods as they are not serializable.
151
- *
152
- * This method creates a new {@link ProjectGraphError} from a {@link DaemonProjectGraphError} with the methods based on the same serialized data.
153
- */
154
- static fromDaemonProjectGraphError(e) {
155
- return new ProjectGraphError(e.errors, e.projectGraph, e.sourceMaps);
156
- }
157
- /**
158
- * This gets the partial project graph despite the errors which occured.
159
- * This partial project graph may be missing nodes, properties of nodes, or dependencies.
160
- * This is useful mostly for visualization/debugging. It should not be used for running tasks.
161
- */
162
- getPartialProjectGraph() {
163
- return tslib_1.__classPrivateFieldGet(this, _ProjectGraphError_partialProjectGraph, "f");
164
- }
165
- getPartialSourcemaps() {
166
- return tslib_1.__classPrivateFieldGet(this, _ProjectGraphError_partialSourceMaps, "f");
167
- }
168
- getErrors() {
169
- return tslib_1.__classPrivateFieldGet(this, _ProjectGraphError_errors, "f");
170
- }
171
- }
172
- exports.ProjectGraphError = ProjectGraphError;
173
- _ProjectGraphError_errors = new WeakMap(), _ProjectGraphError_partialProjectGraph = new WeakMap(), _ProjectGraphError_partialSourceMaps = new WeakMap();
174
133
  function handleProjectGraphError(opts, e) {
175
134
  if (opts.exitOnError) {
176
135
  const isVerbose = process.env.NX_VERBOSE_LOGGING === 'true';
177
- if (e instanceof ProjectGraphError) {
136
+ if (e instanceof error_types_1.ProjectGraphError) {
178
137
  let title = e.message;
179
138
  if (isVerbose) {
180
139
  title += ' See errors below.';
@@ -9,12 +9,12 @@ import { LoadedNxPlugin } from '../plugins/internal-api';
9
9
  * @param nxJson
10
10
  */
11
11
  export declare function retrieveWorkspaceFiles(workspaceRoot: string, projectRootMap: Record<string, string>): Promise<{
12
- allWorkspaceFiles: import("nx/src/devkit-exports").FileData[];
12
+ allWorkspaceFiles: import("../file-utils").FileData[];
13
13
  fileMap: {
14
14
  projectFileMap: ProjectFiles;
15
- nonProjectFiles: import("nx/src/native").FileData[];
15
+ nonProjectFiles: import("../../native").FileData[];
16
16
  };
17
- rustReferences: import("nx/src/native").NxWorkspaceFilesExternals;
17
+ rustReferences: import("../../native").NxWorkspaceFilesExternals;
18
18
  }>;
19
19
  /**
20
20
  * Walk through the workspace and return `ProjectConfigurations`. Only use this if the projectFileMap is not needed.
@@ -8,8 +8,10 @@ const run_command_1 = require("./run-command");
8
8
  const invoke_runner_terminal_output_life_cycle_1 = require("./life-cycles/invoke-runner-terminal-output-life-cycle");
9
9
  const perf_hooks_1 = require("perf_hooks");
10
10
  const utils_1 = require("./utils");
11
+ const dotenv_1 = require("../utils/dotenv");
11
12
  async function initTasksRunner(nxArgs) {
12
13
  perf_hooks_1.performance.mark('init-local');
14
+ (0, dotenv_1.loadRootEnvFiles)();
13
15
  (0, workspace_configuration_check_1.workspaceConfigurationCheck)();
14
16
  const nxJson = (0, configuration_1.readNxJson)();
15
17
  if (nxArgs.verbose) {