nx 16.7.0 → 16.8.0-beta.0

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 (54) hide show
  1. package/package.json +13 -13
  2. package/plugins/package-json-workspaces.d.ts +9 -3
  3. package/plugins/package-json-workspaces.js +14 -15
  4. package/plugins/package-json.d.ts +1 -1
  5. package/plugins/package-json.js +10 -2
  6. package/plugins/project-json.d.ts +4 -1
  7. package/plugins/project-json.js +38 -1
  8. package/schemas/nx-schema.json +1 -1
  9. package/schemas/project-schema.json +1 -1
  10. package/src/adapter/angular-json.d.ts +4 -6
  11. package/src/adapter/angular-json.js +11 -15
  12. package/src/command-line/examples.js +2 -2
  13. package/src/command-line/format/format.js +10 -1
  14. package/src/command-line/init/implementation/angular/standalone-workspace.js +6 -1
  15. package/src/command-line/show/command-object.js +1 -1
  16. package/src/config/calculate-default-project-name.d.ts +1 -3
  17. package/src/config/configuration.d.ts +0 -6
  18. package/src/config/configuration.js +1 -11
  19. package/src/config/workspaces.d.ts +5 -13
  20. package/src/config/workspaces.js +8 -42
  21. package/src/daemon/server/project-graph-incremental-recomputation.js +3 -4
  22. package/src/devkit-exports.d.ts +2 -2
  23. package/src/devkit-exports.js +3 -2
  24. package/src/devkit-internals.d.ts +6 -0
  25. package/src/devkit-internals.js +13 -1
  26. package/src/executors/utils/convert-nx-executor.js +5 -3
  27. package/src/generators/utils/project-configuration.js +5 -6
  28. package/src/hasher/task-hasher.js +1 -0
  29. package/src/plugins/js/index.js +6 -2
  30. package/src/plugins/js/lock-file/yarn-parser.js +17 -9
  31. package/src/project-graph/build-nodes/workspace-projects.js +1 -35
  32. package/src/project-graph/build-project-graph.d.ts +2 -2
  33. package/src/project-graph/build-project-graph.js +12 -9
  34. package/src/project-graph/file-utils.d.ts +5 -1
  35. package/src/project-graph/file-utils.js +13 -6
  36. package/src/project-graph/nx-deps-cache.d.ts +2 -2
  37. package/src/project-graph/nx-deps-cache.js +1 -1
  38. package/src/project-graph/project-graph.d.ts +4 -1
  39. package/src/project-graph/project-graph.js +5 -2
  40. package/src/project-graph/utils/project-configuration-utils.d.ts +2 -1
  41. package/src/project-graph/utils/project-configuration-utils.js +58 -37
  42. package/src/project-graph/utils/retrieve-workspace-files.d.ts +11 -0
  43. package/src/project-graph/utils/retrieve-workspace-files.js +35 -12
  44. package/src/tasks-runner/life-cycles/task-profiling-life-cycle.js +2 -3
  45. package/src/utils/assert-workspace-validity.d.ts +2 -2
  46. package/src/utils/assert-workspace-validity.js +3 -4
  47. package/src/utils/nx-plugin.d.ts +0 -1
  48. package/src/utils/nx-plugin.js +7 -0
  49. package/src/utils/package-json.d.ts +1 -0
  50. package/src/utils/package-json.js +11 -1
  51. package/src/utils/package-manager.js +1 -3
  52. package/src/utils/project-graph-utils.d.ts +0 -2
  53. package/src/utils/project-graph-utils.js +1 -21
  54. package/src/utils/testing/mock-fs.js +12 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "16.7.0",
3
+ "version": "16.8.0-beta.0",
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": {
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "homepage": "https://nx.dev",
34
34
  "dependencies": {
35
- "@nrwl/tao": "16.7.0",
35
+ "@nrwl/tao": "16.8.0-beta.0",
36
36
  "@parcel/watcher": "2.0.4",
37
37
  "@yarnpkg/lockfile": "^1.1.0",
38
38
  "@yarnpkg/parsers": "3.0.0-rc.46",
@@ -81,16 +81,16 @@
81
81
  }
82
82
  },
83
83
  "optionalDependencies": {
84
- "@nx/nx-darwin-arm64": "16.7.0",
85
- "@nx/nx-darwin-x64": "16.7.0",
86
- "@nx/nx-freebsd-x64": "16.7.0",
87
- "@nx/nx-linux-arm-gnueabihf": "16.7.0",
88
- "@nx/nx-linux-arm64-gnu": "16.7.0",
89
- "@nx/nx-linux-arm64-musl": "16.7.0",
90
- "@nx/nx-linux-x64-gnu": "16.7.0",
91
- "@nx/nx-linux-x64-musl": "16.7.0",
92
- "@nx/nx-win32-arm64-msvc": "16.7.0",
93
- "@nx/nx-win32-x64-msvc": "16.7.0"
84
+ "@nx/nx-darwin-arm64": "16.8.0-beta.0",
85
+ "@nx/nx-darwin-x64": "16.8.0-beta.0",
86
+ "@nx/nx-freebsd-x64": "16.8.0-beta.0",
87
+ "@nx/nx-linux-arm-gnueabihf": "16.8.0-beta.0",
88
+ "@nx/nx-linux-arm64-gnu": "16.8.0-beta.0",
89
+ "@nx/nx-linux-arm64-musl": "16.8.0-beta.0",
90
+ "@nx/nx-linux-x64-gnu": "16.8.0-beta.0",
91
+ "@nx/nx-linux-x64-musl": "16.8.0-beta.0",
92
+ "@nx/nx-win32-arm64-msvc": "16.8.0-beta.0",
93
+ "@nx/nx-win32-x64-msvc": "16.8.0-beta.0"
94
94
  },
