@storm-software/workspace-tools 1.296.19 → 1.296.21

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/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.296.17-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.296.19-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 -->
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storm-software/workspace-tools",
3
- "version": "1.296.19",
3
+ "version": "1.296.21",
4
4
  "description": "Tools for managing a Storm workspace, including various Nx generators and executors for common development tasks.",
5
5
  "keywords": [
6
6
  "monorepo",
@@ -238,13 +238,13 @@
238
238
  "@size-limit/esbuild": "^11.2.0",
239
239
  "@size-limit/esbuild-why": "^11.2.0",
240
240
  "@size-limit/file": "^11.2.0",
241
- "@storm-software/config-tools": "1.190.41",
242
- "@storm-software/esbuild": "0.53.202",
243
- "@storm-software/npm-tools": "0.6.159",
244
- "@storm-software/pnpm-tools": "0.7.52",
245
- "@storm-software/prettier": "0.59.93",
246
- "@storm-software/tsdown": "0.45.202",
247
- "@storm-software/unbuild": "0.57.202",
241
+ "@storm-software/config-tools": "1.190.43",
242
+ "@storm-software/esbuild": "0.53.204",
243
+ "@storm-software/npm-tools": "0.6.161",
244
+ "@storm-software/pnpm-tools": "0.7.54",
245
+ "@storm-software/prettier": "0.59.95",
246
+ "@storm-software/tsdown": "0.45.204",
247
+ "@storm-software/unbuild": "0.57.204",
248
248
  "fs-extra": "11.2.0",
249
249
  "glob": "^11.1.0",
250
250
  "jiti": "^2.7.0",
@@ -258,7 +258,7 @@
258
258
  },
259
259
  "devDependencies": {
260
260
  "@napi-rs/cli": "^3.7.0",
261
- "@storm-software/package-constants": "0.1.54",
261
+ "@storm-software/package-constants": "0.1.56",
262
262
  "@types/micromatch": "^4.0.10",
263
263
  "@types/node": "^25.9.2",
264
264
  "@types/semver": "^7.7.1",
@@ -283,5 +283,5 @@
283
283
  "publishConfig": { "access": "public" },
284
284
  "executors": "./executors.json",
285
285
  "generators": "./generators.json",
286
- "gitHead": "8b04bd1c84001d6ac81a2ca2348660b2c8a2f52f"
286
+ "gitHead": "a00a4a5ea2a12a0704c5300638f1980a0fcd3bac"
287
287
  }
