@nx/js 19.2.0-alpha.3 → 19.2.0-beta.0

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/migrations.json CHANGED
@@ -158,6 +158,23 @@
158
158
  "alwaysAddToPackageJson": false
159
159
  }
160
160
  }
161
+ },
162
+ "19.2.0": {
163
+ "version": "19.2.0-beta.0",
164
+ "packages": {
165
+ "@swc/core": {
166
+ "version": "~1.5.7",
167
+ "alwaysAddToPackageJson": false
168
+ },
169
+ "@swc/helpers": {
170
+ "version": "~0.5.11",
171
+ "alwaysAddToPackageJson": false
172
+ },
173
+ "@swc-node/register": {
174
+ "version": "~1.9.1",
175
+ "alwaysAddToPackageJson": false
176
+ }
177
+ }
161
178
  }
162
179
  }
163
180
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/js",
3
- "version": "19.2.0-alpha.3",
3
+ "version": "19.2.0-beta.0",
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": {
@@ -58,9 +58,9 @@
58
58
  "semver": "^7.5.3",
59
59
  "source-map-support": "0.5.19",
60
60
  "tslib": "^2.3.0",
61
- "@nx/devkit": "19.2.0-alpha.3",
62
- "@nx/workspace": "19.2.0-alpha.3",
63
- "@nrwl/js": "19.2.0-alpha.3"
61
+ "@nx/devkit": "19.2.0-beta.0",
62
+ "@nx/workspace": "19.2.0-beta.0",
63
+ "@nrwl/js": "19.2.0-beta.0"
64
64
  },
