nx 18.3.0-beta.0 → 18.3.0-beta.1

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 (81) hide show
  1. package/bin/post-install.js +7 -5
  2. package/package.json +12 -12
  3. package/src/adapter/angular-json.d.ts +2 -1
  4. package/src/adapter/angular-json.js +1 -0
  5. package/src/adapter/ngcli-adapter.js +3 -3
  6. package/src/command-line/generate/generator-utils.js +2 -2
  7. package/src/command-line/init/implementation/react/index.js +1 -1
  8. package/src/command-line/run/executor-utils.js +2 -2
  9. package/src/config/nx-json.d.ts +2 -1
  10. package/src/config/schema-utils.js +2 -2
  11. package/src/daemon/server/plugins.d.ts +3 -0
  12. package/src/daemon/server/plugins.js +22 -0
  13. package/src/daemon/server/project-graph-incremental-recomputation.js +11 -10
  14. package/src/daemon/server/shutdown-utils.js +2 -0
  15. package/src/devkit-exports.d.ts +3 -2
  16. package/src/executors/run-commands/run-commands.impl.d.ts +4 -1
  17. package/src/executors/run-commands/run-commands.impl.js +51 -4
  18. package/src/executors/utils/convert-nx-executor.js +4 -1
  19. package/src/generators/utils/project-configuration.js +2 -2
  20. package/src/migrations/update-15-1-0/set-project-names.js +4 -2
  21. package/src/native/assert-supported-platform.js +1 -1
  22. package/src/plugins/js/index.d.ts +1 -1
  23. package/src/plugins/js/lock-file/lock-file.d.ts +1 -1
  24. package/src/plugins/js/lock-file/npm-parser.d.ts +1 -1
  25. package/src/plugins/js/lock-file/pnpm-parser.d.ts +1 -1
  26. package/src/plugins/js/lock-file/yarn-parser.d.ts +1 -1
  27. package/src/plugins/js/project-graph/build-dependencies/build-dependencies.d.ts +1 -1
  28. package/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.d.ts +1 -1
  29. package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.d.ts +1 -1
  30. package/src/plugins/package-json-workspaces/create-nodes.d.ts +2 -2
  31. package/src/plugins/package-json-workspaces/create-nodes.js +24 -31
  32. package/src/plugins/package-json-workspaces/index.d.ts +1 -0
  33. package/src/plugins/package-json-workspaces/index.js +2 -0
  34. package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.d.ts +2 -1
  35. package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.js +1 -0
  36. package/src/plugins/project-json/build-nodes/project-json.d.ts +2 -1
  37. package/src/plugins/project-json/build-nodes/project-json.js +1 -0
  38. package/src/plugins/target-defaults/symbols.d.ts +17 -0
  39. package/src/plugins/target-defaults/symbols.js +20 -0
  40. package/src/plugins/target-defaults/target-defaults-plugin.d.ts +2 -18
  41. package/src/plugins/target-defaults/target-defaults-plugin.js +5 -20
  42. package/src/project-graph/affected/locators/project-glob-changes.js +3 -3
  43. package/src/project-graph/build-project-graph.d.ts +2 -1
  44. package/src/project-graph/build-project-graph.js +11 -13
  45. package/src/project-graph/error-types.d.ts +34 -0
  46. package/src/project-graph/error-types.js +65 -0
  47. package/src/project-graph/file-utils.js +3 -3
  48. package/src/project-graph/plugins/index.d.ts +2 -0
  49. package/src/project-graph/plugins/index.js +8 -0
  50. package/src/project-graph/plugins/internal-api.d.ts +28 -0
  51. package/src/project-graph/plugins/internal-api.js +85 -0
  52. package/src/project-graph/plugins/isolation/index.d.ts +3 -0
  53. package/src/project-graph/plugins/isolation/index.js +16 -0
  54. package/src/project-graph/plugins/isolation/messaging.d.ts +94 -0
  55. package/src/project-graph/plugins/isolation/messaging.js +23 -0
  56. package/src/project-graph/plugins/isolation/plugin-pool.d.ts +3 -0
  57. package/src/project-graph/plugins/isolation/plugin-pool.js +189 -0
  58. package/src/project-graph/plugins/isolation/plugin-worker.d.ts +1 -0
  59. package/src/project-graph/plugins/isolation/plugin-worker.js +81 -0
  60. package/src/project-graph/plugins/loader.d.ts +24 -0
  61. package/src/project-graph/plugins/loader.js +206 -0
  62. package/src/{utils/nx-plugin.d.ts → project-graph/plugins/public-api.d.ts} +8 -44
  63. package/src/project-graph/plugins/public-api.js +4 -0
  64. package/src/project-graph/plugins/utils.d.ts +7 -0
  65. package/src/project-graph/plugins/utils.js +88 -0
  66. package/src/project-graph/project-graph-builder.d.ts +1 -1
  67. package/src/project-graph/project-graph.d.ts +3 -2
  68. package/src/project-graph/project-graph.js +9 -7
  69. package/src/project-graph/utils/normalize-project-nodes.d.ts +1 -1
  70. package/src/project-graph/utils/project-configuration-utils.d.ts +3 -26
  71. package/src/project-graph/utils/project-configuration-utils.js +29 -97
  72. package/src/project-graph/utils/retrieve-workspace-files.d.ts +11 -10
  73. package/src/project-graph/utils/retrieve-workspace-files.js +18 -21
  74. package/src/tasks-runner/cache.js +1 -1
  75. package/src/utils/logger.d.ts +1 -0
  76. package/src/utils/logger.js +5 -0
  77. package/src/utils/nx-plugin.deprecated.d.ts +2 -2
  78. package/src/utils/nx-plugin.deprecated.js +5 -7
  79. package/src/utils/plugins/plugin-capabilities.d.ts +1 -1
  80. package/src/utils/plugins/plugin-capabilities.js +18 -12
  81. package/src/utils/nx-plugin.js +0 -309
