nx 16.6.0-beta.4 → 16.6.0-beta.6

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 (67) hide show
  1. package/.eslintrc.json +30 -0
  2. package/migrations.json +6 -0
  3. package/package.json +13 -13
  4. package/src/command-line/affected/print-affected.js +1 -4
  5. package/src/command-line/exec/exec.js +2 -2
  6. package/src/command-line/generate/generate.js +2 -1
  7. package/src/command-line/init/implementation/angular/index.js +1 -1
  8. package/src/command-line/init/implementation/angular/legacy-angular-versions.js +1 -1
  9. package/src/command-line/init/implementation/react/index.js +1 -1
  10. package/src/command-line/migrate/migrate.js +1 -1
  11. package/src/command-line/run/run-one.d.ts +1 -3
  12. package/src/command-line/run/run-one.js +3 -25
  13. package/src/command-line/show/command-object.js +4 -3
  14. package/src/command-line/show/show.js +2 -1
  15. package/src/config/calculate-default-project-name.d.ts +6 -0
  16. package/src/config/calculate-default-project-name.js +41 -0
  17. package/src/config/configuration.d.ts +1 -1
  18. package/src/config/configuration.js +5 -6
  19. package/src/config/nx-json.d.ts +2 -0
  20. package/src/config/nx-json.js +35 -0
  21. package/src/config/workspaces.d.ts +0 -5
  22. package/src/config/workspaces.js +7 -141
  23. package/src/core/graph/3rdpartylicenses.txt +25 -0
  24. package/src/core/graph/main.js +1 -1
  25. package/src/core/graph/polyfills.js +1 -1
  26. package/src/core/graph/styles.css +2 -2
  27. package/src/daemon/client/client.d.ts +3 -1
  28. package/src/daemon/client/client.js +37 -19
  29. package/src/daemon/server/project-graph-incremental-recomputation.js +2 -1
  30. package/src/devkit-exports.d.ts +1 -1
  31. package/src/devkit-exports.js +3 -4
  32. package/src/devkit-internals.d.ts +2 -0
  33. package/src/devkit-internals.js +5 -1
  34. package/src/executors/utils/convert-nx-executor.js +2 -1
  35. package/src/generators/utils/nx-json.js +2 -2
  36. package/src/generators/utils/project-configuration.js +2 -2
  37. package/src/hasher/file-hasher.d.ts +0 -1
  38. package/src/hasher/file-hasher.js +0 -5
  39. package/src/hasher/hash-task.d.ts +2 -3
  40. package/src/hasher/hash-task.js +6 -5
  41. package/src/hasher/task-hasher.js +141 -101
  42. package/src/migrations/update-15-0-0/prefix-outputs.js +13 -8
  43. package/src/migrations/update-15-1-0/set-project-names.js +2 -3
  44. package/src/native/assert-supported-platform.js +1 -1
  45. package/src/native/index.d.ts +9 -3
  46. package/src/native/index.js +3 -2
  47. package/src/plugins/js/hasher/hasher.js +1 -1
  48. package/src/plugins/js/lock-file/lock-file.js +5 -2
  49. package/src/plugins/js/lock-file/yarn-parser.d.ts +1 -1
  50. package/src/plugins/js/lock-file/yarn-parser.js +66 -33
  51. package/src/project-graph/file-utils.js +1 -1
  52. package/src/project-graph/project-graph.js +2 -2
  53. package/src/project-graph/utils/retrieve-workspace-files.d.ts +2 -0
  54. package/src/project-graph/utils/retrieve-workspace-files.js +43 -15
  55. package/src/tasks-runner/cache.js +1 -1
  56. package/src/tasks-runner/run-command.js +1 -2
  57. package/src/tasks-runner/task-orchestrator.d.ts +0 -2
  58. package/src/tasks-runner/task-orchestrator.js +2 -6
  59. package/src/tasks-runner/tasks-schedule.d.ts +1 -5
  60. package/src/tasks-runner/tasks-schedule.js +3 -5
  61. package/src/tasks-runner/utils.d.ts +3 -4
  62. package/src/tasks-runner/utils.js +6 -5
  63. package/src/utils/nx-plugin.js +5 -7
  64. package/src/utils/package-manager.js +1 -1
  65. package/src/utils/testing/temp-fs.js +1 -1
  66. package/src/utils/workspace-root.d.ts +0 -1
  67. package/src/utils/workspace-root.js +1 -5