95
95
  "nx-migrations": {
96
96
  "migrations": "./migrations.json",
@@ -177,5 +177,5 @@
177
177
  },
178
178
  "main": "./bin/nx.js",
179
179
  "type": "commonjs",
180
- "gitHead": "37fd20b7063be8fe23a45892f5a21c2703bc53a6"
180
+ "gitHead": "818352404283c1d34ab303d91b3bd16474f54916"
181
181
  }
@@ -1,10 +1,16 @@
1
1
  import { NxJsonConfiguration } from '../src/config/nx-json';
2
2
  import { ProjectConfiguration } from '../src/config/workspace-json-project-json';
3
3
  import { NxPluginV2 } from '../src/utils/nx-plugin';
4
+ import { PackageJson } from '../src/utils/package-json';
4
5
  export declare function getNxPackageJsonWorkspacesPlugin(root: string): NxPluginV2;
5
- export declare function buildProjectConfigurationFromPackageJson(packageJson: {
6
- name: string;
7
- }, path: string, nxJson: NxJsonConfiguration): ProjectConfiguration & {
6
+ export declare function createNodeFromPackageJson(pkgJsonPath: string, root: string): {
7
+ projects: {
8
+ [x: string]: ProjectConfiguration & {
9
+ name: string;
10
+ };
11
+ };
12
+ };
13
+ export declare function buildProjectConfigurationFromPackageJson(packageJson: PackageJson, path: string, nxJson: NxJsonConfiguration): ProjectConfiguration & {
8
14
  name: string;
9
15
  };
10
16
  /**
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getGlobPatternsFromPackageManagerWorkspaces = exports.buildProjectConfigurationFromPackageJson = exports.getNxPackageJsonWorkspacesPlugin = void 0;
3
+ exports.getGlobPatternsFromPackageManagerWorkspaces = exports.buildProjectConfigurationFromPackageJson = exports.createNodeFromPackageJson = exports.getNxPackageJsonWorkspacesPlugin = void 0;
4
4
  const node_fs_1 = require("node:fs");
5
5
  const node_path_1 = require("node:path");
6
6
  const nx_json_1 = require("../src/config/nx-json");
@@ -9,6 +9,7 @@ const fileutils_1 = require("../src/utils/fileutils");
9
9
  const globs_1 = require("../src/utils/globs");
10
10
  const logger_1 = require("../src/utils/logger");
11
11
  const output_1 = require("../src/utils/output");
12
+ const package_json_1 = require("../src/utils/package-json");
12
13
  const path_1 = require("../src/utils/path");
13
14
  function getNxPackageJsonWorkspacesPlugin(root) {
14
15
  const readJson = (f) => (0, fileutils_1.readJsonFile)((0, node_path_1.join)(root, f));
@@ -16,18 +17,20 @@ function getNxPackageJsonWorkspacesPlugin(root) {
16
17
  name: 'nx-core-build-package-json-nodes',
17
18
  createNodes: [
18
19
  (0, globs_1.combineGlobPatterns)(getGlobPatternsFromPackageManagerWorkspaces(root, readJson)),
19
- (pkgJsonPath) => {
20
- const json = readJson(pkgJsonPath);
21
- return {
22
- projects: {
23
- [json.name]: buildProjectConfigurationFromPackageJson(json, pkgJsonPath, (0, nx_json_1.readNxJson)(root)),
24
- },
25
- };
26
- },
20
+ (p) => createNodeFromPackageJson(p, root),
27
21
  ],
28
22
  };
29
23
  }
30
24
  exports.getNxPackageJsonWorkspacesPlugin = getNxPackageJsonWorkspacesPlugin;
25
+ function createNodeFromPackageJson(pkgJsonPath, root) {
26
+ const json = (0, fileutils_1.readJsonFile)((0, node_path_1.join)(root, pkgJsonPath));
27
+ return {
28
+ projects: {
29
+ [json.name]: buildProjectConfigurationFromPackageJson(json, pkgJsonPath, (0, nx_json_1.readNxJson)(root)),
30
+ },
31
+ };
32
+ }
33
+ exports.createNodeFromPackageJson = createNodeFromPackageJson;
31
34
  function buildProjectConfigurationFromPackageJson(packageJson, path, nxJson) {
32
35
  var _a, _b, _c, _d;
33
36
  const normalizedPath = path.split('\\').join('/');
@@ -47,12 +50,8 @@ function buildProjectConfigurationFromPackageJson(packageJson, path, nxJson) {
47
50
  directory.startsWith(nxJson.workspaceLayout.appsDir)
48
51
  ? 'application'
49
52
  : 'library';
50
- return {
51
- root: directory,
52
- sourceRoot: directory,
53
- name,
54
- projectType,
55
- };
53
+ return Object.assign(Object.assign({ root: directory, sourceRoot: directory, name,
54
+ projectType }, packageJson.nx), { targets: (0, package_json_1.readTargetsFromPackageJson)(packageJson) });
56
55
  }
57
56
  exports.buildProjectConfigurationFromPackageJson = buildProjectConfigurationFromPackageJson;
58
57
  /**
@@ -1 +1 @@
1
- export declare const projectFilePatterns: string[];
1
+ export {};
@@ -1,4 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.projectFilePatterns = void 0;
4
- exports.projectFilePatterns = ['package.json'];
3
+ const workspace_root_1 = require("../src/utils/workspace-root");
4
+ const package_json_workspaces_1 = require("./package-json-workspaces");
5
+ const plugin = {
6
+ name: 'nx-all-package-jsons-plugin',
7
+ createNodes: [
8
+ '*/**/package.json',
9
+ (f) => (0, package_json_workspaces_1.createNodeFromPackageJson)(f, workspace_root_1.workspaceRoot),
10
+ ],
11
+ };
12
+ module.exports = plugin;
@@ -1,4 +1,7 @@
1
- import { ProjectConfiguration } from '../src/config/workspace-json-project-json';
1
+ import { ProjectConfiguration, TargetConfiguration } from '../src/config/workspace-json-project-json';
2
2
  import { NxPluginV2 } from '../src/utils/nx-plugin';
