nx 18.2.0-canary.20240321-2a4c57d → 18.2.0-canary.20240323-54d4780

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.
Files changed (35) hide show
  1. package/LICENSE +1 -1
  2. package/package.json +12 -12
  3. package/schemas/nx-schema.json +32 -6
  4. package/src/command-line/add/add.js +1 -1
  5. package/src/command-line/affected/command-object.js +49 -22
  6. package/src/command-line/generate/generate.js +3 -3
  7. package/src/command-line/init/init-v2.js +16 -11
  8. package/src/command-line/run/command-object.js +9 -2
  9. package/src/command-line/run/run-one.js +1 -1
  10. package/src/command-line/run-many/command-object.js +4 -1
  11. package/src/command-line/show/command-object.d.ts +2 -0
  12. package/src/command-line/show/command-object.js +19 -2
  13. package/src/config/nx-json.d.ts +2 -0
  14. package/src/daemon/client/client.js +19 -7
  15. package/src/daemon/daemon-project-graph-error.d.ts +8 -0
  16. package/src/daemon/daemon-project-graph-error.js +13 -0
  17. package/src/daemon/server/handle-hash-tasks.js +11 -1
  18. package/src/daemon/server/project-graph-incremental-recomputation.d.ts +1 -0
  19. package/src/daemon/server/project-graph-incremental-recomputation.js +55 -6
  20. package/src/daemon/server/shutdown-utils.js +1 -3
  21. package/src/daemon/socket-utils.js +7 -1
  22. package/src/project-graph/build-project-graph.d.ts +18 -1
  23. package/src/project-graph/build-project-graph.js +71 -24
  24. package/src/project-graph/project-graph.d.ts +23 -2
  25. package/src/project-graph/project-graph.js +117 -14
  26. package/src/project-graph/utils/project-configuration-utils.d.ts +27 -4
  27. package/src/project-graph/utils/project-configuration-utils.js +106 -43
  28. package/src/project-graph/utils/retrieve-workspace-files.d.ts +4 -12
  29. package/src/project-graph/utils/retrieve-workspace-files.js +3 -16
  30. package/src/tasks-runner/cache.js +6 -3
  31. package/src/utils/nx-plugin.d.ts +2 -0
  32. package/src/utils/nx-plugin.js +18 -2
  33. package/src/utils/output.d.ts +1 -1
  34. package/src/utils/params.d.ts +2 -2
  35. package/src/utils/params.js +14 -0
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2017-2023 Narwhal Technologies Inc.
3
+ Copyright (c) 2017-2024 Narwhal Technologies Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "18.2.0-canary.20240321-2a4c57d",
3
+ "version": "18.2.0-canary.20240323-54d4780",
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-parser": "21.1.1",
67
67
  "node-machine-id": "1.1.12",
68
68
  "ora": "5.3.0",
69
- "@nrwl/tao": "18.2.0-canary.20240321-2a4c57d"
69
+ "@nrwl/tao": "18.2.0-canary.20240323-54d4780"
70
70
  },
71
71
  "peerDependencies": {
72
72
  "@swc-node/register": "^1.8.0",
@@ -81,16 +81,16 @@
81
81
  }
82
82
  },
