nx 19.7.0-canary.20240830-83a387a → 19.7.0-canary.20240903-9039e5e

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "19.7.0-canary.20240830-83a387a",
3
+ "version": "19.7.0-canary.20240903-9039e5e",
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.7.0-canary.20240830-83a387a"
74
+ "@nrwl/tao": "19.7.0-canary.20240903-9039e5e"
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.7.0-canary.20240830-83a387a",
90
- "@nx/nx-darwin-arm64": "19.7.0-canary.20240830-83a387a",
91
- "@nx/nx-linux-x64-gnu": "19.7.0-canary.20240830-83a387a",
92
- "@nx/nx-linux-x64-musl": "19.7.0-canary.20240830-83a387a",
93
- "@nx/nx-win32-x64-msvc": "19.7.0-canary.20240830-83a387a",
94
- "@nx/nx-linux-arm64-gnu": "19.7.0-canary.20240830-83a387a",
95
- "@nx/nx-linux-arm64-musl": "19.7.0-canary.20240830-83a387a",
96
- "@nx/nx-linux-arm-gnueabihf": "19.7.0-canary.20240830-83a387a",
97
- "@nx/nx-win32-arm64-msvc": "19.7.0-canary.20240830-83a387a",
98
- "@nx/nx-freebsd-x64": "19.7.0-canary.20240830-83a387a"
89
+ "@nx/nx-darwin-x64": "19.7.0-canary.20240903-9039e5e",
90
+ "@nx/nx-darwin-arm64": "19.7.0-canary.20240903-9039e5e",
91
+ "@nx/nx-linux-x64-gnu": "19.7.0-canary.20240903-9039e5e",
92
+ "@nx/nx-linux-x64-musl": "19.7.0-canary.20240903-9039e5e",
93
+ "@nx/nx-win32-x64-msvc": "19.7.0-canary.20240903-9039e5e",
94
+ "@nx/nx-linux-arm64-gnu": "19.7.0-canary.20240903-9039e5e",
95
+ "@nx/nx-linux-arm64-musl": "19.7.0-canary.20240903-9039e5e",
96
+ "@nx/nx-linux-arm-gnueabihf": "19.7.0-canary.20240903-9039e5e",
97
+ "@nx/nx-win32-arm64-msvc": "19.7.0-canary.20240903-9039e5e",
98
+ "@nx/nx-freebsd-x64": "19.7.0-canary.20240903-9039e5e"
99
99
  },
100
100
  "nx-migrations": {
101
101
  "migrations": "./migrations.json",
@@ -506,6 +506,11 @@
506
506
  "type": "object"
507
507
  }
508
508
  },
509
+ "parallelism": {
510
+ "type": "boolean",
511
+ "default": true,
512
+ "description": "Whether this target can be run in parallel with other tasks"
513
+ },
509
514
  "inputs": {
510
515
  "$ref": "#/definitions/inputs"
511
516
  },
