nx 23.3.0-beta.1 → 23.3.0-beta.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.
- package/dist/src/command-line/init/implementation/add-nx-to-monorepo.js +0 -3
- package/dist/src/command-line/init/implementation/add-nx-to-nest.js +0 -3
- package/dist/src/command-line/init/implementation/add-nx-to-npm-repo.js +0 -3
- package/dist/src/command-line/init/implementation/angular/index.js +0 -3
- package/dist/src/command-line/init/implementation/angular/legacy-angular-versions.js +0 -3
- package/dist/src/command-line/init/implementation/utils.d.ts +0 -1
- package/dist/src/command-line/init/implementation/utils.js +0 -8
- package/dist/src/command-line/init/init-v2.js +0 -3
- package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +0 -10
- package/dist/src/core/graph/main.js +1 -1
- package/dist/src/daemon/client/client.d.ts +2 -0
- package/dist/src/daemon/client/client.js +7 -0
- package/dist/src/daemon/message-types/get-plugin-capabilities.d.ts +5 -0
- package/dist/src/daemon/message-types/get-plugin-capabilities.js +11 -0
- package/dist/src/daemon/server/handle-get-plugin-capabilities.d.ts +2 -0
- package/dist/src/daemon/server/handle-get-plugin-capabilities.js +13 -0
- package/dist/src/daemon/server/project-graph-incremental-recomputation.js +1 -1
- package/dist/src/daemon/server/server.js +5 -0
- package/dist/src/native/index.d.ts +20 -0
- package/dist/src/native/native-bindings.js +1 -0
- package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
- package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
- package/dist/src/project-graph/affected/locators/project-glob-changes.js +19 -26
- package/dist/src/project-graph/error-types.d.ts +5 -0
- package/dist/src/project-graph/error-types.js +44 -5
- package/dist/src/project-graph/file-utils.d.ts +2 -0
- package/dist/src/project-graph/file-utils.js +6 -1
- package/dist/src/project-graph/nx-deps-cache.d.ts +5 -2
- package/dist/src/project-graph/nx-deps-cache.js +4 -4
- package/dist/src/project-graph/plugins/get-plugins.d.ts +3 -1
- package/dist/src/project-graph/plugins/get-plugins.js +60 -82
- package/dist/src/project-graph/plugins/in-process-loader.d.ts +1 -1
- package/dist/src/project-graph/plugins/in-process-loader.js +1 -4
- package/dist/src/project-graph/plugins/isolation/index.d.ts +1 -1
- package/dist/src/project-graph/plugins/isolation/index.js +3 -1
- package/dist/src/project-graph/plugins/isolation/isolated-plugin.d.ts +8 -0
- package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +40 -5
- package/dist/src/project-graph/plugins/isolation/load-isolated-plugin.d.ts +10 -1
- package/dist/src/project-graph/plugins/isolation/load-isolated-plugin.js +67 -17
- package/dist/src/project-graph/plugins/loaded-nx-plugin.d.ts +2 -0
- package/dist/src/project-graph/plugins/loaded-nx-plugin.js +9 -0
- package/dist/src/project-graph/plugins/nx-plugin-capabilities.d.ts +6 -0
- package/dist/src/project-graph/plugins/nx-plugin-capabilities.js +28 -0
- package/dist/src/project-graph/plugins/tasks-execution-hooks.js +12 -0
- package/dist/src/project-graph/project-graph.js +41 -42
- package/dist/src/utils/ab-testing.d.ts +1 -1
- package/dist/src/utils/ab-testing.js +0 -4
- package/dist/src/utils/handle-errors.js +5 -43
- package/dist/src/utils/plugins/plugin-capabilities.js +7 -2
- package/dist/src/utils/serialize-overrides-into-command-line.js +2 -4
- package/package.json +11 -12
|
@@ -8,6 +8,7 @@ import type { MaybeStubbedPostTasksExecutionContext } from '../../project-graph/
|
|
|
8
8
|
import { ConfigurationSourceMaps } from '../../project-graph/utils/project-configuration/source-maps';
|
|
9
9
|
import type { FlushSyncGeneratorChangesResult, SyncGeneratorRunResult } from '../../utils/sync-generators';
|
|
10
10
|
import { type ConfigureAiAgentsStatusResponse } from '../message-types/configure-ai-agents';
|
|
11
|
+
import type { NxPluginCapabilities } from '../../project-graph/plugins/nx-plugin-capabilities';
|
|
11
12
|
import { type NxConsoleStatusResponse, type SetNxConsolePreferenceAndInstallResponse } from '../message-types/nx-console';
|
|
12
13
|
/** A refused connect: the errno, and the path it was made against. */
|
|
13
14
|
type ConnectRefusal = {
|
|
@@ -100,6 +101,7 @@ export declare class DaemonClient {
|
|
|
100
101
|
globalGenerators: string[];
|
|
101
102
|
taskGenerators: string[];
|
|
102
103
|
}>;
|
|
104
|
+
getPluginCapabilities(): Promise<NxPluginCapabilities[]>;
|
|
103
105
|
updateWorkspaceContext(createdFiles: string[], updatedFiles: string[], deletedFiles: string[]): Promise<void>;
|
|
104
106
|
runPreTasksExecution(context: PreTasksExecutionContext): Promise<NodeJS.ProcessEnv[]>;
|
|
105
107
|
runPostTasksExecution(context: MaybeStubbedPostTasksExecutionContext): Promise<void>;
|
|
@@ -35,6 +35,7 @@ const get_context_file_data_1 = require("../message-types/get-context-file-data"
|
|
|
35
35
|
const get_files_in_directory_1 = require("../message-types/get-files-in-directory");
|
|
36
36
|
const get_nx_workspace_files_1 = require("../message-types/get-nx-workspace-files");
|
|
37
37
|
const get_registered_sync_generators_1 = require("../message-types/get-registered-sync-generators");
|
|
38
|
+
const get_plugin_capabilities_1 = require("../message-types/get-plugin-capabilities");
|
|
38
39
|
const get_sync_generator_changes_1 = require("../message-types/get-sync-generator-changes");
|
|
39
40
|
const hash_glob_1 = require("../message-types/hash-glob");
|
|
40
41
|
const nx_console_1 = require("../message-types/nx-console");
|
|
@@ -718,6 +719,12 @@ class DaemonClient {
|
|
|
718
719
|
};
|
|
719
720
|
return this.sendToDaemonViaQueue(message);
|
|
720
721
|
}
|
|
722
|
+
getPluginCapabilities() {
|
|
723
|
+
const message = {
|
|
724
|
+
type: get_plugin_capabilities_1.GET_PLUGIN_CAPABILITIES,
|
|
725
|
+
};
|
|
726
|
+
return this.sendToDaemonViaQueue(message);
|
|
727
|
+
}
|
|
721
728
|
updateWorkspaceContext(createdFiles, updatedFiles, deletedFiles) {
|
|
722
729
|
const message = {
|
|
723
730
|
type: update_workspace_context_1.UPDATE_WORKSPACE_CONTEXT,
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const GET_PLUGIN_CAPABILITIES: 'GET_PLUGIN_CAPABILITIES';
|
|
2
|
+
export type HandleGetPluginCapabilitiesMessage = {
|
|
3
|
+
type: typeof GET_PLUGIN_CAPABILITIES;
|
|
4
|
+
};
|
|
5
|
+
export declare function isHandleGetPluginCapabilitiesMessage(message: unknown): message is HandleGetPluginCapabilitiesMessage;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GET_PLUGIN_CAPABILITIES = void 0;
|
|
4
|
+
exports.isHandleGetPluginCapabilitiesMessage = isHandleGetPluginCapabilitiesMessage;
|
|
5
|
+
exports.GET_PLUGIN_CAPABILITIES = 'GET_PLUGIN_CAPABILITIES';
|
|
6
|
+
function isHandleGetPluginCapabilitiesMessage(message) {
|
|
7
|
+
return (typeof message === 'object' &&
|
|
8
|
+
message !== null &&
|
|
9
|
+
'type' in message &&
|
|
10
|
+
message['type'] === exports.GET_PLUGIN_CAPABILITIES);
|
|
11
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleGetPluginCapabilities = handleGetPluginCapabilities;
|
|
4
|
+
const nx_json_1 = require("../../config/nx-json");
|
|
5
|
+
const get_plugins_1 = require("../../project-graph/plugins/get-plugins");
|
|
6
|
+
const workspace_root_1 = require("../../utils/workspace-root");
|
|
7
|
+
async function handleGetPluginCapabilities() {
|
|
8
|
+
const plugins = await (0, get_plugins_1.getPlugins)((0, nx_json_1.readNxJson)(workspace_root_1.workspaceRoot), workspace_root_1.workspaceRoot);
|
|
9
|
+
return {
|
|
10
|
+
response: plugins.map((plugin) => plugin.capabilities()),
|
|
11
|
+
description: 'handleGetPluginCapabilities',
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -588,7 +588,7 @@ function persistProjectGraphToDisk(result) {
|
|
|
588
588
|
!result.sourceMaps) {
|
|
589
589
|
return;
|
|
590
590
|
}
|
|
591
|
-
(0, nx_deps_cache_1.writeCache)(result.projectFileMapCache, result.projectGraph, result.sourceMaps, extractErrors(result.error));
|
|
591
|
+
(0, nx_deps_cache_1.writeCache)(result.projectFileMapCache, result.projectGraph, result.sourceMaps, extractErrors(result.error), Date.now());
|
|
592
592
|
cacheHasBeenPersisted = true;
|
|
593
593
|
}
|
|
594
594
|
function copyFileData(d) {
|
|
@@ -27,6 +27,7 @@ const get_context_file_data_1 = require("../message-types/get-context-file-data"
|
|
|
27
27
|
const get_files_in_directory_1 = require("../message-types/get-files-in-directory");
|
|
28
28
|
const get_nx_workspace_files_1 = require("../message-types/get-nx-workspace-files");
|
|
29
29
|
const get_registered_sync_generators_1 = require("../message-types/get-registered-sync-generators");
|
|
30
|
+
const get_plugin_capabilities_1 = require("../message-types/get-plugin-capabilities");
|
|
30
31
|
const get_sync_generator_changes_1 = require("../message-types/get-sync-generator-changes");
|
|
31
32
|
const glob_1 = require("../message-types/glob");
|
|
32
33
|
const hash_glob_1 = require("../message-types/hash-glob");
|
|
@@ -45,6 +46,7 @@ const handle_force_shutdown_1 = require("./handle-force-shutdown");
|
|
|
45
46
|
const handle_client_env_1 = require("./handle-client-env");
|
|
46
47
|
const handle_get_files_in_directory_1 = require("./handle-get-files-in-directory");
|
|
47
48
|
const handle_get_registered_sync_generators_1 = require("./handle-get-registered-sync-generators");
|
|
49
|
+
const handle_get_plugin_capabilities_1 = require("./handle-get-plugin-capabilities");
|
|
48
50
|
const handle_get_sync_generator_changes_1 = require("./handle-get-sync-generator-changes");
|
|
49
51
|
const handle_glob_1 = require("./handle-glob");
|
|
50
52
|
const handle_hash_glob_1 = require("./handle-hash-glob");
|
|
@@ -208,6 +210,9 @@ async function handleMessage(socket, data) {
|
|
|
208
210
|
else if ((0, get_registered_sync_generators_1.isHandleGetRegisteredSyncGeneratorsMessage)(payload)) {
|
|
209
211
|
await handleResult(socket, get_registered_sync_generators_1.GET_REGISTERED_SYNC_GENERATORS, () => (0, handle_get_registered_sync_generators_1.handleGetRegisteredSyncGenerators)(), mode);
|
|
210
212
|
}
|
|
213
|
+
else if ((0, get_plugin_capabilities_1.isHandleGetPluginCapabilitiesMessage)(payload)) {
|
|
214
|
+
await handleResult(socket, get_plugin_capabilities_1.GET_PLUGIN_CAPABILITIES, () => (0, handle_get_plugin_capabilities_1.handleGetPluginCapabilities)(), mode);
|
|
215
|
+
}
|
|
211
216
|
else if ((0, update_workspace_context_1.isHandleUpdateWorkspaceContextMessage)(payload)) {
|
|
212
217
|
await handleResult(socket, update_workspace_context_1.UPDATE_WORKSPACE_CONTEXT, () => (0, handle_update_workspace_context_1.handleUpdateWorkspaceContext)(payload.createdFiles, payload.updatedFiles, payload.deletedFiles), mode);
|
|
213
218
|
}
|
|
@@ -75,6 +75,8 @@ export declare class FileLock {
|
|
|
75
75
|
check(): boolean
|
|
76
76
|
wait(): Promise<void>
|
|
77
77
|
lock(): void
|
|
78
|
+
/** Takes the lock without blocking; false means another handle holds it. */
|
|
79
|
+
tryLock(): boolean
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
export declare class HashPlanInspector {
|
|
@@ -162,6 +164,16 @@ export declare class NxConsolePreferences {
|
|
|
162
164
|
setAutoInstallPreference(autoInstall: boolean): void
|
|
163
165
|
}
|
|
164
166
|
|
|
167
|
+
export declare class NxPluginCapabilities {
|
|
168
|
+
constructor(db: ExternalObject<NxDbConnection>)
|
|
169
|
+
record(computedAt: number, capabilities: Array<CachedPluginCapabilities>): void
|
|
170
|
+
/**
|
|
171
|
+
* The capabilities recorded with the graph computed at `computed_at`, or
|
|
172
|
+
* null when what is recorded belongs to another build or nothing is.
|
|
173
|
+
*/
|
|
174
|
+
get(computedAt: number): Array<CachedPluginCapabilities> | null
|
|
175
|
+
}
|
|
176
|
+
|
|
165
177
|
export declare class NxTaskHistory {
|
|
166
178
|
constructor(db: ExternalObject<NxDbConnection>)
|
|
167
179
|
recordTaskRuns(taskRuns: Array<TaskRun>): void
|
|
@@ -381,6 +393,14 @@ export declare const enum BatchStatus {
|
|
|
381
393
|
Failure = 'Failure'
|
|
382
394
|
}
|
|
383
395
|
|
|
396
|
+
export interface CachedPluginCapabilities {
|
|
397
|
+
createNodesPattern?: string
|
|
398
|
+
hasCreateDependencies: boolean
|
|
399
|
+
hasCreateMetadata: boolean
|
|
400
|
+
hasPreTasksExecution: boolean
|
|
401
|
+
hasPostTasksExecution: boolean
|
|
402
|
+
}
|
|
403
|
+
|
|
384
404
|
export interface CachedResult {
|
|
385
405
|
code: number
|
|
386
406
|
terminalOutput?: string
|
|
@@ -586,6 +586,7 @@ module.exports.IgnoredIndexReader = nativeBinding.IgnoredIndexReader
|
|
|
586
586
|
module.exports.ImportResult = nativeBinding.ImportResult
|
|
587
587
|
module.exports.NxCache = nativeBinding.NxCache
|
|
588
588
|
module.exports.NxConsolePreferences = nativeBinding.NxConsolePreferences
|
|
589
|
+
module.exports.NxPluginCapabilities = nativeBinding.NxPluginCapabilities
|
|
589
590
|
module.exports.NxTaskHistory = nativeBinding.NxTaskHistory
|
|
590
591
|
module.exports.ProcessMetricsCollector = nativeBinding.ProcessMetricsCollector
|
|
591
592
|
module.exports.RunningTasksService = nativeBinding.RunningTasksService
|
|
Binary file
|
|
Binary file
|
|
@@ -4,15 +4,17 @@ exports.getTouchedProjectsFromProjectGlobChanges = void 0;
|
|
|
4
4
|
const minimatch_1 = require("minimatch");
|
|
5
5
|
const nx_json_1 = require("../../../config/nx-json");
|
|
6
6
|
const workspace_root_1 = require("../../../utils/workspace-root");
|
|
7
|
-
const path_1 = require("path");
|
|
8
|
-
const fs_1 = require("fs");
|
|
9
|
-
const retrieve_workspace_files_1 = require("../../utils/retrieve-workspace-files");
|
|
10
7
|
const globs_1 = require("../../../utils/globs");
|
|
11
8
|
const get_plugins_1 = require("../../plugins/get-plugins");
|
|
9
|
+
const file_utils_1 = require("../../file-utils");
|
|
12
10
|
const getTouchedProjectsFromProjectGlobChanges = async (touchedFiles, projectGraphNodes, _nxJson, _packageJson, _projectGraph, projectDeletionAffectsAllProjects = true) => {
|
|
11
|
+
// Only deletions matter here. Uses `isDeletedFile`, not `getChanges()`,
|
|
12
|
+
// which also parses json/lock files at two revisions for every touched file.
|
|
13
|
+
const deleted = touchedFiles.filter((touchedFile) => (0, file_utils_1.isDeletedFile)(touchedFile.file));
|
|
14
|
+
if (!deleted.length) {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
13
17
|
const globPattern = await (async () => {
|
|
14
|
-
// TODO: We need a quicker way to get patterns that should not
|
|
15
|
-
// require starting up plugin workers
|
|
16
18
|
if (process.env.NX_FORCE_REUSE_CACHED_GRAPH === 'true') {
|
|
17
19
|
return (0, globs_1.combineGlobPatterns)([
|
|
18
20
|
'**/package.json',
|
|
@@ -21,27 +23,18 @@ const getTouchedProjectsFromProjectGlobChanges = async (touchedFiles, projectGra
|
|
|
21
23
|
'package.json',
|
|
22
24
|
]);
|
|
23
25
|
}
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
+
const nxJson = (0, nx_json_1.readNxJson)(workspace_root_1.workspaceRoot);
|
|
27
|
+
const capabilities = await (0, get_plugins_1.capabilitiesOfConfiguredPlugins)(nxJson, workspace_root_1.workspaceRoot);
|
|
28
|
+
return (0, globs_1.combineGlobPatterns)(capabilities
|
|
29
|
+
.map((capability) => capability.createNodesPattern)
|
|
30
|
+
.filter((pattern) => !!pattern));
|
|
26
31
|
})();
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (!(0, fs_1.existsSync)((0, path_1.join)(workspace_root_1.workspaceRoot, touchedFile.file))) {
|
|
35
|
-
// If any project has been deleted, we must assume all projects were affected
|
|
36
|
-
if (projectDeletionAffectsAllProjects) {
|
|
37
|
-
return Object.keys(projectGraphNodes);
|
|
38
|
-
}
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
// Modified project config files are under a project's root, and implicitly
|
|
42
|
-
// mark it as affected. Thus, we don't need to handle it here.
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return Array.from(touchedProjects);
|
|
32
|
+
const configDeleted = deleted.some((touchedFile) => (0, minimatch_1.minimatch)(touchedFile.file, globPattern, { dot: true }));
|
|
33
|
+
// If any project has been deleted, we must assume all projects were
|
|
34
|
+
// affected. A modified project configuration is under its own project's
|
|
35
|
+
// root, which marks that project affected without this locator.
|
|
36
|
+
return configDeleted && projectDeletionAffectsAllProjects
|
|
37
|
+
? Object.keys(projectGraphNodes)
|
|
38
|
+
: [];
|
|
46
39
|
};
|
|
47
40
|
exports.getTouchedProjectsFromProjectGlobChanges = getTouchedProjectsFromProjectGlobChanges;
|
|
@@ -66,6 +66,10 @@ export declare class ProjectConfigurationsError extends Error {
|
|
|
66
66
|
constructor(errors: Array<MergeNodesError | AggregateCreateNodesError | ProjectsWithNoNameError | MultipleProjectsWithSameNameError | WorkspaceValidityError>, partialProjectConfigurationsResult: ConfigurationResult);
|
|
67
67
|
}
|
|
68
68
|
export declare function isProjectConfigurationsError(e: unknown): e is ProjectConfigurationsError;
|
|
69
|
+
export declare function formatProjectGraphError(error: ProjectGraphError | ProjectConfigurationsError, isVerbose: boolean): {
|
|
70
|
+
title: string;
|
|
71
|
+
bodyLines: string[];
|
|
72
|
+
};
|
|
69
73
|
/**
|
|
70
74
|
* This error should be thrown when a `createNodesV2` function hits a recoverable error.
|
|
71
75
|
* It allows Nx to recieve partial results and continue processing for better UX.
|
|
@@ -149,3 +153,4 @@ export declare class LoadPluginError extends Error {
|
|
|
149
153
|
plugin: string;
|
|
150
154
|
constructor(plugin: string, cause: Error);
|
|
151
155
|
}
|
|
156
|
+
export declare function formatErrorStackAndCause(error: Error): string;
|
|
@@ -7,12 +7,14 @@ exports.isMultipleProjectsWithSameNameError = isMultipleProjectsWithSameNameErro
|
|
|
7
7
|
exports.isProjectsWithNoNameError = isProjectsWithNoNameError;
|
|
8
8
|
exports.isProjectWithNoNameError = isProjectWithNoNameError;
|
|
9
9
|
exports.isProjectConfigurationsError = isProjectConfigurationsError;
|
|
10
|
+
exports.formatProjectGraphError = formatProjectGraphError;
|
|
10
11
|
exports.formatAggregateCreateNodesError = formatAggregateCreateNodesError;
|
|
11
12
|
exports.isWorkspaceValidityError = isWorkspaceValidityError;
|
|
12
13
|
exports.isAggregateProjectGraphError = isAggregateProjectGraphError;
|
|
13
14
|
exports.isCreateMetadataError = isCreateMetadataError;
|
|
14
15
|
exports.isAggregateCreateNodesError = isAggregateCreateNodesError;
|
|
15
16
|
exports.isMergeNodesError = isMergeNodesError;
|
|
17
|
+
exports.formatErrorStackAndCause = formatErrorStackAndCause;
|
|
16
18
|
const tslib_1 = require("tslib");
|
|
17
19
|
class StaleProjectGraphCacheError extends Error {
|
|
18
20
|
constructor() {
|
|
@@ -222,6 +224,27 @@ function isProjectConfigurationsError(e) {
|
|
|
222
224
|
'name' in e &&
|
|
223
225
|
e?.name === ProjectConfigurationsError.name));
|
|
224
226
|
}
|
|
227
|
+
function formatProjectGraphError(error, isVerbose) {
|
|
228
|
+
const errors = isProjectConfigurationsError(error)
|
|
229
|
+
? error.errors
|
|
230
|
+
: error.getErrors();
|
|
231
|
+
let title = error.message;
|
|
232
|
+
if (error.cause &&
|
|
233
|
+
typeof error.cause === 'object' &&
|
|
234
|
+
'message' in error.cause) {
|
|
235
|
+
title += ' ' + error.cause.message + '.';
|
|
236
|
+
}
|
|
237
|
+
return {
|
|
238
|
+
title,
|
|
239
|
+
bodyLines: isVerbose
|
|
240
|
+
? [formatErrorStackAndCause(error)]
|
|
241
|
+
: [
|
|
242
|
+
...errors.map((e) => e.message),
|
|
243
|
+
'',
|
|
244
|
+
'Pass --verbose to see the stacktraces.',
|
|
245
|
+
],
|
|
246
|
+
};
|
|
247
|
+
}
|
|
225
248
|
/**
|
|
226
249
|
* This error should be thrown when a `createNodesV2` function hits a recoverable error.
|
|
227
250
|
* It allows Nx to recieve partial results and continue processing for better UX.
|
|
@@ -476,9 +499,25 @@ function indentString(str, indent) {
|
|
|
476
499
|
.join('\n'));
|
|
477
500
|
}
|
|
478
501
|
function formatErrorStackAndCause(error) {
|
|
479
|
-
const cause = error.cause
|
|
480
|
-
return (error.stack +
|
|
481
|
-
(cause
|
|
482
|
-
|
|
483
|
-
|
|
502
|
+
const cause = describeCause(error.cause);
|
|
503
|
+
return ((error.stack ?? error.message) +
|
|
504
|
+
(cause ? `\nCaused by: \n${indentString(cause, 2)}` : ''));
|
|
505
|
+
}
|
|
506
|
+
function describeCause(cause) {
|
|
507
|
+
if (!cause) {
|
|
508
|
+
return null;
|
|
509
|
+
}
|
|
510
|
+
if (cause instanceof Error) {
|
|
511
|
+
return cause.stack ?? cause.message;
|
|
512
|
+
}
|
|
513
|
+
if (typeof cause === 'object') {
|
|
514
|
+
const { stack, message } = cause;
|
|
515
|
+
if (typeof stack === 'string') {
|
|
516
|
+
return stack;
|
|
517
|
+
}
|
|
518
|
+
if (typeof message === 'string') {
|
|
519
|
+
return message;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
return String(cause);
|
|
484
523
|
}
|
|
@@ -22,6 +22,8 @@ export declare class LockFileChange implements Change {
|
|
|
22
22
|
export declare function isWholeFileChange(change: Change): change is WholeFileChange;
|
|
23
23
|
export declare function isDeletedFileChange(change: Change): change is DeletedFileChange;
|
|
24
24
|
export declare function isLockFileChange(change: Change): change is LockFileChange;
|
|
25
|
+
/** Whether a touched file was deleted. Much cheaper than `getChanges()`. */
|
|
26
|
+
export declare function isDeletedFile(file: string): boolean;
|
|
25
27
|
export declare function calculateFileChanges(files: string[], nxArgs?: NxArgs, readFileAtRevision?: {
|
|
26
28
|
(f: string, r: string | void): string;
|
|
27
29
|
}, ignore?: ReturnType<typeof ignore>): FileChange[];
|
|
@@ -4,6 +4,7 @@ exports.TEN_MEGABYTES = exports.LockFileChange = exports.DeletedFileChange = exp
|
|
|
4
4
|
exports.isWholeFileChange = isWholeFileChange;
|
|
5
5
|
exports.isDeletedFileChange = isDeletedFileChange;
|
|
6
6
|
exports.isLockFileChange = isLockFileChange;
|
|
7
|
+
exports.isDeletedFile = isDeletedFile;
|
|
7
8
|
exports.calculateFileChanges = calculateFileChanges;
|
|
8
9
|
exports.defaultFileRead = defaultFileRead;
|
|
9
10
|
exports.readPackageJson = readPackageJson;
|
|
@@ -53,6 +54,10 @@ const TEXT_LOCK_FILES = new Set([
|
|
|
53
54
|
'bun.lock',
|
|
54
55
|
]);
|
|
55
56
|
const BINARY_LOCK_FILES = new Set(['bun.lockb']);
|
|
57
|
+
/** Whether a touched file was deleted. Much cheaper than `getChanges()`. */
|
|
58
|
+
function isDeletedFile(file) {
|
|
59
|
+
return !(0, fs_1.existsSync)((0, path_1.join)(workspace_root_1.workspaceRoot, file));
|
|
60
|
+
}
|
|
56
61
|
function calculateFileChanges(files, nxArgs, readFileAtRevision = defaultReadFileAtRevision, ignore = (0, ignore_1.getIgnoreObject)()) {
|
|
57
62
|
files = files.filter((f) => !ignore.ignores(f));
|
|
58
63
|
return files.map((f) => {
|
|
@@ -61,7 +66,7 @@ function calculateFileChanges(files, nxArgs, readFileAtRevision = defaultReadFil
|
|
|
61
66
|
return {
|
|
62
67
|
file: f,
|
|
63
68
|
getChanges: () => {
|
|
64
|
-
if (
|
|
69
|
+
if (isDeletedFile(f)) {
|
|
65
70
|
return [new DeletedFileChange()];
|
|
66
71
|
}
|
|
67
72
|
if (!nxArgs) {
|
|
@@ -17,7 +17,10 @@ export declare const nxFileMap: string;
|
|
|
17
17
|
export declare const nxSourceMaps: string;
|
|
18
18
|
export declare function ensureCacheDirectory(): void;
|
|
19
19
|
export declare function readFileMapCache(): null | FileMapCache;
|
|
20
|
-
export declare function readProjectGraphCache(minimumComputedAt?: number): null |
|
|
20
|
+
export declare function readProjectGraphCache(minimumComputedAt?: number): null | {
|
|
21
|
+
projectGraph: ProjectGraph;
|
|
22
|
+
computedAt: number | undefined;
|
|
23
|
+
};
|
|
21
24
|
export declare function readSourceMapsCache(): null | ConfigurationSourceMaps;
|
|
22
25
|
export declare function createProjectFileMapCache(nxJson: NxJsonConfiguration<'*' | string[]>, packageJsonDeps: Record<string, string>, fileMap: FileMap, tsConfig: {
|
|
23
26
|
compilerOptions?: {
|
|
@@ -26,7 +29,7 @@ export declare function createProjectFileMapCache(nxJson: NxJsonConfiguration<'*
|
|
|
26
29
|
};
|
|
27
30
|
};
|
|
28
31
|
}, externalNodesHash: string): FileMapCache;
|
|
29
|
-
export declare function writeCache(cache: FileMapCache, projectGraph: ProjectGraph, sourceMaps: ConfigurationSourceMaps, errors: ProjectGraphErrorTypes[]): void;
|
|
32
|
+
export declare function writeCache(cache: FileMapCache, projectGraph: ProjectGraph, sourceMaps: ConfigurationSourceMaps, errors: ProjectGraphErrorTypes[], computedAt: number): void;
|
|
30
33
|
/**
|
|
31
34
|
* Writes the cache only if the on-disk cache file has been modified since
|
|
32
35
|
* this process last wrote it (i.e. an external process overwrote it), or
|
|
@@ -83,7 +83,7 @@ function readProjectGraphCache(minimumComputedAt) {
|
|
|
83
83
|
}
|
|
84
84
|
throw new error_types_1.ProjectGraphError(errors, projectGraphCache, readSourceMapsCache());
|
|
85
85
|
}
|
|
86
|
-
return projectGraphCache;
|
|
86
|
+
return { projectGraph: projectGraphCache, computedAt };
|
|
87
87
|
}
|
|
88
88
|
else {
|
|
89
89
|
return null;
|
|
@@ -140,7 +140,7 @@ function createProjectFileMapCache(nxJson, packageJsonDeps, fileMap, tsConfig, e
|
|
|
140
140
|
* when no external process has modified the cache file since the last write.
|
|
141
141
|
*/
|
|
142
142
|
let lastWrittenCacheMtimeMs;
|
|
143
|
-
function writeCache(cache, projectGraph, sourceMaps, errors) {
|
|
143
|
+
function writeCache(cache, projectGraph, sourceMaps, errors, computedAt) {
|
|
144
144
|
perf_hooks_1.performance.mark('write cache:start');
|
|
145
145
|
let retry = 1;
|
|
146
146
|
let done = false;
|
|
@@ -158,7 +158,7 @@ function writeCache(cache, projectGraph, sourceMaps, errors) {
|
|
|
158
158
|
(0, fileutils_1.writeJsonFile)(tmpProjectGraphPath, {
|
|
159
159
|
...projectGraph,
|
|
160
160
|
errors,
|
|
161
|
-
computedAt
|
|
161
|
+
computedAt,
|
|
162
162
|
});
|
|
163
163
|
(0, node_fs_1.renameSync)(tmpProjectGraphPath, exports.nxProjectGraph);
|
|
164
164
|
(0, fileutils_1.writeJsonFile)(tmpSourceMapPath, sourceMaps);
|
|
@@ -221,7 +221,7 @@ function writeCacheIfStale(cache, projectGraph, sourceMaps, errors) {
|
|
|
221
221
|
// File doesn't exist or can't be stat'd — proceed with write
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
|
-
writeCache(cache, projectGraph, sourceMaps, errors);
|
|
224
|
+
writeCache(cache, projectGraph, sourceMaps, errors, Date.now());
|
|
225
225
|
}
|
|
226
226
|
function shouldRecomputeWholeGraph(cache, packageJsonDeps, projects, nxJson, tsConfig, externalNodesHash) {
|
|
227
227
|
if (cache.version !== '6.0') {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { NxJsonConfiguration, PluginConfiguration } from '../../config/nx-json';
|
|
2
|
+
import { type NxPluginCapabilities } from './nx-plugin-capabilities';
|
|
2
3
|
import type { LoadedNxPlugin } from './loaded-nx-plugin';
|
|
3
4
|
export interface SeparatedPlugins {
|
|
4
5
|
specifiedPlugins: LoadedNxPlugin[];
|
|
@@ -21,7 +22,7 @@ export declare function resetIsolationFallbackForTesting(): void;
|
|
|
21
22
|
* threw is rethrown, because rerunning it in-process would bury its actual
|
|
22
23
|
* error.
|
|
23
24
|
*/
|
|
24
|
-
export declare const loadingMethod: (plugin: PluginConfiguration, root: string, index?: number) => Promise<
|
|
25
|
+
export declare const loadingMethod: (plugin: PluginConfiguration, root: string, index?: number) => Promise<LoadedNxPlugin>;
|
|
25
26
|
/**
|
|
26
27
|
* Returns all plugins (specified + default) as a flat list.
|
|
27
28
|
* Specified plugins come first, followed by default plugins.
|
|
@@ -48,4 +49,5 @@ export declare function getOnlyDefaultPlugins(root?: string): Promise<LoadedNxPl
|
|
|
48
49
|
*/
|
|
49
50
|
export declare function getPluginsIfLoadedOrLoading(): Promise<LoadedNxPlugin[]> | undefined;
|
|
50
51
|
export declare function cleanupPlugins(): void;
|
|
52
|
+
export declare function capabilitiesOfConfiguredPlugins(nxJson: NxJsonConfiguration, root?: string): Promise<NxPluginCapabilities[]>;
|
|
51
53
|
export declare function reasonToError(reason: unknown): Error;
|