nx 22.4.0-beta.1 → 22.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "22.4.0-beta.1",
3
+ "version": "22.4.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": {
@@ -53,7 +53,7 @@
53
53
  "jest-diff": "^30.0.2",
54
54
  "jsonc-parser": "3.2.0",
55
55
  "lines-and-columns": "2.0.3",
56
- "minimatch": "9.0.3",
56
+ "minimatch": "10.1.1",
57
57
  "node-machine-id": "1.1.12",
58
58
  "npm-run-path": "^4.0.1",
59
59
  "open": "^8.4.0",
@@ -83,16 +83,16 @@
83
83
  }
84
84
  },
85
85
  "optionalDependencies": {
86
- "@nx/nx-darwin-arm64": "22.4.0-beta.1",
87
- "@nx/nx-darwin-x64": "22.4.0-beta.1",
88
- "@nx/nx-freebsd-x64": "22.4.0-beta.1",
89
- "@nx/nx-linux-arm-gnueabihf": "22.4.0-beta.1",
90
- "@nx/nx-linux-arm64-gnu": "22.4.0-beta.1",
91
- "@nx/nx-linux-arm64-musl": "22.4.0-beta.1",
92
- "@nx/nx-linux-x64-gnu": "22.4.0-beta.1",
93
- "@nx/nx-linux-x64-musl": "22.4.0-beta.1",
94
- "@nx/nx-win32-arm64-msvc": "22.4.0-beta.1",
95
- "@nx/nx-win32-x64-msvc": "22.4.0-beta.1"
86
+ "@nx/nx-darwin-arm64": "22.4.0-beta.3",
87
+ "@nx/nx-darwin-x64": "22.4.0-beta.3",
88
+ "@nx/nx-freebsd-x64": "22.4.0-beta.3",
89
+ "@nx/nx-linux-arm-gnueabihf": "22.4.0-beta.3",
90
+ "@nx/nx-linux-arm64-gnu": "22.4.0-beta.3",
91
+ "@nx/nx-linux-arm64-musl": "22.4.0-beta.3",
92
+ "@nx/nx-linux-x64-gnu": "22.4.0-beta.3",
93
+ "@nx/nx-linux-x64-musl": "22.4.0-beta.3",
94
+ "@nx/nx-win32-arm64-msvc": "22.4.0-beta.3",
95
+ "@nx/nx-win32-x64-msvc": "22.4.0-beta.3"
96
96
  },
