nx 18.1.0 → 18.1.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 (121) hide show
  1. package/bin/init-local.js +13 -1
  2. package/package.json +12 -12
  3. package/release/changelog-renderer/index.d.ts +2 -0
  4. package/release/changelog-renderer/index.js +4 -18
  5. package/schemas/nx-schema.json +62 -1
  6. package/schemas/project-schema.json +20 -0
  7. package/src/adapter/angular-json.d.ts +1 -2
  8. package/src/adapter/angular-json.js +0 -1
  9. package/src/adapter/ngcli-adapter.js +3 -3
  10. package/src/command-line/generate/generator-utils.js +2 -2
  11. package/src/command-line/init/implementation/add-nx-to-nest.js +2 -2
  12. package/src/command-line/init/implementation/add-nx-to-npm-repo.js +2 -2
  13. package/src/command-line/init/implementation/utils.d.ts +1 -3
  14. package/src/command-line/init/implementation/utils.js +9 -16
  15. package/src/command-line/init/init-v2.js +3 -2
  16. package/src/command-line/release/changelog.js +17 -14
  17. package/src/command-line/release/command-object.d.ts +1 -0
  18. package/src/command-line/release/config/config.d.ts +12 -15
  19. package/src/command-line/release/config/config.js +151 -22
  20. package/src/command-line/release/config/conventional-commits.d.ts +2 -0
  21. package/src/command-line/release/config/conventional-commits.js +98 -0
  22. package/src/command-line/release/publish.js +4 -3
  23. package/src/command-line/release/release.js +12 -11
  24. package/src/command-line/release/utils/git.js +30 -1
  25. package/src/command-line/release/utils/resolve-semver-specifier.d.ts +2 -1
  26. package/src/command-line/release/utils/resolve-semver-specifier.js +2 -13
  27. package/src/command-line/release/utils/semver.d.ts +2 -8
  28. package/src/command-line/release/utils/semver.js +4 -1
  29. package/src/command-line/release/utils/shared.d.ts +5 -1
  30. package/src/command-line/release/version.d.ts +6 -1
  31. package/src/command-line/release/version.js +71 -19
  32. package/src/command-line/run/executor-utils.js +2 -2
  33. package/src/command-line/run/run.js +3 -3
  34. package/src/config/nx-json.d.ts +31 -0
  35. package/src/config/schema-utils.js +2 -2
  36. package/src/core/graph/main.js +1 -1
  37. package/src/core/graph/polyfills.js +1 -1
  38. package/src/core/graph/styles.css +1 -1
  39. package/src/daemon/server/project-graph-incremental-recomputation.js +1 -0
  40. package/src/devkit-exports.d.ts +1 -2
  41. package/src/devkit-internals.d.ts +0 -1
  42. package/src/devkit-internals.js +1 -3
  43. package/src/executors/run-commands/run-commands.impl.d.ts +7 -1
  44. package/src/executors/run-commands/run-commands.impl.js +120 -57
  45. package/src/executors/run-script/run-script.impl.js +5 -5
  46. package/src/generators/utils/project-configuration.js +2 -2
  47. package/src/hasher/hash-task.js +2 -2
  48. package/src/migrations/update-15-1-0/set-project-names.js +2 -4
  49. package/src/migrations/update-17-2-0/move-default-base.d.ts +1 -1
  50. package/src/migrations/update-17-2-0/move-default-base.js +3 -1
  51. package/src/migrations/update-17-3-0/nx-release-path.js +0 -1
  52. package/src/native/index.d.ts +14 -11
  53. package/src/native/index.js +3 -4
  54. package/src/plugins/js/index.d.ts +1 -1
  55. package/src/plugins/js/lock-file/lock-file.d.ts +1 -1
  56. package/src/plugins/js/lock-file/lock-file.js +13 -1
  57. package/src/plugins/js/lock-file/npm-parser.d.ts +1 -1
  58. package/src/plugins/js/lock-file/pnpm-parser.d.ts +1 -1
  59. package/src/plugins/js/lock-file/yarn-parser.d.ts +1 -1
  60. package/src/plugins/js/project-graph/build-dependencies/build-dependencies.d.ts +1 -1
  61. package/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.d.ts +1 -1
  62. package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.d.ts +1 -1
  63. package/src/plugins/js/utils/register.js +3 -1
  64. package/src/plugins/package-json-workspaces/create-nodes.d.ts +2 -2
  65. package/src/plugins/package-json-workspaces/create-nodes.js +31 -24
  66. package/src/plugins/package-json-workspaces/index.d.ts +0 -1
  67. package/src/plugins/package-json-workspaces/index.js +0 -2
  68. package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.d.ts +1 -2
  69. package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.js +0 -1
  70. package/src/plugins/project-json/build-nodes/project-json.d.ts +1 -2
  71. package/src/plugins/project-json/build-nodes/project-json.js +0 -1
  72. package/src/plugins/target-defaults/target-defaults-plugin.d.ts +1 -2
  73. package/src/plugins/target-defaults/target-defaults-plugin.js +0 -1
  74. package/src/project-graph/affected/locators/project-glob-changes.js +3 -2
  75. package/src/project-graph/build-project-graph.js +8 -11
  76. package/src/project-graph/file-utils.js +6 -4
  77. package/src/project-graph/project-graph-builder.d.ts +1 -1
  78. package/src/project-graph/project-graph.js +3 -0
  79. package/src/project-graph/utils/normalize-project-nodes.d.ts +1 -1
  80. package/src/project-graph/utils/project-configuration-utils.d.ts +4 -4
  81. package/src/project-graph/utils/project-configuration-utils.js +58 -17
  82. package/src/project-graph/utils/retrieve-workspace-files.d.ts +4 -8
  83. package/src/project-graph/utils/retrieve-workspace-files.js +18 -20
  84. package/src/tasks-runner/fork.js +7 -7
  85. package/src/tasks-runner/forked-process-task-runner.d.ts +2 -4
  86. package/src/tasks-runner/forked-process-task-runner.js +13 -17
  87. package/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.js +16 -13
  88. package/src/tasks-runner/life-cycles/dynamic-run-one-terminal-output-life-cycle.js +8 -7
  89. package/src/tasks-runner/{psuedo-ipc.d.ts → pseudo-ipc.d.ts} +7 -7
  90. package/src/tasks-runner/{psuedo-ipc.js → pseudo-ipc.js} +9 -9
  91. package/src/tasks-runner/pseudo-terminal.d.ts +42 -0
  92. package/src/tasks-runner/pseudo-terminal.js +133 -0
  93. package/src/tasks-runner/task-orchestrator.js +45 -9
  94. package/src/tasks-runner/tasks-schedule.js +3 -3
  95. package/src/tasks-runner/utils.d.ts +7 -6
  96. package/src/tasks-runner/utils.js +11 -7
  97. package/src/utils/ignore.js +1 -1
  98. package/src/utils/logger.d.ts +0 -1
  99. package/src/utils/logger.js +0 -5
  100. package/src/{project-graph/plugins/public-api.d.ts → utils/nx-plugin.d.ts} +45 -7
  101. package/src/utils/nx-plugin.deprecated.d.ts +2 -4
  102. package/src/utils/nx-plugin.deprecated.js +4 -4
  103. package/src/utils/nx-plugin.js +293 -0
  104. package/src/utils/output.js +1 -1
  105. package/src/utils/plugins/plugin-capabilities.d.ts +1 -1
  106. package/src/utils/plugins/plugin-capabilities.js +7 -8
  107. package/src/project-graph/plugins/index.d.ts +0 -2
  108. package/src/project-graph/plugins/index.js +0 -8
  109. package/src/project-graph/plugins/internal-api.d.ts +0 -18
  110. package/src/project-graph/plugins/internal-api.js +0 -48
  111. package/src/project-graph/plugins/messaging.d.ts +0 -94
  112. package/src/project-graph/plugins/messaging.js +0 -23
  113. package/src/project-graph/plugins/plugin-pool.d.ts +0 -4
  114. package/src/project-graph/plugins/plugin-pool.js +0 -216
  115. package/src/project-graph/plugins/plugin-worker.d.ts +0 -1
  116. package/src/project-graph/plugins/plugin-worker.js +0 -115
  117. package/src/project-graph/plugins/public-api.js +0 -4
  118. package/src/project-graph/plugins/utils.d.ts +0 -9
  119. package/src/project-graph/plugins/utils.js +0 -55
  120. package/src/project-graph/plugins/worker-api.d.ts +0 -26
  121. package/src/project-graph/plugins/worker-api.js +0 -177
