nx 17.3.0-beta.2 → 17.3.0-beta.3

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/migrations.json CHANGED
@@ -76,6 +76,12 @@
76
76
  "version": "17.0.0-rc.1",
77
77
  "description": "Migration for v17.0.0-rc.1",
78
78
  "implementation": "./src/migrations/update-17-0-0/rm-default-collection-npm-scope"
79
+ },
80
+ "17.3.0-nx-release-git-operations-explicit-opt-out": {
81
+ "cli": "nx",
82
+ "version": "17.3.0-beta.3",
83
+ "description": "Explicitly opt-out of git operations in nx release",
84
+ "implementation": "./src/migrations/update-17-3-0/nx-release-git-operations-explicit-opt-out"
79
85
  }
80
86
  }
81
87
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "17.3.0-beta.2",
3
+ "version": "17.3.0-beta.3",
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": {
@@ -66,7 +66,7 @@
66
66
  "yargs": "^17.6.2",
67
67
  "yargs-parser": "21.1.1",
68
68
  "node-machine-id": "1.1.12",
69
- "@nrwl/tao": "17.3.0-beta.2"
69
+ "@nrwl/tao": "17.3.0-beta.3"
70
70
  },
71
71
  "peerDependencies": {
72
72
  "@swc-node/register": "^1.6.7",
@@ -81,16 +81,16 @@
81
81
  }
82
82
  },
83
83
  "optionalDependencies": {
84
- "@nx/nx-darwin-x64": "17.3.0-beta.2",
85
- "@nx/nx-darwin-arm64": "17.3.0-beta.2",
86
- "@nx/nx-linux-x64-gnu": "17.3.0-beta.2",
87
- "@nx/nx-linux-x64-musl": "17.3.0-beta.2",
88
- "@nx/nx-win32-x64-msvc": "17.3.0-beta.2",
89
- "@nx/nx-linux-arm64-gnu": "17.3.0-beta.2",
90
- "@nx/nx-linux-arm64-musl": "17.3.0-beta.2",
91
- "@nx/nx-linux-arm-gnueabihf": "17.3.0-beta.2",
92
- "@nx/nx-win32-arm64-msvc": "17.3.0-beta.2",
93
- "@nx/nx-freebsd-x64": "17.3.0-beta.2"
84
+ "@nx/nx-darwin-x64": "17.3.0-beta.3",
85
+ "@nx/nx-darwin-arm64": "17.3.0-beta.3",
86
+ "@nx/nx-linux-x64-gnu": "17.3.0-beta.3",
87
+ "@nx/nx-linux-x64-musl": "17.3.0-beta.3",
88
+ "@nx/nx-win32-x64-msvc": "17.3.0-beta.3",
89
+ "@nx/nx-linux-arm64-gnu": "17.3.0-beta.3",
90
+ "@nx/nx-linux-arm64-musl": "17.3.0-beta.3",
91
+ "@nx/nx-linux-arm-gnueabihf": "17.3.0-beta.3",
92
+ "@nx/nx-win32-arm64-msvc": "17.3.0-beta.3",
93
+ "@nx/nx-freebsd-x64": "17.3.0-beta.3"
94
94
  },