package/.eslintrc.json CHANGED
@@ -70,6 +70,36 @@
70
70
  ],
71
71
  "no-restricted-imports": "off"
72
72
  }
73
+ },
74
+ {
75
+ "files": ["./package.json"],
76
+ "parser": "jsonc-eslint-parser",
77
+ "rules": {
78
+ "@nx/dependency-checks": [
79
+ "error",
80
+ {
81
+ "buildTargets": ["build-base"],
82
+ "ignoredDependencies": [
83
+ "typescript",
84
+ "@angular-devkit/build-angular",
85
+ "@angular-devkit/core",
86
+ "@angular-devkit/architect",
87
+ "@swc/core", //Optional, used in JS analysis if available
88
+ "@swc/node-register", //Optional, used in JS analysis if available
89
+ "rxjs",
90
+ "@angular-devkit/schematics",
91
+ "@pnpm/lockfile-types",
92
+ "@nestjs/cli", // nx init nest makes use of nestjs cli (which should be available in NestJS CLI app) to parse the nest-cli.json file
93
+ "ts-node", // We *may* fall back on ts-node, but we want to encourage the use of @swc-node instead so we don't explicitly list ts-node as an optional dep
94
+ "memfs", // used in mock for handling .node files in tests
95
+ "events", // This is coming from @storybook/builder-manager since it uses the browser polyfill
96
+ "process", // This is coming from @storybook/builder-manager since it uses the browser polyfill
97
+ "prettier", // This is coming from @storybook/builder-manager since it uses the browser polyfill
98
+ "util" // This is coming from @storybook/builder-manager since it uses the browser polyfill
99
+ ]
100
+ }
101
+ ]
102
+ }
73
103
  }
74
104
  ]
75
105
  }
package/migrations.json CHANGED
@@ -77,6 +77,12 @@
77
77
  "version": "16.2.0-beta.0",
78
78
  "description": "Remove outputPath from run commands",
79
79
  "implementation": "./src/migrations/update-16-2-0/remove-run-commands-output-path"
80
+ },
81
+ "16.6.0-prefix-outputs": {
82
+ "cli": "nx",
83
+ "version": "16.6.0-beta.6",
84
+ "description": "Prefix outputs with {workspaceRoot}/{projectRoot} if needed",
85
+ "implementation": "./src/migrations/update-15-0-0/prefix-outputs"
80
86
  }
81
87
  }
82
88
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "16.6.0-beta.4",
3
+ "version": "16.6.0-beta.6",
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.6.0-beta.4",
35
+ "@nrwl/tao": "16.6.0-beta.6",
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.6.0-beta.4",
85
- "@nx/nx-darwin-x64": "16.6.0-beta.4",
86
- "@nx/nx-freebsd-x64": "16.6.0-beta.4",
87
- "@nx/nx-linux-arm-gnueabihf": "16.6.0-beta.4",
88
- "@nx/nx-linux-arm64-gnu": "16.6.0-beta.4",
89
- "@nx/nx-linux-arm64-musl": "16.6.0-beta.4",
90
- "@nx/nx-linux-x64-gnu": "16.6.0-beta.4",
91
- "@nx/nx-linux-x64-musl": "16.6.0-beta.4",
92
- "@nx/nx-win32-arm64-msvc": "16.6.0-beta.4",
93
- "@nx/nx-win32-x64-msvc": "16.6.0-beta.4"
84
+ "@nx/nx-darwin-arm64": "16.6.0-beta.6",
85
+ "@nx/nx-darwin-x64": "16.6.0-beta.6",
86
+ "@nx/nx-freebsd-x64": "16.6.0-beta.6",
87
+ "@nx/nx-linux-arm-gnueabihf": "16.6.0-beta.6",
88
+ "@nx/nx-linux-arm64-gnu": "16.6.0-beta.6",
89
+ "@nx/nx-linux-arm64-musl": "16.6.0-beta.6",
90
+ "@nx/nx-linux-x64-gnu": "16.6.0-beta.6",
91
+ "@nx/nx-linux-x64-musl": "16.6.0-beta.6",
92
+ "@nx/nx-win32-arm64-msvc": "16.6.0-beta.6",
93
+ "@nx/nx-win32-x64-msvc": "16.6.0-beta.6"
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
  "types": "./bin/nx.d.ts",