@@ -21,12 +21,6 @@ export function expandOutputs(directory: string, entries: Array<string>): Array<
21
21
  export function getFilesForOutputs(directory: string, entries: Array<string>): Array<string>
22
22
  export function remove(src: string): void
23
23
  export function copy(src: string, dest: string): void
24
- export function runCommand(command: string, commandDir?: string | undefined | null, jsEnv?: Record<string, string> | undefined | null, quiet?: boolean | undefined | null): ChildProcess
25
- /**
26
- * This allows us to run a pseudoterminal with a fake node ipc channel
27
- * this makes it possible to be backwards compatible with the old implementation
28
- */
29
- export function nxFork(id: string, forkScript: string, psuedoIpcPath: string, commandDir: string | undefined | null, jsEnv: Record<string, string> | undefined | null, quiet: boolean): ChildProcess
30
24
  export function hashArray(input: Array<string>): string
31
25
  export function hashFile(file: string): string | null
32
26
  export function findImports(projectFileMap: Record<string, Array<string>>): Array<ImportResult>
@@ -146,17 +140,26 @@ export interface FileMap {
146
140
  nonProjectFiles: Array<FileData>
147
141
  }
148
142
  export function testOnlyTransferFileMap(projectFiles: Record<string, Array<FileData>>, nonProjectFiles: Array<FileData>): NxWorkspaceFilesExternals
