nx 18.1.0-canary.20240223-21e7648 → 18.1.0-canary.20240227-452d845

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 (64) hide show
  1. package/package.json +12 -12
  2. package/src/adapter/angular-json.d.ts +2 -1
  3. package/src/adapter/angular-json.js +1 -0
  4. package/src/adapter/ngcli-adapter.js +3 -3
  5. package/src/command-line/generate/generator-utils.js +2 -2
  6. package/src/command-line/init/init-v2.js +17 -11
  7. package/src/command-line/migrate/migrate.js +3 -1
  8. package/src/command-line/run/executor-utils.js +2 -2
  9. package/src/config/schema-utils.js +2 -2
  10. package/src/devkit-exports.d.ts +2 -1
  11. package/src/devkit-internals.d.ts +1 -0
  12. package/src/devkit-internals.js +3 -1
  13. package/src/generators/utils/project-configuration.js +2 -2
  14. package/src/migrations/update-15-1-0/set-project-names.js +2 -2
  15. package/src/plugins/js/index.d.ts +1 -1
  16. package/src/plugins/js/lock-file/lock-file.d.ts +1 -1
  17. package/src/plugins/js/lock-file/npm-parser.d.ts +1 -1
  18. package/src/plugins/js/lock-file/pnpm-parser.d.ts +1 -1
  19. package/src/plugins/js/lock-file/yarn-parser.d.ts +1 -1
  20. package/src/plugins/js/project-graph/build-dependencies/build-dependencies.d.ts +1 -1
  21. package/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.d.ts +1 -1
  22. package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.d.ts +1 -1
  23. package/src/plugins/package-json-workspaces/create-nodes.d.ts +2 -2
  24. package/src/plugins/package-json-workspaces/create-nodes.js +24 -31
  25. package/src/plugins/package-json-workspaces/index.d.ts +1 -0
  26. package/src/plugins/package-json-workspaces/index.js +2 -0
  27. package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.d.ts +2 -1
  28. package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.js +1 -0
  29. package/src/plugins/project-json/build-nodes/project-json.d.ts +2 -1
  30. package/src/plugins/project-json/build-nodes/project-json.js +1 -0
  31. package/src/plugins/target-defaults/target-defaults-plugin.d.ts +4 -4
  32. package/src/plugins/target-defaults/target-defaults-plugin.js +24 -27
  33. package/src/project-graph/affected/locators/project-glob-changes.js +2 -3
  34. package/src/project-graph/build-project-graph.js +10 -8
  35. package/src/project-graph/file-utils.js +3 -3
  36. package/src/project-graph/plugins/index.d.ts +2 -0
  37. package/src/project-graph/plugins/index.js +8 -0
  38. package/src/project-graph/plugins/internal-api.d.ts +21 -0
  39. package/src/project-graph/plugins/internal-api.js +84 -0
  40. package/src/project-graph/plugins/messaging.d.ts +89 -0
  41. package/src/project-graph/plugins/messaging.js +23 -0
  42. package/src/project-graph/plugins/plugin-pool.d.ts +4 -0
  43. package/src/project-graph/plugins/plugin-pool.js +188 -0
  44. package/src/project-graph/plugins/plugin-worker.d.ts +1 -0
  45. package/src/project-graph/plugins/plugin-worker.js +122 -0
  46. package/src/{utils/nx-plugin.d.ts → project-graph/plugins/public-api.d.ts} +6 -40
  47. package/src/project-graph/plugins/public-api.js +4 -0
  48. package/src/project-graph/plugins/worker-api.d.ts +26 -0
  49. package/src/project-graph/plugins/worker-api.js +177 -0
  50. package/src/project-graph/project-graph-builder.d.ts +1 -1
  51. package/src/project-graph/project-graph.js +0 -2
  52. package/src/project-graph/utils/normalize-project-nodes.d.ts +1 -1
  53. package/src/project-graph/utils/project-configuration-utils.d.ts +2 -2
  54. package/src/project-graph/utils/project-configuration-utils.js +27 -47
  55. package/src/project-graph/utils/retrieve-workspace-files.d.ts +8 -4
  56. package/src/project-graph/utils/retrieve-workspace-files.js +11 -14
  57. package/src/utils/logger.d.ts +1 -0
  58. package/src/utils/logger.js +5 -0
  59. package/src/utils/nx-plugin.deprecated.d.ts +4 -2
  60. package/src/utils/nx-plugin.deprecated.js +4 -4
  61. package/src/utils/package-json.js +2 -2
  62. package/src/utils/plugins/plugin-capabilities.d.ts +1 -1
  63. package/src/utils/plugins/plugin-capabilities.js +8 -7
  64. package/src/utils/nx-plugin.js +0 -293
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "18.1.0-canary.20240223-21e7648",
3
+ "version": "18.1.0-canary.20240227-452d845",
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.1.0-canary.20240223-21e7648"
69
+ "@nrwl/tao": "18.1.0-canary.20240227-452d845"
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.1.0-canary.20240223-21e7648",
85
- "@nx/nx-darwin-arm64": "18.1.0-canary.20240223-21e7648",
86
- "@nx/nx-linux-x64-gnu": "18.1.0-canary.20240223-21e7648",
87
- "@nx/nx-linux-x64-musl": "18.1.0-canary.20240223-21e7648",
88
- "@nx/nx-win32-x64-msvc": "18.1.0-canary.20240223-21e7648",
89
- "@nx/nx-linux-arm64-gnu": "18.1.0-canary.20240223-21e7648",
90
- "@nx/nx-linux-arm64-musl": "18.1.0-canary.20240223-21e7648",
91
- "@nx/nx-linux-arm-gnueabihf": "18.1.0-canary.20240223-21e7648",
92
- "@nx/nx-win32-arm64-msvc": "18.1.0-canary.20240223-21e7648",
93
- "@nx/nx-freebsd-x64": "18.1.0-canary.20240223-21e7648"
84
+ "@nx/nx-darwin-x64": "18.1.0-canary.20240227-452d845",
85
+ "@nx/nx-darwin-arm64": "18.1.0-canary.20240227-452d845",
86
+ "@nx/nx-linux-x64-gnu": "18.1.0-canary.20240227-452d845",
87
+ "@nx/nx-linux-x64-musl": "18.1.0-canary.20240227-452d845",
88
+ "@nx/nx-win32-x64-msvc": "18.1.0-canary.20240227-452d845",
89
+ "@nx/nx-linux-arm64-gnu": "18.1.0-canary.20240227-452d845",
90
+ "@nx/nx-linux-arm64-musl": "18.1.0-canary.20240227-452d845",
91
+ "@nx/nx-linux-arm-gnueabihf": "18.1.0-canary.20240227-452d845",
92
+ "@nx/nx-win32-arm64-msvc": "18.1.0-canary.20240227-452d845",
93
+ "@nx/nx-freebsd-x64": "18.1.0-canary.20240227-452d845"
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.`);
@@ -17,6 +17,7 @@ const workspace_context_1 = require("../../utils/workspace-context");
17
17
  const connect_to_nx_cloud_1 = require("../connect/connect-to-nx-cloud");
18
18
  const add_nx_to_npm_repo_1 = require("./implementation/add-nx-to-npm-repo");
19
19
  const add_nx_to_monorepo_1 = require("./implementation/add-nx-to-monorepo");
20
+ const path_1 = require("path");
20
21
  async function initHandler(options) {
21
22
  const version = process.env.NX_VERSION ?? ((0, semver_1.prerelease)(versions_1.nxVersion) ? 'next' : 'latest');
22
23
  if (process.env.NX_VERSION) {
@@ -42,6 +43,7 @@ async function initHandler(options) {
42
43
  });
43
44
  return;
44
45
  }
46
+ output_1.output.log({ title: '🧐 Checking dependencies' });
45
47
  const detectPluginsResponse = await detectPlugins();
46
48
  if (!detectPluginsResponse?.plugins.length) {
47
49
  // If no plugins are detected/chosen, guide users to setup
@@ -63,19 +65,23 @@ async function initHandler(options) {
63
65
  const pmc = (0, package_manager_1.getPackageManagerCommand)();
64
66
  (0, utils_1.createNxJsonFile)(repoRoot, [], [], {});
65
67
  (0, utils_1.updateGitIgnore)(repoRoot);
66
- (0, utils_1.addDepsToPackageJson)(repoRoot, detectPluginsResponse?.plugins ?? []);
68
+ (0, utils_1.addDepsToPackageJson)(repoRoot, detectPluginsResponse.plugins);
67
69
  output_1.output.log({ title: '📦 Installing Nx' });
68
70
  (0, utils_1.runInstall)(repoRoot, pmc);
69
- if (detectPluginsResponse) {
70
- output_1.output.log({ title: '🔨 Configuring plugins' });
71
- for (const plugin of detectPluginsResponse.plugins) {
72
- (0, child_process_2.execSync)(`${pmc.exec} nx g ${plugin}:init --keepExistingVersions ${detectPluginsResponse.updatePackageScripts
73
- ? '--updatePackageScripts'
74
- : ''} --no-interactive`, {
75
- stdio: [0, 1, 2],
76
- cwd: repoRoot,
77
- });
78
- }
71
+ output_1.output.log({ title: '🔨 Configuring plugins' });
72
+ for (const plugin of detectPluginsResponse.plugins) {
73
+ (0, child_process_2.execSync)(`${pmc.exec} nx g ${plugin}:init --keepExistingVersions ${detectPluginsResponse.updatePackageScripts
74
+ ? '--updatePackageScripts'
75
+ : ''} --no-interactive`, {
76
+ stdio: [0, 1, 2],
77
+ cwd: repoRoot,
78
+ });
79
+ }
80
+ if (!detectPluginsResponse.updatePackageScripts) {
81
+ const rootPackageJsonPath = (0, path_1.join)(repoRoot, 'package.json');
82
+ const json = (0, fileutils_1.readJsonFile)(rootPackageJsonPath);
83
+ json.nx = {};
84
+ (0, fileutils_1.writeJsonFile)(rootPackageJsonPath, json);
79
85
  }
80
86
  if (useNxCloud) {
81
87
  output_1.output.log({ title: '🛠️ Setting up Nx Cloud' });
@@ -872,7 +872,9 @@ async function executeMigrations(root, migrations, isVerbose, shouldCreateCommit
872
872
  if (b.name === '15-7-0-split-configuration-into-project-json-files') {
873
873
  return 1;
874
874
  }
875
- return (0, semver_1.lt)(a.version, b.version) ? -1 : 1;
875
+ return (0, semver_1.lt)(normalizeVersion(a.version), normalizeVersion(b.version))
876
+ ? -1
877
+ : 1;
876
878
  });
877
879
  for (const m of sortedMigrations) {
878
880
  try {
@@ -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;
@@ -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
@@ -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
  */
@@ -18,3 +18,4 @@ export { hashObject } from './hasher/file-hasher';
18
18
  export { hashWithWorkspaceContext } from './utils/workspace-context';
19
19
  export { createProjectRootMappingsFromProjectConfigurations, findProjectForPath, } from './project-graph/utils/find-project-for-path';
20
20
  export { registerTsProject } from './plugins/js/utils/register';
21
+ export { shutdownPluginWorkers } from './project-graph/plugins/plugin-pool';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.registerTsProject = exports.findProjectForPath = exports.createProjectRootMappingsFromProjectConfigurations = exports.hashWithWorkspaceContext = exports.hashObject = exports.splitByColons = exports.readModulePackageJson = exports.stripIndent = exports.sortObjectByKeys = exports.combineOptionsForExecutor = exports.splitTarget = exports.retrieveProjectConfigurationsWithAngularProjects = exports.calculateDefaultProjectName = exports.readNxJsonFromDisk = exports.getExecutorInformation = exports.createTempNpmDirectory = void 0;
3
+ exports.shutdownPluginWorkers = exports.registerTsProject = exports.findProjectForPath = exports.createProjectRootMappingsFromProjectConfigurations = exports.hashWithWorkspaceContext = exports.hashObject = exports.splitByColons = exports.readModulePackageJson = exports.stripIndent = exports.sortObjectByKeys = exports.combineOptionsForExecutor = exports.splitTarget = exports.retrieveProjectConfigurationsWithAngularProjects = exports.calculateDefaultProjectName = exports.readNxJsonFromDisk = exports.getExecutorInformation = exports.createTempNpmDirectory = void 0;
4
4
  /**
5
5
  * Note to developers: STOP! These exports are available via requireNx in @nx/devkit.
6
6
  *
@@ -37,3 +37,5 @@ Object.defineProperty(exports, "createProjectRootMappingsFromProjectConfiguratio
37
37
  Object.defineProperty(exports, "findProjectForPath", { enumerable: true, get: function () { return find_project_for_path_1.findProjectForPath; } });
38
38
  var register_1 = require("./plugins/js/utils/register");
39
39
  Object.defineProperty(exports, "registerTsProject", { enumerable: true, get: function () { return register_1.registerTsProject; } });
40
+ var plugin_pool_1 = require("./project-graph/plugins/plugin-pool");
41
+ Object.defineProperty(exports, "shutdownPluginWorkers", { enumerable: true, get: function () { return plugin_pool_1.shutdownPluginWorkers; } });
@@ -134,8 +134,8 @@ function readAndCombineAllProjectConfigurations(tree) {
134
134
  ...(0, package_json_workspaces_1.getGlobPatternsFromPackageManagerWorkspaces)(tree.root, (p) => (0, json_1.readJson)(tree, p)),
135
135
  ];
136
136
  const projectGlobPatterns = (0, retrieve_workspace_files_1.configurationGlobs)([
137
- { plugin: project_json_1.ProjectJsonProjectsPlugin },
138
- { plugin: (0, package_json_workspaces_1.getNxPackageJsonWorkspacesPlugin)(tree.root) },
137
+ project_json_1.ProjectJsonProjectsPlugin,
138
+ { createNodes: package_json_workspaces_1.createNodes },
139
139
  ]);
140
140
  const globbedFiles = (0, workspace_context_1.globWithWorkspaceContext)(tree.root, projectGlobPatterns);
141
141
  const createdFiles = findCreatedProjectFiles(tree, patterns);
@@ -5,10 +5,10 @@ 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 projectFiles = await (0, retrieve_workspace_files_1.retrieveProjectConfigurationPaths)(tree.root, await (0, internal_api_1.loadNxPlugins)(nxJson?.plugins));
12
12
  const projectJsons = projectFiles.filter((f) => f.endsWith('project.json'));
13
13
  for (let f of projectJsons) {
14
14
  const projectJson = (0, json_1.readJson)(tree, f);
@@ -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 } from '../../../utils/nx-plugin';
9
+ import { CreateDependenciesContext } 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 & {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getGlobPatternsFromPackageManagerWorkspaces = exports.buildProjectConfigurationFromPackageJson = exports.createNodeFromPackageJson = exports.getNxPackageJsonWorkspacesPlugin = void 0;
3
+ exports.getGlobPatternsFromPackageManagerWorkspaces = exports.buildProjectConfigurationFromPackageJson = exports.createNodeFromPackageJson = exports.createNodes = void 0;
4
4
  const minimatch_1 = require("minimatch");
5
5
  const node_fs_1 = require("node:fs");
6
6
  const node_path_1 = require("node:path");
@@ -12,37 +12,30 @@ const logger_1 = require("../../utils/logger");
12
12
  const output_1 = require("../../utils/output");
13
13
  const package_json_1 = require("../../utils/package-json");
14
14
  const path_1 = require("../../utils/path");
15
- function getNxPackageJsonWorkspacesPlugin(root) {
16
- const readJson = (f) => (0, fileutils_1.readJsonFile)((0, node_path_1.join)(root, f));
17
- const patterns = getGlobPatternsFromPackageManagerWorkspaces(root, readJson);
18
- // If the user only specified a negative pattern, we should find all package.json
19
- // files and only return those that don't match a negative pattern.
20
- const negativePatterns = patterns.filter((p) => p.startsWith('!'));
21
- let positivePatterns = patterns.filter((p) => !p.startsWith('!'));
22
- if (
23
- // There are some negative patterns
24
- negativePatterns.length > 0 &&
25
- // No positive patterns
26
- (positivePatterns.length === 0 ||
27
- // Or only a single positive pattern that is the default coming from root package
28
- (positivePatterns.length === 1 && positivePatterns[0] === 'package.json'))) {
29
- positivePatterns.push('**/package.json');
30
- }
31
- return {
32
- name: 'nx/core/package-json-workspaces',
33
- createNodes: [
34
- (0, globs_1.combineGlobPatterns)(positivePatterns),
35
- (p) => {
36
- if (!negativePatterns.some((negative) => (0, minimatch_1.minimatch)(p, negative))) {
37
- return createNodeFromPackageJson(p, root);
38
- }
39
- // A negative pattern matched, so we should not create a node for this package.json
40
- return {};
41
- },
42
- ],
43
- };
15
+ const workspace_root_1 = require("../../utils/workspace-root");
16
+ const readJson = (f) => (0, fileutils_1.readJsonFile)((0, node_path_1.join)(workspace_root_1.workspaceRoot, f));
17
+ const patterns = getGlobPatternsFromPackageManagerWorkspaces(workspace_root_1.workspaceRoot, readJson);
18
+ const negativePatterns = patterns.filter((p) => p.startsWith('!'));
19
+ const positivePatterns = patterns.filter((p) => !p.startsWith('!'));
20
+ if (
21
+ // There are some negative patterns
22
+ negativePatterns.length > 0 &&
23
+ // No positive patterns
24
+ (positivePatterns.length === 0 ||
25
+ // Or only a single positive pattern that is the default coming from root package
26
+ (positivePatterns.length === 1 && positivePatterns[0] === 'package.json'))) {
27
+ positivePatterns.push('**/package.json');
44
28
  }
45
- exports.getNxPackageJsonWorkspacesPlugin = getNxPackageJsonWorkspacesPlugin;
29
+ exports.createNodes = [
30
+ (0, globs_1.combineGlobPatterns)(positivePatterns),
31
+ (p, _, { workspaceRoot }) => {
32
+ if (!negativePatterns.some((negative) => (0, minimatch_1.minimatch)(p, negative))) {
33
+ return createNodeFromPackageJson(p, workspaceRoot);
34
+ }
35
+ // A negative pattern matched, so we should not create a node for this package.json
36
+ return {};
37
+ },
38
+ ];
46
39
  function createNodeFromPackageJson(pkgJsonPath, root) {
47
40
  const json = (0, fileutils_1.readJsonFile)((0, node_path_1.join)(root, pkgJsonPath));
48
41
  const project = buildProjectConfigurationFromPackageJson(json, pkgJsonPath, (0, nx_json_1.readNxJson)(root));
@@ -1 +1,2 @@
1
1
  export * from './create-nodes';
2
+ export declare const name = "nx/core/package-json-workspaces";
@@ -1,4 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.name = void 0;
3
4
  const tslib_1 = require("tslib");
4
5
  tslib_1.__exportStar(require("./create-nodes"), exports);
6
+ exports.name = 'nx/core/package-json-workspaces';
@@ -1,2 +1,3 @@
1
- import { NxPluginV2 } from '../../../utils/nx-plugin';
1
+ import { NxPluginV2 } from '../../../project-graph/plugins';
2
2
  export declare const PackageJsonProjectsNextToProjectJsonPlugin: NxPluginV2;
3
+ export default PackageJsonProjectsNextToProjectJsonPlugin;
@@ -24,6 +24,7 @@ exports.PackageJsonProjectsNextToProjectJsonPlugin = {
24
24
  },
25
25
  ],
26
26
  };
27
+ exports.default = exports.PackageJsonProjectsNextToProjectJsonPlugin;
27
28
  function createProjectFromPackageJsonNextToProjectJson(projectJsonPath, workspaceRoot) {
28
29
  const root = (0, path_1.dirname)(projectJsonPath);
29
30
  const packageJsonPath = (0, path_1.join)(workspaceRoot, root, 'package.json');
@@ -1,4 +1,5 @@
1
1
  import { ProjectConfiguration } 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 ProjectJsonProjectsPlugin: NxPluginV2;
4
+ export default ProjectJsonProjectsPlugin;
4
5
  export declare function buildProjectFromProjectJson(json: Partial<ProjectConfiguration>, path: string): ProjectConfiguration;
@@ -19,6 +19,7 @@ exports.ProjectJsonProjectsPlugin = {
19
19
  },
20
20
  ],
21
21
  };
22
+ exports.default = exports.ProjectJsonProjectsPlugin;
22
23
  function buildProjectFromProjectJson(json, path) {
23
24
  return {
24
25
  name: (0, workspaces_1.toProjectName)(path),
@@ -1,6 +1,5 @@
1
- import { ProjectConfiguration } from '../../config/workspace-json-project-json';
2
- import { NxPluginV2 } from '../../utils/nx-plugin';
3
- import { PackageJson } from '../../utils/package-json';
1
+ import { TargetConfiguration } from '../../config/workspace-json-project-json';
2
+ import { NxPluginV2 } from '../../project-graph/plugins';
4
3
  /**
5
4
  * This symbol marks that a target provides information which should modify a target already registered
6
5
  * on the project via other plugins. If the target has not already been registered, and this symbol is true,
@@ -8,6 +7,7 @@ import { PackageJson } from '../../utils/package-json';
8
7
  */
9
8
  export declare const ONLY_MODIFIES_EXISTING_TARGET: unique symbol;
10
9
  export declare const TargetDefaultsPlugin: NxPluginV2;
10
+ export default TargetDefaultsPlugin;
11
11
  /**
12
12
  * This fn gets target info that would make a target uniquely compatible
13
13
  * with what is described by project.json or package.json. As the merge process
@@ -17,7 +17,7 @@ export declare const TargetDefaultsPlugin: NxPluginV2;
17
17
  * being scrapped. By adding enough information from the project.json / package.json,
18
18
  * we can make sure that the target after merging is compatible with the defined target.
19
19
  */
20
- export declare function getTargetInfo(target: string, projectJson: Pick<ProjectConfiguration, 'targets'>, packageJson: Pick<PackageJson, 'scripts' | 'nx'>): {
20
+ export declare function getTargetInfo(target: string, projectJsonTargets: Record<string, TargetConfiguration>, packageJsonTargets: Record<string, TargetConfiguration>): {
21
21
  command: string;
22
22
  executor?: undefined;
23
23
  options?: undefined;
@@ -38,13 +38,12 @@ exports.TargetDefaultsPlugin = {
38
38
  }
39
39
  const projectJson = readJsonOrNull((0, node_path_1.join)(ctx.workspaceRoot, root, 'project.json'));
40
40
  const packageJson = readJsonOrNull((0, node_path_1.join)(ctx.workspaceRoot, root, 'package.json'));
41
+ const packageJsonTargets = (0, package_json_1.readTargetsFromPackageJson)(packageJson);
41
42
  const projectDefinedTargets = new Set([
42
43
  ...Object.keys(projectJson?.targets ?? {}),
43
- ...(packageJson
44
- ? Object.keys((0, package_json_1.readTargetsFromPackageJson)(packageJson))
45
- : []),
44
+ ...(packageJson ? Object.keys(packageJsonTargets) : []),
46
45
  ]);
47
- const executorToTargetMap = getExecutorToTargetMap(packageJson, projectJson);
46
+ const executorToTargetMap = getExecutorToTargetMap(packageJsonTargets, projectJson?.targets);
48
47
  const modifiedTargets = {};
49
48
  for (const defaultSpecifier in targetDefaults) {
50
49
  const targetNames = executorToTargetMap.get(defaultSpecifier) ?? new Set();
@@ -55,7 +54,7 @@ exports.TargetDefaultsPlugin = {
55
54
  if (!modifiedTargets[targetName] || targetName !== defaultSpecifier) {
56
55
  const defaults = JSON.parse(JSON.stringify(targetDefaults[defaultSpecifier]));
57
56
  modifiedTargets[targetName] = {
58
- ...getTargetInfo(targetName, projectJson, packageJson),
57
+ ...getTargetInfo(targetName, projectJson?.targets, packageJsonTargets),
59
58
  ...defaults,
60
59
  };
61
60
  }
@@ -76,17 +75,15 @@ exports.TargetDefaultsPlugin = {
76
75
  },
77
76
  ],
78
77
  };
79
- function getExecutorToTargetMap(packageJson, projectJson) {
78
+ exports.default = exports.TargetDefaultsPlugin;
79
+ function getExecutorToTargetMap(packageJsonTargets, projectJsonTargets) {
80
80
  const executorToTargetMap = new Map();
81
81
  const targets = Object.keys({
82
- ...projectJson?.targets,
83
- ...packageJson?.scripts,
84
- ...packageJson?.nx?.targets,
82
+ ...projectJsonTargets,
83
+ ...packageJsonTargets,
85
84
  });
86
85
  for (const target of targets) {
87
- const executor = projectJson?.targets?.[target]?.executor ??
88
- packageJson?.nx?.targets?.[target]?.executor ??
89
- 'nx:run-script';
86
+ const executor = getTargetExecutor(target, projectJsonTargets, packageJsonTargets);
90
87
  const targetsForExecutor = executorToTargetMap.get(executor) ?? new Set();
91
88
  targetsForExecutor.add(target);
92
89
  executorToTargetMap.set(executor, targetsForExecutor);
@@ -110,10 +107,10 @@ function readJsonOrNull(path) {
110
107
  * being scrapped. By adding enough information from the project.json / package.json,
111
108
  * we can make sure that the target after merging is compatible with the defined target.
112
109
  */
113
- function getTargetInfo(target, projectJson, packageJson) {
114
- const projectJsonTarget = projectJson?.targets?.[target];
115
- const packageJsonTarget = packageJson?.nx?.targets?.[target];
116
- const executor = getTargetExecutor(target, projectJson, packageJson);
110
+ function getTargetInfo(target, projectJsonTargets, packageJsonTargets) {
111
+ const projectJsonTarget = projectJsonTargets?.[target];
112
+ const packageJsonTarget = packageJsonTargets?.[target];
113
+ const executor = getTargetExecutor(target, projectJsonTargets, packageJsonTargets);
117
114
  const targetOptions = {
118
115
  ...packageJsonTarget?.options,
119
116
  ...projectJsonTarget?.options,
@@ -158,17 +155,17 @@ function getTargetInfo(target, projectJson, packageJson) {
158
155
  return {};
159
156
  }
160
157
  exports.getTargetInfo = getTargetInfo;
161
- function getTargetExecutor(target, projectJson, packageJson) {
162
- const projectJsonTarget = projectJson?.targets?.[target];
163
- const packageJsonTarget = packageJson?.nx?.targets?.[target];
164
- const packageJsonScript = packageJson?.scripts?.[target];
165
- if (projectJsonTarget?.command) {
166
- return 'nx:run-commands';
158
+ function getTargetExecutor(target, projectJsonTargets, packageJsonTargets) {
159
+ const projectJsonTargetConfiguration = projectJsonTargets?.[target];
160
+ const packageJsonTargetConfiguration = packageJsonTargets?.[target];
161
+ if (!projectJsonTargetConfiguration && packageJsonTargetConfiguration) {
162
+ return packageJsonTargetConfiguration?.executor ?? 'nx:run-script';
167
163
  }
168
- if (!projectJsonTarget?.executor &&
169
- !packageJsonTarget?.executor &&
170
- packageJsonScript) {
171
- return 'nx:run-script';
164
+ if (projectJsonTargetConfiguration?.executor) {
165
+ return projectJsonTargetConfiguration.executor;
166
+ }
167
+ if (projectJsonTargetConfiguration?.command) {
168
+ return 'nx:run-commands';
172
169
  }
173
- return projectJsonTarget?.executor ?? packageJsonTarget?.executor;
170
+ return null;
174
171
  }
@@ -3,14 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getTouchedProjectsFromProjectGlobChanges = void 0;
4
4
  const minimatch_1 = require("minimatch");
5
5
  const workspace_root_1 = require("../../../utils/workspace-root");
6
- const installation_directory_1 = require("../../../utils/installation-directory");
7
6
  const path_1 = require("path");
8
7
  const fs_1 = require("fs");
9
8
  const retrieve_workspace_files_1 = require("../../utils/retrieve-workspace-files");
10
- const nx_plugin_1 = require("../../../utils/nx-plugin");
9
+ const internal_api_1 = require("../../plugins/internal-api");
11
10
  const globs_1 = require("../../../utils/globs");
12
11
  const getTouchedProjectsFromProjectGlobChanges = async (touchedFiles, projectGraphNodes, nxJson) => {
13
- const globPattern = (0, globs_1.combineGlobPatterns)((0, retrieve_workspace_files_1.configurationGlobs)(await (0, nx_plugin_1.loadNxPlugins)(nxJson?.plugins, (0, installation_directory_1.getNxRequirePaths)(workspace_root_1.workspaceRoot), workspace_root_1.workspaceRoot)));
12
+ const globPattern = (0, globs_1.combineGlobPatterns)((0, retrieve_workspace_files_1.configurationGlobs)(await (0, internal_api_1.loadNxPlugins)(nxJson?.plugins, workspace_root_1.workspaceRoot)));
14
13
  const touchedProjects = new Set();
15
14
  for (const touchedFile of touchedFiles) {
16
15
  const isProjectFile = (0, minimatch_1.minimatch)(touchedFile.file, globPattern, {