@nx/js 17.0.3 → 17.0.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 (54) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +9 -4
  3. package/babel.js +36 -16
  4. package/executors.json +1 -1
  5. package/migrations.json +56 -0
  6. package/package.json +9 -9
  7. package/src/executors/node/node.impl.js +1 -1
  8. package/src/executors/node/schema.json +1 -1
  9. package/src/executors/release-publish/release-publish.impl.js +135 -32
  10. package/src/executors/release-publish/schema.d.ts +2 -0
  11. package/src/executors/release-publish/schema.json +1 -1
  12. package/src/executors/swc/schema.json +1 -1
  13. package/src/executors/swc/swc.impl.js +6 -7
  14. package/src/executors/verdaccio/schema.json +1 -1
  15. package/src/executors/verdaccio/verdaccio.impl.js +1 -1
  16. package/src/generators/convert-to-swc/schema.json +1 -1
  17. package/src/generators/init/init.js +3 -2
  18. package/src/generators/init/schema.d.ts +1 -0
  19. package/src/generators/init/schema.json +7 -1
  20. package/src/generators/library/files/lib/tsconfig.lib.json__tmpl__ +5 -1
  21. package/src/generators/library/files/{lib → readme}/README.md +1 -1
  22. package/src/generators/library/library.d.ts +1 -1
  23. package/src/generators/library/library.js +171 -29
  24. package/src/generators/library/schema.json +8 -2
  25. package/src/generators/release-version/release-version.d.ts +2 -1
  26. package/src/generators/release-version/release-version.js +341 -86
  27. package/src/generators/release-version/schema.json +26 -4
  28. package/src/generators/release-version/utils/resolve-local-package-dependencies.d.ts +7 -1
  29. package/src/generators/release-version/utils/resolve-local-package-dependencies.js +14 -4
  30. package/src/generators/release-version/utils/resolve-version-spec.js +4 -1
  31. package/src/generators/release-version/utils/update-lock-file.d.ts +5 -0
  32. package/src/generators/release-version/utils/update-lock-file.js +105 -0
  33. package/src/generators/setup-build/generator.js +3 -0
  34. package/src/generators/setup-build/schema.json +1 -1
  35. package/src/generators/setup-verdaccio/schema.json +1 -1
  36. package/src/utils/add-local-registry-scripts.js +26 -6
  37. package/src/utils/assets/copy-assets-handler.js +4 -4
  38. package/src/utils/buildable-libs-utils.js +7 -3
  39. package/src/utils/find-npm-dependencies.d.ts +2 -1
  40. package/src/utils/find-npm-dependencies.js +28 -11
  41. package/src/utils/inline.js +6 -4
  42. package/src/utils/npm-config.d.ts +25 -0
  43. package/src/utils/npm-config.js +90 -0
  44. package/src/utils/schema.d.ts +3 -0
  45. package/src/utils/swc/get-swcrc-path.d.ts +4 -1
  46. package/src/utils/swc/get-swcrc-path.js +6 -1
  47. package/src/utils/swc/inline.d.ts +1 -1
  48. package/src/utils/swc/inline.js +1 -2
  49. package/src/utils/typescript/ast-utils.js +2 -3
  50. package/src/utils/typescript/ts-config.js +1 -0
  51. package/src/utils/versions.d.ts +4 -4
  52. package/src/utils/versions.js +4 -4
  53. package/src/utils/minimal-publish-script.d.ts +0 -2
  54. package/src/utils/minimal-publish-script.js +0 -74
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2017-2023 Narwhal Technologies Inc.
3
+ Copyright (c) 2017-2024 Narwhal Technologies Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
package/README.md CHANGED
@@ -1,4 +1,9 @@
1
- <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Smart, Fast and Extensible Build System"></p>
1
+ <p style="text-align: center;">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-dark.svg">
4
+ <img alt="Nx - Smart Monorepos · Fast CI" src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-light.svg" width="100%">
5
+ </picture>
6
+ </p>
2
7
 
3
8
  <div style="text-align: center;">
4
9
 
@@ -15,9 +20,9 @@
15
20
 
16
21
  <hr>
17
22
 
18
- # Nx: Smart, Fast and Extensible Build System
23
+ # Nx: Smart Monorepos · Fast CI
19
24
 