149
- export class ChildProcess {
150
- kill(): void
151
- onExit(callback: (message: string) => void): void
152
- onOutput(callback: (message: string) => void): void
153
- }
154
143
  export class ImportResult {
155
144
  file: string
156
145
  sourceProject: string
157
146
  dynamicImportExpressions: Array<string>
158
147
  staticImportExpressions: Array<string>
159
148
  }
149
+ export class ChildProcess {
150
+ kill(): void
151
+ onExit(callback: (message: string) => void): void
152
+ onOutput(callback: (message: string) => void): void
153
+ }
154
+ export class RustPseudoTerminal {
155
+ constructor()
156
+ runCommand(command: string, commandDir?: string | undefined | null, jsEnv?: Record<string, string> | undefined | null, quiet?: boolean | undefined | null): ChildProcess
157
+ /**
158
+ * This allows us to run a pseudoterminal with a fake node ipc channel
159
+ * this makes it possible to be backwards compatible with the old implementation
160
+ */
161
+ fork(id: string, forkScript: string, pseudoIpcPath: string, commandDir: string | undefined | null, jsEnv: Record<string, string> | undefined | null, quiet: boolean): ChildProcess
162
+ }
160
163
  export class HashPlanner {
161
164
  constructor(nxJson: NxJson, projectGraph: ExternalObject<ProjectGraph>)
162
165
  getPlans(taskIds: Array<string>, taskGraph: TaskGraph): Record<string, string[]>
@@ -246,20 +246,19 @@ if (!nativeBinding) {
246
246
  throw new Error(`Failed to load native binding`)
247
247
  }
248
248
 
249
- const { expandOutputs, getFilesForOutputs, remove, copy, ChildProcess, runCommand, nxFork, hashArray, hashFile, ImportResult, findImports, transferProjectGraph, HashPlanner, TaskHasher, EventType, Watcher, WorkspaceContext, WorkspaceErrors, testOnlyTransferFileMap } = nativeBinding
249
+ const { expandOutputs, getFilesForOutputs, remove, copy, hashArray, hashFile, ImportResult, findImports, transferProjectGraph, ChildProcess, RustPseudoTerminal, HashPlanner, TaskHasher, EventType, Watcher, WorkspaceContext, WorkspaceErrors, testOnlyTransferFileMap } = nativeBinding
250
250
 
251
251
  module.exports.expandOutputs = expandOutputs
252
252
  module.exports.getFilesForOutputs = getFilesForOutputs
253
253
  module.exports.remove = remove
254
254
  module.exports.copy = copy
255
- module.exports.ChildProcess = ChildProcess
256
- module.exports.runCommand = runCommand
257
- module.exports.nxFork = nxFork
258
255
  module.exports.hashArray = hashArray
259
256
  module.exports.hashFile = hashFile
260
257
  module.exports.ImportResult = ImportResult
261
258
  module.exports.findImports = findImports
262
259
  module.exports.transferProjectGraph = transferProjectGraph
260
+ module.exports.ChildProcess = ChildProcess
261
+ module.exports.RustPseudoTerminal = RustPseudoTerminal
263
262
  module.exports.HashPlanner = HashPlanner
264
263
  module.exports.TaskHasher = TaskHasher
265
264
  module.exports.EventType = EventType
@@ -1,4 +1,4 @@
1
- import { CreateDependencies, CreateNodes } from '../../project-graph/plugins';
1
+ import { CreateDependencies, CreateNodes } from '../../utils/nx-plugin';
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 '../../../project-graph/plugins';
9
+ import { CreateDependenciesContext } from '../../../utils/nx-plugin';
10
10
  export declare const LOCKFILES: string[];
11
11
  /**
12
12
  * Parses lock file and maps dependencies and metadata to {@link LockFileGraph}
@@ -109,6 +109,18 @@ function getLockFileName(packageManager) {
109
109
  throw new Error(`Unknown package manager: ${packageManager}`);
110
110
  }
111
111
  exports.getLockFileName = getLockFileName;
112
+ function getLockFilePath(packageManager) {
113
+ if (packageManager === 'yarn') {
114
+ return YARN_LOCK_PATH;
115
+ }
116
+ if (packageManager === 'pnpm') {
117
+ return PNPM_LOCK_PATH;
118
+ }
119
+ if (packageManager === 'npm') {
120
+ return NPM_LOCK_PATH;
121
+ }
122
+ throw new Error(`Unknown package manager: ${packageManager}`);
123
+ }
112
124
  /**
113
125
  * Create lock file based on the root level lock file and (pruned) package.json
114
126
  *
@@ -119,7 +131,7 @@ exports.getLockFileName = getLockFileName;
119
131
  */
120
132
  function createLockFile(packageJson, graph, packageManager = (0, package_manager_1.detectPackageManager)(workspace_root_1.workspaceRoot)) {
121
133
  const normalizedPackageJson = (0, package_json_1.normalizePackageJson)(packageJson);
122
- const content = (0, fs_1.readFileSync)(getLockFileName(packageManager), 'utf8');
134
+ const content = (0, fs_1.readFileSync)(getLockFilePath(packageManager), 'utf8');
123
135
  try {
124
136
  if (packageManager === 'yarn') {
125
137
  const prunedGraph = (0, project_graph_pruning_1.pruneProjectGraph)(graph, packageJson);
@@ -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 '../../../project-graph/plugins';
4
+ import { CreateDependenciesContext } from '../../../utils/nx-plugin';
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 '../../../project-graph/plugins';
4
+ import { CreateDependenciesContext } from '../../../utils/nx-plugin';
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 '../../../project-graph/plugins';
4
+ import { CreateDependenciesContext } from '../../../utils/nx-plugin';
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 '../../../../project-graph/plugins';
1
+ import { CreateDependenciesContext } from '../../../../utils/nx-plugin';
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 '../../../../project-graph/plugins';
1
+ import { CreateDependenciesContext } from '../../../../utils/nx-plugin';
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 '../../../../project-graph/plugins';
1
+ import { CreateDependenciesContext } from '../../../../utils/nx-plugin';
2
2
  import { RawProjectGraphDependency } from '../../../../project-graph/project-graph-builder';
3
3
  export declare function buildExplicitTypeScriptDependencies(ctx: CreateDependenciesContext): RawProjectGraphDependency[];
@@ -67,7 +67,9 @@ function getTranspiler(compilerOptions) {
67
67
  }
68
68
  compilerOptions.lib = ['es2021'];
69
69
  compilerOptions.module = ts.ModuleKind.CommonJS;
70
- compilerOptions.moduleResolution = ts.ModuleResolutionKind.Node10;
70
+ // use NodeJs module resolution until support for TS 4.x is dropped and then
71
+ // we can switch to Node10
72
+ compilerOptions.moduleResolution = ts.ModuleResolutionKind.NodeJs;
71
73
  compilerOptions.target = ts.ScriptTarget.ES2021;
72
74
  compilerOptions.inlineSourceMap = true;
73
75
  compilerOptions.skipLibCheck = true;
@@ -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';
3
4
  import { PackageJson } from '../../utils/package-json';
4
- import { CreateNodes } from '../../project-graph/plugins';
5
- export declare const createNodes: CreateNodes;
5
+ export declare function getNxPackageJsonWorkspacesPlugin(root: string): NxPluginV2;
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.createNodes = void 0;
3
+ exports.getGlobPatternsFromPackageManagerWorkspaces = exports.buildProjectConfigurationFromPackageJson = exports.createNodeFromPackageJson = exports.getNxPackageJsonWorkspacesPlugin = 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,30 +12,37 @@ 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
- 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');
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
+ };
28
44
  }
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
- ];
45
+ exports.getNxPackageJsonWorkspacesPlugin = getNxPackageJsonWorkspacesPlugin;
39
46
  function createNodeFromPackageJson(pkgJsonPath, root) {
40
47
  const json = (0, fileutils_1.readJsonFile)((0, node_path_1.join)(root, pkgJsonPath));
41
48
  const project = buildProjectConfigurationFromPackageJson(json, pkgJsonPath, (0, nx_json_1.readNxJson)(root));
@@ -1,2 +1 @@
1
1
  export * from './create-nodes';
2
- export declare const name = "nx/core/package-json-workspaces";
@@ -1,6 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.name = void 0;
4
3
  const tslib_1 = require("tslib");
5
4
  tslib_1.__exportStar(require("./create-nodes"), exports);
6
- exports.name = 'nx/core/package-json-workspaces';
@@ -1,3 +1,2 @@
1
- import { NxPluginV2 } from '../../../project-graph/plugins';
1
+ import { NxPluginV2 } from '../../../utils/nx-plugin';
2
2
  export declare const PackageJsonProjectsNextToProjectJsonPlugin: NxPluginV2;
3
- export default PackageJsonProjectsNextToProjectJsonPlugin;
@@ -24,7 +24,6 @@ exports.PackageJsonProjectsNextToProjectJsonPlugin = {
24
24
  },
25
25
  ],
26
26
  };
