nx 19.0.0-beta.1 → 19.0.0-beta.10

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 (99) hide show
  1. package/.eslintrc.json +1 -1
  2. package/migrations.json +2 -25
  3. package/package.json +12 -12
  4. package/src/command-line/add/add.js +17 -16
  5. package/src/command-line/affected/affected.js +1 -1
  6. package/src/command-line/graph/graph.d.ts +11 -1
  7. package/src/command-line/graph/graph.js +97 -13
  8. package/src/command-line/init/implementation/react/index.js +1 -1
  9. package/src/command-line/release/changelog.js +1 -1
  10. package/src/command-line/release/command-object.js +2 -2
  11. package/src/command-line/release/publish.js +1 -1
  12. package/src/command-line/report/report.js +1 -1
  13. package/src/command-line/run/run-one.js +1 -1
  14. package/src/command-line/run-many/run-many.js +1 -1
  15. package/src/command-line/yargs-utils/shared-options.js +1 -1
  16. package/src/config/nx-json.d.ts +2 -2
  17. package/src/config/to-project-name.d.ts +5 -0
  18. package/src/config/to-project-name.js +13 -0
  19. package/src/core/graph/index.html +1 -2
  20. package/src/core/graph/main.js +1 -1
  21. package/src/core/graph/runtime.js +1 -1
  22. package/src/core/graph/styles.css +2 -2
  23. package/src/core/graph/styles.js +1 -1
  24. package/src/daemon/client/client.d.ts +2 -2
  25. package/src/daemon/client/client.js +21 -6
  26. package/src/daemon/server/project-graph-incremental-recomputation.js +8 -8
  27. package/src/daemon/server/shutdown-utils.js +7 -2
  28. package/src/daemon/tmp-dir.js +2 -2
  29. package/src/devkit-exports.d.ts +1 -5
  30. package/src/devkit-exports.js +1 -7
  31. package/src/devkit-internals.d.ts +2 -0
  32. package/src/devkit-internals.js +5 -1
  33. package/src/executors/run-commands/run-commands.impl.d.ts +2 -0
  34. package/src/executors/run-commands/run-commands.impl.js +69 -23
  35. package/src/executors/run-commands/schema.json +19 -2
  36. package/src/executors/utils/convert-nx-executor.js +2 -1
  37. package/src/generators/testing-utils/create-tree-with-empty-workspace.js +7 -0
  38. package/src/generators/utils/project-configuration.js +3 -8
  39. package/src/hasher/task-hasher.d.ts +4 -4
  40. package/src/native/index.d.ts +1 -1
  41. package/src/plugins/js/lock-file/pnpm-parser.js +109 -67
  42. package/src/plugins/package-json-workspaces/create-nodes.d.ts +1 -0
  43. package/src/plugins/package-json-workspaces/create-nodes.js +25 -20
  44. package/src/plugins/project-json/build-nodes/project-json.js +2 -2
  45. package/src/project-graph/affected/locators/workspace-projects.js +3 -1
  46. package/src/project-graph/build-project-graph.d.ts +8 -18
  47. package/src/project-graph/build-project-graph.js +86 -57
  48. package/src/project-graph/error-types.d.ts +31 -3
  49. package/src/project-graph/error-types.js +74 -2
  50. package/src/project-graph/file-utils.d.ts +2 -3
  51. package/src/project-graph/file-utils.js +5 -9
  52. package/src/project-graph/plugins/internal-api.d.ts +3 -2
  53. package/src/project-graph/plugins/internal-api.js +3 -0
  54. package/src/project-graph/plugins/isolation/messaging.d.ts +26 -3
  55. package/src/project-graph/plugins/isolation/plugin-pool.js +23 -1
  56. package/src/project-graph/plugins/isolation/plugin-worker.js +21 -0
  57. package/src/project-graph/plugins/loader.js +14 -6
  58. package/src/project-graph/plugins/public-api.d.ts +11 -1
  59. package/src/project-graph/plugins/utils.d.ts +2 -2
  60. package/src/project-graph/plugins/utils.js +19 -24
  61. package/src/project-graph/project-graph.d.ts +3 -0
  62. package/src/project-graph/project-graph.js +8 -7
  63. package/src/project-graph/utils/find-project-for-path.js +2 -3
  64. package/src/project-graph/utils/normalize-project-nodes.d.ts +1 -1
  65. package/src/project-graph/utils/normalize-project-nodes.js +8 -14
  66. package/src/project-graph/utils/project-configuration-utils.d.ts +23 -6
  67. package/src/project-graph/utils/project-configuration-utils.js +43 -20
  68. package/src/tasks-runner/create-task-graph.js +0 -1
  69. package/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.js +5 -1
  70. package/src/tasks-runner/life-cycles/dynamic-run-one-terminal-output-life-cycle.js +4 -0
  71. package/src/tasks-runner/pseudo-terminal.d.ts +2 -1
  72. package/src/tasks-runner/pseudo-terminal.js +8 -2
  73. package/src/tasks-runner/run-command.js +4 -4
  74. package/src/tasks-runner/utils.js +17 -0
  75. package/src/utils/assert-workspace-validity.js +2 -1
  76. package/src/utils/command-line-utils.d.ts +1 -1
  77. package/src/utils/nx-plugin.deprecated.d.ts +1 -1
  78. package/src/utils/nx-plugin.deprecated.js +1 -1
  79. package/src/utils/params.js +4 -0
  80. package/src/utils/perf-logging.js +3 -1
  81. package/src/command-line/repair.d.ts +0 -4
  82. package/src/command-line/repair.js +0 -7
  83. package/src/command-line/run-many.d.ts +0 -4
  84. package/src/command-line/run-many.js +0 -7
  85. package/src/command-line/run-one.d.ts +0 -4
  86. package/src/command-line/run-one.js +0 -7
  87. package/src/command-line/run.d.ts +0 -4
  88. package/src/command-line/run.js +0 -7
  89. package/src/command-line/watch.d.ts +0 -4
  90. package/src/command-line/watch.js +0 -7
  91. package/src/config/workspaces.d.ts +0 -18
  92. package/src/config/workspaces.js +0 -35
  93. package/src/core/graph/3rdpartylicenses.txt +0 -785
  94. package/src/migrations/update-15-1-0/set-project-names.d.ts +0 -2
  95. package/src/migrations/update-15-1-0/set-project-names.js +0 -34
  96. package/src/migrations/update-15-8-2/update-nxw.d.ts +0 -2
  97. package/src/migrations/update-15-8-2/update-nxw.js +0 -7
  98. package/src/utils/typescript.d.ts +0 -1
  99. package/src/utils/typescript.js +0 -5