83
83
  "optionalDependencies": {
84
- "@nx/nx-darwin-x64": "18.2.0-canary.20240321-2a4c57d",
85
- "@nx/nx-darwin-arm64": "18.2.0-canary.20240321-2a4c57d",
86
- "@nx/nx-linux-x64-gnu": "18.2.0-canary.20240321-2a4c57d",
87
- "@nx/nx-linux-x64-musl": "18.2.0-canary.20240321-2a4c57d",
88
- "@nx/nx-win32-x64-msvc": "18.2.0-canary.20240321-2a4c57d",
89
- "@nx/nx-linux-arm64-gnu": "18.2.0-canary.20240321-2a4c57d",
90
- "@nx/nx-linux-arm64-musl": "18.2.0-canary.20240321-2a4c57d",
91
- "@nx/nx-linux-arm-gnueabihf": "18.2.0-canary.20240321-2a4c57d",
92
- "@nx/nx-win32-arm64-msvc": "18.2.0-canary.20240321-2a4c57d",
93
- "@nx/nx-freebsd-x64": "18.2.0-canary.20240321-2a4c57d"
84
+ "@nx/nx-darwin-x64": "18.2.0-canary.20240323-54d4780",
85
+ "@nx/nx-darwin-arm64": "18.2.0-canary.20240323-54d4780",
86
+ "@nx/nx-linux-x64-gnu": "18.2.0-canary.20240323-54d4780",
87
+ "@nx/nx-linux-x64-musl": "18.2.0-canary.20240323-54d4780",
88
+ "@nx/nx-win32-x64-msvc": "18.2.0-canary.20240323-54d4780",
89
+ "@nx/nx-linux-arm64-gnu": "18.2.0-canary.20240323-54d4780",
90
+ "@nx/nx-linux-arm64-musl": "18.2.0-canary.20240323-54d4780",
91
+ "@nx/nx-linux-arm-gnueabihf": "18.2.0-canary.20240323-54d4780",
92
+ "@nx/nx-win32-arm64-msvc": "18.2.0-canary.20240323-54d4780",
93
+ "@nx/nx-freebsd-x64": "18.2.0-canary.20240323-54d4780"
94
94
  },
95
95
  "nx-migrations": {
96
96
  "migrations": "./migrations.json",
@@ -270,7 +270,9 @@
270
270
  {
271
271
  "type": "array",
272
272
  "description": "The projects that the targets belong to.",
273
- "items": { "type": "string" }
273
+ "items": {
274
+ "type": "string"
275
+ }
274
276
  }
275
277
  ]
276
278
  },
@@ -294,8 +296,12 @@
294
296
  "required": ["input"],
295
297
  "not": {
296
298
  "anyOf": [
297
- { "required": ["projects"] },
298
- { "required": ["dependencies"] }
299
+ {
300
+ "required": ["projects"]
301
+ },
302
+ {
303
+ "required": ["dependencies"]
304
+ }
299
305
  ]
300
306
  }
301
307
  }
@@ -327,7 +333,9 @@
327
333
  "properties": {
328
334
  "externalDependencies": {
329
335
  "type": "array",
330
- "items": { "type": "string" },
336
+ "items": {
337
+ "type": "string"
338
+ },
331
339
  "description": "The list of external dependencies that our target depends on for `nx:run-commands` and community plugins."
332
340
  }
333
341
  },
@@ -495,8 +503,12 @@
495
503
  "required": ["target"],
496
504
  "not": {
497
505
  "anyOf": [
498
- { "required": ["projects"] },
499
- { "required": ["dependencies"] }
506
+ {
507
+ "required": ["projects"]
508
+ },
509
+ {
510
+ "required": ["dependencies"]
511
+ }
500
512
  ]
501
513
  }
502
514
  }
@@ -529,6 +541,20 @@
529
541
  "options": {
530
542
  "type": "object",
531
543
  "description": "The options passed to the plugin when creating nodes and dependencies"
544
+ },
545
+ "include": {
546
+ "type": "array",
547
+ "description": "File patterns which are included by the plugin",
548
+ "items": {
549
+ "type": "string"
550
+ }
551
+ },
552
+ "exclude": {
553
+ "type": "array",
554
+ "description": "File patterns which are excluded by the plugin",
555
+ "items": {
556
+ "type": "string"
557
+ }
532
558
  }
533
559
  }
534
560
  }
@@ -55,7 +55,7 @@ async function installPackage(pkgName, version) {
55
55
  nxJson.installation.plugins[pkgName] = version;
56
56
  (0, fileutils_1.writeJsonFile)('nx.json', nxJson);
57
57
  try {
58
- await (0, child_process_2.runNxAsync)('--help');
58
+ await (0, child_process_2.runNxAsync)('--help', { silent: true });
59
59
  }
60
60
  catch (e) {
61
61
  // revert adding the plugin to nx.json
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.yargsPrintAffectedCommand = exports.printAffectedDeprecationMessage = exports.yargsAffectedGraphCommand = exports.affectedGraphDeprecationMessage = exports.yargsAffectedE2ECommand = exports.yargsAffectedLintCommand = exports.yargsAffectedBuildCommand = exports.yargsAffectedTestCommand = exports.yargsAffectedCommand = void 0;
4
4
  const documentation_1 = require("../yargs-utils/documentation");
5
5
  const shared_options_1 = require("../yargs-utils/shared-options");
6
+ const params_1 = require("../../utils/params");
6
7
  exports.yargsAffectedCommand = {
7
8
  command: 'affected',
8
9
  describe: 'Run target for affected projects',
@@ -16,43 +17,63 @@ exports.yargsAffectedCommand = {
16
17
  throw new Error("The '--all' option has been removed for `nx affected`. Use 'nx run-many' instead.");
17
18
  }
18
19
  }), 'affected'),
