@storm-software/cloudflare-tools 0.70.49 → 0.71.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.
Files changed (51) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +9 -2
  3. package/dist/chunk-7ESZB4KW.mjs +220 -0
  4. package/dist/{chunk-6KHWP2MO.js → chunk-BPUFICBM.js} +2 -2
  5. package/dist/{chunk-3JEOBMM5.mjs → chunk-C6B32MBV.mjs} +12 -8
  6. package/dist/{chunk-D4JUMEIC.js → chunk-DRYNN63F.js} +7 -6
  7. package/dist/{chunk-2B7ISOXH.mjs → chunk-J2DOKDIF.mjs} +8 -7
  8. package/dist/{chunk-UEJFDB6Y.mjs → chunk-QN6OKPMU.mjs} +1 -1
  9. package/dist/chunk-VHMJXOF4.js +220 -0
  10. package/dist/{chunk-YAUK66IM.js → chunk-W5IPHIXB.js} +11 -7
  11. package/dist/{chunk-BIFOD6C3.mjs → chunk-XDQBFBX4.mjs} +1 -1
  12. package/dist/{chunk-Y5VPR2KX.mjs → chunk-ZFJIFXOW.mjs} +4 -4
  13. package/dist/executors.d.mts +1 -1
  14. package/dist/executors.d.ts +1 -1
  15. package/dist/executors.js +2 -2
  16. package/dist/executors.mjs +4 -4
  17. package/dist/generators.js +3 -3
  18. package/dist/generators.mjs +3 -3
  19. package/dist/index.d.mts +1 -1
  20. package/dist/index.d.ts +1 -1
  21. package/dist/index.js +5 -5
  22. package/dist/index.mjs +6 -6
  23. package/dist/schema.d-elsO8UQp.d.mts +88 -0
  24. package/dist/schema.d-elsO8UQp.d.ts +88 -0
  25. package/dist/src/executors/cloudflare-publish/executor.js +1 -1
  26. package/dist/src/executors/cloudflare-publish/executor.mjs +3 -3
  27. package/dist/src/executors/r2-upload-publish/executor.d.mts +1 -1
  28. package/dist/src/executors/r2-upload-publish/executor.d.ts +1 -1
  29. package/dist/src/executors/r2-upload-publish/executor.js +2 -2
  30. package/dist/src/executors/r2-upload-publish/executor.mjs +2 -2
  31. package/dist/src/executors/r2-upload-publish/schema.d.ts +86 -7
  32. package/dist/src/executors/r2-upload-publish/schema.json +63 -22
  33. package/dist/src/executors/serve/executor.js +2 -2
  34. package/dist/src/executors/serve/executor.mjs +2 -2
  35. package/dist/src/generators/init/generator.js +2 -2
  36. package/dist/src/generators/init/generator.mjs +2 -2
  37. package/dist/src/generators/worker/generator.js +3 -3
  38. package/dist/src/generators/worker/generator.mjs +3 -3
  39. package/dist/src/utils/index.mjs +1 -1
  40. package/dist/src/utils/r2-bucket-helpers.mjs +1 -1
  41. package/dist/tsup.config.mjs +1 -1
  42. package/docs/api/executors/r2-upload-publish/schema.md +93 -0
  43. package/package.json +13 -12
  44. package/dist/chunk-IH7ZJRS7.js +0 -262
  45. package/dist/chunk-JEMQ2Y24.mjs +0 -265
  46. package/dist/chunk-KSZZYFCQ.js +0 -209
  47. package/dist/chunk-OTDPGPH4.js +0 -209
  48. package/dist/chunk-S3HIZ32I.mjs +0 -209
  49. package/dist/chunk-WBUCIAVK.mjs +0 -209
  50. package/dist/schema.d-oSirXiCO.d.mts +0 -11
  51. package/dist/schema.d-oSirXiCO.d.ts +0 -11
package/CHANGELOG.md CHANGED
@@ -2,6 +2,27 @@
2
2
 
3
3
  # Changelog for Storm Ops - Cloudflare Tools
4
4
 
