nx 19.6.0-beta.1 → 19.6.0-beta.2
Sign up to get free protection for your applications and to get access to all the features.
- package/bin/post-install.js +8 -0
- package/package.json +12 -12
- package/schemas/nx-schema.json +25 -0
- package/schemas/project-schema.json +7 -0
- package/src/adapter/compat.d.ts +1 -1
- package/src/adapter/compat.js +1 -0
- package/src/command-line/nx-commands.js +3 -0
- package/src/command-line/sync/command-object.d.ts +6 -0
- package/src/command-line/sync/command-object.js +25 -0
- package/src/command-line/sync/sync.d.ts +6 -0
- package/src/command-line/sync/sync.js +30 -0
- package/src/config/nx-json.d.ts +23 -0
- package/src/config/workspace-json-project-json.d.ts +5 -0
- package/src/daemon/client/client.d.ts +5 -0
- package/src/daemon/client/client.js +33 -0
- package/src/daemon/message-types/flush-sync-generator-changes-to-disk.d.ts +6 -0
- package/src/daemon/message-types/flush-sync-generator-changes-to-disk.js +11 -0
- package/src/daemon/message-types/get-registered-sync-generators.d.ts +5 -0
- package/src/daemon/message-types/get-registered-sync-generators.js +11 -0
- package/src/daemon/message-types/get-sync-generator-changes.d.ts +6 -0
- package/src/daemon/message-types/get-sync-generator-changes.js +11 -0
- package/src/daemon/message-types/update-workspace-context.d.ts +8 -0
- package/src/daemon/message-types/update-workspace-context.js +11 -0
- package/src/daemon/server/handle-flush-sync-generator-changes-to-disk.d.ts +2 -0
- package/src/daemon/server/handle-flush-sync-generator-changes-to-disk.js +11 -0
- package/src/daemon/server/handle-get-registered-sync-generators.d.ts +2 -0
- package/src/daemon/server/handle-get-registered-sync-generators.js +11 -0
- package/src/daemon/server/handle-get-sync-generator-changes.d.ts +2 -0
- package/src/daemon/server/handle-get-sync-generator-changes.js +17 -0
- package/src/daemon/server/handle-update-workspace-context.d.ts +2 -0
- package/src/daemon/server/handle-update-workspace-context.js +11 -0
- package/src/daemon/server/project-graph-incremental-recomputation.d.ts +1 -0
- package/src/daemon/server/project-graph-incremental-recomputation.js +19 -2
- package/src/daemon/server/server.js +25 -0
- package/src/daemon/server/sync-generators.d.ts +6 -0
- package/src/daemon/server/sync-generators.js +202 -0
- package/src/daemon/socket-utils.js +18 -5
- package/src/daemon/tmp-dir.js +2 -1
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +1 -1
- package/src/tasks-runner/run-command.d.ts +1 -1
- package/src/tasks-runner/run-command.js +120 -2
- package/src/utils/plugins/output.js +1 -1
- package/src/utils/sync-generators.d.ts +22 -0
- package/src/utils/sync-generators.js +161 -0
- package/src/utils/workspace-context.d.ts +1 -0
- package/src/utils/workspace-context.js +16 -0
- package/src/daemon/message-types/update-context-files.d.ts +0 -7
- package/src/daemon/message-types/update-context-files.js +0 -11
package/bin/post-install.js
CHANGED
@@ -53,3 +53,11 @@ function isMainNxPackage() {
|
|
53
53
|
const thisNxPath = require.resolve('nx');
|
54
54
|
return mainNxPath === thisNxPath;
|
55
55
|
}
|
56
|
+
process.on('uncaughtException', (e) => {
|
57
|
+
logger_1.logger.verbose(e);
|
58
|
+
process.exit(0);
|
59
|
+
});
|
60
|
+
process.on('unhandledRejection', (e) => {
|
61
|
+
logger_1.logger.verbose(e);
|
62
|
+
process.exit(0);
|
63
|
+
});
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "nx",
|
3
|
-
"version": "19.6.0-beta.
|
3
|
+
"version": "19.6.0-beta.2",
|
4
4
|
"private": false,
|
5
5
|
"description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
|
6
6
|
"repository": {
|
@@ -71,7 +71,7 @@
|
|
71
71
|
"yargs-parser": "21.1.1",
|
72
72
|
"node-machine-id": "1.1.12",
|
73
73
|
"ora": "5.3.0",
|
74
|
-
"@nrwl/tao": "19.6.0-beta.
|
74
|
+
"@nrwl/tao": "19.6.0-beta.2"
|
75
75
|
},
|
76
76
|
"peerDependencies": {
|
77
77
|
"@swc-node/register": "^1.8.0",
|
@@ -86,16 +86,16 @@
|
|
86
86
|
}
|
87
87
|
},
|
88
88
|
"optionalDependencies": {
|
89
|
-
"@nx/nx-darwin-x64": "19.6.0-beta.
|
90
|
-
"@nx/nx-darwin-arm64": "19.6.0-beta.
|
91
|
-
"@nx/nx-linux-x64-gnu": "19.6.0-beta.
|
92
|
-
"@nx/nx-linux-x64-musl": "19.6.0-beta.
|
93
|
-
"@nx/nx-win32-x64-msvc": "19.6.0-beta.
|
94
|
-
"@nx/nx-linux-arm64-gnu": "19.6.0-beta.
|
95
|
-
"@nx/nx-linux-arm64-musl": "19.6.0-beta.
|
96
|
-
"@nx/nx-linux-arm-gnueabihf": "19.6.0-beta.
|
97
|
-
"@nx/nx-win32-arm64-msvc": "19.6.0-beta.
|
98
|
-
"@nx/nx-freebsd-x64": "19.6.0-beta.
|
89
|
+
"@nx/nx-darwin-x64": "19.6.0-beta.2",
|
90
|
+
"@nx/nx-darwin-arm64": "19.6.0-beta.2",
|
91
|
+
"@nx/nx-linux-x64-gnu": "19.6.0-beta.2",
|
92
|
+
"@nx/nx-linux-x64-musl": "19.6.0-beta.2",
|
93
|
+
"@nx/nx-win32-x64-msvc": "19.6.0-beta.2",
|
94
|
+
"@nx/nx-linux-arm64-gnu": "19.6.0-beta.2",
|
95
|
+
"@nx/nx-linux-arm64-musl": "19.6.0-beta.2",
|
96
|
+
"@nx/nx-linux-arm-gnueabihf": "19.6.0-beta.2",
|
97
|
+
"@nx/nx-win32-arm64-msvc": "19.6.0-beta.2",
|
98
|
+
"@nx/nx-freebsd-x64": "19.6.0-beta.2"
|
99
99
|
},
|
100
100
|
"nx-migrations": {
|
101
101
|
"migrations": "./migrations.json",
|
package/schemas/nx-schema.json
CHANGED
@@ -246,6 +246,31 @@
|
|
246
246
|
"type": "string"
|
247
247
|
}
|
248
248
|
}
|
249
|
+
},
|
250
|
+
"sync": {
|
251
|
+
"type": "object",
|
252
|
+
"description": "Configuration for the `nx sync` command",
|
253
|
+
"properties": {
|
254
|
+
"globalGenerators": {
|
255
|
+
"type": "array",
|
256
|
+
"items": {
|
257
|
+
"type": "string"
|
258
|
+
},
|
259
|
+
"description": "List of workspace-wide sync generators to be run (not attached to targets)"
|
260
|
+
},
|
261
|
+
"generatorOptions": {
|
262
|
+
"type": "object",
|
263
|
+
"description": "Options for the sync generators.",
|
264
|
+
"additionalProperties": {
|
265
|
+
"type": "object"
|
266
|
+
}
|
267
|
+
},
|
268
|
+
"applyChanges": {
|
269
|
+
"type": "boolean",
|
270
|
+
"description": "Whether to automatically apply sync generator changes when running tasks. If not set, the user will be prompted. If set to `true`, the user will not be prompted and the changes will be applied. If set to `false`, the user will not be prompted and the changes will not be applied."
|
271
|
+
}
|
272
|
+
},
|
273
|
+
"additionalProperties": false
|
249
274
|
}
|
250
275
|
},
|
251
276
|
"definitions": {
|
@@ -153,6 +153,13 @@
|
|
153
153
|
}
|
154
154
|
},
|
155
155
|
"additionalProperties": true
|
156
|
+
},
|
157
|
+
"syncGenerators": {
|
158
|
+
"type": "array",
|
159
|
+
"items": {
|
160
|
+
"type": "string"
|
161
|
+
},
|
162
|
+
"description": "List of generators to run before the target to ensure the workspace is up to date"
|
156
163
|
}
|
157
164
|
}
|
158
165
|
}
|
package/src/adapter/compat.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
export declare const allowedProjectExtensions: readonly ["tags", "implicitDependencies", "configFilePath", "$schema", "generators", "namedInputs", "name", "files", "root", "sourceRoot", "projectType", "release", "includedScripts", "metadata"];
|
2
|
-
export declare const allowedWorkspaceExtensions: readonly ["implicitDependencies", "affected", "defaultBase", "tasksRunnerOptions", "workspaceLayout", "plugins", "targetDefaults", "files", "generators", "namedInputs", "extends", "cli", "pluginsConfig", "defaultProject", "installation", "release", "nxCloudAccessToken", "nxCloudId", "nxCloudUrl", "nxCloudEncryptionKey", "parallel", "cacheDirectory", "useDaemonProcess", "useInferencePlugins", "neverConnectToCloud"];
|
2
|
+
export declare const allowedWorkspaceExtensions: readonly ["implicitDependencies", "affected", "defaultBase", "tasksRunnerOptions", "workspaceLayout", "plugins", "targetDefaults", "files", "generators", "namedInputs", "extends", "cli", "pluginsConfig", "defaultProject", "installation", "release", "nxCloudAccessToken", "nxCloudId", "nxCloudUrl", "nxCloudEncryptionKey", "parallel", "cacheDirectory", "useDaemonProcess", "useInferencePlugins", "neverConnectToCloud", "sync"];
|
package/src/adapter/compat.js
CHANGED
@@ -24,6 +24,7 @@ const command_object_18 = require("./reset/command-object");
|
|
24
24
|
const command_object_19 = require("./release/command-object");
|
25
25
|
const command_object_20 = require("./add/command-object");
|
26
26
|
const command_objects_1 = require("./deprecated/command-objects");
|
27
|
+
const command_object_21 = require("./sync/command-object");
|
27
28
|
// Ensure that the output takes up the available width of the terminal.
|
28
29
|
yargs.wrap(yargs.terminalWidth());
|
29
30
|
exports.parserConfiguration = {
|
@@ -67,6 +68,8 @@ exports.commandsObject = yargs
|
|
67
68
|
.command(command_object_14.yargsRunCommand)
|
68
69
|
.command(command_object_15.yargsRunManyCommand)
|
69
70
|
.command(command_object_16.yargsShowCommand)
|
71
|
+
.command(command_object_21.yargsSyncCommand)
|
72
|
+
.command(command_object_21.yargsSyncCheckCommand)
|
70
73
|
.command(command_object_2.yargsViewLogsCommand)
|
71
74
|
.command(command_object_17.yargsWatchCommand)
|
72
75
|
.command(command_object_14.yargsNxInfixCommand)
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import type { CommandModule } from 'yargs';
|
2
|
+
export interface SyncArgs {
|
3
|
+
verbose?: boolean;
|
4
|
+
}
|
5
|
+
export declare const yargsSyncCommand: CommandModule<Record<string, unknown>, SyncArgs>;
|
6
|
+
export declare const yargsSyncCheckCommand: CommandModule<Record<string, unknown>, SyncArgs>;
|
@@ -0,0 +1,25 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.yargsSyncCheckCommand = exports.yargsSyncCommand = void 0;
|
4
|
+
exports.yargsSyncCommand = {
|
5
|
+
command: 'sync',
|
6
|
+
describe: false,
|
7
|
+
builder: (yargs) => yargs.option('verbose', {
|
8
|
+
type: 'boolean',
|
9
|
+
description: 'Prints additional information about the commands (e.g., stack traces)',
|
10
|
+
}),
|
11
|
+
handler: async (args) => {
|
12
|
+
process.exit(await Promise.resolve().then(() => require('./sync')).then((m) => m.syncHandler(args)));
|
13
|
+
},
|
14
|
+
};
|
15
|
+
exports.yargsSyncCheckCommand = {
|
16
|
+
command: 'sync:check',
|
17
|
+
describe: false,
|
18
|
+
builder: (yargs) => yargs.option('verbose', {
|
19
|
+
type: 'boolean',
|
20
|
+
description: 'Prints additional information about the commands (e.g., stack traces)',
|
21
|
+
}),
|
22
|
+
handler: async (args) => {
|
23
|
+
process.exit(await Promise.resolve().then(() => require('./sync')).then((m) => m.syncHandler({ ...args, check: true })));
|
24
|
+
},
|
25
|
+
};
|
@@ -0,0 +1,30 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.syncHandler = syncHandler;
|
4
|
+
const project_graph_1 = require("../../project-graph/project-graph");
|
5
|
+
const output_1 = require("../../utils/output");
|
6
|
+
const params_1 = require("../../utils/params");
|
7
|
+
const sync_generators_1 = require("../../utils/sync-generators");
|
8
|
+
function syncHandler(options) {
|
9
|
+
if (options.verbose) {
|
10
|
+
process.env.NX_VERBOSE_LOGGING = 'true';
|
11
|
+
}
|
12
|
+
const isVerbose = process.env.NX_VERBOSE_LOGGING === 'true';
|
13
|
+
return (0, params_1.handleErrors)(isVerbose, async () => {
|
14
|
+
const projectGraph = await (0, project_graph_1.createProjectGraphAsync)();
|
15
|
+
const syncGenerators = await (0, sync_generators_1.collectAllRegisteredSyncGenerators)(projectGraph);
|
16
|
+
const results = await (0, sync_generators_1.getSyncGeneratorChanges)(syncGenerators);
|
17
|
+
if (!results.length) {
|
18
|
+
return 0;
|
19
|
+
}
|
20
|
+
if (options.check) {
|
21
|
+
output_1.output.error({
|
22
|
+
title: `The workspace is out of sync`,
|
23
|
+
bodyLines: (0, sync_generators_1.syncGeneratorResultsToMessageLines)(results),
|
24
|
+
});
|
25
|
+
return 1;
|
26
|
+
}
|
27
|
+
await (0, sync_generators_1.flushSyncGeneratorChanges)(results);
|
28
|
+
return 0;
|
29
|
+
});
|
30
|
+
}
|
package/src/config/nx-json.d.ts
CHANGED
@@ -266,6 +266,25 @@ export interface NxReleaseConfiguration {
|
|
266
266
|
*/
|
267
267
|
versionPlans?: boolean;
|
268
268
|
}
|
269
|
+
export interface NxSyncConfiguration {
|
270
|
+
/**
|
271
|
+
* List of workspace-wide sync generators to be run (not attached to targets).
|
272
|
+
*/
|
273
|
+
globalGenerators?: string[];
|
274
|
+
/**
|
275
|
+
* Options for the sync generators.
|
276
|
+
*/
|
277
|
+
generatorOptions?: {
|
278
|
+
[generatorName: string]: Record<string, unknown>;
|
279
|
+
};
|
280
|
+
/**
|
281
|
+
* Whether to automatically apply sync generator changes when running tasks.
|
282
|
+
* If not set, the user will be prompted.
|
283
|
+
* If set to `true`, the user will not be prompted and the changes will be applied.
|
284
|
+
* If set to `false`, the user will not be prompted and the changes will not be applied.
|
285
|
+
*/
|
286
|
+
applyChanges?: boolean;
|
287
|
+
}
|
269
288
|
/**
|
270
289
|
* Nx.json configuration
|
271
290
|
*
|
@@ -413,6 +432,10 @@ export interface NxJsonConfiguration<T = '*' | string[]> {
|
|
413
432
|
* Set this to false to disable connection to Nx Cloud
|
414
433
|
*/
|
415
434
|
neverConnectToCloud?: boolean;
|
435
|
+
/**
|
436
|
+
* Configuration for the `nx sync` command.
|
437
|
+
*/
|
438
|
+
sync?: NxSyncConfiguration;
|
416
439
|
}
|
417
440
|
export type PluginConfiguration = string | ExpandedPluginConfiguration;
|
418
441
|
export type ExpandedPluginConfiguration<T = unknown> = {
|
@@ -5,6 +5,7 @@ import { Task, TaskGraph } from '../../config/task-graph';
|
|
5
5
|
import { ConfigurationSourceMaps } from '../../project-graph/utils/project-configuration-utils';
|
6
6
|
import { NxWorkspaceFiles } from '../../native';
|
7
7
|
import { TaskRun } from '../../utils/task-history';
|
8
|
+
import type { SyncGeneratorChangesResult } from '../../utils/sync-generators';
|
8
9
|
export type UnregisterCallback = () => void;
|
9
10
|
export type ChangedFile = {
|
10
11
|
path: string;
|
@@ -54,6 +55,10 @@ export declare class DaemonClient {
|
|
54
55
|
[hash: string]: TaskRun[];
|
55
56
|
}>;
|
56
57
|
writeTaskRunsToHistory(taskRuns: TaskRun[]): Promise<void>;
|
58
|
+
getSyncGeneratorChanges(generators: string[]): Promise<SyncGeneratorChangesResult[]>;
|
59
|
+
flushSyncGeneratorChangesToDisk(generators: string[]): Promise<void>;
|
60
|
+
getRegisteredSyncGenerators(): Promise<string[]>;
|
61
|
+
updateWorkspaceContext(createdFiles: string[], updatedFiles: string[], deletedFiles: string[]): Promise<void>;
|
57
62
|
isServerAvailable(): Promise<boolean>;
|
58
63
|
private sendToDaemonViaQueue;
|
59
64
|
private setUpConnection;
|
@@ -26,6 +26,10 @@ const get_context_file_data_1 = require("../message-types/get-context-file-data"
|
|
26
26
|
const get_files_in_directory_1 = require("../message-types/get-files-in-directory");
|
27
27
|
const hash_glob_1 = require("../message-types/hash-glob");
|
28
28
|
const force_shutdown_1 = require("../message-types/force-shutdown");
|
29
|
+
const get_sync_generator_changes_1 = require("../message-types/get-sync-generator-changes");
|
30
|
+
const get_registered_sync_generators_1 = require("../message-types/get-registered-sync-generators");
|
31
|
+
const update_workspace_context_1 = require("../message-types/update-workspace-context");
|
32
|
+
const flush_sync_generator_changes_to_disk_1 = require("../message-types/flush-sync-generator-changes-to-disk");
|
29
33
|
const DAEMON_ENV_SETTINGS = {
|
30
34
|
NX_PROJECT_GLOB_CACHE: 'false',
|
31
35
|
NX_CACHE_PROJECTS_CONFIG: 'false',
|
@@ -245,6 +249,35 @@ class DaemonClient {
|
|
245
249
|
};
|
246
250
|
return this.sendMessageToDaemon(message);
|
247
251
|
}
|
252
|
+
getSyncGeneratorChanges(generators) {
|
253
|
+
const message = {
|
254
|
+
type: get_sync_generator_changes_1.GET_SYNC_GENERATOR_CHANGES,
|
255
|
+
generators,
|
256
|
+
};
|
257
|
+
return this.sendToDaemonViaQueue(message);
|
258
|
+
}
|
259
|
+
flushSyncGeneratorChangesToDisk(generators) {
|
260
|
+
const message = {
|
261
|
+
type: flush_sync_generator_changes_to_disk_1.FLUSH_SYNC_GENERATOR_CHANGES_TO_DISK,
|
262
|
+
generators,
|
263
|
+
};
|
264
|
+
return this.sendToDaemonViaQueue(message);
|
265
|
+
}
|
266
|
+
getRegisteredSyncGenerators() {
|
267
|
+
const message = {
|
268
|
+
type: get_registered_sync_generators_1.GET_REGISTERED_SYNC_GENERATORS,
|
269
|
+
};
|
270
|
+
return this.sendToDaemonViaQueue(message);
|
271
|
+
}
|
272
|
+
updateWorkspaceContext(createdFiles, updatedFiles, deletedFiles) {
|
273
|
+
const message = {
|
274
|
+
type: update_workspace_context_1.UPDATE_WORKSPACE_CONTEXT,
|
275
|
+
createdFiles,
|
276
|
+
updatedFiles,
|
277
|
+
deletedFiles,
|
278
|
+
};
|
279
|
+
return this.sendToDaemonViaQueue(message);
|
280
|
+
}
|
248
281
|
async isServerAvailable() {
|
249
282
|
return new Promise((resolve) => {
|
250
283
|
try {
|
@@ -0,0 +1,6 @@
|
|
1
|
+
export declare const FLUSH_SYNC_GENERATOR_CHANGES_TO_DISK: "CLEAR_CACHED_SYNC_GENERATOR_CHANGES";
|
2
|
+
export type HandleFlushSyncGeneratorChangesToDiskMessage = {
|
3
|
+
type: typeof FLUSH_SYNC_GENERATOR_CHANGES_TO_DISK;
|
4
|
+
generators: string[];
|
5
|
+
};
|
6
|
+
export declare function isHandleFlushSyncGeneratorChangesToDiskMessage(message: unknown): message is HandleFlushSyncGeneratorChangesToDiskMessage;
|
@@ -0,0 +1,11 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.FLUSH_SYNC_GENERATOR_CHANGES_TO_DISK = void 0;
|
4
|
+
exports.isHandleFlushSyncGeneratorChangesToDiskMessage = isHandleFlushSyncGeneratorChangesToDiskMessage;
|
5
|
+
exports.FLUSH_SYNC_GENERATOR_CHANGES_TO_DISK = 'CLEAR_CACHED_SYNC_GENERATOR_CHANGES';
|
6
|
+
function isHandleFlushSyncGeneratorChangesToDiskMessage(message) {
|
7
|
+
return (typeof message === 'object' &&
|
8
|
+
message !== null &&
|
9
|
+
'type' in message &&
|
10
|
+
message['type'] === exports.FLUSH_SYNC_GENERATOR_CHANGES_TO_DISK);
|
11
|
+
}
|
@@ -0,0 +1,5 @@
|
|
1
|
+
export declare const GET_REGISTERED_SYNC_GENERATORS: "GET_REGISTERED_SYNC_GENERATORS";
|
2
|
+
export type HandleGetRegisteredSyncGeneratorsMessage = {
|
3
|
+
type: typeof GET_REGISTERED_SYNC_GENERATORS;
|
4
|
+
};
|
5
|
+
export declare function isHandleGetRegisteredSyncGeneratorsMessage(message: unknown): message is HandleGetRegisteredSyncGeneratorsMessage;
|
@@ -0,0 +1,11 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.GET_REGISTERED_SYNC_GENERATORS = void 0;
|
4
|
+
exports.isHandleGetRegisteredSyncGeneratorsMessage = isHandleGetRegisteredSyncGeneratorsMessage;
|
5
|
+
exports.GET_REGISTERED_SYNC_GENERATORS = 'GET_REGISTERED_SYNC_GENERATORS';
|
6
|
+
function isHandleGetRegisteredSyncGeneratorsMessage(message) {
|
7
|
+
return (typeof message === 'object' &&
|
8
|
+
message !== null &&
|
9
|
+
'type' in message &&
|
10
|
+
message['type'] === exports.GET_REGISTERED_SYNC_GENERATORS);
|
11
|
+
}
|
@@ -0,0 +1,6 @@
|
|
1
|
+
export declare const GET_SYNC_GENERATOR_CHANGES: "GET_SYNC_GENERATOR_CHANGES";
|
2
|
+
export type HandleGetSyncGeneratorChangesMessage = {
|
3
|
+
type: typeof GET_SYNC_GENERATOR_CHANGES;
|
4
|
+
generators: string[];
|
5
|
+
};
|
6
|
+
export declare function isHandleGetSyncGeneratorChangesMessage(message: unknown): message is HandleGetSyncGeneratorChangesMessage;
|
@@ -0,0 +1,11 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.GET_SYNC_GENERATOR_CHANGES = void 0;
|
4
|
+
exports.isHandleGetSyncGeneratorChangesMessage = isHandleGetSyncGeneratorChangesMessage;
|
5
|
+
exports.GET_SYNC_GENERATOR_CHANGES = 'GET_SYNC_GENERATOR_CHANGES';
|
6
|
+
function isHandleGetSyncGeneratorChangesMessage(message) {
|
7
|
+
return (typeof message === 'object' &&
|
8
|
+
message !== null &&
|
9
|
+
'type' in message &&
|
10
|
+
message['type'] === exports.GET_SYNC_GENERATOR_CHANGES);
|
11
|
+
}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
export declare const UPDATE_WORKSPACE_CONTEXT: "UPDATE_WORKSPACE_CONTEXT";
|
2
|
+
export type HandleUpdateWorkspaceContextMessage = {
|
3
|
+
type: typeof UPDATE_WORKSPACE_CONTEXT;
|
4
|
+
createdFiles: string[];
|
5
|
+
updatedFiles: string[];
|
6
|
+
deletedFiles: string[];
|
7
|
+
};
|
8
|
+
export declare function isHandleUpdateWorkspaceContextMessage(message: unknown): message is HandleUpdateWorkspaceContextMessage;
|
@@ -0,0 +1,11 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.UPDATE_WORKSPACE_CONTEXT = void 0;
|
4
|
+
exports.isHandleUpdateWorkspaceContextMessage = isHandleUpdateWorkspaceContextMessage;
|
5
|
+
exports.UPDATE_WORKSPACE_CONTEXT = 'UPDATE_WORKSPACE_CONTEXT';
|
6
|
+
function isHandleUpdateWorkspaceContextMessage(message) {
|
7
|
+
return (typeof message === 'object' &&
|
8
|
+
message !== null &&
|
9
|
+
'type' in message &&
|
10
|
+
message['type'] === exports.UPDATE_WORKSPACE_CONTEXT);
|
11
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.handleFlushSyncGeneratorChangesToDisk = handleFlushSyncGeneratorChangesToDisk;
|
4
|
+
const sync_generators_1 = require("./sync-generators");
|
5
|
+
async function handleFlushSyncGeneratorChangesToDisk(generators) {
|
6
|
+
await (0, sync_generators_1.flushSyncGeneratorChangesToDisk)(generators);
|
7
|
+
return {
|
8
|
+
response: '{}',
|
9
|
+
description: 'handleFlushSyncGeneratorChangesToDisk',
|
10
|
+
};
|
11
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.handleGetRegisteredSyncGenerators = handleGetRegisteredSyncGenerators;
|
4
|
+
const sync_generators_1 = require("./sync-generators");
|
5
|
+
async function handleGetRegisteredSyncGenerators() {
|
6
|
+
const syncGenerators = await (0, sync_generators_1.getCachedRegisteredSyncGenerators)();
|
7
|
+
return {
|
8
|
+
response: JSON.stringify(syncGenerators),
|
9
|
+
description: 'handleGetSyncGeneratorChanges',
|
10
|
+
};
|
11
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.handleGetSyncGeneratorChanges = handleGetSyncGeneratorChanges;
|
4
|
+
const sync_generators_1 = require("./sync-generators");
|
5
|
+
async function handleGetSyncGeneratorChanges(generators) {
|
6
|
+
const changes = await (0, sync_generators_1.getCachedSyncGeneratorChanges)(generators);
|
7
|
+
// strip out the content of the changes and any potential callback
|
8
|
+
const result = changes.map((change) => ({
|
9
|
+
generatorName: change.generatorName,
|
10
|
+
changes: change.changes.map((c) => ({ ...c, content: null })),
|
11
|
+
outOfSyncMessage: change.outOfSyncMessage,
|
12
|
+
}));
|
13
|
+
return {
|
14
|
+
response: JSON.stringify(result),
|
15
|
+
description: 'handleGetSyncGeneratorChanges',
|
16
|
+
};
|
17
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.handleUpdateWorkspaceContext = handleUpdateWorkspaceContext;
|
4
|
+
const project_graph_incremental_recomputation_1 = require("./project-graph-incremental-recomputation");
|
5
|
+
async function handleUpdateWorkspaceContext(createdFiles, updatedFiles, deletedFiles) {
|
6
|
+
(0, project_graph_incremental_recomputation_1.addUpdatedAndDeletedFiles)(createdFiles, updatedFiles, deletedFiles);
|
7
|
+
return {
|
8
|
+
response: '{}',
|
9
|
+
description: 'handleUpdateContextFiles',
|
10
|
+
};
|
11
|
+
}
|
@@ -20,4 +20,5 @@ export declare let currentProjectFileMapCache: FileMapCache | undefined;
|
|
20
20
|
export declare let currentProjectGraph: ProjectGraph | undefined;
|
21
21
|
export declare function getCachedSerializedProjectGraphPromise(): Promise<SerializedProjectGraph>;
|
22
22
|
export declare function addUpdatedAndDeletedFiles(createdFiles: string[], updatedFiles: string[], deletedFiles: string[]): void;
|
23
|
+
export declare function registerProjectGraphRecomputationListener(listener: (projectGraph: ProjectGraph) => void): void;
|
23
24
|
export {};
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.currentProjectGraph = exports.currentProjectFileMapCache = exports.fileMapWithFiles = void 0;
|
4
4
|
exports.getCachedSerializedProjectGraphPromise = getCachedSerializedProjectGraphPromise;
|
5
5
|
exports.addUpdatedAndDeletedFiles = addUpdatedAndDeletedFiles;
|
6
|
+
exports.registerProjectGraphRecomputationListener = registerProjectGraphRecomputationListener;
|
6
7
|
const perf_hooks_1 = require("perf_hooks");
|
7
8
|
const nx_json_1 = require("../../config/nx-json");
|
8
9
|
const file_hasher_1 = require("../../hasher/file-hasher");
|
@@ -20,14 +21,17 @@ const error_types_1 = require("../../project-graph/error-types");
|
|
20
21
|
let cachedSerializedProjectGraphPromise;
|
21
22
|
const collectedUpdatedFiles = new Set();
|
22
23
|
const collectedDeletedFiles = new Set();
|
24
|
+
const projectGraphRecomputationListeners = new Set();
|
23
25
|
let storedWorkspaceConfigHash;
|
24
26
|
let waitPeriod = 100;
|
25
27
|
let scheduledTimeoutId;
|
26
28
|
let knownExternalNodes = {};
|
27
29
|
async function getCachedSerializedProjectGraphPromise() {
|
28
30
|
try {
|
31
|
+
let wasScheduled = false;
|
29
32
|
// recomputing it now on demand. we can ignore the scheduled timeout
|
30
33
|
if (scheduledTimeoutId) {
|
34
|
+
wasScheduled = true;
|
31
35
|
clearTimeout(scheduledTimeoutId);
|
32
36
|
scheduledTimeoutId = undefined;
|
33
37
|
}
|
@@ -45,7 +49,11 @@ async function getCachedSerializedProjectGraphPromise() {
|
|
45
49
|
cachedSerializedProjectGraphPromise =
|
46
50
|
processFilesAndCreateAndSerializeProjectGraph(plugins);
|
47
51
|
}
|
48
|
-
|
52
|
+
const result = await cachedSerializedProjectGraphPromise;
|
53
|
+
if (wasScheduled) {
|
54
|
+
notifyProjectGraphRecomputationListeners(result.projectGraph);
|
55
|
+
}
|
56
|
+
return result;
|
49
57
|
}
|
50
58
|
catch (e) {
|
51
59
|
return {
|
@@ -83,13 +91,17 @@ function addUpdatedAndDeletedFiles(createdFiles, updatedFiles, deletedFiles) {
|
|
83
91
|
}
|
84
92
|
cachedSerializedProjectGraphPromise =
|
85
93
|
processFilesAndCreateAndSerializeProjectGraph(await (0, plugins_1.getPlugins)());
|
86
|
-
await cachedSerializedProjectGraphPromise;
|
94
|
+
const { projectGraph } = await cachedSerializedProjectGraphPromise;
|
87
95
|
if (createdFiles.length > 0) {
|
88
96
|
(0, file_watcher_sockets_1.notifyFileWatcherSockets)(createdFiles, null, null);
|
89
97
|
}
|
98
|
+
notifyProjectGraphRecomputationListeners(projectGraph);
|
90
99
|
}, waitPeriod);
|
91
100
|
}
|
92
101
|
}
|
102
|
+
function registerProjectGraphRecomputationListener(listener) {
|
103
|
+
projectGraphRecomputationListeners.add(listener);
|
104
|
+
}
|
93
105
|
function computeWorkspaceConfigHash(projectsConfigurations) {
|
94
106
|
const projectConfigurationStrings = Object.entries(projectsConfigurations)
|
95
107
|
.sort(([projectNameA], [projectNameB]) => projectNameA.localeCompare(projectNameB))
|
@@ -281,3 +293,8 @@ async function resetInternalStateIfNxDepsMissing() {
|
|
281
293
|
await resetInternalState();
|
282
294
|
}
|
283
295
|
}
|
296
|
+
function notifyProjectGraphRecomputationListeners(projectGraph) {
|
297
|
+
for (const listener of projectGraphRecomputationListeners) {
|
298
|
+
listener(projectGraph);
|
299
|
+
}
|
300
|
+
}
|
@@ -42,6 +42,15 @@ const handle_get_task_history_1 = require("./handle-get-task-history");
|
|
42
42
|
const handle_write_task_runs_to_history_1 = require("./handle-write-task-runs-to-history");
|
43
43
|
const force_shutdown_1 = require("../message-types/force-shutdown");
|
44
44
|
const handle_force_shutdown_1 = require("./handle-force-shutdown");
|
45
|
+
const get_sync_generator_changes_1 = require("../message-types/get-sync-generator-changes");
|
46
|
+
const handle_get_sync_generator_changes_1 = require("./handle-get-sync-generator-changes");
|
47
|
+
const sync_generators_1 = require("./sync-generators");
|
48
|
+
const get_registered_sync_generators_1 = require("../message-types/get-registered-sync-generators");
|
49
|
+
const handle_get_registered_sync_generators_1 = require("./handle-get-registered-sync-generators");
|
50
|
+
const update_workspace_context_1 = require("../message-types/update-workspace-context");
|
51
|
+
const handle_update_workspace_context_1 = require("./handle-update-workspace-context");
|
52
|
+
const flush_sync_generator_changes_to_disk_1 = require("../message-types/flush-sync-generator-changes-to-disk");
|
53
|
+
const handle_flush_sync_generator_changes_to_disk_1 = require("./handle-flush-sync-generator-changes-to-disk");
|
45
54
|
let performanceObserver;
|
46
55
|
let workspaceWatcherError;
|
47
56
|
let outputsWatcherError;
|
@@ -140,6 +149,18 @@ async function handleMessage(socket, data) {
|
|
140
149
|
else if ((0, force_shutdown_1.isHandleForceShutdownMessage)(payload)) {
|
141
150
|
await handleResult(socket, 'FORCE_SHUTDOWN', () => (0, handle_force_shutdown_1.handleForceShutdown)(server));
|
142
151
|
}
|
152
|
+
else if ((0, get_sync_generator_changes_1.isHandleGetSyncGeneratorChangesMessage)(payload)) {
|
153
|
+
await handleResult(socket, get_sync_generator_changes_1.GET_SYNC_GENERATOR_CHANGES, () => (0, handle_get_sync_generator_changes_1.handleGetSyncGeneratorChanges)(payload.generators));
|
154
|
+
}
|
155
|
+
else if ((0, flush_sync_generator_changes_to_disk_1.isHandleFlushSyncGeneratorChangesToDiskMessage)(payload)) {
|
156
|
+
await handleResult(socket, flush_sync_generator_changes_to_disk_1.FLUSH_SYNC_GENERATOR_CHANGES_TO_DISK, () => (0, handle_flush_sync_generator_changes_to_disk_1.handleFlushSyncGeneratorChangesToDisk)(payload.generators));
|
157
|
+
}
|
158
|
+
else if ((0, get_registered_sync_generators_1.isHandleGetRegisteredSyncGeneratorsMessage)(payload)) {
|
159
|
+
await handleResult(socket, get_registered_sync_generators_1.GET_REGISTERED_SYNC_GENERATORS, () => (0, handle_get_registered_sync_generators_1.handleGetRegisteredSyncGenerators)());
|
160
|
+
}
|
161
|
+
else if ((0, update_workspace_context_1.isHandleUpdateWorkspaceContextMessage)(payload)) {
|
162
|
+
await handleResult(socket, update_workspace_context_1.UPDATE_WORKSPACE_CONTEXT, () => (0, handle_update_workspace_context_1.handleUpdateWorkspaceContext)(payload.createdFiles, payload.updatedFiles, payload.deletedFiles));
|
163
|
+
}
|
143
164
|
else {
|
144
165
|
await (0, shutdown_utils_1.respondWithErrorAndExit)(socket, `Invalid payload from the client`, new Error(`Unsupported payload sent to daemon server: ${unparsedPayload}`));
|
145
166
|
}
|
@@ -339,6 +360,10 @@ async function startServer() {
|
|
339
360
|
if (!(0, shutdown_utils_1.getOutputWatcherInstance)()) {
|
340
361
|
(0, shutdown_utils_1.storeOutputWatcherInstance)(await (0, watcher_1.watchOutputFiles)(handleOutputsChanges));
|
341
362
|
}
|
363
|
+
// listen for project graph recomputation events to collect and schedule sync generators
|
364
|
+
(0, project_graph_incremental_recomputation_1.registerProjectGraphRecomputationListener)(sync_generators_1.collectAndScheduleSyncGenerators);
|
365
|
+
// trigger an initial project graph recomputation
|
366
|
+
(0, project_graph_incremental_recomputation_1.addUpdatedAndDeletedFiles)([], [], []);
|
342
367
|
return resolve(server);
|
343
368
|
}
|
344
369
|
catch (err) {
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import type { ProjectGraph } from '../../config/project-graph';
|
2
|
+
import { type SyncGeneratorChangesResult } from '../../utils/sync-generators';
|
3
|
+
export declare function getCachedSyncGeneratorChanges(generators: string[]): Promise<SyncGeneratorChangesResult[]>;
|
4
|
+
export declare function flushSyncGeneratorChangesToDisk(generators: string[]): Promise<void>;
|
5
|
+
export declare function collectAndScheduleSyncGenerators(projectGraph: ProjectGraph): void;
|
6
|
+
export declare function getCachedRegisteredSyncGenerators(): Promise<string[]>;
|