19
- handler: async (args) => (await Promise.resolve().then(() => require('./affected'))).affected('affected', (0, shared_options_1.withOverrides)(args)),
20
+ handler: async (args) => {
21
+ return (0, params_1.handleErrors)(args.verbose ?? process.env.NX_VERBOSE_LOGGING === 'true', async () => {
22
+ return (await Promise.resolve().then(() => require('./affected'))).affected('affected', (0, shared_options_1.withOverrides)(args));
23
+ });
24
+ },
20
25
  };
21
26
  exports.yargsAffectedTestCommand = {
22
27
  command: 'affected:test',
23
28
  describe: false,
24
29
  builder: (yargs) => (0, documentation_1.linkToNxDevAndExamples)((0, shared_options_1.withAffectedOptions)((0, shared_options_1.withRunOptions)((0, shared_options_1.withOutputStyleOption)((0, shared_options_1.withConfiguration)(yargs)))), 'affected'),
25
- handler: async (args) => (await Promise.resolve().then(() => require('./affected'))).affected('affected', {
26
- ...(0, shared_options_1.withOverrides)(args),
27
- target: 'test',
28
- }),
30
+ handler: async (args) => {
31
+ return (0, params_1.handleErrors)(args.verbose ?? process.env.NX_VERBOSE_LOGGING === 'true', async () => {
32
+ return (await Promise.resolve().then(() => require('./affected'))).affected('affected', {
33
+ ...(0, shared_options_1.withOverrides)(args),
34
+ target: 'test',
35
+ });
36
+ });
37
+ },
29
38
  };
30
39
  exports.yargsAffectedBuildCommand = {
31
40
  command: 'affected:build',
32
41
  describe: false,
33
42
  builder: (yargs) => (0, documentation_1.linkToNxDevAndExamples)((0, shared_options_1.withAffectedOptions)((0, shared_options_1.withRunOptions)((0, shared_options_1.withOutputStyleOption)((0, shared_options_1.withConfiguration)(yargs)))), 'affected'),
34
- handler: async (args) => (await Promise.resolve().then(() => require('./affected'))).affected('affected', {
35
- ...(0, shared_options_1.withOverrides)(args),
36
- target: 'build',
37
- }),
43
+ handler: async (args) => {
44
+ return (0, params_1.handleErrors)(args.verbose ?? process.env.NX_VERBOSE_LOGGING === 'true', async () => {
45
+ return (await Promise.resolve().then(() => require('./affected'))).affected('affected', {
46
+ ...(0, shared_options_1.withOverrides)(args),
47
+ target: 'build',
48
+ });
49
+ });
50
+ },
38
51
  };
39
52
  exports.yargsAffectedLintCommand = {
40
53
  command: 'affected:lint',
41
54
  describe: false,
42
55
  builder: (yargs) => (0, documentation_1.linkToNxDevAndExamples)((0, shared_options_1.withAffectedOptions)((0, shared_options_1.withRunOptions)((0, shared_options_1.withOutputStyleOption)((0, shared_options_1.withConfiguration)(yargs)))), 'affected'),
43
- handler: async (args) => (await Promise.resolve().then(() => require('./affected'))).affected('affected', {
44
- ...(0, shared_options_1.withOverrides)(args),
45
- target: 'lint',
46
- }),
56
+ handler: async (args) => {
57
+ return (0, params_1.handleErrors)(args.verbose ?? process.env.NX_VERBOSE_LOGGING === 'true', async () => {
58
+ return (await Promise.resolve().then(() => require('./affected'))).affected('affected', {
59
+ ...(0, shared_options_1.withOverrides)(args),
60
+ target: 'lint',
61
+ });
62
+ });
63
+ },
47
64
  };