65
65
  "peerDependencies": {
66
66
  "verdaccio": "^5.0.4"
@@ -0,0 +1,5 @@
1
+ export declare function extractNpmPublishJsonData(str: string): {
2
+ beforeJsonData: string;
3
+ jsonData: Record<string, unknown> | null;
4
+ afterJsonData: string;
5
+ };
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractNpmPublishJsonData = void 0;
4
+ const expectedNpmPublishJsonKeys = [
5
+ 'id',
6
+ 'name',
7
+ 'version',
8
+ 'size',
9
+ 'filename',
10
+ ];
11
+ // Regular expression to match JSON-like objects, including nested objects (which the expected npm publish output will have, e.g. in its "files" array)
12
+ // /{(?:[^{}]|{[^{}]*})*}/g
13
+ // /{ : Matches the opening brace of a JSON object
14
+ // (?: ) : Non-capturing group to apply quantifiers
15
+ // [^{}] : Matches any character except for braces
16
+ // | : OR
17
+ // {[^{}]*} : Matches nested JSON objects
18
+ // * : The non-capturing group (i.e. any character except for braces OR nested JSON objects) can repeat zero or more times
19
+ // } : Matches the closing brace of a JSON object
20
+ // /g : Global flag to match all occurrences in the string
21
+ const jsonRegex = /{(?:[^{}]|{[^{}]*})*}/g;
22
+ function extractNpmPublishJsonData(str) {
23
+ const jsonMatches = str.match(jsonRegex);
24
+ if (jsonMatches) {
25
+ for (const match of jsonMatches) {
26
+ // Cheap upfront check to see if the stringified JSON data has the expected keys as substrings
27
+ if (!expectedNpmPublishJsonKeys.every((key) => str.includes(key))) {
28
+ continue;
29
+ }
30
+ // Full JSON parsing to identify the JSON object
31
+ try {
32
+ const parsedJson = JSON.parse(match);
33
+ if (!expectedNpmPublishJsonKeys.every((key) => parsedJson[key] !== undefined)) {
34
+ continue;
35
+ }
36
+ const jsonStartIndex = str.indexOf(match);
37
+ return {
38
+ beforeJsonData: str.slice(0, jsonStartIndex),
39
+ jsonData: parsedJson,
40
+ afterJsonData: str.slice(jsonStartIndex + match.length),
41
+ };
42
+ }
43
+ catch {
44
+ // Ignore parsing errors for unrelated JSON blocks
45
+ }
46
+ }
47
+ }
48
+ // No applicable jsonData detected, the whole contents is the beforeJsonData
49
+ return {
50
+ beforeJsonData: str,
51
+ jsonData: null,
52
+ afterJsonData: '',
53
+ };
54
+ }
55
+ exports.extractNpmPublishJsonData = extractNpmPublishJsonData;
@@ -7,6 +7,7 @@ const path_1 = require("path");
7
7
  const npm_config_1 = require("../../utils/npm-config");
8
8
  const log_tar_1 = require("./log-tar");
9
9
  const chalk = require("chalk");
10
+ const extract_npm_publish_json_data_1 = require("./extract-npm-publish-json-data");
10
11
  const LARGE_BUFFER = 1024 * 1000000;
11
12
  function processEnv(color) {
12
13
  const env = {
@@ -146,6 +147,11 @@ async function runExecutor(options, context) {
146
147
  if (options.firstRelease && context.isVerbose) {
147
148
  console.log('Skipped npm view because --first-release was set');
148
149
  }
150
+ /**
151
+ * NOTE: If this is ever changed away from running the command at the workspace root and pointing at the package root (e.g. back
152
+ * to running from the package root directly), then special attention should be paid to the fact that npm publish will nest its
153
+ * JSON output under the name of the package in that case (and it would need to be handled below).
154
+ */
149
155
  const npmPublishCommandSegments = [
150
156
  `npm publish "${packageRoot}" --json --"${registryConfigKey}=${registry}" --tag=${tag}`,
151
157
  ];
@@ -162,10 +168,35 @@ async function runExecutor(options, context) {
162
168
  cwd: context.root,
163
169
  stdio: ['ignore', 'pipe', 'pipe'],
164
170
  });
165
- const stdoutData = JSON.parse(output.toString());
166
- // If npm workspaces are in use, the publish output will nest the data under the package name, so we normalize it first
167
- const normalizedStdoutData = stdoutData[packageName] ?? stdoutData;
168
- (0, log_tar_1.logTar)(normalizedStdoutData);
171
+ /**
172
+ * 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.
173
+ * Additionally, we want to capture and show the lifecycle script outputs as beforeJsonData and afterJsonData and print them accordingly below.
174
+ */
175
+ const { beforeJsonData, jsonData, afterJsonData } = (0, extract_npm_publish_json_data_1.extractNpmPublishJsonData)(output.toString());
176
+ if (!jsonData) {
177
+ console.error('The npm publish output data could not be extracted. Please report this issue on https://github.com/nrwl/nx');
178
+ return {
179
+ success: false,
180
+ };
181
+ }
182
+ // If in dry-run mode, the version on disk will not represent the version that would be published, so we scrub it from the output to avoid confusion.
183
+ const dryRunVersionPlaceholder = 'X.X.X-dry-run';
184
+ if (isDryRun) {
185
+ for (const [key, val] of Object.entries(jsonData)) {
186
+ if (typeof val !== 'string') {
187
+ continue;
188
+ }
189
+ jsonData[key] = val.replace(new RegExp(packageJson.version, 'g'), dryRunVersionPlaceholder);
190
+ }
191
+ }
192
+ if (typeof beforeJsonData === 'string' &&
193
+ beforeJsonData.trim().length > 0) {
194
+ console.log(beforeJsonData);
195
+ }
196
+ (0, log_tar_1.logTar)(jsonData);
197
+ if (typeof afterJsonData === 'string' && afterJsonData.trim().length > 0) {
198
+ console.log(afterJsonData);
199
+ }
169
200
  if (isDryRun) {
170
201
  console.log(`Would publish to ${registry} with tag "${tag}", but ${chalk.keyword('orange')('[dry-run]')} was set`);
171
202
  }
@@ -105,7 +105,11 @@ function collectDependencies(project, projGraph, acc, shallow, areTopLevelDeps =
105
105
  }
106
106
  function readTsConfigWithRemappedPaths(tsConfig, generatedTsConfigPath, dependencies) {
107
107
  const generatedTsConfig = { compilerOptions: {} };
108
- generatedTsConfig.extends = (0, path_1.relative)((0, path_1.dirname)(generatedTsConfigPath), tsConfig);
108
+ const dirnameTsConfig = (0, path_1.dirname)(generatedTsConfigPath);
109
+ const relativeTsconfig = (0, path_1.isAbsolute)(dirnameTsConfig)
110
+ ? (0, path_1.relative)(devkit_1.workspaceRoot, dirnameTsConfig)
111
+ : dirnameTsConfig;
112
+ generatedTsConfig.extends = (0, path_1.relative)(relativeTsconfig, tsConfig);
109
113
  generatedTsConfig.compilerOptions.paths = computeCompilerOptionsPaths(tsConfig, dependencies);
110
114
  if (process.env.NX_VERBOSE_LOGGING_PATH_MAPPINGS === 'true') {
111
115
  output_1.output.log({
@@ -2,9 +2,9 @@ export declare const nxVersion: any;
2
2
  export declare const esbuildVersion = "^0.19.2";
3
3
  export declare const prettierVersion = "^2.6.2";
4
4
  export declare const swcCliVersion = "~0.3.12";
5
- export declare const swcCoreVersion = "~1.3.85";
6
- export declare const swcHelpersVersion = "~0.5.2";
7
- export declare const swcNodeVersion = "~1.8.0";
5
+ export declare const swcCoreVersion = "~1.5.7";
6
+ export declare const swcHelpersVersion = "~0.5.11";
7
+ export declare const swcNodeVersion = "~1.9.1";
8
8
  export declare const tsLibVersion = "^2.3.0";
9
9
  export declare const typesNodeVersion = "18.16.9";
10
10
  export declare const verdaccioVersion = "^5.0.4";
@@ -5,9 +5,9 @@ exports.nxVersion = require('../../package.json').version;
5
5
  exports.esbuildVersion = '^0.19.2';
6
6
  exports.prettierVersion = '^2.6.2';
7
7
  exports.swcCliVersion = '~0.3.12';
8
- exports.swcCoreVersion = '~1.3.85';
9
- exports.swcHelpersVersion = '~0.5.2';
10
- exports.swcNodeVersion = '~1.8.0';
8
+ exports.swcCoreVersion = '~1.5.7';
9
+ exports.swcHelpersVersion = '~0.5.11';
10
+ exports.swcNodeVersion = '~1.9.1';
11
11
  exports.tsLibVersion = '^2.3.0';
12
12
  exports.typesNodeVersion = '18.16.9';
13
13
  exports.verdaccioVersion = '^5.0.4';