20
- Nx is a next generation build system with first class monorepo support and powerful integrations.
25
+ Nx is a build system with built-in tooling and advanced CI capabilities. It helps you maintain and scale monorepos, both locally and on CI.
21
26
 
22
27
  This package is a [JavaScript/TypeScript plugin for Nx](https://nx.dev/js/overview).
23
28
 
@@ -59,5 +64,5 @@ npx nx@latest init
59
64
  - [Blog Posts About Nx](https://blog.nrwl.io/nx/home)
60
65
 
61
66
  <p style="text-align: center;"><a href="https://nx.dev/#learning-materials" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-courses-and-videos.svg"
62
- width="100%" alt="Nx - Smart, Fast and Extensible Build System"></a></p>
67
+ width="100%" alt="Nx - Smart Monorepos · Fast CI"></a></p>
63
68
 
package/babel.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const path_1 = require("path");
4
+ const semver_1 = require("semver");
4
5
  const devkit_1 = require("@nx/devkit");
5
6
  module.exports = function (api, options = {}) {
6
7
  api.assertVersion(7);
@@ -12,10 +13,10 @@ module.exports = function (api, options = {}) {
12
13
  const emitDecoratorMetadata = api.caller((caller) => caller?.emitDecoratorMetadata ?? true);
13
14
  // Determine settings for `@babel//babel-plugin-transform-class-properties`,
14
15
  // so that we can sync the `loose` option with `@babel/preset-env`.
15
- // TODO(v18): Remove classProperties since it's no longer needed, now that the class props transform is in preset-env.
16
+ // TODO(v19): Remove classProperties since it's no longer needed, now that the class props transform is in preset-env.
16
17
  const loose = options.classProperties?.loose ?? options.loose ?? true;
17
18
  if (options.classProperties) {
18
- devkit_1.logger.warn(`Use =\`loose\` option instead of \`classProperties.loose\`. The \`classProperties\` option will be removed in Nx 18`);
19
+ devkit_1.logger.warn(`Use =\`loose\` option instead of \`classProperties.loose\`. The \`classProperties\` option will be removed in Nx 19`);
19
20
  }
20
21
  return {
21
22
  presets: [
@@ -25,21 +26,9 @@ module.exports = function (api, options = {}) {
25
26
  // For Jest tests, NODE_ENV is set as 'test' and we only want to set target as Node.
26
27
  // All other options will fail in Jest since Node does not support some ES features
27
28
  // such as import syntax.
28
- isTest || process.env.NODE_ENV === 'test'
29
+ isTest || process.env.NODE_ENV === 'test' || process.env.JEST_WORKER_ID
29
30
  ? { targets: { node: 'current' }, loose: true }
30
- : {
31
- // Allow importing core-js in entrypoint and use browserslist to select polyfills.
32
- useBuiltIns: options.useBuiltIns ?? 'entry',
33
- corejs: options.useBuiltIns !== false ? 3 : null,
34
- // Do not transform modules to CJS
35
- modules: false,
36
- targets: isModern ? { esmodules: 'intersect' } : undefined,
37
- bugfixes: true,
38
- // Exclude transforms that make all code slower
39
- exclude: ['transform-typeof-symbol'],
40
- // This must match the setting for `@babel/plugin-proposal-class-properties`
41
- loose,
42
- },
31
+ : createBabelPresetEnvOptions(options.useBuiltIns, isModern, loose),
43
32
  ],
44
33
  [
45
34
  require.resolve('@babel/preset-typescript'),
@@ -89,3 +78,34 @@ module.exports = function (api, options = {}) {
89
78
  ],
90
79
  };
91
80
  };
81
+ function createBabelPresetEnvOptions(useBuiltIns, isModern, loose) {
82
+ const presetOptions = {
83
+ // Do not transform modules to CJS
84
+ modules: false,
85
+ targets: isModern ? { esmodules: 'intersect' } : undefined,
86
+ bugfixes: true,
87
+ // Exclude transforms that make all code slower
88
+ exclude: ['transform-typeof-symbol'],
89
+ // This must match the setting for `@babel/plugin-proposal-class-properties`
90
+ loose,
91
+ };
92
+ // If core-js is installed then set corresponding options, otherwise don't use core-js.
93
+ // Previously, core-js was required for all projects, but it is not longer required when using only stable JS features that does not need to be transpiled.
94
+ const coreJsVersion = findCoreJsVersion();
95
+ if (coreJsVersion) {
96
+ presetOptions.useBuiltIns = useBuiltIns ?? 'entry';
97
+ presetOptions.corejs = useBuiltIns !== false ? coreJsVersion : null;
98
+ }
99
+ return presetOptions;
100
+ }
101
+ function findCoreJsVersion() {
102
+ try {
103
+ // nx-ignore-next-line
104
+ const v = require('core-js/package.json').version;
105
+ const { major, minor } = (0, semver_1.parse)(v);
106
+ return `${major}.${minor}`;
107
+ }
108
+ catch (e) {
109
+ return null;
110
+ }
111
+ }
package/executors.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "executors": {
4
4
  "tsc": {
5
5
  "implementation": "./src/executors/tsc/tsc.impl",
package/migrations.json CHANGED
@@ -111,6 +111,62 @@
111
111
  "alwaysAddToPackageJson": false
112
112
  }
113
113
  }
114
+ },
115
+ "17.1.0": {
116
+ "version": "17.1.0-beta.4",
117
+ "x-prompt": "Do you want to update to TypeScript v5.2?",
118
+ "requires": {
119
+ "typescript": ">=5.1.0 <5.2.0"
120
+ },
121
+ "packages": {
122
+ "typescript": {
123
+ "version": "~5.2.2"
124
+ }
125
+ }
126
+ },
127
+ "17.3.0": {
128
+ "version": "17.3.0-beta.3",
129
+ "packages": {
130
+ "@types/node": {
131
+ "version": "^18.16.9",
132
+ "alwaysAddToPackageJson": false
133
+ }
134
+ }
135
+ },
136
+ "17.3.0-beta.10": {
137
+ "version": "17.3.0-beta.10",
138
+ "x-prompt": "Do you want to update to TypeScript v5.3?",
139
+ "requires": {
140
+ "typescript": ">=5.2.0 <5.3.0"
141
+ },
142
+ "packages": {
143
+ "typescript": {
144
+ "version": "~5.3.2",
145
+ "alwaysAddToPackageJson": false
146
+ }
147
+ }
148
+ },
149
+ "18.0.4": {
150
+ "version": "18.0.4-beta.0",
151
+ "packages": {
152
+ "@swc-node/register": {
153
+ "version": "~1.8.0",
154
+ "alwaysAddToPackageJson": false
155
+ }
156
+ }
157
+ },
158
+ "18.2.0": {
159
+ "version": "18.2.0-beta.0",
160
+ "x-prompt": "Do you want to update to TypeScript v5.4?",
161
+ "requires": {
162
+ "typescript": ">=5.3.0 <5.4.0"
163
+ },
164
+ "packages": {
165
+ "typescript": {
166
+ "version": "~5.4.2",
167
+ "alwaysAddToPackageJson": false
168
+ }
169
+ }
114
170
  }
115
171
  }
116
172
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/js",
3
- "version": "17.0.3",
3
+ "version": "17.0.5",
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": {
@@ -30,11 +30,11 @@
30
30
  "generators": "./generators.json",
31
31
  "executors": "./executors.json",
32
32
  "dependencies": {
33
- "@babel/core": "^7.22.9",
33
+ "@babel/core": "^7.23.2",
34
34
  "@babel/plugin-proposal-decorators": "^7.22.7",
35
- "@babel/plugin-transform-runtime": "^7.22.9",
35
+ "@babel/plugin-transform-runtime": "^7.23.2",
36
36
  "@babel/plugin-transform-class-properties": "^7.22.5",
37
- "@babel/preset-env": "^7.22.9",
37
+ "@babel/preset-env": "^7.23.2",
38
38
  "@babel/preset-typescript": "^7.22.5",
39
39
  "@babel/runtime": "^7.22.6",
40
40
  "@phenomnomnominal/tsquery": "~5.0.1",
@@ -52,14 +52,14 @@
52
52
  "tsconfig-paths": "^4.1.2",
53
53
  "ignore": "^5.0.4",
54
54
  "js-tokens": "^4.0.0",
55
- "minimatch": "3.0.5",
55
+ "minimatch": "9.0.3",
56
56
  "ora": "5.3.0",
57
- "semver": "7.5.3",
57
+ "semver": "^7.5.3",
58
58
  "source-map-support": "0.5.19",
59
59
  "tslib": "^2.3.0",
60
- "@nx/devkit": "17.0.3",
61
- "@nx/workspace": "17.0.3",
62
- "@nrwl/js": "17.0.3"
60
+ "@nx/devkit": "17.0.5",
61
+ "@nx/workspace": "17.0.5",
62
+ "@nrwl/js": "17.0.5"
63
63
  },
64
64
  "peerDependencies": {
65
65
  "verdaccio": "^5.0.4"
@@ -61,7 +61,7 @@ async function* nodeExecutor(options, context) {
61
61
  await previousTask?.stop('SIGTERM');
62
62
  await task.start();
63
63
  };
64
- const debouncedProcessQueue = debounce(processQueue, options.debounce ?? 1000);
64
+ const debouncedProcessQueue = debounce(processQueue, options.debounce ?? 1_000);
65
65
  const addToQueue = async (childProcess, buildResult) => {
66
66
  const task = {
67
67
  id: (0, crypto_1.randomUUID)(),
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 2,
3
3
  "outputCapture": "direct-nodejs",
4
- "$schema": "http://json-schema.org/schema",
4
+ "$schema": "https://json-schema.org/schema",
5
5
  "cli": "nx",
6
6
  "title": "Node executor",
7
7
  "description": "Execute Nodejs applications.",
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const devkit_1 = require("@nx/devkit");
4
4
  const child_process_1 = require("child_process");
5
5
  const npm_run_path_1 = require("npm-run-path");
6
+ const path_1 = require("path");
7
+ const npm_config_1 = require("../../utils/npm-config");
6
8
  const log_tar_1 = require("./log-tar");
7
9
  const chalk = require("chalk");
8
10
  const LARGE_BUFFER = 1024 * 1000000;
@@ -17,46 +19,154 @@ function processEnv(color) {
17
19
  return env;
18
20
  }
19
21
  async function runExecutor(options, context) {
22
+ /**
23
+ * We need to check both the env var and the option because the executor may have been triggered
24
+ * indirectly via dependsOn, in which case the env var will be set, but the option will not.
25
+ */
26
+ const isDryRun = process.env.NX_DRY_RUN === 'true' || options.dryRun || false;
20
27
  const projectConfig = context.projectsConfigurations.projects[context.projectName];
21
- const packageRoot = (0, devkit_1.joinPathFragments)(context.root, options.packageRoot ?? projectConfig.root);
22
- const packageJsonPath = (0, devkit_1.joinPathFragments)(packageRoot, 'package.json');
23
- const projectPackageJson = (0, devkit_1.readJsonFile)(packageJsonPath);
24
- const name = projectPackageJson.name;
28
+ const packageRoot = (0, path_1.join)(context.root, options.packageRoot ?? projectConfig.root);
29
+ const packageJsonPath = (0, path_1.join)(packageRoot, 'package.json');
30
+ const packageJson = (0, devkit_1.readJsonFile)(packageJsonPath);
31
+ const packageName = packageJson.name;
25
32
  // If package and project name match, we can make log messages terser
26
- let packageTxt = name === context.projectName
27
- ? `package "${name}"`
28
- : `package "${name}" from project "${context.projectName}"`;
29
- if (projectPackageJson.private === true) {
30
- console.warn(`Skipping ${packageTxt}, because it has \`"private": true\` in ${packageJsonPath}`);
33
+ let packageTxt = packageName === context.projectName
34
+ ? `package "${packageName}"`
35
+ : `package "${packageName}" from project "${context.projectName}"`;
36
+ if (packageJson.private === true) {
37
+ console.warn(`Skipped ${packageTxt}, because it has \`"private": true\` in ${packageJsonPath}`);
31
38
  return {
32
39
  success: true,
33
40
  };
34
41
  }
35
- const npmPublishCommandSegments = [`npm publish --json`];
36
- if (options.registry) {
37
- npmPublishCommandSegments.push(`--registry=${options.registry}`);
42
+ const warnFn = (message) => {
43
+ console.log(chalk.keyword('orange')(message));
44
+ };
45
+ const { registry, tag, registryConfigKey } = await (0, npm_config_1.parseRegistryOptions)(context.root, {
46
+ packageRoot,
47
+ packageJson,
48
+ }, {
49
+ registry: options.registry,
50
+ tag: options.tag,
51
+ }, warnFn);
52
+ const npmViewCommandSegments = [
53
+ `npm view ${packageName} versions dist-tags --json --"${registryConfigKey}=${registry}"`,
54
+ ];
55
+ const npmDistTagAddCommandSegments = [
56
+ `npm dist-tag add ${packageName}@${packageJson.version} ${tag} --"${registryConfigKey}=${registry}"`,
57
+ ];
58
+ /**
59
+ * In a dry-run scenario, it is most likely that all commands are being run with dry-run, therefore
60
+ * the most up to date/relevant version might not exist on disk for us to read and make the npm view
61
+ * request with.
62
+ *
63
+ * Therefore, so as to not produce misleading output in dry around dist-tags being altered, we do not
64
+ * perform the npm view step, and just show npm publish's dry-run output.
65
+ */
66
+ if (!isDryRun && !options.firstRelease) {
67
+ const currentVersion = packageJson.version;
68
+ try {
69
+ const result = (0, child_process_1.execSync)(npmViewCommandSegments.join(' '), {
70
+ env: processEnv(true),
71
+ cwd: context.root,
72
+ stdio: ['ignore', 'pipe', 'pipe'],
73
+ });
74
+ const resultJson = JSON.parse(result.toString());
75
+ const distTags = resultJson['dist-tags'] || {};
76
+ if (distTags[tag] === currentVersion) {
77
+ console.warn(`Skipped ${packageTxt} because v${currentVersion} already exists in ${registry} with tag "${tag}"`);
78
+ return {
79
+ success: true,
80
+ };
81
+ }
82
+ if (resultJson.versions.includes(currentVersion)) {
83
+ try {
84
+ if (!isDryRun) {
85
+ (0, child_process_1.execSync)(npmDistTagAddCommandSegments.join(' '), {
86
+ env: processEnv(true),
87
+ cwd: context.root,
88
+ stdio: 'ignore',
89
+ });
90
+ console.log(`Added the dist-tag ${tag} to v${currentVersion} for registry ${registry}.\n`);
91
+ }
92
+ else {
93
+ console.log(`Would add the dist-tag ${tag} to v${currentVersion} for registry ${registry}, but ${chalk.keyword('orange')('[dry-run]')} was set.\n`);
94
+ }
95
+ return {
96
+ success: true,
97
+ };
98
+ }
99
+ catch (err) {
100
+ try {
101
+ const stdoutData = JSON.parse(err.stdout?.toString() || '{}');
102
+ // If the error is that the package doesn't exist, then we can ignore it because we will be publishing it for the first time in the next step
103
+ if (!(stdoutData.error?.code?.includes('E404') &&
104
+ stdoutData.error?.summary?.includes('no such package available')) &&
105
+ !(err.stderr?.toString().includes('E404') &&
106
+ err.stderr?.toString().includes('no such package available'))) {
107
+ console.error('npm dist-tag add error:');
108
+ if (stdoutData.error.summary) {
109
+ console.error(stdoutData.error.summary);
110
+ }
111
+ if (stdoutData.error.detail) {
112
+ console.error(stdoutData.error.detail);
113
+ }
114
+ if (context.isVerbose) {
115
+ console.error('npm dist-tag add stdout:');
116
+ console.error(JSON.stringify(stdoutData, null, 2));
117
+ }
118
+ return {
119
+ success: false,
120
+ };
121
+ }
122
+ }
123
+ catch (err) {
124
+ console.error('Something unexpected went wrong when processing the npm dist-tag add output\n', err);
125
+ return {
126
+ success: false,
127
+ };
128
+ }
129
+ }
130
+ }
131
+ }
132
+ catch (err) {
133
+ const stdoutData = JSON.parse(err.stdout?.toString() || '{}');
134
+ // If the error is that the package doesn't exist, then we can ignore it because we will be publishing it for the first time in the next step
135
+ if (!(stdoutData.error?.code?.includes('E404') &&
136
+ stdoutData.error?.summary?.toLowerCase().includes('not found')) &&
137
+ !(err.stderr?.toString().includes('E404') &&
138
+ err.stderr?.toString().toLowerCase().includes('not found'))) {
139
+ console.error(`Something unexpected went wrong when checking for existing dist-tags.\n`, err);
140
+ return {
141
+ success: false,
142
+ };
143
+ }
144
+ }
145
+ }
146
+ if (options.firstRelease && context.isVerbose) {
147
+ console.log('Skipped npm view because --first-release was set');
38
148
  }
39
- if (options.tag) {
40
- npmPublishCommandSegments.push(`--tag=${options.tag}`);
149
+ const npmPublishCommandSegments = [
150
+ `npm publish ${packageRoot} --json --"${registryConfigKey}=${registry}" --tag=${tag}`,
151
+ ];
152
+ if (options.otp) {
153
+ npmPublishCommandSegments.push(`--otp=${options.otp}`);
41
154
  }
42
- if (options.dryRun) {
155
+ if (isDryRun) {
43
156
  npmPublishCommandSegments.push(`--dry-run`);
44
157
  }
45
- // Resolve values using the `npm config` command so that things like environment variables and `publishConfig`s are accounted for
46
- const registry = options.registry ?? (0, child_process_1.execSync)(`npm config get registry`).toString().trim();
47
- const tag = options.tag ?? (0, child_process_1.execSync)(`npm config get tag`).toString().trim();
48
158
  try {
49
159
  const output = (0, child_process_1.execSync)(npmPublishCommandSegments.join(' '), {
50
160
  maxBuffer: LARGE_BUFFER,
51
161
  env: processEnv(true),
52
- cwd: packageRoot,
162
+ cwd: context.root,
53
163
  stdio: ['ignore', 'pipe', 'pipe'],
54
164
  });
55
165
  const stdoutData = JSON.parse(output.toString());
56
166
  // If npm workspaces are in use, the publish output will nest the data under the package name, so we normalize it first
57
- const normalizedStdoutData = stdoutData[context.projectName] ?? stdoutData;
167
+ const normalizedStdoutData = stdoutData[packageName] ?? stdoutData;
58
168
  (0, log_tar_1.logTar)(normalizedStdoutData);
59
- if (options.dryRun) {
169
+ if (isDryRun) {
60
170
  console.log(`Would publish to ${registry} with tag "${tag}", but ${chalk.keyword('orange')('[dry-run]')} was set`);
61
171
  }
62
172
  else {
@@ -68,16 +178,7 @@ async function runExecutor(options, context) {
68
178
  }
69
179
  catch (err) {
70
180
  try {
71
- const currentVersion = projectPackageJson.version;
72
181
  const stdoutData = JSON.parse(err.stdout?.toString() || '{}');
73
- if (stdoutData.error?.code === 'EPUBLISHCONFLICT' ||
74
- (stdoutData.error?.code === 'E403' &&
75
- stdoutData.error?.body?.error?.includes('You cannot publish over the previously published versions'))) {
76
- console.warn(`Skipping ${packageTxt}, as v${currentVersion} has already been published to ${registry} with tag "${tag}"`);
77
- return {
78
- success: true,
79
- };
80
- }
81
182
  console.error('npm publish error:');
82
183
  if (stdoutData.error.summary) {
83
184
  console.error(stdoutData.error.summary);
@@ -85,13 +186,15 @@ async function runExecutor(options, context) {
85
186
  if (stdoutData.error.detail) {
86
187
  console.error(stdoutData.error.detail);
87
188
  }
189
+ if (context.isVerbose) {
190
+ console.error('npm publish stdout:');
191
+ console.error(JSON.stringify(stdoutData, null, 2));
192
+ }
88
193
  return {
89
194
  success: false,
90
195
  };
91
196
  }
92
197
  catch (err) {
93
- // npm v9 onwards seems to guarantee stdout will be well formed JSON when --json is used, so maybe we need to
94
- // specify that as minimum supported version? (comes with node 18 and 20 by default)
95
198
  console.error('Something unexpected went wrong when processing the npm publish output\n', err);
96
199
  return {
97
200
  success: false,
@@ -2,5 +2,7 @@ export interface PublishExecutorSchema {
2
2
  packageRoot?: string;
3
3
  registry?: string;
4
4
  tag?: string;
5
+ otp?: number;
5
6
  dryRun?: boolean;
7
+ firstRelease?: boolean;
6
8
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "version": 2,
4
4
  "title": "Implementation details of `nx release publish`",
5
5
  "description": "DO NOT INVOKE DIRECTLY WITH `nx run`. Use `nx release publish` instead.",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 2,
3
3
  "outputCapture": "direct-nodejs",
4
- "$schema": "http://json-schema.org/schema",
4
+ "$schema": "https://json-schema.org/schema",
5
5
  "cli": "nx",
6
6
  "title": "Typescript Build Target",
7
7
  "description": "Builds using SWC.",
@@ -42,7 +42,7 @@ function normalizeOptions(options, root, sourceRoot, projectRoot) {
42
42
  // default to current directory if projectRootParts is [].
43
43
  // Eg: when a project is at the root level, outside of layout dir
44
44
  const swcCwd = projectRootParts.join('/') || '.';
45
- const swcrcPath = (0, get_swcrc_path_1.getSwcrcPath)(options, root, projectRoot);
45
+ const { swcrcPath, tmpSwcrcPath } = (0, get_swcrc_path_1.getSwcrcPath)(options, root, projectRoot);
46
46
  const swcCliOptions = {
47
47
  srcPath: projectDir,
48
48
  destPath: (0, path_1.relative)((0, path_1.join)(root, swcCwd), outputPath),
@@ -60,6 +60,7 @@ function normalizeOptions(options, root, sourceRoot, projectRoot) {
60
60
  outputPath,
61
61
  tsConfig: (0, path_1.join)(root, options.tsConfig),
62
62
  swcCliOptions,
63
+ tmpSwcrcPath,
63
64
  };
64
65
  }
65
66
  async function* swcExecutor(_options, context) {
@@ -79,14 +80,11 @@ async function* swcExecutor(_options, context) {
79
80
  // remap paths for SWC compilation
80
81
  options.swcCliOptions.srcPath = options.swcCliOptions.swcCwd;
81
82
  options.swcCliOptions.swcCwd = '.';
82
- options.swcCliOptions.destPath = options.swcCliOptions.destPath
83
- .split('../')
84
- .at(-1)
85
- .concat('/', options.swcCliOptions.srcPath);
83
+ options.swcCliOptions.destPath = (0, path_1.join)(options.swcCliOptions.destPath.split((0, path_1.normalize)('../')).at(-1), options.swcCliOptions.srcPath);
86
84
  // tmp swcrc with dependencies to exclude
87
85
  // - buildable libraries
88
86
  // - other libraries that are not dependent on the current project
89
- options.swcCliOptions.swcrcPath = (0, inline_2.generateTmpSwcrc)(inlineProjectGraph, options.swcCliOptions.swcrcPath);
87
+ options.swcCliOptions.swcrcPath = (0, inline_2.generateTmpSwcrc)(inlineProjectGraph, options.swcCliOptions.swcrcPath, options.tmpSwcrcPath);
90
88
  }
91
89
  function determineModuleFormatFromSwcrc(absolutePathToSwcrc) {
92
90
  const swcrc = (0, devkit_1.readJsonFile)(absolutePathToSwcrc);
@@ -136,7 +134,8 @@ async function* swcExecutor(_options, context) {
136
134
  }
137
135
  exports.swcExecutor = swcExecutor;
138
136
  function removeTmpSwcrc(swcrcPath) {
139
- if (swcrcPath.includes('tmp/') && swcrcPath.includes('.generated.swcrc')) {
137
+ if (swcrcPath.includes((0, path_1.normalize)('tmp/')) &&
138
+ swcrcPath.includes('.generated.swcrc')) {
140
139
  (0, fs_extra_1.removeSync)((0, path_1.dirname)(swcrcPath));
141
140
  }
142
141
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "version": 2,
4
4
  "title": "Verdaccio Local Registry",
5
5
  "description": "Start a local registry with Verdaccio.",
@@ -149,7 +149,7 @@ function getYarnUnsafeHttpWhitelist(isYarnV1) {
149
149
  : null;
150
150
  }
151
151
  function setYarnUnsafeHttpWhitelist(currentWhitelist, options) {
152
- if (currentWhitelist.size > 1) {
152
+ if (currentWhitelist.size > 0) {
153
153
  (0, child_process_1.execSync)(`yarn config set unsafeHttpWhitelist --json '${JSON.stringify(Array.from(currentWhitelist))}'` + (options.location === 'user' ? ' --home' : ''));
154
154
  }
155
155
  else {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "$id": "NxTypescriptLibrary",
4
4
  "cli": "nx",
5
5
  "title": "Convert a TSC library to SWC",
@@ -49,8 +49,9 @@ async function initGenerator(tree, schema) {
49
49
  // we prefer to use SWC, and fallback to ts-node for workspaces that don't use SWC.
50
50
  '@swc-node/register': versions_1.swcNodeVersion,
51
51
  '@swc/core': versions_1.swcCoreVersion,
52
+ '@swc/helpers': versions_1.swcHelpersVersion,
52
53
  };
53
- if (!schema.js) {
54
+ if (!schema.js && !schema.keepExistingVersions) {
54
55
  const installedTsVersion = await getInstalledTypescriptVersion(tree);
55
56
  if (!installedTsVersion ||
56
57
  !(0, semver_2.satisfies)(installedTsVersion, versions_1.supportedTypescriptVersions, {
@@ -96,7 +97,7 @@ async function initGenerator(tree, schema) {
96
97
  });
97
98
  }
98
99
  const installTask = !schema.skipPackageJson
99
- ? (0, devkit_1.addDependenciesToPackageJson)(tree, {}, devDependencies)
100
+ ? (0, devkit_1.addDependenciesToPackageJson)(tree, {}, devDependencies, undefined, schema.keepExistingVersions)
100
101
  : () => { };
101
102
  tasks.push(installTask);
102
103
  (0, devkit_1.ensurePackage)('prettier', versions_1.prettierVersion);
@@ -2,5 +2,6 @@ export interface InitSchema {
2
2
  js?: boolean;
3
3
  skipFormat?: boolean;
4
4
  skipPackageJson?: boolean;
5
+ keepExistingVersions?: boolean;
5
6
  tsConfigName?: string;
6
7
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "$id": "NxTypescriptInit",
4
4
  "cli": "nx",
5
5
  "title": "Init nx/js",
@@ -21,6 +21,12 @@
21
21
  "description": "Skip adding package.json dependencies",
22
22
  "x-priority": "internal"
23
23
  },
24
+ "keepExistingVersions": {
25
+ "type": "boolean",
26
+ "x-priority": "internal",
27
+ "description": "Keep existing dependencies versions",
28
+ "default": false
29
+ },
24
30
  "tsConfigName": {
25
31
  "type": "string",
26
32
  "description": "Customize the generated tsconfig file name.",
@@ -6,5 +6,9 @@
6
6
  "types": ["node"]
7
7
  },
8
8
  "include": ["src/**/*.ts"<% if (js) { %>, "src/**/*.js"<% } %>],
9
- "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"<% if (js) { %>, "src/**/*.spec.js", "src/**/*.test.js"<% } %>]
9
+ "exclude": [
10
+ <% if (hasUnitTestRunner && unitTestRunner === 'jest') { %>"jest.config.ts",
11
+ <% } else if (hasUnitTestRunner) { %>"vite.config.ts",
12
+ <% } %>"src/**/*.spec.ts", "src/**/*.test.ts"<% if (js) { %>, "src/**/*.spec.js", "src/**/*.test.js"<% } %>
13
+ ]
10
14
  }
@@ -14,6 +14,6 @@ Run `<%= cliCommand %> build <%= name %>` to build the library.
14
14
 
15
15
  ## Running unit tests
16
16
 
17
- Run `<%= cliCommand %> test <%= name %>` to execute the unit tests via [Jest](https://jestjs.io).
17
+ Run `<%= cliCommand %> test <%= name %>` to execute the unit tests via <% if(unitTestRunner === 'jest') { %>[Jest](https://jestjs.io)<% } else { %>[Vitest](https://vitest.dev/)<% } %>.
18
18
 
19
19
  <% } %>
@@ -11,6 +11,6 @@ export interface NormalizedSchema extends LibraryGeneratorSchema {
11
11
  parsedTags: string[];
12
12
  importPath?: string;
13
13
  }
14
- export type AddLintOptions = Pick<NormalizedSchema, 'name' | 'linter' | 'projectRoot' | 'unitTestRunner' | 'js' | 'setParserOptionsProject' | 'rootProject' | 'bundler'>;
14
+ export type AddLintOptions = Pick<NormalizedSchema, 'name' | 'linter' | 'projectRoot' | 'unitTestRunner' | 'js' | 'setParserOptionsProject' | 'rootProject' | 'bundler' | 'addPlugin'>;
15
15
  export declare function addLint(tree: Tree, options: AddLintOptions): Promise<GeneratorCallback>;
16
16
  export default libraryGenerator;