@storm-software/workspace-tools 1.295.87 → 1.296.1

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 (109) hide show
  1. package/README.md +1 -1
  2. package/dist/{chunk-OBATTMGC.mjs → chunk-3WCWA5OH.mjs} +1 -1
  3. package/dist/chunk-54BBSJHK.mjs +40 -0
  4. package/dist/{chunk-GTBTSMUH.mjs → chunk-C3NYIWL4.mjs} +1 -1
  5. package/dist/{chunk-FPNWNZUL.mjs → chunk-J4MHHL63.mjs} +1 -1
  6. package/dist/{chunk-RCSUK5YZ.mjs → chunk-JIWQM3MH.mjs} +1 -1
  7. package/dist/chunk-MKJITWLN.js +40 -0
  8. package/dist/{chunk-HECOVC7R.mjs → chunk-NIETCJS4.mjs} +1 -1
  9. package/dist/{chunk-GCDDSEDG.mjs → chunk-OL6ZWI4R.mjs} +67 -93
  10. package/dist/{chunk-SGI4JCLV.js → chunk-RLJFRJ2F.js} +72 -98
  11. package/dist/{executor-0ivVjqma.d.mts → executor-BF7_LjrR.d.mts} +4 -4
  12. package/dist/{executor-0ivVjqma.d.ts → executor-BF7_LjrR.d.ts} +4 -4
  13. package/dist/executors.d.mts +1 -1
  14. package/dist/executors.d.ts +1 -1
  15. package/dist/executors.js +3 -2
  16. package/dist/executors.mjs +3 -2
  17. package/dist/generators.mjs +5 -5
  18. package/dist/index.d.mts +2 -1
  19. package/dist/index.d.ts +2 -1
  20. package/dist/index.js +13 -9
  21. package/dist/index.mjs +18 -14
  22. package/dist/src/base/base-executor.mjs +1 -1
  23. package/dist/src/base/base-executor.untyped.mjs +1 -1
  24. package/dist/src/base/base-generator.mjs +1 -1
  25. package/dist/src/base/base-generator.untyped.mjs +1 -1
  26. package/dist/src/base/cargo-base-executor.untyped.mjs +1 -1
  27. package/dist/src/base/index.mjs +1 -1
  28. package/dist/src/base/typescript-build-executor.untyped.mjs +1 -1
  29. package/dist/src/base/typescript-library-generator.untyped.mjs +1 -1
  30. package/dist/src/executors/cargo-build/executor.mjs +1 -1
  31. package/dist/src/executors/cargo-build/untyped.mjs +1 -1
  32. package/dist/src/executors/cargo-check/executor.mjs +1 -1
  33. package/dist/src/executors/cargo-check/untyped.mjs +1 -1
  34. package/dist/src/executors/cargo-clippy/executor.mjs +1 -1
  35. package/dist/src/executors/cargo-clippy/untyped.mjs +1 -1
  36. package/dist/src/executors/cargo-doc/executor.mjs +1 -1
  37. package/dist/src/executors/cargo-doc/untyped.mjs +1 -1
  38. package/dist/src/executors/cargo-format/executor.mjs +1 -1
  39. package/dist/src/executors/cargo-format/untyped.mjs +1 -1
  40. package/dist/src/executors/cargo-publish/executor.mjs +1 -1
  41. package/dist/src/executors/cargo-publish/untyped.mjs +1 -1
  42. package/dist/src/executors/clean-package/executor.mjs +1 -1
  43. package/dist/src/executors/clean-package/untyped.mjs +1 -1
  44. package/dist/src/executors/esbuild/executor.mjs +1 -1
  45. package/dist/src/executors/esbuild/untyped.mjs +1 -1
  46. package/dist/src/executors/napi/executor.mjs +1 -1
  47. package/dist/src/executors/napi/untyped.mjs +1 -1
  48. package/dist/src/executors/npm-publish/executor.d.mts +1 -1
  49. package/dist/src/executors/npm-publish/executor.d.ts +1 -1
  50. package/dist/src/executors/npm-publish/executor.js +3 -2
  51. package/dist/src/executors/npm-publish/executor.mjs +3 -2
  52. package/dist/src/executors/npm-publish/schema.d.ts +4 -4
  53. package/dist/src/executors/npm-publish/schema.json +4 -4
  54. package/dist/src/executors/npm-publish/untyped.js +4 -4
  55. package/dist/src/executors/npm-publish/untyped.mjs +5 -5
  56. package/dist/src/executors/size-limit/executor.mjs +1 -1
  57. package/dist/src/executors/size-limit/untyped.mjs +1 -1
  58. package/dist/src/executors/tsdown/executor.mjs +1 -1
  59. package/dist/src/executors/tsdown/untyped.mjs +1 -1
  60. package/dist/src/executors/typia/executor.mjs +1 -1
  61. package/dist/src/executors/typia/untyped.mjs +1 -1
  62. package/dist/src/executors/unbuild/executor.mjs +1 -1
  63. package/dist/src/executors/unbuild/untyped.mjs +1 -1
  64. package/dist/src/generators/browser-library/generator.mjs +2 -2
  65. package/dist/src/generators/browser-library/untyped.mjs +1 -1
  66. package/dist/src/generators/config-schema/generator.mjs +1 -1
  67. package/dist/src/generators/config-schema/untyped.mjs +1 -1
  68. package/dist/src/generators/init/init.mjs +1 -1
  69. package/dist/src/generators/init/untyped.mjs +1 -1
  70. package/dist/src/generators/neutral-library/generator.mjs +2 -2
  71. package/dist/src/generators/neutral-library/untyped.mjs +1 -1
  72. package/dist/src/generators/node-library/generator.mjs +2 -2
  73. package/dist/src/generators/node-library/untyped.mjs +1 -1
  74. package/dist/src/generators/preset/generator.mjs +2 -2
  75. package/dist/src/generators/preset/untyped.mjs +1 -1
  76. package/dist/src/plugins/rust/cargo-toml.mjs +1 -1
  77. package/dist/src/plugins/rust/index.mjs +1 -1
  78. package/dist/src/plugins/typescript/index.mjs +1 -1
  79. package/dist/src/plugins/typescript/tsdown.mjs +1 -1
  80. package/dist/src/plugins/typescript/tsup.mjs +1 -1
  81. package/dist/src/plugins/typescript/untyped-schema.mjs +1 -1
  82. package/dist/src/release/index.mjs +1 -1
  83. package/dist/src/release/js-version-actions.mjs +1 -1
  84. package/dist/src/release/rust-version-actions.mjs +1 -1
  85. package/dist/src/types.mjs +1 -1
  86. package/dist/src/utils/apply-workspace-tokens.mjs +1 -1
  87. package/dist/src/utils/cargo.mjs +1 -1
  88. package/dist/src/utils/create-cli-options.mjs +1 -1
  89. package/dist/src/utils/get-project-configurations.mjs +1 -1
  90. package/dist/src/utils/github.d.mts +19 -0
  91. package/dist/src/utils/github.d.ts +19 -0
  92. package/dist/src/utils/github.js +7 -0
  93. package/dist/src/utils/github.mjs +8 -0
  94. package/dist/src/utils/index.d.mts +4 -0
  95. package/dist/src/utils/index.d.ts +4 -0
  96. package/dist/src/utils/index.js +12 -8
  97. package/dist/src/utils/index.mjs +13 -9
  98. package/dist/src/utils/lock-file.mjs +1 -1
  99. package/dist/src/utils/nx-json.mjs +1 -1
  100. package/dist/src/utils/package-helpers.mjs +1 -1
  101. package/dist/src/utils/plugin-helpers.mjs +1 -1
  102. package/dist/src/utils/project-tags.mjs +1 -1
  103. package/dist/src/utils/registry-helpers.mjs +1 -1
  104. package/dist/src/utils/typia-transform.mjs +1 -1
  105. package/dist/src/utils/versions.mjs +1 -1
  106. package/docs/api/executors/npm-publish/schema.md +4 -4
  107. package/package.json +16 -15
  108. /package/dist/{chunk-JGP4YWZY.js → chunk-DO2X7OZO.js} +0 -0
  109. /package/dist/{chunk-6YZ3OUJB.mjs → chunk-XCVH63OO.mjs} +0 -0
