@storm-software/workspace-tools 1.297.1 → 1.297.2

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/dist/executors.js CHANGED
@@ -5,20 +5,20 @@ var _chunkUEDAT7SJjs = require('./chunk-UEDAT7SJ.js');
5
5
 
6
6
 
7
7
  var _chunkZWUGCEBZjs = require('./chunk-ZWUGCEBZ.js');
8
- require('./chunk-HKZ7DBR7.js');
9
8
 
10
9
 
11
10
  var _chunkVKLLVYQ5js = require('./chunk-VKLLVYQ5.js');
11
+ require('./chunk-HKZ7DBR7.js');
12
12
 
13
13
 
14
14
  var _chunk65C6CGV3js = require('./chunk-65C6CGV3.js');
15
15
 
16
16
 
17
17
  var _chunkULONYXYFjs = require('./chunk-ULONYXYF.js');
18
+ require('./chunk-KCQIASWP.js');
18
19
 
19
20
 
20
21
  var _chunk3AHXYCKAjs = require('./chunk-3AHXYCKA.js');
21
- require('./chunk-KCQIASWP.js');
22
22
 
23
23
 
24
24
  var _chunkN5LZIOWWjs = require('./chunk-N5LZIOWW.js');
@@ -5,20 +5,20 @@ import {
5
5
  import {
6
6
  unbuildExecutorFn
7
7
  } from "./chunk-N2PEIA6H.mjs";
8
- import "./chunk-N55FJ7J3.mjs";
9
8
  import {
10
9
  napiExecutor
11
10
  } from "./chunk-U6J67ZUE.mjs";
11
+ import "./chunk-N55FJ7J3.mjs";
12
12
  import {
13
13
  sizeLimitExecutorFn
14
14
  } from "./chunk-I7RM7R7C.mjs";
15
15
  import {
16
16
  tsdownExecutorFn
17
17
  } from "./chunk-MOIGXVIF.mjs";
18
+ import "./chunk-52ZDVDIY.mjs";
18
19
  import {
19
20
  getRegistryVersion
20
21
  } from "./chunk-QQ64FCAP.mjs";
21
- import "./chunk-52ZDVDIY.mjs";
22
22
  import {
23
23
  esbuildExecutorFn
24
24
  } from "./chunk-XLOJK63P.mjs";
@@ -1,9 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-C3TC7AUW.js');
2
2
 
3
3
 
4
- var _chunkOKSECMVKjs = require('./chunk-OKSECMVK.js');
5
-
6
-
7
4
  var _chunkW4JSEGT2js = require('./chunk-W4JSEGT2.js');
8
5
 
9
6
 
@@ -17,6 +14,9 @@ var _chunkXV4FCARJjs = require('./chunk-XV4FCARJ.js');
17
14
 
18
15
 
19
16
  var _chunk32MOOPKKjs = require('./chunk-32MOOPKK.js');
17
+
18
+
19
+ var _chunkOKSECMVKjs = require('./chunk-OKSECMVK.js');
20
20
  require('./chunk-HN5UXNLM.js');
21
21
  require('./chunk-ILSI74FW.js');
22
22
  require('./chunk-3G7PNDZ5.js');
@@ -1,7 +1,4 @@
1
1
  import "./chunk-SAIDGUHG.mjs";
2
- import {
3
- initGenerator
4
- } from "./chunk-437WGH2M.mjs";
5
2
  import {
6
3
  neutralLibraryGeneratorFn
7
4
  } from "./chunk-5IB3CZCB.mjs";
@@ -17,6 +14,9 @@ import {
17
14
  import {
18
15
  configSchemaGeneratorFn
19
16
  } from "./chunk-EYIUJSGD.mjs";
17
+ import {
18
+ initGenerator
19
+ } from "./chunk-437WGH2M.mjs";
20
20
  import "./chunk-VQYZG5YE.mjs";
21
21
  import "./chunk-XSHN3XHD.mjs";
22
22
  import "./chunk-DEHA5C77.mjs";
package/dist/index.js CHANGED
@@ -49,20 +49,20 @@ var _chunkUEDAT7SJjs = require('./chunk-UEDAT7SJ.js');
49
49
 
50
50
 
51
51
  var _chunkZWUGCEBZjs = require('./chunk-ZWUGCEBZ.js');
52
- require('./chunk-HKZ7DBR7.js');
53
52
 
54
53
 
55
54
  var _chunkVKLLVYQ5js = require('./chunk-VKLLVYQ5.js');
55
+ require('./chunk-HKZ7DBR7.js');
56
56
 
57
57
 
58
58
  var _chunk65C6CGV3js = require('./chunk-65C6CGV3.js');
59
59
 
60
60
 
61
61
  var _chunkULONYXYFjs = require('./chunk-ULONYXYF.js');
62
+ require('./chunk-KCQIASWP.js');
62
63
 
63
64
 
64
65
  var _chunk3AHXYCKAjs = require('./chunk-3AHXYCKA.js');
65
- require('./chunk-KCQIASWP.js');
66
66
 
67
67
 
68
68
  var _chunkN5LZIOWWjs = require('./chunk-N5LZIOWW.js');
@@ -110,9 +110,6 @@ require('./chunk-N2365RCI.js');
110
110
  require('./chunk-C3TC7AUW.js');
111
111
 
112
112
 
113
- var _chunkOKSECMVKjs = require('./chunk-OKSECMVK.js');
114
-
115
-
116
113
  var _chunkW4JSEGT2js = require('./chunk-W4JSEGT2.js');
117
114
 
118
115
 
@@ -128,6 +125,9 @@ var _chunkXV4FCARJjs = require('./chunk-XV4FCARJ.js');
128
125
  var _chunk32MOOPKKjs = require('./chunk-32MOOPKK.js');
129
126
 
130
127
 
128
+ var _chunkOKSECMVKjs = require('./chunk-OKSECMVK.js');
129
+
130
+
131
131
 
132
132
 
133
133
 
package/dist/index.mjs CHANGED
@@ -49,20 +49,20 @@ import {
49
49
  import {
50
50
  unbuildExecutorFn
51
51
  } from "./chunk-N2PEIA6H.mjs";
52
- import "./chunk-N55FJ7J3.mjs";
53
52
  import {
54
53
  napiExecutor
55
54
  } from "./chunk-U6J67ZUE.mjs";
55
+ import "./chunk-N55FJ7J3.mjs";
56
56
  import {
57
57
  sizeLimitExecutorFn
58
58
  } from "./chunk-I7RM7R7C.mjs";
59
59
  import {
60
60
  tsdownExecutorFn
61
61
  } from "./chunk-MOIGXVIF.mjs";
62
+ import "./chunk-52ZDVDIY.mjs";
62
63
  import {
63
64
  getRegistryVersion
64
65
  } from "./chunk-QQ64FCAP.mjs";
65
- import "./chunk-52ZDVDIY.mjs";
66
66
  import {
67
67
  esbuildExecutorFn
68
68
  } from "./chunk-XLOJK63P.mjs";
@@ -108,9 +108,6 @@ import {
108
108
  } from "./chunk-G4DPDEL3.mjs";
109
109
  import "./chunk-UA33NH5O.mjs";
110
110
  import "./chunk-SAIDGUHG.mjs";
111
- import {
112
- initGenerator
113
- } from "./chunk-437WGH2M.mjs";
114
111
  import {
115
112
  neutralLibraryGeneratorFn
116
113
  } from "./chunk-5IB3CZCB.mjs";
@@ -126,6 +123,9 @@ import {
126
123
  import {
127
124
  configSchemaGeneratorFn
128
125
  } from "./chunk-EYIUJSGD.mjs";
126
+ import {
127
+ initGenerator
128
+ } from "./chunk-437WGH2M.mjs";
129
129
  import {
130
130
  BUN_LOCK_FILE,
131
131
  BUN_LOCK_PATH,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storm-software/workspace-tools",
3
- "version": "1.297.1",
3
+ "version": "1.297.2",
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,11 +238,11 @@
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": "^1.138.68",
242
- "@storm-software/config-tools": "^1.190.132",
243
- "@storm-software/npm-tools": "^0.6.252",
244
- "@storm-software/prettier": "^0.59.185",
245
- "@storm-software/tsdown": "^0.45.293",
241
+ "@storm-software/config": "^1.138.69",
242
+ "@storm-software/config-tools": "^1.190.133",
243
+ "@storm-software/npm-tools": "^0.6.253",
244
+ "@storm-software/prettier": "^0.59.186",
245
+ "@storm-software/tsdown": "^0.45.294",
246
246
  "defu": "^6.1.7",
247
247
  "esbuild": "^0.25.12",
248
248
  "fs-extra": "^11.4.0",
@@ -260,12 +260,12 @@
260
260
  "zod": "^4.4.3"
261
261
  },
262
262
  "devDependencies": {
263
- "@napi-rs/cli": "^3.8.2",
264
- "@storm-software/bun-tools": "^0.0.45",
265
- "@storm-software/esbuild": "^0.53.293",
266
- "@storm-software/package-constants": "^0.1.144",
267
- "@storm-software/pnpm-tools": "^0.7.146",
268
- "@storm-software/unbuild": "^0.57.293",
263
+ "@napi-rs/cli": "^3.8.3",
264
+ "@storm-software/bun-tools": "^0.0.46",
265
+ "@storm-software/esbuild": "^0.53.294",
266
+ "@storm-software/package-constants": "^0.1.145",
267
+ "@storm-software/pnpm-tools": "^0.7.147",
268
+ "@storm-software/unbuild": "^0.57.294",
269
269
  "@types/micromatch": "^4.0.10",
270
270
  "@types/node": "^25.9.5",
271
271
  "@types/semver": "^7.8.0",
@@ -294,5 +294,5 @@
294
294
  "publishConfig": { "access": "public" },
295
295
  "executors": "./executors.json",
296
296
  "generators": "./generators.json",
297
- "gitHead": "bb76fcb55c98655530cc01050ad3582941d36fbd"
297
+ "gitHead": "7302cd6416daad63ba041a3be4076bcde2637373"
298
298
  }
@@ -1,328 +0,0 @@
1
- import {
2
- getGitHubTools
3
- } from "./chunk-SHJC4UVH.mjs";
4
- import {
5
- addPackageJsonGitHead,
6
- stripPrivateWorkspaceDeps
7
- } from "./chunk-G4DPDEL3.mjs";
8
- import {
9
- getWorkspacePackageManager
10
- } from "./chunk-EXRSULNO.mjs";
11
- import {
12
- getConfig
13
- } from "./chunk-I4KVL3GR.mjs";
14
- import {
15
- joinPaths
16
- } from "./chunk-TBW5MCN6.mjs";
17
-
18
- // src/executors/npm-publish/executor.ts
19
- import { createJiti } from "jiti";
20
- import { execSync } from "node:child_process";
21
- import { readFile, writeFile } from "node:fs/promises";
22
- import { format } from "prettier";
23
- import prettierPlugin from "prettier-plugin-packagejson";
24
- var LARGE_BUFFER = 1024 * 1e6;
25
- async function replaceDepsAliases(jiti, packageRoot, workspaceRoot, packageManager) {
26
- if (packageManager === "bun") {
27
- const { replaceDepsAliases: replaceBunDepsAliases } = await jiti.import(jiti.esmResolve("@storm-software/bun-tools"));
28
- return replaceBunDepsAliases(packageRoot, workspaceRoot);
29
- }
30
- if (packageManager === "pnpm") {
31
- const { replaceDepsAliases: replacePnpmDepsAliases } = await jiti.import(jiti.esmResolve("@storm-software/pnpm-tools"));
32
- return replacePnpmDepsAliases(packageRoot, workspaceRoot);
33
- }
34
- }
35
- async function npmPublishExecutorFn(options, context) {
36
- const workspaceConfig = await getConfig(context.root);
37
- const packageManager = await getWorkspacePackageManager(
38
- context.root,
39
- workspaceConfig
40
- );
41
- const github = await getGitHubTools(workspaceConfig);
42
- const isDryRun = process.env.NX_DRY_RUN === "true" || options.dryRun || false;
43
- if (!context.projectName) {
44
- github.error("The `npm-publish` executor requires a `projectName`.");
45
- return { success: false };
46
- }
47
- const projectConfig = context.projectsConfigurations?.projects?.[context.projectName];
48
- if (!projectConfig) {
49
- github.error(
50
- `Could not find project configuration for \`${context.projectName}\``
51
- );
52
- return { success: false };
53
- }
54
- const packageRoot = joinPaths(
55
- context.root,
56
- options.packageRoot || joinPaths("dist", projectConfig.root)
57
- );
58
- const projectRoot = context.projectsConfigurations.projects[context.projectName]?.root ? joinPaths(
59
- context.root,
60
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
61
- context.projectsConfigurations.projects[context.projectName].root
62
- ) : packageRoot;
63
- const jiti = createJiti(context.root, {
64
- fsCache: joinPaths(context.root, "node_modules/.cache/storm", "jiti"),
65
- interopDefault: true
66
- });
67
- const { getNpmRegistry, getRegistry } = await jiti.import(jiti.esmResolve("@storm-software/npm-tools/helpers"));
68
- const packageJsonPath = joinPaths(packageRoot, "package.json");
69
- const packageJsonFile = await readFile(packageJsonPath, "utf8");
70
- if (!packageJsonFile) {
71
- github.error(`Could not find \`package.json\` at ${packageJsonPath}`);
72
- return { success: false };
73
- }
74
- const packageJson = JSON.parse(packageJsonFile);
75
- const projectPackageJsonPath = joinPaths(projectRoot, "package.json");
76
- const projectPackageJsonFile = await readFile(projectPackageJsonPath, "utf8");
77
- if (!projectPackageJsonFile) {
78
- github.error(
79
- `Could not find \`package.json\` at ${projectPackageJsonPath}`
80
- );
81
- return { success: false };
82
- }
83
- const projectPackageJson = JSON.parse(projectPackageJsonFile);
84
- if (packageJson.version !== projectPackageJson.version) {
85
- console.warn(
86
- `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.`
87
- );
88
- if (projectPackageJson.version) {
89
- packageJson.version = projectPackageJson.version;
90
- await writeFile(
91
- packageJsonPath,
92
- await format(JSON.stringify(packageJson), {
93
- parser: "json",
94
- proseWrap: "preserve",
95
- trailingComma: "none",
96
- tabWidth: 2,
97
- semi: true,
98
- singleQuote: false,
99
- quoteProps: "as-needed",
100
- insertPragma: false,
101
- bracketSameLine: true,
102
- printWidth: 80,
103
- bracketSpacing: true,
104
- arrowParens: "avoid",
105
- endOfLine: "lf",
106
- plugins: [prettierPlugin]
107
- })
108
- );
109
- }
110
- }
111
- const packageName = packageJson.name;
112
- console.info(
113
- `\u{1F680} Running Storm NPM Publish executor on the ${packageName} package`
114
- );
115
- const packageTxt = packageName === context.projectName ? `package "${packageName}"` : `package "${packageName}" from project "${context.projectName}"`;
116
- if (packageJson.private === true) {
117
- console.warn(
118
- `Skipped ${packageTxt}, because it has \`"private": true\` in ${packageJsonPath}`
119
- );
120
- return { success: true };
121
- }
122
- const removedPrivateWorkspaceDeps = await stripPrivateWorkspaceDeps(
123
- packageRoot,
124
- context.root
125
- );
126
- if (removedPrivateWorkspaceDeps.length > 0) {
127
- console.info(
128
- `Removed private workspace dependencies from ${packageJsonPath}: ${removedPrivateWorkspaceDeps.join(", ")}`
129
- );
130
- }
131
- await replaceDepsAliases(jiti, packageRoot, context.root, packageManager);
132
- await addPackageJsonGitHead(packageRoot);
133
- const npmPublishCommandSegments = [`npm publish --json`];
134
- const npmViewCommandSegments = [
135
- `npm view ${packageName} versions dist-tags --json`
136
- ];
137
- const registry = await Promise.resolve(
138
- options.registry ?? (await getRegistry() || getNpmRegistry())
139
- );
140
- if (registry) {
141
- npmPublishCommandSegments.push(`--registry="${registry}" `);
142
- npmViewCommandSegments.push(`--registry="${registry}" `);
143
- }
144
- if (options.otp) {
145
- npmPublishCommandSegments.push(`--otp="${options.otp}" `);
146
- }
147
- let token;
148
- if (!options.otp && registry) {
149
- token = await github.getIDToken(
150
- `npm:${registry.replace(/^https?:\/\//, "")}`
151
- );
152
- if (!token) {
153
- github.warning(
154
- `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.`
155
- );
156
- }
157
- }
158
- npmPublishCommandSegments.push("--provenance --access=public ");
159
- if (isDryRun) {
160
- npmPublishCommandSegments.push("--dry-run");
161
- }
162
- const tag = options.tag || execSync("npm config get tag", {
163
- cwd: packageRoot,
164
- env: {
165
- NPM_ID_TOKEN: token ? token : void 0,
166
- ...process.env,
167
- FORCE_COLOR: "true"
168
- },
169
- maxBuffer: LARGE_BUFFER,
170
- killSignal: "SIGTERM"
171
- }).toString().trim();
172
- if (tag) {
173
- npmPublishCommandSegments.push(`--tag="${tag}" `);
174
- }
175
- if (!isDryRun) {
176
- const currentVersion = options.version || packageJson.version;
177
- try {
178
- try {
179
- const result = execSync(npmViewCommandSegments.join(" "), {
180
- cwd: packageRoot,
181
- env: {
182
- NPM_ID_TOKEN: token,
183
- ...process.env,
184
- FORCE_COLOR: "true"
185
- },
186
- maxBuffer: LARGE_BUFFER,
187
- killSignal: "SIGTERM"
188
- });
189
- const resultJson = JSON.parse(result.toString());
190
- const distTags = resultJson["dist-tags"] || {};
191
- if (distTags[tag] === currentVersion) {
192
- console.warn(
193
- `Skipped ${packageTxt} because v${currentVersion} already exists in ${registry} with tag "${tag}"`
194
- );
195
- return { success: true };
196
- }
197
- } catch (err) {
198
- console.debug(
199
- `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.
200
-
201
- Error: ${JSON.stringify(
202
- err,
203
- null,
204
- 2
205
- )}`
206
- );
207
- }
208
- try {
209
- if (!isDryRun) {
210
- const command = `npm dist-tag add ${packageName}@${currentVersion} ${tag} --registry="${registry}" `;
211
- console.debug(
212
- `Adding the dist-tag ${tag} - preparing to run the following: ${command}`
213
- );
214
- const result = execSync(command, {
215
- cwd: packageRoot,
216
- env: {
217
- NPM_ID_TOKEN: token,
218
- ...process.env,
219
- FORCE_COLOR: "true"
220
- },
221
- maxBuffer: LARGE_BUFFER,
222
- killSignal: "SIGTERM"
223
- });
224
- console.info(
225
- `Added the dist-tag ${tag} to v${currentVersion} for registry "${registry}".
226
-
227
- Execution response: ${result.toString()}`
228
- );
229
- } else {
230
- console.info(
231
- `Would have added the dist-tag ${tag} to v${currentVersion} for registry "${registry}", but [dry-run] was set.
232
- `
233
- );
234
- }
235
- return { success: true };
236
- } catch (err) {
237
- try {
238
- const stdoutData = JSON.parse(err.stdout?.toString() || "{}");
239
- 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"))) {
240
- const errorMessage = `An unexpected error occured while running the npm dist-tag add command:
241
-
242
- ${stdoutData?.error?.summary ? `Summary: ${stdoutData?.error?.summary}${stdoutData?.error?.code ? ` (${stdoutData?.error?.code})` : ""}
243
- ` : ""}${stdoutData?.error?.detail ? `Detail: ${stdoutData?.error?.detail}
244
- ` : ""}`;
245
- github.error(errorMessage);
246
- return { success: false };
247
- }
248
- } catch (err2) {
249
- const stdoutData = JSON.parse(err2.stdout?.toString() || "{}");
250
- const errorMessage = `An unexpected error occured while processing the npm dist-tag add output:
251
-
252
- ${stdoutData?.error?.summary ? `Summary: ${stdoutData?.error?.summary}${stdoutData?.error?.code ? ` (${stdoutData?.error?.code})` : ""}
253
- ` : ""}${stdoutData?.error?.detail ? `Detail: ${stdoutData?.error?.detail}
254
- ` : ""}`;
255
- github.error(errorMessage);
256
- return { success: false };
257
- }
258
- }
259
- } catch (err) {
260
- const stdoutData = JSON.parse(err.stdout?.toString() || "{}");
261
- 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"))) {
262
- const errorMessage = `An unexpected error occured while checking for existing dist-tags:
263
-
264
- ${stdoutData?.error?.summary ? `Summary: ${stdoutData?.error?.summary}${stdoutData?.error?.code ? ` (${stdoutData?.error?.code})` : ""}
265
- ` : ""}${stdoutData?.error?.detail ? `Detail: ${stdoutData?.error?.detail}
266
- ` : ""}`;
267
- github.error(errorMessage);
268
- return { success: false };
269
- }
270
- }
271
- }
272
- try {
273
- const cwd = packageRoot;
274
- const command = npmPublishCommandSegments.join(" ");
275
- console.info(
276
- `Running publish command "${command}" in current working directory: "${cwd}" `
277
- );
278
- const result = execSync(command, {
279
- cwd,
280
- env: {
281
- NPM_ID_TOKEN: token,
282
- ...process.env,
283
- FORCE_COLOR: "true"
284
- },
285
- maxBuffer: LARGE_BUFFER,
286
- killSignal: "SIGTERM"
287
- });
288
- if (isDryRun) {
289
- console.info(
290
- `Would publish tag "${tag}" to ${registry}, but [dry-run] was set. ${result ? `
291
-
292
- Execution response: ${result.toString()}` : ""}`
293
- );
294
- } else {
295
- console.info(
296
- `Published tag "${tag}" to ${registry}. ${result ? `
297
-
298
- Execution response: ${result.toString()}` : ""}`
299
- );
300
- }
301
- return { success: true };
302
- } catch (err) {
303
- try {
304
- const stdoutData = JSON.parse(err.stdout?.toString() || "{}");
305
- const errorMessage = `An error occurred while publishing the npm package:
306
-
307
- ${stdoutData?.error?.summary ? `Summary: ${stdoutData?.error?.summary}${stdoutData?.error?.code ? ` (${stdoutData?.error?.code})` : ""}
308
- ` : ""}${stdoutData?.error?.detail ? `Detail: ${stdoutData?.error?.detail}
309
- ` : ""}`;
310
- github.error(errorMessage);
311
- return { success: false };
312
- } catch (err2) {
313
- const errorMessage = `Something unexpected went wrong when processing the npm publish output.
314
-
315
- Error: ${JSON.stringify(
316
- Buffer.isBuffer(err2) ? err2.toString() : err2,
317
- null,
318
- 2
319
- )}`;
320
- github.error(errorMessage);
321
- return { success: false };
322
- }
323
- }
324
- }
325
-
326
- export {
327
- npmPublishExecutorFn
328
- };
@@ -1,328 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
-
3
- var _chunkP5OQBBN3js = require('./chunk-P5OQBBN3.js');
4
-
5
-
6
-
7
- var _chunkVXOPWQTJjs = require('./chunk-VXOPWQTJ.js');
8
-
9
-
10
- var _chunk3MXZ2RJFjs = require('./chunk-3MXZ2RJF.js');
11
-
12
-
13
- var _chunkIMY2BU43js = require('./chunk-IMY2BU43.js');
14
-
15
-
16
- var _chunkCQDBLKPFjs = require('./chunk-CQDBLKPF.js');
17
-
18
- // src/executors/npm-publish/executor.ts
19
- var _jiti = require('jiti');
20
- var _child_process = require('child_process');
21
- var _promises = require('fs/promises');
22
- var _prettier = require('prettier');
23
- var _prettierpluginpackagejson = require('prettier-plugin-packagejson'); var _prettierpluginpackagejson2 = _interopRequireDefault(_prettierpluginpackagejson);
24
- var LARGE_BUFFER = 1024 * 1e6;
25
- async function replaceDepsAliases(jiti, packageRoot, workspaceRoot, packageManager) {
26
- if (packageManager === "bun") {
27
- const { replaceDepsAliases: replaceBunDepsAliases } = await jiti.import(jiti.esmResolve("@storm-software/bun-tools"));
28
- return replaceBunDepsAliases(packageRoot, workspaceRoot);
29
- }
30
- if (packageManager === "pnpm") {
31
- const { replaceDepsAliases: replacePnpmDepsAliases } = await jiti.import(jiti.esmResolve("@storm-software/pnpm-tools"));
32
- return replacePnpmDepsAliases(packageRoot, workspaceRoot);
33
- }
34
- }
35
- async function npmPublishExecutorFn(options, context) {
36
- const workspaceConfig = await _chunkIMY2BU43js.getConfig.call(void 0, context.root);
37
- const packageManager = await _chunk3MXZ2RJFjs.getWorkspacePackageManager.call(void 0,
38
- context.root,
39
- workspaceConfig
40
- );
41
- const github = await _chunkP5OQBBN3js.getGitHubTools.call(void 0, workspaceConfig);
42
- const isDryRun = process.env.NX_DRY_RUN === "true" || options.dryRun || false;
43
- if (!context.projectName) {
44
- github.error("The `npm-publish` executor requires a `projectName`.");
45
- return { success: false };
46
- }
47
- const projectConfig = _optionalChain([context, 'access', _ => _.projectsConfigurations, 'optionalAccess', _2 => _2.projects, 'optionalAccess', _3 => _3[context.projectName]]);
48
- if (!projectConfig) {
49
- github.error(
50
- `Could not find project configuration for \`${context.projectName}\``
51
- );
52
- return { success: false };
53
- }
54
- const packageRoot = _chunkCQDBLKPFjs.joinPaths.call(void 0,
55
- context.root,
56
- options.packageRoot || _chunkCQDBLKPFjs.joinPaths.call(void 0, "dist", projectConfig.root)
57
- );
58
- const projectRoot = _optionalChain([context, 'access', _4 => _4.projectsConfigurations, 'access', _5 => _5.projects, 'access', _6 => _6[context.projectName], 'optionalAccess', _7 => _7.root]) ? _chunkCQDBLKPFjs.joinPaths.call(void 0,
59
- context.root,
60
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
61
- context.projectsConfigurations.projects[context.projectName].root
62
- ) : packageRoot;
63
- const jiti = _jiti.createJiti.call(void 0, context.root, {
64
- fsCache: _chunkCQDBLKPFjs.joinPaths.call(void 0, context.root, "node_modules/.cache/storm", "jiti"),
65
- interopDefault: true
66
- });
67
- const { getNpmRegistry, getRegistry } = await jiti.import(jiti.esmResolve("@storm-software/npm-tools/helpers"));
68
- const packageJsonPath = _chunkCQDBLKPFjs.joinPaths.call(void 0, packageRoot, "package.json");
69
- const packageJsonFile = await _promises.readFile.call(void 0, packageJsonPath, "utf8");
70
- if (!packageJsonFile) {
71
- github.error(`Could not find \`package.json\` at ${packageJsonPath}`);
72
- return { success: false };
73
- }
74
- const packageJson = JSON.parse(packageJsonFile);
75
- const projectPackageJsonPath = _chunkCQDBLKPFjs.joinPaths.call(void 0, projectRoot, "package.json");
76
- const projectPackageJsonFile = await _promises.readFile.call(void 0, projectPackageJsonPath, "utf8");
77
- if (!projectPackageJsonFile) {
78
- github.error(
79
- `Could not find \`package.json\` at ${projectPackageJsonPath}`
80
- );
81
- return { success: false };
82
- }
83
- const projectPackageJson = JSON.parse(projectPackageJsonFile);
84
- if (packageJson.version !== projectPackageJson.version) {
85
- console.warn(
86
- `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.`
87
- );
88
- if (projectPackageJson.version) {
89
- packageJson.version = projectPackageJson.version;
90
- await _promises.writeFile.call(void 0,
91
- packageJsonPath,
92
- await _prettier.format.call(void 0, JSON.stringify(packageJson), {
93
- parser: "json",
94
- proseWrap: "preserve",
95
- trailingComma: "none",
96
- tabWidth: 2,
97
- semi: true,
98
- singleQuote: false,
99
- quoteProps: "as-needed",
100
- insertPragma: false,
101
- bracketSameLine: true,
102
- printWidth: 80,
103
- bracketSpacing: true,
104
- arrowParens: "avoid",
105
- endOfLine: "lf",
106
- plugins: [_prettierpluginpackagejson2.default]
107
- })
108
- );
109
- }
110
- }
111
- const packageName = packageJson.name;
112
- console.info(
113
- `\u{1F680} Running Storm NPM Publish executor on the ${packageName} package`
114
- );
115
- const packageTxt = packageName === context.projectName ? `package "${packageName}"` : `package "${packageName}" from project "${context.projectName}"`;
116
- if (packageJson.private === true) {
117
- console.warn(
118
- `Skipped ${packageTxt}, because it has \`"private": true\` in ${packageJsonPath}`
119
- );
120
- return { success: true };
121
- }
122
- const removedPrivateWorkspaceDeps = await _chunkVXOPWQTJjs.stripPrivateWorkspaceDeps.call(void 0,
123
- packageRoot,
124
- context.root
125
- );
126
- if (removedPrivateWorkspaceDeps.length > 0) {
127
- console.info(
128
- `Removed private workspace dependencies from ${packageJsonPath}: ${removedPrivateWorkspaceDeps.join(", ")}`
129
- );
130
- }
131
- await replaceDepsAliases(jiti, packageRoot, context.root, packageManager);
132
- await _chunkVXOPWQTJjs.addPackageJsonGitHead.call(void 0, packageRoot);
133
- const npmPublishCommandSegments = [`npm publish --json`];
134
- const npmViewCommandSegments = [
135
- `npm view ${packageName} versions dist-tags --json`
136
- ];
137
- const registry = await Promise.resolve(
138
- await _asyncNullishCoalesce(options.registry, async () => ( (await getRegistry() || getNpmRegistry())))
139
- );
140
- if (registry) {
141
- npmPublishCommandSegments.push(`--registry="${registry}" `);
142
- npmViewCommandSegments.push(`--registry="${registry}" `);
143
- }
144
- if (options.otp) {
145
- npmPublishCommandSegments.push(`--otp="${options.otp}" `);
146
- }
147
- let token;
148
- if (!options.otp && registry) {
149
- token = await github.getIDToken(
150
- `npm:${registry.replace(/^https?:\/\//, "")}`
151
- );
152
- if (!token) {
153
- github.warning(
154
- `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.`
155
- );
156
- }
157
- }
158
- npmPublishCommandSegments.push("--provenance --access=public ");
159
- if (isDryRun) {
160
- npmPublishCommandSegments.push("--dry-run");
161
- }
162
- const tag = options.tag || _child_process.execSync.call(void 0, "npm config get tag", {
163
- cwd: packageRoot,
164
- env: {
165
- NPM_ID_TOKEN: token ? token : void 0,
166
- ...process.env,
167
- FORCE_COLOR: "true"
168
- },
169
- maxBuffer: LARGE_BUFFER,
170
- killSignal: "SIGTERM"
171
- }).toString().trim();
172
- if (tag) {
173
- npmPublishCommandSegments.push(`--tag="${tag}" `);
174
- }
175
- if (!isDryRun) {
176
- const currentVersion = options.version || packageJson.version;
177
- try {
178
- try {
179
- const result = _child_process.execSync.call(void 0, npmViewCommandSegments.join(" "), {
180
- cwd: packageRoot,
181
- env: {
182
- NPM_ID_TOKEN: token,
183
- ...process.env,
184
- FORCE_COLOR: "true"
185
- },
186
- maxBuffer: LARGE_BUFFER,
187
- killSignal: "SIGTERM"
188
- });
189
- const resultJson = JSON.parse(result.toString());
190
- const distTags = resultJson["dist-tags"] || {};
191
- if (distTags[tag] === currentVersion) {
192
- console.warn(
193
- `Skipped ${packageTxt} because v${currentVersion} already exists in ${registry} with tag "${tag}"`
194
- );
195
- return { success: true };
196
- }
197
- } catch (err) {
198
- console.debug(
199
- `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.
200
-
201
- Error: ${JSON.stringify(
202
- err,
203
- null,
204
- 2
205
- )}`
206
- );
207
- }
208
- try {
209
- if (!isDryRun) {
210
- const command = `npm dist-tag add ${packageName}@${currentVersion} ${tag} --registry="${registry}" `;
211
- console.debug(
212
- `Adding the dist-tag ${tag} - preparing to run the following: ${command}`
213
- );
214
- const result = _child_process.execSync.call(void 0, command, {
215
- cwd: packageRoot,
216
- env: {
217
- NPM_ID_TOKEN: token,
218
- ...process.env,
219
- FORCE_COLOR: "true"
220
- },
221
- maxBuffer: LARGE_BUFFER,
222
- killSignal: "SIGTERM"
223
- });
224
- console.info(
225
- `Added the dist-tag ${tag} to v${currentVersion} for registry "${registry}".
226
-
227
- Execution response: ${result.toString()}`
228
- );
229
- } else {
230
- console.info(
231
- `Would have added the dist-tag ${tag} to v${currentVersion} for registry "${registry}", but [dry-run] was set.
232
- `
233
- );
234
- }
235
- return { success: true };
236
- } catch (err) {
237
- try {
238
- const stdoutData = JSON.parse(_optionalChain([err, 'access', _8 => _8.stdout, 'optionalAccess', _9 => _9.toString, 'call', _10 => _10()]) || "{}");
239
- if (_optionalChain([stdoutData, 'optionalAccess', _11 => _11.error]) && !(_optionalChain([stdoutData, 'access', _12 => _12.error, 'optionalAccess', _13 => _13.code, 'optionalAccess', _14 => _14.includes, 'call', _15 => _15("E404")]) && _optionalChain([stdoutData, 'access', _16 => _16.error, 'optionalAccess', _17 => _17.summary, 'optionalAccess', _18 => _18.includes, 'call', _19 => _19("no such package available")])) && !(_optionalChain([err, 'access', _20 => _20.stderr, 'optionalAccess', _21 => _21.toString, 'call', _22 => _22(), 'access', _23 => _23.includes, 'call', _24 => _24("E404")]) && _optionalChain([err, 'access', _25 => _25.stderr, 'optionalAccess', _26 => _26.toString, 'call', _27 => _27(), 'access', _28 => _28.includes, 'call', _29 => _29("no such package available")]))) {
240
- const errorMessage = `An unexpected error occured while running the npm dist-tag add command:
241
-
242
- ${_optionalChain([stdoutData, 'optionalAccess', _30 => _30.error, 'optionalAccess', _31 => _31.summary]) ? `Summary: ${_optionalChain([stdoutData, 'optionalAccess', _32 => _32.error, 'optionalAccess', _33 => _33.summary])}${_optionalChain([stdoutData, 'optionalAccess', _34 => _34.error, 'optionalAccess', _35 => _35.code]) ? ` (${_optionalChain([stdoutData, 'optionalAccess', _36 => _36.error, 'optionalAccess', _37 => _37.code])})` : ""}
243
- ` : ""}${_optionalChain([stdoutData, 'optionalAccess', _38 => _38.error, 'optionalAccess', _39 => _39.detail]) ? `Detail: ${_optionalChain([stdoutData, 'optionalAccess', _40 => _40.error, 'optionalAccess', _41 => _41.detail])}
244
- ` : ""}`;
245
- github.error(errorMessage);
246
- return { success: false };
247
- }
248
- } catch (err2) {
249
- const stdoutData = JSON.parse(_optionalChain([err2, 'access', _42 => _42.stdout, 'optionalAccess', _43 => _43.toString, 'call', _44 => _44()]) || "{}");
250
- const errorMessage = `An unexpected error occured while processing the npm dist-tag add output:
251
-
252
- ${_optionalChain([stdoutData, 'optionalAccess', _45 => _45.error, 'optionalAccess', _46 => _46.summary]) ? `Summary: ${_optionalChain([stdoutData, 'optionalAccess', _47 => _47.error, 'optionalAccess', _48 => _48.summary])}${_optionalChain([stdoutData, 'optionalAccess', _49 => _49.error, 'optionalAccess', _50 => _50.code]) ? ` (${_optionalChain([stdoutData, 'optionalAccess', _51 => _51.error, 'optionalAccess', _52 => _52.code])})` : ""}
253
- ` : ""}${_optionalChain([stdoutData, 'optionalAccess', _53 => _53.error, 'optionalAccess', _54 => _54.detail]) ? `Detail: ${_optionalChain([stdoutData, 'optionalAccess', _55 => _55.error, 'optionalAccess', _56 => _56.detail])}
254
- ` : ""}`;
255
- github.error(errorMessage);
256
- return { success: false };
257
- }
258
- }
259
- } catch (err) {
260
- const stdoutData = JSON.parse(_optionalChain([err, 'access', _57 => _57.stdout, 'optionalAccess', _58 => _58.toString, 'call', _59 => _59()]) || "{}");
261
- if (!(_optionalChain([stdoutData, 'access', _60 => _60.error, 'optionalAccess', _61 => _61.code, 'optionalAccess', _62 => _62.includes, 'call', _63 => _63("E404")]) && _optionalChain([stdoutData, 'access', _64 => _64.error, 'optionalAccess', _65 => _65.summary, 'optionalAccess', _66 => _66.toLowerCase, 'call', _67 => _67(), 'access', _68 => _68.includes, 'call', _69 => _69("not found")])) && !(_optionalChain([err, 'access', _70 => _70.stderr, 'optionalAccess', _71 => _71.toString, 'call', _72 => _72(), 'access', _73 => _73.includes, 'call', _74 => _74("E404")]) && _optionalChain([err, 'access', _75 => _75.stderr, 'optionalAccess', _76 => _76.toString, 'call', _77 => _77(), 'access', _78 => _78.toLowerCase, 'call', _79 => _79(), 'access', _80 => _80.includes, 'call', _81 => _81("not found")]))) {
262
- const errorMessage = `An unexpected error occured while checking for existing dist-tags:
263
-
264
- ${_optionalChain([stdoutData, 'optionalAccess', _82 => _82.error, 'optionalAccess', _83 => _83.summary]) ? `Summary: ${_optionalChain([stdoutData, 'optionalAccess', _84 => _84.error, 'optionalAccess', _85 => _85.summary])}${_optionalChain([stdoutData, 'optionalAccess', _86 => _86.error, 'optionalAccess', _87 => _87.code]) ? ` (${_optionalChain([stdoutData, 'optionalAccess', _88 => _88.error, 'optionalAccess', _89 => _89.code])})` : ""}
265
- ` : ""}${_optionalChain([stdoutData, 'optionalAccess', _90 => _90.error, 'optionalAccess', _91 => _91.detail]) ? `Detail: ${_optionalChain([stdoutData, 'optionalAccess', _92 => _92.error, 'optionalAccess', _93 => _93.detail])}
266
- ` : ""}`;
267
- github.error(errorMessage);
268
- return { success: false };
269
- }
270
- }
271
- }
272
- try {
273
- const cwd = packageRoot;
274
- const command = npmPublishCommandSegments.join(" ");
275
- console.info(
276
- `Running publish command "${command}" in current working directory: "${cwd}" `
277
- );
278
- const result = _child_process.execSync.call(void 0, command, {
279
- cwd,
280
- env: {
281
- NPM_ID_TOKEN: token,
282
- ...process.env,
283
- FORCE_COLOR: "true"
284
- },
285
- maxBuffer: LARGE_BUFFER,
286
- killSignal: "SIGTERM"
287
- });
288
- if (isDryRun) {
289
- console.info(
290
- `Would publish tag "${tag}" to ${registry}, but [dry-run] was set. ${result ? `
291
-
292
- Execution response: ${result.toString()}` : ""}`
293
- );
294
- } else {
295
- console.info(
296
- `Published tag "${tag}" to ${registry}. ${result ? `
297
-
298
- Execution response: ${result.toString()}` : ""}`
299
- );
300
- }
301
- return { success: true };
302
- } catch (err) {
303
- try {
304
- const stdoutData = JSON.parse(_optionalChain([err, 'access', _94 => _94.stdout, 'optionalAccess', _95 => _95.toString, 'call', _96 => _96()]) || "{}");
305
- const errorMessage = `An error occurred while publishing the npm package:
306
-
307
- ${_optionalChain([stdoutData, 'optionalAccess', _97 => _97.error, 'optionalAccess', _98 => _98.summary]) ? `Summary: ${_optionalChain([stdoutData, 'optionalAccess', _99 => _99.error, 'optionalAccess', _100 => _100.summary])}${_optionalChain([stdoutData, 'optionalAccess', _101 => _101.error, 'optionalAccess', _102 => _102.code]) ? ` (${_optionalChain([stdoutData, 'optionalAccess', _103 => _103.error, 'optionalAccess', _104 => _104.code])})` : ""}
308
- ` : ""}${_optionalChain([stdoutData, 'optionalAccess', _105 => _105.error, 'optionalAccess', _106 => _106.detail]) ? `Detail: ${_optionalChain([stdoutData, 'optionalAccess', _107 => _107.error, 'optionalAccess', _108 => _108.detail])}
309
- ` : ""}`;
310
- github.error(errorMessage);
311
- return { success: false };
312
- } catch (err2) {
313
- const errorMessage = `Something unexpected went wrong when processing the npm publish output.
314
-
315
- Error: ${JSON.stringify(
316
- Buffer.isBuffer(err2) ? err2.toString() : err2,
317
- null,
318
- 2
319
- )}`;
320
- github.error(errorMessage);
321
- return { success: false };
322
- }
323
- }
324
- }
325
-
326
-
327
-
328
- exports.npmPublishExecutorFn = npmPublishExecutorFn;