nx 16.6.0-beta.3 → 16.6.0-beta.5

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 (71) hide show
  1. package/.eslintrc.json +30 -0
  2. package/package.json +13 -13
  3. package/src/adapter/angular-json.js +1 -0
  4. package/src/adapter/ngcli-adapter.d.ts +6 -0
  5. package/src/adapter/ngcli-adapter.js +132 -70
  6. package/src/command-line/affected/print-affected.js +1 -4
  7. package/src/command-line/exec/exec.js +2 -2
  8. package/src/command-line/generate/generate.js +8 -6
  9. package/src/command-line/generate/generator-utils.d.ts +16 -0
  10. package/src/command-line/generate/generator-utils.js +85 -0
  11. package/src/command-line/init/implementation/angular/index.js +1 -1
  12. package/src/command-line/init/implementation/angular/legacy-angular-versions.js +1 -1
  13. package/src/command-line/init/implementation/react/index.js +1 -1
  14. package/src/command-line/migrate/migrate.js +1 -1
  15. package/src/command-line/new/new.js +2 -3
  16. package/src/command-line/run/run-one.d.ts +1 -3
  17. package/src/command-line/run/run-one.js +3 -25
  18. package/src/command-line/show/command-object.js +4 -3
  19. package/src/command-line/show/show.js +2 -1
  20. package/src/config/calculate-default-project-name.d.ts +6 -0
  21. package/src/config/calculate-default-project-name.js +41 -0
  22. package/src/config/configuration.d.ts +1 -1
  23. package/src/config/configuration.js +5 -6
  24. package/src/config/nx-json.d.ts +2 -0
  25. package/src/config/nx-json.js +35 -0
  26. package/src/config/workspaces.d.ts +0 -21
  27. package/src/config/workspaces.js +7 -224
  28. package/src/core/graph/3rdpartylicenses.txt +25 -0
  29. package/src/core/graph/main.js +1 -1
  30. package/src/core/graph/polyfills.js +1 -1
  31. package/src/core/graph/styles.css +2 -2
  32. package/src/daemon/client/client.d.ts +3 -1
  33. package/src/daemon/client/client.js +37 -19
  34. package/src/daemon/server/project-graph-incremental-recomputation.js +2 -1
  35. package/src/devkit-exports.d.ts +1 -1
  36. package/src/devkit-exports.js +3 -4
  37. package/src/devkit-internals.d.ts +2 -0
  38. package/src/devkit-internals.js +5 -1
  39. package/src/executors/utils/convert-nx-executor.js +2 -1
  40. package/src/generators/utils/nx-json.js +2 -2
  41. package/src/generators/utils/project-configuration.js +2 -2
  42. package/src/hasher/hash-task.d.ts +2 -3
  43. package/src/hasher/hash-task.js +6 -5
  44. package/src/hasher/task-hasher.js +29 -18
  45. package/src/migrations/update-15-1-0/set-project-names.js +2 -3
  46. package/src/native/assert-supported-platform.js +1 -1
  47. package/src/native/index.d.ts +9 -0
  48. package/src/native/index.js +4 -1
  49. package/src/plugins/js/index.js +4 -0
  50. package/src/plugins/js/lock-file/lock-file.js +5 -2
  51. package/src/plugins/js/lock-file/yarn-parser.d.ts +1 -1
  52. package/src/plugins/js/lock-file/yarn-parser.js +39 -13
  53. package/src/plugins/js/project-graph/build-dependencies/build-dependencies.js +13 -12
  54. package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.js +89 -5
  55. package/src/project-graph/file-utils.js +1 -1
  56. package/src/project-graph/project-graph.js +2 -2
  57. package/src/project-graph/utils/retrieve-workspace-files.d.ts +2 -0
  58. package/src/project-graph/utils/retrieve-workspace-files.js +43 -15
  59. package/src/tasks-runner/cache.js +1 -1
  60. package/src/tasks-runner/run-command.js +1 -2
  61. package/src/tasks-runner/task-orchestrator.d.ts +0 -2
  62. package/src/tasks-runner/task-orchestrator.js +2 -6
  63. package/src/tasks-runner/tasks-schedule.d.ts +1 -5
  64. package/src/tasks-runner/tasks-schedule.js +3 -5
  65. package/src/tasks-runner/utils.d.ts +3 -4
  66. package/src/tasks-runner/utils.js +4 -4
  67. package/src/utils/ab-testing.js +1 -1
  68. package/src/utils/nx-plugin.js +5 -7
  69. package/src/utils/package-manager.d.ts +1 -1
  70. package/src/utils/package-manager.js +7 -4
  71. package/src/utils/testing/temp-fs.js +6 -2
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "16.6.0-beta.3",
3
+ "version": "16.6.0-beta.5",
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.3",
35
+ "@nrwl/tao": "16.6.0-beta.5",
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.3",
85
- "@nx/nx-darwin-x64": "16.6.0-beta.3",
86
- "@nx/nx-freebsd-x64": "16.6.0-beta.3",
87
- "@nx/nx-linux-arm-gnueabihf": "16.6.0-beta.3",
88
- "@nx/nx-linux-arm64-gnu": "16.6.0-beta.3",
89
- "@nx/nx-linux-arm64-musl": "16.6.0-beta.3",
90
- "@nx/nx-linux-x64-gnu": "16.6.0-beta.3",
91
- "@nx/nx-linux-x64-musl": "16.6.0-beta.3",
92
- "@nx/nx-win32-arm64-msvc": "16.6.0-beta.3",
93
- "@nx/nx-win32-x64-msvc": "16.6.0-beta.3"
84
+ "@nx/nx-darwin-arm64": "16.6.0-beta.5",
85
+ "@nx/nx-darwin-x64": "16.6.0-beta.5",
86
+ "@nx/nx-freebsd-x64": "16.6.0-beta.5",
87
+ "@nx/nx-linux-arm-gnueabihf": "16.6.0-beta.5",
88
+ "@nx/nx-linux-arm64-gnu": "16.6.0-beta.5",
89
+ "@nx/nx-linux-arm64-musl": "16.6.0-beta.5",
90
+ "@nx/nx-linux-x64-gnu": "16.6.0-beta.5",
91
+ "@nx/nx-linux-x64-musl": "16.6.0-beta.5",
92
+ "@nx/nx-win32-arm64-msvc": "16.6.0-beta.5",
93
+ "@nx/nx-win32-x64-msvc": "16.6.0-beta.5"
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": "cd8c61d7a3b8ab9bc7bab068f5ca49bbf14abbf5"
180
+ "gitHead": "aab868aa0c30949832fe2c4b9cb109c204442e39"
181
181
  }