@@ -584,7 +584,17 @@ async function applyChangesAndExit(args, nxReleaseConfig, tree, toSHA, postGitTa
584
584
  releaseGroups.forEach((group) => {
585
585
  if (group.resolvedVersionPlans) {
586
586
  group.resolvedVersionPlans.forEach((plan) => {
587
- (0, fs_extra_1.removeSync)(plan.absolutePath);
587
+ if (!args.dryRun) {
588
+ (0, fs_extra_1.removeSync)(plan.absolutePath);
589
+ if (args.verbose) {
590
+ console.log(`Removing ${plan.relativePath}`);
591
+ }
592
+ }
593
+ else {
594
+ if (args.verbose) {
595
+ console.log(`Would remove ${plan.relativePath}, but --dry-run was set`);
596
+ }
597
+ }
588
598
  planFiles.add(plan.relativePath);
589
599
  });
590
600
  }
@@ -44,6 +44,7 @@ export type PublishOptions = NxReleaseArgs & Partial<RunManyOptions> & {
44
44
  export type PlanOptions = NxReleaseArgs & {
45
45
  bump?: string;
46
46
  message?: string;
47
+ onlyTouched?: boolean;
47
48
  };
48
49
  export type PlanCheckOptions = BaseNxReleaseArgs & {
49
50
  base?: string;
@@ -207,7 +207,7 @@ const planCommand = {
207
207
  // Create a plan to pick a new version and generate a changelog entry.
208
208
  // Hidden for now until the feature is more stable
209
209
  describe: false,
210
- builder: (yargs) => yargs
210
+ builder: (yargs) => (0, shared_options_1.withAffectedOptions)(yargs)
211
211
  .positional('bump', {
212
212
  type: 'string',
213
213
  describe: 'Semver keyword to use for the selected release group.',
@@ -225,6 +225,11 @@ const planCommand = {
225
225
  type: 'string',
226
226
  alias: 'm',
227
227
  describe: 'Custom message to use for the changelog entry',
228
+ })
229
+ .option('onlyTouched', {
230
+ type: 'boolean',
231
+ describe: 'Only include projects that have been affected by the current changes',
232
+ default: true,
228
233
  }),
229
234
  handler: async (args) => {
230
235
  const release = await Promise.resolve().then(() => require('./plan'));
@@ -3,19 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.releasePlanCheckCLIHandler = void 0;
4
4
  exports.createAPI = createAPI;
5
5
  const nx_json_1 = require("../../config/nx-json");
6
- const workspace_projects_1 = require("../../project-graph/affected/locators/workspace-projects");
7
6
  const file_map_utils_1 = require("../../project-graph/file-map-utils");
8
- const file_utils_1 = require("../../project-graph/file-utils");
9
7
  const project_graph_1 = require("../../project-graph/project-graph");
10
8
  const all_file_data_1 = require("../../utils/all-file-data");
11
9
  const command_line_utils_1 = require("../../utils/command-line-utils");
12
- const ignore_1 = require("../../utils/ignore");
13
10
  const output_1 = require("../../utils/output");
14
11
  const params_1 = require("../../utils/params");
15
12
  const config_1 = require("./config/config");
16
13
  const deep_merge_json_1 = require("./config/deep-merge-json");
17
14
  const filter_release_groups_1 = require("./config/filter-release-groups");
18
15
  const version_plans_1 = require("./config/version-plans");
16
+ const get_touched_projects_for_group_1 = require("./utils/get-touched-projects-for-group");
19
17
  const print_config_1 = require("./utils/print-config");
20
18
  const releasePlanCheckCLIHandler = (args) => (0, params_1.handleErrors)(args.verbose, () => createAPI({})(args));
21
19
  exports.releasePlanCheckCLIHandler = releasePlanCheckCLIHandler;
@@ -37,7 +35,8 @@ function createAPI(overrideReleaseConfig) {
37
35
  isDebug: args.printConfig === 'debug',
38
36
  });
39
37
  }
40
- const { error: filterError, releaseGroups, releaseGroupToFilteredProjects, } = (0, filter_release_groups_1.filterReleaseGroups)(projectGraph, nxReleaseConfig, args.projects, args.groups);
38
+ // No filtering is applied here, as we want to consider all release groups for plan:check
39
+ const { error: filterError, releaseGroups } = (0, filter_release_groups_1.filterReleaseGroups)(projectGraph, nxReleaseConfig);
41
40
  if (filterError) {
42
41
  output_1.output.error(filterError);
43
42
  process.exit(1);
@@ -74,11 +73,7 @@ function createAPI(overrideReleaseConfig) {
74
73
  }
75
74
  }
76
75
  const resolvedAllFileData = await (0, all_file_data_1.allFileData)();
77
- /**
78
- * Create a minimal subset of touched projects based on the configured ignore patterns, we only need
79
- * to recompute when the ignorePatternsForPlanCheck differs between release groups.
80
- */
81
- const serializedIgnorePatternsToTouchedProjects = new Map();
76
+ const getTouchedProjectsForGroup = (0, get_touched_projects_for_group_1.createGetTouchedProjectsForGroup)(nxArgs, projectGraph, changedFiles, resolvedAllFileData);
82
77
  const NOTE_ABOUT_VERBOSE_LOGGING = 'Run with --verbose to see the full list of changed files used for the touched projects logic.';
83
78
  let hasErrors = false;
84
79
  for (const releaseGroup of releaseGroups) {
@@ -100,57 +95,9 @@ function createAPI(overrideReleaseConfig) {
100
95
  });
101
96
  continue;
102
97
  }
103
- // Exclude patterns from .nxignore, .gitignore and explicit version plan config
104
- let serializedIgnorePatterns = '[]';
105
- const ignore = (0, ignore_1.getIgnoreObject)();
106
- if (typeof releaseGroup.versionPlans !== 'boolean' &&
107
- Array.isArray(releaseGroup.versionPlans.ignorePatternsForPlanCheck) &&
108
- releaseGroup.versionPlans.ignorePatternsForPlanCheck.length) {
109
- output_1.output.note({
110
- title: `Applying configured ignore patterns to changed files${releaseGroup.name !== config_1.IMPLICIT_DEFAULT_RELEASE_GROUP
111
- ? ` for release group "${releaseGroup.name}"`
112
- : ''}`,
113
- bodyLines: [
114
- ...releaseGroup.versionPlans.ignorePatternsForPlanCheck.map((pattern) => ` - ${pattern}`),
115
- ],
116
- });
117
- ignore.add(releaseGroup.versionPlans.ignorePatternsForPlanCheck);
118
- serializedIgnorePatterns = JSON.stringify(releaseGroup.versionPlans.ignorePatternsForPlanCheck);
119
- }
120
- let touchedProjects = {};
121
- if (serializedIgnorePatternsToTouchedProjects.has(serializedIgnorePatterns)) {
122
- touchedProjects = serializedIgnorePatternsToTouchedProjects.get(serializedIgnorePatterns);
123
- }
124
- else {
125
- // We only care about directly touched projects, not implicitly affected ones etc
126
- const touchedProjectsArr = await (0, workspace_projects_1.getTouchedProjects)((0, file_utils_1.calculateFileChanges)(changedFiles, resolvedAllFileData, nxArgs, undefined, ignore), projectGraph.nodes);
127
- touchedProjects = touchedProjectsArr.reduce((acc, project) => ({ ...acc, [project]: true }), {});
128
- serializedIgnorePatternsToTouchedProjects.set(serializedIgnorePatterns, touchedProjects);
129
- }
130
- const touchedProjectsUnderReleaseGroup = releaseGroup.projects.filter((project) => touchedProjects[project]);
131
- if (touchedProjectsUnderReleaseGroup.length) {
132
- output_1.output.log({
133
- title: `Touched projects based on changed files${releaseGroup.name !== config_1.IMPLICIT_DEFAULT_RELEASE_GROUP
134
- ? ` under release group "${releaseGroup.name}"`
135
- : ''}`,
136
- bodyLines: [
137
- ...touchedProjectsUnderReleaseGroup.map((project) => ` - ${project}`),
138
- '',
139
- '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.',
140
- ],
141
- });
142
- }
143
- else {
144
- output_1.output.log({
145
- title: `No touched projects found based on changed files${typeof releaseGroup.versionPlans !== 'boolean' &&
146
- Array.isArray(releaseGroup.versionPlans.ignorePatternsForPlanCheck) &&
147
- releaseGroup.versionPlans.ignorePatternsForPlanCheck.length
148
- ? ' combined with configured ignore patterns'
149
- : ''}${releaseGroup.name !== config_1.IMPLICIT_DEFAULT_RELEASE_GROUP
150
- ? ` under release group "${releaseGroup.name}"`
151
- : ''}`,
152
- });
153
- }
98
+ const touchedProjectsUnderReleaseGroup = await getTouchedProjectsForGroup(releaseGroup,
99
+ // We do not take any --projects or --groups filtering into account for plan:check
100
+ releaseGroup.projects, false);
154
101
  const projectsInResolvedVersionPlans = resolvedVersionPlans.reduce((acc, plan) => {
155
102
  if ('projectVersionBumps' in plan) {
156
103
  for (const project in plan.projectVersionBumps) {
@@ -10,6 +10,8 @@ const tmp_1 = require("tmp");
10
10
  const nx_json_1 = require("../../config/nx-json");
11
11
  const file_map_utils_1 = require("../../project-graph/file-map-utils");
12
12
  const project_graph_1 = require("../../project-graph/project-graph");
13
+ const all_file_data_1 = require("../../utils/all-file-data");
14
+ const command_line_utils_1 = require("../../utils/command-line-utils");
13
15
  const output_1 = require("../../utils/output");
14
16
  const params_1 = require("../../utils/params");
15
17
  const config_1 = require("./config/config");
@@ -17,6 +19,7 @@ const deep_merge_json_1 = require("./config/deep-merge-json");
17
19
  const filter_release_groups_1 = require("./config/filter-release-groups");
18
20
  const version_plans_1 = require("./config/version-plans");
19
21
  const generate_version_plan_content_1 = require("./utils/generate-version-plan-content");
22
+ const get_touched_projects_for_group_1 = require("./utils/get-touched-projects-for-group");
20
23
  const launch_editor_1 = require("./utils/launch-editor");
21
24
  const print_changes_1 = require("./utils/print-changes");
22
25
  const print_config_1 = require("./utils/print-config");
@@ -45,64 +48,155 @@ function createAPI(overrideReleaseConfig) {
45
48
  output_1.output.error(filterError);
46
49
  process.exit(1);
47
50
  }
51
+ // If no release groups have version plans enabled, it doesn't make sense to use the plan command only to set yourself up for an error at release time
52
+ if (!releaseGroups.some((group) => group.versionPlans === true)) {
53
+ if (releaseGroups.length === 1) {
54
+ output_1.output.warn({
55
+ title: `Version plans are not enabled in your release configuration`,
56
+ bodyLines: [
57
+ 'To enable version plans, set `"versionPlans": true` at the top level of your `"release"` configuration',
58
+ ],
59
+ });
60
+ return 0;
61
+ }
62
+ output_1.output.warn({
63
+ title: 'No release groups have version plans enabled',
64
+ bodyLines: [
65
+ 'To enable version plans, set `"versionPlans": true` at the top level of your `"release"` configuration to apply it to all groups, otherwise set it at the release group level',
66
+ ],
67
+ });
68
+ return 0;
69
+ }
70
+ // Resolve the final values for base, head etc to use when resolving the changes to consider
71
+ const { nxArgs } = (0, command_line_utils_1.splitArgsIntoNxArgsAndOverrides)(args, 'affected', {
72
+ printWarnings: args.verbose,
73
+ }, nxJson);
48
74
  const versionPlanBumps = {};
49
75
  const setBumpIfNotNone = (projectOrGroup, version) => {
50
76
  if (version !== 'none') {
51
77
  versionPlanBumps[projectOrGroup] = version;
52
78
  }
53
79
  };
54
- if (releaseGroups[0].name === config_1.IMPLICIT_DEFAULT_RELEASE_GROUP) {
55
- const group = releaseGroups[0];
56
- if (group.projectsRelationship === 'independent') {
57
- for (const project of group.projects) {
58
- setBumpIfNotNone(project, args.bump ||
59
- (await promptForVersion(`How do you want to bump the version of the project "${project}"?`)));
80
+ // Changed files are only relevant if considering touched projects
81
+ let changedFiles = [];
82
+ let getProjectsToVersionForGroup;
83
+ if (args.onlyTouched) {
84
+ changedFiles = (0, command_line_utils_1.parseFiles)(nxArgs).files;
85
+ if (nxArgs.verbose) {
86
+ if (changedFiles.length) {
87
+ output_1.output.log({
88
+ title: `Changed files based on resolved "base" (${nxArgs.base}) and "head" (${nxArgs.head ?? 'HEAD'})`,
89
+ bodyLines: changedFiles.map((file) => ` - ${file}`),
90
+ });
91
+ }
92
+ else {
93
+ output_1.output.warn({
94
+ title: 'No changed files found based on resolved "base" and "head"',
95
+ });
60
96
  }
61
97
  }
62
- else {
63
- // TODO: use project names instead of the implicit default release group name? (though this might be confusing, as users might think they can just delete one of the project bumps to change the behavior to independent versioning)
64
- setBumpIfNotNone(group.name, args.bump ||
65
- (await promptForVersion(`How do you want to bump the versions of all projects?`)));
66
- }
98
+ const resolvedAllFileData = await (0, all_file_data_1.allFileData)();
99
+ getProjectsToVersionForGroup = (0, get_touched_projects_for_group_1.createGetTouchedProjectsForGroup)(nxArgs, projectGraph, changedFiles, resolvedAllFileData);
67
100
  }
68
- else {
69
- for (const group of releaseGroups) {
70
- if (group.projectsRelationship === 'independent') {
71
- for (const project of releaseGroupToFilteredProjects.get(group)) {
101
+ if (args.projects?.length) {
102
+ /**
103
+ * Run plan for all remaining release groups and filtered projects within them
104
+ */
105
+ for (const releaseGroup of releaseGroups) {
106
+ const releaseGroupName = releaseGroup.name;
107
+ const releaseGroupProjectNames = Array.from(releaseGroupToFilteredProjects.get(releaseGroup));
108
+ let applicableProjects = releaseGroupProjectNames;
109
+ if (args.onlyTouched &&
110
+ typeof getProjectsToVersionForGroup === 'function') {
111
+ applicableProjects = await getProjectsToVersionForGroup(releaseGroup, releaseGroupProjectNames, true);
112
+ }
113
+ if (!applicableProjects.length) {
114
+ continue;
115
+ }
116
+ if (releaseGroup.projectsRelationship === 'independent') {
117
+ for (const project of applicableProjects) {
72
118
  setBumpIfNotNone(project, args.bump ||
73
- (await promptForVersion(`How do you want to bump the version of the project "${project}" within group "${group.name}"?`)));
119
+ (await promptForVersion(`How do you want to bump the version of the project "${project}"${releaseGroupName === config_1.IMPLICIT_DEFAULT_RELEASE_GROUP
120
+ ? ''
121
+ : ` within group "${releaseGroupName}"`}?`)));
74
122
  }
75
123
  }
76
124
  else {
77
- setBumpIfNotNone(group.name, args.bump ||
78
- (await promptForVersion(`How do you want to bump the versions of the projects in the group "${group.name}"?`)));
125
+ setBumpIfNotNone(releaseGroupName, args.bump ||
126
+ (await promptForVersion(`How do you want to bump the versions of ${releaseGroupName === config_1.IMPLICIT_DEFAULT_RELEASE_GROUP
127
+ ? 'all projects'
128
+ : `the projects in the group "${releaseGroupName}"`}?`)));
79
129
  }
80
130
  }
81
- }
82
- if (!Object.keys(versionPlanBumps).length) {
83
- output_1.output.warn({
84
- title: 'No version bumps were selected so no version plan file was created.',
85
- });
131
+ // Create a version plan file if applicable
132
+ await createVersionPlanFileForBumps(args, versionPlanBumps);
86
133
  return 0;
87
134
  }
88
- const versionPlanName = `version-plan-${new Date().getTime()}`;
89
- const versionPlanMessage = args.message || (await promptForMessage(versionPlanName));
90
- const versionPlanFileContent = (0, generate_version_plan_content_1.generateVersionPlanContent)(versionPlanBumps, versionPlanMessage);
91
- const versionPlanFileName = `${versionPlanName}.md`;
92
- if (args.dryRun) {
93
- output_1.output.logSingleLine(`Would create version plan file "${versionPlanFileName}", but --dry-run was set.`);
94
- (0, print_changes_1.printDiff)('', versionPlanFileContent, 1);
95
- }
96
- else {
97
- output_1.output.logSingleLine(`Creating version plan file "${versionPlanFileName}"`);
98
- (0, print_changes_1.printDiff)('', versionPlanFileContent, 1);
99
- const versionPlansAbsolutePath = (0, version_plans_1.getVersionPlansAbsolutePath)();
100
- await (0, fs_extra_1.ensureDir)(versionPlansAbsolutePath);
101
- await (0, fs_extra_1.writeFile)((0, node_path_1.join)(versionPlansAbsolutePath, versionPlanFileName), versionPlanFileContent);
135
+ /**
136
+ * Run plan for all remaining release groups
137
+ */
138
+ for (const releaseGroup of releaseGroups) {
139
+ const releaseGroupName = releaseGroup.name;
140
+ let applicableProjects = releaseGroup.projects;
141
+ if (args.onlyTouched &&
142
+ typeof getProjectsToVersionForGroup === 'function') {
143
+ applicableProjects = await getProjectsToVersionForGroup(releaseGroup, releaseGroup.projects, false);
144
+ }
145
+ if (!applicableProjects.length) {
146
+ continue;
147
+ }
148
+ if (releaseGroup.projectsRelationship === 'independent') {
149
+ for (const project of applicableProjects) {
150
+ setBumpIfNotNone(project, args.bump ||
151
+ (await promptForVersion(`How do you want to bump the version of the project "${project}"${releaseGroupName === config_1.IMPLICIT_DEFAULT_RELEASE_GROUP
152
+ ? ''
153
+ : ` within group "${releaseGroupName}"`}?`)));
154
+ }
155
+ }
156
+ else {
157
+ setBumpIfNotNone(releaseGroupName, args.bump ||
158
+ (await promptForVersion(`How do you want to bump the versions of ${releaseGroupName === config_1.IMPLICIT_DEFAULT_RELEASE_GROUP
159
+ ? 'all projects'
160
+ : `the projects in the group "${releaseGroupName}"`}?`)));
161
+ }
102
162
  }
163
+ // Create a version plan file if applicable
164
+ await createVersionPlanFileForBumps(args, versionPlanBumps);
103
165
  return 0;
104
166
  };
105
167
  }
168
+ async function createVersionPlanFileForBumps(args, versionPlanBumps) {
169
+ if (!Object.keys(versionPlanBumps).length) {
170
+ let bodyLines = [];
171
+ if (args.onlyTouched) {
172
+ bodyLines = [
173
+ 'This might be because no projects have been changed, or projects you expected to release have not been touched',
174
+ 'To include all projects, not just those that have been changed, pass --only-touched=false',
175
+ 'Alternatively, you can specify alternate --base and --head refs to include only changes from certain commits',
176
+ ];
177
+ }
178
+ output_1.output.warn({
179
+ title: 'No version bumps were selected so no version plan file was created.',
180
+ bodyLines,
181
+ });
182
+ return 0;
183
+ }
184
+ const versionPlanName = `version-plan-${new Date().getTime()}`;
185
+ const versionPlanMessage = args.message || (await promptForMessage(versionPlanName));
186
+ const versionPlanFileContent = (0, generate_version_plan_content_1.generateVersionPlanContent)(versionPlanBumps, versionPlanMessage);
187
+ const versionPlanFileName = `${versionPlanName}.md`;
188
+ if (args.dryRun) {
189
+ output_1.output.logSingleLine(`Would create version plan file "${versionPlanFileName}", but --dry-run was set.`);
190
+ (0, print_changes_1.printDiff)('', versionPlanFileContent, 1);
191
+ }
192
+ else {
193
+ output_1.output.logSingleLine(`Creating version plan file "${versionPlanFileName}"`);
194
+ (0, print_changes_1.printDiff)('', versionPlanFileContent, 1);
195
+ const versionPlansAbsolutePath = (0, version_plans_1.getVersionPlansAbsolutePath)();
196
+ await (0, fs_extra_1.ensureDir)(versionPlansAbsolutePath);
197
+ await (0, fs_extra_1.writeFile)((0, node_path_1.join)(versionPlansAbsolutePath, versionPlanFileName), versionPlanFileContent);
198
+ }
199
+ }
106
200
  async function promptForVersion(message) {
107
201
  try {
108
202
  const reply = await (0, enquirer_1.prompt)([
@@ -0,0 +1,7 @@
1
+ import { FileData, ProjectGraph } from '../../../config/project-graph';
2
+ import { NxArgs } from '../../../utils/command-line-utils';
3
+ import { ReleaseGroupWithName } from '../config/filter-release-groups';
4
+ /**
5
+ * Create a function that returns the touched projects for a given release group. Only relevant when version plans are enabled.
6
+ */
7
+ export declare function createGetTouchedProjectsForGroup(nxArgs: NxArgs, projectGraph: ProjectGraph, changedFiles: string[], fileData: FileData[]): (releaseGroup: ReleaseGroupWithName, releaseGroupFilteredProjectNames: string[], hasProjectsFilter: boolean) => Promise<string[]>;
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createGetTouchedProjectsForGroup = createGetTouchedProjectsForGroup;
4
+ const workspace_projects_1 = require("../../../project-graph/affected/locators/workspace-projects");
5
+ const file_utils_1 = require("../../../project-graph/file-utils");
6
+ const ignore_1 = require("../../../utils/ignore");
7
+ const output_1 = require("../../../utils/output");
8
+ const config_1 = require("../config/config");
9
+ /**
10
+ * Create a function that returns the touched projects for a given release group. Only relevant when version plans are enabled.
11
+ */
12
+ function createGetTouchedProjectsForGroup(nxArgs, projectGraph, changedFiles, fileData) {
13
+ /**
14
+ * Create a minimal subset of touched projects based on the configured ignore patterns, we only need
15
+ * to recompute when the ignorePatternsForPlanCheck differs between release groups.
16
+ */
17
+ const serializedIgnorePatternsToTouchedProjects = new Map();
18
+ return async function getTouchedProjectsForGroup(releaseGroup,
19
+ // We don't access releaseGroups.projects directly, because we need to take the --projects filter into account
20
+ releaseGroupFilteredProjectNames, hasProjectsFilter) {
21
+ // The current release group doesn't leverage version plans
22
+ if (!releaseGroup.versionPlans) {
23
+ return [];
24
+ }
25
+ // Exclude patterns from .nxignore, .gitignore and explicit version plan config
26
+ let serializedIgnorePatterns = '[]';
27
+ const ignore = (0, ignore_1.getIgnoreObject)();
28
+ if (typeof releaseGroup.versionPlans !== 'boolean' &&
29
+ Array.isArray(releaseGroup.versionPlans.ignorePatternsForPlanCheck) &&
30
+ releaseGroup.versionPlans.ignorePatternsForPlanCheck.length) {
31
+ output_1.output.note({
32
+ title: `Applying configured ignore patterns to changed files${releaseGroup.name !== config_1.IMPLICIT_DEFAULT_RELEASE_GROUP
33
+ ? ` for release group "${releaseGroup.name}"`
34
+ : ''}`,
35
+ bodyLines: [
36
+ ...releaseGroup.versionPlans.ignorePatternsForPlanCheck.map((pattern) => ` - ${pattern}`),
37
+ ],
38
+ });
39
+ ignore.add(releaseGroup.versionPlans.ignorePatternsForPlanCheck);
40
+ serializedIgnorePatterns = JSON.stringify(releaseGroup.versionPlans.ignorePatternsForPlanCheck);
41
+ }
42
+ let touchedProjects = {};
43
+ if (serializedIgnorePatternsToTouchedProjects.has(serializedIgnorePatterns)) {
44
+ touchedProjects = serializedIgnorePatternsToTouchedProjects.get(serializedIgnorePatterns);
45
+ }
46
+ else {
47
+ // We only care about directly touched projects, not implicitly affected ones etc
48
+ const touchedProjectsArr = await (0, workspace_projects_1.getTouchedProjects)((0, file_utils_1.calculateFileChanges)(changedFiles, fileData, nxArgs, undefined, ignore), projectGraph.nodes);
49
+ touchedProjects = touchedProjectsArr.reduce((acc, project) => ({ ...acc, [project]: true }), {});
50
+ serializedIgnorePatternsToTouchedProjects.set(serializedIgnorePatterns, touchedProjects);
51
+ }
52
+ const touchedProjectsUnderReleaseGroup = releaseGroupFilteredProjectNames.filter((project) => touchedProjects[project]);
53
+ if (touchedProjectsUnderReleaseGroup.length) {
54
+ output_1.output.log({
55
+ title: `Touched projects${hasProjectsFilter ? ` (after --projects filter applied)` : ''} based on changed files${releaseGroup.name !== config_1.IMPLICIT_DEFAULT_RELEASE_GROUP
56
+ ? ` under release group "${releaseGroup.name}"`
57
+ : ''}`,
58
+ bodyLines: [
59
+ ...touchedProjectsUnderReleaseGroup.map((project) => ` - ${project}`),
60
+ '',
61
+ '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.',
62
+ ],
63
+ });
64
+ }
65
+ else {
66
+ output_1.output.log({
67
+ title: `No touched projects${hasProjectsFilter ? ` (after --projects filter applied)` : ''} found based on changed files${typeof releaseGroup.versionPlans !== 'boolean' &&
68
+ Array.isArray(releaseGroup.versionPlans.ignorePatternsForPlanCheck) &&
69
+ releaseGroup.versionPlans.ignorePatternsForPlanCheck.length
70
+ ? ' combined with configured ignore patterns'
71
+ : ''}${releaseGroup.name !== config_1.IMPLICIT_DEFAULT_RELEASE_GROUP
72
+ ? ` under release group "${releaseGroup.name}"`
73
+ : ''}`,
74
+ });
75
+ }
76
+ return touchedProjectsUnderReleaseGroup;
77
+ };
78
+ }
Binary file
@@ -273,7 +273,7 @@ async function startPluginWorker() {
273
273
  socket,
274
274
  });
275
275
  }
276
- else if (attempts > 1000) {
276
+ else if (attempts > 10000) {
277
277
  // daemon fails to start, the process probably exited
278
278
  // we print the logs and exit the client
279
279
  reject('Failed to start plugin worker.');