@nx/workspace 21.5.0-canary.20250821-4ba2085 → 21.5.0-canary.20250823-a93e74e

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/workspace",
3
- "version": "21.5.0-canary.20250821-4ba2085",
3
+ "version": "21.5.0-canary.20250823-a93e74e",
4
4
  "private": false,
5
5
  "description": "The Workspace plugin contains executors and generators that are useful for any Nx workspace. It should be present in every Nx workspace and other plugins build on it.",
6
6
  "repository": {
@@ -38,17 +38,18 @@
38
38
  }
39
39
  },
40
40
  "dependencies": {
41
- "@nx/devkit": "21.5.0-canary.20250821-4ba2085",
41
+ "@nx/devkit": "21.5.0-canary.20250823-a93e74e",
42
42
  "@zkochan/js-yaml": "0.0.7",
43
43
  "chalk": "^4.1.0",
44
44
  "enquirer": "~2.3.6",
45
45
  "picomatch": "4.0.2",
46
+ "semver": "^7.6.3",
46
47
  "tslib": "^2.3.0",
47
48
  "yargs-parser": "21.1.1",
48
- "nx": "21.5.0-canary.20250821-4ba2085"
49
+ "nx": "21.5.0-canary.20250823-a93e74e"
49
50
  },
50
51
  "devDependencies": {
51
- "nx": "21.5.0-canary.20250821-4ba2085"
52
+ "nx": "21.5.0-canary.20250823-a93e74e"
52
53
  },