@@ -12,10 +12,10 @@ const nx_cloud_utils_1 = require("../src/utils/nx-cloud-utils");
12
12
  const nx_json_1 = require("../src/config/nx-json");
13
13
  const workspace_context_1 = require("../src/utils/workspace-context");
14
14
  (async () => {
15
+ const start = new Date();
15
16
  try {
16
17
  (0, workspace_context_1.setupWorkspaceContext)(workspace_root_1.workspaceRoot);
17
18
  if (isMainNxPackage() && (0, fileutils_1.fileExists)((0, path_1.join)(workspace_root_1.workspaceRoot, 'nx.json'))) {
18
- const b = new Date();
19
19
  (0, assert_supported_platform_1.assertSupportedPlatform)();
20
20
  try {
21
21
  await client_1.daemonClient.stop();
@@ -34,10 +34,6 @@ const workspace_context_1 = require("../src/utils/workspace-context");
34
34
  }
35
35
  });
36
36
  }));
37
- if (process.env.NX_VERBOSE_LOGGING === 'true') {
38
- const a = new Date();
39
- console.log(`Nx postinstall steps took ${a.getTime() - b.getTime()}ms`);
40
- }
41
37
  }
42
38
  }
43
39
  catch (e) {
@@ -45,6 +41,12 @@ const workspace_context_1 = require("../src/utils/workspace-context");
45
41
  console.log(e);
46
42
  }
47
43
  }
44
+ finally {
45
+ if (process.env.NX_VERBOSE_LOGGING === 'true') {
46
+ const end = new Date();
47
+ console.log(`Nx postinstall steps took ${end.getTime() - start.getTime()}ms`);
48
+ }
49
+ }
48
50
  })();
49
51
  function isMainNxPackage() {
50
52
  const mainNxPath = require.resolve('nx', {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "18.3.0-beta.0",
3
+ "version": "18.3.0-beta.1",
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.3.0-beta.0"
69
+ "@nrwl/tao": "18.3.0-beta.1"
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.3.0-beta.0",
85
- "@nx/nx-darwin-arm64": "18.3.0-beta.0",
86
- "@nx/nx-linux-x64-gnu": "18.3.0-beta.0",
87
- "@nx/nx-linux-x64-musl": "18.3.0-beta.0",
88
- "@nx/nx-win32-x64-msvc": "18.3.0-beta.0",
89
- "@nx/nx-linux-arm64-gnu": "18.3.0-beta.0",
90
- "@nx/nx-linux-arm64-musl": "18.3.0-beta.0",
91
- "@nx/nx-linux-arm-gnueabihf": "18.3.0-beta.0",
92
- "@nx/nx-win32-arm64-msvc": "18.3.0-beta.0",
93
- "@nx/nx-freebsd-x64": "18.3.0-beta.0"
84
+ "@nx/nx-darwin-x64": "18.3.0-beta.1",
85
+ "@nx/nx-darwin-arm64": "18.3.0-beta.1",
86
+ "@nx/nx-linux-x64-gnu": "18.3.0-beta.1",
87
+ "@nx/nx-linux-x64-musl": "18.3.0-beta.1",
88
+ "@nx/nx-win32-x64-msvc": "18.3.0-beta.1",
89
+ "@nx/nx-linux-arm64-gnu": "18.3.0-beta.1",
90
+ "@nx/nx-linux-arm64-musl": "18.3.0-beta.1",
91
+ "@nx/nx-linux-arm-gnueabihf": "18.3.0-beta.1",
92
+ "@nx/nx-win32-arm64-msvc": "18.3.0-beta.1",
93
+ "@nx/nx-freebsd-x64": "18.3.0-beta.1"
94
94
  },
95
95
  "nx-migrations": {
96
96
  "migrations": "./migrations.json",
@@ -1,7 +1,8 @@
1
1
  import { ProjectsConfigurations } from '../config/workspace-json-project-json';
2
- import { NxPluginV2 } from '../utils/nx-plugin';
2
+ import { NxPluginV2 } from '../project-graph/plugins';
3
3
  export declare const NX_ANGULAR_JSON_PLUGIN_NAME = "nx-angular-json-plugin";
4
4
  export declare const NxAngularJsonPlugin: NxPluginV2;
5
+ export default NxAngularJsonPlugin;
5
6
  export declare function shouldMergeAngularProjects(root: string, includeProjectsFromAngularJson: boolean): boolean;
6
7
  export declare function isAngularPluginInstalled(): boolean;
7
8
  export declare function toNewFormat(w: any): ProjectsConfigurations;
@@ -14,6 +14,7 @@ exports.NxAngularJsonPlugin = {
14
14
  }),
15
15
  ],
16
16
  };