5
+ ## [0.70.50](https://github.com/storm-software/storm-ops/releases/tag/cloudflare-tools%400.70.50) (11/27/2025)
6
+
7
+ ### Miscellaneous
8
+
9
+ - **monorepo:** Regenerate README markdown files and `Cargo.lock`
10
+ ([5758ea3f0](https://github.com/storm-software/storm-ops/commit/5758ea3f0))
11
+
12
+ ### Updated Dependencies
13
+
14
+ - Updated **workspace-tools** to **v1.293.20**
15
+ - Updated **config-tools** to **v1.188.50**
16
+ - Updated **config** to **v1.134.50**
17
+
18
+ ## [0.70.49](https://github.com/storm-software/storm-ops/releases/tag/cloudflare-tools%400.70.49) (11/25/2025)
19
+
20
+ ### Updated Dependencies
21
+
22
+ - Updated **workspace-tools** to **v1.293.19**
23
+ - Updated **config-tools** to **v1.188.49**
24
+ - Updated **config** to **v1.134.49**
25
+
5
26
  ## [0.70.48](https://github.com/storm-software/storm-ops/releases/tag/cloudflare-tools%400.70.48) (11/20/2025)
6
27
 
7
28
  ### Miscellaneous
package/README.md CHANGED
@@ -3,7 +3,13 @@
3
3
  <!-- markdownlint-disable -->
4
4
 
5
5
 
6
- <div align="center"><img src="https://public.storm-cdn.com/storm-banner.gif" width="100%" alt="Storm Software" /></div>
6
+ <div align="center">
7
+ <picture>
8
+ <source media="(prefers-color-scheme: dark)" srcset="https://public.storm-cdn.com/storm-software/banner-1280x640-dark-optimized.gif">
9
+ <source media="(prefers-color-scheme: light)" srcset="https://public.storm-cdn.com/storm-software/banner-1280x640-light-optimized.gif">
10
+ <img src="https://public.storm-cdn.com/storm-software/banner-1280x640-dark-optimized.gif" width="100%" alt="Storm Software" />
11
+ </picture>
12
+ </div>
7
13
  <br />
8
14
 
9
15
  <div align="center">
@@ -21,7 +27,7 @@ This package is part of the <b>⚡Storm-Ops</b> monorepo. The Storm-Ops packages
21
27
 
22
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 />
23
29
 
24
- [![Version](https://img.shields.io/badge/version-0.70.46-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-0.70.49-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)
25
31
 
26
32
  <!-- prettier-ignore-start -->
27
33
  <!-- markdownlint-disable -->
@@ -40,6 +46,7 @@ This package is part of the <b>⚡Storm-Ops</b> monorepo. The Storm-Ops packages
40
46
 
41
47
  <!-- START doctoc -->
42
48
  <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
49
+
43
50
  ## Table of Contents
44
51
 
45
52
  - [Storm Cloudflare Tools](#storm-cloudflare-tools)
@@ -0,0 +1,220 @@
1
+ import {
2
+ getInternalDependencies,
3
+ r2UploadFile
4
+ } from "./chunk-5N2NVDKX.mjs";
5
+ import {
6
+ createCliOptions,
7
+ getPackageInfo
8
+ } from "./chunk-PH3DHY4Q.mjs";
9
+ import {
10
+ findWorkspaceRoot,
11
+ getConfig
12
+ } from "./chunk-PTTJW7MW.mjs";
13
+ import {
14
+ writeDebug,
15
+ writeSuccess,
16
+ writeTrace,
17
+ writeWarning
18
+ } from "./chunk-6MATO2MJ.mjs";
19
+
20
+ // src/executors/r2-upload-publish/executor.ts
21
+ import { S3 } from "@aws-sdk/client-s3";
22
+ import {
23
+ createProjectGraphAsync,
24
+ joinPathFragments,
25
+ readCachedProjectGraph
26
+ } from "@nx/devkit";
27
+ import { glob } from "glob";
28
+ import mime from "mime-types";
29
+ import { execSync } from "node:child_process";
30
+ import { readFile } from "node:fs/promises";
31
+ async function runExecutor(options, context) {
32
+ const isDryRun = process.env.NX_DRY_RUN === "true" || options.dryRun || false;
33
+ if (!context.projectName) {
34
+ throw new Error("The executor requires a projectName.");
35
+ }
36
+ console.info(
37
+ `\u{1F680} Running Storm Cloudflare Publish executor on the ${context.projectName} worker`
38
+ );
39
+ if (!context.projectName || !context.projectsConfigurations?.projects || !context.projectsConfigurations.projects[context.projectName] || !context.projectsConfigurations.projects[context.projectName]?.root) {
40
+ throw new Error("The executor requires projectsConfigurations.");
41
+ }
42
+ try {
43
+ const workspaceRoot = findWorkspaceRoot();
44
+ const config = await getConfig(workspaceRoot);
45
+ const sourceRoot = context.projectsConfigurations.projects[context.projectName]?.sourceRoot ?? workspaceRoot;
46
+ const projectName = context.projectsConfigurations.projects[context.projectName]?.name ?? context.projectName;
47
+ const projectDetails = getPackageInfo(
48
+ context.projectsConfigurations.projects[context.projectName]
49
+ );
50
+ const bucketId = options.bucketId;
51
+ const bucketPath = options.bucketPath || "/";
52
+ if (!bucketId) {
53
+ throw new Error("The executor requires a bucketId.");
54
+ }
55
+ const args = createCliOptions({ ...options });
56
+ if (isDryRun) {
57
+ args.push("--dry-run");
58
+ }
59
+ const cloudflareAccountId = process.env.CLOUDFLARE_ACCOUNT_ID || process.env.STORM_BOT_CLOUDFLARE_ACCOUNT;
60
+ if (!options?.registry && !cloudflareAccountId) {
61
+ throw new Error(
62
+ "The registry option and `CLOUDFLARE_ACCOUNT_ID` environment variable are not set. Please set one of these values to upload to the Cloudflare R2 bucket."
63
+ );
64
+ }
65
+ if (!process.env.ACCESS_KEY_ID && !process.env.CLOUDFLARE_ACCESS_KEY_ID && !process.env.AWS_ACCESS_KEY_ID || !process.env.SECRET_ACCESS_KEY && !process.env.CLOUDFLARE_SECRET_ACCESS_KEY && !process.env.AWS_SECRET_ACCESS_KEY) {
66
+ throw new Error(
67
+ "The `ACCESS_KEY_ID` and `SECRET_ACCESS_KEY` environment variables are not set. Please set these environment variables to upload to the Cloudflare R2 bucket."
68
+ );
69
+ }
70
+ const registry = options?.registry ? options.registry : `https://${cloudflareAccountId}.r2.cloudflarestorage.com`;
71
+ let projectGraph;
72
+ try {
73
+ projectGraph = readCachedProjectGraph();
74
+ } catch {
75
+ await createProjectGraphAsync();
76
+ projectGraph = readCachedProjectGraph();
77
+ }
78
+ if (!projectGraph) {
79
+ throw new Error(
80
+ "The executor failed because the project graph is not available. Please run the build command again."
81
+ );
82
+ }
83
+ writeDebug(
84
+ `Publishing ${context.projectName} to the ${bucketId} R2 Bucket (at ${registry})`
85
+ );
86
+ const client = new S3({
87
+ region: "auto",
88
+ endpoint: registry,
89
+ credentials: {
90
+ accessKeyId: process.env.ACCESS_KEY_ID || process.env.CLOUDFLARE_ACCESS_KEY_ID || process.env.AWS_ACCESS_KEY_ID,
91
+ secretAccessKey: process.env.SECRET_ACCESS_KEY || process.env.CLOUDFLARE_SECRET_ACCESS_KEY || process.env.AWS_SECRET_ACCESS_KEY
92
+ }
93
+ });
94
+ const version = projectDetails?.content?.version;
95
+ if (version) {
96
+ writeDebug(`Starting upload version ${version}`);
97
+ }
98
+ const files = await glob(
99
+ joinPathFragments(options.path || sourceRoot, "**/*"),
100
+ {
101
+ ignore: "**/{*.stories.tsx,*.stories.ts,*.spec.tsx,*.spec.ts}"
102
+ }
103
+ );
104
+ const internalDependencies = await getInternalDependencies(
105
+ context.projectName,
106
+ projectGraph
107
+ );
108
+ const dependencies = internalDependencies.filter(
109
+ (projectNode) => !projectNode.data.tags || projectNode.data.tags.every((tag) => tag.toLowerCase() !== "component")
110
+ ).reduce((ret, dep) => {
111
+ if (!ret[dep.name]) {
112
+ ret[dep.name] = "latest";
113
+ }
114
+ return ret;
115
+ }, projectDetails?.content.dependencies ?? {});
116
+ const release = options.tag ?? execSync("npm config get tag").toString().trim();
117
+ if (options.clean === true) {
118
+ writeDebug(`Clearing out existing items in ${bucketPath}`);
119
+ if (!isDryRun) {
120
+ const response = await client.listObjects({
121
+ Bucket: bucketId,
122
+ Prefix: bucketPath
123
+ });
124
+ if (response?.Contents && response.Contents.length > 0) {
125
+ writeTrace(
126
+ `Deleting the following existing items from the R2 bucket path ${bucketPath}: ${response.Contents.map((item) => item.Key).join(", ")}`
127
+ );
128
+ await Promise.all(
129
+ response.Contents.map(
130
+ (item) => client.deleteObjects({
131
+ Bucket: bucketId,
132
+ Delete: {
133
+ Objects: [
134
+ {
135
+ Key: item.Key
136
+ }
137
+ ],
138
+ Quiet: false
139
+ }
140
+ })
141
+ )
142
+ );
143
+ } else {
144
+ writeDebug(
145
+ `No existing items to delete in the R2 bucket path ${bucketPath}`
146
+ );
147
+ }
148
+ } else {
149
+ writeWarning("[Dry run]: Skipping R2 bucket clean.");
150
+ }
151
+ }
152
+ if (options.writeMetaJson === true) {
153
+ const meta = {
154
+ name: context.projectName,
155
+ version,
156
+ release,
157
+ description: projectDetails?.content?.description,
158
+ tags: projectDetails?.content?.keywords,
159
+ dependencies,
160
+ devDependencies: null,
161
+ internalDependencies: internalDependencies.filter(
162
+ (projectNode) => projectNode.data.tags && projectNode.data.tags.some(
163
+ (tag) => tag.toLowerCase() === "component"
164
+ )
165
+ ).map((dep) => dep.name)
166
+ };
167
+ if (projectDetails?.type === "package.json") {
168
+ meta.devDependencies = projectDetails?.content?.devDependencies;
169
+ }
170
+ const metaJson = JSON.stringify(meta);
171
+ writeTrace(`Generating meta.json file:
172
+ ${metaJson}`);
173
+ await r2UploadFile(
174
+ client,
175
+ bucketId,
176
+ bucketPath,
177
+ "meta.json",
178
+ version,
179
+ metaJson,
180
+ "application/json",
181
+ isDryRun
182
+ );
183
+ }
184
+ await Promise.all(
185
+ files.map(async (file) => {
186
+ const name = file.replaceAll("\\", "/").replace(sourceRoot.replaceAll("\\", "/"), "");
187
+ const type = mime.lookup(name) || "application/octet-stream";
188
+ writeTrace(`Uploading file: ${name} (content-type: ${type})`);
189
+ await r2UploadFile(
190
+ client,
191
+ bucketId,
192
+ bucketPath,
193
+ name,
194
+ version,
195
+ await readFile(file, { encoding: "utf8" }),
196
+ type,
197
+ isDryRun
198
+ );
199
+ })
200
+ );
201
+ writeSuccess(
202
+ `Successfully uploaded the ${projectName} project to the Cloudflare R2 bucket.`,
203
+ config
204
+ );
205
+ return {
206
+ success: true
207
+ };
208
+ } catch (error) {
209
+ console.error("Failed to publish to Cloudflare R2 bucket");
210
+ console.error(error);
211
+ console.log("");
212
+ return {
213
+ success: false
214
+ };
215
+ }
216
+ }
217
+
218
+ export {
219
+ runExecutor
220
+ };
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return 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
2
 
3
- var _chunkD4JUMEICjs = require('./chunk-D4JUMEIC.js');
3
+ var _chunkDRYNN63Fjs = require('./chunk-DRYNN63F.js');
4
4
 
5
5
 
6
6
 
@@ -66,7 +66,7 @@ ${Object.keys(process.env).map((key) => ` - ${key}=${JSON.stringify(process.env[
66
66
  const options = await normalizeOptions(tree, schema, config);
67
67
  const tasks = [];
68
68
  tasks.push(
69
- await _chunkD4JUMEICjs.generator_default.call(void 0, tree, {
69
+ await _chunkDRYNN63Fjs.generator_default.call(void 0, tree, {
70
70
  ...options,
71
71
  skipFormat: true
72
72
  })
@@ -26,7 +26,7 @@ import {
26
26
  } from "./chunk-6MATO2MJ.mjs";
27
27
  import {
28
28
  __dirname
29
- } from "./chunk-UEJFDB6Y.mjs";
29
+ } from "./chunk-QN6OKPMU.mjs";
30
30
 
31
31
  // ../config-tools/src/utilities/apply-workspace-tokens.ts
32
32
  var applyWorkspaceBaseTokens = async (option, tokenParams) => {
@@ -455,11 +455,15 @@ import https from "node:https";
455
455
  var LARGE_BUFFER = 1024 * 1e6;
456
456
 
457
457
  // ../build-tools/src/config.ts
458
- var DEFAULT_COMPILED_BANNER = `/*****************************************
459
- *
460
- * \u26A1 Built by Storm Software
461
- *
462
- *****************************************/
458
+ var DEFAULT_JS_BANNER = `
459
+ // ---------------------------------------
460
+ // \u26A1 Built by Storm Software
461
+ // ---------------------------------------
462
+ `;
463
+ var DEFAULT_CSS_BANNER = `
464
+ /* ---------------------------------------
465
+ \u26A1 Built by Storm Software
466
+ --------------------------------------- */
463
467
  `;
464
468
  var DEFAULT_ENVIRONMENT = "production";
465
469
  var DEFAULT_TARGET = "esnext";
@@ -824,8 +828,8 @@ var DEFAULT_BUILD_OPTIONS = {
824
828
  ".woff2": "file"
825
829
  },
826
830
  banner: {
827
- js: DEFAULT_COMPILED_BANNER,
828
- css: DEFAULT_COMPILED_BANNER
831
+ js: DEFAULT_JS_BANNER,
832
+ css: DEFAULT_CSS_BANNER
829
833
  }
830
834
  };
831
835
 
@@ -7,7 +7,7 @@ var require_package = _chunkMCKGQKYUjs.__commonJS.call(void 0, {
7
7
  "package.json"(exports, module) {
8
8
  module.exports = {
9
9
  name: "@storm-software/cloudflare-tools",
10
- version: "0.70.48",
10
+ version: "0.70.50",
11
11
  description: "A Nx plugin package that contains various executors, generators, and utilities that assist in managing Cloudflare services.",
12
12
  repository: {
13
13
  type: "github",
@@ -136,9 +136,9 @@ var require_package = _chunkMCKGQKYUjs.__commonJS.call(void 0, {
136
136
  "@nx/js": "catalog:",
137
137
  "@nx/node": "catalog:",
138
138
  "@nx/web": "catalog:",
139
- "@storm-software/config": "1.134.48",
140
- "@storm-software/config-tools": "1.188.48",
141
- "@storm-software/workspace-tools": "1.293.18",
139
+ "@storm-software/config": "1.134.50",
140
+ "@storm-software/config-tools": "1.188.50",
141
+ "@storm-software/workspace-tools": "1.293.20",
142
142
  nx: "catalog:",
143
143
  tsup: "catalog:",
144
144
  wrangler: ">=3.58.0"
@@ -166,7 +166,8 @@ var require_package = _chunkMCKGQKYUjs.__commonJS.call(void 0, {
166
166
  dependencies: {
167
167
  "@aws-sdk/client-s3": "3.47.0",
168
168
  defu: "catalog:",
169
- glob: "catalog:"
169
+ glob: "catalog:",
170
+ "mime-types": "^3.0.2"
170
171
  },
171
172
  devDependencies: {
172
173
  "@nx/devkit": "catalog:",
@@ -176,7 +177,7 @@ var require_package = _chunkMCKGQKYUjs.__commonJS.call(void 0, {
176
177
  nx: "catalog:",
177
178
  tsup: "catalog:",
178
179
  untyped: "catalog:",
179
- wrangler: "^4.50.0"
180
+ wrangler: "^4.53.0"
180
181
  },
181
182
  publishConfig: {
182
183
  access: "public"
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  __commonJS
3
- } from "./chunk-UEJFDB6Y.mjs";
3
+ } from "./chunk-QN6OKPMU.mjs";
4
4
 
5
5
  // package.json
6
6
  var require_package = __commonJS({
7
7
  "package.json"(exports, module) {
8
8
  module.exports = {
9
9
  name: "@storm-software/cloudflare-tools",
10
- version: "0.70.48",
10
+ version: "0.70.50",
11
11
  description: "A Nx plugin package that contains various executors, generators, and utilities that assist in managing Cloudflare services.",
12
12
  repository: {
13
13
  type: "github",
@@ -136,9 +136,9 @@ var require_package = __commonJS({
136
136
  "@nx/js": "catalog:",
137
137
  "@nx/node": "catalog:",
138
138
  "@nx/web": "catalog:",
139
- "@storm-software/config": "1.134.48",
140
- "@storm-software/config-tools": "1.188.48",
141
- "@storm-software/workspace-tools": "1.293.18",
139
+ "@storm-software/config": "1.134.50",
140
+ "@storm-software/config-tools": "1.188.50",
141
+ "@storm-software/workspace-tools": "1.293.20",
142
142
  nx: "catalog:",
143
143
  tsup: "catalog:",
144
144
  wrangler: ">=3.58.0"
@@ -166,7 +166,8 @@ var require_package = __commonJS({
166
166
  dependencies: {
167
167
  "@aws-sdk/client-s3": "3.47.0",
168
168
  defu: "catalog:",
169
- glob: "catalog:"
169
+ glob: "catalog:",
170
+ "mime-types": "^3.0.2"
170
171
  },
171
172
  devDependencies: {
172
173
  "@nx/devkit": "catalog:",
@@ -176,7 +177,7 @@ var require_package = __commonJS({
176
177
  nx: "catalog:",
177
178
  tsup: "catalog:",
178
179
  untyped: "catalog:",
179
- wrangler: "^4.50.0"
180
+ wrangler: "^4.53.0"
180
181
  },
181
182
  publishConfig: {
182
183
  access: "public"
@@ -9,7 +9,7 @@ var __commonJS = (cb, mod) => function __require2() {
9
9
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
10
  };
11
11
 
12
- // ../../node_modules/.pnpm/tsup@8.4.0_patch_hash=751a554d775c3572381af4e7e5fa22eeda6dd6856012fb1cf521d6806eb2dc74__a793dd249f39ab21a45375c80b03a1ea/node_modules/tsup/assets/esm_shims.js
12
+ // ../../node_modules/.pnpm/tsup@8.4.0_patch_hash=751a554d775c3572381af4e7e5fa22eeda6dd6856012fb1cf521d6806eb2dc74__5adfafe360c1e61df03aa1e123559c5f/node_modules/tsup/assets/esm_shims.js
13
13
  import { fileURLToPath } from "url";
14
14
  import path from "path";
15
15
  var getFilename = () => fileURLToPath(import.meta.url);
@@ -0,0 +1,220 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return 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
+
4
+ var _chunkFFOLWRMAjs = require('./chunk-FFOLWRMA.js');
5
+
6
+
7
+
8
+ var _chunkNU34IEWNjs = require('./chunk-NU34IEWN.js');
9
+
10
+
11
+
12
+ var _chunkEQXEFXCVjs = require('./chunk-EQXEFXCV.js');
13
+
14
+
15
+
16
+
17
+
18
+ var _chunk4BWM53AAjs = require('./chunk-4BWM53AA.js');
19
+
20
+ // src/executors/r2-upload-publish/executor.ts
21
+ var _clients3 = require('@aws-sdk/client-s3');
22
+
23
+
24
+
25
+
26
+ var _devkit = require('@nx/devkit');
27
+ var _glob = require('glob');
28
+ var _mimetypes = require('mime-types'); var _mimetypes2 = _interopRequireDefault(_mimetypes);
29
+ var _child_process = require('child_process');
30
+ var _promises = require('fs/promises');
31
+ async function runExecutor(options, context) {
32
+ const isDryRun = process.env.NX_DRY_RUN === "true" || options.dryRun || false;
33
+ if (!context.projectName) {
34
+ throw new Error("The executor requires a projectName.");
35
+ }
36
+ console.info(
37
+ `\u{1F680} Running Storm Cloudflare Publish executor on the ${context.projectName} worker`
38
+ );
39
+ if (!context.projectName || !_optionalChain([context, 'access', _ => _.projectsConfigurations, 'optionalAccess', _2 => _2.projects]) || !context.projectsConfigurations.projects[context.projectName] || !_optionalChain([context, 'access', _3 => _3.projectsConfigurations, 'access', _4 => _4.projects, 'access', _5 => _5[context.projectName], 'optionalAccess', _6 => _6.root])) {
40
+ throw new Error("The executor requires projectsConfigurations.");
41
+ }
42
+ try {
43
+ const workspaceRoot = _chunkEQXEFXCVjs.findWorkspaceRoot.call(void 0, );
44
+ const config = await _chunkEQXEFXCVjs.getConfig.call(void 0, workspaceRoot);
45
+ const sourceRoot = _nullishCoalesce(_optionalChain([context, 'access', _7 => _7.projectsConfigurations, 'access', _8 => _8.projects, 'access', _9 => _9[context.projectName], 'optionalAccess', _10 => _10.sourceRoot]), () => ( workspaceRoot));
46
+ const projectName = _nullishCoalesce(_optionalChain([context, 'access', _11 => _11.projectsConfigurations, 'access', _12 => _12.projects, 'access', _13 => _13[context.projectName], 'optionalAccess', _14 => _14.name]), () => ( context.projectName));
47
+ const projectDetails = _chunkNU34IEWNjs.getPackageInfo.call(void 0,
48
+ context.projectsConfigurations.projects[context.projectName]
49
+ );
50
+ const bucketId = options.bucketId;
51
+ const bucketPath = options.bucketPath || "/";
52
+ if (!bucketId) {
53
+ throw new Error("The executor requires a bucketId.");
54
+ }
55
+ const args = _chunkNU34IEWNjs.createCliOptions.call(void 0, { ...options });
56
+ if (isDryRun) {
57
+ args.push("--dry-run");
58
+ }
59
+ const cloudflareAccountId = process.env.CLOUDFLARE_ACCOUNT_ID || process.env.STORM_BOT_CLOUDFLARE_ACCOUNT;
60
+ if (!_optionalChain([options, 'optionalAccess', _15 => _15.registry]) && !cloudflareAccountId) {
61
+ throw new Error(
62
+ "The registry option and `CLOUDFLARE_ACCOUNT_ID` environment variable are not set. Please set one of these values to upload to the Cloudflare R2 bucket."
63
+ );
64
+ }
65
+ if (!process.env.ACCESS_KEY_ID && !process.env.CLOUDFLARE_ACCESS_KEY_ID && !process.env.AWS_ACCESS_KEY_ID || !process.env.SECRET_ACCESS_KEY && !process.env.CLOUDFLARE_SECRET_ACCESS_KEY && !process.env.AWS_SECRET_ACCESS_KEY) {
66
+ throw new Error(
67
+ "The `ACCESS_KEY_ID` and `SECRET_ACCESS_KEY` environment variables are not set. Please set these environment variables to upload to the Cloudflare R2 bucket."
68
+ );
69
+ }
70
+ const registry = _optionalChain([options, 'optionalAccess', _16 => _16.registry]) ? options.registry : `https://${cloudflareAccountId}.r2.cloudflarestorage.com`;
71
+ let projectGraph;
72
+ try {
73
+ projectGraph = _devkit.readCachedProjectGraph.call(void 0, );
74
+ } catch (e) {
75
+ await _devkit.createProjectGraphAsync.call(void 0, );
76
+ projectGraph = _devkit.readCachedProjectGraph.call(void 0, );
77
+ }
78
+ if (!projectGraph) {
79
+ throw new Error(
80
+ "The executor failed because the project graph is not available. Please run the build command again."
81
+ );
82
+ }
83
+ _chunk4BWM53AAjs.writeDebug.call(void 0,
84
+ `Publishing ${context.projectName} to the ${bucketId} R2 Bucket (at ${registry})`
85
+ );
86
+ const client = new (0, _clients3.S3)({
87
+ region: "auto",
88
+ endpoint: registry,
89
+ credentials: {
90
+ accessKeyId: process.env.ACCESS_KEY_ID || process.env.CLOUDFLARE_ACCESS_KEY_ID || process.env.AWS_ACCESS_KEY_ID,
91
+ secretAccessKey: process.env.SECRET_ACCESS_KEY || process.env.CLOUDFLARE_SECRET_ACCESS_KEY || process.env.AWS_SECRET_ACCESS_KEY
92
+ }
93
+ });
94
+ const version = _optionalChain([projectDetails, 'optionalAccess', _17 => _17.content, 'optionalAccess', _18 => _18.version]);
95
+ if (version) {
96
+ _chunk4BWM53AAjs.writeDebug.call(void 0, `Starting upload version ${version}`);
97
+ }
98
+ const files = await _glob.glob.call(void 0,
99
+ _devkit.joinPathFragments.call(void 0, options.path || sourceRoot, "**/*"),
100
+ {
101
+ ignore: "**/{*.stories.tsx,*.stories.ts,*.spec.tsx,*.spec.ts}"
102
+ }
103
+ );
104
+ const internalDependencies = await _chunkFFOLWRMAjs.getInternalDependencies.call(void 0,
105
+ context.projectName,
106
+ projectGraph
107
+ );
108
+ const dependencies = internalDependencies.filter(
109
+ (projectNode) => !projectNode.data.tags || projectNode.data.tags.every((tag) => tag.toLowerCase() !== "component")
110
+ ).reduce((ret, dep) => {
111
+ if (!ret[dep.name]) {
112
+ ret[dep.name] = "latest";
113
+ }
114
+ return ret;
115
+ }, _nullishCoalesce(_optionalChain([projectDetails, 'optionalAccess', _19 => _19.content, 'access', _20 => _20.dependencies]), () => ( {})));
116
+ const release = _nullishCoalesce(options.tag, () => ( _child_process.execSync.call(void 0, "npm config get tag").toString().trim()));
117
+ if (options.clean === true) {
118
+ _chunk4BWM53AAjs.writeDebug.call(void 0, `Clearing out existing items in ${bucketPath}`);
119
+ if (!isDryRun) {
120
+ const response = await client.listObjects({
121
+ Bucket: bucketId,
122
+ Prefix: bucketPath
123
+ });
124
+ if (_optionalChain([response, 'optionalAccess', _21 => _21.Contents]) && response.Contents.length > 0) {
125
+ _chunk4BWM53AAjs.writeTrace.call(void 0,
126
+ `Deleting the following existing items from the R2 bucket path ${bucketPath}: ${response.Contents.map((item) => item.Key).join(", ")}`
127
+ );
128
+ await Promise.all(
129
+ response.Contents.map(
130
+ (item) => client.deleteObjects({
131
+ Bucket: bucketId,
132
+ Delete: {
133
+ Objects: [
134
+ {
135
+ Key: item.Key
136
+ }
137
+ ],
138
+ Quiet: false
139
+ }
140
+ })
141
+ )
142
+ );
143
+ } else {
144
+ _chunk4BWM53AAjs.writeDebug.call(void 0,
145
+ `No existing items to delete in the R2 bucket path ${bucketPath}`
146
+ );
147
+ }
148
+ } else {
149
+ _chunk4BWM53AAjs.writeWarning.call(void 0, "[Dry run]: Skipping R2 bucket clean.");
150
+ }
151
+ }
152
+ if (options.writeMetaJson === true) {
153
+ const meta = {
154
+ name: context.projectName,
155
+ version,
156
+ release,
157
+ description: _optionalChain([projectDetails, 'optionalAccess', _22 => _22.content, 'optionalAccess', _23 => _23.description]),
158
+ tags: _optionalChain([projectDetails, 'optionalAccess', _24 => _24.content, 'optionalAccess', _25 => _25.keywords]),
159
+ dependencies,
160
+ devDependencies: null,
161
+ internalDependencies: internalDependencies.filter(
162
+ (projectNode) => projectNode.data.tags && projectNode.data.tags.some(
163
+ (tag) => tag.toLowerCase() === "component"
164
+ )
165
+ ).map((dep) => dep.name)
166
+ };
167
+ if (_optionalChain([projectDetails, 'optionalAccess', _26 => _26.type]) === "package.json") {
168
+ meta.devDependencies = _optionalChain([projectDetails, 'optionalAccess', _27 => _27.content, 'optionalAccess', _28 => _28.devDependencies]);
169
+ }
170
+ const metaJson = JSON.stringify(meta);
171
+ _chunk4BWM53AAjs.writeTrace.call(void 0, `Generating meta.json file:
172
+ ${metaJson}`);
173
+ await _chunkFFOLWRMAjs.r2UploadFile.call(void 0,
174
+ client,
175
+ bucketId,
176
+ bucketPath,
177
+ "meta.json",
178
+ version,
179
+ metaJson,
180
+ "application/json",
181
+ isDryRun
182
+ );
183
+ }
184
+ await Promise.all(
185
+ files.map(async (file) => {
186
+ const name = file.replaceAll("\\", "/").replace(sourceRoot.replaceAll("\\", "/"), "");
187
+ const type = _mimetypes2.default.lookup(name) || "application/octet-stream";
188
+ _chunk4BWM53AAjs.writeTrace.call(void 0, `Uploading file: ${name} (content-type: ${type})`);
189
+ await _chunkFFOLWRMAjs.r2UploadFile.call(void 0,
190
+ client,
191
+ bucketId,
192
+ bucketPath,
193
+ name,
194
+ version,
195
+ await _promises.readFile.call(void 0, file, { encoding: "utf8" }),
196
+ type,
197
+ isDryRun
198
+ );
199
+ })
200
+ );
201
+ _chunk4BWM53AAjs.writeSuccess.call(void 0,
202
+ `Successfully uploaded the ${projectName} project to the Cloudflare R2 bucket.`,
203
+ config
204
+ );
205
+ return {
206
+ success: true
207
+ };
208
+ } catch (error) {
209
+ console.error("Failed to publish to Cloudflare R2 bucket");
210
+ console.error(error);
211
+ console.log("");
212
+ return {
213
+ success: false
214
+ };
215
+ }
216
+ }
217
+
218
+
219
+
220
+ exports.runExecutor = runExecutor;