@@ -140,7 +140,7 @@ async function invokeTasksRunner({ tasks, projectGraph, taskGraph, lifeCycle, nx
140
140
  title: `TaskGraph is now required as an argument to hashTask`,
141
141
  bodyLines: [
142
142
  `The TaskGraph object can be retrieved from the context`,
143
- 'This will result in an error in Nx 19',
143
+ 'This will result in an error in Nx 20',
144
144
  ],
145
145
  });
146
146
  taskGraph_ = taskGraph;
@@ -150,7 +150,7 @@ async function invokeTasksRunner({ tasks, projectGraph, taskGraph, lifeCycle, nx
150
150
  title: `The environment variables are now required as an argument to hashTask`,
151
151
  bodyLines: [
152
152
  `Please pass the environment variables used when running the task`,
153
- 'This will result in an error in Nx 19',
153
+ 'This will result in an error in Nx 20',
154
154
  ],
155
155
  });
156
156
  env = process.env;
@@ -163,7 +163,7 @@ async function invokeTasksRunner({ tasks, projectGraph, taskGraph, lifeCycle, nx
163
163
  title: `TaskGraph is now required as an argument to hashTasks`,
164
164
  bodyLines: [
165
165
  `The TaskGraph object can be retrieved from the context`,
166
- 'This will result in an error in Nx 19',
166
+ 'This will result in an error in Nx 20',
167
167
  ],
168
168
  });
169
169
  taskGraph_ = taskGraph;
@@ -173,7 +173,7 @@ async function invokeTasksRunner({ tasks, projectGraph, taskGraph, lifeCycle, nx
173
173
  title: `The environment variables are now required as an argument to hashTasks`,
174
174
  bodyLines: [
175
175
  `Please pass the environment variables used when running the tasks`,
176
- 'This will result in an error in Nx 19',
176
+ 'This will result in an error in Nx 20',
177
177
  ],
178
178
  });
179
179
  env = process.env;
@@ -78,7 +78,24 @@ class InvalidOutputsError extends Error {
78
78
  return `The following outputs are invalid:${invalidOutputsList}\nPlease run "nx repair" to repair your configuration`;
79
79
  }
80
80
  }
