@storm-software/cloudflare-tools 0.55.85 → 0.55.87

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 (45) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +1 -1
  3. package/dist/{chunk-VTHBMY4B.js → chunk-6XDOBG77.js} +39 -28
  4. package/dist/{chunk-FUE3PSOC.mjs → chunk-CW6SXRL4.mjs} +825 -544
  5. package/dist/{chunk-VRLPVMXP.mjs → chunk-FABNT5TZ.mjs} +15 -13
  6. package/dist/{chunk-QQJ225UZ.mjs → chunk-GPAI4NHQ.mjs} +141 -87
  7. package/dist/{chunk-YNJJF3XM.mjs → chunk-H4XWGL24.mjs} +93 -56
  8. package/dist/{chunk-IVLCYFXD.js → chunk-HBASMEU5.js} +168 -114
  9. package/dist/{chunk-6B5PUF7X.js → chunk-HIUZ6UL7.js} +97 -47
  10. package/dist/{chunk-R7AIVBS7.js → chunk-I4P7DVDN.js} +19 -24
  11. package/dist/{chunk-KWHACLHR.mjs → chunk-ISGKIYF5.mjs} +92 -42
  12. package/dist/{chunk-5RE7UZTH.mjs → chunk-L4WFYC7K.mjs} +39 -28
  13. package/dist/{chunk-PWYTCJYX.js → chunk-LDHIZ5T7.js} +875 -594
  14. package/dist/{chunk-J5SB6L2L.js → chunk-MCKGQKYU.js} +2 -5
  15. package/dist/{chunk-DEJ5S46A.mjs → chunk-MV24QW26.mjs} +195 -127
  16. package/dist/{chunk-V7LBWOVV.js → chunk-PZ5CI56F.js} +196 -128
  17. package/dist/{chunk-AOEF7EWN.mjs → chunk-QPABB45G.mjs} +19 -24
  18. package/dist/{chunk-TLFPZXKG.mjs → chunk-QQ22YQSB.mjs} +3 -6
  19. package/dist/{chunk-QGRENI3O.js → chunk-RIUVF72K.js} +17 -15
  20. package/dist/{chunk-PKQBY4ZM.js → chunk-X4Y76AIM.js} +26 -20
  21. package/dist/{chunk-CNGX2WYG.js → chunk-XCEENUJB.js} +93 -58
  22. package/dist/{chunk-N4KJP2OA.mjs → chunk-YJOYATEB.mjs} +27 -21
  23. package/dist/executors.js +8 -8
  24. package/dist/executors.mjs +8 -8
  25. package/dist/generators.js +6 -6
  26. package/dist/generators.mjs +5 -5
  27. package/dist/index.js +41 -49
  28. package/dist/index.mjs +40 -48
  29. package/dist/src/executors/cloudflare-publish/executor.js +7 -7
  30. package/dist/src/executors/cloudflare-publish/executor.mjs +6 -6
  31. package/dist/src/executors/r2-upload-publish/executor.js +7 -7
  32. package/dist/src/executors/r2-upload-publish/executor.mjs +6 -6
  33. package/dist/src/executors/serve/executor.js +49 -50
  34. package/dist/src/executors/serve/executor.mjs +48 -49
  35. package/dist/src/generators/init/generator.js +3 -3
  36. package/dist/src/generators/init/generator.mjs +2 -2
  37. package/dist/src/generators/worker/generator.js +6 -6
  38. package/dist/src/generators/worker/generator.mjs +5 -5
  39. package/dist/src/utils/index.js +4 -4
  40. package/dist/src/utils/index.mjs +3 -3
  41. package/dist/src/utils/r2-bucket-helpers.js +4 -4
  42. package/dist/src/utils/r2-bucket-helpers.mjs +3 -3
  43. package/dist/tsup.config.js +3 -8
  44. package/dist/tsup.config.mjs +3 -8
  45. package/package.json +1 -1
@@ -1,27 +1,28 @@
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
3
 
4
- var _chunkQGRENI3Ojs = require('./chunk-QGRENI3O.js');
4
+ var _chunkRIUVF72Kjs = require('./chunk-RIUVF72K.js');
5
5
 
6
6
 
7
7
 
