@nx/devkit 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.
@@ -19,7 +19,7 @@ export type { Generator, GeneratorCallback, Executor, ExecutorContext, TaskGraph
19
19
  * @category Workspace
20
20
  */
21
21
  export { Workspaces } from 'nx/src/config/workspaces';
22
- export { readAllWorkspaceConfiguration, workspaceLayout, } from 'nx/src/project-graph/file-utils';
22
+ export { readAllWorkspaceConfiguration, workspaceLayout, } from 'nx/src/config/configuration';
23
23
  export type { NxPlugin, ProjectTargetConfigurator, } from 'nx/src/utils/nx-plugin';
24
24
  /**
25
25
  * @category Workspace
@@ -11,10 +11,9 @@ exports.cacheDir = exports.defaultTasksRunner = exports.getOutputsForTargetAndCo
11
11
  */
12
12
  var workspaces_1 = require("nx/src/config/workspaces");
13
13
  Object.defineProperty(exports, "Workspaces", { enumerable: true, get: function () { return workspaces_1.Workspaces; } });
14
- // TODO (v16): Change this to export from 'nx/src/config/configuration'
15
- var file_utils_1 = require("nx/src/project-graph/file-utils");
16
- Object.defineProperty(exports, "readAllWorkspaceConfiguration", { enumerable: true, get: function () { return file_utils_1.readAllWorkspaceConfiguration; } });
17
- Object.defineProperty(exports, "workspaceLayout", { enumerable: true, get: function () { return file_utils_1.workspaceLayout; } });
14
+ var configuration_1 = require("nx/src/config/configuration");
15
+ Object.defineProperty(exports, "readAllWorkspaceConfiguration", { enumerable: true, get: function () { return configuration_1.readAllWorkspaceConfiguration; } });
16
+ Object.defineProperty(exports, "workspaceLayout", { enumerable: true, get: function () { return configuration_1.workspaceLayout; } });
18
17
  /**
19
18
  * @category Logger
20
19
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/devkit",
3
- "version": "16.6.0-beta.4",
3
+ "version": "16.6.0-beta.6",
4
4
  "private": false,
5
5
  "description": "The Nx Devkit is used to customize Nx for different technologies and use cases. It contains many utility functions for reading and writing files, updating configuration, working with Abstract Syntax Trees(ASTs), and more.",
6
6
  "repository": {
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "homepage": "https://nx.dev",
30
30
  "dependencies": {
31
- "@nrwl/devkit": "16.6.0-beta.4",
31
+ "@nrwl/devkit": "16.6.0-beta.6",
32
32
  "ejs": "^3.1.7",
33
33
  "ignore": "^5.0.4",
34
34
  "semver": "7.5.3",
@@ -45,5 +45,5 @@
45
45
  "migrations": "./migrations.json"
46
46
  },
47
47
  "types": "./index.d.ts",
48
- "gitHead": "b1a9ae7ce76697019b26ec9a172005840cca8da6"
48
+ "gitHead": "9aad21dbfb2b659e488b6626f59df58ab23c0032"
49
49
  }
@@ -4,7 +4,7 @@ exports.readTargetOptions = void 0;
4
4
  // eslint-disable-next-line @typescript-eslint/no-restricted-imports
5
5
  const params_1 = require("nx/src/utils/params");
6
6
  const nx_1 = require("../../nx");
7
- const { Workspaces, getExecutorInformation } = (0, nx_1.requireNx)();
7
+ const { Workspaces, getExecutorInformation, calculateDefaultProjectName } = (0, nx_1.requireNx)();
8
8
  /**
9
9
  * Reads and combines options for a given target.
10
10
  *
@@ -16,8 +16,14 @@ function readTargetOptions({ project, target, configuration }, context) {
16
16
  const targetConfiguration = projectConfiguration.targets[target];
17
17
  const ws = new Workspaces(context.root);
18
18
  const [nodeModule, executorName] = targetConfiguration.executor.split(':');
19
- const { schema } = getExecutorInformation(nodeModule, executorName, context.root);
20
- const defaultProject = ws.calculateDefaultProjectName(context.cwd, { version: 2, projects: context.projectsConfigurations.projects }, context.nxJsonConfiguration);
19
+ const { schema } = getExecutorInformation
20
+ ? getExecutorInformation(nodeModule, executorName, context.root)
21
+ : // TODO(v18): remove readExecutor. This is to be backwards compatible with Nx 16.5 and below.
22
+ ws.readExecutor(nodeModule, executorName);
23
+ const defaultProject = calculateDefaultProjectName
24
+ ? calculateDefaultProjectName(context.cwd, context.root, { version: 2, projects: context.projectsConfigurations.projects }, context.nxJsonConfiguration)
25
+ : // TODO(v18): remove calculateDefaultProjectName. This is to be backwards compatible with Nx 16.5 and below.
26
+ ws.calculateDefaultProjectName(context.cwd, { version: 2, projects: context.projectsConfigurations.projects }, context.nxJsonConfiguration);
21
27
  return (0, params_1.combineOptionsForExecutor)({}, (_a = configuration !== null && configuration !== void 0 ? configuration : targetConfiguration.defaultConfiguration) !== null && _a !== void 0 ? _a : '', targetConfiguration, schema, defaultProject, ws.relativeCwd(context.cwd));
22
28
  }
23
29
  exports.readTargetOptions = readTargetOptions;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.convertNxExecutor = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const nx_1 = require("../../nx");
6
- const { Workspaces } = (0, nx_1.requireNx)();
6
+ const { Workspaces, readNxJsonFromDisk } = (0, nx_1.requireNx)();
7
7
  /**
8
8
  * Convert an Nx Executor into an Angular Devkit Builder
9
9
  *
@@ -13,7 +13,10 @@ const { Workspaces } = (0, nx_1.requireNx)();
13
13
  function convertNxExecutor(executor) {
14
14
  const builderFunction = (options, builderContext) => {
15
15
  const workspaces = new Workspaces(builderContext.workspaceRoot);
16
- const nxJsonConfiguration = workspaces.readNxJson();
16
+ const nxJsonConfiguration = readNxJsonFromDisk
17
+ ? readNxJsonFromDisk(builderContext.workspaceRoot)
18
+ : // TODO(v18): remove readNxJson. This is to be backwards compatible with Nx 16.5 and below.
19
+ workspaces.readNxJson();
17
20
  const projectsConfigurations = workspaces.readProjectsConfigurations({
18
21
  _includeProjectsFromAngularJson: true,
19
22
  });
@@ -8,7 +8,8 @@ const install_packages_task_1 = require("../tasks/install-packages-task");
8
8
  const nx_1 = require("../../nx");
9
9
  const tmp_1 = require("tmp");
10
10
  const path_1 = require("path");
11
- const { readJson, updateJson, getPackageManagerCommand, workspaceRoot, detectPackageManager, createTempNpmDirectory, } = (0, nx_1.requireNx)();
11
+ const fs_1 = require("fs");
12
+ const { readJson, updateJson, getPackageManagerCommand, workspaceRoot, detectPackageManager, createTempNpmDirectory, getPackageManagerVersion, } = (0, nx_1.requireNx)();
12
13
  const UNIDENTIFIED_VERSION = 'UNIDENTIFIED_VERSION';
13
14
  const NON_SEMVER_TAGS = {
14
15
  '*': 2,
@@ -268,6 +269,7 @@ function ensurePackage(pkgOrTree, requiredVersionOrPackage, maybeRequiredVersion
268
269
  console.log(`Fetching ${pkg}...`);
269
270
  const packageManager = detectPackageManager();
270
271
  const isVerbose = process.env.NX_VERBOSE_LOGGING === 'true';
272
+ generatePackageManagerFiles(tempDir, packageManager);
271
273
  const preInstallCommand = getPackageManagerCommand(packageManager).preInstall;
272
274
  if (preInstallCommand) {
273
275
  // ensure package.json and repo in tmp folder is set to a proper package manager state
@@ -306,6 +308,20 @@ function ensurePackage(pkgOrTree, requiredVersionOrPackage, maybeRequiredVersion
306
308
  }
307
309
  }
308
310
  exports.ensurePackage = ensurePackage;
311
+ /**
312
+ * Generates necessary files needed for the package manager to work
313
+ * and for the node_modules to be accessible.
314
+ */
315
+ function generatePackageManagerFiles(root, packageManager = detectPackageManager()) {
316
+ const [pmMajor] = getPackageManagerVersion(packageManager).split('.');
317
+ switch (packageManager) {
318
+ case 'yarn':
319
+ if (+pmMajor >= 2) {
320
+ (0, fs_1.writeFileSync)((0, path_1.join)(root, '.yarnrc.yml'), 'nodeLinker: node-modules\nenableScripts: false');
321
+ }
322
+ break;
323
+ }
324
+ }
309
325
  function addToNodePath(dir) {
310
326
  // NODE_PATH is a delimited list of paths.
311
327
  // The delimiter is different for windows.