97
97
  "nx-migrations": {
98
98
  "migrations": "./migrations.json",
package/project.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "inputs": ["native"],
16
16
  "outputs": [
17
17
  "{projectRoot}/src/native/*.wasm",
18
- "{projectRoot}/src/native/*.js",
18
+ "{projectRoot}/src/native/!(index|browser).js",
19
19
  "{projectRoot}/src/native/*.cjs",
20
20
  "{projectRoot}/src/native/*.mjs",
21
21
  "{projectRoot}/src/native/index.d.ts"
@@ -31,7 +31,7 @@
31
31
  "build-native": {
32
32
  "outputs": [
33
33
  "{projectRoot}/src/native/*.node",
34
- "{projectRoot}/src/native/*.js",
34
+ "{projectRoot}/src/native/!(index|browser).js",
35
35
  "{projectRoot}/src/native/index.d.ts"
36
36
  ],
37
37
  "executor": "@monodon/rust:napi",
@@ -45,7 +45,7 @@ async function format(command, args) {
45
45
  sortTsConfig();
46
46
  }
47
47
  addRootConfigFiles(chunkList, nxArgs);
48
- chunkList.forEach((chunk) => write(chunk));
48
+ chunkList.forEach((chunk) => write(prettier, chunk));
49
49
  break;
50
50
  case 'check': {
51
51
  const filesWithDifferentFormatting = [];
@@ -140,14 +140,14 @@ function addRootConfigFiles(chunkList, nxArgs) {
140
140
  function getPatternsFromProjects(projects, projectGraph) {
141
141
  return (0, command_line_utils_1.getProjectRoots)(projects, projectGraph);
142
142
  }
143
- function write(patterns) {
143
+ function write(prettier, patterns) {
144
144
  if (patterns.length > 0) {
145
145
  const [swcrcPatterns, regularPatterns] = patterns.reduce((result, pattern) => {
146
146
  result[pattern.includes('.swcrc') ? 0 : 1].push(pattern);
147
147
  return result;
148
148
  }, [[], []]);
149
149
  const prettierPath = getPrettierPath();
150
- const listDifferentArg = shouldUseListDifferent()
150
+ const listDifferentArg = shouldUseListDifferent(prettier.version)
151
151
  ? '--list-different '
152
152
  : '';
153
153
  (0, node_child_process_1.execSync)(`node "${prettierPath}" --write ${listDifferentArg}${regularPatterns.join(' ')}`, {
@@ -201,8 +201,8 @@ function getPrettierPath() {
201
201
  if (prettierPath) {
202
202
  return prettierPath;
203
203
  }
204
- const { bin } = (0, package_json_1.readModulePackageJson)('prettier').packageJson;
205
- prettierPath = require.resolve(path.join('prettier', bin));
204
+ const { packageJson, path: packageJsonPath } = (0, package_json_1.readModulePackageJson)('prettier');
205
+ prettierPath = path.resolve(path.dirname(packageJsonPath), packageJson.bin);
206
206
  return prettierPath;
207
207
  }
208
208
  let useListDifferent;
@@ -210,11 +210,11 @@ let useListDifferent;
210
210
  * Determines if --list-different should be used with --write.
211
211
  * Prettier 4+ and 3.6.x with experimental CLI don't support combining these flags.
212
212
  */
213
- function shouldUseListDifferent() {
213
+ function shouldUseListDifferent(prettierVersion) {
214
214
  if (useListDifferent !== undefined) {
215
215
  return useListDifferent;
216
216
  }
217
- const prettierMajor = (0, semver_1.major)(require('prettier').version);
217
+ const prettierMajor = (0, semver_1.major)(prettierVersion);
218
218
  const isExperimentalCli = process.env.PRETTIER_EXPERIMENTAL_CLI === '1';
219
219
  useListDifferent = prettierMajor < 4 && !isExperimentalCli;
220
220
  return useListDifferent;
@@ -22,6 +22,12 @@ export interface ReportData {
22
22
  localPlugins: string[];
23
23
  communityPlugins: PackageJson[];
24
24
  registeredPlugins: string[];
25
+ daemon: {
26
+ available: boolean;
27
+ disabled: boolean;
28
+ } | {
29
+ error: unknown;
30
+ };
25
31
  packageVersionsWeCareAbout: {
26
32
  package: string;
27
33
  version: string;
@@ -1 +1 @@
1
- {"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/command-line/report/report.ts"],"names":[],"mappings":"AAGA,OAAO,EAIL,cAAc,EACf,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,WAAW,EAGZ,MAAM,0BAA0B,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Aa,IAAI,OAAO,CAAC,UAAU,CAAC,CA+DzD;AA6CD,UAAU,qBAAqB;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE;QAClB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;KACjB,EAAE,CAAC;IACJ,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,gCAAgC,CAC9C,IAAI,EAAE,WAAW,GAChB,SAAS,GAAG,qBAAqB,CAgCnC;AAED,wBAAgB,6BAA6B,IAAI,WAAW,EAAE,CAO7D;AAED,wBAAgB,6BAA6B,IAAI,WAAW,EAAE,CAW7D;AAED,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,mBAAmB,YAQzE;AAED,wBAAgB,gCAAgC;;;IAe/C"}
1
+ {"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/command-line/report/report.ts"],"names":[],"mappings":"AAGA,OAAO,EAIL,cAAc,EACf,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,WAAW,EAGZ,MAAM,0BAA0B,CAAC;AASlC,OAAO,EAAE,mBAAmB,EAAc,MAAM,sBAAsB,CAAC;AAUvE,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,SAAS,CAAC;AAarC,eAAO,MAAM,mBAAmB,UAO/B,CAAC;AAEF,eAAO,MAAM,iCAAiC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAMpE,CAAC;AAIF;;;;;;;GAOG;AACH,wBAAsB,aAAa,kBA2MlC;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,cAAc,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,UAAU,EAAE,KAAK,GAAG,IAAI,CAAC;IACzB,gBAAgB,EAAE,WAAW,EAAE,CAAC;IAChC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB,EAAE,WAAW,EAAE,CAAC;I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,MAAM,EAAE,mBAAmB,YAQzE;AAED,wBAAgB,gCAAgC;;;IAe/C"}
@@ -25,6 +25,7 @@ const operators_1 = require("../../project-graph/operators");
25
25
  const versions_1 = require("../../utils/versions");
26
26
  const nx_key_1 = require("../../utils/nx-key");
27
27
  const cache_1 = require("../../tasks-runner/cache");
28
+ const client_1 = require("../../daemon/client/client");
28
29
  const nxPackageJson = (0, fileutils_1.readJsonFile)((0, path_1.join)(__dirname, '../../../package.json'));
29
30
  exports.packagesWeCareAbout = [
30
31
  'lerna',
@@ -49,12 +50,22 @@ const LINE_SEPARATOR = '---------------------------------------';
49
50
  *
50
51
  */
51
52
  async function reportHandler() {
52
- const { pm, pmVersion, nxKey, nxKeyError, localPlugins, powerpackPlugins, communityPlugins, registeredPlugins, packageVersionsWeCareAbout, outOfSyncPackageGroup, mismatchedNxVersions, projectGraphError, nativeTarget, cache, } = await getReportData();
53
+ const { pm, pmVersion, nxKey, nxKeyError, localPlugins, powerpackPlugins, communityPlugins, registeredPlugins, packageVersionsWeCareAbout, outOfSyncPackageGroup, mismatchedNxVersions, projectGraphError, nativeTarget, cache, daemon, } = await getReportData();
53
54
  const fields = [
54
55
  ['Node', process.versions.node],
55
56
  ['OS', `${process.platform}-${process.arch}`],
56
57
  ['Native Target', nativeTarget ?? 'Unavailable'],
57
58
  [pm, pmVersion],
59
+ [
60
+ 'daemon',
61
+ 'error' in daemon
62
+ ? `Error: ${daemon.error}`
63
+ : daemon.disabled
64
+ ? 'Disabled'
65
+ : daemon.available
66
+ ? 'Available'
67
+ : 'Unavailable',
68
+ ],
58
69
  ];
59
70
  let padding = Math.max(...fields.map((f) => f[0].length));
60
71
  const bodyLines = fields.map(([field, value]) => `${field.padEnd(padding)} : ${value}`);
@@ -271,8 +282,24 @@ async function getReportData() {
271
282
  projectGraphError,
272
283
  nativeTarget: native ? native.getBinaryTarget() : null,
273
284
  cache,
285
+ daemon: await getDaemonStatus(),
274
286
  };
275
287
  }
288
+ async function getDaemonStatus() {
289
+ try {
290
+ const enabled = client_1.daemonClient.enabled();
291
+ const available = enabled && (await client_1.daemonClient.isServerAvailable());
292
+ return {
293
+ available,
294
+ disabled: !enabled,
295
+ };
296
+ }
297
+ catch (e) {
298
+ return {
299
+ error: e,
300
+ };
301
+ }
302
+ }
276
303
  async function tryGetProjectGraph() {
277
304
  try {
278
305
  return { graph: await (0, project_graph_1.createProjectGraphAsync)() };
@@ -18,7 +18,7 @@ export type ShowProjectsOptions = NxShowArgs & {
18
18
  sep?: string;
19
19
  };
20
20
  export type ShowProjectOptions = NxShowArgs & {
21
- projectName: string;
21
+ projectName?: string;
22
22
  web?: boolean;
23
23
  open?: boolean;
24
24
  verbose?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"command-object.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/command-line/show/command-object.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAY,MAAM,OAAO,CAAC;AAQhD,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG;IAC7C,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,SAAS,CAAC,EAAE,GAAG,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,uBAAuB,CAAC,MAAM,CAAC,CAAC;IACvC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG;IAC5C,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,aAAa,CAC1C,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvB,UAAU,CA6BX,CAAC"}
1
+ {"version":3,"file":"command-object.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/command-line/show/command-object.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAY,MAAM,OAAO,CAAC;AAQhD,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG;IAC7C,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,SAAS,CAAC,EAAE,GAAG,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,uBAAuB,CAAC,MAAM,CAAC,CAAC;IACvC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,aAAa,CAC1C,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvB,UAAU,CA6BX,CAAC"}
@@ -73,13 +73,13 @@ const showProjectsCommand = {
73
73
  },
74
74
  };
75
75
  const showProjectCommand = {
76
- command: 'project <projectName>',
77
- describe: 'Shows resolved project configuration for a given project.',
76
+ command: 'project [projectName]',
77
+ describe: 'Shows resolved project configuration for a given project. If run within a project directory and no project name is provided, the project is inferred from the current working directory.',
78
78
  builder: (yargs) => (0, shared_options_1.withVerbose)(yargs)
79
79
  .positional('projectName', {
80
80
  type: 'string',
81
81
  alias: 'p',
82
- description: 'Which project should be viewed?.',
82
+ description: 'The project to show. If not provided, infers the project from the current working directory.',
83
83
  })
84
84
  .option('web', {
85
85
  type: 'boolean',
@@ -104,7 +104,8 @@ const showProjectCommand = {
104
104
  return true;
105
105
  })
106
106
  .example('$0 show project my-app', 'View project information for my-app in JSON format')
107
- .example('$0 show project my-app --web', 'View project information for my-app in the browser'),
107
+ .example('$0 show project my-app --web', 'View project information for my-app in the browser')
108
+ .example('$0 show project', 'View project information for the project in the current working directory'),
108
109
  handler: async (args) => {
109
110
  const exitCode = await (0, handle_errors_1.handleErrors)(args.verbose, async () => {
110
111
  const { showProjectHandler } = await Promise.resolve().then(() => require('./project'));
@@ -1 +1 @@
1
- {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/command-line/show/project.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAItD,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC,IAAI,CAAC,CA0Ff"}
1
+ {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/command-line/show/project.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAOtD,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC,IAAI,CAAC,CAqHf"}
@@ -5,16 +5,37 @@ const output_1 = require("../../utils/output");
5
5
  const project_graph_1 = require("../../project-graph/project-graph");
6
6
  const graph_1 = require("../graph/graph");
7
7
  const find_matching_projects_1 = require("../../utils/find-matching-projects");
8
+ const workspace_root_1 = require("../../utils/workspace-root");
9
+ const configuration_1 = require("../../config/configuration");
10
+ const calculate_default_project_name_1 = require("../../config/calculate-default-project-name");
8
11
  async function showProjectHandler(args) {
9
12
  performance.mark('code-loading:end');
10
13
  performance.measure('code-loading', 'init-local', 'code-loading:end');
11
14
  const graph = await (0, project_graph_1.createProjectGraphAsync)();
12
- let node = graph.nodes[args.projectName];
15
+ let projectName = args.projectName;
16
+ // If no project name is provided, try to infer from cwd
17
+ if (!projectName) {
18
+ const nxJson = (0, configuration_1.readNxJson)();
19
+ projectName = (0, calculate_default_project_name_1.calculateDefaultProjectName)(process.cwd(), workspace_root_1.workspaceRoot, (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(graph), nxJson);
20
+ if (!projectName) {
21
+ output_1.output.error({
22
+ title: 'Could not find a project in the current working directory.',
23
+ bodyLines: [
24
+ `Please specify a project name using:`,
25
+ ` nx show project <project-name>`,
26
+ ``,
27
+ `Or run this command from within a project directory.`,
28
+ ],
29
+ });
30
+ process.exit(1);
31
+ }
32
+ }
33
+ let node = graph.nodes[projectName];
13
34
  if (!node) {
14
- const projects = (0, find_matching_projects_1.findMatchingProjects)([args.projectName], graph.nodes);
35
+ const projects = (0, find_matching_projects_1.findMatchingProjects)([projectName], graph.nodes);
15
36
  if (projects.length === 1) {
16
- const projectName = projects[0];
17
- node = graph.nodes[projectName];
37
+ const matchedProjectName = projects[0];
38
+ node = graph.nodes[matchedProjectName];
18
39
  }
19
40
  else if (projects.length > 1) {
20
41
  output_1.output.error({
@@ -27,7 +48,7 @@ async function showProjectHandler(args) {
27
48
  process.exit(1);
28
49
  }
29
50
  else {
30
- console.log(`Could not find project ${args.projectName}`);
51
+ console.log(`Could not find project ${projectName}`);
31
52
  process.exit(1);
32
53
  }
33
54
  }