8
- var _chunkVTHBMY4Bjs = require('./chunk-VTHBMY4B.js');
8
+ var _chunk6XDOBG77js = require('./chunk-6XDOBG77.js');
9
9
 
10
10
 
11
- var _chunkIVLCYFXDjs = require('./chunk-IVLCYFXD.js');
11
+ var _chunkHBASMEU5js = require('./chunk-HBASMEU5.js');
12
12
 
13
13
 
14
14
 
15
15
 
16
16
 
17
17
 
18
- var _chunkV7LBWOVVjs = require('./chunk-V7LBWOVV.js');
19
-
20
-
21
- var _chunkJ5SB6L2Ljs = require('./chunk-J5SB6L2L.js');
18
+ var _chunkPZ5CI56Fjs = require('./chunk-PZ5CI56F.js');
22
19
 
23
20
  // src/executors/r2-upload-publish/executor.ts
24
21
  var _clients3 = require('@aws-sdk/client-s3');
22
+
23
+
24
+
25
+
25
26
  var _devkit = require('@nx/devkit');
26
27
  var _glob = require('glob');
27
28
  var _child_process = require('child_process');
@@ -31,31 +32,39 @@ async function runExecutor(options, context) {
31
32
  if (!context.projectName) {
32
33
  throw new Error("The executor requires a projectName.");
33
34
  }
34
- console.info(`\u{1F680} Running Storm Cloudflare Publish executor on the ${context.projectName} worker`);
35
+ console.info(
36
+ `\u{1F680} Running Storm Cloudflare Publish executor on the ${context.projectName} worker`
37
+ );
35
38
  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])) {
36
39
  throw new Error("The executor requires projectsConfigurations.");
37
40
  }