48
65
  exports.yargsAffectedE2ECommand = {
49
66
  command: 'affected:e2e',
50
67
  describe: false,
51
68
  builder: (yargs) => (0, documentation_1.linkToNxDevAndExamples)((0, shared_options_1.withAffectedOptions)((0, shared_options_1.withRunOptions)((0, shared_options_1.withOutputStyleOption)((0, shared_options_1.withConfiguration)(yargs)))), 'affected'),
52
- handler: async (args) => (await Promise.resolve().then(() => require('./affected'))).affected('affected', {
53
- ...(0, shared_options_1.withOverrides)(args),
54
- target: 'e2e',
55
- }),
69
+ handler: async (args) => {
70
+ return (0, params_1.handleErrors)(args.verbose ?? process.env.NX_VERBOSE_LOGGING === 'true', async () => {
71
+ return (await Promise.resolve().then(() => require('./affected'))).affected('affected', {
72
+ ...(0, shared_options_1.withOverrides)(args),
73
+ target: 'e2e',
74
+ });
75
+ });
76
+ },
56
77
  };
57
78
  exports.affectedGraphDeprecationMessage = 'Use `nx graph --affected`, or `nx affected --graph` instead depending on which best suits your use case. The `affected:graph` command will be removed in Nx 19.';
58
79
  /**
@@ -63,9 +84,13 @@ exports.yargsAffectedGraphCommand = {
63
84
  describe: 'Graph dependencies affected by changes',
64
85
  aliases: ['affected:dep-graph'],
65
86
  builder: (yargs) => (0, documentation_1.linkToNxDevAndExamples)((0, shared_options_1.withAffectedOptions)((0, shared_options_1.withDepGraphOptions)(yargs)), 'affected:graph'),
66
- handler: async (args) => await (await Promise.resolve().then(() => require('./affected'))).affected('graph', {
67
- ...args,
68
- }),
87
+ handler: async (args) => {
88
+ return (0, params_1.handleErrors)(args.verbose ?? process.env.NX_VERBOSE_LOGGING === 'true', async () => {
89
+ return await (await Promise.resolve().then(() => require('./affected'))).affected('graph', {
90
+ ...args,
91
+ });
92
+ });
93
+ },
69
94
  deprecated: exports.affectedGraphDeprecationMessage,
70
95
  };
71
96
  exports.printAffectedDeprecationMessage = 'Use `nx show projects --affected`, `nx affected --graph -t build` or `nx graph --affected` depending on which best suits your use case. The `print-affected` command will be removed in Nx 19.';
@@ -86,8 +111,10 @@ exports.yargsPrintAffectedCommand = {
86
111
  describe: 'Select the type of projects to be returned (e.g., --type=app)',
87
112
  }),
88
113
  handler: async (args) => {
89
- await (await Promise.resolve().then(() => require('./affected'))).affected('print-affected', (0, shared_options_1.withOverrides)(args));
90
- process.exit(0);
114
+ return (0, params_1.handleErrors)(args.verbose ?? process.env.NX_VERBOSE_LOGGING === 'true', async () => {
115
+ await (await Promise.resolve().then(() => require('./affected'))).affected('print-affected', (0, shared_options_1.withOverrides)(args));
116
+ process.exit(0);
117
+ });
91
118
  },
92
119
  deprecated: exports.printAffectedDeprecationMessage,
93
120
  };
@@ -210,10 +210,10 @@ async function generate(cwd, args) {
210
210
  process.env.NX_VERBOSE_LOGGING = 'true';
211
211
  }
212
212
  const verbose = process.env.NX_VERBOSE_LOGGING === 'true';
213
- const nxJsonConfiguration = (0, configuration_1.readNxJson)();
214
- const projectGraph = await (0, project_graph_1.createProjectGraphAsync)({ exitOnError: true });
215
- const projectsConfigurations = (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph);
216
213
  return (0, params_1.handleErrors)(verbose, async () => {
214
+ const nxJsonConfiguration = (0, configuration_1.readNxJson)();
215
+ const projectGraph = await (0, project_graph_1.createProjectGraphAsync)();
216
+ const projectsConfigurations = (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph);
217
217
  const opts = await convertToGenerateOptions(args, 'generate', projectsConfigurations);
218
218
  const { normalizedGeneratorName, schema, implementationFactory, generatorConfiguration: { aliases, hidden, ['x-deprecated']: deprecated, ['x-use-standalone-layout']: isStandalonePreset, }, } = (0, generator_utils_1.getGeneratorInformation)(opts.collectionName, opts.generatorName, workspace_root_1.workspaceRoot, projectsConfigurations.projects);
219
219
  if (deprecated) {
@@ -51,8 +51,8 @@ async function initHandler(options) {
51
51
  return;
52
52
  }
53
53
  output_1.output.log({ title: '🧐 Checking dependencies' });
54
- const detectPluginsResponse = await detectPlugins();
55
- if (!detectPluginsResponse?.plugins.length) {
54
+ const { plugins, updatePackageScripts } = await detectPlugins();
55
+ if (!plugins.length) {
56
56
  // If no plugins are detected/chosen, guide users to setup
57
57
  // their targetDefaults correctly so their package scripts will work.
58
58
  const packageJson = (0, fileutils_1.readJsonFile)('package.json');
@@ -72,19 +72,17 @@ async function initHandler(options) {
72
72
  const pmc = (0, package_manager_1.getPackageManagerCommand)();
73
73
  (0, utils_1.createNxJsonFile)(repoRoot, [], [], {});
74
74
  (0, utils_1.updateGitIgnore)(repoRoot);
75
- (0, utils_1.addDepsToPackageJson)(repoRoot, detectPluginsResponse.plugins);
75
+ (0, utils_1.addDepsToPackageJson)(repoRoot, plugins);
76
76
  output_1.output.log({ title: '📦 Installing Nx' });
77
77
  (0, utils_1.runInstall)(repoRoot, pmc);
78
78
  output_1.output.log({ title: '🔨 Configuring plugins' });
79
- for (const plugin of detectPluginsResponse.plugins) {
80
- (0, child_process_2.execSync)(`${pmc.exec} nx g ${plugin}:init --keepExistingVersions ${detectPluginsResponse.updatePackageScripts
81
- ? '--updatePackageScripts'
82
- : ''} --no-interactive`, {
79
+ for (const plugin of plugins) {
80
+ (0, child_process_2.execSync)(`${pmc.exec} nx g ${plugin}:init --keepExistingVersions ${updatePackageScripts ? '--updatePackageScripts' : ''} --no-interactive`, {
83
81
  stdio: [0, 1, 2],
84
82
  cwd: repoRoot,
85
83
  });
86
84
  }
87
- if (!detectPluginsResponse.updatePackageScripts) {
85
+ if (!updatePackageScripts) {
88
86
  const rootPackageJsonPath = (0, path_1.join)(repoRoot, 'package.json');
89
87
  const json = (0, fileutils_1.readJsonFile)(rootPackageJsonPath);
90
88
  json.nx = { includedScripts: [] };
@@ -156,8 +154,12 @@ async function detectPlugins() {
156
154
  detectedPlugins.add('@nx/gradle');
157
155
  }
158
156
  const plugins = Array.from(detectedPlugins);
159
- if (plugins.length === 0)
160
- return undefined;
157
+ if (plugins.length === 0) {
158
+ return {
159
+ plugins: [],
160
+ updatePackageScripts: false,
161
+ };
162
+ }
161
163
  output_1.output.log({
162
164
  title: `Recommended Plugins:`,
163
165
  bodyLines: [
@@ -174,7 +176,10 @@ async function detectPlugins() {
174
176
  },
175
177
  ]).then((r) => r.plugins);
176
178
  if (pluginsToInstall?.length === 0)
177
- return undefined;
179
+ return {
180
+ plugins: [],
181
+ updatePackageScripts: false,
182
+ };
178
183
  const updatePackageScripts = (0, fs_1.existsSync)('package.json') &&
179
184
  (await (0, enquirer_1.prompt)([
180
185
  {
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.yargsNxInfixCommand = exports.yargsRunCommand = void 0;
4
4
  const shared_options_1 = require("../yargs-utils/shared-options");
5
+ const params_1 = require("../../utils/params");
5
6
  exports.yargsRunCommand = {
6
7
  command: 'run [project][:target][:configuration] [_..]',
7
8
  describe: `Run a target for a project
@@ -12,7 +13,9 @@ exports.yargsRunCommand = {
12
13
 
13
14
  You can skip the use of Nx cache by using the --skip-nx-cache option.`,
14
15
  builder: (yargs) => (0, shared_options_1.withRunOneOptions)((0, shared_options_1.withBatch)(yargs)),
15
- handler: async (args) => (await Promise.resolve().then(() => require('./run-one'))).runOne(process.cwd(), (0, shared_options_1.withOverrides)(args)),
16
+ handler: async (args) => await (0, params_1.handleErrors)(args.verbose ?? process.env.NX_VERBOSE_LOGGING === 'true', async () => {
17
+ (await Promise.resolve().then(() => require('./run-one'))).runOne(process.cwd(), (0, shared_options_1.withOverrides)(args));
18
+ }),
16
19
  };
17
20
  /**
18
21
  * Handles the infix notation for running a target.
@@ -21,5 +24,9 @@ exports.yargsNxInfixCommand = {
21
24
  ...exports.yargsRunCommand,
22
25
  command: '$0 <target> [project] [_..]',
23
26
  describe: 'Run a target for a project',
24
- handler: async (args) => (await Promise.resolve().then(() => require('./run-one'))).runOne(process.cwd(), (0, shared_options_1.withOverrides)(args, 0)),
27
+ handler: async (args) => {
28
+ await (0, params_1.handleErrors)(args.verbose ?? process.env.NX_VERBOSE_LOGGING === 'true', async () => {
29
+ return (await Promise.resolve().then(() => require('./run-one'))).runOne(process.cwd(), (0, shared_options_1.withOverrides)(args, 0));
30
+ });
31
+ },
25
32
  };
@@ -18,7 +18,7 @@ async function runOne(cwd, args, extraTargetDependencies = {}, extraOptions = {
18
18
  perf_hooks_1.performance.measure('code-loading', 'init-local', 'code-loading:end');
19
19
  (0, workspace_configuration_check_1.workspaceConfigurationCheck)();
20
20
  const nxJson = (0, configuration_1.readNxJson)();
21
- const projectGraph = await (0, project_graph_1.createProjectGraphAsync)({ exitOnError: true });
21
+ const projectGraph = await (0, project_graph_1.createProjectGraphAsync)();
22
22
  const opts = parseRunOneOptions(cwd, args, projectGraph, nxJson);
23
23
  const { nxArgs, overrides } = (0, command_line_utils_1.splitArgsIntoNxArgsAndOverrides)({
24
24
  ...opts.parsedArgs,
@@ -3,9 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.yargsRunManyCommand = void 0;
4
4
  const documentation_1 = require("../yargs-utils/documentation");
5
5
  const shared_options_1 = require("../yargs-utils/shared-options");
6
+ const params_1 = require("../../utils/params");
6
7
  exports.yargsRunManyCommand = {
7
8
  command: 'run-many',
8
9
  describe: 'Run target for multiple listed projects',
9
10
  builder: (yargs) => (0, documentation_1.linkToNxDevAndExamples)((0, shared_options_1.withRunManyOptions)((0, shared_options_1.withOutputStyleOption)((0, shared_options_1.withTargetAndConfigurationOption)((0, shared_options_1.withBatch)(yargs)))), 'run-many'),
10
- handler: async (args) => (await Promise.resolve().then(() => require('./run-many'))).runMany((0, shared_options_1.withOverrides)(args)),
11
+ handler: async (args) => await (0, params_1.handleErrors)(args.verbose ?? process.env.NX_VERBOSE_LOGGING === 'true', async () => {
12
+ (await Promise.resolve().then(() => require('./run-many'))).runMany((0, shared_options_1.withOverrides)(args));
13
+ }),
11
14
  };
@@ -14,9 +14,11 @@ export type ShowProjectsOptions = NxShowArgs & {
14
14
  type: ProjectGraphProjectNode['type'];
15
15
  projects: string[];
16
16
  withTarget: string[];
17
+ verbose: boolean;
17
18
  };
18
19
  export type ShowProjectOptions = NxShowArgs & {
19
20
  projectName: string;
20
21
  web?: boolean;
22
+ verbose: boolean;
21
23
  };
22
24
  export declare const yargsShowCommand: CommandModule<Record<string, unknown>, NxShowArgs>;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.yargsShowCommand = void 0;
4
4
  const yargs_1 = require("yargs");
5
5
  const shared_options_1 = require("../yargs-utils/shared-options");
6
+ const params_1 = require("../../utils/params");
6
7
  exports.yargsShowCommand = {
7
8
  command: 'show',
8
9
  describe: 'Show information about the workspace (e.g., list of projects)',
@@ -46,6 +47,10 @@ const showProjectsCommand = {
46
47
  type: 'string',
47
48
  description: 'Select only projects of the given type',
48
49
  choices: ['app', 'lib', 'e2e'],
50
+ })
51
+ .option('verbose', {
52
+ type: 'boolean',
53
+ description: 'Prints additional information about the commands (e.g., stack traces)',
49
54
  })
50
55
  .implies('untracked', 'affected')
51
56
  .implies('uncommitted', 'affected')
@@ -57,7 +62,11 @@ const showProjectsCommand = {
57
62
  .example('$0 show projects --affected', 'Show affected projects in the workspace')
58
63
  .example('$0 show projects --type app --affected', 'Show affected apps in the workspace')
59
64
  .example('$0 show projects --affected --exclude=*-e2e', 'Show affected projects in the workspace, excluding end-to-end projects'),
60
- handler: (args) => Promise.resolve().then(() => require('./show')).then((m) => m.showProjectsHandler(args)),
65
+ handler: (args) => {
66
+ return (0, params_1.handleErrors)(args.verbose ?? process.env.NX_VERBOSE_LOGGING === 'true', async () => {
67
+ return (await Promise.resolve().then(() => require('./show'))).showProjectsHandler(args);
68
+ });
69
+ },
61
70
  };
62
71
  const showProjectCommand = {
63
72
  command: 'project <projectName>',
@@ -72,6 +81,10 @@ const showProjectCommand = {
72
81
  .option('web', {
73
82
  type: 'boolean',
74
83
  description: 'Show project details in the browser',
84
+ })
85
+ .option('verbose', {
86
+ type: 'boolean',
87
+ description: 'Prints additional information about the commands (e.g., stack traces)',
75
88
  })
76
89
  .check((argv) => {
77
90
  if (argv.web) {
@@ -80,5 +93,9 @@ const showProjectCommand = {
80
93
  return true;
81
94
  })
82
95
  .example('$0 show project my-app', 'View project information for my-app in JSON format'),
83
- handler: (args) => Promise.resolve().then(() => require('./show')).then((m) => m.showProjectHandler(args)),
96
+ handler: (args) => {
97
+ return (0, params_1.handleErrors)(args.verbose ?? process.env.NX_VERBOSE_LOGGING === 'true', async () => {
98
+ return (await Promise.resolve().then(() => require('./show'))).showProjectHandler(args);
99
+ });
100
+ },
84
101
  };
@@ -397,6 +397,8 @@ export interface NxJsonConfiguration<T = '*' | string[]> {
397
397
  export type PluginConfiguration = string | {
398
398
  plugin: string;
399
399
  options?: unknown;
400
+ include?: string[];
401
+ exclude?: string[];
400
402
  };
401
403
  export declare function readNxJson(root?: string): NxJsonConfiguration;
402
404
  export declare function hasNxJson(root: string): boolean;
@@ -18,6 +18,8 @@ const promised_based_queue_1 = require("../../utils/promised-based-queue");
18
18
  const nx_json_1 = require("../../config/nx-json");
19
19
  const daemon_socket_messenger_1 = require("./daemon-socket-messenger");
20
20
  const cache_1 = require("../cache");
21
+ const daemon_project_graph_error_1 = require("../daemon-project-graph-error");
22
+ const project_graph_1 = require("../../project-graph/project-graph");
21
23
  const DAEMON_ENV_SETTINGS = {
22
24
  ...process.env,
23
25
  NX_PROJECT_GLOB_CACHE: 'false',
@@ -90,13 +92,23 @@ class DaemonClient {
90
92
  return this.sendToDaemonViaQueue({ type: 'REQUEST_SHUTDOWN' });
91
93
  }
92
94
  async getProjectGraphAndSourceMaps() {
93
- const response = await this.sendToDaemonViaQueue({
94
- type: 'REQUEST_PROJECT_GRAPH',
95
- });
96
- return {
97
- projectGraph: response.projectGraph,
98
- sourceMaps: response.sourceMaps,
99
- };
95
+ try {
96
+ const response = await this.sendToDaemonViaQueue({
97
+ type: 'REQUEST_PROJECT_GRAPH',
98
+ });
99
+ return {
100
+ projectGraph: response.projectGraph,
101
+ sourceMaps: response.sourceMaps,
102
+ };
103
+ }
104
+ catch (e) {
105
+ if (e.name === daemon_project_graph_error_1.DaemonProjectGraphError.name) {
106
+ throw project_graph_1.ProjectGraphError.fromDaemonProjectGraphError(e);
107
+ }
108
+ else {
109
+ throw e;
110
+ }
111
+ }
100
112
  }
101
113
  async getAllFileData() {
102
114
  return await this.sendToDaemonViaQueue({ type: 'REQUEST_FILE_DATA' });
@@ -0,0 +1,8 @@
1
+ import { ProjectGraph } from '../config/project-graph';
2
+ import { ConfigurationSourceMaps } from '../project-graph/utils/project-configuration-utils';
3
+ export declare class DaemonProjectGraphError extends Error {
4
+ errors: any[];
5
+ readonly projectGraph: ProjectGraph;
6
+ readonly sourceMaps: ConfigurationSourceMaps;
7
+ constructor(errors: any[], projectGraph: ProjectGraph, sourceMaps: ConfigurationSourceMaps);
8
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DaemonProjectGraphError = void 0;
4
+ class DaemonProjectGraphError extends Error {
5
+ constructor(errors, projectGraph, sourceMaps) {
6
+ super(`The Daemon Process threw an error while calculating the project graph. Convert this error to a ProjectGraphError to get more information.`);
7
+ this.errors = errors;
8
+ this.projectGraph = projectGraph;
9
+ this.sourceMaps = sourceMaps;
10
+ this.name = this.constructor.name;
11
+ }
12
+ }
13
+ exports.DaemonProjectGraphError = DaemonProjectGraphError;
@@ -4,6 +4,7 @@ exports.handleHashTasks = void 0;
4
4
  const project_graph_incremental_recomputation_1 = require("./project-graph-incremental-recomputation");
5
5
  const task_hasher_1 = require("../../hasher/task-hasher");
6
6
  const configuration_1 = require("../../config/configuration");
7
+ const daemon_project_graph_error_1 = require("../daemon-project-graph-error");
7
8
  /**
8
9
  * We use this not to recreated hasher for every hash operation
9
10
  * TaskHasher has a cache inside, so keeping it around results in faster performance
@@ -11,7 +12,16 @@ const configuration_1 = require("../../config/configuration");
11
12
  let storedProjectGraph = null;
12
13
  let storedHasher = null;
13
14
  async function handleHashTasks(payload) {
14
- const { projectGraph, allWorkspaceFiles, fileMap, rustReferences } = await (0, project_graph_incremental_recomputation_1.getCachedSerializedProjectGraphPromise)();
15
+ const { error, projectGraph: _graph, allWorkspaceFiles, fileMap, rustReferences, } = await (0, project_graph_incremental_recomputation_1.getCachedSerializedProjectGraphPromise)();
16
+ let projectGraph = _graph;
17
+ if (error) {
18
+ if (error instanceof daemon_project_graph_error_1.DaemonProjectGraphError) {
19
+ projectGraph = error.projectGraph;
20
+ }
21
+ else {
22
+ throw error;
23
+ }
24
+ }
15
25
  const nxJson = (0, configuration_1.readNxJson)();
16
26
  if (projectGraph !== storedProjectGraph) {
17
27
  storedProjectGraph = projectGraph;
@@ -4,6 +4,7 @@ import { NxWorkspaceFilesExternals } from '../../native';
4
4
  interface SerializedProjectGraph {
5
5
  error: Error | null;
6
6
  projectGraph: ProjectGraph | null;
7
+ projectFileMapCache: FileMapCache | null;
7
8
  fileMap: FileMap | null;
8
9
  allWorkspaceFiles: FileData[] | null;
9
10
  serializedProjectGraph: string | null;