nx 18.2.0-canary.20240320-64b2396 → 18.2.0-canary.20240322-61cb63d

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": "18.2.0-canary.20240320-64b2396",
3
+ "version": "18.2.0-canary.20240322-61cb63d",
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.20240320-64b2396"
69
+ "@nrwl/tao": "18.2.0-canary.20240322-61cb63d"
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.20240320-64b2396",
85
- "@nx/nx-darwin-arm64": "18.2.0-canary.20240320-64b2396",
86
- "@nx/nx-linux-x64-gnu": "18.2.0-canary.20240320-64b2396",
87
- "@nx/nx-linux-x64-musl": "18.2.0-canary.20240320-64b2396",
88
- "@nx/nx-win32-x64-msvc": "18.2.0-canary.20240320-64b2396",
89
- "@nx/nx-linux-arm64-gnu": "18.2.0-canary.20240320-64b2396",
90
- "@nx/nx-linux-arm64-musl": "18.2.0-canary.20240320-64b2396",
91
- "@nx/nx-linux-arm-gnueabihf": "18.2.0-canary.20240320-64b2396",
92
- "@nx/nx-win32-arm64-msvc": "18.2.0-canary.20240320-64b2396",
93
- "@nx/nx-freebsd-x64": "18.2.0-canary.20240320-64b2396"
84
+ "@nx/nx-darwin-x64": "18.2.0-canary.20240322-61cb63d",
85
+ "@nx/nx-darwin-arm64": "18.2.0-canary.20240322-61cb63d",
86
+ "@nx/nx-linux-x64-gnu": "18.2.0-canary.20240322-61cb63d",
87
+ "@nx/nx-linux-x64-musl": "18.2.0-canary.20240322-61cb63d",
88
+ "@nx/nx-win32-x64-msvc": "18.2.0-canary.20240322-61cb63d",
89
+ "@nx/nx-linux-arm64-gnu": "18.2.0-canary.20240322-61cb63d",
90
+ "@nx/nx-linux-arm64-musl": "18.2.0-canary.20240322-61cb63d",
91
+ "@nx/nx-linux-arm-gnueabihf": "18.2.0-canary.20240322-61cb63d",
92
+ "@nx/nx-win32-arm64-msvc": "18.2.0-canary.20240322-61cb63d",
93
+ "@nx/nx-freebsd-x64": "18.2.0-canary.20240322-61cb63d"
94
94
  },
95
95
  "nx-migrations": {
96
96
  "migrations": "./migrations.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) {
@@ -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
  };
@@ -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;
@@ -13,6 +13,8 @@ const workspace_context_1 = require("../../utils/workspace-context");
13
13
  const workspace_root_1 = require("../../utils/workspace-root");
14
14
  const file_watcher_sockets_1 = require("./file-watching/file-watcher-sockets");
15
15
  const logger_1 = require("./logger");
16
+ const project_configuration_utils_1 = require("../../project-graph/utils/project-configuration-utils");
17
+ const daemon_project_graph_error_1 = require("../daemon-project-graph-error");
16
18
  let cachedSerializedProjectGraphPromise;
17
19
  const collectedUpdatedFiles = new Set();
18
20
  const collectedDeletedFiles = new Set();