@@ -21,6 +21,7 @@ function shouldMergeAngularProjects(root, includeProjectsFromAngularJson) {
21
21
  exports.shouldMergeAngularProjects = shouldMergeAngularProjects;
22
22
  function isAngularPluginInstalled() {
23
23
  try {
24
+ // nx-ignore-next-line
24
25
  require.resolve('@nx/angular');
25
26
  return true;
26
27
  }
@@ -4,6 +4,12 @@ import { Observable } from 'rxjs';
4
4
  import type { GenerateOptions } from '../command-line/generate/generate';
5
5
  import { ProjectConfiguration } from '../config/workspace-json-project-json';
6
6
  import { Tree } from '../generators/tree';
7
+ import { ExecutorContext } from '../config/misc-interfaces';
8
+ export declare function createBuilderContext(builderInfo: {
9
+ builderName: string;
10
+ description: string;
11
+ optionSchema: any;
12
+ }, context: ExecutorContext): Promise<import("@angular-devkit/architect").BuilderContext>;
7
13
  export declare function scheduleTarget(root: string, opts: {
8
14
  project: string;
9
15
  target: string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getLogger = exports.wrapAngularDevkitSchematic = exports.mockSchematicsForTesting = exports.overrideCollectionResolutionForTesting = exports.runMigration = exports.generate = exports.NxScopeHostUsedForWrappedSchematics = exports.arrayBufferToString = exports.NxScopedHost = exports.scheduleTarget = void 0;
3
+ exports.getLogger = exports.wrapAngularDevkitSchematic = exports.mockSchematicsForTesting = exports.overrideCollectionResolutionForTesting = exports.runMigration = exports.generate = exports.NxScopeHostUsedForWrappedSchematics = exports.arrayBufferToString = exports.NxScopedHost = exports.scheduleTarget = exports.createBuilderContext = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const core_1 = require("@angular-devkit/core");
6
6
  const node_1 = require("@angular-devkit/core/node");
@@ -20,9 +20,67 @@ const package_json_1 = require("../utils/package-json");
20
20
  const package_manager_1 = require("../utils/package-manager");
21
21
  const angular_json_1 = require("./angular-json");
22
22
  const executor_utils_1 = require("../command-line/run/executor-utils");
23
- const workspaces_1 = require("../config/workspaces");
24
23
  const nx_plugin_1 = require("../utils/nx-plugin");
25
24
  const schema_utils_1 = require("../config/schema-utils");
25
+ function createBuilderContext(builderInfo, context) {
26
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
27
+ require('nx/src/adapter/compat');
28
+ const fsHost = new NxScopedHost(context.root);
29
+ const { workspace } = yield core_1.workspaces.readWorkspace('angular.json', core_1.workspaces.createWorkspaceHost(fsHost));
30
+ const architectHost = yield getWrappedWorkspaceNodeModulesArchitectHost(workspace, context.root);
31
+ const registry = new core_1.schema.CoreSchemaRegistry();
32
+ registry.addPostTransform(core_1.schema.transforms.addUndefinedDefaults);
33
+ registry.addSmartDefaultProvider('unparsed', () => {
34
+ // This happens when context.scheduleTarget is used to run a target using nx:run-commands
35
+ return [];
36
+ });
37
+ const { Architect } = require('@angular-devkit/architect');
38
+ const architect = new Architect(architectHost, registry);
39
+ const { firstValueFrom } = require('rxjs');
40
+ const toPromise = (obs) => firstValueFrom ? firstValueFrom(obs) : obs.toPromise();
41
+ const validateOptions = (options, builderName) => toPromise(architect['_scheduler'].schedule('..validateOptions', [
42
+ builderName,
43
+ options,
44
+ ]).output);
45
+ const getProjectMetadata = (target) => toPromise(architect['_scheduler'].schedule('..getProjectMetadata', target).output);
46
+ const builderContext = {
47
+ workspaceRoot: context.root,
48
+ target: {
49
+ project: context.projectName,
50
+ target: context.targetName,
51
+ configuration: context.configurationName,
52
+ },
53
+ builder: Object.assign({}, builderInfo),
54
+ logger: (0, exports.getLogger)(),
55
+ id: 1,
56
+ currentDirectory: process.cwd(),
57
+ scheduleTarget: architect.scheduleTarget,
58
+ getBuilderNameForTarget: architectHost.getBuilderNameForTarget,
59
+ scheduleBuilder: architect.scheduleBuilder,
60
+ getTargetOptions: architectHost.getOptionsForTarget,
61
+ addTeardown(teardown) {
62
+ // No-op as Nx doesn't require an implementation of this function
63
+ return;
64
+ },
65
+ reportProgress(...args) {
66
+ // No-op as Nx doesn't require an implementation of this function
67
+ return;
68
+ },
69
+ reportRunning(...args) {
70
+ // No-op as Nx doesn't require an implementation of this function
71
+ return;
72
+ },
73
+ reportStatus(status) {
74
+ // No-op as Nx doesn't require an implementation of this function
75
+ return;
76
+ },
77
+ getProjectMetadata,
78
+ validateOptions,
79
+ };
80
+ return builderContext;
81
+ });
82
+ }
83
+ exports.createBuilderContext = createBuilderContext;
26
84
  function scheduleTarget(root, opts, verbose) {
27
85
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
28
86
  const { Architect } = require('@angular-devkit/architect');
@@ -35,74 +93,7 @@ function scheduleTarget(root, opts, verbose) {
35
93
  // This happens when context.scheduleTarget is used to run a target using nx:run-commands
36
94
  return [];
37
95
  });
38
- const AngularWorkspaceNodeModulesArchitectHost = require('@angular-devkit/architect/node').WorkspaceNodeModulesArchitectHost;
39
- class WrappedWorkspaceNodeModulesArchitectHost extends AngularWorkspaceNodeModulesArchitectHost {
40
- constructor(workspace, root) {
41
- super(workspace, root);
42
- this.workspace = workspace;
43
- this.root = root;
44
- this.workspaces = new workspaces_1.Workspaces(this.root);
45
- }
46
- resolveBuilder(builderStr) {
47
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
48
- const [packageName, builderName] = builderStr.split(':');
49
- const { executorsFilePath, executorConfig } = this.readExecutorsJson(packageName, builderName);
50
- const builderInfo = this.readExecutor(packageName, builderName);
51
- return {
52
- name: builderStr,
53
- builderName,
54
- description: (0, fileutils_1.readJsonFile)(executorsFilePath).builders[builderName]
55
- .description,
56
- optionSchema: builderInfo.schema,
57
- import: (0, schema_utils_1.resolveImplementation)(executorConfig.implementation, (0, path_1.dirname)(executorsFilePath)),
58
- };
59
- });
60
- }
61
- readExecutorsJson(nodeModule, builder) {
62
- var _a, _b;
63
- const { json: packageJson, path: packageJsonPath } = (0, nx_plugin_1.readPluginPackageJson)(nodeModule, this.workspaces['resolvePaths'].bind(this.workspaces)());
64
- const executorsFile = (_a = packageJson.executors) !== null && _a !== void 0 ? _a : packageJson.builders;
65
- if (!executorsFile) {
66
- throw new Error(`The "${nodeModule}" package does not support Nx executors or Angular Devkit Builders.`);
67
- }
68
- const executorsFilePath = require.resolve((0, path_1.join)((0, path_1.dirname)(packageJsonPath), executorsFile));
69
- const executorsJson = (0, fileutils_1.readJsonFile)(executorsFilePath);
70
- const executorConfig = (_b = executorsJson.builders) === null || _b === void 0 ? void 0 : _b[builder];
71
- if (!executorConfig) {
72
- throw new Error(`Cannot find builder '${builder}' in ${executorsFilePath}.`);
73
- }
74
- return { executorsFilePath, executorConfig, isNgCompat: true };
75
- }
76
- readExecutor(nodeModule, executor) {
77
- try {
78
- const { executorsFilePath, executorConfig, isNgCompat } = this.readExecutorsJson(nodeModule, executor);
79
- const executorsDir = (0, path_1.dirname)(executorsFilePath);
80
- const schemaPath = (0, schema_utils_1.resolveSchema)(executorConfig.schema, executorsDir);
81
- const schema = (0, executor_utils_1.normalizeExecutorSchema)((0, fileutils_1.readJsonFile)(schemaPath));
82
- const implementationFactory = this.getImplementationFactory(executorConfig.implementation, executorsDir);
83
- const batchImplementationFactory = executorConfig.batchImplementation
84
- ? this.getImplementationFactory(executorConfig.batchImplementation, executorsDir)
85
- : null;
86
- const hasherFactory = executorConfig.hasher
87
- ? this.getImplementationFactory(executorConfig.hasher, executorsDir)
88
- : null;
89
- return {
90
- schema,
91
- implementationFactory,
92
- batchImplementationFactory,
93
- hasherFactory,
94
- isNgCompat,
95
- };
96
- }
97
- catch (e) {
98
- throw new Error(`Unable to resolve ${nodeModule}:${executor}.\n${e.message}`);
99
- }
100
- }
101
- getImplementationFactory(implementation, executorsDir) {
102
- return (0, schema_utils_1.getImplementationFactory)(implementation, executorsDir);
103
- }
104
- }
105
- const architectHost = new WrappedWorkspaceNodeModulesArchitectHost(workspace, root);
96
+ const architectHost = yield getWrappedWorkspaceNodeModulesArchitectHost(workspace, root);
106
97
  const architect = new Architect(architectHost, registry);