180
- "gitHead": "b1a9ae7ce76697019b26ec9a172005840cca8da6"
180
+ "gitHead": "9aad21dbfb2b659e488b6626f59df58ab23c0032"
181
181
  }
@@ -4,10 +4,8 @@ exports.selectPrintAffected = exports.printAffected = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const utils_1 = require("../../tasks-runner/utils");
6
6
  const create_task_graph_1 = require("../../tasks-runner/create-task-graph");
7
- const workspaces_1 = require("../../config/workspaces");
8
7
  const task_hasher_1 = require("../../hasher/task-hasher");
9
8
  const hash_task_1 = require("../../hasher/hash-task");
10
- const workspace_root_1 = require("../../utils/workspace-root");
11
9
  const package_manager_1 = require("../../utils/package-manager");
12
10
  const file_hasher_1 = require("../../hasher/file-hasher");
13
11
  const command_object_1 = require("./command-object");
@@ -39,13 +37,12 @@ function printAffected(affectedProjects, projectGraph, { nxJson }, nxArgs, overr
39
37
  exports.printAffected = printAffected;
40
38
  function createTasks(affectedProjectsWithTargetAndConfig, projectGraph, nxArgs, nxJson, overrides) {
41
39
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
42
- const workspaces = new workspaces_1.Workspaces(workspace_root_1.workspaceRoot);
43
40
  const defaultDependencyConfigs = (0, create_task_graph_1.mapTargetDefaultsToDependencies)(nxJson.targetDefaults);
44
41
  const taskGraph = (0, create_task_graph_1.createTaskGraph)(projectGraph, defaultDependencyConfigs, affectedProjectsWithTargetAndConfig.map((p) => p.name), nxArgs.targets, nxArgs.configuration, overrides);
45
42
  const hasher = new task_hasher_1.InProcessTaskHasher({}, [], projectGraph, taskGraph, nxJson, {}, file_hasher_1.fileHasher);
46
43
  const execCommand = (0, package_manager_1.getPackageManagerCommand)().exec;
47
44
  const tasks = Object.values(taskGraph.tasks);
48
- yield Promise.all(tasks.map((t) => (0, hash_task_1.hashTask)(workspaces, hasher, projectGraph, {}, t)));
45
+ yield Promise.all(tasks.map((t) => (0, hash_task_1.hashTask)(hasher, projectGraph, {}, t)));
49
46
  return tasks.map((task) => ({
50
47
  id: task.id,
51
48
  overrides,
@@ -13,7 +13,7 @@ const fileutils_1 = require("../../utils/fileutils");
13
13
  const output_1 = require("../../utils/output");
14
14
  const package_manager_1 = require("../../utils/package-manager");
15
15
  const workspace_root_1 = require("../../utils/workspace-root");
16
- const run_one_1 = require("../run/run-one");
16
+ const calculate_default_project_name_1 = require("../../config/calculate-default-project-name");
17
17
  function nxExecCommand(args) {
18
18
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
19
19
  const scriptArgV = readScriptArgV(args);
@@ -87,7 +87,7 @@ function ensureNxTarget(project, targetName) {
87
87
  }
88
88
  }
89
89
  function getProject(projectGraph) {
90
- const projectName = (0, run_one_1.calculateDefaultProjectName)(process.cwd(), workspace_root_1.workspaceRoot, (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph), (0, configuration_1.readNxJson)());
90
+ const projectName = (0, calculate_default_project_name_1.calculateDefaultProjectName)(process.cwd(), workspace_root_1.workspaceRoot, (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph), (0, configuration_1.readNxJson)());
91
91
  if (!projectName) {
92
92
  output_1.output.error({
93
93
  title: 'Unable to determine project name for `nx exec`',
@@ -13,6 +13,7 @@ const params_1 = require("../../utils/params");
13
13
  const local_plugins_1 = require("../../utils/plugins/local-plugins");
14
14
  const print_help_1 = require("../../utils/print-help");
15
15
  const workspace_root_1 = require("../../utils/workspace-root");
16
+ const calculate_default_project_name_1 = require("../../config/calculate-default-project-name");
16
17
  const installed_plugins_1 = require("../../utils/plugins/installed-plugins");
17
18
  const output_1 = require("../../utils/output");
18
19
  const generator_utils_1 = require("./generator-utils");
@@ -239,7 +240,7 @@ function generate(cwd, args) {
239
240
  printGenHelp(opts, schema, normalizedGeneratorName, aliases);
240
241
  return 0;
241
242
  }
242
- const combinedOpts = yield (0, params_1.combineOptionsForGenerator)(opts.generatorOptions, opts.collectionName, normalizedGeneratorName, projectsConfigurations, nxJsonConfiguration, schema, opts.interactive, ws.calculateDefaultProjectName(cwd, projectsConfigurations, nxJsonConfiguration), ws.relativeCwd(cwd), verbose);
243
+ const combinedOpts = yield (0, params_1.combineOptionsForGenerator)(opts.generatorOptions, opts.collectionName, normalizedGeneratorName, projectsConfigurations, nxJsonConfiguration, schema, opts.interactive, (0, calculate_default_project_name_1.calculateDefaultProjectName)(cwd, workspace_root_1.workspaceRoot, projectsConfigurations, nxJsonConfiguration), ws.relativeCwd(cwd), verbose);
243
244
  if ((0, generator_utils_1.getGeneratorInformation)(opts.collectionName, normalizedGeneratorName, workspace_root_1.workspaceRoot).isNxGenerator) {
244
245
  const host = new tree_1.FsTree(workspace_root_1.workspaceRoot, verbose, `generating (${opts.collectionName}:${normalizedGeneratorName})`);
245
246
  const implementation = implementationFactory();
@@ -48,7 +48,7 @@ function addNxToAngularCliRepo(options) {
48
48
  (0, utils_1.initCloud)(repoRoot, 'nx-init-angular');
49
49
  }
50
50
  (0, utils_1.printFinalMessage)({
51
- learnMoreLink: 'https://nx.dev/recipes/adopting-nx/migration-angular',
51
+ learnMoreLink: 'https://nx.dev/recipes/angular/migration/angular',
52
52
  bodyLines: [
53
53
  '- Execute "npx nx build" twice to see the computation caching in action.',
54
54
  ],
@@ -84,7 +84,7 @@ function getLegacyMigrationFunctionIfApplicable(repoRoot, options) {
84
84
  (0, utils_1.initCloud)(repoRoot, 'nx-init-angular');
85
85
  }
86
86
  (0, utils_1.printFinalMessage)({
87
- learnMoreLink: 'https://nx.dev/recipes/adopting-nx/migration-angular',
87
+ learnMoreLink: 'https://nx.dev/recipes/angular/migration/angular',
88
88
  bodyLines: [
89
89
  '- Execute "npx nx build" twice to see the computation caching in action.',
90
90
  ],
@@ -100,7 +100,7 @@ function reorgnizeWorkspaceStructure(options) {
100
100
  ? `npx nx build ${options.reactAppName}`
101
101
  : 'npm run build';
102
102
  (0, utils_1.printFinalMessage)({
103
- learnMoreLink: 'https://nx.dev/recipes/adopting-nx/migration-cra',
103
+ learnMoreLink: 'https://nx.dev/recipes/react/migration-cra',
104
104
  bodyLines: [
105
105
  `- Execute "${buildCommand}" twice to see the computation caching in action.`,
106
106
  ],
@@ -833,7 +833,7 @@ function generateMigrationsJsonAndUpdatePackageJson(root, opts) {
833
833
  ? [
834
834
  `- You opted out of some migrations for now. Write the following command down somewhere to apply these migrations later:`,
835
835
  ` nx migrate ${opts.targetVersion} --from ${opts.targetPackage}@${minVersionWithSkippedUpdates} --exclude-applied-migrations`,
836
- `- To learn more go to https://nx.dev/recipes/managing-repository/advanced-update`,
836
+ `- To learn more go to https://nx.dev/recipes/tips-n-tricks/advanced-update`,
837
837
  ]
838
838
  : [
839
839
  `- To learn more go to https://nx.dev/core-features/automate-updating-dependencies`,
@@ -1,9 +1,7 @@
1
- import { NxJsonConfiguration } from '../../config/nx-json';
2
- import { ProjectsConfigurations, TargetDependencyConfig } from '../../config/workspace-json-project-json';
1
+ import { TargetDependencyConfig } from '../../config/workspace-json-project-json';
3
2
  export declare function runOne(cwd: string, args: {
4
3
  [k: string]: any;
5
4
  }, extraTargetDependencies?: Record<string, (TargetDependencyConfig | string)[]>, extraOptions?: {
6
5
  excludeTaskDependencies: boolean;
7
6
  loadDotEnvFiles: boolean;
8
7
  }): Promise<void>;
9
- export declare function calculateDefaultProjectName(cwd: string, root: string, projectsConfigurations: ProjectsConfigurations, nxJsonConfiguration: NxJsonConfiguration): string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.calculateDefaultProjectName = exports.runOne = void 0;
3
+ exports.runOne = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const run_command_1 = require("../../tasks-runner/run-command");
6
6
  const command_line_utils_1 = require("../../utils/command-line-utils");
@@ -11,6 +11,7 @@ const workspace_root_1 = require("../../utils/workspace-root");
11
11
  const split_target_1 = require("../../utils/split-target");
12
12
  const output_1 = require("../../utils/output");
13
13
  const configuration_1 = require("../../config/configuration");
14
+ const calculate_default_project_name_1 = require("../../config/calculate-default-project-name");
14
15
  const workspace_configuration_check_1 = require("../../utils/workspace-configuration-check");
15
16
  const graph_1 = require("../graph/graph");
16
17
  function runOne(cwd, args, extraTargetDependencies = {}, extraOptions = { excludeTaskDependencies: false, loadDotEnvFiles: true }) {
@@ -70,7 +71,7 @@ const targetAliases = {
70
71
  t: 'test',
71
72
  };
72
73
  function parseRunOneOptions(cwd, parsedArgs, projectGraph, nxJson) {
73
- const defaultProjectName = calculateDefaultProjectName(cwd, workspace_root_1.workspaceRoot, (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph), nxJson);
74
+ const defaultProjectName = (0, calculate_default_project_name_1.calculateDefaultProjectName)(cwd, workspace_root_1.workspaceRoot, (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph), nxJson);
74
75
  let project;
75
76
  let target;
76
77
  let configuration;
@@ -112,26 +113,3 @@ function parseRunOneOptions(cwd, parsedArgs, projectGraph, nxJson) {
112
113
  delete parsedArgs['project'];
113
114
  return res;
114
115
  }
115
- function calculateDefaultProjectName(cwd, root, projectsConfigurations, nxJsonConfiguration) {
116
- var _a;
117
- if (cwd && /^[A-Z]:/.test(cwd)) {
118
- cwd = cwd.charAt(0).toLowerCase() + cwd.slice(1);
119
- }
120
- if (root && /^[A-Z]:/.test(root)) {
121
- root = root.charAt(0).toLowerCase() + root.slice(1);
122
- }
123
- let relativeCwd = cwd.replace(/\\/g, '/').split(root.replace(/\\/g, '/'))[1];
124
- relativeCwd = relativeCwd.startsWith('/')
125
- ? relativeCwd.substring(1)
126
- : relativeCwd;
127
- const matchingProject = Object.keys(projectsConfigurations.projects).find((p) => {
128
- const projectRoot = projectsConfigurations.projects[p].root;
129
- return (relativeCwd == projectRoot ||
130
- (relativeCwd == '' && projectRoot == '.') ||
131
- relativeCwd.startsWith(`${projectRoot}/`));
132
- });
133
- if (matchingProject)
134
- return matchingProject;
135
- return (((_a = nxJsonConfiguration.cli) === null || _a === void 0 ? void 0 : _a.defaultProjectName) || nxJsonConfiguration.defaultProject);
136
- }
137
- exports.calculateDefaultProjectName = calculateDefaultProjectName;
@@ -16,7 +16,8 @@ exports.yargsShowCommand = {
16
16
  description: 'Output JSON',
17
17
  })
18
18
  .example('$0 show projects', 'Show a list of all projects in the workspace')
19
- .example('$0 show targets', 'Show a list of all targets in the workspace'),
19
+ .example('$0 show projects --with-target serve', 'Show a list of all projects in the workspace that have a "serve" target')
20
+ .example('$0 show project [projectName]', 'Shows the resolved configuration for [projectName]'),
20
21
  handler: (args) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
21
22
  (0, yargs_1.showHelp)();
22
23
  process.exit(1);
@@ -54,12 +55,12 @@ const showProjectsCommand = {
54
55
  };
55
56
  const showProjectCommand = {
56
57
  command: 'project <projectName>',
57
- describe: 'Show a list of targets in the workspace.',
58
+ describe: 'Shows resolved project configuration for a given project.',
58
59
  builder: (yargs) => yargs
59
60
  .positional('projectName', {
60
61
  type: 'string',
61
62
  alias: 'p',
62
- description: 'Show targets for the given project',
63
+ description: 'Which project should be viewed?',
63
64
  })
64
65
  .default('json', true)
65
66
  .example('$0 show project my-app', 'View project information for my-app in JSON format'),
@@ -4,6 +4,7 @@ exports.showProjectHandler = exports.showProjectsHandler = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const affected_project_graph_1 = require("../../project-graph/affected/affected-project-graph");
6
6
  const file_utils_1 = require("../../project-graph/file-utils");
7
+ const nx_json_1 = require("../../config/nx-json");
7
8
  const command_line_utils_1 = require("../../utils/command-line-utils");
8
9
  const project_graph_1 = require("../../project-graph/project-graph");
9
10
  const find_matching_projects_1 = require("../../utils/find-matching-projects");
@@ -11,7 +12,7 @@ const all_file_data_1 = require("../../utils/all-file-data");
11
12
  function showProjectsHandler(args) {
12
13
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
13
14
  let graph = yield (0, project_graph_1.createProjectGraphAsync)();
14
- const nxJson = (0, file_utils_1.readNxJson)();
15
+ const nxJson = (0, nx_json_1.readNxJson)();
15
16
  const { nxArgs } = (0, command_line_utils_1.splitArgsIntoNxArgsAndOverrides)(args, 'affected', {
16
17
  printWarnings: false,
17
18
  }, nxJson);
@@ -0,0 +1,6 @@
1
+ import type { NxJsonConfiguration } from './nx-json';
2
+ import { ProjectConfiguration, ProjectsConfigurations } from './workspace-json-project-json';
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;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findMatchingProjectInCwd = exports.calculateDefaultProjectName = void 0;
4
+ const find_project_for_path_1 = require("../project-graph/utils/find-project-for-path");
5
+ const path_1 = require("path");
6
+ function calculateDefaultProjectName(cwd, root, { projects }, nxJson) {
7
+ var _a, _b, _c, _d;
8
+ const relativeCwd = (_a = (0, path_1.relative)(root, cwd).replace(/\\/g, '/')) !== null && _a !== void 0 ? _a : null;
9
+ if (relativeCwd !== null) {
10
+ const matchingProject = findMatchingProjectInCwd(projects, relativeCwd);
11
+ // We have found a project
12
+ if (matchingProject) {
13
+ // That is not at the root
14
+ if (projects[matchingProject].root !== '.' &&
15
+ projects[matchingProject].root !== '') {
16
+ return matchingProject;
17
+ // But its at the root, and NX_DEFAULT_PROJECT is set
18
+ }
19
+ else if (process.env.NX_DEFAULT_PROJECT) {
20
+ return process.env.NX_DEFAULT_PROJECT;
21
+ // Its root, and NX_DEFAULT_PROJECT is not set
22
+ }
23
+ else {
24
+ return matchingProject;
25
+ }
26
+ }
27
+ }
28
+ // There was no matching project in cwd.
29
+ return ((_d = (_b = process.env.NX_DEFAULT_PROJECT) !== null && _b !== void 0 ? _b : (_c = nxJson.cli) === null || _c === void 0 ? void 0 : _c.defaultProjectName) !== null && _d !== void 0 ? _d : nxJson === null || nxJson === void 0 ? void 0 : nxJson.defaultProject);
30
+ }
31
+ exports.calculateDefaultProjectName = calculateDefaultProjectName;
32
+ function findMatchingProjectInCwd(projects, relativeCwd) {
33
+ const projectRootMappings = new Map();
34
+ for (const projectName of Object.keys(projects)) {
35
+ const { root } = projects[projectName];
36
+ projectRootMappings.set((0, find_project_for_path_1.normalizeProjectRoot)(root), projectName);
37
+ }
38
+ const matchingProject = (0, find_project_for_path_1.findProjectForPath)(relativeCwd, projectRootMappings);
39
+ return matchingProject;
40
+ }
41
+ exports.findMatchingProjectInCwd = findMatchingProjectInCwd;
@@ -1,6 +1,5 @@
1
1
  import { NxJsonConfiguration } from './nx-json';
2
2
  import { ProjectsConfigurations } from './workspace-json-project-json';
3
- export declare function readNxJson(): NxJsonConfiguration;
4
3
  /**
5
4
  * @deprecated Use readProjectsConfigurationFromProjectGraph(await createProjectGraphAsync())
6
5
  */
@@ -12,3 +11,4 @@ export declare function workspaceLayout(): {
12
11
  appsDir: string;
13
12
  libsDir: string;
14
13
  };
14
+ export { readNxJson } from './nx-json';
@@ -1,12 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.workspaceLayout = exports.readAllWorkspaceConfiguration = exports.readNxJson = void 0;
3
+ exports.readNxJson = exports.workspaceLayout = exports.readAllWorkspaceConfiguration = void 0;
4
4
  const workspaces_1 = require("./workspaces");
5
5
  const workspace_root_1 = require("../utils/workspace-root");
6
- function readNxJson() {
7
- return new workspaces_1.Workspaces(workspace_root_1.workspaceRoot).readNxJson();
8
- }
9
- exports.readNxJson = readNxJson;
6
+ const nx_json_1 = require("./nx-json");
10
7
  // TODO(vsavkin): Remove after Nx 16 is out
11
8
  /**
12
9
  * @deprecated Use readProjectsConfigurationFromProjectGraph(await createProjectGraphAsync())
@@ -20,10 +17,12 @@ exports.readAllWorkspaceConfiguration = readAllWorkspaceConfiguration;
20
17
  */
21
18
  function workspaceLayout() {
22
19
  var _a, _b, _c, _d;
23
- const nxJson = readNxJson();
20
+ const nxJson = (0, nx_json_1.readNxJson)();
24
21
  return {
25
22
  appsDir: (_b = (_a = nxJson.workspaceLayout) === null || _a === void 0 ? void 0 : _a.appsDir) !== null && _b !== void 0 ? _b : 'apps',
26
23
  libsDir: (_d = (_c = nxJson.workspaceLayout) === null || _c === void 0 ? void 0 : _c.libsDir) !== null && _d !== void 0 ? _d : 'libs',
27
24
  };
28
25
  }
29
26
  exports.workspaceLayout = workspaceLayout;
27
+ var nx_json_2 = require("./nx-json");
28
+ Object.defineProperty(exports, "readNxJson", { enumerable: true, get: function () { return nx_json_2.readNxJson; } });
@@ -138,4 +138,6 @@ export interface NxJsonConfiguration<T = '*' | string[]> {
138
138
  */
139
139
  installation?: NxInstallationConfiguration;
140
140
  }
141
+ export declare function readNxJson(root?: string): NxJsonConfiguration;
142
+ export declare function hasNxJson(root: string): boolean;
141
143
  export {};
@@ -1,2 +1,37 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hasNxJson = exports.readNxJson = void 0;
4
+ const path_1 = require("path");
5
+ const fs_1 = require("fs");
6
+ const fileutils_1 = require("../utils/fileutils");
7
+ const workspace_root_1 = require("../utils/workspace-root");
8
+ function readNxJson(root = workspace_root_1.workspaceRoot) {
9
+ const nxJson = (0, path_1.join)(root, 'nx.json');
10
+ if ((0, fs_1.existsSync)(nxJson)) {
11
+ const nxJsonConfiguration = (0, fileutils_1.readJsonFile)(nxJson);
12
+ if (nxJsonConfiguration.extends) {
13
+ const extendedNxJsonPath = require.resolve(nxJsonConfiguration.extends, {
14
+ paths: [(0, path_1.dirname)(nxJson)],
15
+ });
16
+ const baseNxJson = (0, fileutils_1.readJsonFile)(extendedNxJsonPath);
17
+ return Object.assign(Object.assign({}, baseNxJson), nxJsonConfiguration);
18
+ }
19
+ else {
20
+ return nxJsonConfiguration;
21
+ }
22
+ }
23
+ else {
24
+ try {
25
+ return (0, fileutils_1.readJsonFile)((0, path_1.join)(__dirname, '..', '..', 'presets', 'core.json'));
26
+ }
27
+ catch (e) {
28
+ return {};
29
+ }
30
+ }
31
+ }
32
+ exports.readNxJson = readNxJson;
33
+ function hasNxJson(root) {
34
+ const nxJson = (0, path_1.join)(root, 'nx.json');
35
+ return (0, fs_1.existsSync)(nxJson);
36
+ }
37
+ exports.hasNxJson = hasNxJson;
@@ -5,12 +5,10 @@ export declare class Workspaces {
5
5
  private cachedProjectsConfig;
6
6
  constructor(root: string);
7
7
  relativeCwd(cwd: string): string;
8
- calculateDefaultProjectName(cwd: string, { projects }: ProjectsConfigurations, nxJson: NxJsonConfiguration): string;
9
8
  /**
10
9
  * @deprecated
11
10
  */
12
11
  readProjectsConfigurations(opts?: {
13
- _ignorePluginInference?: boolean;
14
12
  _includeProjectsFromAngularJson?: boolean;
15
13
  }): ProjectsConfigurations;
16
14
  /**
@@ -21,8 +19,6 @@ export declare class Workspaces {
21
19
  _includeProjectsFromAngularJson?: boolean;
22
20
  }): ProjectsConfigurations & NxJsonConfiguration;
23
21
  private mergeTargetDefaultsIntoProjectDescriptions;
24
- hasNxJson(): boolean;
25
- readNxJson(): NxJsonConfiguration;
26
22
  }
27
23
  /**
28
24
  * Pulled from toFileName in names from @nx/devkit.
@@ -38,7 +34,6 @@ export declare function getGlobPatternsFromPluginsAsync(nxJson: NxJsonConfigurat
38
34
  * Get the package.json globs from package manager workspaces
39
35
  */
40
36
  export declare function getGlobPatternsFromPackageManagerWorkspaces(root: string): string[];
41
- export declare function globForProjectFiles(root: string, pluginsGlobPatterns: string[], nxJson?: NxJsonConfiguration): string[];
42
37
  /**
43
38
  * @description Loops through files and reduces them to 1 file per project.
44
39
  * @param files Array of files that may represent projects