nx 16.6.0-beta.3 → 16.6.0-beta.4

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.
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.4",
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.4",
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.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"
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": "b1a9ae7ce76697019b26ec9a172005840cca8da6"
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
+ }
@@ -15,6 +15,7 @@ const print_help_1 = require("../../utils/print-help");
15
15
  const workspace_root_1 = require("../../utils/workspace-root");
16
16
  const installed_plugins_1 = require("../../utils/plugins/installed-plugins");
17
17
  const output_1 = require("../../utils/output");
18
+ const generator_utils_1 = require("./generator-utils");
18
19
  function printChanges(fileChanges) {
19
20
  fileChanges.forEach((f) => {
20
21
  if (f.type === 'CREATE') {
@@ -37,7 +38,7 @@ function promptForCollection(generatorName, ws, interactive, projectsConfigurati
37
38
  const deprecatedChoices = new Set();
38
39
  for (const collectionName of installedCollections) {
39
40
  try {
40
- const { resolvedCollectionName, normalizedGeneratorName, generatorConfiguration: { ['x-deprecated']: deprecated, hidden }, } = ws.readGenerator(collectionName, generatorName);
41
+ const { resolvedCollectionName, normalizedGeneratorName, generatorConfiguration: { ['x-deprecated']: deprecated, hidden }, } = (0, generator_utils_1.getGeneratorInformation)(collectionName, generatorName, workspace_root_1.workspaceRoot);
41
42
  if (hidden) {
42
43
  continue;
43
44
  }
@@ -53,7 +54,7 @@ function promptForCollection(generatorName, ws, interactive, projectsConfigurati
53
54
  const choicesFromLocalPlugins = [];
54
55
  for (const [name] of localPlugins) {
55
56
  try {
56
- const { resolvedCollectionName, normalizedGeneratorName, generatorConfiguration: { ['x-deprecated']: deprecated, hidden }, } = ws.readGenerator(name, generatorName);
57
+ const { resolvedCollectionName, normalizedGeneratorName, generatorConfiguration: { ['x-deprecated']: deprecated, hidden }, } = (0, generator_utils_1.getGeneratorInformation)(name, generatorName, workspace_root_1.workspaceRoot);
57
58
  if (hidden) {
58
59
  continue;
59
60
  }
@@ -107,7 +108,7 @@ function promptForCollection(generatorName, ws, interactive, projectsConfigurati
107
108
  return true;
108
109
  }
109
110
  try {
110
- ws.readGenerator(value, generatorName);
111
+ (0, generator_utils_1.getGeneratorInformation)(value, generatorName, workspace_root_1.workspaceRoot);
111
112
  return true;
112
113
  }
113
114
  catch (_a) {
@@ -224,7 +225,7 @@ function generate(cwd, args) {
224
225
  const projectsConfigurations = (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph);
225
226
  return (0, params_1.handleErrors)(verbose, () => tslib_1.__awaiter(this, void 0, void 0, function* () {
226
227
  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);
228
+ 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
229
  if (deprecated) {
229
230
  logger_1.logger.warn([
230
231
  `${logger_1.NX_PREFIX}: ${opts.collectionName}:${normalizedGeneratorName} is deprecated`,
@@ -239,7 +240,7 @@ function generate(cwd, args) {
239
240
  return 0;
240
241
  }
241
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);
242
- if (ws.isNxGenerator(opts.collectionName, normalizedGeneratorName)) {
243
+ if ((0, generator_utils_1.getGeneratorInformation)(opts.collectionName, normalizedGeneratorName, workspace_root_1.workspaceRoot).isNxGenerator) {
243
244
  const host = new tree_1.FsTree(workspace_root_1.workspaceRoot, verbose, `generating (${opts.collectionName}:${normalizedGeneratorName})`);
244
245
  const implementation = implementationFactory();
245
246
  // @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
+ }
@@ -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/managing-repository/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,6 +1,5 @@
1
1
  import type { NxJsonConfiguration, TargetDefaults } from './nx-json';
2
2
  import { ProjectConfiguration, ProjectsConfigurations, TargetConfiguration } from './workspace-json-project-json';
3
- import { Generator, GeneratorsJsonEntry } from './misc-interfaces';
4
3
  export declare class Workspaces {
5
4
  private root;
6
5
  private cachedProjectsConfig;
@@ -22,23 +21,8 @@ export declare class Workspaces {
22
21
  _includeProjectsFromAngularJson?: boolean;
23
22
  }): ProjectsConfigurations & NxJsonConfiguration;
24
23
  private mergeTargetDefaultsIntoProjectDescriptions;
25
- isNxGenerator(collectionName: string, generatorName: string): boolean;
26
- readGenerator(collectionName: string, generatorName: string): {
27
- resolvedCollectionName: string;
28
- normalizedGeneratorName: string;
29
- schema: any;
30
- implementationFactory: () => Generator<unknown>;
31
- isNgCompat: boolean;
32
- /**
33
- * @deprecated(v16): This will be removed in v16, use generatorConfiguration.aliases
34
- */
35
- aliases: string[];
36
- generatorConfiguration: GeneratorsJsonEntry;
37
- };
38
24
  hasNxJson(): boolean;
39
25
  readNxJson(): NxJsonConfiguration;
40
- private readGeneratorsJson;
41
- private resolvePaths;
42
26
  }
43
27
  /**
44
28
  * Pulled from toFileName in names from @nx/devkit.
@@ -17,7 +17,6 @@ const angular_json_1 = require("../adapter/angular-json");
17
17
  const installation_directory_1 = require("../utils/installation-directory");
18
18
  const ignore_1 = require("../utils/ignore");
19
19
  const find_project_for_path_1 = require("../project-graph/utils/find-project-for-path");
20
- const schema_utils_1 = require("./schema-utils");
21
20
  class Workspaces {
22
21
  constructor(root) {
23
22
  this.root = root;
@@ -92,40 +91,6 @@ class Workspaces {
92
91
  }
93
92
  return projects;
94
93
  }
95
- isNxGenerator(collectionName, generatorName) {
96
- return !this.readGenerator(collectionName, generatorName).isNgCompat;
97
- }
98
- readGenerator(collectionName, generatorName) {
99
- var _a, _b, _c, _d;
100
- try {
101
- const { generatorsFilePath, generatorsJson, resolvedCollectionName, normalizedGeneratorName, } = this.readGeneratorsJson(collectionName, generatorName);
102
- const generatorsDir = path.dirname(generatorsFilePath);
103
- const generatorConfig = ((_a = generatorsJson.generators) === null || _a === void 0 ? void 0 : _a[normalizedGeneratorName]) ||
104
- ((_b = generatorsJson.schematics) === null || _b === void 0 ? void 0 : _b[normalizedGeneratorName]);
105
- const isNgCompat = !((_c = generatorsJson.generators) === null || _c === void 0 ? void 0 : _c[normalizedGeneratorName]);
106
- const schemaPath = (0, schema_utils_1.resolveSchema)(generatorConfig.schema, generatorsDir);
107
- const schema = (0, fileutils_1.readJsonFile)(schemaPath);
108
- if (!schema.properties || typeof schema.properties !== 'object') {
109
- schema.properties = {};
110
- }
111
- generatorConfig.implementation =
112
- generatorConfig.implementation || generatorConfig.factory;
113
- const implementationFactory = (0, schema_utils_1.getImplementationFactory)(generatorConfig.implementation, generatorsDir);
114
- const normalizedGeneratorConfiguration = Object.assign(Object.assign({}, generatorConfig), { aliases: (_d = generatorConfig.aliases) !== null && _d !== void 0 ? _d : [], hidden: !!generatorConfig.hidden });
115
- return {
116
- resolvedCollectionName,
117
- normalizedGeneratorName,
118
- schema,
119
- implementationFactory,
120
- isNgCompat,
121
- aliases: generatorConfig.aliases || [],
122
- generatorConfiguration: normalizedGeneratorConfiguration,
123
- };
124
- }
125
- catch (e) {
126
- throw new Error(`Unable to resolve ${collectionName}:${generatorName}.\n${e.message}`);
127
- }
128
- }
129
94
  hasNxJson() {
130
95
  const nxJson = path.join(this.root, 'nx.json');
131
96
  return (0, fs_1.existsSync)(nxJson);
@@ -154,44 +119,6 @@ class Workspaces {
154
119
  }
155
120
  }
156
121
  }
157
- readGeneratorsJson(collectionName, generator) {
158
- var _a;
159
- let generatorsFilePath;
160
- if (collectionName.endsWith('.json')) {
161
- generatorsFilePath = require.resolve(collectionName, {
162
- paths: this.resolvePaths(),
163
- });
164
- }
165
- else {
166
- const { json: packageJson, path: packageJsonPath } = (0, nx_plugin_1.readPluginPackageJson)(collectionName, this.resolvePaths());
167
- const generatorsFile = (_a = packageJson.generators) !== null && _a !== void 0 ? _a : packageJson.schematics;
168
- if (!generatorsFile) {
169
- throw new Error(`The "${collectionName}" package does not support Nx generators.`);
170
- }
171
- generatorsFilePath = require.resolve(path.join(path.dirname(packageJsonPath), generatorsFile));
172
- }
173
- const generatorsJson = (0, fileutils_1.readJsonFile)(generatorsFilePath);
174
- let normalizedGeneratorName = findFullGeneratorName(generator, generatorsJson.generators) ||
175
- findFullGeneratorName(generator, generatorsJson.schematics);
176
- if (!normalizedGeneratorName) {
177
- for (let parent of generatorsJson.extends || []) {
178
- try {
179
- return this.readGeneratorsJson(parent, generator);
180
- }
181
- catch (e) { }
182
- }
183
- throw new Error(`Cannot find generator '${generator}' in ${generatorsFilePath}.`);
184
- }
185
- return {
186
- generatorsFilePath,
187
- generatorsJson,
188
- normalizedGeneratorName,
189
- resolvedCollectionName: collectionName,
190
- };
191
- }
192
- resolvePaths() {
193
- return this.root ? [this.root, __dirname] : [__dirname];
194
- }
195
122
  }
196
123
  exports.Workspaces = Workspaces;
197
124
  function findMatchingProjectInCwd(projects, relativeCwd) {
@@ -203,16 +130,6 @@ function findMatchingProjectInCwd(projects, relativeCwd) {
203
130
  const matchingProject = (0, find_project_for_path_1.findProjectForPath)(relativeCwd, projectRootMappings);
204
131
  return matchingProject;
205
132
  }
206
- function findFullGeneratorName(name, generators) {
207
- if (generators) {
208
- for (let [key, data] of Object.entries(generators)) {
209
- if (key === name ||
210
- (data.aliases && data.aliases.includes(name))) {
211
- return key;
212
- }
213
- }
214
- }
215
- }
216
133
  /**
217
134
  * Pulled from toFileName in names from @nx/devkit.
218
135
  * Todo: Should refactor, not duplicate.
@@ -14,6 +14,7 @@ export function hashArray(input: Array<string>): string
14
14
  export function hashFile(file: string): FileData | null
15
15
  export function hashFiles(workspaceRoot: string): Record<string, string>
16
16
  export function hashFilesMatchingGlobs(directory: string, globPatterns: Array<string>): string | null
17
+ export function findImports(projectFileMap: Record<string, Array<string>>): Array<ImportResult>
17
18
  export interface FileData {
18
19
  file: string
19
20
  hash: string
@@ -44,6 +45,12 @@ export interface NxWorkspaceFiles {
44
45
  projectConfigurations: Record<string, object>
45
46
  }
46
47
  export function getWorkspaceFilesNative(workspaceRoot: string, globs: Array<string>, parseConfigurations: (arg0: Array<string>) => Record<string, object>): NxWorkspaceFiles
48
+ export class ImportResult {
49
+ file: string
50
+ sourceProject: string
51
+ dynamicImportExpressions: Array<string>
52
+ staticImportExpressions: Array<string>
53
+ }
47
54
  export class Watcher {
48
55
  origin: string
49
56
  /**
@@ -246,7 +246,7 @@ if (!nativeBinding) {
246
246
  throw new Error(`Failed to load native binding`)
247
247
  }
248
248
 
249
- const { expandOutputs, remove, copy, hashArray, hashFile, hashFiles, hashFilesMatchingGlobs, EventType, Watcher, WorkspaceErrors, getProjectConfigurations, getWorkspaceFilesNative } = nativeBinding
249
+ const { expandOutputs, remove, copy, hashArray, hashFile, hashFiles, hashFilesMatchingGlobs, ImportResult, findImports, EventType, Watcher, WorkspaceErrors, getProjectConfigurations, getWorkspaceFilesNative } = nativeBinding
250
250
 
251
251
  module.exports.expandOutputs = expandOutputs
252
252
  module.exports.remove = remove
@@ -255,6 +255,8 @@ module.exports.hashArray = hashArray
255
255
  module.exports.hashFile = hashFile
256
256
  module.exports.hashFiles = hashFiles
257
257
  module.exports.hashFilesMatchingGlobs = hashFilesMatchingGlobs
258
+ module.exports.ImportResult = ImportResult
259
+ module.exports.findImports = findImports
258
260
  module.exports.EventType = EventType
259
261
  module.exports.Watcher = Watcher
260
262
  module.exports.WorkspaceErrors = WorkspaceErrors
@@ -12,6 +12,7 @@ const cache_directory_1 = require("../../utils/cache-directory");
12
12
  const fs_1 = require("fs");
13
13
  const workspace_root_1 = require("../../utils/workspace-root");
14
14
  const fs_extra_1 = require("fs-extra");
15
+ const perf_hooks_1 = require("perf_hooks");
15
16
  const processProjectGraph = (graph, context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
16
17
  const builder = new project_graph_builder_1.ProjectGraphBuilder(graph, context.fileMap);
17
18
  const pluginConfig = jsPluginConfig((0, configuration_1.readNxJson)());
@@ -30,7 +31,10 @@ const processProjectGraph = (graph, context) => tslib_1.__awaiter(void 0, void 0
30
31
  builder.mergeProjectGraph(parsedLockFile);
31
32
  }
32
33
  }
34
+ perf_hooks_1.performance.mark('build typescript dependencies - start');
33
35
  yield (0, build_dependencies_1.buildExplicitDependencies)(pluginConfig, context, builder);
36
+ perf_hooks_1.performance.mark('build typescript dependencies - end');
37
+ perf_hooks_1.performance.measure('build typescript dependencies', 'build typescript dependencies - start', 'build typescript dependencies - end');
34
38
  return builder.getUpdatedProjectGraph();
35
39
  });
36
40
  exports.processProjectGraph = processProjectGraph;
@@ -13,7 +13,9 @@ function buildExplicitDependencies(jsPluginConfig, ctx, builder) {
13
13
  // files we need to process is >= 100 and there are more than 2 CPUs
14
14
  // to be able to use at least 2 workers (1 worker per CPU and
15
15
  // 1 CPU for the main thread)
16
- if (jsPluginConfig.analyzeSourceFiles === false ||
16
+ if ((process.env.NX_NATIVE_TS_DEPS &&
17
+ process.env.NX_NATIVE_TS_DEPS !== 'false') ||
18
+ jsPluginConfig.analyzeSourceFiles === false ||
17
19
  totalNumOfFilesToProcess < 100 ||
18
20
  getNumberOfWorkers() <= 2) {
19
21
  return buildExplicitDependenciesWithoutWorkers(jsPluginConfig, ctx, builder);
@@ -59,15 +61,16 @@ function createWorkerPool(numberOfWorkers) {
59
61
  }
60
62
  return res;
61
63
  }
64
+ function addDependency(builder, dependency) {
65
+ if (dependency.type === project_graph_1.DependencyType.static) {
66
+ builder.addStaticDependency(dependency.sourceProjectName, dependency.targetProjectName, dependency.sourceProjectFile);
67
+ }
68
+ else {
69
+ builder.addDynamicDependency(dependency.sourceProjectName, dependency.targetProjectName, dependency.sourceProjectFile);
70
+ }
71
+ }
62
72
  function buildExplicitDependenciesWithoutWorkers(jsPluginConfig, ctx, builder) {
63
- (0, build_explicit_typescript_and_package_json_dependencies_1.buildExplicitTypescriptAndPackageJsonDependencies)(jsPluginConfig, ctx.nxJsonConfiguration, ctx.projectsConfigurations, builder.graph, ctx.filesToProcess).forEach((r) => {
64
- if (r.type === project_graph_1.DependencyType.static) {
65
- builder.addStaticDependency(r.sourceProjectName, r.targetProjectName, r.sourceProjectFile);
66
- }
67
- else {
68
- builder.addDynamicDependency(r.sourceProjectName, r.targetProjectName, r.sourceProjectFile);
69
- }
70
- });
73
+ (0, build_explicit_typescript_and_package_json_dependencies_1.buildExplicitTypescriptAndPackageJsonDependencies)(jsPluginConfig, ctx.nxJsonConfiguration, ctx.projectsConfigurations, builder.graph, ctx.filesToProcess).forEach((r) => addDependency(builder, r));
71
74
  }
72
75
  function buildExplicitDependenciesUsingWorkers(jsPluginConfig, ctx, totalNumOfFilesToProcess, builder) {
73
76
  const numberOfWorkers = Math.min(totalNumOfFilesToProcess, getNumberOfWorkers());
@@ -77,9 +80,7 @@ function buildExplicitDependenciesUsingWorkers(jsPluginConfig, ctx, totalNumOfFi
77
80
  return new Promise((res, reject) => {
78
81
  for (let w of workers) {
79
82
  w.on('message', (explicitDependencies) => {
80
- explicitDependencies.forEach((r) => {
81
- builder.addExplicitDependency(r.sourceProjectName, r.sourceProjectFile, r.targetProjectName);
82
- });
83
+ explicitDependencies.forEach((r) => addDependency(builder, r));
83
84
  if (bins.length > 0) {
84
85
  w.postMessage({ filesToProcess: bins.shift() });
85
86
  }
@@ -3,11 +3,96 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.buildExplicitTypeScriptDependencies = void 0;
4
4
  const typescript_import_locator_1 = require("./typescript-import-locator");
5
5
  const target_project_locator_1 = require("./target-project-locator");
6
+ const project_graph_1 = require("../../../../config/project-graph");
6
7
  function buildExplicitTypeScriptDependencies(graph, filesToProcess) {
7
- function isRoot(projectName) {
8
- var _a, _b;
9
- return ((_b = (_a = graph.nodes[projectName]) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.root) === '.';
8
+ let results;
9
+ if (process.env.NX_NATIVE_TS_DEPS &&
10
+ process.env.NX_NATIVE_TS_DEPS !== 'false') {
11
+ results = buildExplicitTypeScriptDependenciesWithSwc(filesToProcess, graph);
10
12
  }
13
+ else {
14
+ results = buildExplicitTypeScriptDependenciesWithTs(filesToProcess, graph);
15
+ }
16
+ if (process.env.NX_NATIVE_TS_DEPS &&
17
+ process.env.NX_NATIVE_TS_DEPS === 'debug') {
18
+ const tsResults = buildExplicitTypeScriptDependenciesWithTs(filesToProcess, graph);
19
+ const set = new Set();
20
+ for (const dep of results) {
21
+ set.add(`+ ${dep.sourceProjectName} -> ${dep.targetProjectName} (${dep.sourceProjectFile})`);
22
+ }
23
+ for (const dep of tsResults) {
24
+ set.delete(`+ ${dep.sourceProjectName} -> ${dep.targetProjectName} (${dep.sourceProjectFile})`);
25
+ set.add(`- ${dep.sourceProjectName} -> ${dep.targetProjectName} (${dep.sourceProjectFile})`);
26
+ }
27
+ for (const dep of results) {
28
+ set.delete(`- ${dep.sourceProjectName} -> ${dep.targetProjectName} (${dep.sourceProjectFile})`);
29
+ }
30
+ set.forEach((s) => console.log(s));
31
+ }
32
+ return results;
33
+ }
34
+ exports.buildExplicitTypeScriptDependencies = buildExplicitTypeScriptDependencies;
35
+ function isRoot(graph, projectName) {
36
+ var _a, _b;
37
+ return ((_b = (_a = graph.nodes[projectName]) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.root) === '.';
38
+ }
39
+ function convertImportToDependency(importExpr, file, sourceProject, type, targetProjectLocator) {
40
+ const target = targetProjectLocator.findProjectWithImport(importExpr, file);
41
+ let targetProjectName;
42
+ if (target) {
43
+ targetProjectName = target;
44
+ }
45
+ else {
46
+ // treat all unknowns as npm packages, they can be eiher
47
+ // - mistyped local import, which has to be fixed manually
48
+ // - node internals, which should still be tracked as a dependency
49
+ // - npm packages, which are not yet installed but should be tracked
50
+ targetProjectName = `npm:${importExpr}`;
51
+ }
52
+ return {
53
+ sourceProjectName: sourceProject,
54
+ targetProjectName,
55
+ sourceProjectFile: file,
56
+ type,
57
+ };
58
+ }
59
+ function buildExplicitTypeScriptDependenciesWithSwc(projectFileMap, graph) {
60
+ var _a;
61
+ const targetProjectLocator = new target_project_locator_1.TargetProjectLocator(graph.nodes, graph.externalNodes);
62
+ const res = [];
63
+ const filesToProcess = {};
64
+ const moduleExtensions = ['.ts', '.js', '.tsx', '.jsx', '.mts', '.mjs'];
65
+ for (const [project, fileData] of Object.entries(projectFileMap)) {
66
+ (_a = filesToProcess[project]) !== null && _a !== void 0 ? _a : (filesToProcess[project] = []);
67
+ for (const { file } of fileData) {
68
+ if (moduleExtensions.some((ext) => file.endsWith(ext))) {
69
+ filesToProcess[project].push(file);
70
+ }
71
+ }
72
+ }
73
+ const { findImports } = require('../../../../native');
74
+ const imports = findImports(filesToProcess);
75
+ for (const { sourceProject, file, staticImportExpressions, dynamicImportExpressions, } of imports) {
76
+ for (const importExpr of staticImportExpressions) {
77
+ const dependency = convertImportToDependency(importExpr, file, sourceProject, project_graph_1.DependencyType.static, targetProjectLocator);
78
+ // TODO: These edges technically should be allowed but we need to figure out how to separate config files out from root
79
+ if (isRoot(graph, dependency.sourceProjectName) ||
80
+ !isRoot(graph, dependency.targetProjectName)) {
81
+ res.push(dependency);
82
+ }
83
+ }
84
+ for (const importExpr of dynamicImportExpressions) {
85
+ const dependency = convertImportToDependency(importExpr, file, sourceProject, project_graph_1.DependencyType.dynamic, targetProjectLocator);
86
+ // TODO: These edges technically should be allowed but we need to figure out how to separate config files out from root
87
+ if (isRoot(graph, dependency.sourceProjectName) ||
88
+ !isRoot(graph, dependency.targetProjectName)) {
89
+ res.push(dependency);
90
+ }
91
+ }
92
+ }
93
+ return res;
94
+ }
95
+ function buildExplicitTypeScriptDependenciesWithTs(filesToProcess, graph) {
11
96
  const importLocator = new typescript_import_locator_1.TypeScriptImportLocator();
12
97
  const targetProjectLocator = new target_project_locator_1.TargetProjectLocator(graph.nodes, graph.externalNodes);
13
98
  const res = [];
@@ -17,7 +102,7 @@ function buildExplicitTypeScriptDependencies(graph, filesToProcess) {
17
102
  const target = targetProjectLocator.findProjectWithImport(importExpr, f.file);
18
103
  let targetProjectName;
19
104
  if (target) {
20
- if (!isRoot(source) && isRoot(target)) {
105
+ if (!isRoot(graph, source) && isRoot(graph, target)) {
21
106
  // TODO: These edges technically should be allowed but we need to figure out how to separate config files out from root
22
107
  return;
23
108
  }
@@ -41,4 +126,3 @@ function buildExplicitTypeScriptDependencies(graph, filesToProcess) {
41
126
  });
42
127
  return res;
43
128
  }
44
- exports.buildExplicitTypeScriptDependencies = buildExplicitTypeScriptDependencies;
@@ -52,7 +52,7 @@ function recordStat(opts) {
52
52
  if (process.env.NX_VERBOSE_LOGGING === 'true') {
53
53
  console.log(`Record stat. Major: ${major}`);
54
54
  }
55
- if (major < 10 || major > 15)
55
+ if (major < 10 || major > 16)
56
56
  return; // test version, skip it
57
57
  const axios = require('axios');
58
58
  yield ((_a = axios['default']) !== null && _a !== void 0 ? _a : axios)
@@ -34,7 +34,7 @@ export declare function getPackageManagerCommand(packageManager?: PackageManager
34
34
  * By default, the package manager is derived based on the lock file,
35
35
  * but it can also be passed in explicitly.
36
36
  */
37
- export declare function getPackageManagerVersion(packageManager?: PackageManager): string;
37
+ export declare function getPackageManagerVersion(packageManager?: PackageManager, cwd?: string): string;
38
38
  /**
39
39
  * Checks for a project level npmrc file by crawling up the file tree until
40
40
  * hitting a package.json file, as this is how npm finds them as well.
@@ -44,7 +44,7 @@ exports.detectPackageManager = detectPackageManager;
44
44
  function getPackageManagerCommand(packageManager = detectPackageManager(), root = workspace_root_1.workspaceRoot) {
45
45
  const commands = {
46
46
  yarn: () => {
47
- const yarnVersion = getPackageManagerVersion('yarn');
47
+ const yarnVersion = getPackageManagerVersion('yarn', root);
48
48
  const useBerry = (0, semver_1.gte)(yarnVersion, '2.0.0');
49
49
  return {
50
50
  preInstall: useBerry
@@ -63,7 +63,7 @@ function getPackageManagerCommand(packageManager = detectPackageManager(), root
63
63
  };
64
64
  },
65
65
  pnpm: () => {
66
- const pnpmVersion = getPackageManagerVersion('pnpm');
66
+ const pnpmVersion = getPackageManagerVersion('pnpm', root);
67
67
  const useExec = (0, semver_1.gte)(pnpmVersion, '6.13.0');
68
68
  const includeDoubleDashBeforeArgs = (0, semver_1.lt)(pnpmVersion, '7.0.0');
69
69
  const isPnpmWorkspace = (0, fs_1.existsSync)((0, path_1.join)(root, 'pnpm-workspace.yaml'));
@@ -105,8 +105,11 @@ exports.getPackageManagerCommand = getPackageManagerCommand;
105
105
  * By default, the package manager is derived based on the lock file,
106
106
  * but it can also be passed in explicitly.
107
107
  */
108
- function getPackageManagerVersion(packageManager = detectPackageManager()) {
109
- return (0, child_process_1.execSync)(`${packageManager} --version`).toString('utf-8').trim();
108
+ function getPackageManagerVersion(packageManager = detectPackageManager(), cwd = process.cwd()) {
109
+ return (0, child_process_1.execSync)(`${packageManager} --version`, {
110
+ cwd,
111
+ encoding: 'utf-8',
112
+ }).trim();
110
113
  }
111
114
  exports.getPackageManagerVersion = getPackageManagerVersion;
112
115
  /**
@@ -33,7 +33,11 @@ class TempFs {
33
33
  });
34
34
  }
35
35
  createFileSync(filePath, content) {
36
- (0, fs_extra_1.outputFileSync)((0, path_2.joinPathFragments)(this.tempDir, filePath), content);
36
+ let dir = (0, path_2.joinPathFragments)(this.tempDir, (0, path_1.dirname)(filePath));
37
+ if (!(0, fs_1.existsSync)(dir)) {
38
+ (0, fs_extra_1.mkdirpSync)(dir);
39
+ }
40
+ (0, fs_1.writeFileSync)((0, path_2.joinPathFragments)(this.tempDir, filePath), content);
37
41
  }
38
42
  readFile(filePath) {
39
43
  return tslib_1.__awaiter(this, void 0, void 0, function* () {