@@ -48,6 +50,7 @@ async function getCachedSerializedProjectGraphPromise() {
48
50
  serializedProjectGraph: null,
49
51
  serializedSourceMaps: null,
50
52
  projectGraph: null,
53
+ projectFileMapCache: null,
51
54
  fileMap: null,
52
55
  allWorkspaceFiles: null,
53
56
  rustReferences: null,
@@ -139,22 +142,66 @@ async function processFilesAndCreateAndSerializeProjectGraph() {
139
142
  const nxJson = (0, nx_json_1.readNxJson)(workspace_root_1.workspaceRoot);
140
143
  // Set this globally to allow plugins to know if they are being called from the project graph creation
141
144
  global.NX_GRAPH_CREATION = true;
142
- const graphNodes = await (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(workspace_root_1.workspaceRoot, nxJson);
145
+ let graphNodes;
146
+ let projectConfigurationsError;
147
+ try {
148
+ graphNodes = await (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(workspace_root_1.workspaceRoot, nxJson);
149
+ }
150
+ catch (e) {
151
+ if (e instanceof project_configuration_utils_1.ProjectConfigurationsError) {
152
+ graphNodes = e.partialProjectConfigurationsResult;
153
+ projectConfigurationsError = e;
154
+ }
155
+ }
143
156
  await processCollectedUpdatedAndDeletedFiles(graphNodes, updatedFileHashes, deletedFiles);
144
- const g = createAndSerializeProjectGraph(graphNodes);
157
+ const g = await createAndSerializeProjectGraph(graphNodes);
145
158
  delete global.NX_GRAPH_CREATION;
146
- return g;
159
+ const errors = [...(projectConfigurationsError?.errors ?? [])];
160
+ if (g.error) {
161
+ if (g.error instanceof build_project_graph_1.CreateDependenciesError) {
162
+ errors.concat(g.error.errors);
163
+ }
164
+ else {
165
+ return {
166
+ error: g.error,
167
+ projectGraph: null,
168
+ projectFileMapCache: null,
169
+ fileMap: null,
170
+ rustReferences: null,
171
+ allWorkspaceFiles: null,
172
+ serializedProjectGraph: null,
173
+ serializedSourceMaps: null,
174
+ };
175
+ }
176
+ }
177
+ if (errors.length > 0) {
178
+ return {
179
+ error: new daemon_project_graph_error_1.DaemonProjectGraphError(errors, g.projectGraph, graphNodes.sourceMaps),
180
+ projectGraph: null,
181
+ projectFileMapCache: null,
182
+ fileMap: null,
183
+ rustReferences: null,
184
+ allWorkspaceFiles: null,
185
+ serializedProjectGraph: null,
186
+ serializedSourceMaps: null,
187
+ };
188
+ }
189
+ else {
190
+ (0, nx_deps_cache_1.writeCache)(g.projectFileMapCache, g.projectGraph);
191
+ return g;
192
+ }
147
193
  }
148
194
  catch (err) {
149
- return Promise.resolve({
195
+ return {
150
196
  error: err,
151
197
  projectGraph: null,
198
+ projectFileMapCache: null,
152
199
  fileMap: null,
153
200
  rustReferences: null,
154
201
  allWorkspaceFiles: null,
155
202
  serializedProjectGraph: null,
156
203
  serializedSourceMaps: null,
157
- });
204
+ };
158
205
  }
159
206
  }
160
207
  function copyFileData(d) {
@@ -176,7 +223,7 @@ async function createAndSerializeProjectGraph({ projects, sourceMaps, }) {
176
223
  const fileMap = copyFileMap(exports.fileMapWithFiles.fileMap);
177
224
  const allWorkspaceFiles = copyFileData(exports.fileMapWithFiles.allWorkspaceFiles);
178
225
  const rustReferences = exports.fileMapWithFiles.rustReferences;
179
- const { projectGraph, projectFileMapCache } = await (0, build_project_graph_1.buildProjectGraphUsingProjectFileMap)(projects, knownExternalNodes, fileMap, allWorkspaceFiles, rustReferences, exports.currentProjectFileMapCache || (0, nx_deps_cache_1.readFileMapCache)(), true);
226
+ const { projectGraph, projectFileMapCache } = await (0, build_project_graph_1.buildProjectGraphUsingProjectFileMap)(projects, knownExternalNodes, fileMap, allWorkspaceFiles, rustReferences, exports.currentProjectFileMapCache || (0, nx_deps_cache_1.readFileMapCache)());
180
227
  exports.currentProjectFileMapCache = projectFileMapCache;
181
228
  exports.currentProjectGraph = projectGraph;
182
229
  perf_hooks_1.performance.mark('create-project-graph-end');
@@ -189,6 +236,7 @@ async function createAndSerializeProjectGraph({ projects, sourceMaps, }) {
189
236
  return {
190
237
  error: null,
191
238
  projectGraph,
239
+ projectFileMapCache,
192
240
  fileMap,
193
241
  allWorkspaceFiles,
194
242
  serializedProjectGraph,
@@ -201,6 +249,7 @@ async function createAndSerializeProjectGraph({ projects, sourceMaps, }) {
201
249
  return {
202
250
  error: e,
203
251
  projectGraph: null,
252
+ projectFileMapCache: null,
204
253
  fileMap: null,
205
254
  allWorkspaceFiles: null,
206
255
  serializedProjectGraph: null,
@@ -69,9 +69,7 @@ exports.respondToClient = respondToClient;
69
69
  async function respondWithErrorAndExit(socket, description, error) {
70
70
  // print some extra stuff in the error message
71
71
  logger_1.serverLogger.requestLog(`Responding to the client with an error.`, description, error.message);
72
- console.error(error);
73
- error.message = `${error.message}\n\nBecause of the error the Nx daemon process has exited. The next Nx command is going to restart the daemon process.\nIf the error persists, please run "nx reset".`;
72
+ console.error(error.stack);
74
73
  await respondToClient(socket, (0, socket_utils_1.serializeResult)(error, null, null), null);
75
- process.exit(1);
76
74
  }
77
75
  exports.respondWithErrorAndExit = respondWithErrorAndExit;
@@ -5,6 +5,7 @@ const fs_1 = require("fs");
5
5
  const os_1 = require("os");
6
6
  const path_1 = require("path");
7
7
  const tmp_dir_1 = require("./tmp-dir");
8
+ const daemon_project_graph_error_1 = require("./daemon-project-graph-error");
8
9
  exports.isWindows = (0, os_1.platform)() === 'win32';
9
10
  /**
10
11
  * For IPC with the daemon server we use unix sockets or windows named pipes, depending on the user's operating system.
@@ -32,7 +33,12 @@ function serializeError(error) {
32
33
  if (!error) {
33
34
  return null;
34
35
  }
35
- return JSON.stringify(error, Object.getOwnPropertyNames(error));
36
+ if (error instanceof daemon_project_graph_error_1.DaemonProjectGraphError) {
37
+ error.errors = error.errors.map((e) => JSON.parse(serializeError(e)));
38
+ }
39
+ return `{${Object.getOwnPropertyNames(error)
40
+ .map((k) => `"${k}": ${JSON.stringify(error[k])}`)
41
+ .join(',')}}`;
36
42
  }
37
43
  // Prepare a serialized project graph result for sending over IPC from the server to the client
38
44
  function serializeResult(error, serializedProjectGraph, serializedSourceMaps) {
@@ -8,7 +8,24 @@ export declare function getFileMap(): {
8
8
  allWorkspaceFiles: FileData[];
9
9
  rustReferences: NxWorkspaceFilesExternals | null;
10
10
  };
11
- export declare function buildProjectGraphUsingProjectFileMap(projects: Record<string, ProjectConfiguration>, externalNodes: Record<string, ProjectGraphExternalNode>, fileMap: FileMap, allWorkspaceFiles: FileData[], rustReferences: NxWorkspaceFilesExternals, fileMapCache: FileMapCache | null, shouldWriteCache: boolean): Promise<{
11
+ export declare function buildProjectGraphUsingProjectFileMap(projects: Record<string, ProjectConfiguration>, externalNodes: Record<string, ProjectGraphExternalNode>, fileMap: FileMap, allWorkspaceFiles: FileData[], rustReferences: NxWorkspaceFilesExternals, fileMapCache: FileMapCache | null): Promise<{
12
12
  projectGraph: ProjectGraph;
13
13
  projectFileMapCache: FileMapCache;
14
14
  }>;
15
+ export declare class ProcessDependenciesError extends Error {
16
+ readonly pluginName: string;
17
+ constructor(pluginName: string, { cause }: {
18
+ cause: any;
19
+ });
20
+ }
21
+ export declare class ProcessProjectGraphError extends Error {
22
+ readonly pluginName: string;
23
+ constructor(pluginName: string, { cause }: {
24
+ cause: any;
25
+ });
26
+ }
27
+ export declare class CreateDependenciesError extends Error {
28
+ readonly errors: Array<ProcessDependenciesError | ProcessProjectGraphError>;
29
+ readonly partialProjectGraph: ProjectGraph;
30
+ constructor(errors: Array<ProcessDependenciesError | ProcessProjectGraphError>, partialProjectGraph: ProjectGraph);
31
+ }