nx 19.6.0-beta.1 → 19.6.0-beta.3
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 +55 -4
- 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/release/changelog.js +9 -9
- package/src/command-line/release/command-object.d.ts +12 -3
- package/src/command-line/release/command-object.js +16 -1
- package/src/command-line/release/config/config.js +4 -2
- package/src/command-line/release/config/filter-release-groups.d.ts +2 -2
- package/src/command-line/release/config/filter-release-groups.js +1 -1
- package/src/command-line/release/config/version-plans.d.ts +1 -1
- package/src/command-line/release/config/version-plans.js +12 -12
- package/src/command-line/release/plan-check.d.ts +4 -0
- package/src/command-line/release/plan-check.js +225 -0
- package/src/command-line/release/plan.js +1 -1
- package/src/command-line/release/release.js +3 -3
- package/src/command-line/release/version.js +1 -1
- 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 +32 -2
- 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/command-line-utils.js +1 -1
- 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
@@ -0,0 +1,161 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getSyncGeneratorChanges = getSyncGeneratorChanges;
|
4
|
+
exports.flushSyncGeneratorChanges = flushSyncGeneratorChanges;
|
5
|
+
exports.collectAllRegisteredSyncGenerators = collectAllRegisteredSyncGenerators;
|
6
|
+
exports.runSyncGenerator = runSyncGenerator;
|
7
|
+
exports.collectRegisteredTaskSyncGenerators = collectRegisteredTaskSyncGenerators;
|
8
|
+
exports.collectRegisteredGlobalSyncGenerators = collectRegisteredGlobalSyncGenerators;
|
9
|
+
exports.syncGeneratorResultsToMessageLines = syncGeneratorResultsToMessageLines;
|
10
|
+
const perf_hooks_1 = require("perf_hooks");
|
11
|
+
const generate_1 = require("../command-line/generate/generate");
|
12
|
+
const generator_utils_1 = require("../command-line/generate/generator-utils");
|
13
|
+
const nx_json_1 = require("../config/nx-json");
|
14
|
+
const client_1 = require("../daemon/client/client");
|
15
|
+
const is_on_daemon_1 = require("../daemon/is-on-daemon");
|
16
|
+
const tree_1 = require("../generators/tree");
|
17
|
+
const project_graph_1 = require("../project-graph/project-graph");
|
18
|
+
const workspace_context_1 = require("./workspace-context");
|
19
|
+
const workspace_root_1 = require("./workspace-root");
|
20
|
+
const chalk = require("chalk");
|
21
|
+
async function getSyncGeneratorChanges(generators) {
|
22
|
+
perf_hooks_1.performance.mark('get-sync-generators-changes:start');
|
23
|
+
let results;
|
24
|
+
if (!client_1.daemonClient.enabled()) {
|
25
|
+
results = await runSyncGenerators(generators);
|
26
|
+
}
|
27
|
+
else {
|
28
|
+
results = await client_1.daemonClient.getSyncGeneratorChanges(generators);
|
29
|
+
}
|
30
|
+
perf_hooks_1.performance.mark('get-sync-generators-changes:end');
|
31
|
+
perf_hooks_1.performance.measure('get-sync-generators-changes', 'get-sync-generators-changes:start', 'get-sync-generators-changes:end');
|
32
|
+
return results.filter((r) => r.changes.length > 0);
|
33
|
+
}
|
34
|
+
async function flushSyncGeneratorChanges(results) {
|
35
|
+
if ((0, is_on_daemon_1.isOnDaemon)() || !client_1.daemonClient.enabled()) {
|
36
|
+
await flushSyncGeneratorChangesToDisk(results);
|
37
|
+
}
|
38
|
+
else {
|
39
|
+
await client_1.daemonClient.flushSyncGeneratorChangesToDisk(results.map((r) => r.generatorName));
|
40
|
+
}
|
41
|
+
}
|
42
|
+
async function collectAllRegisteredSyncGenerators(projectGraph) {
|
43
|
+
if (!client_1.daemonClient.enabled()) {
|
44
|
+
return [
|
45
|
+
...collectRegisteredTaskSyncGenerators(projectGraph),
|
46
|
+
...collectRegisteredGlobalSyncGenerators(),
|
47
|
+
];
|
48
|
+
}
|
49
|
+
return await client_1.daemonClient.getRegisteredSyncGenerators();
|
50
|
+
}
|
51
|
+
async function runSyncGenerator(tree, generatorSpecifier, projects) {
|
52
|
+
perf_hooks_1.performance.mark(`run-sync-generator:${generatorSpecifier}:start`);
|
53
|
+
const { collection, generator } = (0, generate_1.parseGeneratorString)(generatorSpecifier);
|
54
|
+
const { implementationFactory } = (0, generator_utils_1.getGeneratorInformation)(collection, generator, workspace_root_1.workspaceRoot, projects);
|
55
|
+
const implementation = implementationFactory();
|
56
|
+
const result = await implementation(tree);
|
57
|
+
let callback;
|
58
|
+
let outOfSyncMessage;
|
59
|
+
if (result && typeof result === 'object') {
|
60
|
+
callback = result.callback;
|
61
|
+
outOfSyncMessage = result.outOfSyncMessage;
|
62
|
+
}
|
63
|
+
perf_hooks_1.performance.mark(`run-sync-generator:${generatorSpecifier}:end`);
|
64
|
+
perf_hooks_1.performance.measure(`run-sync-generator:${generatorSpecifier}`, `run-sync-generator:${generatorSpecifier}:start`, `run-sync-generator:${generatorSpecifier}:end`);
|
65
|
+
return {
|
66
|
+
changes: tree.listChanges(),
|
67
|
+
generatorName: generatorSpecifier,
|
68
|
+
callback,
|
69
|
+
outOfSyncMessage,
|
70
|
+
};
|
71
|
+
}
|
72
|
+
function collectRegisteredTaskSyncGenerators(projectGraph) {
|
73
|
+
const taskSyncGenerators = new Set();
|
74
|
+
for (const { data: { targets }, } of Object.values(projectGraph.nodes)) {
|
75
|
+
if (!targets) {
|
76
|
+
continue;
|
77
|
+
}
|
78
|
+
for (const target of Object.values(targets)) {
|
79
|
+
if (!target.syncGenerators) {
|
80
|
+
continue;
|
81
|
+
}
|
82
|
+
for (const generator of target.syncGenerators) {
|
83
|
+
taskSyncGenerators.add(generator);
|
84
|
+
}
|
85
|
+
}
|
86
|
+
}
|
87
|
+
return taskSyncGenerators;
|
88
|
+
}
|
89
|
+
function collectRegisteredGlobalSyncGenerators(nxJson = (0, nx_json_1.readNxJson)()) {
|
90
|
+
const globalSyncGenerators = new Set();
|
91
|
+
if (!nxJson.sync?.globalGenerators?.length) {
|
92
|
+
return globalSyncGenerators;
|
93
|
+
}
|
94
|
+
for (const generator of nxJson.sync.globalGenerators) {
|
95
|
+
globalSyncGenerators.add(generator);
|
96
|
+
}
|
97
|
+
return globalSyncGenerators;
|
98
|
+
}
|
99
|
+
function syncGeneratorResultsToMessageLines(results) {
|
100
|
+
const messageLines = [];
|
101
|
+
for (const result of results) {
|
102
|
+
messageLines.push(`The ${chalk.bold(result.generatorName)} sync generator identified ${chalk.bold(result.changes.length)} file${result.changes.length === 1 ? '' : 's'} in the workspace that ${result.changes.length === 1 ? 'is' : 'are'} out of sync${result.outOfSyncMessage ? ':' : '.'}`);
|
103
|
+
if (result.outOfSyncMessage) {
|
104
|
+
messageLines.push(result.outOfSyncMessage);
|
105
|
+
}
|
106
|
+
messageLines.push('');
|
107
|
+
}
|
108
|
+
return messageLines;
|
109
|
+
}
|
110
|
+
async function runSyncGenerators(generators) {
|
111
|
+
const tree = new tree_1.FsTree(workspace_root_1.workspaceRoot, false, 'running sync generators');
|
112
|
+
const projectGraph = await (0, project_graph_1.createProjectGraphAsync)();
|
113
|
+
const { projects } = (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph);
|
114
|
+
const results = [];
|
115
|
+
for (const generator of generators) {
|
116
|
+
const result = await runSyncGenerator(tree, generator, projects);
|
117
|
+
results.push(result);
|
118
|
+
}
|
119
|
+
return results;
|
120
|
+
}
|
121
|
+
async function flushSyncGeneratorChangesToDisk(results) {
|
122
|
+
perf_hooks_1.performance.mark('flush-sync-generator-changes-to-disk:start');
|
123
|
+
const { changes, createdFiles, updatedFiles, deletedFiles, callbacks } = processSyncGeneratorResults(results);
|
124
|
+
// Write changes to disk
|
125
|
+
(0, tree_1.flushChanges)(workspace_root_1.workspaceRoot, changes);
|
126
|
+
// Run the callbacks
|
127
|
+
if (callbacks.length) {
|
128
|
+
for (const callback of callbacks) {
|
129
|
+
await callback();
|
130
|
+
}
|
131
|
+
}
|
132
|
+
// Update the context files
|
133
|
+
await (0, workspace_context_1.updateContextWithChangedFiles)(createdFiles, updatedFiles, deletedFiles);
|
134
|
+
perf_hooks_1.performance.mark('flush-sync-generator-changes-to-disk:end');
|
135
|
+
perf_hooks_1.performance.measure('flush sync generator changes to disk', 'flush-sync-generator-changes-to-disk:start', 'flush-sync-generator-changes-to-disk:end');
|
136
|
+
}
|
137
|
+
function processSyncGeneratorResults(results) {
|
138
|
+
const changes = [];
|
139
|
+
const createdFiles = [];
|
140
|
+
const updatedFiles = [];
|
141
|
+
const deletedFiles = [];
|
142
|
+
const callbacks = [];
|
143
|
+
for (const result of results) {
|
144
|
+
if (result.callback) {
|
145
|
+
callbacks.push(result.callback);
|
146
|
+
}
|
147
|
+
for (const change of result.changes) {
|
148
|
+
changes.push(change);
|
149
|
+
if (change.type === 'CREATE') {
|
150
|
+
createdFiles.push(change.path);
|
151
|
+
}
|
152
|
+
else if (change.type === 'UPDATE') {
|
153
|
+
updatedFiles.push(change.path);
|
154
|
+
}
|
155
|
+
else if (change.type === 'DELETE') {
|
156
|
+
deletedFiles.push(change.path);
|
157
|
+
}
|
158
|
+
}
|
159
|
+
}
|
160
|
+
return { changes, createdFiles, updatedFiles, deletedFiles, callbacks };
|
161
|
+
}
|
@@ -11,6 +11,7 @@ export declare function getNxWorkspaceFilesFromContext(workspaceRoot: string, pr
|
|
11
11
|
export declare function globWithWorkspaceContextSync(workspaceRoot: string, globs: string[], exclude?: string[]): string[];
|
12
12
|
export declare function globWithWorkspaceContext(workspaceRoot: string, globs: string[], exclude?: string[]): Promise<string[]>;
|
13
13
|
export declare function hashWithWorkspaceContext(workspaceRoot: string, globs: string[], exclude?: string[]): Promise<string>;
|
14
|
+
export declare function updateContextWithChangedFiles(createdFiles: string[], updatedFiles: string[], deletedFiles: string[]): Promise<void>;
|
14
15
|
export declare function updateFilesInContext(updatedFiles: string[], deletedFiles: string[]): Record<string, string>;
|
15
16
|
export declare function getAllFileDataInContext(workspaceRoot: string): Promise<import("../native").FileData[]>;
|
16
17
|
export declare function getFilesInDirectoryUsingContext(workspaceRoot: string, dir: string): Promise<string[]>;
|
@@ -5,6 +5,7 @@ exports.getNxWorkspaceFilesFromContext = getNxWorkspaceFilesFromContext;
|
|
5
5
|
exports.globWithWorkspaceContextSync = globWithWorkspaceContextSync;
|
6
6
|
exports.globWithWorkspaceContext = globWithWorkspaceContext;
|
7
7
|
exports.hashWithWorkspaceContext = hashWithWorkspaceContext;
|
8
|
+
exports.updateContextWithChangedFiles = updateContextWithChangedFiles;
|
8
9
|
exports.updateFilesInContext = updateFilesInContext;
|
9
10
|
exports.getAllFileDataInContext = getAllFileDataInContext;
|
10
11
|
exports.getFilesInDirectoryUsingContext = getFilesInDirectoryUsingContext;
|
@@ -56,6 +57,21 @@ async function hashWithWorkspaceContext(workspaceRoot, globs, exclude) {
|
|
56
57
|
}
|
57
58
|
return client_1.daemonClient.hashGlob(globs, exclude);
|
58
59
|
}
|
60
|
+
async function updateContextWithChangedFiles(createdFiles, updatedFiles, deletedFiles) {
|
61
|
+
if (!client_1.daemonClient.enabled()) {
|
62
|
+
updateFilesInContext([...createdFiles, ...updatedFiles], deletedFiles);
|
63
|
+
}
|
64
|
+
else if ((0, is_on_daemon_1.isOnDaemon)()) {
|
65
|
+
// make sure to only import this when running on the daemon
|
66
|
+
const { addUpdatedAndDeletedFiles } = await Promise.resolve().then(() => require('../daemon/server/project-graph-incremental-recomputation'));
|
67
|
+
// update files for the incremental graph recomputation on the daemon
|
68
|
+
addUpdatedAndDeletedFiles(createdFiles, updatedFiles, deletedFiles);
|
69
|
+
}
|
70
|
+
else {
|
71
|
+
// daemon is enabled but we are not running on it, ask the daemon to update the context
|
72
|
+
await client_1.daemonClient.updateWorkspaceContext(createdFiles, updatedFiles, deletedFiles);
|
73
|
+
}
|
74
|
+
}
|
59
75
|
function updateFilesInContext(updatedFiles, deletedFiles) {
|
60
76
|
return workspaceContext?.incrementalUpdate(updatedFiles, deletedFiles);
|
61
77
|
}
|
@@ -1,7 +0,0 @@
|
|
1
|
-
export declare const GLOB: "GLOB";
|
2
|
-
export type HandleUpdateContextMessage = {
|
3
|
-
type: typeof GLOB;
|
4
|
-
updatedFiles: string[];
|
5
|
-
deletedFiles: string[];
|
6
|
-
};
|
7
|
-
export declare function isHandleUpdateContextMessage(message: unknown): message is HandleUpdateContextMessage;
|
@@ -1,11 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.GLOB = void 0;
|
4
|
-
exports.isHandleUpdateContextMessage = isHandleUpdateContextMessage;
|
5
|
-
exports.GLOB = 'GLOB';
|
6
|
-
function isHandleUpdateContextMessage(message) {
|
7
|
-
return (typeof message === 'object' &&
|
8
|
-
message !== null &&
|
9
|
-
'type' in message &&
|
10
|
-
message['type'] === exports.GLOB);
|
11
|
-
}
|