nx 19.0.6 → 19.0.7

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/bin/init-local.js CHANGED
@@ -132,7 +132,7 @@ function handleAngularCLIFallbacks(workspace) {
132
132
  else if (process.argv[2] === 'cache') {
133
133
  console.log(`"ng cache" is not natively supported by Nx.
134
134
  To clear the cache, you can delete the ".angular/cache" directory (or the directory configured by "cli.cache.path" in the "nx.json" file).
135
- To update the cache configuration, you can directly update the relevant options in your "nx.json" file (https://angular.io/guide/workspace-config#cache-options).`);
135
+ To update the cache configuration, you can directly update the relevant options in your "nx.json" file (https://angular.dev/reference/configs/workspace-config#cache-options).`);
136
136
  }
137
137
  else {
138
138
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "19.0.6",
3
+ "version": "19.0.7",
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": {
@@ -20,7 +20,11 @@
20
20
  "Nest",
21
21
  "Jest",
22
22
  "Cypress",
23
- "CLI"
23
+ "CLI",
24
+ "Testing",
25
+ "Front-end",
26
+ "Backend",
27
+ "Mobile"
24
28
  ],
25
29
  "bin": {
26
30
  "nx": "./bin/nx.js",
@@ -65,7 +69,7 @@
65
69
  "yargs-parser": "21.1.1",
66
70
  "node-machine-id": "1.1.12",
67
71
  "ora": "5.3.0",
68
- "@nrwl/tao": "19.0.6"
72
+ "@nrwl/tao": "19.0.7"
69
73
  },
70
74
  "peerDependencies": {
71
75
  "@swc-node/register": "^1.8.0",
@@ -80,16 +84,16 @@
80
84
  }
81
85
  },
82
86
  "optionalDependencies": {
83
- "@nx/nx-darwin-x64": "19.0.6",
84
- "@nx/nx-darwin-arm64": "19.0.6",
85
- "@nx/nx-linux-x64-gnu": "19.0.6",
86
- "@nx/nx-linux-x64-musl": "19.0.6",
87
- "@nx/nx-win32-x64-msvc": "19.0.6",
88
- "@nx/nx-linux-arm64-gnu": "19.0.6",
89
- "@nx/nx-linux-arm64-musl": "19.0.6",
90
- "@nx/nx-linux-arm-gnueabihf": "19.0.6",
91
- "@nx/nx-win32-arm64-msvc": "19.0.6",
92
- "@nx/nx-freebsd-x64": "19.0.6"
87
+ "@nx/nx-darwin-x64": "19.0.7",
88
+ "@nx/nx-darwin-arm64": "19.0.7",
89
+ "@nx/nx-linux-x64-gnu": "19.0.7",
90
+ "@nx/nx-linux-x64-musl": "19.0.7",
91
+ "@nx/nx-win32-x64-msvc": "19.0.7",
92
+ "@nx/nx-linux-arm64-gnu": "19.0.7",
93
+ "@nx/nx-linux-arm64-musl": "19.0.7",
94
+ "@nx/nx-linux-arm-gnueabihf": "19.0.7",
95
+ "@nx/nx-win32-arm64-msvc": "19.0.7",
96
+ "@nx/nx-freebsd-x64": "19.0.7"
93
97
  },
94
98
  "nx-migrations": {
95
99
  "migrations": "./migrations.json",
@@ -1,23 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.format = void 0;
4
- const child_process_1 = require("child_process");
5
- const path = require("path");
4
+ const node_child_process_1 = require("node:child_process");
5
+ const path = require("node:path");
6
+ const file_utils_1 = require("../../project-graph/file-utils");
6
7
  const command_line_utils_1 = require("../../utils/command-line-utils");
7
- const ignore_1 = require("../../utils/ignore");
8
8
  const fileutils_1 = require("../../utils/fileutils");
9
- const file_utils_1 = require("../../project-graph/file-utils");
9
+ const ignore_1 = require("../../utils/ignore");
10
10
  const prettier = require("prettier");
11
- const object_sort_1 = require("../../utils/object-sort");
12
- const package_json_1 = require("../../utils/package-json");
11
+ const configuration_1 = require("../../config/configuration");
13
12
  const typescript_1 = require("../../plugins/js/utils/typescript");
14
- const project_graph_1 = require("../../project-graph/project-graph");
15
13
  const affected_project_graph_1 = require("../../project-graph/affected/affected-project-graph");
16
- const configuration_1 = require("../../config/configuration");
17
- const chunkify_1 = require("../../utils/chunkify");
14
+ const project_graph_1 = require("../../project-graph/project-graph");
18
15
  const all_file_data_1 = require("../../utils/all-file-data");
19
- const workspace_root_1 = require("../../utils/workspace-root");
16
+ const chunkify_1 = require("../../utils/chunkify");
17
+ const object_sort_1 = require("../../utils/object-sort");
20
18
  const output_1 = require("../../utils/output");
19
+ const package_json_1 = require("../../utils/package-json");
20
+ const workspace_root_1 = require("../../utils/workspace-root");
21
21
  const PRETTIER_PATH = getPrettierPath();
22
22
  async function format(command, args) {
23
23
  const { nxArgs } = (0, command_line_utils_1.splitArgsIntoNxArgsAndOverrides)(args, 'affected', { printWarnings: false }, (0, configuration_1.readNxJson)());
@@ -33,12 +33,31 @@ async function format(command, args) {
33
33
  addRootConfigFiles(chunkList, nxArgs);
34
34
  chunkList.forEach((chunk) => write(chunk));
35
35
  break;
36
- case 'check':
37
- const pass = chunkList.reduce((pass, chunk) => check(chunk) && pass, true);
38
- if (!pass) {
36
+ case 'check': {
37
+ const filesWithDifferentFormatting = [];
38
+ for (const chunk of chunkList) {
39
+ const files = await check(chunk);
40
+ filesWithDifferentFormatting.push(...files);
41
+ }
42
+ if (filesWithDifferentFormatting.length > 0) {
43
+ if (nxArgs.verbose) {
44
+ output_1.output.error({
45
+ title: 'The following files are not formatted correctly based on your Prettier configuration',
46
+ bodyLines: [
47
+ '- Run "nx format:write" and commit the resulting diff to fix these files.',
48
+ '- Please note, Prettier does not support a native way to diff the output of its check logic (https://github.com/prettier/prettier/issues/6885).',
49
+ '',
50
+ ...filesWithDifferentFormatting,
51
+ ],
52
+ });
53
+ }
54
+ else {
55
+ console.log(filesWithDifferentFormatting.join('\n'));
56
+ }
39
57
  process.exit(1);
40
58
  }
41
59
  break;
60
+ }
42
61
  }
43
62
  }
44
63
  exports.format = format;
@@ -113,29 +132,32 @@ function write(patterns) {
113
132
  result[pattern.includes('.swcrc') ? 0 : 1].push(pattern);
114
133
  return result;
115
134
  }, [[], []]);
116
- (0, child_process_1.execSync)(`node "${PRETTIER_PATH}" --write --list-different ${regularPatterns.join(' ')}`, {
135
+ (0, node_child_process_1.execSync)(`node "${PRETTIER_PATH}" --write --list-different ${regularPatterns.join(' ')}`, {
117
136
  stdio: [0, 1, 2],
118
137
  });
119
138
  if (swcrcPatterns.length > 0) {
120
- (0, child_process_1.execSync)(`node "${PRETTIER_PATH}" --write --list-different ${swcrcPatterns.join(' ')} --parser json`, {
139
+ (0, node_child_process_1.execSync)(`node "${PRETTIER_PATH}" --write --list-different ${swcrcPatterns.join(' ')} --parser json`, {
121
140
  stdio: [0, 1, 2],
122
141
  });
123
142
  }
124
143
  }
125
144
  }
126
- function check(patterns) {
145
+ async function check(patterns) {
127
146
  if (patterns.length === 0) {
128
- return true;
147
+ return [];
129
148
  }
130
- try {
131
- (0, child_process_1.execSync)(`node "${PRETTIER_PATH}" --list-different ${patterns.join(' ')}`, {
132
- stdio: [0, 1, 2],
149
+ return new Promise((resolve) => {
150
+ (0, node_child_process_1.exec)(`node "${PRETTIER_PATH}" --list-different ${patterns.join(' ')}`, { encoding: 'utf-8' }, (error, stdout) => {
151
+ if (error) {
152
+ // The command failed so there are files with different formatting. Prettier writes them to stdout, newline separated.
153
+ resolve(stdout.trim().split('\n'));
154
+ }
155
+ else {
156
+ // The command succeeded so there are no files with different formatting
157
+ resolve([]);
158
+ }
133
159
  });
134
- return true;
135
- }
136
- catch {
137
- return false;
138
- }
160
+ });
139
161
  }
140
162
  function sortTsConfig() {
141
163
  try {
@@ -1,4 +1,5 @@
1
1
  import { InputDefinition, TargetConfiguration } from '../config/workspace-json-project-json';
2
+ import { PackageManagerCommands } from './package-manager';
2
3
  export interface NxProjectPackageJsonConfiguration {
3
4
  implicitDependencies?: string[];
4
5
  tags?: string[];
@@ -65,7 +66,7 @@ export declare function normalizePackageGroup(packageGroup: PackageGroup): Array
65
66
  export declare function readNxMigrateConfig(json: Partial<PackageJson>): NxMigrationsConfiguration & {
66
67
  packageGroup?: ArrayPackageGroup;
67
68
  };
68
- export declare function buildTargetFromScript(script: string, scripts?: Record<string, string>): TargetConfiguration;
69
+ export declare function buildTargetFromScript(script: string, scripts: Record<string, string>, packageManagerCommand: PackageManagerCommands): TargetConfiguration;
69
70
  export declare function readTargetsFromPackageJson(packageJson: PackageJson): Record<string, TargetConfiguration<any>>;
70
71
  /**
71
72
  * Uses `require.resolve` to read the package.json for a module.
@@ -39,8 +39,7 @@ function readNxMigrateConfig(json) {
39
39
  };
40
40
  }
41
41
  exports.readNxMigrateConfig = readNxMigrateConfig;
42
- function buildTargetFromScript(script, scripts = {}) {
43
- const packageManagerCommand = (0, package_manager_1.getPackageManagerCommand)();
42
+ function buildTargetFromScript(script, scripts = {}, packageManagerCommand) {
44
43
  return {
45
44
  executor: 'nx:run-script',
46
45
  options: {
@@ -57,9 +56,9 @@ function readTargetsFromPackageJson(packageJson) {
57
56
  const { scripts, nx, private: isPrivate } = packageJson ?? {};
58
57
  const res = {};
59
58
  const includedScripts = nx?.includedScripts || Object.keys(scripts ?? {});
60
- //
59
+ const packageManagerCommand = (0, package_manager_1.getPackageManagerCommand)();
61
60
  for (const script of includedScripts) {
62
- res[script] = buildTargetFromScript(script, scripts);
61
+ res[script] = buildTargetFromScript(script, scripts, packageManagerCommand);
63
62
  }
64
63
  for (const targetName in nx?.targets) {
65
64
  res[targetName] = (0, project_configuration_utils_1.mergeTargetConfigurations)(nx?.targets[targetName], res[targetName]);