nx 19.0.0-beta.0 → 19.0.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/.eslintrc.json +1 -1
  2. package/migrations.json +2 -25
  3. package/package.json +12 -12
  4. package/src/command-line/add/add.js +17 -16
  5. package/src/command-line/affected/affected.js +1 -1
  6. package/src/command-line/graph/command-object.js +1 -1
  7. package/src/command-line/graph/graph.d.ts +11 -1
  8. package/src/command-line/graph/graph.js +97 -13
  9. package/src/command-line/init/implementation/react/index.js +1 -1
  10. package/src/command-line/release/changelog.js +1 -1
  11. package/src/command-line/release/command-object.js +2 -2
  12. package/src/command-line/release/publish.js +1 -1
  13. package/src/command-line/report/report.js +1 -1
  14. package/src/command-line/run/run-one.js +1 -1
  15. package/src/command-line/run-many/run-many.js +1 -1
  16. package/src/command-line/show/command-object.js +1 -5
  17. package/src/command-line/yargs-utils/shared-options.d.ts +3 -0
  18. package/src/command-line/yargs-utils/shared-options.js +16 -7
  19. package/src/config/nx-json.d.ts +2 -2
  20. package/src/config/to-project-name.d.ts +5 -0
  21. package/src/config/to-project-name.js +13 -0
  22. package/src/core/graph/index.html +1 -2
  23. package/src/core/graph/main.js +1 -1
  24. package/src/core/graph/runtime.js +1 -1
  25. package/src/core/graph/styles.css +2 -2
  26. package/src/core/graph/styles.js +1 -1
  27. package/src/daemon/client/client.d.ts +2 -2
  28. package/src/daemon/client/client.js +21 -6
  29. package/src/daemon/server/project-graph-incremental-recomputation.js +8 -8
  30. package/src/daemon/server/server.js +1 -4
  31. package/src/daemon/server/shutdown-utils.js +7 -2
  32. package/src/daemon/socket-utils.js +2 -14
  33. package/src/daemon/tmp-dir.js +2 -2
  34. package/src/devkit-exports.d.ts +1 -5
  35. package/src/devkit-exports.js +1 -7
  36. package/src/devkit-internals.d.ts +2 -0
  37. package/src/devkit-internals.js +5 -1
  38. package/src/executors/run-commands/run-commands.impl.d.ts +2 -0
  39. package/src/executors/run-commands/run-commands.impl.js +69 -15
  40. package/src/executors/run-commands/schema.json +19 -2
  41. package/src/executors/utils/convert-nx-executor.js +2 -1
  42. package/src/generators/testing-utils/create-tree-with-empty-workspace.js +7 -0
  43. package/src/generators/utils/project-configuration.js +3 -8
  44. package/src/hasher/task-hasher.d.ts +4 -4
  45. package/src/native/index.d.ts +1 -1
  46. package/src/plugins/js/lock-file/pnpm-parser.js +109 -67
  47. package/src/plugins/package-json-workspaces/create-nodes.d.ts +1 -0
  48. package/src/plugins/package-json-workspaces/create-nodes.js +25 -20
  49. package/src/plugins/project-json/build-nodes/project-json.js +2 -2
  50. package/src/project-graph/affected/locators/workspace-projects.js +3 -1
  51. package/src/project-graph/build-project-graph.d.ts +8 -18
  52. package/src/project-graph/build-project-graph.js +86 -57
  53. package/src/project-graph/error-types.d.ts +35 -3
  54. package/src/project-graph/error-types.js +84 -2
  55. package/src/project-graph/file-utils.d.ts +2 -3
  56. package/src/project-graph/file-utils.js +5 -9
  57. package/src/project-graph/plugins/internal-api.d.ts +3 -2
  58. package/src/project-graph/plugins/internal-api.js +3 -0
  59. package/src/project-graph/plugins/isolation/messaging.d.ts +34 -8
  60. package/src/project-graph/plugins/isolation/messaging.js +27 -10
  61. package/src/project-graph/plugins/isolation/plugin-pool.js +34 -15
  62. package/src/project-graph/plugins/isolation/plugin-worker.js +41 -4
  63. package/src/project-graph/plugins/loader.js +36 -24
  64. package/src/project-graph/plugins/public-api.d.ts +11 -1
  65. package/src/project-graph/plugins/utils.d.ts +2 -2
  66. package/src/project-graph/plugins/utils.js +19 -24
  67. package/src/project-graph/project-graph.d.ts +3 -0
  68. package/src/project-graph/project-graph.js +8 -7
  69. package/src/project-graph/utils/find-project-for-path.js +2 -3
  70. package/src/project-graph/utils/normalize-project-nodes.d.ts +1 -1
  71. package/src/project-graph/utils/normalize-project-nodes.js +8 -14
  72. package/src/project-graph/utils/project-configuration-utils.d.ts +23 -6
  73. package/src/project-graph/utils/project-configuration-utils.js +43 -20
  74. package/src/tasks-runner/create-task-graph.js +0 -1
  75. package/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.js +5 -1
  76. package/src/tasks-runner/life-cycles/dynamic-run-one-terminal-output-life-cycle.js +4 -0
  77. package/src/tasks-runner/pseudo-terminal.d.ts +2 -1
  78. package/src/tasks-runner/pseudo-terminal.js +8 -2
  79. package/src/tasks-runner/run-command.js +4 -4
  80. package/src/tasks-runner/utils.js +17 -0
  81. package/src/utils/assert-workspace-validity.js +2 -1
  82. package/src/utils/command-line-utils.d.ts +1 -1
  83. package/src/utils/nx-plugin.deprecated.d.ts +1 -1
  84. package/src/utils/nx-plugin.deprecated.js +1 -1
  85. package/src/utils/params.js +4 -0
  86. package/src/utils/perf-logging.js +3 -1
  87. package/src/utils/serializable-error.d.ts +4 -0
  88. package/src/utils/serializable-error.js +28 -0
  89. package/src/command-line/repair.d.ts +0 -4
  90. package/src/command-line/repair.js +0 -7
  91. package/src/command-line/run-many.d.ts +0 -4
  92. package/src/command-line/run-many.js +0 -7
  93. package/src/command-line/run-one.d.ts +0 -4
  94. package/src/command-line/run-one.js +0 -7
  95. package/src/command-line/run.d.ts +0 -4
  96. package/src/command-line/run.js +0 -7
  97. package/src/command-line/watch.d.ts +0 -4
  98. package/src/command-line/watch.js +0 -7
  99. package/src/config/workspaces.d.ts +0 -18
  100. package/src/config/workspaces.js +0 -35
  101. package/src/core/graph/3rdpartylicenses.txt +0 -785
  102. package/src/migrations/update-15-1-0/set-project-names.d.ts +0 -2
  103. package/src/migrations/update-15-1-0/set-project-names.js +0 -34
  104. package/src/migrations/update-15-8-2/update-nxw.d.ts +0 -2
  105. package/src/migrations/update-15-8-2/update-nxw.js +0 -7
  106. package/src/utils/typescript.d.ts +0 -1
  107. package/src/utils/typescript.js +0 -5