3
+ import { PackageJson } from '../src/utils/package-json';
3
4
  export declare function getNxProjectJsonPlugin(root: string): NxPluginV2;
4
5
  export declare function buildProjectFromProjectJson(json: Partial<ProjectConfiguration>, path: string): ProjectConfiguration;
6
+ export declare function mergePackageJsonConfigurationWithProjectJson(p: ProjectConfiguration, root: string): void;
7
+ export declare function mergeNpmScriptsWithTargets(packageJson: PackageJson, targets: Record<string, TargetConfiguration>): Record<string, TargetConfiguration>;
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildProjectFromProjectJson = exports.getNxProjectJsonPlugin = void 0;
3
+ exports.mergeNpmScriptsWithTargets = exports.mergePackageJsonConfigurationWithProjectJson = exports.buildProjectFromProjectJson = exports.getNxProjectJsonPlugin = void 0;
4
4
  const node_path_1 = require("node:path");
5
+ const node_fs_1 = require("node:fs");
5
6
  const workspaces_1 = require("../src/config/workspaces");
6
7
  const fileutils_1 = require("../src/utils/fileutils");
8
+ const package_json_1 = require("../src/utils/package-json");
7
9
  function getNxProjectJsonPlugin(root) {
8
10
  return {
9
11
  name: 'nx-core-build-project-json-nodes',
@@ -12,6 +14,7 @@ function getNxProjectJsonPlugin(root) {
12
14
  (file) => {
13
15
  const json = (0, fileutils_1.readJsonFile)((0, node_path_1.join)(root, file));
14
16
  const project = buildProjectFromProjectJson(json, file);
17
+ mergePackageJsonConfigurationWithProjectJson(project, root);
15
18
  return {
16
19
  projects: {
17
20
  [project.name]: project,
@@ -26,3 +29,37 @@ function buildProjectFromProjectJson(json, path) {
26
29
  return Object.assign({ name: (0, workspaces_1.toProjectName)(path), root: (0, node_path_1.dirname)(path) }, json);
27
30
  }
28
31
  exports.buildProjectFromProjectJson = buildProjectFromProjectJson;
32
+ function mergePackageJsonConfigurationWithProjectJson(p, root) {
33
+ if ((0, node_fs_1.existsSync)((0, node_path_1.join)(root, p.root, 'package.json'))) {
34
+ try {
35
+ const packageJson = (0, fileutils_1.readJsonFile)((0, node_path_1.join)(root, p.root, 'package.json'));
36
+ p.targets = mergeNpmScriptsWithTargets(packageJson, p.targets);
37
+ const { nx } = packageJson;
38
+ if (nx === null || nx === void 0 ? void 0 : nx.tags) {
39
+ p.tags = [...(p.tags || []), ...nx.tags];
40
+ }
41
+ if (nx === null || nx === void 0 ? void 0 : nx.implicitDependencies) {
42
+ p.implicitDependencies = [
43
+ ...(p.implicitDependencies || []),
44
+ ...nx.implicitDependencies,
45
+ ];
46
+ }
47
+ if (nx === null || nx === void 0 ? void 0 : nx.namedInputs) {
48
+ p.namedInputs = Object.assign(Object.assign({}, (p.namedInputs || {})), nx.namedInputs);
49
+ }
50
+ }
51
+ catch (e) {
52
+ // ignore json parser errors
53
+ }
54
+ }
55
+ }
56
+ exports.mergePackageJsonConfigurationWithProjectJson = mergePackageJsonConfigurationWithProjectJson;
57
+ function mergeNpmScriptsWithTargets(packageJson, targets) {
58
+ try {
59
+ return Object.assign(Object.assign({}, (0, package_json_1.readTargetsFromPackageJson)(packageJson)), (targets || {}));
60
+ }
61
+ catch (e) {
62
+ return targets;
63
+ }
64
+ }
65
+ exports.mergeNpmScriptsWithTargets = mergeNpmScriptsWithTargets;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema",
3
- "$id": "https://nx.dev/core-concepts/configuration#nxjson",
3
+ "$id": "https://nx.dev/reference/nx-json",
4
4
  "title": "JSON schema for Nx configuration",
5
5
  "type": "object",
6
6
  "properties": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema",
3
- "$id": "https://nx.dev/project-schema",
3
+ "$id": "https://nx.dev/reference/project-configuration",
4
4
  "title": "JSON schema for Nx projects",
5
5
  "type": "object",
6
6
  "properties": {
@@ -1,11 +1,9 @@
1
- import { ProjectConfiguration, ProjectsConfigurations } from '../config/workspace-json-project-json';
1
+ import { ProjectsConfigurations } from '../config/workspace-json-project-json';
2
+ import { NxPluginV2 } from '../devkit-exports';
3
+ export declare const NX_ANGULAR_JSON_PLUGIN_NAME = "nx-angular-json-plugin";
4
+ export declare const NxAngularJsonPlugin: NxPluginV2;
2
5
  export declare function shouldMergeAngularProjects(root: string, includeProjectsFromAngularJson: boolean): boolean;
3
6
  export declare function isAngularPluginInstalled(): boolean;
4
- export declare function mergeAngularJsonAndProjects(projects: {
5
- [name: string]: ProjectConfiguration;
6
- }, angularCliWorkspaceRoot: string): {
7
- [name: string]: ProjectConfiguration;
8
- };
9
7
  export declare function toNewFormat(w: any): ProjectsConfigurations;
10
8
  export declare function toOldFormat(w: any): any;
11
9
  export declare function renamePropertyWithStableKeys(obj: any, from: string, to: string): void;
@@ -1,9 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.renamePropertyWithStableKeys = exports.toOldFormat = exports.toNewFormat = exports.mergeAngularJsonAndProjects = exports.isAngularPluginInstalled = exports.shouldMergeAngularProjects = void 0;
3
+ exports.renamePropertyWithStableKeys = exports.toOldFormat = exports.toNewFormat = exports.isAngularPluginInstalled = exports.shouldMergeAngularProjects = exports.NxAngularJsonPlugin = exports.NX_ANGULAR_JSON_PLUGIN_NAME = void 0;
4
4
  const fs_1 = require("fs");
5
5
  const path = require("path");
6
6
  const fileutils_1 = require("../utils/fileutils");
7
+ exports.NX_ANGULAR_JSON_PLUGIN_NAME = 'nx-angular-json-plugin';
8
+ exports.NxAngularJsonPlugin = {
9
+ name: exports.NX_ANGULAR_JSON_PLUGIN_NAME,
10
+ createNodes: [
11
+ 'angular.json',
12
+ (f, ctx) => ({
13
+ projects: readAngularJson(ctx.workspaceRoot),
14
+ }),
15
+ ],
16
+ };
7
17
  function shouldMergeAngularProjects(root, includeProjectsFromAngularJson) {
8
18
  if ((0, fs_1.existsSync)(path.join(root, 'angular.json')) &&
9
19
  // Include projects from angular.json if explicitly required.
@@ -38,20 +48,6 @@ exports.isAngularPluginInstalled = isAngularPluginInstalled;
38
48
  function readAngularJson(angularCliWorkspaceRoot) {
39
49
  return toNewFormat((0, fileutils_1.readJsonFile)(path.join(angularCliWorkspaceRoot, 'angular.json'))).projects;
40
50
  }
41
- function mergeAngularJsonAndProjects(projects, angularCliWorkspaceRoot) {
42
- const res = readAngularJson(angularCliWorkspaceRoot);
43
- const folders = new Set();
44
- for (let k of Object.keys(res)) {
45
- folders.add(res[k].root);
46
- }
47
- for (let k of Object.keys(projects)) {
48
- if (!folders.has(projects[k].root)) {
49
- res[k] = projects[k];
50
- }
51
- }
52
- return res;
53
- }
54
- exports.mergeAngularJsonAndProjects = mergeAngularJsonAndProjects;
55
51
  function toNewFormat(w) {
56
52
  Object.values(w.projects || {}).forEach((projectConfig) => {
57
53
  if (projectConfig.architect) {
@@ -54,7 +54,7 @@ exports.examples = {
54
54
  description: 'Run tests for all the projects affected by the last commit on main',
55
55
  },
56
56
  {
57
- command: "affected -t build --exclude '*,!tag:dotnet'",
57
+ command: "affected -t=build --exclude='*,!tag:dotnet'",
58
58
  description: 'Run build for only projects with the tag `dotnet`',
59
59
  },
60
60
  {
@@ -317,7 +317,7 @@ exports.examples = {
317
317
  description: 'Show affected projects in the workspace',
318
318
  },
319
319
  {
320
- command: 'show projects --affected --exclude *-e2e',
320
+ command: 'show projects --affected --exclude=*-e2e',
321
321
  description: 'Show affected projects in the workspace, excluding end-to-end projects',
322
322
  },
323
323
  {
@@ -9,13 +9,15 @@ const fileutils_1 = require("../../utils/fileutils");
9
9
  const file_utils_1 = require("../../project-graph/file-utils");
10
10
  const prettier = require("prettier");
11
11
  const object_sort_1 = require("../../utils/object-sort");
12
+ const package_json_1 = require("../../utils/package-json");
12
13
  const typescript_1 = require("../../plugins/js/utils/typescript");
13
14
  const project_graph_1 = require("../../project-graph/project-graph");
14
15
  const affected_project_graph_1 = require("../../project-graph/affected/affected-project-graph");
15
16
  const configuration_1 = require("../../config/configuration");
16
17
  const chunkify_1 = require("../../utils/chunkify");
17
18
  const all_file_data_1 = require("../../utils/all-file-data");
18
- const PRETTIER_PATH = require.resolve('prettier/bin-prettier');
19
+ const semver_1 = require("semver");
20
+ const PRETTIER_PATH = getPrettierPath();
19
21
  function format(command, args) {
20
22
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
21
23
  const { nxArgs } = (0, command_line_utils_1.splitArgsIntoNxArgsAndOverrides)(args, 'affected', { printWarnings: false }, (0, configuration_1.readNxJson)());
@@ -143,3 +145,10 @@ function sortTsConfig() {
143
145
  // catch noop
144
146
  }
145
147
  }
148
+ function getPrettierPath() {
149
+ const prettierVersion = (0, package_json_1.readModulePackageJson)('prettier').packageJson.version;
150
+ if ((0, semver_1.gte)(prettierVersion, '3.0.0')) {
151
+ return require.resolve('prettier/bin/prettier.cjs');
152
+ }
153
+ return require.resolve('prettier/bin-prettier');
154
+ }
@@ -48,7 +48,9 @@ function createNxJson(repoRoot, angularJson, cacheableOperations, { eslintProjec
48
48
  karmaProjectConfigFile ? '!{projectRoot}/karma.conf.js' : undefined,
49
49
  ].filter(Boolean)
50
50
  : []),
51
- eslintProjectConfigFile ? '!{projectRoot}/.eslintrc.json' : undefined,
51
+ ...(eslintProjectConfigFile
52
+ ? ['!{projectRoot}/.eslintrc.json', '!{projectRoot}/eslint.config.js']
53
+ : []),
52
54
  ].filter(Boolean),
53
55
  };
54
56
  nxJson.targetDefaults = {};
@@ -73,6 +75,9 @@ function createNxJson(repoRoot, angularJson, cacheableOperations, { eslintProjec
73
75
  if ((0, fileutils_1.fileExists)((0, path_1.join)(repoRoot, '.eslintrc.json'))) {
74
76
  inputs.push('{workspaceRoot}/.eslintrc.json');
75
77
  }
78
+ if ((0, fileutils_1.fileExists)((0, path_1.join)(repoRoot, 'eslint.config.js'))) {
79
+ inputs.push('{workspaceRoot}/eslint.config.js');
80
+ }
76
81
  nxJson.targetDefaults.lint = { inputs };
77
82
  }
78
83
  if (workspaceTargets.includes('e2e')) {
@@ -50,7 +50,7 @@ const showProjectsCommand = {
50
50
  .example('$0 show projects --projects "apps/*"', 'Show all projects in the apps directory')
51
51
  .example('$0 show projects --projects "shared-*"', 'Show all projects that start with "shared-"')
52
52
  .example('$0 show projects --affected', 'Show affected projects in the workspace')
53
- .example('$0 show projects --affected --exclude *-e2e', 'Show affected projects in the workspace, excluding end-to-end projects'),
53
+ .example('$0 show projects --affected --exclude=*-e2e', 'Show affected projects in the workspace, excluding end-to-end projects'),
54
54
  handler: (args) => Promise.resolve().then(() => require('./show')).then((m) => m.showProjectsHandler(args)),
55
55
  };
56
56
  const showProjectCommand = {
@@ -1,6 +1,4 @@
1
1
  import type { NxJsonConfiguration } from './nx-json';
2
2
  import { ProjectConfiguration, ProjectsConfigurations } from './workspace-json-project-json';
3
3
  export declare function calculateDefaultProjectName(cwd: string, root: string, { projects }: ProjectsConfigurations, nxJson: NxJsonConfiguration): string;
4
- export declare function findMatchingProjectInCwd(projects: {
5
- [projectName: string]: ProjectConfiguration;
6
- }, relativeCwd: string): string | undefined;
4
+ export declare function findMatchingProjectInCwd(projects: Record<string, ProjectConfiguration>, relativeCwd: string): string | undefined;
@@ -1,9 +1,3 @@
1
- import { NxJsonConfiguration } from './nx-json';
2
- import { ProjectsConfigurations } from './workspace-json-project-json';
3
- /**
4
- * @deprecated Use readProjectsConfigurationFromProjectGraph(await createProjectGraphAsync())
5
- */
6
- export declare function readAllWorkspaceConfiguration(): ProjectsConfigurations & NxJsonConfiguration;
7
1
  /**
8
2
  * Returns information about where apps and libs will be created.
9
3
  */
@@ -1,17 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.readNxJson = exports.workspaceLayout = exports.readAllWorkspaceConfiguration = void 0;
4
- const workspaces_1 = require("./workspaces");
5
- const workspace_root_1 = require("../utils/workspace-root");
3
+ exports.readNxJson = exports.workspaceLayout = void 0;
6
4
  const nx_json_1 = require("./nx-json");
7
- // TODO(vsavkin): Remove after Nx 16 is out
8
- /**
9
- * @deprecated Use readProjectsConfigurationFromProjectGraph(await createProjectGraphAsync())
10
- */
11
- function readAllWorkspaceConfiguration() {
12
- return new workspaces_1.Workspaces(workspace_root_1.workspaceRoot).readProjectsConfigurations();
13
- }
14
- exports.readAllWorkspaceConfiguration = readAllWorkspaceConfiguration;
15
5
  /**
16
6
  * Returns information about where apps and libs will be created.
17
7
  */
@@ -1,23 +1,15 @@
1
1
  import type { NxJsonConfiguration } from './nx-json';
2
2
  import { ProjectsConfigurations } from './workspace-json-project-json';
3
+ /**
4
+ * @deprecated This will be removed in v18. Use {@link readProjectsConfigurationFromProjectGraph} instead.
5
+ */
3
6
  export declare class Workspaces {
4
7
  private root;
5
- private cachedProjectsConfig;
6
8
  constructor(root: string);
7
9
  /**
8
- * @deprecated
9
- */
10
- readProjectsConfigurations(opts?: {
11
- _includeProjectsFromAngularJson?: boolean;
12
- }): ProjectsConfigurations;
13
- /**
14
- * Deprecated. Use readProjectsConfigurations
10
+ * @deprecated Use {@link readProjectsConfigurationFromProjectGraph} instead.
15
11
  */
16
- readWorkspaceConfiguration(opts?: {
17
- _ignorePluginInference?: boolean;
18
- _includeProjectsFromAngularJson?: boolean;
19
- }): ProjectsConfigurations & NxJsonConfiguration;
20
- private mergeTargetDefaultsIntoProjectDescriptions;
12
+ readWorkspaceConfiguration(): ProjectsConfigurations & NxJsonConfiguration;
21
13
  }
22
14
  /**
23
15
  * Pulled from toFileName in names from @nx/devkit.
@@ -2,57 +2,23 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toProjectName = exports.Workspaces = void 0;
4
4
  const path_1 = require("path");
5
- const installation_directory_1 = require("../utils/installation-directory");
6
- const nx_plugin_1 = require("../utils/nx-plugin");
7
5
  const nx_json_1 = require("./nx-json");
8
- const angular_json_1 = require("../adapter/angular-json");
9
6
  const retrieve_workspace_files_1 = require("../project-graph/utils/retrieve-workspace-files");
10
- const project_configuration_utils_1 = require("../project-graph/utils/project-configuration-utils");
7
+ // TODO(v18): remove this class
8
+ /**
9
+ * @deprecated This will be removed in v18. Use {@link readProjectsConfigurationFromProjectGraph} instead.
10
+ */
11
11
  class Workspaces {
12
12
  constructor(root) {
13
13
  this.root = root;
14
14
  }
15
15
  /**
16
- * @deprecated
16
+ * @deprecated Use {@link readProjectsConfigurationFromProjectGraph} instead.
17
17
  */
18
- readProjectsConfigurations(opts) {
19
- if (this.cachedProjectsConfig &&
20
- process.env.NX_CACHE_PROJECTS_CONFIG !== 'false') {
21
- return this.cachedProjectsConfig;
22
- }
18
+ readWorkspaceConfiguration() {
23
19
  const nxJson = (0, nx_json_1.readNxJson)(this.root);
24
- const projectPaths = (0, retrieve_workspace_files_1.retrieveProjectConfigurationPaths)(this.root, nxJson);
25
- let projectsConfigurations = (0, project_configuration_utils_1.buildProjectsConfigurationsFromProjectPathsAndPlugins)(nxJson, projectPaths, (0, nx_plugin_1.loadNxPluginsSync)(nxJson.plugins, (0, installation_directory_1.getNxRequirePaths)(this.root), this.root), this.root).projects;
26
- if ((0, angular_json_1.shouldMergeAngularProjects)(this.root, opts === null || opts === void 0 ? void 0 : opts._includeProjectsFromAngularJson)) {
27
- projectsConfigurations = (0, angular_json_1.mergeAngularJsonAndProjects)(projectsConfigurations, this.root);
28
- }
29
- this.cachedProjectsConfig = {
30
- version: 2,
31
- projects: projectsConfigurations,
32
- };
33
- return this.cachedProjectsConfig;
34
- }
35
- /**
36
- * Deprecated. Use readProjectsConfigurations
37
- */
38
- readWorkspaceConfiguration(opts) {
39
- const nxJson = (0, nx_json_1.readNxJson)(this.root);
40
- return Object.assign(Object.assign({}, this.readProjectsConfigurations(opts)), nxJson);
41
- }
42
- mergeTargetDefaultsIntoProjectDescriptions(projects, nxJson) {
43
- var _a;
44
- for (const proj of Object.values(projects)) {
45
- if (proj.targets) {
46
- for (const targetName of Object.keys((_a = proj.targets) !== null && _a !== void 0 ? _a : {})) {
47
- const projectTargetDefinition = proj.targets[targetName];
48
- const defaults = (0, project_configuration_utils_1.readTargetDefaultsForTarget)(targetName, nxJson.targetDefaults, projectTargetDefinition.executor);
49
- if (defaults) {
50
- proj.targets[targetName] = (0, project_configuration_utils_1.mergeTargetConfigurations)(proj, targetName, defaults);
51
- }
52
- }
53
- }
54
- }
55
- return projects;
20
+ return Object.assign({ version: 2, projects: (0, retrieve_workspace_files_1.retrieveProjectConfigurationsSync)(this.root, nxJson)
21
+ .projectNodes }, nxJson);
56
22
  }
57
23
  }
58
24
  exports.Workspaces = Workspaces;
@@ -9,7 +9,6 @@ const nx_deps_cache_1 = require("../../project-graph/nx-deps-cache");
9
9
  const fileutils_1 = require("../../utils/fileutils");
10
10
  const file_watcher_sockets_1 = require("./file-watching/file-watcher-sockets");
11
11
  const logger_1 = require("./logger");
12
- const workspaces_1 = require("../../config/workspaces");
13
12
  const workspace_root_1 = require("../../utils/workspace-root");
14
13
  const child_process_1 = require("child_process");
15
14
  const file_hasher_1 = require("../../hasher/file-hasher");
@@ -128,7 +127,7 @@ function processCollectedUpdatedAndDeletedFiles() {
128
127
  perf_hooks_1.performance.mark('hash-watched-changes-end');
129
128
  perf_hooks_1.performance.measure('hash changed files from watcher', 'hash-watched-changes-start', 'hash-watched-changes-end');
130
129
  file_hasher_1.fileHasher.incrementalUpdate(updatedFiles, deletedFiles);
131
- let nxJson = (0, nx_json_1.readNxJson)(workspace_root_1.workspaceRoot);
130
+ const nxJson = (0, nx_json_1.readNxJson)(workspace_root_1.workspaceRoot);
132
131
  const { projectNodes } = yield (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(workspace_root_1.workspaceRoot, nxJson);
133
132
  const workspaceConfigHash = computeWorkspaceConfigHash(projectNodes);
134
133
  logger_1.serverLogger.requestLog(`Updated file-hasher based on watched changes, recomputing project graph...`);
@@ -195,10 +194,10 @@ function createAndSerializeProjectGraph() {
195
194
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
196
195
  try {
197
196
  perf_hooks_1.performance.mark('create-project-graph-start');
198
- const projectsConfigurations = new workspaces_1.Workspaces(workspace_root_1.workspaceRoot).readProjectsConfigurations();
197
+ const projectConfigurations = yield (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(workspace_root_1.workspaceRoot, (0, nx_json_1.readNxJson)(workspace_root_1.workspaceRoot));
199
198
  const projectFileMap = copyFileMap(exports.projectFileMapWithFiles.projectFileMap);
200
199
  const allWorkspaceFiles = copyFileData(exports.projectFileMapWithFiles.allWorkspaceFiles);
201
- const { projectGraph, projectFileMapCache } = yield (0, build_project_graph_1.buildProjectGraphUsingProjectFileMap)(projectsConfigurations, knownExternalNodes, projectFileMap, allWorkspaceFiles, exports.currentProjectFileMapCache || (0, nx_deps_cache_1.readProjectFileMapCache)(), true);
200
+ const { projectGraph, projectFileMapCache } = yield (0, build_project_graph_1.buildProjectGraphUsingProjectFileMap)(projectConfigurations.projectNodes, knownExternalNodes, projectFileMap, allWorkspaceFiles, exports.currentProjectFileMapCache || (0, nx_deps_cache_1.readProjectFileMapCache)(), true);
202
201
  exports.currentProjectFileMapCache = projectFileMapCache;
203
202
  exports.currentProjectGraph = projectGraph;
204
203
  perf_hooks_1.performance.mark('create-project-graph-end');
@@ -18,7 +18,7 @@ export type { Generator, GeneratorCallback, Executor, ExecutorContext, TaskGraph
18
18
  * @category Workspace
19
19
  */
20
20
  export { Workspaces } from './config/workspaces';
21
- export { readAllWorkspaceConfiguration, workspaceLayout, } from './config/configuration';
21
+ export { workspaceLayout } from './config/configuration';
22
22
  export type { NxPlugin, NxPluginV1, NxPluginV2, ProjectTargetConfigurator, CreateNodes, CreateNodesFunction, CreateNodesContext, CreateDependencies, CreateDependenciesContext, } from './utils/nx-plugin';
23
23
  /**
24
24
  * @category Workspace
@@ -108,7 +108,7 @@ export { reverse } from './project-graph/operators';
108
108
  /**
109
109
  * @category Utils
110
110
  */
111
- export { createProjectGraphAsync, readCachedProjectGraph, } from './project-graph/project-graph';
111
+ export { createProjectGraphAsync, readCachedProjectGraph, readProjectsConfigurationFromProjectGraph, } from './project-graph/project-graph';
112
112
  /**
113
113
  * @category Utils
114
114
  */
@@ -4,14 +4,14 @@
4
4
  * Try hard to not add to this API to reduce the surface area we need to maintain.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.createProjectFileMapUsingProjectGraph = exports.cacheDir = exports.hashArray = exports.defaultTasksRunner = exports.getOutputsForTargetAndConfiguration = exports.readCachedProjectGraph = exports.createProjectGraphAsync = exports.reverse = exports.appRootPath = exports.workspaceRoot = exports.normalizePath = exports.joinPathFragments = exports.stripIndents = exports.writeJsonFile = exports.readJsonFile = exports.stripJsonComments = exports.serializeJson = exports.parseJson = exports.updateJson = exports.writeJson = exports.readJson = exports.validateDependency = exports.ProjectGraphBuilder = exports.DependencyType = exports.updateNxJson = exports.readNxJson = exports.getWorkspacePath = exports.isStandaloneProject = exports.updateWorkspaceConfiguration = exports.readWorkspaceConfiguration = exports.getProjects = exports.updateProjectConfiguration = exports.removeProjectConfiguration = exports.readProjectConfiguration = exports.addProjectConfiguration = exports.runExecutor = exports.getPackageManagerVersion = exports.detectPackageManager = exports.getPackageManagerCommand = exports.output = exports.logger = exports.workspaceLayout = exports.readAllWorkspaceConfiguration = exports.Workspaces = void 0;
7
+ exports.createProjectFileMapUsingProjectGraph = exports.cacheDir = exports.hashArray = exports.defaultTasksRunner = exports.getOutputsForTargetAndConfiguration = exports.readProjectsConfigurationFromProjectGraph = exports.readCachedProjectGraph = exports.createProjectGraphAsync = exports.reverse = exports.appRootPath = exports.workspaceRoot = exports.normalizePath = exports.joinPathFragments = exports.stripIndents = exports.writeJsonFile = exports.readJsonFile = exports.stripJsonComments = exports.serializeJson = exports.parseJson = exports.updateJson = exports.writeJson = exports.readJson = exports.validateDependency = exports.ProjectGraphBuilder = exports.DependencyType = exports.updateNxJson = exports.readNxJson = exports.getWorkspacePath = exports.isStandaloneProject = exports.updateWorkspaceConfiguration = exports.readWorkspaceConfiguration = exports.getProjects = exports.updateProjectConfiguration = exports.removeProjectConfiguration = exports.readProjectConfiguration = exports.addProjectConfiguration = exports.runExecutor = exports.getPackageManagerVersion = exports.detectPackageManager = exports.getPackageManagerCommand = exports.output = exports.logger = exports.workspaceLayout = exports.Workspaces = void 0;
8
+ // TODO(v18): Remove this export
8
9
  /**
9
10
  * @category Workspace
10
11
  */
11
12
  var workspaces_1 = require("./config/workspaces");
12
13
  Object.defineProperty(exports, "Workspaces", { enumerable: true, get: function () { return workspaces_1.Workspaces; } });
13
14
  var configuration_1 = require("./config/configuration");
14
- Object.defineProperty(exports, "readAllWorkspaceConfiguration", { enumerable: true, get: function () { return configuration_1.readAllWorkspaceConfiguration; } });
15
15
  Object.defineProperty(exports, "workspaceLayout", { enumerable: true, get: function () { return configuration_1.workspaceLayout; } });
16
16
  /**
17
17
  * @category Logger
@@ -115,6 +115,7 @@ Object.defineProperty(exports, "reverse", { enumerable: true, get: function () {
115
115
  var project_graph_2 = require("./project-graph/project-graph");
116
116
  Object.defineProperty(exports, "createProjectGraphAsync", { enumerable: true, get: function () { return project_graph_2.createProjectGraphAsync; } });
117
117
  Object.defineProperty(exports, "readCachedProjectGraph", { enumerable: true, get: function () { return project_graph_2.readCachedProjectGraph; } });
118
+ Object.defineProperty(exports, "readProjectsConfigurationFromProjectGraph", { enumerable: true, get: function () { return project_graph_2.readProjectsConfigurationFromProjectGraph; } });
118
119
  /**
119
120
  * @category Utils
120
121
  */
@@ -7,3 +7,9 @@ export { createTempNpmDirectory } from './utils/package-manager';
7
7
  export { getExecutorInformation } from './command-line/run/executor-utils';
8
8
  export { readNxJson as readNxJsonFromDisk } from './config/nx-json';
9
9
  export { calculateDefaultProjectName } from './config/calculate-default-project-name';
10
+ export { retrieveProjectConfigurationsWithAngularProjects } from './project-graph/utils/retrieve-workspace-files';
11
+ export { splitTarget } from './utils/split-target';
12
+ export { combineOptionsForExecutor } from './utils/params';
13
+ export { sortObjectByKeys } from './utils/object-sort';
14
+ export { stripIndent } from './utils/logger';
15
+ export { readModulePackageJson } from './utils/package-json';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.calculateDefaultProjectName = exports.readNxJsonFromDisk = exports.getExecutorInformation = exports.createTempNpmDirectory = void 0;
3
+ 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
  *
@@ -14,3 +14,15 @@ var nx_json_1 = require("./config/nx-json");
14
14
  Object.defineProperty(exports, "readNxJsonFromDisk", { enumerable: true, get: function () { return nx_json_1.readNxJson; } });
15
15
  var calculate_default_project_name_1 = require("./config/calculate-default-project-name");
16
16
  Object.defineProperty(exports, "calculateDefaultProjectName", { enumerable: true, get: function () { return calculate_default_project_name_1.calculateDefaultProjectName; } });
17
+ var retrieve_workspace_files_1 = require("./project-graph/utils/retrieve-workspace-files");
18
+ Object.defineProperty(exports, "retrieveProjectConfigurationsWithAngularProjects", { enumerable: true, get: function () { return retrieve_workspace_files_1.retrieveProjectConfigurationsWithAngularProjects; } });
19
+ var split_target_1 = require("./utils/split-target");
20
+ Object.defineProperty(exports, "splitTarget", { enumerable: true, get: function () { return split_target_1.splitTarget; } });
21
+ var params_1 = require("./utils/params");
22
+ Object.defineProperty(exports, "combineOptionsForExecutor", { enumerable: true, get: function () { return params_1.combineOptionsForExecutor; } });
23
+ var object_sort_1 = require("./utils/object-sort");
24
+ Object.defineProperty(exports, "sortObjectByKeys", { enumerable: true, get: function () { return object_sort_1.sortObjectByKeys; } });
25
+ var logger_1 = require("./utils/logger");
26
+ Object.defineProperty(exports, "stripIndent", { enumerable: true, get: function () { return logger_1.stripIndent; } });
27
+ var package_json_1 = require("./utils/package-json");
28
+ Object.defineProperty(exports, "readModulePackageJson", { enumerable: true, get: function () { return package_json_1.readModulePackageJson; } });