package/README.md CHANGED
@@ -27,7 +27,7 @@ This package is part of the <b>⚡Storm-Ops</b> monorepo. The Storm-Ops packages
27
27
 
28
28
  <h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
29
29
 
30
- [![Version](https://img.shields.io/badge/version-1.295.84-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://prettier.io/)&nbsp;[![Nx](https://img.shields.io/badge/Nx-17.0.2-lightgrey?style=for-the-badge&logo=nx&logoWidth=20&&color=1fb2a6)](http://nx.dev/)&nbsp;[![NextJs](https://img.shields.io/badge/Next.js-14.0.2-lightgrey?style=for-the-badge&logo=nextdotjs&logoWidth=20&color=1fb2a6)](https://nextjs.org/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;[![documented with Fumadocs](https://img.shields.io/badge/documented_with-fumadocs-success.svg?style=for-the-badge&logo=readthedocs&color=1fb2a6)](https://fumadocs.vercel.app/)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/storm-ops/cr.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
30
+ [![Version](https://img.shields.io/badge/version-1.295.87-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://prettier.io/)&nbsp;[![Nx](https://img.shields.io/badge/Nx-17.0.2-lightgrey?style=for-the-badge&logo=nx&logoWidth=20&&color=1fb2a6)](http://nx.dev/)&nbsp;[![NextJs](https://img.shields.io/badge/Next.js-14.0.2-lightgrey?style=for-the-badge&logo=nextdotjs&logoWidth=20&color=1fb2a6)](https://nextjs.org/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;[![documented with Fumadocs](https://img.shields.io/badge/documented_with-fumadocs-success.svg?style=for-the-badge&logo=readthedocs&color=1fb2a6)](https://fumadocs.vercel.app/)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/storm-ops/cr.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
31
31
 
32
32
  <!-- prettier-ignore-start -->
33
33
  <!-- markdownlint-disable -->
@@ -10,7 +10,7 @@ import {
10
10
  } from "./chunk-TBW5MCN6.mjs";
11
11
  import {
12
12
  __dirname
13
- } from "./chunk-GTBTSMUH.mjs";
13
+ } from "./chunk-C3NYIWL4.mjs";
14
14
 
15
15
  // src/generators/browser-library/generator.ts
16
16
  import {
@@ -0,0 +1,40 @@
1
+ import {
2
+ joinPaths
3
+ } from "./chunk-TBW5MCN6.mjs";
4
+
5
+ // src/utils/github.ts
6
+ import { createJiti } from "jiti";
7
+ async function getGitHubTools(workspaceConfig) {
8
+ try {
9
+ const jiti = createJiti(workspaceConfig.workspaceRoot, {
10
+ fsCache: workspaceConfig.skipCache ? false : joinPaths(
11
+ workspaceConfig.workspaceRoot,
12
+ workspaceConfig.directories.cache || "node_modules/.cache/storm",
13
+ "jiti"
14
+ ),
15
+ interopDefault: true
16
+ });
17
+ const core = await jiti.import(
18
+ jiti.esmResolve("@actions/core")
19
+ );
20
+ return {
21
+ error: core.error,
22
+ warning: core.warning,
23
+ info: core.info,
24
+ getIDToken: core.getIDToken
25
+ };
26
+ } catch {
27
+ return {
28
+ error: (message) => console.error(message),
29
+ warning: (message) => console.warn(message),
30
+ info: (message) => console.log(message),
31
+ getIDToken: async () => {
32
+ throw new Error("getIDToken is not supported in this environment");
33
+ }
34
+ };
35
+ }
36
+ }
37
+
38
+ export {
39
+ getGitHubTools
40
+ };
@@ -1,4 +1,4 @@
1
- // ../../node_modules/.pnpm/tsup@8.4.0_patch_hash=751a554d775c3572381af4e7e5fa22eeda6dd6856012fb1cf521d6806eb2dc74__c57ea7b126adfa5c204aaea33b08d818/node_modules/tsup/assets/esm_shims.js
1
+ // ../../node_modules/.pnpm/tsup@8.4.0_patch_hash=751a554d775c3572381af4e7e5fa22eeda6dd6856012fb1cf521d6806eb2dc74__b287391bfb89dd26f0e4843187079e1f/node_modules/tsup/assets/esm_shims.js
2
2
  import { fileURLToPath } from "url";
3
3
  import path from "path";
4
4
  var getFilename = () => fileURLToPath(import.meta.url);
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-ALL63TSY.mjs";
8
8
  import {
9
9
  __dirname
10
- } from "./chunk-GTBTSMUH.mjs";
10
+ } from "./chunk-C3NYIWL4.mjs";
11
11
 
12
12
  // src/generators/preset/generator.ts
13
13
  import {
@@ -10,7 +10,7 @@ import {
10
10
  } from "./chunk-TBW5MCN6.mjs";
11
11
  import {
12
12
  __dirname
13
- } from "./chunk-GTBTSMUH.mjs";
13
+ } from "./chunk-C3NYIWL4.mjs";
14
14
 
15
15
  // src/generators/neutral-library/generator.ts
16
16
  import {
@@ -0,0 +1,40 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkCQDBLKPFjs = require('./chunk-CQDBLKPF.js');
4
+
5
+ // src/utils/github.ts
6
+ var _jiti = require('jiti');
7
+ async function getGitHubTools(workspaceConfig) {
8
+ try {
9
+ const jiti = _jiti.createJiti.call(void 0, workspaceConfig.workspaceRoot, {
10
+ fsCache: workspaceConfig.skipCache ? false : _chunkCQDBLKPFjs.joinPaths.call(void 0,
11
+ workspaceConfig.workspaceRoot,
12
+ workspaceConfig.directories.cache || "node_modules/.cache/storm",
13
+ "jiti"
14
+ ),
15
+ interopDefault: true
16
+ });
17
+ const core = await jiti.import(
18
+ jiti.esmResolve("@actions/core")
19
+ );
20
+ return {
21
+ error: core.error,
22
+ warning: core.warning,
23
+ info: core.info,
24
+ getIDToken: core.getIDToken
25
+ };
26
+ } catch (e) {
27
+ return {
28
+ error: (message) => console.error(message),
29
+ warning: (message) => console.warn(message),
30
+ info: (message) => console.log(message),
31
+ getIDToken: async () => {
32
+ throw new Error("getIDToken is not supported in this environment");
33
+ }
34
+ };
35
+ }
36
+ }
37
+
38
+
39
+
40
+ exports.getGitHubTools = getGitHubTools;
@@ -13,7 +13,7 @@ import {
13
13
  } from "./chunk-TBW5MCN6.mjs";
14
14
  import {
15
15
  __dirname
16
- } from "./chunk-GTBTSMUH.mjs";
16
+ } from "./chunk-C3NYIWL4.mjs";
17
17
 
18
18
  // src/generators/node-library/generator.ts
19
19
  import {
@@ -1,3 +1,6 @@
1
+ import {
2
+ getGitHubTools
3
+ } from "./chunk-54BBSJHK.mjs";
1
4
  import {
2
5
  addPackageJsonGitHead
3
6
  } from "./chunk-EYO6EPEG.mjs";
@@ -243,15 +246,19 @@ import { readFile as readFile3, writeFile as writeFile3 } from "node:fs/promises
243
246
  import { format as format2 } from "prettier";
244
247
  var LARGE_BUFFER = 1024 * 1e6;
245
248
  async function npmPublishExecutorFn(options, context) {
249
+ const workspaceConfig = await getConfig(context.root);
250
+ const github = await getGitHubTools(workspaceConfig);
246
251
  const isDryRun = process.env.NX_DRY_RUN === "true" || options.dryRun || false;
247
252
  if (!context.projectName) {
248
- throw new Error("The `npm-publish` executor requires a `projectName`.");
253
+ github.error("The `npm-publish` executor requires a `projectName`.");
254
+ return { success: false };
249
255
  }
250
256
  const projectConfig = context.projectsConfigurations?.projects?.[context.projectName];
251
257
  if (!projectConfig) {
252
- throw new Error(
258
+ github.error(
253
259
  `Could not find project configuration for \`${context.projectName}\``
254
260
  );
261
+ return { success: false };
255
262
  }
256
263
  const packageRoot = joinPaths(
257
264
  context.root,
@@ -265,15 +272,17 @@ async function npmPublishExecutorFn(options, context) {
265
272
  const packageJsonPath = joinPaths(packageRoot, "package.json");
266
273
  const packageJsonFile = await readFile3(packageJsonPath, "utf8");
267
274
  if (!packageJsonFile) {
268
- throw new Error(`Could not find \`package.json\` at ${packageJsonPath}`);
275
+ github.error(`Could not find \`package.json\` at ${packageJsonPath}`);
276
+ return { success: false };
269
277
  }
270
278
  const packageJson = JSON.parse(packageJsonFile);
271
279
  const projectPackageJsonPath = joinPaths(projectRoot, "package.json");
272
280
  const projectPackageJsonFile = await readFile3(projectPackageJsonPath, "utf8");
273
281
  if (!projectPackageJsonFile) {
274
- throw new Error(
282
+ github.error(
275
283
  `Could not find \`package.json\` at ${projectPackageJsonPath}`
276
284
  );
285
+ return { success: false };
277
286
  }
278
287
  const projectPackageJson = JSON.parse(projectPackageJsonFile);
279
288
  if (packageJson.version !== projectPackageJson.version) {
@@ -325,13 +334,20 @@ async function npmPublishExecutorFn(options, context) {
325
334
  npmPublishCommandSegments.push(`--registry="${registry}" `);
326
335
  npmViewCommandSegments.push(`--registry="${registry}" `);
327
336
  }
328
- if (options.otp) {
329
- npmPublishCommandSegments.push(`--otp="${options.otp}" `);
337
+ let otp = options.otp;
338
+ if (!otp) {
339
+ otp = await github.getIDToken();
340
+ }
341
+ if (!otp) {
342
+ const errorMessage = `One time password (OTP) is required to publish ${packageTxt} to NPM. Usually this should be provided automatically via the GitHub Actions OIDC token (see: https://github.com/actions/toolkit/tree/main/packages/core#oidc-token); however, the release process was unable to retrieve it. Please provide it via the \`otp\` executor option.`;
343
+ github.error(errorMessage);
344
+ return { success: false };
330
345
  }
346
+ npmPublishCommandSegments.push(`--otp="${otp}" `);
347
+ npmPublishCommandSegments.push("--provenance --access=public ");
331
348
  if (isDryRun) {
332
349
  npmPublishCommandSegments.push("--dry-run");
333
350
  }
334
- npmPublishCommandSegments.push("--provenance --access=public ");
335
351
  const tag = options.tag || execSync("npm config get tag", {
336
352
  cwd: packageRoot,
337
353
  env: {
@@ -366,21 +382,21 @@ async function npmPublishExecutorFn(options, context) {
366
382
  return { success: true };
367
383
  }
368
384
  } catch (err) {
369
- console.warn("\n ********************** \n");
370
- console.warn(
371
- `An error occurred while checking for existing dist-tags
372
- ${JSON.stringify(err)}
385
+ console.debug(
386
+ `An error occurred while checking for existing dist-tags. Please note: if this is the first time this package has been published to npm, this can be ignored.
373
387
 
374
- Note: If this is the first time this package has been published to NPM, this can be ignored.`
388
+ Error: ${JSON.stringify(
389
+ err,
390
+ null,
391
+ 2
392
+ )}`
375
393
  );
376
- console.info("");
377
394
  }
378
395
  try {
379
396
  if (!isDryRun) {
380
397
  const command = `npm dist-tag add ${packageName}@${currentVersion} ${tag} --registry="${registry}" `;
381
- console.info(
382
- `Adding the dist-tag ${tag} - preparing to run the following:
383
- ${command}`
398
+ console.debug(
399
+ `Adding the dist-tag ${tag} - preparing to run the following: ${command}`
384
400
  );
385
401
  const result = execSync(command, {
386
402
  cwd: packageRoot,
@@ -392,76 +408,49 @@ ${command}`
392
408
  killSignal: "SIGTERM"
393
409
  });
394
410
  console.info(
395
- `Added the dist-tag ${tag} to v${currentVersion} for registry "${registry}"
411
+ `Added the dist-tag ${tag} to v${currentVersion} for registry "${registry}".
396
412
 
397
413
  Execution response: ${result.toString()}`
398
414
  );
399
415
  } else {
400
416
  console.info(
401
- `Would add the dist-tag ${tag} to v${currentVersion} for registry "${registry}", but [dry-run] was set.
417
+ `Would have added the dist-tag ${tag} to v${currentVersion} for registry "${registry}", but [dry-run] was set.
402
418
  `
403
419
  );
404
420
  }
405
421
  return { success: true };
406
422
  } catch (err) {
407
423
  try {
408
- console.warn("\n ********************** \n");
409
- let error = err;
410
- if (Buffer.isBuffer(error)) {
411
- error = error.toString();
412
- }
413
- console.warn(
414
- `An error occurred while adding dist-tags:
415
- ${error}
416
-
417
- Note: If this is the first time this package has been published to NPM, this can be ignored.`
418
- );
419
- console.info("");
420
424
  const stdoutData = JSON.parse(err.stdout?.toString() || "{}");
421
425
  if (stdoutData?.error && !(stdoutData.error?.code?.includes("E404") && stdoutData.error?.summary?.includes("no such package available")) && !(err.stderr?.toString().includes("E404") && err.stderr?.toString().includes("no such package available"))) {
422
- console.error(
423
- "npm dist-tag add error please see below for more information:"
424
- );
425
- if (stdoutData.error.summary) {
426
- console.error(stdoutData.error?.summary);
427
- }
428
- if (stdoutData.error.detail) {
429
- console.error(stdoutData.error?.detail);
430
- }
431
- if (context.isVerbose) {
432
- console.error(
433
- `npm dist-tag add stdout: ${JSON.stringify(stdoutData, null, 2)}`
434
- );
435
- }
426
+ const errorMessage = `An unexpected error occured while running the npm dist-tag add command:
427
+
428
+ ${stdoutData?.error?.summary ? `Summary: ${stdoutData?.error?.summary}${stdoutData?.error?.code ? ` (${stdoutData?.error?.code})` : ""}
429
+ ` : ""}${stdoutData?.error?.detail ? `Detail: ${stdoutData?.error?.detail}
430
+ ` : ""}`;
431
+ github.error(errorMessage);
436
432
  return { success: false };
437
433
  }
438
434
  } catch (err2) {
439
- console.error(
440
- `Something unexpected went wrong when processing the npm dist-tag add output
441
- ${JSON.stringify(err2)}`
442
- );
435
+ const stdoutData = JSON.parse(err2.stdout?.toString() || "{}");
436
+ const errorMessage = `An unexpected error occured while processing the npm dist-tag add output:
437
+
438
+ ${stdoutData?.error?.summary ? `Summary: ${stdoutData?.error?.summary}${stdoutData?.error?.code ? ` (${stdoutData?.error?.code})` : ""}
439
+ ` : ""}${stdoutData?.error?.detail ? `Detail: ${stdoutData?.error?.detail}
440
+ ` : ""}`;
441
+ github.error(errorMessage);
443
442
  return { success: false };
444
443
  }
445
444
  }
446
445
  } catch (err) {
447
- let error = err;
448
- if (Buffer.isBuffer(error)) {
449
- error = error.toString();
450
- }
451
- console.error("\n ********************** \n");
452
- console.info("");
453
- console.error(
454
- "An error occured trying to run the npm dist-tag add command."
455
- );
456
- console.error(error);
457
- console.info("");
458
446
  const stdoutData = JSON.parse(err.stdout?.toString() || "{}");
459
447
  if (!(stdoutData.error?.code?.includes("E404") && stdoutData.error?.summary?.toLowerCase().includes("not found")) && !(err.stderr?.toString().includes("E404") && err.stderr?.toString().toLowerCase().includes("not found"))) {
460
- console.error(
461
- `Something unexpected went wrong when checking for existing dist-tags.
448
+ const errorMessage = `An unexpected error occured while checking for existing dist-tags:
462
449
 
463
- Error: ${JSON.stringify(err, null, 2)}`
464
- );
450
+ ${stdoutData?.error?.summary ? `Summary: ${stdoutData?.error?.summary}${stdoutData?.error?.code ? ` (${stdoutData?.error?.code})` : ""}
451
+ ` : ""}${stdoutData?.error?.detail ? `Detail: ${stdoutData?.error?.detail}
452
+ ` : ""}`;
453
+ github.error(errorMessage);
465
454
  return { success: false };
466
455
  }
467
456
  }
@@ -483,13 +472,13 @@ Error: ${JSON.stringify(err, null, 2)}`
483
472
  });
484
473
  if (isDryRun) {
485
474
  console.info(
486
- `Would publish to ${registry} with tag "${tag}", but [dry-run] was set ${result ? `
475
+ `Would publish tag "${tag}" to ${registry}, but [dry-run] was set. ${result ? `
487
476
 
488
477
  Execution response: ${result.toString()}` : ""}`
489
478
  );
490
479
  } else {
491
480
  console.info(
492
- `Published to ${registry} with tag "${tag}" ${result ? `
481
+ `Published tag "${tag}" to ${registry}. ${result ? `
493
482
 
494
483
  Execution response: ${result.toString()}` : ""}`
495
484
  );
@@ -497,38 +486,23 @@ Execution response: ${result.toString()}` : ""}`
497
486
  return { success: true };
498
487
  } catch (err) {
499
488
  try {
500
- console.error("\n ********************** \n");
501
- console.info("");
502
- console.error("An error occured running npm publish.");
503
- console.error("Please see below for more information:");
504
- console.info("");
505
489
  const stdoutData = JSON.parse(err.stdout?.toString() || "{}");
506
- if (stdoutData.error.summary) {
507
- console.error(stdoutData.error.summary);
508
- console.error(stdoutData.error.summary);
509
- }
510
- if (stdoutData.error.detail) {
511
- console.error(stdoutData.error.detail);
512
- }
513
- if (context.isVerbose) {
514
- console.error(
515
- `npm publish stdout:
516
- ${JSON.stringify(stdoutData, null, 2)}`
517
- );
518
- }
519
- console.error("\n ********************** \n");
490
+ const errorMessage = `An error occurred while publishing the npm package:
491
+
492
+ ${stdoutData?.error?.summary ? `Summary: ${stdoutData?.error?.summary}${stdoutData?.error?.code ? ` (${stdoutData?.error?.code})` : ""}
493
+ ` : ""}${stdoutData?.error?.detail ? `Detail: ${stdoutData?.error?.detail}
494
+ ` : ""}`;
495
+ github.error(errorMessage);
520
496
  return { success: false };
521
497
  } catch (err2) {
522
- let error = err2;
523
- if (Buffer.isBuffer(error)) {
524
- error = error.toString();
525
- }
526
- console.error(
527
- `Something unexpected went wrong when processing the npm publish output
498
+ const errorMessage = `Something unexpected went wrong when processing the npm publish output.
528
499
 
529
- Error: ${JSON.stringify(error, null, 2)}`
530
- );
531
- console.error("\n ********************** \n");
500
+ Error: ${JSON.stringify(
501
+ Buffer.isBuffer(err2) ? err2.toString() : err2,
502
+ null,
503
+ 2
504
+ )}`;
505
+ github.error(errorMessage);
532
506
  return { success: false };
533
507
  }
534
508
  }