@@ -100,8 +100,15 @@
100
100
  },
101
101
  "args": {
102
102
  "oneOf": [
103
- { "type": "array", "items": { "type": "string" } },
104
- { "type": "string" }
103
+ {
104
+ "type": "array",
105
+ "items": {
106
+ "type": "string"
107
+ }
108
+ },
109
+ {
110
+ "type": "string"
111
+ }
105
112
  ],
106
113
  "description": "Extra arguments. You can pass them as follows: nx run project:target --args='--wait=100'. You can then use {args.wait} syntax to interpolate them in the workspace config file. See example [above](#chaining-commands-interpolating-args-and-setting-the-cwd)"
107
114
  },
@@ -135,6 +142,16 @@
135
142
  "$source": "unparsed"
136
143
  },
137
144
  "x-priority": "internal"
145
+ },
146
+ "forwardAllArgs": {
147
+ "type": "boolean",
148
+ "description": "Whether arguments should be forwarded when interpolation is not present.",
149
+ "default": true
150
+ },
151
+ "tty": {
152
+ "type": "boolean",
153
+ "description": "Whether commands should be run with a tty terminal",
154
+ "hidden": true
138
155
  }
139
156
  },
140
157
  "additionalProperties": true,
@@ -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 project_configuration_utils_1 = require("../../project-graph/utils/project-configuration-utils");
9
10
  const internal_api_1 = require("../../project-graph/plugins/internal-api");