@@ -1,31 +0,0 @@
1
- import {
2
- withRunExecutor
3
- } from "./chunk-QJ74HYMK.mjs";
4
- import {
5
- buildCargoCommand,
6
- cargoCommand
7
- } from "./chunk-GKLFEOKK.mjs";
8
-
9
- // src/executors/cargo-check/executor.ts
10
- async function cargoCheckExecutor(options, context) {
11
- const command = buildCargoCommand("check", options, context);
12
- return await cargoCommand(context.root, ...command);
13
- }
14
- var executor_default = withRunExecutor(
15
- "Cargo - Check",
16
- cargoCheckExecutor,
17
- {
18
- skipReadingConfig: false,
19
- hooks: {
20
- applyDefaultOptions: (options) => {
21
- options.toolchain ??= "stable";
22
- return options;
23
- }
24
- }
25
- }
26
- );
27
-
28
- export {
29
- cargoCheckExecutor,
30
- executor_default
31
- };
@@ -1,524 +0,0 @@
1
- import {
2
- getGitHubTools
3
- } from "./chunk-54BBSJHK.mjs";
4
- import {
5
- addPackageJsonGitHead
6
- } from "./chunk-D6XEM3XX.mjs";
7
- import {
8
- getConfig
9
- } from "./chunk-R5RFMU22.mjs";
10
- import {
11
- findWorkspaceRoot
12
- } from "./chunk-3J2CP54B.mjs";
13
- import {
14
- joinPaths
15
- } from "./chunk-TBW5MCN6.mjs";
16
-
17
- // ../npm-tools/src/helpers/get-registry.ts
18
- import { exec } from "node:child_process";
19
-
20
- // ../npm-tools/src/constants.ts
21
- var DEFAULT_NPM_REGISTRY = "https://registry.npmjs.org";
22
-
23
- // ../npm-tools/src/helpers/get-registry.ts
24
- async function getRegistry(executable = "npm") {
25
- return new Promise((resolve, reject) => {
26
- exec(`${executable} config get registry`, (error, stdout, stderr) => {
27
- if (error && !error.message.toLowerCase().trim().startsWith("npm warn")) {
28
- return reject(error);
29
- }
30
- if (stderr && !stderr.toLowerCase().trim().startsWith("npm warn")) {
31
- return reject(stderr);
32
- }
33
- return resolve(stdout.trim());
34
- });
35
- });
36
- }
37
- async function getNpmRegistry() {
38
- if (process.env.STORM_REGISTRY_NPM) {
39
- return process.env.STORM_REGISTRY_NPM;
40
- }
41
- const workspaceConfig = await getConfig();
42
- if (workspaceConfig?.registry?.npm) {
43
- return workspaceConfig?.registry?.npm;
44
- }
45
- return DEFAULT_NPM_REGISTRY;
46
- }
47
-
48
- // ../pnpm-tools/src/helpers/replace-deps-aliases.ts
49
- import {
50
- createProjectGraphAsync,
51
- readCachedProjectGraph
52
- } from "@nx/devkit";
53
- import { existsSync as existsSync2 } from "node:fs";
54
- import { readFile as readFile2, writeFile as writeFile2 } from "node:fs/promises";
55
- import { format } from "prettier";
56
-
57
- // ../npm-tools/src/helpers/get-version.ts
58
- import { exec as exec2 } from "node:child_process";
59
-
60
- // ../pnpm-tools/src/helpers/catalog.ts
61
- import { coerce, gt, valid } from "semver";
62
-
63
- // ../pnpm-tools/src/helpers/pnpm-workspace.ts
64
- import { existsSync } from "node:fs";
65
- import { readFile, writeFile } from "node:fs/promises";
66
- import { parse, stringify } from "yaml";
67
- function getPnpmWorkspaceFilePath(workspaceRoot = findWorkspaceRoot(process.cwd())) {
68
- const pnpmWorkspacePath = joinPaths(workspaceRoot, "pnpm-workspace.yaml");
69
- if (!existsSync(pnpmWorkspacePath)) {
70
- throw new Error(
71
- `No \`pnpm-workspace.yaml\` file found in workspace root (searched in: ${pnpmWorkspacePath}).`
72
- );
73
- }
74
- return pnpmWorkspacePath;
75
- }
76
- async function readPnpmWorkspaceFile(workspaceRoot = findWorkspaceRoot(process.cwd())) {
77
- const result = await readFile(
78
- getPnpmWorkspaceFilePath(workspaceRoot),
79
- "utf8"
80
- );
81
- if (!result) {
82
- return void 0;
83
- }
84
- return parse(result);
85
- }
86
-
87
- // ../pnpm-tools/src/helpers/catalog.ts
88
- async function getCatalogSafe(workspaceRoot = findWorkspaceRoot(process.cwd())) {
89
- const pnpmWorkspaceFile = await readPnpmWorkspaceFile(workspaceRoot);
90
- if (!pnpmWorkspaceFile) {
91
- throw new Error("No pnpm-workspace.yaml file found");
92
- }
93
- if (pnpmWorkspaceFile?.catalog) {
94
- return Object.fromEntries(
95
- Object.entries(pnpmWorkspaceFile.catalog).map(([key, value]) => {
96
- return [key, value.replaceAll('"', "").replaceAll("'", "")];
97
- })
98
- );
99
- } else {
100
- console.warn(
101
- `No catalog found in pnpm-workspace.yaml file located in workspace root: ${workspaceRoot}
102
- File content: ${JSON.stringify(
103
- pnpmWorkspaceFile,
104
- null,
105
- 2
106
- )}`
107
- );
108
- }
109
- return void 0;
110
- }
111
- async function getCatalog(workspaceRoot = findWorkspaceRoot(process.cwd())) {
112
- const catalog = await getCatalogSafe(workspaceRoot);
113
- if (!catalog) {
114
- throw new Error("No catalog entries found in pnpm-workspace.yaml file");
115
- }
116
- return catalog;
117
- }
118
-
119
- // ../pnpm-tools/src/helpers/replace-deps-aliases.ts
120
- async function replaceDepsAliases(packageRoot = process.cwd(), workspaceRoot = findWorkspaceRoot(packageRoot)) {
121
- const packageJsonPath = joinPaths(packageRoot, "package.json");
122
- const packageJsonFile = await readFile2(packageJsonPath, "utf8");
123
- if (!packageJsonFile) {
124
- throw new Error(
125
- "No package.json file found in package root: " + packageRoot
126
- );
127
- }
128
- const catalog = await getCatalog(workspaceRoot);
129
- const packageJson = JSON.parse(packageJsonFile);
130
- const pnpmWorkspacePath = joinPaths(workspaceRoot, "pnpm-workspace.yaml");
131
- if (!existsSync2(pnpmWorkspacePath)) {
132
- console.warn(
133
- `No \`pnpm-workspace.yaml\` file found in workspace root (searching in: ${pnpmWorkspacePath}). Skipping pnpm catalog read for now.`
134
- );
135
- return packageJson;
136
- }
137
- if (!catalog) {
138
- console.warn(
139
- `No pnpm catalog found. Skipping dependencies replacement for now.`
140
- );
141
- return;
142
- }
143
- for (const dependencyType of [
144
- "dependencies",
145
- "devDependencies",
146
- "peerDependencies"
147
- ]) {
148
- const dependencies = packageJson[dependencyType];
149
- if (!dependencies) {
150
- continue;
151
- }
152
- for (const dependencyName of Object.keys(dependencies)) {
153
- if (dependencies[dependencyName] === "catalog:") {
154
- if (!catalog) {
155
- throw new Error(
156
- `Dependency ${dependencyName} is marked as \`catalog:\`, but no catalog exists in the workspace root's \`pnpm-workspace.yaml\` file.`
157
- );
158
- }
159
- const catalogVersion = catalog[dependencyName];
160
- if (!catalogVersion) {
161
- throw new Error("Missing pnpm catalog version for " + dependencyName);
162
- }
163
- dependencies[dependencyName] = catalogVersion;
164
- } else if (dependencies[dependencyName].startsWith("catalog:")) {
165
- throw new Error("multiple named catalogs not supported");
166
- }
167
- }
168
- }
169
- let projectGraph;
170
- try {
171
- projectGraph = readCachedProjectGraph();
172
- } catch {
173
- await createProjectGraphAsync();
174
- projectGraph = readCachedProjectGraph();
175
- }
176
- const workspacePackages = {};
177
- if (projectGraph) {
178
- await Promise.all(
179
- Object.keys(projectGraph.nodes).map(async (node) => {
180
- const projectNode = projectGraph.nodes[node];
181
- if (projectNode?.data.root) {
182
- const projectPackageJsonPath = joinPaths(
183
- workspaceRoot,
184
- projectNode.data.root,
185
- "package.json"
186
- );
187
- if (existsSync2(projectPackageJsonPath)) {
188
- const projectPackageJsonContent = await readFile2(
189
- projectPackageJsonPath,
190
- "utf8"
191
- );
192
- const projectPackageJson = JSON.parse(projectPackageJsonContent);
193
- if (projectPackageJson.private !== true) {
194
- workspacePackages[projectPackageJson.name] = projectPackageJson.version;
195
- }
196
- }
197
- }
198
- })
199
- );
200
- }
201
- for (const dependencyType of [
202
- "dependencies",
203
- "devDependencies",
204
- "peerDependencies"
205
- ]) {
206
- const dependencies = packageJson[dependencyType];
207
- if (!dependencies) {
208
- continue;
209
- }
210
- for (const dependencyName of Object.keys(dependencies)) {
211
- if (dependencies[dependencyName].startsWith("workspace:")) {
212
- if (workspacePackages[dependencyName]) {
213
- dependencies[dependencyName] = `^${workspacePackages[dependencyName]}`;
214
- } else {
215
- throw new Error(
216
- `Workspace dependency ${dependencyName} not found in workspace packages.`
217
- );
218
- }
219
- }
220
- }
221
- }
222
- return writeFile2(
223
- packageJsonPath,
224
- await format(JSON.stringify(packageJson), {
225
- parser: "json",
226
- proseWrap: "preserve",
227
- trailingComma: "none",
228
- tabWidth: 2,
229
- semi: true,
230
- singleQuote: false,
231
- quoteProps: "as-needed",
232
- insertPragma: false,
233
- bracketSameLine: true,
234
- printWidth: 80,
235
- bracketSpacing: true,
236
- arrowParens: "avoid",
237
- endOfLine: "lf",
238
- plugins: ["prettier-plugin-packagejson"]
239
- })
240
- );
241
- }
242
-
243
- // src/executors/npm-publish/executor.ts
244
- import { execSync } from "node:child_process";
245
- import { readFile as readFile3, writeFile as writeFile3 } from "node:fs/promises";
246
- import { format as format2 } from "prettier";
247
- var LARGE_BUFFER = 1024 * 1e6;
248
- async function npmPublishExecutorFn(options, context) {
249
- const workspaceConfig = await getConfig(context.root);
250
- const github = await getGitHubTools(workspaceConfig);
251
- const isDryRun = process.env.NX_DRY_RUN === "true" || options.dryRun || false;
252
- if (!context.projectName) {
253
- github.error("The `npm-publish` executor requires a `projectName`.");
254
- return { success: false };
255
- }
256
- const projectConfig = context.projectsConfigurations?.projects?.[context.projectName];
257
- if (!projectConfig) {
258
- github.error(
259
- `Could not find project configuration for \`${context.projectName}\``
260
- );
261
- return { success: false };
262
- }
263
- const packageRoot = joinPaths(
264
- context.root,
265
- options.packageRoot || joinPaths("dist", projectConfig.root)
266
- );
267
- const projectRoot = context.projectsConfigurations.projects[context.projectName]?.root ? joinPaths(
268
- context.root,
269
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
270
- context.projectsConfigurations.projects[context.projectName].root
271
- ) : packageRoot;
272
- const packageJsonPath = joinPaths(packageRoot, "package.json");
273
- const packageJsonFile = await readFile3(packageJsonPath, "utf8");
274
- if (!packageJsonFile) {
275
- github.error(`Could not find \`package.json\` at ${packageJsonPath}`);
276
- return { success: false };
277
- }
278
- const packageJson = JSON.parse(packageJsonFile);
279
- const projectPackageJsonPath = joinPaths(projectRoot, "package.json");
280
- const projectPackageJsonFile = await readFile3(projectPackageJsonPath, "utf8");
281
- if (!projectPackageJsonFile) {
282
- github.error(
283
- `Could not find \`package.json\` at ${projectPackageJsonPath}`
284
- );
285
- return { success: false };
286
- }
287
- const projectPackageJson = JSON.parse(projectPackageJsonFile);
288
- if (packageJson.version !== projectPackageJson.version) {
289
- console.warn(
290
- `The version in the package.json file at ${packageJsonPath} (current: ${packageJson.version}) does not match the version in the package.json file at ${projectPackageJsonPath} (current: ${projectPackageJson.version}). This file will be updated to match the version in the project package.json file.`
291
- );
292
- if (projectPackageJson.version) {
293
- packageJson.version = projectPackageJson.version;
294
- await writeFile3(
295
- packageJsonPath,
296
- await format2(JSON.stringify(packageJson), {
297
- parser: "json",
298
- proseWrap: "preserve",
299
- trailingComma: "none",
300
- tabWidth: 2,
301
- semi: true,
302
- singleQuote: false,
303
- quoteProps: "as-needed",
304
- insertPragma: false,
305
- bracketSameLine: true,
306
- printWidth: 80,
307
- bracketSpacing: true,
308
- arrowParens: "avoid",
309
- endOfLine: "lf",
310
- plugins: ["prettier-plugin-packagejson"]
311
- })
312
- );
313
- }
314
- }
315
- const packageName = packageJson.name;
316
- console.info(
317
- `\u{1F680} Running Storm NPM Publish executor on the ${packageName} package`
318
- );
319
- const packageTxt = packageName === context.projectName ? `package "${packageName}"` : `package "${packageName}" from project "${context.projectName}"`;
320
- if (packageJson.private === true) {
321
- console.warn(
322
- `Skipped ${packageTxt}, because it has \`"private": true\` in ${packageJsonPath}`
323
- );
324
- return { success: true };
325
- }
326
- await replaceDepsAliases(packageRoot, context.root);
327
- await addPackageJsonGitHead(packageRoot);
328
- const npmPublishCommandSegments = [`npm publish --json`];
329
- const npmViewCommandSegments = [
330
- `npm view ${packageName} versions dist-tags --json`
331
- ];
332
- const registry = await Promise.resolve(
333
- options.registry ?? (await getRegistry() || getNpmRegistry())
334
- );
335
- if (registry) {
336
- npmPublishCommandSegments.push(`--registry="${registry}" `);
337
- npmViewCommandSegments.push(`--registry="${registry}" `);
338
- }
339
- if (options.otp) {
340
- npmPublishCommandSegments.push(`--otp="${options.otp}" `);
341
- }
342
- let token;
343
- if (!options.otp) {
344
- token = await github.getIDToken(
345
- `npm:${registry.replace(/^https?:\/\//, "")}`
346
- );
347
- if (!token) {
348
- github.warning(
349
- `Either a One time password (OTP) or an OpenID Connect (OIDC) token is generally required to publish ${packageTxt} to NPM. Usually the OIDC token should be provided automatically via GitHub Actions (see: https://github.com/actions/toolkit/tree/main/packages/core#oidc-token); however, the release process was unable to retrieve it. Please provide a \`otp\` executor option, or investigate why the OIDC token could not be retrieved.`
350
- );
351
- }
352
- }
353
- npmPublishCommandSegments.push("--provenance --access=public ");
354
- if (isDryRun) {
355
- npmPublishCommandSegments.push("--dry-run");
356
- }
357
- const tag = options.tag || execSync("npm config get tag", {
358
- cwd: packageRoot,
359
- env: {
360
- NPM_ID_TOKEN: token,
361
- ...process.env,
362
- FORCE_COLOR: "true"
363
- },
364
- maxBuffer: LARGE_BUFFER,
365
- killSignal: "SIGTERM"
366
- }).toString().trim();
367
- if (tag) {
368
- npmPublishCommandSegments.push(`--tag="${tag}" `);
369
- }
370
- if (!isDryRun) {
371
- const currentVersion = options.version || packageJson.version;
372
- try {
373
- try {
374
- const result = execSync(npmViewCommandSegments.join(" "), {
375
- cwd: packageRoot,
376
- env: {
377
- NPM_ID_TOKEN: token,
378
- ...process.env,
379
- FORCE_COLOR: "true"
380
- },
381
- maxBuffer: LARGE_BUFFER,
382
- killSignal: "SIGTERM"
383
- });
384
- const resultJson = JSON.parse(result.toString());
385
- const distTags = resultJson["dist-tags"] || {};
386
- if (distTags[tag] === currentVersion) {
387
- console.warn(
388
- `Skipped ${packageTxt} because v${currentVersion} already exists in ${registry} with tag "${tag}"`
389
- );
390
- return { success: true };
391
- }
392
- } catch (err) {
393
- console.debug(
394
- `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.
395
-
396
- Error: ${JSON.stringify(
397
- err,
398
- null,
399
- 2
400
- )}`
401
- );
402
- }
403
- try {
404
- if (!isDryRun) {
405
- const command = `npm dist-tag add ${packageName}@${currentVersion} ${tag} --registry="${registry}" `;
406
- console.debug(
407
- `Adding the dist-tag ${tag} - preparing to run the following: ${command}`
408
- );
409
- const result = execSync(command, {
410
- cwd: packageRoot,
411
- env: {
412
- NPM_ID_TOKEN: token,
413
- ...process.env,
414
- FORCE_COLOR: "true"
415
- },
416
- maxBuffer: LARGE_BUFFER,
417
- killSignal: "SIGTERM"
418
- });
419
- console.info(
420
- `Added the dist-tag ${tag} to v${currentVersion} for registry "${registry}".
421
-
422
- Execution response: ${result.toString()}`
423
- );
424
- } else {
425
- console.info(
426
- `Would have added the dist-tag ${tag} to v${currentVersion} for registry "${registry}", but [dry-run] was set.
427
- `
428
- );
429
- }
430
- return { success: true };
431
- } catch (err) {
432
- try {
433
- const stdoutData = JSON.parse(err.stdout?.toString() || "{}");
434
- 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"))) {
435
- const errorMessage = `An unexpected error occured while running the npm dist-tag add command:
436
-
437
- ${stdoutData?.error?.summary ? `Summary: ${stdoutData?.error?.summary}${stdoutData?.error?.code ? ` (${stdoutData?.error?.code})` : ""}
438
- ` : ""}${stdoutData?.error?.detail ? `Detail: ${stdoutData?.error?.detail}
439
- ` : ""}`;
440
- github.error(errorMessage);
441
- return { success: false };
442
- }
443
- } catch (err2) {
444
- const stdoutData = JSON.parse(err2.stdout?.toString() || "{}");
445
- const errorMessage = `An unexpected error occured while processing the npm dist-tag add output:
446
-
447
- ${stdoutData?.error?.summary ? `Summary: ${stdoutData?.error?.summary}${stdoutData?.error?.code ? ` (${stdoutData?.error?.code})` : ""}
448
- ` : ""}${stdoutData?.error?.detail ? `Detail: ${stdoutData?.error?.detail}
449
- ` : ""}`;
450
- github.error(errorMessage);
451
- return { success: false };
452
- }
453
- }
454
- } catch (err) {
455
- const stdoutData = JSON.parse(err.stdout?.toString() || "{}");
456
- 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"))) {
457
- const errorMessage = `An unexpected error occured while checking for existing dist-tags:
458
-
459
- ${stdoutData?.error?.summary ? `Summary: ${stdoutData?.error?.summary}${stdoutData?.error?.code ? ` (${stdoutData?.error?.code})` : ""}
460
- ` : ""}${stdoutData?.error?.detail ? `Detail: ${stdoutData?.error?.detail}
461
- ` : ""}`;
462
- github.error(errorMessage);
463
- return { success: false };
464
- }
465
- }
466
- }
467
- try {
468
- const cwd = packageRoot;
469
- const command = npmPublishCommandSegments.join(" ");
470
- console.info(
471
- `Running publish command "${command}" in current working directory: "${cwd}" `
472
- );
473
- const result = execSync(command, {
474
- cwd,
475
- env: {
476
- NPM_ID_TOKEN: token,
477
- ...process.env,
478
- FORCE_COLOR: "true"
479
- },
480
- maxBuffer: LARGE_BUFFER,
481
- killSignal: "SIGTERM"
482
- });
483
- if (isDryRun) {
484
- console.info(
485
- `Would publish tag "${tag}" to ${registry}, but [dry-run] was set. ${result ? `
486
-
487
- Execution response: ${result.toString()}` : ""}`
488
- );
489
- } else {
490
- console.info(
491
- `Published tag "${tag}" to ${registry}. ${result ? `
492
-
493
- Execution response: ${result.toString()}` : ""}`
494
- );
495
- }
496
- return { success: true };
497
- } catch (err) {
498
- try {
499
- const stdoutData = JSON.parse(err.stdout?.toString() || "{}");
500
- const errorMessage = `An error occurred while publishing the npm package:
501
-
502
- ${stdoutData?.error?.summary ? `Summary: ${stdoutData?.error?.summary}${stdoutData?.error?.code ? ` (${stdoutData?.error?.code})` : ""}
503
- ` : ""}${stdoutData?.error?.detail ? `Detail: ${stdoutData?.error?.detail}
504
- ` : ""}`;
505
- github.error(errorMessage);
506
- return { success: false };
507
- } catch (err2) {
508
- const errorMessage = `Something unexpected went wrong when processing the npm publish output.
509
-
510
- Error: ${JSON.stringify(
511
- Buffer.isBuffer(err2) ? err2.toString() : err2,
512
- null,
513
- 2
514
- )}`;
515
- github.error(errorMessage);
516
- return { success: false };
517
- }
518
- }
519
- }
520
-
521
- export {
522
- LARGE_BUFFER,
523
- npmPublishExecutorFn
524
- };