@nx/js 19.7.2 → 19.8.0-canary.20240910-9b3a960

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/js",
3
- "version": "19.7.2",
3
+ "version": "19.8.0-canary.20240910-9b3a960",
4
4
  "private": false,
5
5
  "description": "The JS plugin for Nx contains executors and generators that provide the best experience for developing JavaScript and TypeScript projects. ",
6
6
  "repository": {
@@ -39,8 +39,8 @@
39
39
  "@babel/preset-env": "^7.23.2",
40
40
  "@babel/preset-typescript": "^7.22.5",
41
41
  "@babel/runtime": "^7.22.6",
42
- "@nx/devkit": "19.7.2",
43
- "@nx/workspace": "19.7.2",
42
+ "@nx/devkit": "19.8.0-canary.20240910-9b3a960",
43
+ "@nx/workspace": "19.8.0-canary.20240910-9b3a960",
44
44
  "babel-plugin-const-enum": "^1.0.1",
45
45
  "babel-plugin-macros": "^2.8.0",
46
46
  "babel-plugin-transform-typescript-metadata": "^0.3.1",
@@ -61,7 +61,7 @@
61
61
  "ts-node": "10.9.1",
62
62
  "tsconfig-paths": "^4.1.2",
63
63
  "tslib": "^2.3.0",
64
- "@nrwl/js": "19.7.2"
64
+ "@nrwl/js": "19.8.0-canary.20240910-9b3a960"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "verdaccio": "^5.0.4"
@@ -5,11 +5,10 @@ const devkit_1 = require("@nx/devkit");
5
5
  const child_process_1 = require("child_process");
6
6
  const npm_run_path_1 = require("npm-run-path");
7
7
  const path_1 = require("path");
8
- const is_locally_linked_package_version_1 = require("../../utils/is-locally-linked-package-version");
9
8
  const npm_config_1 = require("../../utils/npm-config");
10
- const extract_npm_publish_json_data_1 = require("./extract-npm-publish-json-data");
11
9
  const log_tar_1 = require("./log-tar");
12
10
  const chalk = require("chalk");
11
+ const extract_npm_publish_json_data_1 = require("./extract-npm-publish-json-data");
13
12
  const LARGE_BUFFER = 1024 * 1000000;
14
13
  function processEnv(color) {
15
14
  const env = {
@@ -22,7 +21,6 @@ function processEnv(color) {
22
21
  return env;
23
22
  }
24
23
  async function runExecutor(options, context) {
25
- const pm = (0, devkit_1.detectPackageManager)();
26
24
  /**
27
25
  * We need to check both the env var and the option because the executor may have been triggered
28
26
  * indirectly via dependsOn, in which case the env var will be set, but the option will not.
@@ -33,28 +31,6 @@ async function runExecutor(options, context) {
33
31
  const packageJsonPath = (0, path_1.join)(packageRoot, 'package.json');
34
32
  const packageJson = (0, devkit_1.readJsonFile)(packageJsonPath);
35
33
  const packageName = packageJson.name;
36
- /**
37
- * pnpm supports dynamically updating locally linked packages during its packing phase, but other package managers do not.
38
- * Therefore, protect the user from publishing invalid packages by checking if it contains local dependency protocols.
39
- */
40
- if (pm !== 'pnpm') {
41
- const depTypes = ['dependencies', 'devDependencies', 'peerDependencies'];
42
- for (const depType of depTypes) {
43
- const deps = packageJson[depType];
44
- if (deps) {
45
- for (const depName in deps) {
46
- if ((0, is_locally_linked_package_version_1.isLocallyLinkedPackageVersion)(deps[depName])) {
47
- console.error(`Error: Cannot publish package "${packageName}" because it contains a local dependency protocol in its "${depType}", and your package manager is ${pm}.
48
-
49
- Please update the local dependency on "${depName}" to be a valid semantic version (e.g. using \`nx release\`) before publishing, or switch to pnpm as a package manager, which supports dynamically replacing these protocols during publishing.`);
50
- return {
51
- success: false,
52
- };
53
- }
54
- }
55
- }
56
- }
57
- }
58
34
  // If package and project name match, we can make log messages terser
59
35
  let packageTxt = packageName === context.projectName
60
36
  ? `package "${packageName}"`
@@ -87,7 +63,7 @@ Please update the local dependency on "${depName}" to be a valid semantic versio
87
63
  * request with.
88
64
  *
89
65
  * Therefore, so as to not produce misleading output in dry around dist-tags being altered, we do not
90
- * perform the npm view step, and just show npm/pnpm publish's dry-run output.
66
+ * perform the npm view step, and just show npm publish's dry-run output.
91
67
  */
92
68
  if (!isDryRun && !options.firstRelease) {
93
69
  const currentVersion = packageJson.version;
@@ -178,38 +154,35 @@ Please update the local dependency on "${depName}" to be a valid semantic versio
178
154
  }
179
155
  /**
180
156
  * NOTE: If this is ever changed away from running the command at the workspace root and pointing at the package root (e.g. back
181
- * to running from the package root directly), then special attention should be paid to the fact that npm/pnpm publish will nest its
157
+ * to running from the package root directly), then special attention should be paid to the fact that npm publish will nest its
182
158
  * JSON output under the name of the package in that case (and it would need to be handled below).
183
159
  */
184
- const publishCommandSegments = [
185
- pm === 'pnpm'
186
- ? // Unlike npm, pnpm publish does not support a custom registryConfigKey option, and will error on uncommitted changes by default if --no-git-checks is not set
187
- `pnpm publish "${packageRoot}" --json --registry="${registry}" --tag=${tag} --no-git-checks`
188
- : `npm publish "${packageRoot}" --json --"${registryConfigKey}=${registry}" --tag=${tag}`,
160
+ const npmPublishCommandSegments = [
161
+ `npm publish "${packageRoot}" --json --"${registryConfigKey}=${registry}" --tag=${tag}`,
189
162
  ];
190
163
  if (options.otp) {
191
- publishCommandSegments.push(`--otp=${options.otp}`);
164
+ npmPublishCommandSegments.push(`--otp=${options.otp}`);
192
165
  }
193
166
  if (options.access) {
194
- publishCommandSegments.push(`--access=${options.access}`);
167
+ npmPublishCommandSegments.push(`--access=${options.access}`);
195
168
  }
196
169
  if (isDryRun) {
197
- publishCommandSegments.push(`--dry-run`);
170
+ npmPublishCommandSegments.push(`--dry-run`);
198
171
  }
199
172
  try {
200
- const output = (0, child_process_1.execSync)(publishCommandSegments.join(' '), {
173
+ const output = (0, child_process_1.execSync)(npmPublishCommandSegments.join(' '), {
201
174
  maxBuffer: LARGE_BUFFER,
202
175
  env: processEnv(true),
203
176
  cwd: context.root,
204
177
  stdio: ['ignore', 'pipe', 'pipe'],
205
178
  });
206
179
  /**
207
- * We cannot JSON.parse the output directly because if the user is using lifecycle scripts, npm/pnpm will mix its publish output with the JSON output all on stdout.
180
+ * We cannot JSON.parse the output directly because if the user is using lifecycle scripts, npm will mix its publish output with the JSON output all on stdout.
208
181
  * Additionally, we want to capture and show the lifecycle script outputs as beforeJsonData and afterJsonData and print them accordingly below.
209
182
  */
210
183
  const { beforeJsonData, jsonData, afterJsonData } = (0, extract_npm_publish_json_data_1.extractNpmPublishJsonData)(output.toString());
211
184
  if (!jsonData) {
212
- console.error(`The ${pm} publish output data could not be extracted. Please report this issue on https://github.com/nrwl/nx`);
185
+ console.error('The npm publish output data could not be extracted. Please report this issue on https://github.com/nrwl/nx');
213
186
  return {
214
187
  success: false,
215
188
  };
@@ -245,7 +218,7 @@ Please update the local dependency on "${depName}" to be a valid semantic versio
245
218
  catch (err) {
246
219
  try {
247
220
  const stdoutData = JSON.parse(err.stdout?.toString() || '{}');
248
- console.error(`${pm} publish error:`);
221
+ console.error('npm publish error:');
249
222
  if (stdoutData.error?.summary) {
250
223
  console.error(stdoutData.error.summary);
251
224
  }
@@ -253,7 +226,7 @@ Please update the local dependency on "${depName}" to be a valid semantic versio
253
226
  console.error(stdoutData.error.detail);
254
227
  }
255
228
  if (context.isVerbose) {
256
- console.error(`${pm} publish stdout:`);
229
+ console.error('npm publish stdout:');
257
230
  console.error(JSON.stringify(stdoutData, null, 2));
258
231
  }
259
232
  if (!stdoutData.error) {
@@ -264,7 +237,7 @@ Please update the local dependency on "${depName}" to be a valid semantic versio
264
237
  };
265
238
  }
266
239
  catch (err) {
267
- console.error(`Something unexpected went wrong when processing the ${pm} publish output\n`, err);
240
+ console.error('Something unexpected went wrong when processing the npm publish output\n', err);
268
241
  return {
269
242
  success: false,
270
243
  };
@@ -14,7 +14,6 @@ const version_1 = require("nx/src/command-line/release/version");
14
14
  const utils_1 = require("nx/src/tasks-runner/utils");
15
15
  const ora = require("ora");
16
16
  const semver_2 = require("semver");
17
- const is_locally_linked_package_version_1 = require("../../utils/is-locally-linked-package-version");
18
17
  const npm_config_1 = require("../../utils/npm-config");
19
18
  const resolve_local_package_dependencies_1 = require("./utils/resolve-local-package-dependencies");
20
19
  const sort_projects_topologically_1 = require("./utils/sort-projects-topologically");
@@ -238,8 +237,7 @@ To fix this you will either need to add a package.json file at that location, or
238
237
  }
239
238
  specifier = await (0, resolve_semver_specifier_1.resolveSemverSpecifierFromConventionalCommits)(previousVersionRef, options.projectGraph, affectedProjects, options.conventionalCommitsConfig);
240
239
  if (!specifier) {
241
- if (updateDependents !== 'never' &&
242
- projectToDependencyBumps.has(projectName)) {
240
+ if (projectToDependencyBumps.has(projectName)) {
243
241
  // No applicable changes to the project directly by the user, but one or more dependencies have been bumped and updateDependents is enabled
244
242
  specifier = updateDependentsBump;
245
243
  logger.buffer(`📄 Resolved the specifier as "${specifier}" because "release.version.generatorOptions.updateDependents" is enabled`);
@@ -473,7 +471,7 @@ To fix this you will either need to add a package.json file at that location, or
473
471
  // Depending on the package manager, locally linked packages could reference packages with `"private": true` and no version field at all
474
472
  const currentPackageVersion = json.version ?? null;
475
473
  if (!currentPackageVersion &&
476
- (0, is_locally_linked_package_version_1.isLocallyLinkedPackageVersion)(currentDependencyVersion)) {
474
+ isLocallyLinkedPackageVersion(currentDependencyVersion)) {
477
475
  if (forceVersionBump) {
478
476
  // Look up any dependent projects from the transitiveLocalPackageDependents list
479
477
  const transitiveDependentProjects = transitiveLocalPackageDependents.filter((localPackageDependency) => localPackageDependency.target === dependentProject.source);
@@ -498,14 +496,10 @@ To fix this you will either need to add a package.json file at that location, or
498
496
  }
499
497
  }
500
498
  }
501
- // Apply the new version of the dependency to the dependent (if not preserving locally linked package protocols)
502
- const shouldUpdateDependency = !((0, is_locally_linked_package_version_1.isLocallyLinkedPackageVersion)(currentDependencyVersion) &&
503
- options.preserveLocalDependencyProtocols);
504
- if (shouldUpdateDependency) {
505
- const newDepVersion = `${versionPrefix}${newDependencyVersion}`;
506
- json[dependentProject.dependencyCollection][dependencyPackageName] =
507
- newDepVersion;
508
- }
499
+ // Apply the new version of the dependency to the dependent
500
+ const newDepVersion = `${versionPrefix}${newDependencyVersion}`;
501
+ json[dependentProject.dependencyCollection][dependencyPackageName] =
502
+ newDepVersion;
509
503
  // Bump the dependent's version if applicable and record it in the version data
510
504
  if (forceVersionBump) {
511
505
  const newPackageVersion = (0, version_1.deriveNewSemverVersion)(currentPackageVersion, forceVersionBump, options.preid);
@@ -675,3 +669,33 @@ class ProjectLogger {
675
669
  });
676
670
  }
677
671
  }
672
+ let pm;
673
+ let pmVersion;
674
+ const localPackageProtocols = [
675
+ 'file:', // all package managers
676
+ 'workspace:', // not npm
677
+ 'portal:', // modern yarn only
678
+ ];
679
+ function isLocallyLinkedPackageVersion(version) {
680
+ // Not using a supported local protocol
681
+ if (!localPackageProtocols.some((protocol) => version.startsWith(protocol))) {
682
+ return false;
683
+ }
684
+ // Supported by all package managers
685
+ if (version.startsWith('file:')) {
686
+ return true;
687
+ }
688
+ // Determine specific package manager in use
689
+ if (!pm) {
690
+ pm = (0, devkit_1.detectPackageManager)();
691
+ pmVersion = (0, devkit_1.getPackageManagerVersion)(pm);
692
+ }
693
+ if (pm === 'npm' && version.startsWith('workspace:')) {
694
+ throw new Error(`The "workspace:" protocol is not yet supported by npm (https://github.com/npm/rfcs/issues/765). Please ensure you have a valid setup according to your package manager before attempting to release packages.`);
695
+ }
696
+ if (version.startsWith('portal:') &&
697
+ (pm !== 'yarn' || (0, semver_2.lt)(pmVersion, '2.0.0'))) {
698
+ throw new Error(`The "portal:" protocol is only supported by yarn@2.0.0 and above. Please ensure you have a valid setup according to your package manager before attempting to release packages.`);
699
+ }
700
+ return true;
701
+ }
@@ -1 +0,0 @@
1
- export declare function isLocallyLinkedPackageVersion(version: string): boolean;
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isLocallyLinkedPackageVersion = isLocallyLinkedPackageVersion;
4
- const devkit_1 = require("@nx/devkit");
5
- // import { lt } from 'semver';
6
- let pm;
7
- // let pmVersion: string | undefined;
8
- const localPackageProtocols = [
9
- 'file:', // all package managers
10
- 'workspace:', // not npm
11
- // TODO: Support portal protocol at the project graph level before enabling here
12
- // 'portal:', // modern yarn only
13
- ];
14
- function isLocallyLinkedPackageVersion(version) {
15
- // Not using a supported local protocol
16
- if (!localPackageProtocols.some((protocol) => version.startsWith(protocol))) {
17
- return false;
18
- }
19
- // Supported by all package managers
20
- if (version.startsWith('file:')) {
21
- return true;
22
- }
23
- // Determine specific package manager in use
24
- if (!pm) {
25
- pm = (0, devkit_1.detectPackageManager)();
26
- // pmVersion = getPackageManagerVersion(pm);
27
- }
28
- if (pm === 'npm' && version.startsWith('workspace:')) {
29
- throw new Error(`The "workspace:" protocol is not yet supported by npm (https://github.com/npm/rfcs/issues/765). Please ensure you have a valid setup according to your package manager before attempting to release packages.`);
30
- }
31
- // TODO: Support portal protocol at the project graph level before enabling here
32
- // if (
33
- // version.startsWith('portal:') &&
34
- // (pm !== 'yarn' || lt(pmVersion, '2.0.0'))
35
- // ) {
36
- // throw new Error(
37
- // `The "portal:" protocol is only supported by yarn@2.0.0 and above. Please ensure you have a valid setup according to your package manager before attempting to release packages.`
38
- // );
39
- // }
40
- return true;
41
- }