nx 20.3.0-canary.20241217-ee4de0b → 20.3.0-canary.20241219-2eb5243

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "20.3.0-canary.20241217-ee4de0b",
3
+ "version": "20.3.0-canary.20241219-2eb5243",
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": {
@@ -82,16 +82,16 @@
82
82
  }
83
83
  },
84
84
  "optionalDependencies": {
85
- "@nx/nx-darwin-arm64": "20.3.0-canary.20241217-ee4de0b",
86
- "@nx/nx-darwin-x64": "20.3.0-canary.20241217-ee4de0b",
87
- "@nx/nx-freebsd-x64": "20.3.0-canary.20241217-ee4de0b",
88
- "@nx/nx-linux-arm-gnueabihf": "20.3.0-canary.20241217-ee4de0b",
89
- "@nx/nx-linux-arm64-gnu": "20.3.0-canary.20241217-ee4de0b",
90
- "@nx/nx-linux-arm64-musl": "20.3.0-canary.20241217-ee4de0b",
91
- "@nx/nx-linux-x64-gnu": "20.3.0-canary.20241217-ee4de0b",
92
- "@nx/nx-linux-x64-musl": "20.3.0-canary.20241217-ee4de0b",
93
- "@nx/nx-win32-arm64-msvc": "20.3.0-canary.20241217-ee4de0b",
94
- "@nx/nx-win32-x64-msvc": "20.3.0-canary.20241217-ee4de0b"
85
+ "@nx/nx-darwin-arm64": "20.3.0-canary.20241219-2eb5243",
86
+ "@nx/nx-darwin-x64": "20.3.0-canary.20241219-2eb5243",
87
+ "@nx/nx-freebsd-x64": "20.3.0-canary.20241219-2eb5243",
88
+ "@nx/nx-linux-arm-gnueabihf": "20.3.0-canary.20241219-2eb5243",
89
+ "@nx/nx-linux-arm64-gnu": "20.3.0-canary.20241219-2eb5243",
90
+ "@nx/nx-linux-arm64-musl": "20.3.0-canary.20241219-2eb5243",
91
+ "@nx/nx-linux-x64-gnu": "20.3.0-canary.20241219-2eb5243",
92
+ "@nx/nx-linux-x64-musl": "20.3.0-canary.20241219-2eb5243",
93
+ "@nx/nx-win32-arm64-msvc": "20.3.0-canary.20241219-2eb5243",
94
+ "@nx/nx-win32-x64-msvc": "20.3.0-canary.20241219-2eb5243"
95
95
  },
96
96
  "nx-migrations": {
97
97
  "migrations": "./migrations.json",
@@ -50,7 +50,7 @@ function createNxJson(repoRoot, angularJson, cacheableOperations, { eslintProjec
50
50
  ].filter(Boolean)
51
51
  : []),
52
52
  ...(eslintProjectConfigFile
53
- ? ['!{projectRoot}/.eslintrc.json', '!{projectRoot}/eslint.config.js']
53
+ ? ['!{projectRoot}/.eslintrc.json', '!{projectRoot}/eslint.config.cjs']
54
54
  : []),
55
55
  ].filter(Boolean),
56
56
  };