53
54
  "publishConfig": {
54
55
  "access": "public"
@@ -1,4 +1,4 @@
1
- import { Tree } from '@nx/devkit';
2
- import { NormalizedSchema } from './new';
1
+ import { type Tree } from '@nx/devkit';
2
+ import type { NormalizedSchema } from './new';
3
3
  export declare function generateWorkspaceFiles(tree: Tree, options: NormalizedSchema): Promise<string>;
4
4
  //# sourceMappingURL=generate-workspace-files.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate-workspace-files.d.ts","sourceRoot":"","sources":["../../../../../../packages/workspace/src/generators/new/generate-workspace-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,IAAI,EAGL,MAAM,YAAY,CAAC;AAKpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AA2IzC,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,gBAAgB,mBA6C1B"}
1
+ {"version":3,"file":"generate-workspace-files.d.ts","sourceRoot":"","sources":["../../../../../../packages/workspace/src/generators/new/generate-workspace-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,IAAI,EAGV,MAAM,YAAY,CAAC;AAQpB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAyI9C,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,gBAAgB,mBAiD1B"}
@@ -2,12 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateWorkspaceFiles = generateWorkspaceFiles;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const versions_1 = require("../../utils/versions");
6
- const path_1 = require("path");
7
- const presets_1 = require("../utils/presets");
8
- const default_base_1 = require("../../utilities/default-base");
9
5
  const connect_to_nx_cloud_1 = require("nx/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud");
10
6
  const url_shorten_1 = require("nx/src/nx-cloud/utilities/url-shorten");
7
+ const path_1 = require("path");
8
+ const semver_1 = require("semver");
9
+ const default_base_1 = require("../../utilities/default-base");
10
+ const versions_1 = require("../../utils/versions");
11
+ const presets_1 = require("../utils/presets");
11
12
  // map from the preset to the name of the plugin s.t. the README can have a more
12
13
  // meaningful generator command.
13
14
  const presetToPluginMap = {
@@ -134,7 +135,12 @@ async function generateWorkspaceFiles(tree, options) {
134
135
  await createReadme(tree, options, token);
135
136
  const [packageMajor] = packageManagerVersion.split('.');
136
137
  if (options.packageManager === 'pnpm' && +packageMajor >= 7) {
137
- createNpmrc(tree, options);
138
+ if ((0, semver_1.gte)(packageManagerVersion, '10.6.0')) {
139
+ addPnpmSettings(tree, options);
140
+ }
141
+ else {
142
+ createNpmrc(tree, options);
143
+ }
138
144
  }
139
145
  else if (options.packageManager === 'yarn') {
140
146
  if (+packageMajor >= 2) {
@@ -246,6 +252,11 @@ async function createReadme(tree, { name, appName, directory, preset, nxCloud, w
246
252
  });
247
253
  }
248
254
  // ensure that pnpm install add all the missing peer deps
255
+ function addPnpmSettings(tree, options) {
256
+ tree.write((0, path_1.join)(options.directory, 'pnpm-workspace.yaml'), `autoInstallPeers: true
257
+ strictPeerDependencies: false
258
+ `);
259
+ }
249
260
  function createNpmrc(tree, options) {
250
261
  tree.write((0, path_1.join)(options.directory, '.npmrc'), 'strict-peer-dependencies=false\nauto-install-peers=true\n');
251
262
  }
@@ -325,9 +336,18 @@ function setUpWorkspacesInPackageJson(tree, options) {
325
336
  options.workspaces)) {
326
337
  const workspaces = options.workspaceGlobs ?? ['packages/*'];
327
338
  if (options.packageManager === 'pnpm') {
328
- tree.write((0, path_1.join)(options.directory, 'pnpm-workspace.yaml'), `packages:
339
+ const pnpmWorkspacePath = (0, path_1.join)(options.directory, 'pnpm-workspace.yaml');
340
+ let content = `packages:
329
341
  ${workspaces.map((workspace) => `- "${workspace}"`).join('\n ')}
330
- `);
342
+ `;
343
+ if (tree.exists(pnpmWorkspacePath)) {
344
+ // already added to set the peer deps settings for pnpm 10.6.0+
345
+ const existingContent = tree.read(pnpmWorkspacePath, 'utf-8');
346
+ if (existingContent.trim().length) {
347
+ content = `${content}\n${existingContent}`;
348
+ }
349
+ }
350
+ tree.write(pnpmWorkspacePath, content);
331
351
  }
332
352
  else {
333
353
  (0, devkit_1.updateJson)(tree, (0, path_1.join)(options.directory, 'package.json'), (json) => {
@@ -1 +1 @@
1
- {"version":3,"file":"package-manager-workspaces.d.ts","sourceRoot":"","sources":["../../../../../packages/workspace/src/utilities/package-manager-workspaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAMvE,wBAAgB,2CAA2C,CACzD,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,GAClB,OAAO,CAQT;AAED,wBAAgB,mCAAmC,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,EAAE,CAWxE;AAED,wBAAgB,+BAA+B,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAEnE;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAYvD"}
1
+ {"version":3,"file":"package-manager-workspaces.d.ts","sourceRoot":"","sources":["../../../../../packages/workspace/src/utilities/package-manager-workspaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAMvE,wBAAgB,2CAA2C,CACzD,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,GAClB,OAAO,CAQT;AAED,wBAAgB,mCAAmC,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,EAAE,CAWxE;AAED,wBAAgB,+BAA+B,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAEnE;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAuBvD"}
@@ -28,7 +28,18 @@ function isUsingPackageManagerWorkspaces(tree) {
28
28
  function isWorkspacesEnabled(tree) {
29
29
  const packageManager = (0, devkit_1.detectPackageManager)(tree.root);
30
30
  if (packageManager === 'pnpm') {
31
- return tree.exists('pnpm-workspace.yaml');
31
+ if (!tree.exists('pnpm-workspace.yaml')) {
32
+ return false;
33
+ }
34
+ try {
35
+ const content = tree.read('pnpm-workspace.yaml', 'utf-8');
36
+ const { load } = require('@zkochan/js-yaml');
37
+ const { packages } = load(content) ?? {};
38
+ return packages !== undefined;
39
+ }
40
+ catch {
41
+ return false;
42
+ }
32
43
  }
33
44
  // yarn and npm both use the same 'workspaces' property in package.json
34
45
  if (tree.exists('package.json')) {
@@ -1 +1 @@
1
- {"version":3,"file":"ts-solution-setup.d.ts","sourceRoot":"","sources":["../../../../../../packages/workspace/src/utilities/typescript/ts-solution-setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,IAAI,EAEV,MAAM,YAAY,CAAC;AAgFpB,wBAAgB,sBAAsB,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,OAAO,CAO3D;AAED,wBAAsB,+BAA+B,CACnD,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,MAAM,iBAuDnB"}
1
+ {"version":3,"file":"ts-solution-setup.d.ts","sourceRoot":"","sources":["../../../../../../packages/workspace/src/utilities/typescript/ts-solution-setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,IAAI,EAAiB,MAAM,YAAY,CAAC;AA8D3E,wBAAgB,sBAAsB,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,OAAO,CAO3D;AAED,wBAAsB,+BAA+B,CACnD,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,MAAM,iBAuDnB"}
@@ -6,21 +6,6 @@ const devkit_1 = require("@nx/devkit");
6
6
  const posix_1 = require("node:path/posix");
7
7
  const tree_1 = require("nx/src/generators/tree");
8
8
  const package_manager_workspaces_1 = require("../package-manager-workspaces");
9
- function isUsingPackageManagerWorkspaces(tree) {
10
- return isWorkspacesEnabled(tree);
11
- }
12
- function isWorkspacesEnabled(tree) {
13
- const packageManager = (0, devkit_1.detectPackageManager)(tree.root);
14
- if (packageManager === 'pnpm') {
15
- return tree.exists('pnpm-workspace.yaml');
16
- }
17
- // yarn and npm both use the same 'workspaces' property in package.json
18
- if (tree.exists('package.json')) {
19
- const packageJson = (0, devkit_1.readJson)(tree, 'package.json');
20
- return !!packageJson?.workspaces;
21
- }
22
- return false;
23
- }
24
9
  /**
25
10
  * The TS solution setup requires:
26
11
  * - `tsconfig.base.json`: TS config with common compiler options needed by the
@@ -67,7 +52,7 @@ function isWorkspaceSetupWithTsSolution(tree) {
67
52
  }
68
53
  function isUsingTsSolutionSetup(tree) {
69
54
  tree ??= new tree_1.FsTree(devkit_1.workspaceRoot, false);
70
- return (isUsingPackageManagerWorkspaces(tree) &&
55
+ return ((0, package_manager_workspaces_1.isUsingPackageManagerWorkspaces)(tree) &&
71
56
  isWorkspaceSetupWithTsSolution(tree));
72
57
  }
73
58
  async function addProjectToTsSolutionWorkspace(tree, projectDir) {