10
11
  /**
11
12
  * Convert an Nx Executor into an Angular Devkit Builder
@@ -19,7 +20,7 @@ function convertNxExecutor(executor) {
19
20
  const [plugins, cleanup] = await (0, internal_api_1.loadNxPlugins)(nxJsonConfiguration.plugins, builderContext.workspaceRoot);
20
21
  const projectsConfigurations = {
21
22
  version: 2,
22
- projects: (await (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(plugins, builderContext.workspaceRoot, nxJsonConfiguration)).projects,
23
+ projects: (0, project_configuration_utils_1.readProjectConfigurationsFromRootMap)((await (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(plugins, builderContext.workspaceRoot, nxJsonConfiguration)).projects),
23
24
  };
24
25
  cleanup();
25
26
  const context = {
@@ -2,11 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createTreeWithEmptyV1Workspace = exports.createTreeWithEmptyWorkspace = void 0;
4
4
  const tree_1 = require("../tree");
5
+ const workspace_root_1 = require("../../utils/workspace-root");
5
6
  /**
6
7
  * Creates a host for testing.
7
8
  */
8
9
  function createTreeWithEmptyWorkspace(opts = {}) {
9
10
  const tree = new tree_1.FsTree('/virtual', false);
11
+ // Our unit tests are all written as though they are at the root of a workspace
12
+ // However, when they are run in a subdirectory of the workspaceRoot,
13
+ // the relative path between workspaceRoot and the directory the tests are run
14
+ // is prepended to the paths created in the virtual tree.
15
+ // Setting this envVar to workspaceRoot prevents this behaviour
16
+ process.env.INIT_CWD = workspace_root_1.workspaceRoot;
10
17
  return addCommonFiles(tree, opts.layout === 'apps-libs');
11
18
  }
12
19
  exports.createTreeWithEmptyWorkspace = createTreeWithEmptyWorkspace;