@@ -83,8 +83,8 @@ function createNxJson(repoRoot, angularJson, cacheableOperations, { eslintProjec
83
83
  if ((0, fileutils_1.fileExists)((0, path_1.join)(repoRoot, '.eslintrc.json'))) {
84
84
  inputs.push('{workspaceRoot}/.eslintrc.json');
85
85
  }
86
- if ((0, fileutils_1.fileExists)((0, path_1.join)(repoRoot, 'eslint.config.js'))) {
87
- inputs.push('{workspaceRoot}/eslint.config.js');
86
+ if ((0, fileutils_1.fileExists)((0, path_1.join)(repoRoot, 'eslint.config.cjs'))) {
87
+ inputs.push('{workspaceRoot}/eslint.config.cjs');
88
88
  }
89
89
  nxJson.targetDefaults.lint = {
90
90
  ...nxJson.targetDefaults.lint,
@@ -159,7 +159,9 @@ function projectHasKarmaConfig(project) {
159
159
  }
160
160
  function projectHasEslintConfig(project) {
161
161
  return ((0, fileutils_1.fileExists)((0, path_1.join)(project.root, '.eslintrc.json')) ||
162
- (0, fileutils_1.fileExists)((0, path_1.join)(project.root, 'eslint.config.js')));
162
+ (0, fileutils_1.fileExists)((0, path_1.join)(project.root, 'eslint.config.js')) ||
163
+ (0, fileutils_1.fileExists)((0, path_1.join)(project.root, 'eslint.config.mjs')) ||
164
+ (0, fileutils_1.fileExists)((0, path_1.join)(project.root, 'eslint.config.cjs')));
163
165
  }
164
166
  function replaceNgWithNxInPackageJsonScripts(repoRoot) {
165
167
  const packageJsonPath = (0, path_1.join)(repoRoot, 'package.json');
@@ -1,5 +1,6 @@
1
- import { NxReleaseChangelogConfiguration, NxReleaseConfiguration } from '../../config/nx-json';
1
+ import { NxReleaseConfiguration } from '../../config/nx-json';
2
2
  import { ChangelogOptions } from './command-object';
3
+ import { NxReleaseConfig } from './config/config';
3
4
  import { Reference } from './utils/git';
4
5
  import { ReleaseVersion } from './utils/shared';
5
6
  export interface NxReleaseChangelogResult {
@@ -31,4 +32,4 @@ export interface ChangelogChange {
31
32
  }
32
33
  export declare const releaseChangelogCLIHandler: (args: ChangelogOptions) => Promise<number>;
33
34
  export declare function createAPI(overrideReleaseConfig: NxReleaseConfiguration): (args: ChangelogOptions) => Promise<NxReleaseChangelogResult>;
34
- export declare function shouldCreateGitHubRelease(changelogConfig: NxReleaseChangelogConfiguration | false | undefined, createReleaseArg?: ChangelogOptions['createRelease'] | undefined): boolean;
35
+ export declare function shouldCreateGitHubRelease(changelogConfig: NxReleaseConfig['changelog']['workspaceChangelog'] | NxReleaseConfig['changelog']['projectChangelogs'] | NxReleaseConfig['groups'][number]['changelog'], createReleaseArg?: ChangelogOptions['createRelease'] | undefined): boolean;
@@ -74,11 +74,15 @@ function createAPI(overrideReleaseConfig) {
74
74
  });
75
75
  process.exit(1);
76
76
  }
77
- const { error: filterError, releaseGroups, releaseGroupToFilteredProjects, } = (0, filter_release_groups_1.filterReleaseGroups)(projectGraph, nxReleaseConfig, args.projects, args.groups);
77
+ const { error: filterError, filterLog, releaseGroups, releaseGroupToFilteredProjects, } = (0, filter_release_groups_1.filterReleaseGroups)(projectGraph, nxReleaseConfig, args.projects, args.groups);
78
78
  if (filterError) {
79
79
  output_1.output.error(filterError);
80
80
  process.exit(1);
81
81
  }
82
+ if (filterLog &&
83
+ process.env.NX_RELEASE_INTERNAL_SUPPRESS_FILTER_LOG !== 'true') {
84
+ output_1.output.note(filterLog);
85
+ }
82
86
  const rawVersionPlans = await (0, version_plans_1.readRawVersionPlans)();
83
87
  await (0, version_plans_1.setResolvedVersionPlansOnGroups)(rawVersionPlans, releaseGroups, Object.keys(projectGraph.nodes), args.verbose);
84
88
  if (args.deleteVersionPlans === undefined) {
@@ -230,18 +234,7 @@ function createAPI(overrideReleaseConfig) {
230
234
  });
231
235
  if (workspaceChangelog &&
232
236
  shouldCreateGitHubRelease(nxReleaseConfig.changelog.workspaceChangelog, args.createRelease)) {
233
- let hasPushed = false;
234
237
  postGitTasks.push(async (latestCommit) => {
235
- if (!hasPushed) {
236
- output_1.output.logSingleLine(`Pushing to git remote`);
237
- // Before we can create/update the release we need to ensure the commit exists on the remote
238
- await (0, git_1.gitPush)({
239
- gitRemote: args.gitRemote,
240
- dryRun: args.dryRun,
241
- verbose: args.verbose,
242
- });
243
- hasPushed = true;
244
- }
245
238
  output_1.output.logSingleLine(`Creating GitHub Release`);
246
239
  await (0, github_1.createOrUpdateGithubRelease)(nxReleaseConfig.changelog.workspaceChangelog
247
240
  ? nxReleaseConfig.changelog.workspaceChangelog.createRelease
@@ -387,21 +380,10 @@ function createAPI(overrideReleaseConfig) {
387
380
  nxReleaseConfig,
388
381
  projectToAdditionalDependencyBumps,
389
382
  });
390
- let hasPushed = false;
391
383
  for (const [projectName, projectChangelog] of Object.entries(projectChangelogs)) {
392
384
  if (projectChangelogs &&
393
385
  shouldCreateGitHubRelease(releaseGroup.changelog, args.createRelease)) {
394
386
  postGitTasks.push(async (latestCommit) => {
395
- if (!hasPushed) {
396
- output_1.output.logSingleLine(`Pushing to git remote`);
397
- // Before we can create/update the release we need to ensure the commit exists on the remote
398
- await (0, git_1.gitPush)({
399
- gitRemote: args.gitRemote,
400
- dryRun: args.dryRun,
401
- verbose: args.verbose,
402
- });
403
- hasPushed = true;
404
- }
405
387
  output_1.output.logSingleLine(`Creating GitHub Release`);
406
388
  await (0, github_1.createOrUpdateGithubRelease)(releaseGroup.changelog
407
389
  ? releaseGroup.changelog.createRelease
@@ -504,21 +486,10 @@ function createAPI(overrideReleaseConfig) {
504
486
  nxReleaseConfig,
505
487
  projectToAdditionalDependencyBumps,
506
488
  });
507
- let hasPushed = false;
508
489
  for (const [projectName, projectChangelog] of Object.entries(projectChangelogs)) {
509
490
  if (projectChangelogs &&
510
491
  shouldCreateGitHubRelease(releaseGroup.changelog, args.createRelease)) {
511
492
  postGitTasks.push(async (latestCommit) => {
512
- if (!hasPushed) {
513
- output_1.output.logSingleLine(`Pushing to git remote`);
514
- // Before we can create/update the release we need to ensure the commit exists on the remote
515
- await (0, git_1.gitPush)({
516
- gitRemote: args.gitRemote,
517
- dryRun: args.dryRun,
518
- verbose: args.verbose,
519
- });
520
- hasPushed = true;
521
- }
522
493
  output_1.output.logSingleLine(`Creating GitHub Release`);
523
494
  await (0, github_1.createOrUpdateGithubRelease)(releaseGroup.changelog
524
495
  ? releaseGroup.changelog.createRelease
@@ -672,6 +643,14 @@ async function applyChangesAndExit(args, nxReleaseConfig, tree, toSHA, postGitTa
672
643
  });
673
644
  }
674
645
  }
646
+ if (args.gitPush ?? nxReleaseConfig.changelog.git.push) {
647
+ output_1.output.logSingleLine(`Pushing to git remote "${args.gitRemote}"`);
648
+ await (0, git_1.gitPush)({
649
+ gitRemote: args.gitRemote,
650
+ dryRun: args.dryRun,
651
+ verbose: args.verbose,
652
+ });
653
+ }
675
654
  // Run any post-git tasks in series
676
655
  for (const postGitTask of postGitTasks) {
677
656
  await postGitTask(latestCommit);
@@ -942,7 +921,10 @@ function shouldCreateGitHubRelease(changelogConfig, createReleaseArg = undefined
942
921
  if (createReleaseArg !== undefined) {
943
922
  return createReleaseArg === 'github';
944
923
  }
945
- return (changelogConfig || {}).createRelease !== false;
924
+ if (changelogConfig === false) {
925
+ return false;
926
+ }
927
+ return changelogConfig.createRelease !== false;
946
928
  }
947
929
  async function promptForGitHubRelease() {
948
930
  try {
@@ -10,7 +10,7 @@ export interface NxReleaseArgs extends BaseNxReleaseArgs {
10
10
  projects?: string[];
11
11
  dryRun?: boolean;
12
12
  }
13
- interface GitCommitAndTagOptions {
13
+ interface GitOptions {
14
14
  stageChanges?: boolean;
15
15
  gitCommit?: boolean;
16
16
  gitCommitMessage?: string;
@@ -18,20 +18,21 @@ interface GitCommitAndTagOptions {
18
18
  gitTag?: boolean;
19
19
  gitTagMessage?: string;
20
20
  gitTagArgs?: string | string[];
21
+ gitPush?: boolean;
22
+ gitRemote?: string;
21
23
  }
22
- export type VersionOptions = NxReleaseArgs & GitCommitAndTagOptions & VersionPlanArgs & FirstReleaseArgs & {
24
+ export type VersionOptions = NxReleaseArgs & GitOptions & VersionPlanArgs & FirstReleaseArgs & {
23
25
  specifier?: string;
24
26
  preid?: string;
25
27
  stageChanges?: boolean;
26
28
  generatorOptionsOverrides?: Record<string, unknown>;
27
29
  };
28
- export type ChangelogOptions = NxReleaseArgs & GitCommitAndTagOptions & VersionPlanArgs & FirstReleaseArgs & {
30
+ export type ChangelogOptions = NxReleaseArgs & GitOptions & VersionPlanArgs & FirstReleaseArgs & {
29
31
  version?: string | null;
30
32
  versionData?: VersionData;
31
33
  to?: string;
32
34
  from?: string;
33
35
  interactive?: string;
34
- gitRemote?: string;
35
36
  createRelease?: false | 'github';
36
37
  };
37
38
  export type PublishOptions = NxReleaseArgs & Partial<RunManyOptions> & {
@@ -104,7 +104,7 @@ const versionCommand = {
104
104
  command: 'version [specifier]',
105
105
  aliases: ['v'],
106
106
  describe: 'Create a version and release for one or more applications and libraries.',
107
- builder: (yargs) => withFirstReleaseOptions(withGitCommitAndGitTagOptions(yargs
107
+ builder: (yargs) => withFirstReleaseOptions(withGitOptions(yargs
108
108
  .positional('specifier', {
109
109
  type: 'string',
110
110
  describe: 'Exact version or semver keyword to apply to the selected release group.',
@@ -131,7 +131,7 @@ const changelogCommand = {
131
131
  command: 'changelog [version]',
132
132
  aliases: ['c'],
133
133
  describe: 'Generate a changelog for one or more projects, and optionally push to Github.',
134
- builder: (yargs) => withFirstReleaseOptions(withGitCommitAndGitTagOptions(yargs
134
+ builder: (yargs) => withFirstReleaseOptions(withGitOptions(yargs
135
135
  // Disable default meaning of yargs version for this command
136
136
  .version(false)
137
137
  .positional('version', {
@@ -152,11 +152,6 @@ const changelogCommand = {
152
152
  type: 'string',
153
153
  description: 'Interactively modify changelog markdown contents in your code editor before applying the changes. You can set it to be interactive for all changelogs, or only the workspace level, or only the project level.',
154
154
  choices: ['all', 'workspace', 'projects'],
155
- })
156
- .option('git-remote', {
157
- type: 'string',
158
- description: 'Alternate git remote in the form {user}/{repo} on which to create the Github release (useful for testing).',
159
- default: 'origin',
160
155
  })
161
156
  .check((argv) => {
162
157
  if (!argv.version) {
@@ -256,7 +251,7 @@ function coerceParallelOption(args) {
256
251
  parallel: (0, shared_options_1.readParallelFromArgsAndEnv)(args),
257
252
  };
258
253
  }
259
- function withGitCommitAndGitTagOptions(yargs) {
254
+ function withGitOptions(yargs) {
260
255
  return yargs
261
256
  .option('git-commit', {
262
257
  describe: 'Whether or not to automatically commit the changes made by this command.',
@@ -285,6 +280,15 @@ function withGitCommitAndGitTagOptions(yargs) {
285
280
  .option('stage-changes', {
286
281
  describe: 'Whether or not to stage the changes made by this command. Always treated as true if git-commit is true.',
287
282
  type: 'boolean',
283
+ })
284
+ .option('git-push', {
285
+ describe: 'Whether or not to automatically push the changes made by this command to the remote git repository.',
286
+ type: 'boolean',
287
+ })
288
+ .option('git-remote', {
289
+ type: 'string',
290
+ description: 'Alternate git remote to push commits and tags to (can be useful for testing).',
291
+ default: 'origin',
288
292
  });
289
293
  }
290
294
  function withFirstReleaseOptions(yargs) {
@@ -42,7 +42,7 @@ export type NxReleaseConfig = Omit<DeepRequired<NxJsonConfiguration['release'] &
42
42
  };
43
43
  }>, 'projects'>;
44
44
  export interface CreateNxReleaseConfigError {
45
- code: 'PROJECTS_AND_GROUPS_DEFINED' | 'RELEASE_GROUP_MATCHES_NO_PROJECTS' | 'RELEASE_GROUP_RELEASE_TAG_PATTERN_VERSION_PLACEHOLDER_MISSING_OR_EXCESSIVE' | 'PROJECT_MATCHES_MULTIPLE_GROUPS' | 'CONVENTIONAL_COMMITS_SHORTHAND_MIXED_WITH_OVERLAPPING_GENERATOR_OPTIONS' | 'GLOBAL_GIT_CONFIG_MIXED_WITH_GRANULAR_GIT_CONFIG' | 'CANNOT_RESOLVE_CHANGELOG_RENDERER' | 'INVALID_CHANGELOG_CREATE_RELEASE_PROVIDER' | 'INVALID_CHANGELOG_CREATE_RELEASE_HOSTNAME' | 'INVALID_CHANGELOG_CREATE_RELEASE_API_BASE_URL';
45
+ code: 'PROJECTS_AND_GROUPS_DEFINED' | 'RELEASE_GROUP_MATCHES_NO_PROJECTS' | 'RELEASE_GROUP_RELEASE_TAG_PATTERN_VERSION_PLACEHOLDER_MISSING_OR_EXCESSIVE' | 'PROJECT_MATCHES_MULTIPLE_GROUPS' | 'CONVENTIONAL_COMMITS_SHORTHAND_MIXED_WITH_OVERLAPPING_GENERATOR_OPTIONS' | 'GLOBAL_GIT_CONFIG_MIXED_WITH_GRANULAR_GIT_CONFIG' | 'CANNOT_RESOLVE_CHANGELOG_RENDERER' | 'INVALID_CHANGELOG_CREATE_RELEASE_PROVIDER' | 'INVALID_CHANGELOG_CREATE_RELEASE_HOSTNAME' | 'INVALID_CHANGELOG_CREATE_RELEASE_API_BASE_URL' | 'GIT_PUSH_FALSE_WITH_CREATE_RELEASE';
46
46
  data: Record<string, string | string[]>;
47
47
  }
48
48
  export declare function createNxReleaseConfig(projectGraph: ProjectGraph, projectFileMap: ProjectFileMap, userConfig?: NxJsonConfiguration['release']): Promise<{
@@ -64,19 +64,51 @@ async function createNxReleaseConfig(projectGraph, projectFileMap, userConfig =
64
64
  tagMessage: '',
65
65
  tagArgs: '',
66
66
  stageChanges: false,
67
+ push: false,
67
68
  };
68
69
  const versionGitDefaults = {
69
70
  ...gitDefaults,
70
71
  stageChanges: true,
71
72
  };
73
+ const isObjectWithCreateReleaseEnabled = (data) => typeof data === 'object' &&
74
+ data !== null &&
75
+ 'createRelease' in data &&
76
+ (typeof data.createRelease === 'string' ||
77
+ (typeof data.createRelease === 'object' && data.createRelease !== null));
78
+ const isCreateReleaseEnabledAtTheRoot = isObjectWithCreateReleaseEnabled(userConfig.changelog?.workspaceChangelog);
79
+ const isCreateReleaseEnabledForProjectChangelogs =
80
+ // At the root
81
+ isObjectWithCreateReleaseEnabled(userConfig.changelog?.projectChangelogs) ||
82
+ // Or any release group
83
+ Object.values(userConfig.groups ?? {}).some((group) => isObjectWithCreateReleaseEnabled(group.changelog));
84
+ const isGitPushExplicitlyDisabled = userConfig.git?.push === false ||
85
+ userConfig.changelog?.git?.push === false ||
86
+ userConfig.version?.git?.push === false;
87
+ if (isGitPushExplicitlyDisabled &&
88
+ (isCreateReleaseEnabledAtTheRoot ||
89
+ isCreateReleaseEnabledForProjectChangelogs)) {
90
+ return {
91
+ error: {
92
+ code: 'GIT_PUSH_FALSE_WITH_CREATE_RELEASE',
93
+ data: {},
94
+ },
95
+ nxReleaseConfig: null,
96
+ };
97
+ }
72
98
  const changelogGitDefaults = {
73
99
  ...gitDefaults,
74
100
  commit: true,
75
101
  tag: true,
102
+ push:
103
+ // We have to perform a git push in order to create a release
104
+ isCreateReleaseEnabledAtTheRoot ||
105
+ isCreateReleaseEnabledForProjectChangelogs
106
+ ? true
107
+ : false,
76
108
  };
77
109
  const defaultFixedReleaseTagPattern = 'v{version}';
78
110
  /**
79
- * TODO: in v20, make it so that this pattern is used by default when any custom groups are used
111
+ * TODO(v21): in v21, make it so that this pattern is used by default when any custom groups are used
80
112
  */
81
113
  const defaultFixedGroupReleaseTagPattern = '{releaseGroupName}-v{version}';
82
114
  const defaultIndependentReleaseTagPattern = '{projectName}@{version}';
@@ -596,6 +628,17 @@ async function handleNxReleaseConfigError(error) {
596
628
  });
597
629
  }
598
630
  break;
631
+ case 'GIT_PUSH_FALSE_WITH_CREATE_RELEASE':
632
+ {
633
+ const nxJsonMessage = await (0, resolve_nx_json_error_message_1.resolveNxJsonConfigErrorMessage)([
634
+ 'release',
635
+ ]);
636
+ output_1.output.error({
637
+ title: `The createRelease option for changelogs cannot be enabled when git push is explicitly disabled because the commit needs to be pushed to the remote in order to tie the release to it`,
638
+ bodyLines: [nxJsonMessage],
639
+ });
640
+ }
641
+ break;
599
642
  default:
600
643
  throw new Error(`Unhandled error code: ${error.code}`);
601
644
  }
@@ -10,6 +10,10 @@ export declare function filterReleaseGroups(projectGraph: ProjectGraph, nxReleas
10
10
  title: string;
11
11
  bodyLines?: string[];
12
12
  };
13
+ filterLog: {
14
+ title: string;
15
+ bodyLines: string[];
16
+ } | null;
13
17
  releaseGroups: ReleaseGroupWithName[];
14
18
  releaseGroupToFilteredProjects: Map<ReleaseGroupWithName, Set<string>>;
15
19
  };
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.filterReleaseGroups = filterReleaseGroups;
4
4
  const find_matching_projects_1 = require("../../../utils/find-matching-projects");
5
- const output_1 = require("../../../utils/output");
6
5
  const config_1 = require("./config");
7
6
  function filterReleaseGroups(projectGraph, nxReleaseConfig, projectsFilter, groupsFilter) {
7
+ let filterLog = null;
8
8
  let releaseGroups = Object.entries(nxReleaseConfig.groups).map(([name, group]) => {
9
9
  return {
10
10
  ...group,
@@ -34,6 +34,7 @@ function filterReleaseGroups(projectGraph, nxReleaseConfig, projectsFilter, grou
34
34
  error: {
35
35
  title: `Your --projects filter "${projectsFilter}" did not match any projects in the workspace`,
36
36
  },
37
+ filterLog: null,
37
38
  releaseGroups: [],
38
39
  releaseGroupToFilteredProjects,
39
40
  };
@@ -62,6 +63,7 @@ function filterReleaseGroups(projectGraph, nxReleaseConfig, projectsFilter, grou
62
63
  title: `The following projects which match your projects filter "${projectsFilter}" did not match any configured release groups:`,
63
64
  bodyLines: unmatchedProjects.map((p) => `- ${p}`),
64
65
  },
66
+ filterLog: null,
65
67
  releaseGroups: [],
66
68
  releaseGroupToFilteredProjects,
67
69
  };
@@ -85,6 +87,7 @@ function filterReleaseGroups(projectGraph, nxReleaseConfig, projectsFilter, grou
85
87
  title: `In order to release specific projects independently with --projects those projects must be configured appropriately. For example, by setting \`"projectsRelationship": "independent"\` in your nx.json config.`,
86
88
  bodyLines: [],
87
89
  },
90
+ filterLog: null,
88
91
  releaseGroups: [],
89
92
  releaseGroupToFilteredProjects,
90
93
  };
@@ -94,11 +97,12 @@ function filterReleaseGroups(projectGraph, nxReleaseConfig, projectsFilter, grou
94
97
  title: `Your --projects filter "${projectsFilter}" matched projects in the following release groups which do not have "independent" configured for their "projectsRelationship":`,
95
98
  bodyLines: releaseGroupsThatAreNotIndependent.map((rg) => `- ${rg.name}`),
96
99
  },
100
+ filterLog: null,
97
101
  releaseGroups: [],
98
102
  releaseGroupToFilteredProjects,
99
103
  };
100
104
  }
101
- output_1.output.note({
105
+ filterLog = {
102
106
  title: `Your filter "${projectsFilter}" matched the following projects:`,
103
107
  bodyLines: matchingProjectsForFilter.map((p) => {
104
108
  const releaseGroupForProject = filteredProjectToReleaseGroup.get(p);
@@ -107,7 +111,7 @@ function filterReleaseGroups(projectGraph, nxReleaseConfig, projectsFilter, grou
107
111
  }
108
112
  return `- ${p} (release group "${releaseGroupForProject.name}")`;
109
113
  }),
110
- });
114
+ };
111
115
  // Filter the releaseGroups collection appropriately
112
116
  for (const [releaseGroupWithName, matchingProjects,] of releaseGroupToFilteredProjects.entries()) {
113
117
  if (matchingProjects.size === 0) {
@@ -117,6 +121,7 @@ function filterReleaseGroups(projectGraph, nxReleaseConfig, projectsFilter, grou
117
121
  releaseGroups = releaseGroups.filter((rg) => releaseGroupToFilteredProjects.get(rg)?.size > 0);
118
122
  return {
119
123
  error: null,
124
+ filterLog,
120
125
  releaseGroups,
121
126
  releaseGroupToFilteredProjects,
122
127
  };
@@ -138,12 +143,14 @@ function filterReleaseGroups(projectGraph, nxReleaseConfig, projectsFilter, grou
138
143
  : // Getting to this point should be impossible, as we should have explicitly handled any errors/invalid config by now
139
144
  `No projects could be matched for versioning, please report this case and include your nx.json config and command line arguments`,
140
145
  },
146
+ filterLog: null,
141
147
  releaseGroups: [],
142
148
  releaseGroupToFilteredProjects,
143
149
  };
144
150
  }
145
151
  return {
146
152
  error: null,
153
+ filterLog,
147
154
  releaseGroups,
148
155
  releaseGroupToFilteredProjects,
149
156
  };
@@ -54,11 +54,15 @@ function createAPI(overrideReleaseConfig) {
54
54
  isDebug: args.printConfig === 'debug',
55
55
  });
56
56
  }
57
- const { error: filterError, releaseGroups, releaseGroupToFilteredProjects, } = (0, filter_release_groups_1.filterReleaseGroups)(projectGraph, nxReleaseConfig, _args.projects, _args.groups);
57
+ const { error: filterError, filterLog, releaseGroups, releaseGroupToFilteredProjects, } = (0, filter_release_groups_1.filterReleaseGroups)(projectGraph, nxReleaseConfig, _args.projects, _args.groups);
58
58
  if (filterError) {
59
59
  output_1.output.error(filterError);
60
60
  process.exit(1);
61
61
  }
62
+ if (filterLog &&
63
+ process.env.NX_RELEASE_INTERNAL_SUPPRESS_FILTER_LOG !== 'true') {
64
+ output_1.output.note(filterLog);
65
+ }
62
66
  /**
63
67
  * If the user is filtering to a subset of projects or groups, we should not run the publish task
64
68
  * for dependencies, because that could cause projects outset of the filtered set to be published.
@@ -57,6 +57,16 @@ function createAPI(overrideReleaseConfig) {
57
57
  isDebug: args.printConfig === 'debug',
58
58
  });
59
59
  }
60
+ const { error: filterError, filterLog, releaseGroups, releaseGroupToFilteredProjects, } = (0, filter_release_groups_1.filterReleaseGroups)(projectGraph, nxReleaseConfig, args.projects, args.groups);
61
+ if (filterError) {
62
+ output_1.output.error(filterError);
63
+ process.exit(1);
64
+ }
65
+ if (filterLog) {
66
+ output_1.output.note(filterLog);
67
+ }
68
+ // Do not repeat the filter log in the release subcommands
69
+ process.env.NX_RELEASE_INTERNAL_SUPPRESS_FILTER_LOG = 'true';
60
70
  const rawVersionPlans = await (0, version_plans_1.readRawVersionPlans)();
61
71
  if (args.specifier && rawVersionPlans.length > 0) {
62
72
  output_1.output.error({
@@ -72,6 +82,11 @@ function createAPI(overrideReleaseConfig) {
72
82
  const shouldCommit = userProvidedReleaseConfig.git?.commit ?? true;
73
83
  const shouldStage = (shouldCommit || userProvidedReleaseConfig.git?.stageChanges) ?? false;
74
84
  const shouldTag = userProvidedReleaseConfig.git?.tag ?? true;
85
+ const shouldCreateWorkspaceRelease = (0, changelog_1.shouldCreateGitHubRelease)(nxReleaseConfig.changelog.workspaceChangelog);
86
+ // If the workspace or any of the release groups specify that a github release should be created, we need to push the changes to the remote
87
+ const shouldPush = (shouldCreateWorkspaceRelease ||
88
+ releaseGroups.some((group) => (0, changelog_1.shouldCreateGitHubRelease)(group.changelog))) ??
89
+ false;
75
90
  const versionResult = await releaseVersion({
76
91
  ...args,
77
92
  stageChanges: shouldStage,
@@ -86,14 +101,10 @@ function createAPI(overrideReleaseConfig) {
86
101
  stageChanges: shouldStage,
87
102
  gitCommit: false,
88
103
  gitTag: false,
104
+ gitPush: false,
89
105
  createRelease: false,
90
106
  deleteVersionPlans: false,
91
107
  });
92
- const { error: filterError, releaseGroups, releaseGroupToFilteredProjects, } = (0, filter_release_groups_1.filterReleaseGroups)(projectGraph, nxReleaseConfig, args.projects, args.groups);
93
- if (filterError) {
94
- output_1.output.error(filterError);
95
- process.exit(1);
96
- }
97
108
  await (0, version_plans_1.setResolvedVersionPlansOnGroups)(rawVersionPlans, releaseGroups, Object.keys(projectGraph.nodes), args.verbose);
98
109
  const planFiles = new Set();
99
110
  releaseGroups.forEach((group) => {
@@ -155,17 +166,20 @@ function createAPI(overrideReleaseConfig) {
155
166
  });
156
167
  }
157
168
  }
158
- const shouldCreateWorkspaceRelease = (0, changelog_1.shouldCreateGitHubRelease)(nxReleaseConfig.changelog.workspaceChangelog);
159
169
  let hasPushedChanges = false;
160
- let latestCommit;
161
- if (shouldCreateWorkspaceRelease && changelogResult.workspaceChangelog) {
162
- output_1.output.logSingleLine(`Pushing to git remote`);
163
- // Before we can create/update the release we need to ensure the commit exists on the remote
170
+ if (shouldPush) {
171
+ output_1.output.logSingleLine(`Pushing to git remote "origin"`);
164
172
  await (0, git_1.gitPush)({
165
173
  dryRun: args.dryRun,
166
174
  verbose: args.verbose,
167
175
  });
168
176
  hasPushedChanges = true;
177
+ }
178
+ let latestCommit;
179
+ if (shouldCreateWorkspaceRelease && changelogResult.workspaceChangelog) {
180
+ if (!hasPushedChanges) {
181
+ throw new Error('It is not possible to create a github release for the workspace without pushing the changes to the remote, please ensure that you have not disabled git push in your nx release config');
182
+ }
169
183
  output_1.output.logSingleLine(`Creating GitHub Release`);
170
184
  latestCommit = await (0, git_1.getCommitHash)('HEAD');
171
185
  await (0, github_1.createOrUpdateGithubRelease)(nxReleaseConfig.changelog.workspaceChangelog
@@ -187,13 +201,7 @@ function createAPI(overrideReleaseConfig) {
187
201
  continue;
188
202
  }
189
203
  if (!hasPushedChanges) {
190
- output_1.output.logSingleLine(`Pushing to git remote`);
191
- // Before we can create/update the release we need to ensure the commit exists on the remote
192
- await (0, git_1.gitPush)({
193
- dryRun: args.dryRun,
194
- verbose: args.verbose,
195
- });
196
- hasPushedChanges = true;
204
+ throw new Error('It is not possible to create a github release for the project without pushing the changes to the remote, please ensure that you have not disabled git push in your nx release config');
197
205
  }
198
206
  output_1.output.logSingleLine(`Creating GitHub Release`);
199
207
  if (!latestCommit) {
@@ -76,11 +76,15 @@ function createAPI(overrideReleaseConfig) {
76
76
  });
77
77
  process.exit(1);
78
78
  }
79
- const { error: filterError, releaseGroups, releaseGroupToFilteredProjects, } = (0, filter_release_groups_1.filterReleaseGroups)(projectGraph, nxReleaseConfig, args.projects, args.groups);
79
+ const { error: filterError, filterLog, releaseGroups, releaseGroupToFilteredProjects, } = (0, filter_release_groups_1.filterReleaseGroups)(projectGraph, nxReleaseConfig, args.projects, args.groups);
80
80
  if (filterError) {
81
81
  output_1.output.error(filterError);
82
82
  process.exit(1);
83
83
  }
84
+ if (filterLog &&
85
+ process.env.NX_RELEASE_INTERNAL_SUPPRESS_FILTER_LOG !== 'true') {
86
+ output_1.output.note(filterLog);
87
+ }
84
88
  if (!args.specifier) {
85
89
  const rawVersionPlans = await (0, version_plans_1.readRawVersionPlans)();
86
90
  await (0, version_plans_1.setResolvedVersionPlansOnGroups)(rawVersionPlans, releaseGroups, Object.keys(projectGraph.nodes), args.verbose);
@@ -196,6 +200,14 @@ function createAPI(overrideReleaseConfig) {
196
200
  });
197
201
  }
198
202
  }
203
+ if (args.gitPush ?? nxReleaseConfig.version.git.push) {
204
+ output_1.output.logSingleLine(`Pushing to git remote "${args.gitRemote}"`);
205
+ await (0, git_1.gitPush)({
206
+ gitRemote: args.gitRemote,
207
+ dryRun: args.dryRun,
208
+ verbose: args.verbose,
209
+ });
210
+ }
199
211
  return {
200
212
  // An overall workspace version cannot be relevant when filtering to independent projects
201
213
  workspaceVersion: undefined,
@@ -124,9 +124,13 @@ export interface NxReleaseGitConfiguration {
124
124
  */
125
125
  tagMessage?: string;
126
126
  /**
127
- * Additional arguments to pass to the `git tag` command invoked behind the scenes. . May be a string or array of strings.
127
+ * Additional arguments to pass to the `git tag` command invoked behind the scenes. May be a string or array of strings.
128
128
  */
129
129
  tagArgs?: string | string[];
130
+ /**
131
+ * Whether or not to automatically push the changes made by this command to the remote git repository.
132
+ */
133
+ push?: boolean;
130
134
  }
131
135
  export interface NxReleaseConventionalCommitsConfiguration {
132
136
  types?: Record<string,
@@ -125,7 +125,7 @@ export interface ProjectMetadata {
125
125
  };
126
126
  js?: {
127
127
  packageName: string;
128
- packageExports: undefined | PackageJson['exports'];
128
+ packageExports?: PackageJson['exports'];
129
129
  };
130
130
  }
131
131
  export interface TargetMetadata {
Binary file