38
41
  try {
39
- const workspaceRoot = _chunkV7LBWOVVjs.findWorkspaceRoot.call(void 0, );
40
- const config = await _chunkIVLCYFXDjs.getConfig.call(void 0, workspaceRoot);
42
+ const workspaceRoot = _chunkPZ5CI56Fjs.findWorkspaceRoot.call(void 0, );
43
+ const config = await _chunkHBASMEU5js.getConfig.call(void 0, workspaceRoot);
41
44
  const sourceRoot = _nullishCoalesce(_optionalChain([context, 'access', _7 => _7.projectsConfigurations, 'access', _8 => _8.projects, 'access', _9 => _9[context.projectName], 'optionalAccess', _10 => _10.sourceRoot]), () => ( workspaceRoot));
42
45
  const projectName = _nullishCoalesce(_optionalChain([context, 'access', _11 => _11.projectsConfigurations, 'access', _12 => _12.projects, 'access', _13 => _13[context.projectName], 'optionalAccess', _14 => _14.name]), () => ( context.projectName));
43
- const projectDetails = _chunkVTHBMY4Bjs.getPackageInfo.call(void 0, context.projectsConfigurations.projects[context.projectName]);
46
+ const projectDetails = _chunk6XDOBG77js.getPackageInfo.call(void 0,
47
+ context.projectsConfigurations.projects[context.projectName]
48
+ );
44
49
  if (!_optionalChain([projectDetails, 'optionalAccess', _15 => _15.content])) {
45
- throw new Error(`Could not find the project details for ${context.projectName}`);
50
+ throw new Error(
51
+ `Could not find the project details for ${context.projectName}`
52
+ );
46
53
  }
47
- const args = _chunkVTHBMY4Bjs.createCliOptions.call(void 0, {
48
- ...options
49
- });
54
+ const args = _chunk6XDOBG77js.createCliOptions.call(void 0, { ...options });
50
55
  if (isDryRun) {
51
56
  args.push("--dry-run");
52
57
  }
53
58
  const cloudflareAccountId = process.env.STORM_BOT_CLOUDFLARE_ACCOUNT;
54
59
  if (!_optionalChain([options, 'optionalAccess', _16 => _16.registry]) && !cloudflareAccountId) {
55
- throw new Error("The Storm Registry URL is not set in the Storm config. Please set either the `extensions.cyclone.registry` or `config.extensions.cyclone.accountId` property in the Storm config.");
60
+ throw new Error(
61
+ "The Storm Registry URL is not set in the Storm config. Please set either the `extensions.cyclone.registry` or `config.extensions.cyclone.accountId` property in the Storm config."
62
+ );
56
63
  }
57
64
  if (!process.env.AWS_ACCESS_KEY_ID || !process.env.AWS_SECRET_ACCESS_KEY) {
58
- throw new Error("The AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables are not set. Please set these environment variables to upload to the Cyclone Registry.");
65
+ throw new Error(
66
+ "The AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables are not set. Please set these environment variables to upload to the Cyclone Registry."
67
+ );
59
68
  }
60
69
  const endpoint = _optionalChain([options, 'optionalAccess', _17 => _17.registry]) ? options.registry : `https://${cloudflareAccountId}.r2.cloudflarestorage.com`;
61
70
  let projectGraph;
@@ -66,9 +75,13 @@ async function runExecutor(options, context) {
66
75
  projectGraph = _devkit.readCachedProjectGraph.call(void 0, );
67
76
  }
68
77
  if (!projectGraph) {
69
- throw new Error("The executor failed because the project graph is not available. Please run the build command again.");
78
+ throw new Error(
79
+ "The executor failed because the project graph is not available. Please run the build command again."
80
+ );
70
81
  }
71
- _chunkV7LBWOVVjs.writeInfo.call(void 0, `Publishing ${context.projectName} to the Storm Registry at ${endpoint}`);
82
+ _chunkPZ5CI56Fjs.writeInfo.call(void 0,
83
+ `Publishing ${context.projectName} to the Storm Registry at ${endpoint}`
84
+ );
72
85
  const s3Client = new (0, _clients3.S3)({
73
86
  region: "auto",
74
87
  endpoint,
@@ -78,43 +91,56 @@ async function runExecutor(options, context) {
78
91
  }
79
92
  });
80
93
  const version = _optionalChain([projectDetails, 'access', _18 => _18.content, 'optionalAccess', _19 => _19.version]);
81
- _chunkV7LBWOVVjs.writeInfo.call(void 0, `Generated component version: ${version}`);
94
+ _chunkPZ5CI56Fjs.writeInfo.call(void 0, `Generated component version: ${version}`);
82
95
  const files = await _glob.glob.call(void 0, _devkit.joinPathFragments.call(void 0, sourceRoot, "**/*"), {
83
96
  ignore: "**/{*.stories.tsx,*.stories.ts,*.spec.tsx,*.spec.ts}"
84
97
  });
85
98
  const projectPath = `registry/${context.projectName}`;
86
- const internalDependencies = await _chunkQGRENI3Ojs.getInternalDependencies.call(void 0, context.projectName, projectGraph);
87
- const dependencies = internalDependencies.filter((projectNode) => !projectNode.data.tags || projectNode.data.tags.every((tag) => tag.toLowerCase() !== "component")).reduce((ret, dep) => {
99
+ const internalDependencies = await _chunkRIUVF72Kjs.getInternalDependencies.call(void 0,
100
+ context.projectName,
101
+ projectGraph
102
+ );
103
+ const dependencies = internalDependencies.filter(
104
+ (projectNode) => !projectNode.data.tags || projectNode.data.tags.every((tag) => tag.toLowerCase() !== "component")
105
+ ).reduce((ret, dep) => {
88
106
  if (!ret[dep.name]) {
89
107
  ret[dep.name] = "latest";
90
108
  }
91
109
  return ret;
92
110
  }, _nullishCoalesce(projectDetails.content.dependencies, () => ( {})));
93
111
  const release = _nullishCoalesce(options.tag, () => ( _child_process.execSync.call(void 0, "npm config get tag").toString().trim()));
94
- _chunkV7LBWOVVjs.writeInfo.call(void 0, `Clearing out existing items in ${projectPath}`);
112
+ _chunkPZ5CI56Fjs.writeInfo.call(void 0, `Clearing out existing items in ${projectPath}`);
95
113
  if (!isDryRun) {
96
114
  const response = await s3Client.listObjects({
97
115
  Bucket: options.bucketId,
98
116
  Prefix: projectPath
99
117
  });
100
118
  if (_optionalChain([response, 'optionalAccess', _20 => _20.Contents]) && response.Contents.length > 0) {
101
- _chunkV7LBWOVVjs.writeDebug.call(void 0, `Deleting the following existing items from the component registry: ${response.Contents.map((item) => item.Key).join(", ")}`);
102
- await Promise.all(response.Contents.map((item) => s3Client.deleteObjects({
103
- Bucket: options.bucketId,
104
- Delete: {
105
- Objects: [
106
- {
107
- Key: item.Key
119
+ _chunkPZ5CI56Fjs.writeDebug.call(void 0,
120
+ `Deleting the following existing items from the component registry: ${response.Contents.map((item) => item.Key).join(", ")}`
121
+ );
122
+ await Promise.all(
123
+ response.Contents.map(
124
+ (item) => s3Client.deleteObjects({
125
+ Bucket: options.bucketId,
126
+ Delete: {
127
+ Objects: [
128
+ {
129
+ Key: item.Key
130
+ }
131
+ ],
132
+ Quiet: false
108
133
  }
109
- ],
110
- Quiet: false
111
- }
112
- })));
134
+ })
135
+ )
136
+ );
113
137
  } else {
114
- _chunkV7LBWOVVjs.writeDebug.call(void 0, `No existing items to delete in the component registry path ${projectPath}`);
138
+ _chunkPZ5CI56Fjs.writeDebug.call(void 0,
139
+ `No existing items to delete in the component registry path ${projectPath}`
140
+ );
115
141
  }
116
142
  } else {
117
- _chunkV7LBWOVVjs.writeWarning.call(void 0, "[Dry run]: skipping upload to the Cyclone Registry.");
143
+ _chunkPZ5CI56Fjs.writeWarning.call(void 0, "[Dry run]: skipping upload to the Cyclone Registry.");
118
144
  }
119
145
  const meta = {
120
146
  name: context.projectName,
@@ -124,22 +150,47 @@ async function runExecutor(options, context) {
124
150
  tags: projectDetails.content.keywords,
125
151
  dependencies,
126
152
  devDependencies: null,
127
- internalDependencies: internalDependencies.filter((projectNode) => projectNode.data.tags && projectNode.data.tags.some((tag) => tag.toLowerCase() === "component")).map((dep) => dep.name)
153
+ internalDependencies: internalDependencies.filter(
154
+ (projectNode) => projectNode.data.tags && projectNode.data.tags.some((tag) => tag.toLowerCase() === "component")
155
+ ).map((dep) => dep.name)
128
156
  };
129
157
  if (projectDetails.type === "package.json") {
130
158
  meta.devDependencies = projectDetails.content.devDependencies;
131
159
  }
132
160
  const metaJson = JSON.stringify(meta);
133
- _chunkV7LBWOVVjs.writeInfo.call(void 0, `Generating meta.json file:
161
+ _chunkPZ5CI56Fjs.writeInfo.call(void 0, `Generating meta.json file:
134
162
  ${metaJson}`);
135
- await _chunkQGRENI3Ojs.r2UploadFile.call(void 0, s3Client, options.bucketId, projectPath, "meta.json", version, metaJson, "application/json", isDryRun);
136
- await Promise.all(files.map((file) => {
137
- const fileName = file.replaceAll("\\", "/").replace(sourceRoot.replaceAll("\\", "/"), "");
138
- return _promises.readFile.call(void 0, file, {
139
- encoding: "utf8"
140
- }).then((fileContent) => _chunkQGRENI3Ojs.r2UploadFile.call(void 0, s3Client, options.bucketId, projectPath, fileName, version, fileContent, "text/plain", isDryRun));
141
- }));
142
- _chunkV7LBWOVVjs.writeSuccess.call(void 0, `Successfully uploaded the ${projectName} component to the Cyclone Registry`, config);
163
+ await _chunkRIUVF72Kjs.r2UploadFile.call(void 0,
164
+ s3Client,
165
+ options.bucketId,
166
+ projectPath,
167
+ "meta.json",
168
+ version,
169
+ metaJson,
170
+ "application/json",
171
+ isDryRun
172
+ );
173
+ await Promise.all(
174
+ files.map((file) => {
175
+ const fileName = file.replaceAll("\\", "/").replace(sourceRoot.replaceAll("\\", "/"), "");
176
+ return _promises.readFile.call(void 0, file, { encoding: "utf8" }).then(
177
+ (fileContent) => _chunkRIUVF72Kjs.r2UploadFile.call(void 0,
178
+ s3Client,
179
+ options.bucketId,
180
+ projectPath,
181
+ fileName,
182
+ version,
183
+ fileContent,
184
+ "text/plain",
185
+ isDryRun
186
+ )
187
+ );
188
+ })
189
+ );
190
+ _chunkPZ5CI56Fjs.writeSuccess.call(void 0,
191
+ `Successfully uploaded the ${projectName} component to the Cyclone Registry`,
192
+ config
193
+ );
143
194
  return {
144
195
  success: true
145
196
  };
@@ -152,7 +203,6 @@ ${metaJson}`);
152
203
  };
153
204
  }
154
205
  }
155
- _chunkJ5SB6L2Ljs.__name.call(void 0, runExecutor, "runExecutor");
156
206
 
157
207
 
158
208
 
@@ -1,10 +1,9 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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 _chunkVTHBMY4Bjs = require('./chunk-VTHBMY4B.js');
3
+ var _chunk6XDOBG77js = require('./chunk-6XDOBG77.js');
4
4
 
5
5
 
6
-
7
- var _chunkJ5SB6L2Ljs = require('./chunk-J5SB6L2L.js');
6
+ var _chunkMCKGQKYUjs = require('./chunk-MCKGQKYU.js');
8
7
 
9
8
  // src/executors/cloudflare-publish/executor.ts
10
9
  var _devkit = require('@nx/devkit');
@@ -14,15 +13,18 @@ async function runExecutor(options, context) {
14
13
  if (!context.projectName) {
15
14
  throw new Error("The executor requires a projectName.");
16
15
  }
17
- console.info(`\u{1F680} Running Storm Cloudflare Publish executor on the ${context.projectName} worker`);
16
+ console.info(
17
+ `\u{1F680} Running Storm Cloudflare Publish executor on the ${context.projectName} worker`
18
+ );
18
19
  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])) {
19
20
  throw new Error("The executor requires projectsConfigurations.");
20
21
  }