27
- exports.default = exports.PackageJsonProjectsNextToProjectJsonPlugin;
28
27
  function createProjectFromPackageJsonNextToProjectJson(projectJsonPath, workspaceRoot) {
29
28
  const root = (0, path_1.dirname)(projectJsonPath);
30
29
  const packageJsonPath = (0, path_1.join)(workspaceRoot, root, 'package.json');
@@ -1,5 +1,4 @@
1
1
  import { ProjectConfiguration } from '../../../config/workspace-json-project-json';
2
- import { NxPluginV2 } from '../../../project-graph/plugins';
2
+ import { NxPluginV2 } from '../../../utils/nx-plugin';
3
3
  export declare const ProjectJsonProjectsPlugin: NxPluginV2;
4
- export default ProjectJsonProjectsPlugin;
5
4
  export declare function buildProjectFromProjectJson(json: Partial<ProjectConfiguration>, path: string): ProjectConfiguration;
@@ -19,7 +19,6 @@ exports.ProjectJsonProjectsPlugin = {
19
19
  },
20
20
  ],
21
21
  };
22
- exports.default = exports.ProjectJsonProjectsPlugin;
23
22
  function buildProjectFromProjectJson(json, path) {
24
23
  return {
25
24
  name: (0, workspaces_1.toProjectName)(path),
@@ -1,5 +1,5 @@
1
1
  import { TargetConfiguration } from '../../config/workspace-json-project-json';
2
- import { NxPluginV2 } from '../../project-graph/plugins';
2
+ import { NxPluginV2 } from '../../utils/nx-plugin';
3
3
  /**
4
4
  * This marks that a target provides information which should modify a target already registered
5
5
  * on the project via other plugins. If the target has not already been registered, and this symbol is true,
@@ -18,7 +18,6 @@ export declare const ONLY_MODIFIES_EXISTING_TARGET = "NX_ONLY_MODIFIES_EXISTING_
18
18
  */
19
19
  export declare const OVERRIDE_SOURCE_FILE = "NX_OVERRIDE_SOURCE_FILE";
20
20
  export declare const TargetDefaultsPlugin: NxPluginV2;
21
- export default TargetDefaultsPlugin;
22
21
  /**
23
22
  * This fn gets target info that would make a target uniquely compatible
24
23
  * with what is described by project.json or package.json. As the merge process
@@ -87,7 +87,6 @@ exports.TargetDefaultsPlugin = {
87
87
  },
88
88
  ],
89
89
  };
90
- exports.default = exports.TargetDefaultsPlugin;
91
90
  function getExecutorToTargetMap(packageJsonTargets, projectJsonTargets) {
92
91
  const executorToTargetMap = new Map();
93
92
  const targets = Object.keys({
@@ -3,13 +3,14 @@ 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");
6
7
  const path_1 = require("path");
7
8
  const fs_1 = require("fs");
8
9
  const retrieve_workspace_files_1 = require("../../utils/retrieve-workspace-files");
9
- const internal_api_1 = require("../../plugins/internal-api");
10
+ const nx_plugin_1 = require("../../../utils/nx-plugin");
10
11
  const globs_1 = require("../../../utils/globs");
11
12
  const getTouchedProjectsFromProjectGlobChanges = async (touchedFiles, projectGraphNodes, nxJson) => {
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)));
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)));
13
14
  const touchedProjects = new Set();
14
15
  for (const touchedFile of touchedFiles) {
15
16
  const isProjectFile = (0, minimatch_1.minimatch)(touchedFile.file, globPattern, {
@@ -8,15 +8,14 @@ const assert_workspace_validity_1 = require("../utils/assert-workspace-validity"
8
8
  const nx_deps_cache_1 = require("./nx-deps-cache");
9
9
  const implicit_project_dependencies_1 = require("./utils/implicit-project-dependencies");
10
10
  const normalize_project_nodes_1 = require("./utils/normalize-project-nodes");
11
- const internal_api_1 = require("./plugins/internal-api");
12
- const utils_1 = require("./plugins/utils");
11
+ const nx_plugin_1 = require("../utils/nx-plugin");
13
12
  const typescript_1 = require("../plugins/js/utils/typescript");
14
13
  const fileutils_1 = require("../utils/fileutils");
15
14
  const project_graph_builder_1 = require("./project-graph-builder");
16
15
  const configuration_1 = require("../config/configuration");
17
16
  const fs_1 = require("fs");
17
+ const installation_directory_1 = require("../utils/installation-directory");
18
18
  const output_1 = require("../utils/output");
19
- const plugin_pool_1 = require("./plugins/plugin-pool");
20
19
  let storedFileMap = null;
21
20
  let storedAllWorkspaceFiles = null;
22
21
  let storedRustReferences = null;
@@ -71,7 +70,6 @@ async function buildProjectGraphUsingProjectFileMap(projects, externalNodes, fil
71
70
  if (shouldWriteCache) {
72
71
  (0, nx_deps_cache_1.writeCache)(projectFileMapCache, projectGraph);
73
72
  }
74
- await (0, plugin_pool_1.shutdownPluginWorkers)();
75
73
  return {
76
74
  projectGraph,
77
75
  projectFileMapCache,
@@ -142,11 +140,11 @@ function createContext(projects, nxJson, externalNodes, fileMap, filesToProcess)
142
140
  };
143
141
  }
144
142
  async function updateProjectGraphWithPlugins(context, initProjectGraph) {
145
- const plugins = await (0, internal_api_1.loadNxPlugins)(context.nxJsonConfiguration?.plugins, context.workspaceRoot);
143
+ const plugins = await (0, nx_plugin_1.loadNxPlugins)(context.nxJsonConfiguration?.plugins, (0, installation_directory_1.getNxRequirePaths)(), context.workspaceRoot, context.projects);
146
144
  let graph = initProjectGraph;
147
- for (const plugin of plugins) {
145
+ for (const { plugin } of plugins) {
148
146
  try {
149
- if ((0, utils_1.isNxPluginV1)(plugin) &&
147
+ if ((0, nx_plugin_1.isNxPluginV1)(plugin) &&
150
148
  plugin.processProjectGraph &&
151
149
  !plugin.createDependencies) {
152
150
  output_1.output.warn({
@@ -184,12 +182,11 @@ async function updateProjectGraphWithPlugins(context, initProjectGraph) {
184
182
  }
185
183
  }
186
184
  const builder = new project_graph_builder_1.ProjectGraphBuilder(graph, context.fileMap.projectFileMap, context.fileMap.nonProjectFiles);
187
- const createDependencyPlugins = plugins.filter((plugin) => (0, utils_1.isNxPluginV2)(plugin) && plugin.createDependencies);
188
- await Promise.all(createDependencyPlugins.map(async (plugin) => {
185
+ const createDependencyPlugins = plugins.filter(({ plugin }) => (0, nx_plugin_1.isNxPluginV2)(plugin) && plugin.createDependencies);
186
+ await Promise.all(createDependencyPlugins.map(async ({ plugin, options }) => {
189
187
  perf_hooks_1.performance.mark(`${plugin.name}:createDependencies - start`);
190
188
  try {
191
- // TODO: we shouldn't have to pass null here
192
- const dependencies = await plugin.createDependencies(null, {
189
+ const dependencies = await plugin.createDependencies(options, {
193
190
  ...context,
194
191
  });
195
192
  for (const dep of dependencies) {
@@ -147,23 +147,25 @@ Object.defineProperty(exports, "workspaceLayout", { enumerable: true, get: funct
147
147
  * TODO(v19): Remove this function.
148
148
  */
149
149
  function getProjectsSyncNoInference(root, nxJson) {
150
- const projectFiles = (0, retrieve_workspace_files_1.retrieveProjectConfigurationPaths)(root, (0, nx_plugin_deprecated_1.getDefaultPluginsSync)(root).map((p) => p.plugin));
150
+ const allConfigFiles = (0, retrieve_workspace_files_1.retrieveProjectConfigurationPaths)(root, (0, nx_plugin_deprecated_1.getDefaultPluginsSync)(root));
151
151
  const plugins = [
152
152
  { plugin: package_json_next_to_project_json_1.PackageJsonProjectsNextToProjectJsonPlugin },
153
153
  ...(0, nx_plugin_deprecated_1.getDefaultPluginsSync)(root),
154
154
  ];
155
155
  const projectRootMap = new Map();
156
156
  // We iterate over plugins first - this ensures that plugins specified first take precedence.
157
- for (const { plugin } of plugins) {
157
+ for (const { plugin, options } of plugins) {
158
158
  const [pattern, createNodes] = plugin.createNodes ?? [];
159
159
  if (!pattern) {
160
160
  continue;
161
161
  }
162
- for (const file of projectFiles) {
162
+ const matchingConfigFiles = allConfigFiles.filter((file) => (0, minimatch_1.minimatch)(file, pattern, { dot: true }));
163
+ for (const file of matchingConfigFiles) {
163
164
  if ((0, minimatch_1.minimatch)(file, pattern, { dot: true })) {
164
- let r = createNodes(file, {}, {
165
+ let r = createNodes(file, options, {
165
166
  nxJsonConfiguration: nxJson,
166
167
  workspaceRoot: root,
168
+ configFiles: matchingConfigFiles,
167
169
  });
168
170
  for (const node in r.projects) {
169
171
  const project = {
@@ -2,7 +2,7 @@
2
2
  * Builder for adding nodes and dependencies to a {@link ProjectGraph}
3
3
  */
4
4
  import { DependencyType, FileMap, ProjectFileMap, ProjectGraph, ProjectGraphExternalNode, ProjectGraphProjectNode } from '../config/project-graph';
5
- import { CreateDependenciesContext } from './plugins';
5
+ import { CreateDependenciesContext } from '../utils/nx-plugin';
6
6
  /**
7
7
  * A class which builds up a project graph
8
8
  * @deprecated The {@link ProjectGraphProcessor} has been deprecated. Use a {@link CreateNodes} and/or a {@link CreateDependencies} instead. This will be removed in Nx 19.
@@ -12,6 +12,7 @@ const workspace_root_1 = require("../utils/workspace-root");
12
12
  const perf_hooks_1 = require("perf_hooks");
13
13
  const retrieve_workspace_files_1 = require("./utils/retrieve-workspace-files");
14
14
  const nx_json_1 = require("../config/nx-json");
15
+ const nx_plugin_1 = require("../utils/nx-plugin");
15
16
  /**
16
17
  * Synchronously reads the latest cached copy of the workspace's ProjectGraph.
17
18
  * @throws {Error} if there is no cached ProjectGraph to read from
@@ -65,6 +66,7 @@ function readProjectsConfigurationFromProjectGraph(projectGraph) {
65
66
  }
66
67
  exports.readProjectsConfigurationFromProjectGraph = readProjectsConfigurationFromProjectGraph;
67
68
  async function buildProjectGraphAndSourceMapsWithoutDaemon() {
69
+ // Set this globally to allow plugins to know if they are being called from the project graph creation
68
70
  global.NX_GRAPH_CREATION = true;
69
71
  const nxJson = (0, nx_json_1.readNxJson)();
70
72
  perf_hooks_1.performance.mark('retrieve-project-configurations:start');
@@ -77,6 +79,7 @@ async function buildProjectGraphAndSourceMapsWithoutDaemon() {
77
79
  perf_hooks_1.performance.mark('build-project-graph-using-project-file-map:start');
78
80
  const projectGraph = (await (0, build_project_graph_1.buildProjectGraphUsingProjectFileMap)(projects, externalNodes, fileMap, allWorkspaceFiles, rustReferences, cacheEnabled ? (0, nx_deps_cache_1.readFileMapCache)() : null, cacheEnabled)).projectGraph;
79
81
  perf_hooks_1.performance.mark('build-project-graph-using-project-file-map:end');
82
+ (0, nx_plugin_1.unregisterPluginTSTranspiler)();
80
83
  delete global.NX_GRAPH_CREATION;
81
84
  return { projectGraph, sourceMaps };
82
85
  }
@@ -1,7 +1,7 @@
1
1
  import { ProjectGraphProjectNode } from '../../config/project-graph';
2
2
  import { ProjectGraphBuilder } from '../project-graph-builder';
3
3
  import { ProjectConfiguration, TargetConfiguration } from '../../config/workspace-json-project-json';
4
- import { CreateDependenciesContext } from '../plugins';
4
+ import { CreateDependenciesContext } from '../../utils/nx-plugin';
5
5
  export declare function normalizeProjectNodes(ctx: CreateDependenciesContext, builder: ProjectGraphBuilder): Promise<void>;
6
6
  /**
7
7
  * Apply target defaults and normalization
@@ -1,8 +1,8 @@
1
1
  import { NxJsonConfiguration, TargetDefaults } from '../../config/nx-json';
2
2
  import { ProjectGraphExternalNode } from '../../config/project-graph';
3
3
  import { ProjectConfiguration, TargetConfiguration } from '../../config/workspace-json-project-json';
4
+ import { LoadedNxPlugin } from '../../utils/nx-plugin';
4
5
  import { ONLY_MODIFIES_EXISTING_TARGET } from '../../plugins/target-defaults/target-defaults-plugin';
5
- import { RemotePlugin } from '../plugins/internal-api';
6
6
  export type SourceInformation = [file: string, plugin: string];
7
7
  export type ConfigurationSourceMaps = Record<string, Record<string, SourceInformation>>;
8
8
  export declare function mergeProjectConfigurationIntoRootMap(projectRootMap: Map<string, ProjectConfiguration>, project: ProjectConfiguration & {
@@ -20,12 +20,12 @@ export type ConfigurationResult = {
20
20
  * Transforms a list of project paths into a map of project configurations.
21
21
  *
22
22
  * @param nxJson The NxJson configuration
23
- * @param projectFiles A list of files identified as projects
23
+ * @param workspaceFiles A list of non-ignored workspace files
24
24
  * @param plugins The plugins that should be used to infer project configuration
25
25
  * @param root The workspace root
26
26
  */
27
- export declare function buildProjectsConfigurationsFromProjectPathsAndPlugins(nxJson: NxJsonConfiguration, projectFiles: string[], // making this parameter allows devkit to pick up newly created projects
28
- plugins: RemotePlugin[], root?: string): Promise<ConfigurationResult>;
27
+ export declare function buildProjectsConfigurationsFromProjectPathsAndPlugins(nxJson: NxJsonConfiguration, workspaceFiles: string[], // making this parameter allows devkit to pick up newly created projects
28
+ plugins: LoadedNxPlugin[], root?: string): Promise<ConfigurationResult>;
29
29
  export declare function readProjectConfigurationsFromRootMap(projectRootMap: Map<string, ProjectConfiguration>): Record<string, ProjectConfiguration>;
30
30
  /**
31
31
  * Merges two targets.