17
+ exports.default = exports.NxAngularJsonPlugin;
17
18
  function shouldMergeAngularProjects(root, includeProjectsFromAngularJson) {
18
19
  if ((0, fs_1.existsSync)(path.join(root, 'angular.json')) &&
19
20
  // Include projects from angular.json if explicitly required.
@@ -19,7 +19,7 @@ const package_json_1 = require("../utils/package-json");
19
19
  const package_manager_1 = require("../utils/package-manager");
20
20
  const angular_json_1 = require("./angular-json");
21
21
  const executor_utils_1 = require("../command-line/run/executor-utils");
22
- const nx_plugin_1 = require("../utils/nx-plugin");
22
+ const plugins_1 = require("../project-graph/plugins");
23
23
  const schema_utils_1 = require("../config/schema-utils");
24
24
  async function createBuilderContext(builderInfo, context) {
25
25
  require('./compat');
@@ -146,7 +146,7 @@ function createNodeModulesEngineHost(resolvePaths, projects) {
146
146
  collectionFilePath = require.resolve(name, { paths });
147
147
  }
148
148
  else {
149
- const { json: { generators, schematics }, path: packageJsonPath, } = (0, nx_plugin_1.readPluginPackageJson)(name, projects, paths);
149
+ const { json: { generators, schematics }, path: packageJsonPath, } = (0, plugins_1.readPluginPackageJson)(name, projects, paths);
150
150
  if (!schematics && !generators) {
151
151
  throw new Error(`The "${name}" package does not support Nx generators or Angular Devkit schematics.`);
152
152
  }
@@ -802,7 +802,7 @@ async function getWrappedWorkspaceNodeModulesArchitectHost(workspace, root, proj
802
802
  };
803
803
  }
804
804
  readExecutorsJson(nodeModule, builder) {
805
- const { json: packageJson, path: packageJsonPath } = (0, nx_plugin_1.readPluginPackageJson)(nodeModule, this.projects, this.root ? [this.root, __dirname] : [__dirname]);
805
+ const { json: packageJson, path: packageJsonPath } = (0, plugins_1.readPluginPackageJson)(nodeModule, this.projects, this.root ? [this.root, __dirname] : [__dirname]);
806
806
  const executorsFile = packageJson.executors ?? packageJson.builders;
807
807
  if (!executorsFile) {
808
808
  throw new Error(`The "${nodeModule}" package does not support Nx executors or Angular Devkit Builders.`);
@@ -4,7 +4,7 @@ exports.readGeneratorsJson = exports.getGeneratorInformation = void 0;
4
4
  const path_1 = require("path");
5
5
  const schema_utils_1 = require("../../config/schema-utils");
6
6
  const fileutils_1 = require("../../utils/fileutils");
7
- const nx_plugin_1 = require("../../utils/nx-plugin");
7
+ const plugins_1 = require("../../project-graph/plugins");
8
8
  function getGeneratorInformation(collectionName, generatorName, root, projects) {
9
9
  try {
10
10
  const { generatorsFilePath, generatorsJson, resolvedCollectionName, normalizedGeneratorName, } = readGeneratorsJson(collectionName, generatorName, root, projects);
@@ -48,7 +48,7 @@ function readGeneratorsJson(collectionName, generator, root, projects) {
48
48
  });
49
49
  }
50
50
  else {
51
- const { json: packageJson, path: packageJsonPath } = (0, nx_plugin_1.readPluginPackageJson)(collectionName, projects, root ? [root, __dirname] : [__dirname]);
51
+ const { json: packageJson, path: packageJsonPath } = (0, plugins_1.readPluginPackageJson)(collectionName, projects, root ? [root, __dirname] : [__dirname]);
52
52
  const generatorsFile = packageJson.generators ?? packageJson.schematics;
53
53
  if (!generatorsFile) {
54
54
  throw new Error(`The "${collectionName}" package does not support Nx generators.`);
@@ -100,7 +100,7 @@ async function reorgnizeWorkspaceStructure(options) {
100
100
  ? `npx nx build ${options.reactAppName}`
101
101
  : 'npm run build';
102
102
  (0, utils_1.printFinalMessage)({
103
- learnMoreLink: 'https://nx.dev/recipes/react/migration-cra',
103
+ learnMoreLink: 'https://nx.dev/recipes/adopting-nx/adding-to-existing-project',
104
104
  bodyLines: [
105
105
  `- Execute "${buildCommand}" twice to see the computation caching in action.`,
106
106
  ],
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getExecutorInformation = exports.normalizeExecutorSchema = void 0;
4
4
  const path_1 = require("path");
5
- const nx_plugin_1 = require("../../utils/nx-plugin");
5
+ const plugins_1 = require("../../project-graph/plugins");
6
6
  const fileutils_1 = require("../../utils/fileutils");
7
7
  const schema_utils_1 = require("../../config/schema-utils");
8
8
  const installation_directory_1 = require("../../utils/installation-directory");
@@ -55,7 +55,7 @@ function getExecutorInformation(nodeModule, executor, root, projects) {
55
55
  }
56
56
  exports.getExecutorInformation = getExecutorInformation;
57
57
  function readExecutorJson(nodeModule, executor, root, projects) {
58
- const { json: packageJson, path: packageJsonPath } = (0, nx_plugin_1.readPluginPackageJson)(nodeModule, projects, root
58
+ const { json: packageJson, path: packageJsonPath } = (0, plugins_1.readPluginPackageJson)(nodeModule, projects, root
59
59
  ? [root, __dirname, process.cwd(), ...(0, installation_directory_1.getNxRequirePaths)()]
60
60
  : [__dirname, process.cwd(), ...(0, installation_directory_1.getNxRequirePaths)()]);
61
61
  const executorsFile = packageJson.executors ?? packageJson.builders;
@@ -394,7 +394,8 @@ export interface NxJsonConfiguration<T = '*' | string[]> {
394
394
  */
395
395
  useInferencePlugins?: boolean;
396
396
  }
397
- export type PluginConfiguration = string | {
397
+ export type PluginConfiguration = string | ExpandedPluginConfiguration;
398
+ export type ExpandedPluginConfiguration = {
398
399
  plugin: string;
399
400
  options?: unknown;
400
401
  include?: string[];
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resolveSchema = exports.resolveImplementation = exports.getImplementationFactory = void 0;
4
4
  const fs_1 = require("fs");
5
5
  const path_1 = require("path");
6
- const nx_plugin_1 = require("../utils/nx-plugin");
6
+ const plugins_1 = require("../project-graph/plugins");
7
7
  /**
8
8
  * This function is used to get the implementation factory of an executor or generator.
9
9
  * @param implementation path to the implementation
@@ -15,7 +15,7 @@ function getImplementationFactory(implementation, directory) {
15
15
  return () => {
16
16
  const modulePath = resolveImplementation(implementationModulePath, directory);
17
17
  if ((0, path_1.extname)(modulePath) === '.ts') {
18
- (0, nx_plugin_1.registerPluginTSTranspiler)();
18
+ (0, plugins_1.registerPluginTSTranspiler)();
19
19
  }
20
20
  const module = require(modulePath);
21
21
  return implementationExportName
@@ -0,0 +1,3 @@
1
+ import { LoadedNxPlugin } from '../../project-graph/plugins/internal-api';
2
+ export declare function getPlugins(): Promise<LoadedNxPlugin[]>;
3
+ export declare function cleanupPlugins(): void;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cleanupPlugins = exports.getPlugins = void 0;
4
+ const nx_json_1 = require("../../config/nx-json");
5
+ const internal_api_1 = require("../../project-graph/plugins/internal-api");
6
+ const workspace_root_1 = require("../../utils/workspace-root");
7
+ let loadedPlugins;
8
+ let cleanup;
9
+ async function getPlugins() {
10
+ if (loadedPlugins) {
11
+ return loadedPlugins;
12
+ }
13
+ const pluginsConfiguration = (0, nx_json_1.readNxJson)().plugins ?? [];
14
+ const [result, cleanupFn] = await (0, internal_api_1.loadNxPlugins)(pluginsConfiguration, workspace_root_1.workspaceRoot);
15
+ cleanup = cleanupFn;
16
+ return result;
17
+ }
18
+ exports.getPlugins = getPlugins;
19
+ function cleanupPlugins() {
20
+ cleanup();
21
+ }
22
+ exports.cleanupPlugins = cleanupPlugins;
@@ -13,8 +13,9 @@ 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
16
  const daemon_project_graph_error_1 = require("../daemon-project-graph-error");
17
+ const plugins_1 = require("./plugins");
18
+ const error_types_1 = require("../../project-graph/error-types");
18
19
  let cachedSerializedProjectGraphPromise;
19
20
  const collectedUpdatedFiles = new Set();
20
21
  const collectedDeletedFiles = new Set();
@@ -32,15 +33,16 @@ async function getCachedSerializedProjectGraphPromise() {
32
33
  // reset the wait time
33
34
  waitPeriod = 100;
34
35
  await resetInternalStateIfNxDepsMissing();
36
+ const plugins = await (0, plugins_1.getPlugins)();
35
37
  if (collectedUpdatedFiles.size == 0 && collectedDeletedFiles.size == 0) {
36
38
  if (!cachedSerializedProjectGraphPromise) {
37
39
  cachedSerializedProjectGraphPromise =
38
- processFilesAndCreateAndSerializeProjectGraph();
40
+ processFilesAndCreateAndSerializeProjectGraph(plugins);
39
41
  }
40
42
  }
41
43
  else {
42
44
  cachedSerializedProjectGraphPromise =
43
- processFilesAndCreateAndSerializeProjectGraph();
45
+ processFilesAndCreateAndSerializeProjectGraph(plugins);
44
46
  }
45
47
  return await cachedSerializedProjectGraphPromise;
46
48
  }
@@ -80,7 +82,7 @@ function addUpdatedAndDeletedFiles(createdFiles, updatedFiles, deletedFiles) {
80
82
  waitPeriod = waitPeriod * 2;
81
83
  }
82
84
  cachedSerializedProjectGraphPromise =
83
- processFilesAndCreateAndSerializeProjectGraph();
85
+ processFilesAndCreateAndSerializeProjectGraph(await (0, plugins_1.getPlugins)());
84
86
  await cachedSerializedProjectGraphPromise;
85
87
  if (createdFiles.length > 0) {
86
88
  (0, file_watcher_sockets_1.notifyFileWatcherSockets)(createdFiles, null, null);
@@ -128,7 +130,7 @@ async function processCollectedUpdatedAndDeletedFiles({ projects, externalNodes,
128
130
  throw e;
129
131
  }
130
132
  }
131
- async function processFilesAndCreateAndSerializeProjectGraph() {
133
+ async function processFilesAndCreateAndSerializeProjectGraph(plugins) {
132
134
  try {
133
135
  perf_hooks_1.performance.mark('hash-watched-changes-start');
134
136
  const updatedFiles = [...collectedUpdatedFiles.values()];
@@ -140,15 +142,14 @@ async function processFilesAndCreateAndSerializeProjectGraph() {
140
142
  logger_1.serverLogger.requestLog([...updatedFiles.values()]);
141
143
  logger_1.serverLogger.requestLog([...deletedFiles]);
142
144
  const nxJson = (0, nx_json_1.readNxJson)(workspace_root_1.workspaceRoot);
143
- // Set this globally to allow plugins to know if they are being called from the project graph creation
144
145
  global.NX_GRAPH_CREATION = true;
145
146
  let graphNodes;
146
147
  let projectConfigurationsError;
147
148
  try {
148
- graphNodes = await (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(workspace_root_1.workspaceRoot, nxJson);
149
+ graphNodes = await (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(plugins, workspace_root_1.workspaceRoot, nxJson);
149
150
  }
150
151
  catch (e) {
151
- if (e instanceof project_configuration_utils_1.ProjectConfigurationsError) {
152
+ if (e instanceof error_types_1.ProjectConfigurationsError) {
152
153
  graphNodes = e.partialProjectConfigurationsResult;
153
154
  projectConfigurationsError = e;
154
155
  }
@@ -162,7 +163,7 @@ async function processFilesAndCreateAndSerializeProjectGraph() {
162
163
  const errors = [...(projectConfigurationsError?.errors ?? [])];
163
164
  if (g.error) {
164
165
  if (g.error instanceof build_project_graph_1.CreateDependenciesError) {
165
- errors.concat(g.error.errors);
166
+ errors.push(...g.error.errors);
166
167
  }
167
168
  else {
168
169
  return {
@@ -226,7 +227,7 @@ async function createAndSerializeProjectGraph({ projects, sourceMaps, }) {
226
227
  const fileMap = copyFileMap(exports.fileMapWithFiles.fileMap);
227
228
  const allWorkspaceFiles = copyFileData(exports.fileMapWithFiles.allWorkspaceFiles);
228
229
  const rustReferences = exports.fileMapWithFiles.rustReferences;
229
- const { projectGraph, projectFileMapCache } = await (0, build_project_graph_1.buildProjectGraphUsingProjectFileMap)(projects, knownExternalNodes, fileMap, allWorkspaceFiles, rustReferences, exports.currentProjectFileMapCache || (0, nx_deps_cache_1.readFileMapCache)());
230
+ const { projectGraph, projectFileMapCache } = await (0, build_project_graph_1.buildProjectGraphUsingProjectFileMap)(projects, knownExternalNodes, fileMap, allWorkspaceFiles, rustReferences, exports.currentProjectFileMapCache || (0, nx_deps_cache_1.readFileMapCache)(), await (0, plugins_1.getPlugins)());
230
231
  exports.currentProjectFileMapCache = projectFileMapCache;
231
232
  exports.currentProjectGraph = projectGraph;
232
233
  perf_hooks_1.performance.mark('create-project-graph-end');
@@ -5,6 +5,7 @@ const workspace_root_1 = require("../../utils/workspace-root");
5
5
  const logger_1 = require("./logger");
6
6
  const socket_utils_1 = require("../socket-utils");
7
7
  const cache_1 = require("../cache");
8
+ const plugins_1 = require("./plugins");
8
9
  exports.SERVER_INACTIVITY_TIMEOUT_MS = 10800000; // 10800000 ms = 3 hours
9
10
  let watcherInstance;
10
11
  function storeWatcherInstance(instance) {
@@ -28,6 +29,7 @@ async function handleServerProcessTermination({ server, reason, }) {
28
29
  try {
29
30
  server.close();
30
31
  (0, cache_1.deleteDaemonJsonProcessCache)();
32
+ (0, plugins_1.cleanupPlugins)();
31
33
  if (watcherInstance) {
32
34
  await watcherInstance.stop();
33
35
  logger_1.serverLogger.watcherLog(`Stopping the watcher for ${workspace_root_1.workspaceRoot} (sources)`);
@@ -19,7 +19,8 @@ export type { Generator, GeneratorCallback, Executor, ExecutorContext, TaskGraph
19
19
  */
20
20
  export { Workspaces } from './config/workspaces';
21
21
  export { workspaceLayout } from './config/configuration';
22
- export type { NxPlugin, NxPluginV1, NxPluginV2, ProjectTargetConfigurator, CreateNodes, CreateNodesFunction, CreateNodesResult, CreateNodesContext, CreateDependencies, CreateDependenciesContext, } from './utils/nx-plugin';
22
+ export type { NxPlugin, NxPluginV2, CreateNodes, CreateNodesFunction, CreateNodesResult, CreateNodesContext, CreateDependencies, CreateDependenciesContext, } from './project-graph/plugins';
23
+ export type { NxPluginV1, ProjectTargetConfigurator, } from './utils/nx-plugin.deprecated';
23
24
  /**
24
25
  * @category Workspace
25
26
  */
@@ -27,7 +28,7 @@ export type { Task, TaskGraph } from './config/task-graph';
27
28
  /**
28
29
  * @category Workspace
29
30
  */
30
- export type { ImplicitDependencyEntry, ImplicitJsonSubsetDependency, NxJsonConfiguration, PluginConfiguration, TargetDefaults, NxAffectedConfig, } from './config/nx-json';
31
+ export type { ImplicitDependencyEntry, ImplicitJsonSubsetDependency, NxJsonConfiguration, PluginConfiguration, ExpandedPluginConfiguration, TargetDefaults, NxAffectedConfig, } from './config/nx-json';
31
32
  /**
32
33
  * @category Logger
33
34
  */
@@ -39,10 +39,13 @@ export interface NormalizedRunCommandsOptions extends RunCommandsOptions {
39
39
  parsedArgs: {
40
40
  [k: string]: any;
41
41
  };
42
+ unparsedCommandArgs?: {
43
+ [k: string]: string;
44
+ };
42
45
  args?: string;
43
46
  }
44
47
  export default function (options: RunCommandsOptions, context: ExecutorContext): Promise<{
45
48
  success: boolean;
46
49
  terminalOutput: string;
47
50
  }>;
48
- export declare function interpolateArgsIntoCommand(command: string, opts: Pick<NormalizedRunCommandsOptions, 'args' | 'parsedArgs' | '__unparsed__' | 'unknownOptions'>, forwardAllArgs: boolean): string;
51
+ export declare function interpolateArgsIntoCommand(command: string, opts: Pick<NormalizedRunCommandsOptions, 'args' | 'parsedArgs' | '__unparsed__' | 'unknownOptions' | 'unparsedCommandArgs'>, forwardAllArgs: boolean): string;
@@ -129,6 +129,7 @@ function normalizeOptions(options) {
129
129
  .filter((p) => propKeys.indexOf(p) === -1 && unparsedCommandArgs[p] === undefined)
130
130
  .reduce((m, c) => ((m[c] = options[c]), m), {});
131
131
  options.parsedArgs = parseArgs(unparsedCommandArgs, options.unknownOptions, options.args);
132
+ options.unparsedCommandArgs = unparsedCommandArgs;
132
133
  options.commands.forEach((c) => {
133
134
  c.command = interpolateArgsIntoCommand(c.command, options, c.forwardAllArgs ?? true);
134
135
  });
@@ -162,12 +163,15 @@ async function createProcess(pseudoTerminal, commandConfig, readyWhen, color, cw
162
163
  !commandConfig.prefix &&
163
164
  !isParallel &&
164
165
  usePty) {
166
+ let terminalOutput = chalk.dim('> ') + commandConfig.command + '\r\n\r\n';
167
+ if (streamOutput) {
168
+ process.stdout.write(terminalOutput);
169
+ }
165
170
  const cp = pseudoTerminal.runCommand(commandConfig.command, {
166
171
  cwd,
167
172
  jsEnv: env,
168
173
  quiet: !streamOutput,
169
174
  });
170
- let terminalOutput = '';
171
175
  return new Promise((res) => {
172
176
  cp.onOutput((output) => {
173
177
  terminalOutput += output;
@@ -188,7 +192,10 @@ async function createProcess(pseudoTerminal, commandConfig, readyWhen, color, cw
188
192
  return nodeProcess(commandConfig, cwd, env, readyWhen, streamOutput);
189
193
  }
190
194
  function nodeProcess(commandConfig, cwd, env, readyWhen, streamOutput = true) {
191
- let terminalOutput = '';
195
+ let terminalOutput = chalk.dim('> ') + commandConfig.command + '\r\n\r\n';
196
+ if (streamOutput) {
197
+ process.stdout.write(terminalOutput);
198
+ }
192
199
  return new Promise((res) => {
193
200
  const childProcess = (0, child_process_1.exec)(commandConfig.command, {
194
201
  maxBuffer: exports.LARGE_BUFFER,
@@ -290,14 +297,17 @@ function interpolateArgsIntoCommand(command, opts, forwardAllArgs) {
290
297
  Object.keys(opts.unknownOptions)
291
298
  .filter((k) => typeof opts.unknownOptions[k] !== 'object' &&
292
299
  opts.parsedArgs[k] === opts.unknownOptions[k])
293
- .map((k) => `--${k} ${opts.unknownOptions[k]}`)
300
+ .map((k) => `--${k}=${opts.unknownOptions[k]}`)
294
301
  .join(' ');
295
302
  }
296
303
  if (opts.args) {
297
304
  args += ` ${opts.args}`;
298
305
  }
299
306
  if (opts.__unparsed__?.length > 0) {
300
- args += ` ${opts.__unparsed__.join(' ')}`;
307
+ const filterdParsedOptions = filterPropKeysFromUnParsedOptions(opts.__unparsed__, opts.unparsedCommandArgs);
308
+ if (filterdParsedOptions.length > 0) {
309
+ args += ` ${filterdParsedOptions.join(' ')}`;
310
+ }
301
311
  }
302
312
  return `${command}${args}`;
303
313
  }
@@ -314,3 +324,40 @@ function parseArgs(unparsedCommandArgs, unknownOptions, args) {
314
324
  configuration: { 'camel-case-expansion': false },
315
325
  });
316
326
  }
327
+ /**
328
+ * This function filters out the prop keys from the unparsed options
329
+ * @param __unparsed__ e.g. ['--prop1', 'value1', '--prop2=value2', '--args=test']
330
+ * @param unparsedCommandArgs e.g. { prop1: 'value1', prop2: 'value2', args: 'test'}
331
+ * @returns filtered options that are not part of the propKeys array e.g. ['--prop1', 'value1', '--prop2=value2']
332
+ */
333
+ function filterPropKeysFromUnParsedOptions(__unparsed__, unparsedCommandArgs = {}) {
334
+ const parsedOptions = [];
335
+ for (let index = 0; index < __unparsed__.length; index++) {
336
+ const element = __unparsed__[index];
337
+ if (element.startsWith('--')) {
338
+ const key = element.replace('--', '');
339
+ if (element.includes('=')) {
340
+ if (!propKeys.includes(key.split('=')[0].split('.')[0])) {
341
+ // check if the key is part of the propKeys array
342
+ parsedOptions.push(element);
343
+ }
344
+ }
345
+ else {
346
+ // check if the next element is a value for the key
347
+ if (propKeys.includes(key)) {
348
+ if (index + 1 < __unparsed__.length &&
349
+ __unparsed__[index + 1] === unparsedCommandArgs[key]) {
350
+ index++; // skip the next element
351
+ }
352
+ }
353
+ else {
354
+ parsedOptions.push(element);
355
+ }
356
+ }
357
+ }
358
+ else {
359
+ parsedOptions.push(element);
360
+ }
361
+ }
362
+ return parsedOptions;
363
+ }
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.convertNxExecutor = void 0;
7
7
  const nx_json_1 = require("../../config/nx-json");
8
8
  const retrieve_workspace_files_1 = require("../../project-graph/utils/retrieve-workspace-files");
9
+ const internal_api_1 = require("../../project-graph/plugins/internal-api");
9
10
  /**
10
11
  * Convert an Nx Executor into an Angular Devkit Builder
11
12
  *
@@ -15,10 +16,12 @@ function convertNxExecutor(executor) {
15
16
  const builderFunction = (options, builderContext) => {
16
17
  const promise = async () => {
17
18
  const nxJsonConfiguration = (0, nx_json_1.readNxJson)(builderContext.workspaceRoot);
19
+ const [plugins, cleanup] = await (0, internal_api_1.loadNxPlugins)(nxJsonConfiguration.plugins, builderContext.workspaceRoot);
18
20
  const projectsConfigurations = {
19
21
  version: 2,
20
- projects: (await (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(builderContext.workspaceRoot, nxJsonConfiguration)).projects,
22
+ projects: (await (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(plugins, builderContext.workspaceRoot, nxJsonConfiguration)).projects,
21
23
  };
24
+ cleanup();
22
25
  const context = {
23
26
  root: builderContext.workspaceRoot,
24
27
  projectName: builderContext.target.project,
@@ -136,8 +136,8 @@ function readAndCombineAllProjectConfigurations(tree) {
136
136
  ...(0, package_json_workspaces_1.getGlobPatternsFromPackageManagerWorkspaces)(tree.root, (p) => (0, json_1.readJson)(tree, p, { expectComments: true })),
137
137
  ];
138
138
  const projectGlobPatterns = (0, retrieve_workspace_files_1.configurationGlobs)([
139
- { plugin: project_json_1.ProjectJsonProjectsPlugin },
140
- { plugin: (0, package_json_workspaces_1.getNxPackageJsonWorkspacesPlugin)(tree.root) },
139
+ project_json_1.ProjectJsonProjectsPlugin,
140
+ { createNodes: package_json_workspaces_1.createNodes },
141
141
  ]);
142
142
  const globbedFiles = (0, workspace_context_1.globWithWorkspaceContext)(tree.root, projectGlobPatterns);
143
143
  const createdFiles = findCreatedProjectFiles(tree, patterns);
@@ -5,10 +5,11 @@ const path_1 = require("path");
5
5
  const json_1 = require("../../generators/utils/json");
6
6
  const format_changed_files_with_prettier_if_available_1 = require("../../generators/internal-utils/format-changed-files-with-prettier-if-available");
7
7
  const retrieve_workspace_files_1 = require("../../project-graph/utils/retrieve-workspace-files");
8
- const nx_plugin_1 = require("../../utils/nx-plugin");
8
+ const internal_api_1 = require("../../project-graph/plugins/internal-api");
9
9
  async function default_1(tree) {
10
10
  const nxJson = (0, nx_json_1.readNxJson)(tree);
11
- const projectFiles = await (0, retrieve_workspace_files_1.retrieveProjectConfigurationPaths)(tree.root, await (0, nx_plugin_1.loadNxPlugins)(nxJson?.plugins));
11
+ const [plugins, cleanup] = await (0, internal_api_1.loadNxPlugins)(nxJson?.plugins ?? [], tree.root);
12
+ const projectFiles = (0, retrieve_workspace_files_1.retrieveProjectConfigurationPaths)(tree.root, plugins);
12
13
  const projectJsons = projectFiles.filter((f) => f.endsWith('project.json'));
13
14
  for (let f of projectJsons) {
14
15
  const projectJson = (0, json_1.readJson)(tree, f);
@@ -18,6 +19,7 @@ async function default_1(tree) {
18
19
  }
19
20
  }
20
21
  await (0, format_changed_files_with_prettier_if_available_1.formatChangedFilesWithPrettierIfAvailable)(tree);
22
+ cleanup();
21
23
  }
22
24
  exports.default = default_1;
23
25
  function toProjectName(directory, nxJson) {
@@ -28,7 +28,7 @@ function assertSupportedPlatform() {
28
28
  `This platform (${process.platform}-${process.arch}) is currently not supported by Nx.`,
29
29
  ];
30
30
  }
31
- bodyLines.push('For more information please see https://nx.dev/recipes/troubleshooting/troubleshoot-nx-install-issues');
31
+ bodyLines.push('For more information please see https://nx.dev/troubleshooting/troubleshoot-nx-install-issues');
32
32
  output_1.output.error({
33
33
  title,
34
34
  bodyLines,
@@ -1,4 +1,4 @@
1
- import { CreateDependencies, CreateNodes } from '../../utils/nx-plugin';
1
+ import { CreateDependencies, CreateNodes } from '../../project-graph/plugins';
2
2
  export declare const name = "nx/js/dependencies-and-lockfile";
3
3
  export declare const createNodes: CreateNodes;
4
4
  export declare const createDependencies: CreateDependencies;
@@ -6,7 +6,7 @@ import { PackageManager } from '../../../utils/package-manager';
6
6
  import { ProjectGraph, ProjectGraphExternalNode } from '../../../config/project-graph';
7
7
  import { RawProjectGraphDependency } from '../../../project-graph/project-graph-builder';
8
8
  import { PackageJson } from '../../../utils/package-json';
9
- import { CreateDependenciesContext, CreateNodesContext } from '../../../utils/nx-plugin';
9
+ import { CreateDependenciesContext, CreateNodesContext } from '../../../project-graph/plugins';
10
10
  export declare const LOCKFILES: string[];
11
11
  /**
12
12
  * Parses lock file and maps dependencies and metadata to {@link LockFileGraph}
@@ -1,7 +1,7 @@
1
1
  import { NormalizedPackageJson } from './utils/package-json';
2
2
  import { RawProjectGraphDependency } from '../../../project-graph/project-graph-builder';
3
3
  import { ProjectGraph, ProjectGraphExternalNode } from '../../../config/project-graph';
4
- import { CreateDependenciesContext } from '../../../utils/nx-plugin';
4
+ import { CreateDependenciesContext } from '../../../project-graph/plugins';
5
5
  export declare function getNpmLockfileNodes(lockFileContent: string, lockFileHash: string): Record<string, ProjectGraphExternalNode>;
6
6
  export declare function getNpmLockfileDependencies(lockFileContent: string, lockFileHash: string, ctx: CreateDependenciesContext): RawProjectGraphDependency[];
7
7
  export declare function stringifyNpmLockfile(graph: ProjectGraph, rootLockFileContent: string, packageJson: NormalizedPackageJson): string;
@@ -1,7 +1,7 @@
1
1
  import { NormalizedPackageJson } from './utils/package-json';
2
2
  import { RawProjectGraphDependency } from '../../../project-graph/project-graph-builder';
3
3
  import { ProjectGraph, ProjectGraphExternalNode } from '../../../config/project-graph';
4
- import { CreateDependenciesContext } from '../../../utils/nx-plugin';
4
+ import { CreateDependenciesContext } from '../../../project-graph/plugins';
5
5
  export declare function getPnpmLockfileNodes(lockFileContent: string, lockFileHash: string): Record<string, ProjectGraphExternalNode>;
6
6
  export declare function getPnpmLockfileDependencies(lockFileContent: string, lockFileHash: string, ctx: CreateDependenciesContext): RawProjectGraphDependency[];
7
7
  export declare function stringifyPnpmLockfile(graph: ProjectGraph, rootLockFileContent: string, packageJson: NormalizedPackageJson): string;
@@ -1,7 +1,7 @@
1
1
  import { NormalizedPackageJson } from './utils/package-json';
2
2
  import { RawProjectGraphDependency } from '../../../project-graph/project-graph-builder';
3
3
  import { ProjectGraph, ProjectGraphExternalNode } from '../../../config/project-graph';
4
- import { CreateDependenciesContext } from '../../../utils/nx-plugin';
4
+ import { CreateDependenciesContext } from '../../../project-graph/plugins';
5
5
  export declare function getYarnLockfileNodes(lockFileContent: string, lockFileHash: string, packageJson: NormalizedPackageJson): Record<string, ProjectGraphExternalNode>;
6
6
  export declare function getYarnLockfileDependencies(lockFileContent: string, lockFileHash: string, ctx: CreateDependenciesContext): RawProjectGraphDependency[];
7
7
  export declare function stringifyYarnLockfile(graph: ProjectGraph, rootLockFileContent: string, packageJson: NormalizedPackageJson): string;
@@ -1,4 +1,4 @@
1
- import { CreateDependenciesContext } from '../../../../utils/nx-plugin';
1
+ import { CreateDependenciesContext } from '../../../../project-graph/plugins';
2
2
  import { RawProjectGraphDependency } from '../../../../project-graph/project-graph-builder';
3
3
  export declare function buildExplicitDependencies(jsPluginConfig: {
4
4
  analyzeSourceFiles?: boolean;
@@ -1,3 +1,3 @@
1
- import { CreateDependenciesContext } from '../../../../utils/nx-plugin';
1
+ import { CreateDependenciesContext } from '../../../../project-graph/plugins';
2
2
  import { RawProjectGraphDependency } from '../../../../project-graph/project-graph-builder';
3
3
  export declare function buildExplicitPackageJsonDependencies(ctx: CreateDependenciesContext): RawProjectGraphDependency[];
@@ -1,3 +1,3 @@
1
- import { CreateDependenciesContext } from '../../../../utils/nx-plugin';
1
+ import { CreateDependenciesContext } from '../../../../project-graph/plugins';
2
2
  import { RawProjectGraphDependency } from '../../../../project-graph/project-graph-builder';
3
3
  export declare function buildExplicitTypeScriptDependencies(ctx: CreateDependenciesContext): RawProjectGraphDependency[];
@@ -1,8 +1,8 @@
1
1
  import { NxJsonConfiguration } from '../../config/nx-json';
2
2
  import { ProjectConfiguration } from '../../config/workspace-json-project-json';
3
- import { NxPluginV2 } from '../../utils/nx-plugin';
4
3
  import { PackageJson } from '../../utils/package-json';
5
- export declare function getNxPackageJsonWorkspacesPlugin(root: string): NxPluginV2;
4
+ import { CreateNodes } from '../../project-graph/plugins';
5
+ export declare const createNodes: CreateNodes;
6
6
  export declare function createNodeFromPackageJson(pkgJsonPath: string, root: string): {
7
7
  projects: {
8
8
  [x: string]: ProjectConfiguration & {