81
+ function assertOutputsAreValidType(outputs) {
82
+ if (!Array.isArray(outputs)) {
83
+ throw new Error("The 'outputs' field must be an array");
84
+ }
85
+ const typesArray = [];
86
+ let hasInvalidType = false;
87
+ for (const output of outputs) {
88
+ if (typeof output !== 'string') {
89
+ hasInvalidType = true;
90
+ }
91
+ typesArray.push(typeof output);
92
+ }
93
+ if (hasInvalidType) {
94
+ throw new Error(`The 'outputs' field must contain only strings, but received types: [${typesArray.join(', ')}]`);
95
+ }
96
+ }
81
97
  function validateOutputs(outputs) {
98
+ assertOutputsAreValidType(outputs);
82
99
  const invalidOutputs = new Set();
83
100
  for (const output of outputs) {
84
101
  if (!/^!?{[\s\S]+}/.test(output)) {
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.assertWorkspaceValidity = void 0;
4
4
  const find_matching_projects_1 = require("./find-matching-projects");
5
5
  const output_1 = require("./output");
6
+ const devkit_internals_1 = require("../devkit-internals");
6
7
  function assertWorkspaceValidity(projects, nxJson) {
7
8
  const projectNames = Object.keys(projects);
8
9
  const projectGraphNodes = projectNames.reduce((graph, project) => {
@@ -67,7 +68,7 @@ function assertWorkspaceValidity(projects, nxJson) {
67
68
  })
68
69
  .join('\n\n');
69
70
  }
70
- throw new Error(`Configuration Error\n${message}`);
71
+ throw new devkit_internals_1.WorkspaceValidityError(message);
71
72
  }
72
73
  exports.assertWorkspaceValidity = assertWorkspaceValidity;
73
74
  function detectAndSetInvalidProjectGlobValues(map, sourceName, desiredImplicitDeps, projectConfigurations, projects) {
@@ -30,7 +30,7 @@ export interface NxArgs {
30
30
  type?: string;
31
31
  batch?: boolean;
32
32
  }
33
- export declare function createOverrides(__overrides_unparsed__?: string[]): any;
33
+ export declare function createOverrides(__overrides_unparsed__?: string[]): Record<string, any>;
34
34
  export declare function splitArgsIntoNxArgsAndOverrides(args: {
35
35
  [k: string]: any;
36
36
  }, mode: 'run-one' | 'run-many' | 'affected' | 'print-affected', options: {
@@ -26,6 +26,6 @@ export type NxPluginV1 = {
26
26
  projectFilePatterns?: string[];
27
27
  };
28
28
  /**
29
- * @todo(@agentender) v19: Remove this fn when we remove readWorkspaceConfig
29
+ * @todo(@agentender) v20: Remove this fn when we remove readWorkspaceConfig
30
30
  */
31
31
  export declare function getDefaultPluginsSync(root: string): NxPluginV2[];
@@ -6,7 +6,7 @@ const project_json_1 = require("../plugins/project-json/build-nodes/project-json
6
6
  const target_defaults_plugin_1 = require("../plugins/target-defaults/target-defaults-plugin");
7
7
  const PackageJsonWorkspacesPlugin = require("../plugins/package-json-workspaces");
8
8
  /**
9
- * @todo(@agentender) v19: Remove this fn when we remove readWorkspaceConfig
9
+ * @todo(@agentender) v20: Remove this fn when we remove readWorkspaceConfig
10
10
  */
11
11
  function getDefaultPluginsSync(root) {
12
12
  const plugins = [
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getPromptsForSchema = exports.convertSmartDefaultsIntoNamedParams = exports.warnDeprecations = exports.combineOptionsForGenerator = exports.combineOptionsForExecutor = exports.applyVerbosity = exports.setDefaults = exports.validateObject = exports.validateOptsAgainstSchema = exports.SchemaError = exports.convertAliases = exports.coerceTypesInOptions = exports.convertToCamelCase = exports.handleErrors = void 0;
4
4
  const logger_1 = require("./logger");
5
5
  const output_1 = require("./output");
6
+ const client_1 = require("../daemon/client/client");
6
7
  const LIST_CHOICE_DISPLAY_LIMIT = 10;
7
8
  async function handleErrors(isVerbose, fn) {
8
9
  try {
@@ -41,6 +42,9 @@ async function handleErrors(isVerbose, fn) {
41
42
  logger_1.logger.info(err.stack);
42
43
  }
43
44
  }
45
+ if (client_1.daemonClient.enabled()) {
46
+ client_1.daemonClient.reset();
47
+ }
44
48
  return 1;
45
49
  }
46
50
  }
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const perf_hooks_1 = require("perf_hooks");
4
- if (process.env.NX_PERF_LOGGING === 'true') {
4
+ let initialized = false;
5
+ if (process.env.NX_PERF_LOGGING === 'true' && !initialized) {
6
+ initialized = true;
5
7
  const obs = new perf_hooks_1.PerformanceObserver((list) => {
6
8
  for (const entry of list.getEntries()) {
7
9
  console.log(`Time for '${entry.name}'`, entry.duration);
@@ -1,4 +0,0 @@
1
- /**
2
- * @deprecated(v17) This file has moved. The reexport will be removed in Nx 17.
3
- */
4
- export * from './repair/repair';
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- /**
5
- * @deprecated(v17) This file has moved. The reexport will be removed in Nx 17.
6
- */
7
- tslib_1.__exportStar(require("./repair/repair"), exports);
@@ -1,4 +0,0 @@
1
- /**
2
- * @deprecated(v17) This file has moved. The reexport will be removed in Nx 17.
3
- */
4
- export * from './run-many/run-many';
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- /**
5
- * @deprecated(v17) This file has moved. The reexport will be removed in Nx 17.
6
- */
7
- tslib_1.__exportStar(require("./run-many/run-many"), exports);
@@ -1,4 +0,0 @@
1
- /**
2
- * @deprecated(v17) This file has moved. The reexport will be removed in Nx 17.
3
- */
4
- export * from './run/run-one';
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- /**
5
- * @deprecated(v17) This file has moved. The reexport will be removed in Nx 17.
6
- */
7
- tslib_1.__exportStar(require("./run/run-one"), exports);
@@ -1,4 +0,0 @@
1
- /**
2
- * @deprecated(v17) This file has moved. The reexport will be removed in Nx 17.
3
- */
4
- export * from './run/run';
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- /**
5
- * @deprecated(v17) This file has moved. The reexport will be removed in Nx 17.
6
- */
7
- tslib_1.__exportStar(require("./run/run"), exports);
@@ -1,4 +0,0 @@
1
- /**
2
- * @deprecated(v17) This file has moved. The reexport will be removed in Nx 17.
3
- */
4
- export * from './watch/watch';
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- /**
5
- * @deprecated(v17) This file has moved. The reexport will be removed in Nx 17.
6
- */
7
- tslib_1.__exportStar(require("./watch/watch"), exports);
@@ -1,18 +0,0 @@
1
- import type { NxJsonConfiguration } from './nx-json';
2
- import { ProjectsConfigurations } from './workspace-json-project-json';
3
- /**
4
- * @deprecated This will be removed in v19. Use {@link readProjectsConfigurationFromProjectGraph} instead.
5
- */
6
- export declare class Workspaces {
7
- private root;
8
- constructor(root: string);
9
- /**
10
- * @deprecated Use {@link readProjectsConfigurationFromProjectGraph} instead.
11
- */
12
- readWorkspaceConfiguration(): ProjectsConfigurations & NxJsonConfiguration;
13
- }
14
- /**
15
- * Pulled from toFileName in names from @nx/devkit.
16
- * Todo: Should refactor, not duplicate.
17
- */
18
- export declare function toProjectName(fileName: string): string;
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toProjectName = exports.Workspaces = void 0;
4
- const path_1 = require("path");
5
- const project_graph_1 = require("../project-graph/project-graph");
6
- const nx_json_1 = require("./nx-json");
7
- // TODO(v19): remove this class
8
- /**
9
- * @deprecated This will be removed in v19. Use {@link readProjectsConfigurationFromProjectGraph} instead.
10
- */
11
- class Workspaces {
12
- constructor(root) {
13
- this.root = root;
14
- }
15
- /**
16
- * @deprecated Use {@link readProjectsConfigurationFromProjectGraph} instead.
17
- */
18
- readWorkspaceConfiguration() {
19
- const nxJson = (0, nx_json_1.readNxJson)(this.root);
20
- return {
21
- ...(0, project_graph_1.readProjectsConfigurationFromProjectGraph)((0, project_graph_1.readCachedProjectGraph)()),
22
- ...nxJson,
23
- };
24
- }
25
- }
26
- exports.Workspaces = Workspaces;
27
- /**
28
- * Pulled from toFileName in names from @nx/devkit.
29
- * Todo: Should refactor, not duplicate.
30
- */
31
- function toProjectName(fileName) {
32
- const parts = (0, path_1.dirname)(fileName).split(/[\/\\]/g);
33
- return parts[parts.length - 1].toLowerCase();
34
- }
35
- exports.toProjectName = toProjectName;