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,225 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.releasePlanCheckCLIHandler = void 0;
|
4
|
+
exports.createAPI = createAPI;
|
5
|
+
const nx_json_1 = require("../../config/nx-json");
|
6
|
+
const workspace_projects_1 = require("../../project-graph/affected/locators/workspace-projects");
|
7
|
+
const file_map_utils_1 = require("../../project-graph/file-map-utils");
|
8
|
+
const file_utils_1 = require("../../project-graph/file-utils");
|
9
|
+
const project_graph_1 = require("../../project-graph/project-graph");
|
10
|
+
const all_file_data_1 = require("../../utils/all-file-data");
|
11
|
+
const command_line_utils_1 = require("../../utils/command-line-utils");
|
12
|
+
const ignore_1 = require("../../utils/ignore");
|
13
|
+
const output_1 = require("../../utils/output");
|
14
|
+
const params_1 = require("../../utils/params");
|
15
|
+
const config_1 = require("./config/config");
|
16
|
+
const deep_merge_json_1 = require("./config/deep-merge-json");
|
17
|
+
const filter_release_groups_1 = require("./config/filter-release-groups");
|
18
|
+
const version_plans_1 = require("./config/version-plans");
|
19
|
+
const print_config_1 = require("./utils/print-config");
|
20
|
+
const releasePlanCheckCLIHandler = (args) => (0, params_1.handleErrors)(args.verbose, () => createAPI({})(args));
|
21
|
+
exports.releasePlanCheckCLIHandler = releasePlanCheckCLIHandler;
|
22
|
+
function createAPI(overrideReleaseConfig) {
|
23
|
+
return async function releasePlanCheck(args) {
|
24
|
+
const projectGraph = await (0, project_graph_1.createProjectGraphAsync)({ exitOnError: true });
|
25
|
+
const nxJson = (0, nx_json_1.readNxJson)();
|
26
|
+
const userProvidedReleaseConfig = (0, deep_merge_json_1.deepMergeJson)(nxJson.release ?? {}, overrideReleaseConfig ?? {});
|
27
|
+
if (args.verbose) {
|
28
|
+
process.env.NX_VERBOSE_LOGGING = 'true';
|
29
|
+
}
|
30
|
+
// Apply default configuration to any optional user configuration
|
31
|
+
const { error: configError, nxReleaseConfig } = await (0, config_1.createNxReleaseConfig)(projectGraph, await (0, file_map_utils_1.createProjectFileMapUsingProjectGraph)(projectGraph), userProvidedReleaseConfig);
|
32
|
+
if (configError) {
|
33
|
+
return await (0, config_1.handleNxReleaseConfigError)(configError);
|
34
|
+
}
|
35
|
+
// --print-config exits directly as it is not designed to be combined with any other programmatic operations
|
36
|
+
if (args.printConfig) {
|
37
|
+
return (0, print_config_1.printConfigAndExit)({
|
38
|
+
userProvidedReleaseConfig,
|
39
|
+
nxReleaseConfig,
|
40
|
+
isDebug: args.printConfig === 'debug',
|
41
|
+
});
|
42
|
+
}
|
43
|
+
const { error: filterError, releaseGroups, releaseGroupToFilteredProjects, } = (0, filter_release_groups_1.filterReleaseGroups)(projectGraph, nxReleaseConfig, args.projects, args.groups);
|
44
|
+
if (filterError) {
|
45
|
+
output_1.output.error(filterError);
|
46
|
+
process.exit(1);
|
47
|
+
}
|
48
|
+
// If no release groups have version plans enabled, provide an explicit error
|
49
|
+
if (!releaseGroups.some((group) => group.versionPlans)) {
|
50
|
+
output_1.output.error({
|
51
|
+
title: 'Version plans are not enabled',
|
52
|
+
bodyLines: [
|
53
|
+
'Please ensure at least one release group has version plans enabled in your Nx release configuration if you want to use this command.',
|
54
|
+
// TODO: Add docs link here once it is available
|
55
|
+
],
|
56
|
+
});
|
57
|
+
return 1;
|
58
|
+
}
|
59
|
+
const rawVersionPlans = await (0, version_plans_1.readRawVersionPlans)();
|
60
|
+
(0, version_plans_1.setResolvedVersionPlansOnGroups)(rawVersionPlans, releaseGroups, Object.keys(projectGraph.nodes));
|
61
|
+
// Resolve the final values for base, head etc to use when resolving the changes to consider
|
62
|
+
const { nxArgs } = (0, command_line_utils_1.splitArgsIntoNxArgsAndOverrides)(args, 'affected', {
|
63
|
+
printWarnings: args.verbose,
|
64
|
+
}, nxJson);
|
65
|
+
const changedFiles = (0, command_line_utils_1.parseFiles)(nxArgs).files;
|
66
|
+
if (nxArgs.verbose) {
|
67
|
+
if (changedFiles.length) {
|
68
|
+
output_1.output.log({
|
69
|
+
title: `Changed files based on resolved "base" (${nxArgs.base}) and "head" (${nxArgs.head ?? 'HEAD'})`,
|
70
|
+
bodyLines: changedFiles.map((file) => ` - ${file}`),
|
71
|
+
});
|
72
|
+
}
|
73
|
+
else {
|
74
|
+
output_1.output.warn({
|
75
|
+
title: 'No changed files found based on resolved "base" and "head"',
|
76
|
+
});
|
77
|
+
}
|
78
|
+
}
|
79
|
+
const resolvedAllFileData = await (0, all_file_data_1.allFileData)();
|
80
|
+
/**
|
81
|
+
* Create a minimal subset of touched projects based on the configured ignore patterns, we only need
|
82
|
+
* to recompute when the ignorePatternsForPlanCheck differs between release groups.
|
83
|
+
*/
|
84
|
+
const serializedIgnorePatternsToTouchedProjects = new Map();
|
85
|
+
const NOTE_ABOUT_VERBOSE_LOGGING = 'Run with --verbose to see the full list of changed files used for the touched projects logic.';
|
86
|
+
let hasErrors = false;
|
87
|
+
for (const releaseGroup of releaseGroups) {
|
88
|
+
// The current release group doesn't leverage version plans
|
89
|
+
if (!releaseGroup.versionPlans) {
|
90
|
+
continue;
|
91
|
+
}
|
92
|
+
const resolvedVersionPlans = releaseGroup.resolvedVersionPlans || [];
|
93
|
+
// Check upfront if the release group as a whole is featured in any version plan files
|
94
|
+
const matchingVersionPlanFiles = resolvedVersionPlans.filter((plan) => 'groupVersionBump' in plan);
|
95
|
+
if (matchingVersionPlanFiles.length) {
|
96
|
+
output_1.output.log({
|
97
|
+
title: `${releaseGroup.name === config_1.IMPLICIT_DEFAULT_RELEASE_GROUP
|
98
|
+
? `There are`
|
99
|
+
: `Release group "${releaseGroup.name}" has`} pending bumps in version plan(s)`,
|
100
|
+
bodyLines: [
|
101
|
+
...matchingVersionPlanFiles.map((plan) => ` - "${plan.groupVersionBump}" in ${plan.fileName}`),
|
102
|
+
],
|
103
|
+
});
|
104
|
+
continue;
|
105
|
+
}
|
106
|
+
// Exclude patterns from .nxignore, .gitignore and explicit version plan config
|
107
|
+
let serializedIgnorePatterns = '[]';
|
108
|
+
const ignore = (0, ignore_1.getIgnoreObject)();
|
109
|
+
if (typeof releaseGroup.versionPlans !== 'boolean' &&
|
110
|
+
Array.isArray(releaseGroup.versionPlans.ignorePatternsForPlanCheck) &&
|
111
|
+
releaseGroup.versionPlans.ignorePatternsForPlanCheck.length) {
|
112
|
+
output_1.output.note({
|
113
|
+
title: `Applying configured ignore patterns to changed files${releaseGroup.name !== config_1.IMPLICIT_DEFAULT_RELEASE_GROUP
|
114
|
+
? ` for release group "${releaseGroup.name}"`
|
115
|
+
: ''}`,
|
116
|
+
bodyLines: [
|
117
|
+
...releaseGroup.versionPlans.ignorePatternsForPlanCheck.map((pattern) => ` - ${pattern}`),
|
118
|
+
],
|
119
|
+
});
|
120
|
+
ignore.add(releaseGroup.versionPlans.ignorePatternsForPlanCheck);
|
121
|
+
serializedIgnorePatterns = JSON.stringify(releaseGroup.versionPlans.ignorePatternsForPlanCheck);
|
122
|
+
}
|
123
|
+
let touchedProjects = {};
|
124
|
+
if (serializedIgnorePatternsToTouchedProjects.has(serializedIgnorePatterns)) {
|
125
|
+
touchedProjects = serializedIgnorePatternsToTouchedProjects.get(serializedIgnorePatterns);
|
126
|
+
}
|
127
|
+
else {
|
128
|
+
// We only care about directly touched projects, not implicitly affected ones etc
|
129
|
+
const touchedProjectsArr = await (0, workspace_projects_1.getTouchedProjects)((0, file_utils_1.calculateFileChanges)(changedFiles, resolvedAllFileData, nxArgs, undefined, ignore), projectGraph.nodes);
|
130
|
+
touchedProjects = touchedProjectsArr.reduce((acc, project) => ({ ...acc, [project]: true }), {});
|
131
|
+
serializedIgnorePatternsToTouchedProjects.set(serializedIgnorePatterns, touchedProjects);
|
132
|
+
}
|
133
|
+
const touchedProjectsUnderReleaseGroup = releaseGroup.projects.filter((project) => touchedProjects[project]);
|
134
|
+
if (touchedProjectsUnderReleaseGroup.length) {
|
135
|
+
output_1.output.log({
|
136
|
+
title: `Touched projects based on changed files${releaseGroup.name !== config_1.IMPLICIT_DEFAULT_RELEASE_GROUP
|
137
|
+
? ` under release group "${releaseGroup.name}"`
|
138
|
+
: ''}`,
|
139
|
+
bodyLines: [
|
140
|
+
...touchedProjectsUnderReleaseGroup.map((project) => ` - ${project}`),
|
141
|
+
'',
|
142
|
+
'NOTE: You can adjust your "versionPlans.ignorePatternsForPlanCheck" config to stop certain files from resulting in projects being classed as touched for the purposes of this command.',
|
143
|
+
],
|
144
|
+
});
|
145
|
+
}
|
146
|
+
else {
|
147
|
+
output_1.output.log({
|
148
|
+
title: `No touched projects found based on changed files${typeof releaseGroup.versionPlans !== 'boolean' &&
|
149
|
+
Array.isArray(releaseGroup.versionPlans.ignorePatternsForPlanCheck) &&
|
150
|
+
releaseGroup.versionPlans.ignorePatternsForPlanCheck.length
|
151
|
+
? ' combined with configured ignore patterns'
|
152
|
+
: ''}${releaseGroup.name !== config_1.IMPLICIT_DEFAULT_RELEASE_GROUP
|
153
|
+
? ` under release group "${releaseGroup.name}"`
|
154
|
+
: ''}`,
|
155
|
+
});
|
156
|
+
}
|
157
|
+
const projectsInResolvedVersionPlans = resolvedVersionPlans.reduce((acc, plan) => {
|
158
|
+
if ('projectVersionBumps' in plan) {
|
159
|
+
for (const project in plan.projectVersionBumps) {
|
160
|
+
acc[project] = acc[project] || [];
|
161
|
+
acc[project].push({
|
162
|
+
bump: plan.projectVersionBumps[project],
|
163
|
+
fileName: plan.fileName,
|
164
|
+
});
|
165
|
+
}
|
166
|
+
}
|
167
|
+
return acc;
|
168
|
+
}, {});
|
169
|
+
// Ensure each touched project under this release group features in at least one version plan file
|
170
|
+
let touchedProjectsNotFoundInVersionPlans = [];
|
171
|
+
for (const touchedProject of touchedProjectsUnderReleaseGroup) {
|
172
|
+
if (!resolvedVersionPlans.length) {
|
173
|
+
touchedProjectsNotFoundInVersionPlans.push(touchedProject);
|
174
|
+
continue;
|
175
|
+
}
|
176
|
+
const matchingVersionPlanFileEntries = projectsInResolvedVersionPlans[touchedProject];
|
177
|
+
if (!matchingVersionPlanFileEntries?.length) {
|
178
|
+
touchedProjectsNotFoundInVersionPlans.push(touchedProject);
|
179
|
+
continue;
|
180
|
+
}
|
181
|
+
}
|
182
|
+
// Log any resolved pending bumps, regardless of whether the projects were directly touched or not
|
183
|
+
for (const [projectName, entries] of Object.entries(projectsInResolvedVersionPlans)) {
|
184
|
+
output_1.output.log({
|
185
|
+
title: `Project "${projectName}" has pending bumps in version plan(s)`,
|
186
|
+
bodyLines: [
|
187
|
+
...entries.map(({ bump, fileName }) => ` - "${bump}" in ${fileName}`),
|
188
|
+
],
|
189
|
+
});
|
190
|
+
}
|
191
|
+
if (touchedProjectsNotFoundInVersionPlans.length) {
|
192
|
+
const bodyLines = [
|
193
|
+
`The following touched projects${releaseGroup.name !== config_1.IMPLICIT_DEFAULT_RELEASE_GROUP
|
194
|
+
? ` under release group "${releaseGroup.name}"`
|
195
|
+
: ''} do not feature in any version plan files:`,
|
196
|
+
...touchedProjectsNotFoundInVersionPlans.map((project) => ` - ${project}`),
|
197
|
+
'',
|
198
|
+
'Please use `nx release plan` to generate missing version plans, or adjust your "versionPlans.ignorePatternsForPlanCheck" config stop certain files from affecting the projects for the purposes of this command.',
|
199
|
+
];
|
200
|
+
if (!nxArgs.verbose) {
|
201
|
+
bodyLines.push('', NOTE_ABOUT_VERBOSE_LOGGING);
|
202
|
+
}
|
203
|
+
output_1.output.error({
|
204
|
+
title: 'Touched projects missing version plans',
|
205
|
+
bodyLines,
|
206
|
+
});
|
207
|
+
// At least one project in one release group has an issue
|
208
|
+
hasErrors = true;
|
209
|
+
}
|
210
|
+
}
|
211
|
+
// Do not print success message if any projects are missing version plans
|
212
|
+
if (hasErrors) {
|
213
|
+
return 1;
|
214
|
+
}
|
215
|
+
const bodyLines = [];
|
216
|
+
if (!nxArgs.verbose) {
|
217
|
+
bodyLines.push(NOTE_ABOUT_VERBOSE_LOGGING);
|
218
|
+
}
|
219
|
+
output_1.output.success({
|
220
|
+
title: 'All touched projects have, or do not require, version plans.',
|
221
|
+
bodyLines,
|
222
|
+
});
|
223
|
+
return 0;
|
224
|
+
};
|
225
|
+
}
|
@@ -31,7 +31,7 @@ function createAPI(overrideReleaseConfig) {
|
|
31
31
|
process.env.NX_VERBOSE_LOGGING = 'true';
|
32
32
|
}
|
33
33
|
// Apply default configuration to any optional user configuration
|
34
|
-
const { error: configError, nxReleaseConfig } = await (0, config_1.createNxReleaseConfig)(projectGraph, await (0, file_map_utils_1.createProjectFileMapUsingProjectGraph)(projectGraph),
|
34
|
+
const { error: configError, nxReleaseConfig } = await (0, config_1.createNxReleaseConfig)(projectGraph, await (0, file_map_utils_1.createProjectFileMapUsingProjectGraph)(projectGraph), userProvidedReleaseConfig);
|
35
35
|
if (configError) {
|
36
36
|
return await (0, config_1.handleNxReleaseConfigError)(configError);
|
37
37
|
}
|
@@ -88,17 +88,17 @@ function createAPI(overrideReleaseConfig) {
|
|
88
88
|
process.exit(1);
|
89
89
|
}
|
90
90
|
const rawVersionPlans = await (0, version_plans_1.readRawVersionPlans)();
|
91
|
-
(0, version_plans_1.
|
91
|
+
(0, version_plans_1.setResolvedVersionPlansOnGroups)(rawVersionPlans, releaseGroups, Object.keys(projectGraph.nodes));
|
92
92
|
const planFiles = new Set();
|
93
93
|
releaseGroups.forEach((group) => {
|
94
|
-
if (group.
|
94
|
+
if (group.resolvedVersionPlans) {
|
95
95
|
if (group.name === config_1.IMPLICIT_DEFAULT_RELEASE_GROUP) {
|
96
96
|
output_1.output.logSingleLine(`Removing version plan files`);
|
97
97
|
}
|
98
98
|
else {
|
99
99
|
output_1.output.logSingleLine(`Removing version plan files for group ${group.name}`);
|
100
100
|
}
|
101
|
-
group.
|
101
|
+
group.resolvedVersionPlans.forEach((plan) => {
|
102
102
|
if (!args.dryRun) {
|
103
103
|
(0, fs_extra_1.removeSync)(plan.absolutePath);
|
104
104
|
if (args.verbose) {
|
@@ -84,7 +84,7 @@ function createAPI(overrideReleaseConfig) {
|
|
84
84
|
process.exit(1);
|
85
85
|
}
|
86
86
|
const rawVersionPlans = await (0, version_plans_1.readRawVersionPlans)();
|
87
|
-
(0, version_plans_1.
|
87
|
+
(0, version_plans_1.setResolvedVersionPlansOnGroups)(rawVersionPlans, releaseGroups, Object.keys(projectGraph.nodes));
|
88
88
|
if (args.deleteVersionPlans === undefined) {
|
89
89
|
// default to not delete version plans after versioning as they may be needed for changelog generation
|
90
90
|
args.deleteVersionPlans = false;
|
@@ -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
@@ -145,6 +145,13 @@ export interface NxReleaseConventionalCommitsConfiguration {
|
|
145
145
|
} | boolean;
|
146
146
|
} | boolean>;
|
147
147
|
}
|
148
|
+
export interface NxReleaseVersionPlansConfiguration {
|
149
|
+
/**
|
150
|
+
* Changes to files matching any of these optional patterns will be excluded from the affected project logic within the `nx release plan:check`
|
151
|
+
* command. This is useful for ignoring files that are not relevant to the versioning process, such as documentation or configuration files.
|
152
|
+
*/
|
153
|
+
ignorePatternsForPlanCheck?: string[];
|
154
|
+
}
|
148
155
|
export interface NxReleaseConfiguration {
|
149
156
|
/**
|
150
157
|
* Shorthand for amending the projects which will be included in the implicit default release group (all projects by default).
|
@@ -193,7 +200,7 @@ export interface NxReleaseConfiguration {
|
|
193
200
|
* Enables using version plans as a specifier source for versioning and
|
194
201
|
* to determine changes for changelog generation.
|
195
202
|
*/
|
196
|
-
versionPlans?: boolean;
|
203
|
+
versionPlans?: NxReleaseVersionPlansConfiguration | boolean;
|
197
204
|
}>;
|
198
205
|
/**
|
199
206
|
* Configures the default value for all groups that don't explicitly state their own projectsRelationship.
|
@@ -264,7 +271,26 @@ export interface NxReleaseConfiguration {
|
|
264
271
|
* Enables using version plans as a specifier source for versioning and
|
265
272
|
* to determine changes for changelog generation.
|
266
273
|
*/
|
267
|
-
versionPlans?: boolean;
|
274
|
+
versionPlans?: NxReleaseVersionPlansConfiguration | boolean;
|
275
|
+
}
|
276
|
+
export interface NxSyncConfiguration {
|
277
|
+
/**
|
278
|
+
* List of workspace-wide sync generators to be run (not attached to targets).
|
279
|
+
*/
|
280
|
+
globalGenerators?: string[];
|
281
|
+
/**
|
282
|
+
* Options for the sync generators.
|
283
|
+
*/
|
284
|
+
generatorOptions?: {
|
285
|
+
[generatorName: string]: Record<string, unknown>;
|
286
|
+
};
|
287
|
+
/**
|
288
|
+
* Whether to automatically apply sync generator changes when running tasks.
|
289
|
+
* If not set, the user will be prompted.
|
290
|
+
* If set to `true`, the user will not be prompted and the changes will be applied.
|
291
|
+
* If set to `false`, the user will not be prompted and the changes will not be applied.
|
292
|
+
*/
|
293
|
+
applyChanges?: boolean;
|
268
294
|
}
|
269
295
|
/**
|
270
296
|
* Nx.json configuration
|
@@ -413,6 +439,10 @@ export interface NxJsonConfiguration<T = '*' | string[]> {
|
|
413
439
|
* Set this to false to disable connection to Nx Cloud
|
414
440
|
*/
|
415
441
|
neverConnectToCloud?: boolean;
|
442
|
+
/**
|
443
|
+
* Configuration for the `nx sync` command.
|
444
|
+
*/
|
445
|
+
sync?: NxSyncConfiguration;
|
416
446
|
}
|
417
447
|
export type PluginConfiguration = string | ExpandedPluginConfiguration;
|
418
448
|
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 {};
|