21
- const packageRoot = _devkit.joinPathFragments.call(void 0, context.root, _optionalChain([context, 'access', _7 => _7.projectsConfigurations, 'access', _8 => _8.projects, 'access', _9 => _9[context.projectName], 'optionalAccess', _10 => _10.root]));
22
+ const packageRoot = _devkit.joinPathFragments.call(void 0,
23
+ context.root,
24
+ _optionalChain([context, 'access', _7 => _7.projectsConfigurations, 'access', _8 => _8.projects, 'access', _9 => _9[context.projectName], 'optionalAccess', _10 => _10.root])
25
+ );
22
26
  try {
23
- const args = _chunkVTHBMY4Bjs.createCliOptions.call(void 0, {
24
- ...options
25
- });
27
+ const args = _chunk6XDOBG77js.createCliOptions.call(void 0, { ...options });
26
28
  if (isDryRun) {
27
29
  args.push("--dry-run");
28
30
  }
@@ -31,10 +33,7 @@ async function runExecutor(options, context) {
31
33
  console.log("");
32
34
  let proc;
33
35
  try {
34
- _child_process.fork.call(void 0, _chunkJ5SB6L2Ljs.__require.resolve("wrangler/bin/wrangler"), [
35
- "deploy",
36
- ...args
37
- ], {
36
+ _child_process.fork.call(void 0, _chunkMCKGQKYUjs.__require.resolve("wrangler/bin/wrangler"), ["deploy", ...args], {
38
37
  env: {
39
38
  CLOUDFLARE_ACCOUNT_ID: process.env.STORM_BOT_CLOUDFLARE_ACCOUNT,
40
39
  CLOUDFLARE_API_TOKEN: process.env.STORM_BOT_CLOUDFLARE_TOKEN,
@@ -43,16 +42,13 @@ async function runExecutor(options, context) {
43
42
  FORCE_COLOR: "true"
44
43
  },
45
44
  cwd: packageRoot,
46
- stdio: [
47
- "pipe",
48
- "pipe",
49
- "pipe",
50
- "ipc"
51
- ]
45
+ stdio: ["pipe", "pipe", "pipe", "ipc"]
52
46
  });
53
47
  } catch (e) {
54
48
  console.error(e);
55
- throw new Error("Unable to run Wrangler. Please ensure Wrangler is installed.");
49
+ throw new Error(
50
+ "Unable to run Wrangler. Please ensure Wrangler is installed."
51
+ );
56
52
  }
57
53
  _optionalChain([proc, 'optionalAccess', _11 => _11.stdout, 'optionalAccess', _12 => _12.on, 'call', _13 => _13("data", (message) => {
58
54
  process.stdout.write(message);
@@ -64,13 +60,13 @@ async function runExecutor(options, context) {
64
60
  _optionalChain([proc, 'optionalAccess', _17 => _17.on, 'call', _18 => _18("close", (code) => {
65
61
  console.log("");
66
62
  if (isDryRun) {
67
- console.log("Would publish to Cloudflare Workers Registry, but [dry-run] was set");
63
+ console.log(
64
+ "Would publish to Cloudflare Workers Registry, but [dry-run] was set"
65
+ );
68
66
  } else {
69
67
  console.log("Published to Cloudflare Workers Registry");
70
68
  }
71
- return resolve({
72
- success: code === 0
73
- });
69
+ return resolve({ success: code === 0 });
74
70
  })]);
75
71
  });
76
72
  } catch (error) {
@@ -82,7 +78,6 @@ async function runExecutor(options, context) {
82
78
  };
83
79
  }
84
80
  }
85
- _chunkJ5SB6L2Ljs.__name.call(void 0, runExecutor, "runExecutor");
86
81
 
87
82
 
88
83
 
@@ -1,28 +1,29 @@
1
1
  import {
2
2
  getInternalDependencies,
3
3
  r2UploadFile
4
- } from "./chunk-VRLPVMXP.mjs";
4
+ } from "./chunk-FABNT5TZ.mjs";
5
5
  import {
6
6
  createCliOptions,
7
7
  getPackageInfo
8
- } from "./chunk-5RE7UZTH.mjs";
8
+ } from "./chunk-L4WFYC7K.mjs";
9
9
  import {
10
10
  getConfig
11
- } from "./chunk-QQJ225UZ.mjs";
11
+ } from "./chunk-GPAI4NHQ.mjs";
12
12
  import {
13
13
  findWorkspaceRoot,
14
14
  writeDebug,
15
15
  writeInfo,
16
16
  writeSuccess,
17
17
  writeWarning
18
- } from "./chunk-DEJ5S46A.mjs";
19
- import {
20
- __name
21
- } from "./chunk-TLFPZXKG.mjs";
18
+ } from "./chunk-MV24QW26.mjs";
22
19
 
23
20
  // src/executors/r2-upload-publish/executor.ts
24
21
  import { S3 } from "@aws-sdk/client-s3";
25
- import { createProjectGraphAsync, joinPathFragments, readCachedProjectGraph } from "@nx/devkit";
22
+ import {
23
+ createProjectGraphAsync,
24
+ joinPathFragments,
25
+ readCachedProjectGraph
26
+ } from "@nx/devkit";
26
27
  import { glob } from "glob";
27
28
  import { execSync } from "node:child_process";
28
29
  import { readFile } from "node:fs/promises";
@@ -31,7 +32,9 @@ async function runExecutor(options, context) {
31
32
  if (!context.projectName) {
32
33
  throw new Error("The executor requires a projectName.");
33
34
  }
34
- console.info(`\u{1F680} Running Storm Cloudflare Publish executor on the ${context.projectName} worker`);
35
+ console.info(
36
+ `\u{1F680} Running Storm Cloudflare Publish executor on the ${context.projectName} worker`
37
+ );
35
38
  if (!context.projectName || !context.projectsConfigurations?.projects || !context.projectsConfigurations.projects[context.projectName] || !context.projectsConfigurations.projects[context.projectName]?.root) {
36
39
  throw new Error("The executor requires projectsConfigurations.");
37
40
  }
@@ -40,22 +43,28 @@ async function runExecutor(options, context) {
40
43
  const config = await getConfig(workspaceRoot);
41
44
  const sourceRoot = context.projectsConfigurations.projects[context.projectName]?.sourceRoot ?? workspaceRoot;
42
45
  const projectName = context.projectsConfigurations.projects[context.projectName]?.name ?? context.projectName;
43
- const projectDetails = getPackageInfo(context.projectsConfigurations.projects[context.projectName]);
46
+ const projectDetails = getPackageInfo(
47
+ context.projectsConfigurations.projects[context.projectName]
48
+ );
44
49
  if (!projectDetails?.content) {
45
- throw new Error(`Could not find the project details for ${context.projectName}`);
50
+ throw new Error(
51
+ `Could not find the project details for ${context.projectName}`
52
+ );
46
53
  }
47
- const args = createCliOptions({
48
- ...options
49
- });
54
+ const args = createCliOptions({ ...options });
50
55
  if (isDryRun) {
51
56
  args.push("--dry-run");
52
57
  }
53
58
  const cloudflareAccountId = process.env.STORM_BOT_CLOUDFLARE_ACCOUNT;
54
59
  if (!options?.registry && !cloudflareAccountId) {
55
- throw new Error("The Storm Registry URL is not set in the Storm config. Please set either the `extensions.cyclone.registry` or `config.extensions.cyclone.accountId` property in the Storm config.");
60
+ throw new Error(
61
+ "The Storm Registry URL is not set in the Storm config. Please set either the `extensions.cyclone.registry` or `config.extensions.cyclone.accountId` property in the Storm config."
62
+ );
56
63
  }
57
64
  if (!process.env.AWS_ACCESS_KEY_ID || !process.env.AWS_SECRET_ACCESS_KEY) {
58
- throw new Error("The AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables are not set. Please set these environment variables to upload to the Cyclone Registry.");
65
+ throw new Error(
66
+ "The AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables are not set. Please set these environment variables to upload to the Cyclone Registry."
67
+ );
59
68
  }
60
69
  const endpoint = options?.registry ? options.registry : `https://${cloudflareAccountId}.r2.cloudflarestorage.com`;
61
70
  let projectGraph;
@@ -66,9 +75,13 @@ async function runExecutor(options, context) {
66
75
  projectGraph = readCachedProjectGraph();
67
76
  }
68
77
  if (!projectGraph) {
69
- throw new Error("The executor failed because the project graph is not available. Please run the build command again.");
78
+ throw new Error(
79
+ "The executor failed because the project graph is not available. Please run the build command again."
80
+ );
70
81
  }
71
- writeInfo(`Publishing ${context.projectName} to the Storm Registry at ${endpoint}`);
82
+ writeInfo(
83
+ `Publishing ${context.projectName} to the Storm Registry at ${endpoint}`
84
+ );
72
85
  const s3Client = new S3({
73
86
  region: "auto",
74
87
  endpoint,
@@ -83,8 +96,13 @@ async function runExecutor(options, context) {
83
96
  ignore: "**/{*.stories.tsx,*.stories.ts,*.spec.tsx,*.spec.ts}"
84
97
  });
85
98
  const projectPath = `registry/${context.projectName}`;
86
- const internalDependencies = await getInternalDependencies(context.projectName, projectGraph);
87
- const dependencies = internalDependencies.filter((projectNode) => !projectNode.data.tags || projectNode.data.tags.every((tag) => tag.toLowerCase() !== "component")).reduce((ret, dep) => {
99
+ const internalDependencies = await getInternalDependencies(
100
+ context.projectName,
101
+ projectGraph
102
+ );
103
+ const dependencies = internalDependencies.filter(
104
+ (projectNode) => !projectNode.data.tags || projectNode.data.tags.every((tag) => tag.toLowerCase() !== "component")
105
+ ).reduce((ret, dep) => {
88
106
  if (!ret[dep.name]) {
89
107
  ret[dep.name] = "latest";
90
108
  }
@@ -98,20 +116,28 @@ async function runExecutor(options, context) {
98
116
  Prefix: projectPath
99
117
  });
100
118
  if (response?.Contents && response.Contents.length > 0) {
101
- writeDebug(`Deleting the following existing items from the component registry: ${response.Contents.map((item) => item.Key).join(", ")}`);
102
- await Promise.all(response.Contents.map((item) => s3Client.deleteObjects({
103
- Bucket: options.bucketId,
104
- Delete: {
105
- Objects: [
106
- {
107
- Key: item.Key
119
+ writeDebug(
120
+ `Deleting the following existing items from the component registry: ${response.Contents.map((item) => item.Key).join(", ")}`
121
+ );
122
+ await Promise.all(
123
+ response.Contents.map(
124
+ (item) => s3Client.deleteObjects({
125
+ Bucket: options.bucketId,
126
+ Delete: {
127
+ Objects: [
128
+ {
129
+ Key: item.Key
130
+ }
131
+ ],
132
+ Quiet: false
108
133
  }
109
- ],
110
- Quiet: false
111
- }
112
- })));
134
+ })
135
+ )
136
+ );
113
137
  } else {
114
- writeDebug(`No existing items to delete in the component registry path ${projectPath}`);
138
+ writeDebug(
139
+ `No existing items to delete in the component registry path ${projectPath}`
140
+ );
115
141
  }
116
142
  } else {
117
143
  writeWarning("[Dry run]: skipping upload to the Cyclone Registry.");
@@ -124,7 +150,9 @@ async function runExecutor(options, context) {
124
150
  tags: projectDetails.content.keywords,
125
151
  dependencies,
126
152
  devDependencies: null,
127
- internalDependencies: internalDependencies.filter((projectNode) => projectNode.data.tags && projectNode.data.tags.some((tag) => tag.toLowerCase() === "component")).map((dep) => dep.name)
153
+ internalDependencies: internalDependencies.filter(
154
+ (projectNode) => projectNode.data.tags && projectNode.data.tags.some((tag) => tag.toLowerCase() === "component")
155
+ ).map((dep) => dep.name)
128
156
  };
129
157
  if (projectDetails.type === "package.json") {
130
158
  meta.devDependencies = projectDetails.content.devDependencies;
@@ -132,14 +160,37 @@ async function runExecutor(options, context) {
132
160
  const metaJson = JSON.stringify(meta);
133
161
  writeInfo(`Generating meta.json file:
134
162
  ${metaJson}`);
135
- await r2UploadFile(s3Client, options.bucketId, projectPath, "meta.json", version, metaJson, "application/json", isDryRun);
136
- await Promise.all(files.map((file) => {
137
- const fileName = file.replaceAll("\\", "/").replace(sourceRoot.replaceAll("\\", "/"), "");
138
- return readFile(file, {
139
- encoding: "utf8"
140
- }).then((fileContent) => r2UploadFile(s3Client, options.bucketId, projectPath, fileName, version, fileContent, "text/plain", isDryRun));
141
- }));
142
- writeSuccess(`Successfully uploaded the ${projectName} component to the Cyclone Registry`, config);
163
+ await r2UploadFile(
164
+ s3Client,
165
+ options.bucketId,
166
+ projectPath,
167
+ "meta.json",
168
+ version,
169
+ metaJson,
170
+ "application/json",
171
+ isDryRun
172
+ );
173
+ await Promise.all(
174
+ files.map((file) => {
175
+ const fileName = file.replaceAll("\\", "/").replace(sourceRoot.replaceAll("\\", "/"), "");
176
+ return readFile(file, { encoding: "utf8" }).then(
177
+ (fileContent) => r2UploadFile(
178
+ s3Client,
179
+ options.bucketId,
180
+ projectPath,
181
+ fileName,
182
+ version,
183
+ fileContent,
184
+ "text/plain",
185
+ isDryRun
186
+ )
187
+ );
188
+ })
189
+ );
190
+ writeSuccess(
191
+ `Successfully uploaded the ${projectName} component to the Cyclone Registry`,
192
+ config
193
+ );
143
194
  return {
144
195
  success: true
145
196
  };
@@ -152,7 +203,6 @@ ${metaJson}`);
152
203
  };
153
204
  }
154
205
  }
155
- __name(runExecutor, "runExecutor");
156
206
 
157
207
  export {
158
208
  runExecutor