95
95
  "nx-migrations": {
96
96
  "migrations": "./migrations.json",
@@ -60,7 +60,7 @@ async function connectToNxCloudPrompt(prompt) {
60
60
  .prompt([
61
61
  {
62
62
  name: 'NxCloud',
63
- message: prompt ?? `Enable distributed caching to make your CI faster`,
63
+ message: prompt ?? `Enable remote caching to make your CI faster`,
64
64
  type: 'autocomplete',
65
65
  choices: [
66
66
  {
@@ -16,6 +16,8 @@ const affected_project_graph_1 = require("../../project-graph/affected/affected-
16
16
  const configuration_1 = require("../../config/configuration");
17
17
  const chunkify_1 = require("../../utils/chunkify");
18
18
  const all_file_data_1 = require("../../utils/all-file-data");
19
+ const workspace_root_1 = require("../../utils/workspace-root");
20
+ const output_1 = require("../../utils/output");
19
21
  const PRETTIER_PATH = getPrettierPath();
20
22
  async function format(command, args) {
21
23
  const { nxArgs } = (0, command_line_utils_1.splitArgsIntoNxArgsAndOverrides)(args, 'affected', { printWarnings: false }, (0, configuration_1.readNxJson)());
@@ -52,21 +54,28 @@ async function getPatterns(args) {
52
54
  }
53
55
  const p = (0, command_line_utils_1.parseFiles)(args);
54
56
  // In prettier v3 the getSupportInfo result is a promise
55
- const supportedExtensions = (await prettier.getSupportInfo()).languages
57
+ const supportedExtensions = new Set((await prettier.getSupportInfo()).languages
56
58
  .flatMap((language) => language.extensions)
57
59
  .filter((extension) => !!extension)
58
60
  // Prettier supports ".swcrc" as a file instead of an extension
59
61
  // So we add ".swcrc" as a supported extension manually
60
62
  // which allows it to be considered for calculating "patterns"
61
- .concat('.swcrc');
62
- const patterns = p.files.filter((f) => (0, fileutils_1.fileExists)(f) && supportedExtensions.includes(path.extname(f)));
63
+ .concat('.swcrc'));
64
+ const patterns = p.files
65
+ .map((f) => path.relative(workspace_root_1.workspaceRoot, f))
66
+ .filter((f) => (0, fileutils_1.fileExists)(f) && supportedExtensions.has(path.extname(f)));
63
67
  // exclude patterns in .nxignore or .gitignore
64
68
  const nonIgnoredPatterns = (0, ignore_1.getIgnoreObject)().filter(patterns);
65
69
  return args.libsAndApps
66
70
  ? await getPatternsFromApps(nonIgnoredPatterns, await (0, all_file_data_1.allFileData)(), graph)
67
71
  : nonIgnoredPatterns;
68
72
  }
69
- catch {
73
+ catch (err) {
74
+ output_1.output.error({
75
+ title: err?.message ||
76
+ 'Something went wrong when resolving the list of files for the formatter',
77
+ bodyLines: [`Defaulting to all files pattern: "${allFilesPattern}"`],
78
+ });
70
79
  return allFilesPattern;
71
80
  }
72
81
  }
@@ -305,6 +305,7 @@ async function startServer(html, environmentJs, host, port = 4211, watchForchang
305
305
  currentProjectGraphClientResponse.focus = focus;
306
306
  currentProjectGraphClientResponse.groupByFolder = groupByFolder;
307
307
  currentProjectGraphClientResponse.exclude = exclude;
308
+ currentSourceMapsClientResponse = sourceMapResponse;
308
309
  const app = http.createServer(async (req, res) => {
309
310
  // parse URL
310
311
  const parsedUrl = new node_url_1.URL(req.url, `http://${host}:${port}`);
@@ -312,6 +313,7 @@ async function startServer(html, environmentJs, host, port = 4211, watchForchang
312
313
  // Avoid https://en.wikipedia.org/wiki/Directory_traversal_attack
313
314
  // e.g curl --path-as-is http://localhost:9000/../fileInDanger.txt
314
315
  // by limiting the path to current directory only
316
+ res.setHeader('Access-Control-Allow-Origin', '*');
315
317
  const sanitizePath = (0, path_1.basename)(parsedUrl.pathname);
316
318
  if (sanitizePath === 'project-graph.json') {
317
319
  res.writeHead(200, { 'Content-Type': 'application/json' });
@@ -417,7 +419,8 @@ function createFileWatcher() {
417
419
  output_1.output.note({ title: 'Recalculating project graph...' });
418
420
  const { projectGraphClientResponse, sourceMapResponse } = await createProjectGraphAndSourceMapClientResponse();
419
421
  if (projectGraphClientResponse.hash !==
420
- currentProjectGraphClientResponse.hash) {
422
+ currentProjectGraphClientResponse.hash &&
423
+ sourceMapResponse) {
421
424
  output_1.output.note({ title: 'Graph changes updated.' });
422
425
  currentProjectGraphClientResponse = projectGraphClientResponse;
423
426
  currentSourceMapsClientResponse = sourceMapResponse;
@@ -439,7 +442,7 @@ async function createProjectGraphAndSourceMapClientResponse(affected = []) {
439
442
  const projects = Object.values(graph.nodes);
440
443
  const dependencies = graph.dependencies;
441
444
  const hasher = (0, crypto_1.createHash)('sha256');
442
- hasher.update(JSON.stringify({ layout, projects, dependencies }));
445
+ hasher.update(JSON.stringify({ layout, projects, dependencies, sourceMaps }));
443
446
  const hash = hasher.digest('hex');
444
447
  perf_hooks_1.performance.mark('project graph response generation:end');
445
448
  perf_hooks_1.performance.measure('project graph watch calculation', 'project graph watch calculation:start', 'project graph watch calculation:end');
@@ -4,7 +4,7 @@ exports.yargsInitCommand = void 0;
4
4
  const shared_options_1 = require("../yargs-utils/shared-options");
5
5
  exports.yargsInitCommand = {
6
6
  command: 'init',
7
- describe: 'Adds Nx to any type of workspace. It installs nx, creates an nx.json configuration file and optionally sets up distributed caching. For more info, check https://nx.dev/recipes/adopting-nx.',
7
+ describe: 'Adds Nx to any type of workspace. It installs nx, creates an nx.json configuration file and optionally sets up remote caching. For more info, check https://nx.dev/recipes/adopting-nx.',
8
8
  builder: (yargs) => withInitOptions(yargs),
9
9
  handler: async (args) => {
10
10
  await (await Promise.resolve().then(() => require('./init'))).initHandler(args);
@@ -15,7 +15,7 @@ function withInitOptions(yargs) {
15
15
  return yargs
16
16
  .option('nxCloud', {
17
17
  type: 'boolean',
18
- description: 'Set up distributed caching with Nx Cloud.',
18
+ description: 'Set up remote caching with Nx Cloud.',
19
19
  })
20
20
  .option('interactive', {
21
21
  describe: 'When false disables interactive input prompts for options.',
@@ -16,7 +16,7 @@ async function askAboutNxCloud() {
16
16
  .prompt([
17
17
  {
18
18
  name: 'NxCloud',
19
- message: `Enable distributed caching to make your CI faster`,
19
+ message: `Enable remote caching to make your CI faster`,
20
20
  type: 'autocomplete',
21
21
  choices: [
22
22
  {
@@ -74,8 +74,8 @@ async function releaseChangelog(args) {
74
74
  throw new Error(`You are attempting to recreate the changelog for an old release, but you have enabled auto-commit mode. Please disable auto-commit mode by updating your nx.json, or passing --git-commit=false`);
75
75
  }
76
76
  const tree = new tree_1.FsTree(workspace_root_1.workspaceRoot, args.verbose);
77
- const userCommitMessage = args.gitCommitMessage || nxReleaseConfig.changelog.git.commitMessage;
78
- const commitMessageValues = (0, shared_1.createCommitMessageValues)(releaseGroups, releaseGroupToFilteredProjects, projectsVersionData, userCommitMessage);
77
+ const commitMessage = args.gitCommitMessage || nxReleaseConfig.changelog.git.commitMessage;
78
+ const commitMessageValues = (0, shared_1.createCommitMessageValues)(releaseGroups, releaseGroupToFilteredProjects, projectsVersionData, commitMessage);
79
79
  // Resolve any git tags as early as possible so that we can hard error in case of any duplicates before reaching the actual git command
80
80
  const gitTagValues = args.gitTag ?? nxReleaseConfig.changelog.git.tag
81
81
  ? (0, shared_1.createGitTagValues)(releaseGroups, releaseGroupToFilteredProjects, projectsVersionData)
@@ -101,10 +101,9 @@ const versionCommand = {
101
101
  describe: 'The optional prerelease identifier to apply to the version, in the case that specifier has been set to prerelease.',
102
102
  default: '',
103
103
  })
104
- .option('stageChanges', {
104
+ .option('stage-changes', {
105
105
  type: 'boolean',
106
- describe: 'Whether or not to stage the changes made by this command, irrespective of the git config in nx.json related to automated commits. Useful when combining this command with changelog generation.',
107
- default: false,
106
+ describe: 'Whether or not to stage the changes made by this command. Useful when combining this command with changelog generation.',
108
107
  })),
109
108
  handler: (args) => Promise.resolve().then(() => require('./version')).then((m) => m.releaseVersionCLIHandler(args))
110
109
  .then((versionDataOrExitCode) => {
@@ -21,12 +21,21 @@ requiredTargetName) {
21
21
  }
22
22
  const gitDefaults = {
23
23
  commit: false,
24
- commitMessage: '',
24
+ commitMessage: 'chore(release): publish {version}',
25
25
  commitArgs: '',
26
26
  tag: false,
27
27
  tagMessage: '',
28
28
  tagArgs: '',
29
29
  };
30
+ const versionGitDefaults = {
31
+ ...gitDefaults,
32
+ stageChanges: true,
33
+ };
34
+ const changelogGitDefaults = {
35
+ ...gitDefaults,
36
+ commit: true,
37
+ tag: true,
38
+ };
30
39
  const defaultFixedReleaseTagPattern = 'v{version}';
31
40
  const defaultIndependentReleaseTagPattern = '{projectName}@{version}';
32
41
  const workspaceProjectsRelationship = userConfig.projectsRelationship || 'fixed';
@@ -35,12 +44,12 @@ requiredTargetName) {
35
44
  projectsRelationship: workspaceProjectsRelationship,
36
45
  git: gitDefaults,
37
46
  version: {
38
- git: gitDefaults,
47
+ git: versionGitDefaults,
39
48
  generator: '@nx/js:release-version',
40
49
  generatorOptions: {},
41
50
  },
42
51
  changelog: {
43
- git: gitDefaults,
52
+ git: changelogGitDefaults,
44
53
  workspaceChangelog: {
45
54
  createRelease: false,
46
55
  entryWhenNoChanges: 'This was a version bump only, there were no code changes.',
@@ -39,9 +39,11 @@ async function release(args) {
39
39
  }
40
40
  const versionResult = await (0, version_1.releaseVersion)({
41
41
  ...args,
42
- // if enabled, committing and tagging will be handled by the changelog
43
- // command, so we should only stage the changes in the version command
44
- stageChanges: nxReleaseConfig.git?.commit,
42
+ // We should stage the changes in the version command only if
43
+ // the changelog command will actually be committing the files.
44
+ // Since git.commit defaults to true for the changelog command, we
45
+ // only need to disable staging if git.commit is explicitly set to false.
46
+ stageChanges: nxReleaseConfig.git?.commit ?? true,
45
47
  gitCommit: false,
46
48
  gitTag: false,
47
49
  });
@@ -19,7 +19,7 @@ export declare class ReleaseVersion {
19
19
  });
20
20
  }
21
21
  export declare function commitChanges(changedFiles: string[], isDryRun: boolean, isVerbose: boolean, gitCommitMessages: string[], gitCommitArgs?: string): Promise<void>;
22
- export declare function createCommitMessageValues(releaseGroups: ReleaseGroupWithName[], releaseGroupToFilteredProjects: Map<ReleaseGroupWithName, Set<string>>, versionData: VersionData, userCommitMessage?: string): string[];
22
+ export declare function createCommitMessageValues(releaseGroups: ReleaseGroupWithName[], releaseGroupToFilteredProjects: Map<ReleaseGroupWithName, Set<string>>, versionData: VersionData, commitMessage: string): string[];
23
23
  export declare function createGitTagValues(releaseGroups: ReleaseGroupWithName[], releaseGroupToFilteredProjects: Map<ReleaseGroupWithName, Set<string>>, versionData: VersionData): string[];
24
24
  export declare function handleDuplicateGitTags(gitTagValues: string[]): void;
25
25
  export declare function getCommitsRelevantToProjects(projectGraph: ProjectGraph, commits: GitCommit[], projects: string[]): Promise<GitCommit[]>;
@@ -46,11 +46,8 @@ async function commitChanges(changedFiles, isDryRun, isVerbose, gitCommitMessage
46
46
  });
47
47
  }
48
48
  exports.commitChanges = commitChanges;
49
- function createCommitMessageValues(releaseGroups, releaseGroupToFilteredProjects, versionData, userCommitMessage) {
50
- const defaultCommitMessage = `chore(release): publish {version}`;
51
- const commitMessageValues = userCommitMessage
52
- ? [userCommitMessage]
53
- : [defaultCommitMessage];
49
+ function createCommitMessageValues(releaseGroups, releaseGroupToFilteredProjects, versionData, commitMessage) {
50
+ const commitMessageValues = [commitMessage];
54
51
  if (releaseGroups.length === 0) {
55
52
  return commitMessageValues;
56
53
  }
@@ -76,7 +73,7 @@ function createCommitMessageValues(releaseGroups, releaseGroupToFilteredProjects
76
73
  */
77
74
  if (releaseGroups.length === 1 &&
78
75
  releaseGroups[0].projectsRelationship === 'independent' &&
79
- userCommitMessage?.includes('{projectName}')) {
76
+ commitMessage.includes('{projectName}')) {
80
77
  const releaseGroup = releaseGroups[0];
81
78
  const releaseGroupProjectNames = Array.from(releaseGroupToFilteredProjects.get(releaseGroup));
82
79
  if (releaseGroupProjectNames.length === 1) {
@@ -45,7 +45,7 @@ async function releaseVersion(args) {
45
45
  }
46
46
  const tree = new tree_1.FsTree(devkit_exports_1.workspaceRoot, args.verbose);
47
47
  const versionData = {};
48
- const userCommitMessage = args.gitCommitMessage || nxReleaseConfig.version.git.commitMessage;
48
+ const commitMessage = args.gitCommitMessage || nxReleaseConfig.version.git.commitMessage;
49
49
  if (args.projects?.length) {
50
50
  /**
51
51
  * Run versioning for all remaining release groups and filtered projects within them
@@ -76,17 +76,17 @@ async function releaseVersion(args) {
76
76
  projectsVersionData: versionData,
77
77
  };
78
78
  }
79
- if (args.stageChanges) {
80
- devkit_exports_1.output.logSingleLine(`Staging changed files with git because --stage-changes was set`);
79
+ if (args.gitCommit ?? nxReleaseConfig.version.git.commit) {
80
+ await (0, shared_1.commitChanges)(tree.listChanges().map((f) => f.path), !!args.dryRun, !!args.verbose, (0, shared_1.createCommitMessageValues)(releaseGroups, releaseGroupToFilteredProjects, versionData, commitMessage), args.gitCommitArgs || nxReleaseConfig.version.git.commitArgs);
81
+ }
82
+ else if (args.stageChanges ?? nxReleaseConfig.version.git.stageChanges) {
83
+ devkit_exports_1.output.logSingleLine(`Staging changed files with git`);
81
84
  await (0, git_1.gitAdd)({
82
85
  changedFiles,
83
86
  dryRun: args.dryRun,
84
87
  verbose: args.verbose,
85
88
  });
86
89
  }
87
- if (args.gitCommit ?? nxReleaseConfig.version.git.commit) {
88
- await (0, shared_1.commitChanges)(tree.listChanges().map((f) => f.path), !!args.dryRun, !!args.verbose, (0, shared_1.createCommitMessageValues)(releaseGroups, releaseGroupToFilteredProjects, versionData, userCommitMessage), args.gitCommitArgs || nxReleaseConfig.version.git.commitArgs);
89
- }
90
90
  if (args.gitTag ?? nxReleaseConfig.version.git.tag) {
91
91
  devkit_exports_1.output.logSingleLine(`Tagging commit with git`);
92
92
  for (const tag of gitTagValues) {
@@ -144,17 +144,17 @@ async function releaseVersion(args) {
144
144
  projectsVersionData: versionData,
145
145
  };
146
146
  }
147
- if (args.stageChanges) {
148
- devkit_exports_1.output.logSingleLine(`Staging changed files with git because --stage-changes was set`);
147
+ if (args.gitCommit ?? nxReleaseConfig.version.git.commit) {
148
+ await (0, shared_1.commitChanges)(changedFiles, !!args.dryRun, !!args.verbose, (0, shared_1.createCommitMessageValues)(releaseGroups, releaseGroupToFilteredProjects, versionData, commitMessage), args.gitCommitArgs || nxReleaseConfig.version.git.commitArgs);
149
+ }
150
+ else if (args.stageChanges ?? nxReleaseConfig.version.git.stageChanges) {
151
+ devkit_exports_1.output.logSingleLine(`Staging changed files with git`);
149
152
  await (0, git_1.gitAdd)({
150
153
  changedFiles,
151
154
  dryRun: args.dryRun,
152
155
  verbose: args.verbose,
153
156
  });
154
157
  }
155
- if (args.gitCommit ?? nxReleaseConfig.version.git.commit) {
156
- await (0, shared_1.commitChanges)(changedFiles, !!args.dryRun, !!args.verbose, (0, shared_1.createCommitMessageValues)(releaseGroups, releaseGroupToFilteredProjects, versionData, userCommitMessage), args.gitCommitArgs || nxReleaseConfig.version.git.commitArgs);
157
- }
158
158
  if (args.gitTag ?? nxReleaseConfig.version.git.tag) {
159
159
  devkit_exports_1.output.logSingleLine(`Tagging commit with git`);
160
160
  for (const tag of gitTagValues) {
@@ -194,7 +194,12 @@ interface NxReleaseConfiguration {
194
194
  /**
195
195
  * Enable or override configuration for git operations as part of the version subcommand
196
196
  */
197
- git?: NxReleaseGitConfiguration;
197
+ git?: NxReleaseGitConfiguration & {
198
+ /**
199
+ * Whether or not to stage the changes made by this command. Useful when combining the version command with changelog generation.
200
+ */
201
+ stageChanges?: boolean;
202
+ };
198
203
  };
199
204
  /**
200
205
  * Optionally override the git/release tag pattern to use. This field is the source of truth