@@ -7,7 +7,6 @@ const package_json_workspaces_1 = require("../../plugins/package-json-workspaces
7
7
  const project_json_1 = require("../../plugins/project-json/build-nodes/project-json");
8
8
  const angular_json_1 = require("../../adapter/angular-json");
9
9
  const project_configuration_utils_1 = require("../../project-graph/utils/project-configuration-utils");
10
- const retrieve_workspace_files_1 = require("../../project-graph/utils/retrieve-workspace-files");
11
10
  const workspace_context_1 = require("../../utils/workspace-context");
12
11
  const output_1 = require("../../utils/output");
13
12
  const path_2 = require("../../utils/path");
@@ -135,15 +134,11 @@ function readAndCombineAllProjectConfigurations(tree) {
135
134
  'project.json',
136
135
  ...(0, package_json_workspaces_1.getGlobPatternsFromPackageManagerWorkspaces)(tree.root, (p) => (0, json_1.readJson)(tree, p, { expectComments: true })),
137
136
  ];
138
- const projectGlobPatterns = (0, retrieve_workspace_files_1.configurationGlobs)([
139
- project_json_1.ProjectJsonProjectsPlugin,
140
- { createNodes: package_json_workspaces_1.createNodes },
141
- ]);
142
- const globbedFiles = (0, workspace_context_1.globWithWorkspaceContext)(tree.root, projectGlobPatterns);
137
+ const globbedFiles = (0, workspace_context_1.globWithWorkspaceContext)(tree.root, patterns);
143
138
  const createdFiles = findCreatedProjectFiles(tree, patterns);
144
139
  const deletedFiles = findDeletedProjectFiles(tree, patterns);
145
140
  const projectFiles = [...globbedFiles, ...createdFiles].filter((r) => deletedFiles.indexOf(r) === -1);
146
- const rootMap = new Map();
141
+ const rootMap = {};
147
142
  for (const projectFile of projectFiles) {
148
143
  if ((0, path_1.basename)(projectFile) === 'project.json') {
149
144
  const json = (0, json_1.readJson)(tree, projectFile);
@@ -153,7 +148,7 @@ function readAndCombineAllProjectConfigurations(tree) {
153
148
  else if ((0, path_1.basename)(projectFile) === 'package.json') {
154
149
  const packageJson = (0, json_1.readJson)(tree, projectFile);
155
150
  const config = (0, package_json_workspaces_1.buildProjectConfigurationFromPackageJson)(packageJson, projectFile, (0, nx_json_1.readNxJson)(tree));
156
- if (!rootMap.has(config.root)) {
151
+ if (!rootMap[config.root]) {
157
152
  (0, project_configuration_utils_1.mergeProjectConfigurationIntoRootMap)(rootMap,
158
153
  // Inferred targets, tags, etc don't show up when running generators
159
154
  // This is to help avoid running into issues when trying to update the workspace
@@ -34,22 +34,22 @@ export interface Hash {
34
34
  }
35
35
  export interface TaskHasher {
36
36
  /**
37
- * @deprecated use hashTask(task:Task, taskGraph: TaskGraph, env: NodeJS.ProcessEnv) instead. This will be removed in v19
37
+ * @deprecated use hashTask(task:Task, taskGraph: TaskGraph, env: NodeJS.ProcessEnv) instead. This will be removed in v20
38
38
  * @param task
39
39
  */
40
40
  hashTask(task: Task): Promise<Hash>;
41
41
  /**
42
- * @deprecated use hashTask(task:Task, taskGraph: TaskGraph, env: NodeJS.ProcessEnv) instead. This will be removed in v19
42
+ * @deprecated use hashTask(task:Task, taskGraph: TaskGraph, env: NodeJS.ProcessEnv) instead. This will be removed in v20
43
43
  */
44
44
  hashTask(task: Task, taskGraph: TaskGraph): Promise<Hash>;
45
45
  hashTask(task: Task, taskGraph: TaskGraph, env: NodeJS.ProcessEnv): Promise<Hash>;
46
46
  /**
47
- * @deprecated use hashTasks(tasks:Task[], taskGraph: TaskGraph, env: NodeJS.ProcessEnv) instead. This will be removed in v19
47
+ * @deprecated use hashTasks(tasks:Task[], taskGraph: TaskGraph, env: NodeJS.ProcessEnv) instead. This will be removed in v20
48
48
  * @param tasks
49
49
  */
50
50
  hashTasks(tasks: Task[]): Promise<Hash[]>;
51
51
  /**
52
- * @deprecated use hashTasks(tasks:Task[], taskGraph: TaskGraph, env: NodeJS.ProcessEnv) instead. This will be removed in v19
52
+ * @deprecated use hashTasks(tasks:Task[], taskGraph: TaskGraph, env: NodeJS.ProcessEnv) instead. This will be removed in v20
53
53
  */
54
54
  hashTasks(tasks: Task[], taskGraph: TaskGraph): Promise<Hash[]>;
55
55
  hashTasks(tasks: Task[], taskGraph: TaskGraph, env: NodeJS.ProcessEnv): Promise<Hash[]>;
@@ -150,7 +150,7 @@ export class ChildProcess {
150
150
  }
151
151
  export class RustPseudoTerminal {
152
152
  constructor()
153
- runCommand(command: string, commandDir?: string | undefined | null, jsEnv?: Record<string, string> | undefined | null, quiet?: boolean | undefined | null): ChildProcess
153
+ runCommand(command: string, commandDir?: string | undefined | null, jsEnv?: Record<string, string> | undefined | null, quiet?: boolean | undefined | null, tty?: boolean | undefined | null): ChildProcess
154
154
  /**
155
155
  * This allows us to run a pseudoterminal with a fake node ipc channel
156
156
  * this makes it possible to be backwards compatible with the old implementation
@@ -33,39 +33,127 @@ function getPnpmLockfileDependencies(lockFileContent, lockFileHash, ctx) {
33
33
  return getDependencies(data, keyMap, isV6, ctx);
34
34
  }
35
35
  exports.getPnpmLockfileDependencies = getPnpmLockfileDependencies;
36
+ function matchPropValue(record, key, originalPackageName) {
37
+ if (!record) {
38
+ return undefined;
39
+ }
40
+ const index = Object.values(record).findIndex((version) => version === key);
41
+ if (index > -1) {
42
+ return Object.keys(record)[index];
43
+ }
44
+ // check if non-aliased name is found
45
+ if (record[originalPackageName] &&
46
+ key.startsWith(`/${originalPackageName}/${record[originalPackageName]}`)) {
47
+ return originalPackageName;
48
+ }
49
+ }
50
+ function matchedDependencyName(importer, key, originalPackageName) {
51
+ return (matchPropValue(importer.dependencies, key, originalPackageName) ||
52
+ matchPropValue(importer.optionalDependencies, key, originalPackageName) ||
53
+ matchPropValue(importer.peerDependencies, key, originalPackageName));
54
+ }
55
+ function createHashFromSnapshot(snapshot) {
56
+ return (snapshot.resolution?.['integrity'] ||
57
+ (snapshot.resolution?.['tarball']
58
+ ? (0, file_hasher_1.hashArray)([snapshot.resolution['tarball']])
59
+ : undefined));
60
+ }
61
+ function isLockFileKey(depVersion) {
62
+ return depVersion.startsWith('/');
63
+ }
36
64
  function getNodes(data, keyMap, isV6) {
37
65
  const nodes = new Map();
38
- Object.entries(data.packages).forEach(([key, snapshot]) => {
39
- findPackageNames(key, snapshot, data).forEach((packageName) => {
40
- const rawVersion = findVersion(key, packageName);
41
- const version = parseBaseVersion(rawVersion, isV6);
42
- // we don't need to keep duplicates, we can just track the keys
43
- const existingNode = nodes.get(packageName)?.get(version);
44
- if (existingNode) {
45
- keyMap.set(key, existingNode);
46
- return;
66
+ const maybeAliasedPackageVersions = new Map(); // <version, alias>
67
+ const packageNames = new Set();
68
+ for (const [key, snapshot] of Object.entries(data.packages)) {
69
+ const originalPackageName = extractNameFromKey(key);
70
+ if (!originalPackageName) {
71
+ continue;
72
+ }
73
+ // snapshot already has a name
74
+ if (snapshot.name) {
75
+ packageNames.add({
76
+ key,
77
+ packageName: snapshot.name,
78
+ hash: createHashFromSnapshot(snapshot),
79
+ });
80
+ }
81
+ const rootDependencyName = matchedDependencyName(data.importers['.'], key, originalPackageName) ||
82
+ // only root importers have devDependencies
83
+ matchPropValue(data.importers['.'].devDependencies, key, originalPackageName);
84
+ if (rootDependencyName) {
85
+ packageNames.add({
86
+ key,
87
+ packageName: rootDependencyName,
88
+ hash: createHashFromSnapshot(snapshot),
89
+ });
90
+ }
91
+ if (!snapshot.name && !rootDependencyName) {
92
+ packageNames.add({
93
+ key,
94
+ packageName: originalPackageName,
95
+ hash: createHashFromSnapshot(snapshot),
96
+ });
97
+ }
98
+ if (snapshot.peerDependencies) {
99
+ for (const [depName, depVersion] of Object.entries(snapshot.peerDependencies)) {
100
+ if (isLockFileKey(depVersion)) {
101
+ maybeAliasedPackageVersions.set(depVersion, depName);
102
+ }
103
+ }
104
+ }
105
+ if (snapshot.optionalDependencies) {
106
+ for (const [depName, depVersion] of Object.entries(snapshot.optionalDependencies)) {
107
+ if (isLockFileKey(depVersion)) {
108
+ maybeAliasedPackageVersions.set(depVersion, depName);
109
+ }
47
110
  }
111
+ }
112
+ if (snapshot.dependencies) {
113
+ for (const [depName, depVersion] of Object.entries(snapshot.dependencies)) {
114
+ if (isLockFileKey(depVersion)) {
115
+ maybeAliasedPackageVersions.set(depVersion, depName);
116
+ }
117
+ }
118
+ }
119
+ const aliasedDep = maybeAliasedPackageVersions.get(key);
120
+ if (aliasedDep) {
121
+ packageNames.add({
122
+ key,
123
+ packageName: aliasedDep,
124
+ hash: createHashFromSnapshot(snapshot),
125
+ });
126
+ }
127
+ }
128
+ for (const { key, packageName, hash } of packageNames) {
129
+ const rawVersion = findVersion(key, packageName);
130
+ if (!rawVersion) {
131
+ continue;
132
+ }
133
+ const version = parseBaseVersion(rawVersion, isV6);
134
+ if (!version) {
135
+ continue;
136
+ }
137
+ if (!nodes.has(packageName)) {
138
+ nodes.set(packageName, new Map());
139
+ }
140
+ if (!nodes.get(packageName).has(version)) {
48
141
  const node = {
49
142
  type: 'npm',
50
143
  name: version ? `npm:${packageName}@${version}` : `npm:${packageName}`,
51
144
  data: {
52
145
  version,
53
146
  packageName,
54
- hash: snapshot.resolution?.['integrity'] ||
55
- (0, file_hasher_1.hashArray)(snapshot.resolution?.['tarball']
56
- ? [snapshot.resolution['tarball']]
57
- : [packageName, version]),
147
+ hash: hash ?? (0, file_hasher_1.hashArray)([packageName, version]),
58
148
  },
59
149
  };
150
+ nodes.get(packageName).set(version, node);
60
151
  keyMap.set(key, node);
61
- if (!nodes.has(packageName)) {
62
- nodes.set(packageName, new Map([[version, node]]));
63
- }
64
- else {
65
- nodes.get(packageName).set(version, node);
66
- }
67
- });
68
- });
152
+ }
153
+ else {
154
+ keyMap.set(key, nodes.get(packageName).get(version));
155
+ }
156
+ }
69
157
  const hoistedDeps = (0, pnpm_normalizer_1.loadPnpmHoistedDepsDefinition)();
70
158
  const results = {};
71
159
  for (const [packageName, versionMap] of nodes.entries()) {
@@ -228,52 +316,6 @@ function findVersion(key, packageName) {
228
316
  // for tarball package the entire key is the version spec
229
317
  return key;
230
318
  }
231
- function findPackageNames(key, snapshot, data) {
232
- const packageNames = new Set();
233
- const originalPackageName = extractNameFromKey(key);
234
- const matchPropValue = (record) => {
235
- if (!record) {
236
- return undefined;
237
- }
238
- const index = Object.values(record).findIndex((version) => version === key);
239
- if (index > -1) {
240
- return Object.keys(record)[index];
241
- }
242
- // check if non aliased name is found
243
- if (record[originalPackageName] &&
244
- key.startsWith(`/${originalPackageName}/${record[originalPackageName]}`)) {
245
- return originalPackageName;
246
- }
247
- };
248
- const matchedDependencyName = (importer) => {
249
- return (matchPropValue(importer.dependencies) ||
250
- matchPropValue(importer.optionalDependencies) ||
251
- matchPropValue(importer.peerDependencies));
252
- };
253
- // snapshot already has a name
254
- if (snapshot.name) {
255
- packageNames.add(snapshot.name);
256
- }
257
- // it'a a root dependency
258
- const rootDependencyName = matchedDependencyName(data.importers['.']) ||
259
- // only root importers have devDependencies
260
- matchPropValue(data.importers['.'].devDependencies);
261
- if (rootDependencyName) {
262
- packageNames.add(rootDependencyName);
263
- }
264
- // find a snapshot that has a dependency that points to this snapshot
265
- const snapshots = Object.values(data.packages);
266
- for (let i = 0; i < snapshots.length; i++) {
267
- const dependencyName = matchedDependencyName(snapshots[i]);
268
- if (dependencyName) {
269
- packageNames.add(dependencyName);
270
- }
271
- }
272
- if (packageNames.size === 0) {
273
- packageNames.add(originalPackageName);
274
- }
275
- return Array.from(packageNames);
276
- }
277
319
  function getVersion(key, packageName) {
278
320
  const KEY_NAME_SEPARATOR_LENGTH = 2; // leading and trailing slash
279
321
  return key.slice(packageName.length + KEY_NAME_SEPARATOR_LENGTH);
@@ -3,6 +3,7 @@ import { ProjectConfiguration } from '../../config/workspace-json-project-json';
3
3
  import { PackageJson } from '../../utils/package-json';
4
4
  import { CreateNodes } from '../../project-graph/plugins';
5
5
  export declare const createNodes: CreateNodes;
6
+ export declare function buildPackageJsonWorkspacesMatcher(workspaceRoot: string, readJson: (string: any) => any): (p: string) => boolean;
6
7
  export declare function createNodeFromPackageJson(pkgJsonPath: string, root: string): {
7
8
  projects: {
8
9
  [x: string]: ProjectConfiguration & {
@@ -1,41 +1,46 @@
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.buildPackageJsonWorkspacesMatcher = 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");
7
7
  const nx_json_1 = require("../../config/nx-json");
8
- const workspaces_1 = require("../../config/workspaces");
8
+ const to_project_name_1 = require("../../config/to-project-name");
9
9
  const fileutils_1 = require("../../utils/fileutils");
10
10
  const globs_1 = require("../../utils/globs");
11
11
  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');
28
- }
29
15
  exports.createNodes = [
30
- (0, globs_1.combineGlobPatterns)(positivePatterns),
16
+ (0, globs_1.combineGlobPatterns)('package.json', '**/package.json'),
31
17
  (p, _, { workspaceRoot }) => {
32
- if (!negativePatterns.some((negative) => (0, minimatch_1.minimatch)(p, negative))) {
18
+ const readJson = (f) => (0, fileutils_1.readJsonFile)((0, node_path_1.join)(workspaceRoot, f));
19
+ const matcher = buildPackageJsonWorkspacesMatcher(workspaceRoot, readJson);
20
+ if (matcher(p)) {
33
21
  return createNodeFromPackageJson(p, workspaceRoot);
34
22
  }
35
- // A negative pattern matched, so we should not create a node for this package.json
23
+ // The given package.json is not part of the workspaces configuration.
36
24
  return {};
37
25
  },
38
26
  ];
27
+ function buildPackageJsonWorkspacesMatcher(workspaceRoot, readJson) {
28
+ const patterns = getGlobPatternsFromPackageManagerWorkspaces(workspaceRoot, readJson);
29
+ const negativePatterns = patterns.filter((p) => p.startsWith('!'));
30
+ const positivePatterns = patterns.filter((p) => !p.startsWith('!'));
31
+ if (
32
+ // There are some negative patterns
33
+ negativePatterns.length > 0 &&
34
+ // No positive patterns
35
+ (positivePatterns.length === 0 ||
36
+ // Or only a single positive pattern that is the default coming from root package
37
+ (positivePatterns.length === 1 && positivePatterns[0] === 'package.json'))) {
38
+ positivePatterns.push('**/package.json');
39
+ }
40
+ return (p) => positivePatterns.some((positive) => (0, minimatch_1.minimatch)(p, positive)) &&
41
+ !negativePatterns.some((negative) => (0, minimatch_1.minimatch)(p, negative));
42
+ }
43
+ exports.buildPackageJsonWorkspacesMatcher = buildPackageJsonWorkspacesMatcher;
39
44
  function createNodeFromPackageJson(pkgJsonPath, root) {
40
45
  const json = (0, fileutils_1.readJsonFile)((0, node_path_1.join)(root, pkgJsonPath));
41
46
  const project = buildProjectConfigurationFromPackageJson(json, pkgJsonPath, (0, nx_json_1.readNxJson)(root));
@@ -52,7 +57,7 @@ function buildProjectConfigurationFromPackageJson(packageJson, path, nxJson) {
52
57
  if (!packageJson.name && directory === '.') {
53
58
  throw new Error('Nx requires the root package.json to specify a name if it is being used as an Nx project.');
54
59
  }
55
- let name = packageJson.name ?? (0, workspaces_1.toProjectName)(normalizedPath);
60
+ let name = packageJson.name ?? (0, to_project_name_1.toProjectName)(normalizedPath);
56
61
  const projectType = nxJson?.workspaceLayout?.appsDir != nxJson?.workspaceLayout?.libsDir &&
57
62
  nxJson?.workspaceLayout?.appsDir &&
58
63
  directory.startsWith(nxJson.workspaceLayout.appsDir)
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.buildProjectFromProjectJson = exports.ProjectJsonProjectsPlugin = void 0;
4
4
  const node_path_1 = require("node:path");
5
- const workspaces_1 = require("../../../config/workspaces");
5
+ const to_project_name_1 = require("../../../config/to-project-name");
6
6
  const fileutils_1 = require("../../../utils/fileutils");
7
7
  exports.ProjectJsonProjectsPlugin = {
8
8
  name: 'nx/core/project-json',
@@ -22,7 +22,7 @@ exports.ProjectJsonProjectsPlugin = {
22
22
  exports.default = exports.ProjectJsonProjectsPlugin;
23
23
  function buildProjectFromProjectJson(json, path) {
24
24
  return {
25
- name: (0, workspaces_1.toProjectName)(path),
25
+ name: (0, to_project_name_1.toProjectName)(path),
26
26
  root: (0, node_path_1.dirname)(path),
27
27
  ...json,
28
28
  };
@@ -15,7 +15,9 @@ const getTouchedProjects = (touchedFiles, projectGraphNodes) => {
15
15
  };
16
16
  exports.getTouchedProjects = getTouchedProjects;
17
17
  const getImplicitlyTouchedProjects = (fileChanges, projectGraphNodes, nxJson) => {
18
- const implicits = {};
18
+ const implicits = {
19
+ 'nx.json': '*',
20
+ };
19
21
  Object.values(projectGraphNodes || {}).forEach((node) => {
20
22
  const namedInputs = {
21
23
  ...nxJson.namedInputs,
@@ -1,32 +1,22 @@
1
1
  import { FileData } from './file-utils';
2
2
  import { FileMapCache } from './nx-deps-cache';
3
3
  import { LoadedNxPlugin } from './plugins/internal-api';
4
+ import { CreateMetadataContext } from './plugins';
4
5
  import { FileMap, ProjectGraph, ProjectGraphExternalNode } from '../config/project-graph';
5
6
  import { ProjectConfiguration } from '../config/workspace-json-project-json';
6
7
  import { NxWorkspaceFilesExternals } from '../native';
8
+ import { CreateMetadataError } from './error-types';
9
+ import { ConfigurationSourceMaps } from './utils/project-configuration-utils';
7
10
  export declare function getFileMap(): {
8
11
  fileMap: FileMap;
9
12
  allWorkspaceFiles: FileData[];
10
13
  rustReferences: NxWorkspaceFilesExternals | null;
11
14
  };
12
- export declare function buildProjectGraphUsingProjectFileMap(projects: Record<string, ProjectConfiguration>, externalNodes: Record<string, ProjectGraphExternalNode>, fileMap: FileMap, allWorkspaceFiles: FileData[], rustReferences: NxWorkspaceFilesExternals, fileMapCache: FileMapCache | null, plugins: LoadedNxPlugin[]): Promise<{
15
+ export declare function buildProjectGraphUsingProjectFileMap(projectRootMap: Record<string, ProjectConfiguration>, externalNodes: Record<string, ProjectGraphExternalNode>, fileMap: FileMap, allWorkspaceFiles: FileData[], rustReferences: NxWorkspaceFilesExternals, fileMapCache: FileMapCache | null, plugins: LoadedNxPlugin[], sourceMap: ConfigurationSourceMaps): Promise<{
13
16
  projectGraph: ProjectGraph;
14
17
  projectFileMapCache: FileMapCache;
15
18
  }>;
16
- export declare class ProcessDependenciesError extends Error {
17
- readonly pluginName: string;
18
- constructor(pluginName: string, { cause }: {
19
- cause: any;
20
- });
21
- }
22
- export declare class ProcessProjectGraphError extends Error {
23
- readonly pluginName: string;
24
- constructor(pluginName: string, { cause }: {
25
- cause: any;
26
- });
27
- }
28
- export declare class CreateDependenciesError extends Error {
29
- readonly errors: Array<ProcessDependenciesError | ProcessProjectGraphError>;
30
- readonly partialProjectGraph: ProjectGraph;
31
- constructor(errors: Array<ProcessDependenciesError | ProcessProjectGraphError>, partialProjectGraph: ProjectGraph);
32
- }
19
+ export declare function applyProjectMetadata(graph: ProjectGraph, plugins: LoadedNxPlugin[], context: CreateMetadataContext, sourceMap: ConfigurationSourceMaps): Promise<{
20
+ graph: ProjectGraph;
21
+ errors?: CreateMetadataError[];
22
+ }>;