107
98
  const run = yield architect.scheduleTarget({
108
99
  project: opts.project,
@@ -726,3 +717,74 @@ function saveProjectsConfigurationsInWrappedSchematic(host, content) {
726
717
  host.write('angular.json', JSON.stringify((0, angular_json_1.toOldFormat)(newAngularJson), null, 2));
727
718
  }
728
719
  }
720
+ function getWrappedWorkspaceNodeModulesArchitectHost(workspace, root) {
721
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
722
+ const { WorkspaceNodeModulesArchitectHost: AngularWorkspaceNodeModulesArchitectHost, } = yield Promise.resolve().then(() => require('@angular-devkit/architect/node'));
723
+ class WrappedWorkspaceNodeModulesArchitectHost extends AngularWorkspaceNodeModulesArchitectHost {
724
+ constructor(workspace, root) {
725
+ super(workspace, root);
726
+ this.workspace = workspace;
727
+ this.root = root;
728
+ }
729
+ resolveBuilder(builderStr) {
730
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
731
+ const [packageName, builderName] = builderStr.split(':');
732
+ const { executorsFilePath, executorConfig } = this.readExecutorsJson(packageName, builderName);
733
+ const builderInfo = this.readExecutor(packageName, builderName);
734
+ return {
735
+ name: builderStr,
736
+ builderName,
737
+ description: (0, fileutils_1.readJsonFile)(executorsFilePath).builders[builderName]
738
+ .description,
739
+ optionSchema: builderInfo.schema,
740
+ import: (0, schema_utils_1.resolveImplementation)(executorConfig.implementation, (0, path_1.dirname)(executorsFilePath)),
741
+ };
742
+ });
743
+ }
744
+ readExecutorsJson(nodeModule, builder) {
745
+ var _a, _b;
746
+ const { json: packageJson, path: packageJsonPath } = (0, nx_plugin_1.readPluginPackageJson)(nodeModule, this.root ? [this.root, __dirname] : [__dirname]);
747
+ const executorsFile = (_a = packageJson.executors) !== null && _a !== void 0 ? _a : packageJson.builders;
748
+ if (!executorsFile) {
749
+ throw new Error(`The "${nodeModule}" package does not support Nx executors or Angular Devkit Builders.`);
750
+ }
751
+ const executorsFilePath = require.resolve((0, path_1.join)((0, path_1.dirname)(packageJsonPath), executorsFile));
752
+ const executorsJson = (0, fileutils_1.readJsonFile)(executorsFilePath);
753
+ const executorConfig = (_b = executorsJson.builders) === null || _b === void 0 ? void 0 : _b[builder];
754
+ if (!executorConfig) {
755
+ throw new Error(`Cannot find builder '${builder}' in ${executorsFilePath}.`);
756
+ }
757
+ return { executorsFilePath, executorConfig, isNgCompat: true };
758
+ }
759
+ readExecutor(nodeModule, executor) {
760
+ try {
761
+ const { executorsFilePath, executorConfig, isNgCompat } = this.readExecutorsJson(nodeModule, executor);
762
+ const executorsDir = (0, path_1.dirname)(executorsFilePath);
763
+ const schemaPath = (0, schema_utils_1.resolveSchema)(executorConfig.schema, executorsDir);
764
+ const schema = (0, executor_utils_1.normalizeExecutorSchema)((0, fileutils_1.readJsonFile)(schemaPath));
765
+ const implementationFactory = this.getImplementationFactory(executorConfig.implementation, executorsDir);
766
+ const batchImplementationFactory = executorConfig.batchImplementation
767
+ ? this.getImplementationFactory(executorConfig.batchImplementation, executorsDir)
768
+ : null;
769
+ const hasherFactory = executorConfig.hasher
770
+ ? this.getImplementationFactory(executorConfig.hasher, executorsDir)
771
+ : null;
772
+ return {
773
+ schema,
774
+ implementationFactory,
775
+ batchImplementationFactory,
776
+ hasherFactory,
777
+ isNgCompat,
778
+ };
779
+ }
780
+ catch (e) {
781
+ throw new Error(`Unable to resolve ${nodeModule}:${executor}.\n${e.message}`);
782
+ }
783
+ }
784
+ getImplementationFactory(implementation, executorsDir) {
785
+ return (0, schema_utils_1.getImplementationFactory)(implementation, executorsDir);
786
+ }
787
+ }
788
+ return new WrappedWorkspaceNodeModulesArchitectHost(workspace, root);
789
+ });
790
+ }
@@ -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,8 +13,10 @@ 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");
19
+ const generator_utils_1 = require("./generator-utils");
18
20
  function printChanges(fileChanges) {
19
21
  fileChanges.forEach((f) => {
20
22
  if (f.type === 'CREATE') {
@@ -37,7 +39,7 @@ function promptForCollection(generatorName, ws, interactive, projectsConfigurati
37
39
  const deprecatedChoices = new Set();
38
40
  for (const collectionName of installedCollections) {
39
41
  try {
40
- const { resolvedCollectionName, normalizedGeneratorName, generatorConfiguration: { ['x-deprecated']: deprecated, hidden }, } = ws.readGenerator(collectionName, generatorName);
42
+ const { resolvedCollectionName, normalizedGeneratorName, generatorConfiguration: { ['x-deprecated']: deprecated, hidden }, } = (0, generator_utils_1.getGeneratorInformation)(collectionName, generatorName, workspace_root_1.workspaceRoot);
41
43
  if (hidden) {
42
44
  continue;
43
45
  }
@@ -53,7 +55,7 @@ function promptForCollection(generatorName, ws, interactive, projectsConfigurati
53
55
  const choicesFromLocalPlugins = [];
54
56
  for (const [name] of localPlugins) {
55
57
  try {
56
- const { resolvedCollectionName, normalizedGeneratorName, generatorConfiguration: { ['x-deprecated']: deprecated, hidden }, } = ws.readGenerator(name, generatorName);
58
+ const { resolvedCollectionName, normalizedGeneratorName, generatorConfiguration: { ['x-deprecated']: deprecated, hidden }, } = (0, generator_utils_1.getGeneratorInformation)(name, generatorName, workspace_root_1.workspaceRoot);
57
59
  if (hidden) {
58
60
  continue;
59
61
  }
@@ -107,7 +109,7 @@ function promptForCollection(generatorName, ws, interactive, projectsConfigurati
107
109
  return true;
108
110
  }
109
111
  try {
110
- ws.readGenerator(value, generatorName);
112
+ (0, generator_utils_1.getGeneratorInformation)(value, generatorName, workspace_root_1.workspaceRoot);
111
113
  return true;
112
114
  }
113
115
  catch (_a) {
@@ -224,7 +226,7 @@ function generate(cwd, args) {
224
226
  const projectsConfigurations = (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph);
225
227
  return (0, params_1.handleErrors)(verbose, () => tslib_1.__awaiter(this, void 0, void 0, function* () {
226
228
  const opts = yield convertToGenerateOptions(args, ws, readDefaultCollection(nxJsonConfiguration), 'generate', projectsConfigurations);
227
- const { normalizedGeneratorName, schema, implementationFactory, generatorConfiguration: { aliases, hidden, ['x-deprecated']: deprecated, ['x-use-standalone-layout']: isStandalonePreset, }, } = ws.readGenerator(opts.collectionName, opts.generatorName);
229
+ const { normalizedGeneratorName, schema, implementationFactory, generatorConfiguration: { aliases, hidden, ['x-deprecated']: deprecated, ['x-use-standalone-layout']: isStandalonePreset, }, } = (0, generator_utils_1.getGeneratorInformation)(opts.collectionName, opts.generatorName, workspace_root_1.workspaceRoot);
228
230
  if (deprecated) {
229
231
  logger_1.logger.warn([
230
232
  `${logger_1.NX_PREFIX}: ${opts.collectionName}:${normalizedGeneratorName} is deprecated`,
@@ -238,8 +240,8 @@ function generate(cwd, args) {
238
240
  printGenHelp(opts, schema, normalizedGeneratorName, aliases);
239
241
  return 0;
240
242
  }
241
- 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);
242
- if (ws.isNxGenerator(opts.collectionName, normalizedGeneratorName)) {
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);
244
+ if ((0, generator_utils_1.getGeneratorInformation)(opts.collectionName, normalizedGeneratorName, workspace_root_1.workspaceRoot).isNxGenerator) {
243
245
  const host = new tree_1.FsTree(workspace_root_1.workspaceRoot, verbose, `generating (${opts.collectionName}:${normalizedGeneratorName})`);
244
246
  const implementation = implementationFactory();
245
247
  // @todo(v17): Remove this, isStandalonePreset property is defunct.
@@ -0,0 +1,16 @@
1
+ import { Generator, GeneratorsJson, GeneratorsJsonEntry } from '../../config/misc-interfaces';
2
+ export declare function getGeneratorInformation(collectionName: string, generatorName: string, root: string | null): {
3
+ resolvedCollectionName: string;
4
+ normalizedGeneratorName: string;
5
+ schema: any;
6
+ implementationFactory: () => Generator<unknown>;
7
+ isNgCompat: boolean;
8
+ isNxGenerator: boolean;
9
+ generatorConfiguration: GeneratorsJsonEntry;
10
+ };
11
+ export declare function readGeneratorsJson(collectionName: string, generator: string, root: string | null): {
12
+ generatorsFilePath: string;
13
+ generatorsJson: GeneratorsJson;
14
+ normalizedGeneratorName: string;
15
+ resolvedCollectionName: string;
16
+ };
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readGeneratorsJson = exports.getGeneratorInformation = void 0;
4
+ const path_1 = require("path");
5
+ const schema_utils_1 = require("../../config/schema-utils");
6
+ const fileutils_1 = require("../../utils/fileutils");
7
+ const nx_plugin_1 = require("../../utils/nx-plugin");
8
+ function getGeneratorInformation(collectionName, generatorName, root) {
9
+ var _a, _b, _c, _d;
10
+ try {
11
+ const { generatorsFilePath, generatorsJson, resolvedCollectionName, normalizedGeneratorName, } = readGeneratorsJson(collectionName, generatorName, root);
12
+ const generatorsDir = (0, path_1.dirname)(generatorsFilePath);
13
+ const generatorConfig = ((_a = generatorsJson.generators) === null || _a === void 0 ? void 0 : _a[normalizedGeneratorName]) ||
14
+ ((_b = generatorsJson.schematics) === null || _b === void 0 ? void 0 : _b[normalizedGeneratorName]);
15
+ const isNgCompat = !((_c = generatorsJson.generators) === null || _c === void 0 ? void 0 : _c[normalizedGeneratorName]);
16
+ const schemaPath = (0, schema_utils_1.resolveSchema)(generatorConfig.schema, generatorsDir);
17
+ const schema = (0, fileutils_1.readJsonFile)(schemaPath);
18
+ if (!schema.properties || typeof schema.properties !== 'object') {
19
+ schema.properties = {};
20
+ }
21
+ generatorConfig.implementation =
22
+ generatorConfig.implementation || generatorConfig.factory;
23
+ const implementationFactory = (0, schema_utils_1.getImplementationFactory)(generatorConfig.implementation, generatorsDir);
24
+ const normalizedGeneratorConfiguration = Object.assign(Object.assign({}, generatorConfig), { aliases: (_d = generatorConfig.aliases) !== null && _d !== void 0 ? _d : [], hidden: !!generatorConfig.hidden });
25
+ return {
26
+ resolvedCollectionName,
27
+ normalizedGeneratorName,
28
+ schema,
29
+ implementationFactory,
30
+ isNgCompat,
31
+ isNxGenerator: !isNgCompat,
32
+ generatorConfiguration: normalizedGeneratorConfiguration,
33
+ };
34
+ }
35
+ catch (e) {
36
+ throw new Error(`Unable to resolve ${collectionName}:${generatorName}.\n${e.message}`);
37
+ }
38
+ }
39
+ exports.getGeneratorInformation = getGeneratorInformation;
40
+ function readGeneratorsJson(collectionName, generator, root) {
41
+ var _a;
42
+ let generatorsFilePath;
43
+ if (collectionName.endsWith('.json')) {
44
+ generatorsFilePath = require.resolve(collectionName, {
45
+ paths: root ? [root, __dirname] : [__dirname],
46
+ });
47
+ }
48
+ else {
49
+ const { json: packageJson, path: packageJsonPath } = (0, nx_plugin_1.readPluginPackageJson)(collectionName, root ? [root, __dirname] : [__dirname]);
50
+ const generatorsFile = (_a = packageJson.generators) !== null && _a !== void 0 ? _a : packageJson.schematics;
51
+ if (!generatorsFile) {
52
+ throw new Error(`The "${collectionName}" package does not support Nx generators.`);
53
+ }
54
+ generatorsFilePath = require.resolve((0, path_1.join)((0, path_1.dirname)(packageJsonPath), generatorsFile));
55
+ }
56
+ const generatorsJson = (0, fileutils_1.readJsonFile)(generatorsFilePath);
57
+ let normalizedGeneratorName = findFullGeneratorName(generator, generatorsJson.generators) ||
58
+ findFullGeneratorName(generator, generatorsJson.schematics);
59
+ if (!normalizedGeneratorName) {
60
+ for (let parent of generatorsJson.extends || []) {
61
+ try {
62
+ return readGeneratorsJson(parent, generator, root);
63
+ }
64
+ catch (e) { }
65
+ }
66
+ throw new Error(`Cannot find generator '${generator}' in ${generatorsFilePath}.`);
67
+ }
68
+ return {
69
+ generatorsFilePath,
70
+ generatorsJson,
71
+ normalizedGeneratorName,
72
+ resolvedCollectionName: collectionName,
73
+ };
74
+ }
75
+ exports.readGeneratorsJson = readGeneratorsJson;
76
+ function findFullGeneratorName(name, generators) {
77
+ if (generators) {
78
+ for (let [key, data] of Object.entries(generators)) {
79
+ if (key === name ||
80
+ (data.aliases && data.aliases.includes(name))) {
81
+ return key;
82
+ }
83
+ }
84
+ }
85
+ }
@@ -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/other/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`,
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.newWorkspace = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const workspaces_1 = require("../../config/workspaces");
6
5
  const tree_1 = require("../../generators/tree");
7
6
  const params_1 = require("../../utils/params");
7
+ const generator_utils_1 = require("../generate/generator-utils");
8
8
  function removeSpecialFlags(generatorOptions) {
9
9
  delete generatorOptions.interactive;
10
10
  delete generatorOptions.help;
@@ -14,10 +14,9 @@ function removeSpecialFlags(generatorOptions) {
14
14
  }
15
15
  function newWorkspace(cwd, args) {
16
16
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
17
- const ws = new workspaces_1.Workspaces(null);
18
17
  return (0, params_1.handleErrors)(process.env.NX_VERBOSE_LOGGING === 'true' || args.verbose, () => tslib_1.__awaiter(this, void 0, void 0, function* () {
19
18
  const isInteractive = args.interactive;
20
- const { normalizedGeneratorName, schema, implementationFactory } = ws.readGenerator('@nx/workspace/generators.json', 'new');
19
+ const { normalizedGeneratorName, schema, implementationFactory } = (0, generator_utils_1.getGeneratorInformation)('@nx/workspace/generators.json', 'new', null);
21
20
  removeSpecialFlags(args);
22
21
  const combinedOpts = yield (0, params_1.combineOptionsForGenerator)(args, '@nx/workspace/generators.json', normalizedGeneratorName, null, null, schema, isInteractive, null, null, false);
23
22
  const host = new tree_1.FsTree(cwd, false, 'nx new');
@@ -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;