@storm-software/cloudflare-tools 0.71.10 → 0.71.11

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/CHANGELOG.md CHANGED
@@ -2,6 +2,24 @@
2
2
 
3
3
  # Changelog for Storm Ops - Cloudflare Tools
4
4
 
5
+ ## [0.71.10](https://github.com/storm-software/storm-ops/releases/tag/cloudflare-tools%400.71.10) (12/08/2025)
6
+
7
+ ### Miscellaneous
8
+
9
+ - **cloudflare-tools:** Changed env names to align with standards
10
+ ([0cacf1cb7](https://github.com/storm-software/storm-ops/commit/0cacf1cb7))
11
+ - **cloudflare-tools:** Update `r2-upload-publish` executor envs
12
+ ([bc0baabca](https://github.com/storm-software/storm-ops/commit/bc0baabca))
13
+ - **cloudflare-tools:** Added `STORM_BOT` env usage to `r2-upload-publish`
14
+ executor
15
+ ([8f073abdc](https://github.com/storm-software/storm-ops/commit/8f073abdc))
16
+
17
+ ### Updated Dependencies
18
+
19
+ - Updated **workspace-tools** to **v1.294.4**
20
+ - Updated **config-tools** to **v1.188.60**
21
+ - Updated **config** to **v1.134.60**
22
+
5
23
  ## [0.71.9](https://github.com/storm-software/storm-ops/releases/tag/cloudflare-tools%400.71.9) (12/06/2025)
6
24
 
7
25
  ### Miscellaneous
@@ -1,8 +1,5 @@
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 _chunkGG44TH3Kjs = require('./chunk-GG44TH3K.js');
4
-
5
-
6
3
 
7
4
  var _chunkVKMAYBQXjs = require('./chunk-VKMAYBQX.js');
8
5
 
@@ -14,6 +11,9 @@ var _chunkVKMAYBQXjs = require('./chunk-VKMAYBQX.js');
14
11
 
15
12
  var _chunkZ2WQB55Rjs = require('./chunk-Z2WQB55R.js');
16
13
 
14
+
15
+ var _chunkZHOESZRMjs = require('./chunk-ZHOESZRM.js');
16
+
17
17
  // src/generators/worker/generator.ts
18
18
 
19
19
 
@@ -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 _chunkGG44TH3Kjs.generator_default.call(void 0, tree, {
69
+ await _chunkZHOESZRMjs.generator_default.call(void 0, tree, {
70
70
  ...options,
71
71
  skipFormat: true
72
72
  })
@@ -1,11 +1,11 @@
1
- import {
2
- getInternalDependencies,
3
- r2UploadFile
4
- } from "./chunk-5CMG7SUH.mjs";
5
1
  import {
6
2
  createCliOptions,
7
3
  getPackageInfo
8
4
  } from "./chunk-3MAI3FU2.mjs";
5
+ import {
6
+ getInternalDependencies,
7
+ r2UploadFile
8
+ } from "./chunk-5CMG7SUH.mjs";
9
9
  import {
10
10
  findWorkspaceRoot,
11
11
  getConfig
@@ -34,6 +34,9 @@ async function runExecutor(options, context) {
34
34
  if (!context.projectName) {
35
35
  throw new Error("The executor requires a projectName.");
36
36
  }
37
+ if (!options.path) {
38
+ throw new Error("The executor requires the `path` option to upload.");
39
+ }
37
40
  console.info(
38
41
  `\u{1F680} Running Storm Cloudflare Publish executor on the ${context.projectName} worker`
39
42
  );
@@ -43,7 +46,6 @@ async function runExecutor(options, context) {
43
46
  try {
44
47
  const workspaceRoot = findWorkspaceRoot();
45
48
  const config = await getConfig(workspaceRoot);
46
- const sourceRoot = context.projectsConfigurations.projects[context.projectName]?.sourceRoot ?? workspaceRoot;
47
49
  const projectName = context.projectsConfigurations.projects[context.projectName]?.name ?? context.projectName;
48
50
  const projectDetails = getPackageInfo(
49
51
  context.projectsConfigurations.projects[context.projectName]
@@ -60,12 +62,12 @@ async function runExecutor(options, context) {
60
62
  const cloudflareAccountId = process.env.CLOUDFLARE_ACCOUNT_ID || process.env.STORM_BOT_CLOUDFLARE_ACCOUNT;
61
63
  if (!options?.registry && !cloudflareAccountId) {
62
64
  throw new Error(
63
- "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."
65
+ "The registry option and `CLOUDFLARE_ACCOUNT_ID` (or `STORM_BOT_CLOUDFLARE_ACCOUNT`) environment variable are not set. Please set one of these values to upload to the Cloudflare R2 bucket."
64
66
  );
65
67
  }
66
68
  if (!process.env.STORM_BOT_ACCESS_KEY_ID && !process.env.ACCESS_KEY_ID && !process.env.CLOUDFLARE_ACCESS_KEY_ID && !process.env.AWS_ACCESS_KEY_ID || !process.env.STORM_BOT_SECRET_ACCESS_KEY && !process.env.CLOUDFLARE_SECRET_ACCESS_KEY && !process.env.SECRET_ACCESS_KEY && !process.env.AWS_SECRET_ACCESS_KEY) {
67
69
  throw new Error(
68
- "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."
70
+ "The `ACCESS_KEY_ID` (or `STORM_BOT_ACCESS_KEY_ID`) and `SECRET_ACCESS_KEY` (or `STORM_BOT_SECRET_ACCESS_KEY`) environment variables are not set. Please set these environment variables to upload to the Cloudflare R2 bucket."
69
71
  );
70
72
  }
71
73
  const registry = options?.registry ? options.registry : `https://${cloudflareAccountId}.r2.cloudflarestorage.com`;
@@ -98,7 +100,7 @@ async function runExecutor(options, context) {
98
100
  if (version) {
99
101
  writeDebug(`Starting upload version ${version}`);
100
102
  }
101
- const basePath = options.path || sourceRoot;
103
+ const basePath = options.path;
102
104
  const files = await glob(joinPaths(basePath, "**/*"), {
103
105
  ignore: "**/{*.stories.tsx,*.stories.ts,*.spec.tsx,*.spec.ts}"
104
106
  });
@@ -1,6 +1,3 @@
1
- import {
2
- generator_default
3
- } from "./chunk-NRILXPPG.mjs";
4
1
  import {
5
2
  findWorkspaceRoot,
6
3
  getConfig
@@ -13,6 +10,9 @@ import {
13
10
  writeInfo,
14
11
  writeTrace
15
12
  } from "./chunk-TPNHSNNZ.mjs";
13
+ import {
14
+ generator_default
15
+ } from "./chunk-O2OONDQ5.mjs";
16
16
  import {
17
17
  __dirname
18
18
  } from "./chunk-TYYFTZLS.mjs";
@@ -0,0 +1,223 @@
1
+ import {
2
+ getInternalDependencies,
3
+ r2UploadFile
4
+ } from "./chunk-5CMG7SUH.mjs";
5
+ import {
6
+ createCliOptions,
7
+ getPackageInfo
8
+ } from "./chunk-3MAI3FU2.mjs";
9
+ import {
10
+ findWorkspaceRoot,
11
+ getConfig
12
+ } from "./chunk-SGTAZO2Q.mjs";
13
+ import {
14
+ correctPaths,
15
+ joinPaths,
16
+ writeDebug,
17
+ writeSuccess,
18
+ writeTrace,
19
+ writeWarning
20
+ } from "./chunk-TPNHSNNZ.mjs";
21
+
22
+ // src/executors/r2-upload-publish/executor.ts
23
+ import { S3 } from "@aws-sdk/client-s3";
24
+ import {
25
+ createProjectGraphAsync,
26
+ readCachedProjectGraph
27
+ } from "@nx/devkit";
28
+ import { glob } from "glob";
29
+ import mime from "mime-types";
30
+ import { execSync } from "node:child_process";
31
+ import { readFile } from "node:fs/promises";
32
+ async function runExecutor(options, context) {
33
+ const isDryRun = process.env.NX_DRY_RUN === "true" || options.dryRun || false;
34
+ if (!context.projectName) {
35
+ throw new Error("The executor requires a projectName.");
36
+ }
37
+ if (!options.path) {
38
+ throw new Error("The executor requires the `path` option to upload.");
39
+ }
40
+ console.info(
41
+ `\u{1F680} Running Storm Cloudflare Publish executor on the ${context.projectName} worker`
42
+ );
43
+ if (!context.projectName || !context.projectsConfigurations?.projects || !context.projectsConfigurations.projects[context.projectName] || !context.projectsConfigurations.projects[context.projectName]?.root) {
44
+ throw new Error("The executor requires projectsConfigurations.");
45
+ }
46
+ try {
47
+ const workspaceRoot = findWorkspaceRoot();
48
+ const config = await getConfig(workspaceRoot);
49
+ const projectName = context.projectsConfigurations.projects[context.projectName]?.name ?? context.projectName;
50
+ const projectDetails = getPackageInfo(
51
+ context.projectsConfigurations.projects[context.projectName]
52
+ );
53
+ const bucketId = options.bucketId;
54
+ const bucketPath = options.bucketPath || "/";
55
+ if (!bucketId) {
56
+ throw new Error("The executor requires a bucketId.");
57
+ }
58
+ const args = createCliOptions({ ...options });
59
+ if (isDryRun) {
60
+ args.push("--dry-run");
61
+ }
62
+ const cloudflareAccountId = process.env.CLOUDFLARE_ACCOUNT_ID || process.env.STORM_BOT_CLOUDFLARE_ACCOUNT;
63
+ if (!options?.registry && !cloudflareAccountId) {
64
+ throw new Error(
65
+ "The registry option and `CLOUDFLARE_ACCOUNT_ID` (or `STORM_BOT_CLOUDFLARE_ACCOUNT`) environment variable are not set. Please set one of these values to upload to the Cloudflare R2 bucket."
66
+ );
67
+ }
68
+ if (!process.env.STORM_BOT_ACCESS_KEY_ID && !process.env.ACCESS_KEY_ID && !process.env.CLOUDFLARE_ACCESS_KEY_ID && !process.env.AWS_ACCESS_KEY_ID || !process.env.STORM_BOT_SECRET_ACCESS_KEY && !process.env.CLOUDFLARE_SECRET_ACCESS_KEY && !process.env.SECRET_ACCESS_KEY && !process.env.AWS_SECRET_ACCESS_KEY) {
69
+ throw new Error(
70
+ "The `ACCESS_KEY_ID` (or `STORM_BOT_ACCESS_KEY_ID`) and `SECRET_ACCESS_KEY` (or `STORM_BOT_SECRET_ACCESS_KEY`) environment variables are not set. Please set these environment variables to upload to the Cloudflare R2 bucket."
71
+ );
72
+ }
73
+ const registry = options?.registry ? options.registry : `https://${cloudflareAccountId}.r2.cloudflarestorage.com`;
74
+ let projectGraph;
75
+ try {
76
+ projectGraph = readCachedProjectGraph();
77
+ } catch {
78
+ await createProjectGraphAsync();
79
+ projectGraph = readCachedProjectGraph();
80
+ }
81
+ if (!projectGraph) {
82
+ throw new Error(
83
+ "The executor failed because the project graph is not available. Please run the build command again."
84
+ );
85
+ }
86
+ writeDebug(
87
+ `Publishing ${context.projectName} to the ${bucketId} R2 Bucket (at ${registry})`
88
+ );
89
+ const client = new S3({
90
+ region: "auto",
91
+ endpoint: registry,
92
+ credentials: {
93
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
94
+ accessKeyId: process.env.STORM_BOT_ACCESS_KEY_ID || process.env.CLOUDFLARE_ACCESS_KEY_ID || process.env.AWS_ACCESS_KEY_ID || process.env.ACCESS_KEY_ID,
95
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
96
+ secretAccessKey: process.env.STORM_BOT_SECRET_ACCESS_KEY || process.env.CLOUDFLARE_SECRET_ACCESS_KEY || process.env.AWS_SECRET_ACCESS_KEY || process.env.SECRET_ACCESS_KEY
97
+ }
98
+ });
99
+ const version = projectDetails?.content?.version;
100
+ if (version) {
101
+ writeDebug(`Starting upload version ${version}`);
102
+ }
103
+ const basePath = options.path;
104
+ const files = await glob(joinPaths(basePath, "**/*"), {
105
+ ignore: "**/{*.stories.tsx,*.stories.ts,*.spec.tsx,*.spec.ts}"
106
+ });
107
+ const internalDependencies = await getInternalDependencies(
108
+ context.projectName,
109
+ projectGraph
110
+ );
111
+ const dependencies = internalDependencies.filter(
112
+ (projectNode) => !projectNode.data.tags || projectNode.data.tags.every((tag) => tag.toLowerCase() !== "component")
113
+ ).reduce((ret, dep) => {
114
+ if (!ret[dep.name]) {
115
+ ret[dep.name] = "latest";
116
+ }
117
+ return ret;
118
+ }, projectDetails?.content.dependencies ?? {});
119
+ const release = options.tag ?? execSync("npm config get tag").toString().trim();
120
+ if (options.clean === true) {
121
+ writeDebug(`Clearing out existing items in ${bucketPath}`);
122
+ if (!isDryRun) {
123
+ const response = await client.listObjects({
124
+ Bucket: bucketId,
125
+ Prefix: bucketPath
126
+ });
127
+ if (response?.Contents && response.Contents.length > 0) {
128
+ writeTrace(
129
+ `Deleting the following existing items from the R2 bucket path ${bucketPath}: ${response.Contents.map((item) => item.Key).join(", ")}`
130
+ );
131
+ await Promise.all(
132
+ response.Contents.map(
133
+ (item) => client.deleteObjects({
134
+ Bucket: bucketId,
135
+ Delete: {
136
+ Objects: [
137
+ {
138
+ Key: item.Key
139
+ }
140
+ ],
141
+ Quiet: false
142
+ }
143
+ })
144
+ )
145
+ );
146
+ } else {
147
+ writeDebug(
148
+ `No existing items to delete in the R2 bucket path ${bucketPath}`
149
+ );
150
+ }
151
+ } else {
152
+ writeWarning("[Dry run]: Skipping R2 bucket clean.");
153
+ }
154
+ }
155
+ if (options.writeMetaJson === true) {
156
+ const meta = {
157
+ name: context.projectName,
158
+ version,
159
+ release,
160
+ description: projectDetails?.content?.description,
161
+ tags: projectDetails?.content?.keywords,
162
+ dependencies,
163
+ devDependencies: null,
164
+ internalDependencies: internalDependencies.filter(
165
+ (projectNode) => projectNode.data.tags && projectNode.data.tags.some(
166
+ (tag) => tag.toLowerCase() === "component"
167
+ )
168
+ ).map((dep) => dep.name)
169
+ };
170
+ if (projectDetails?.type === "package.json") {
171
+ meta.devDependencies = projectDetails?.content?.devDependencies;
172
+ }
173
+ const metaJson = JSON.stringify(meta);
174
+ writeTrace(`Generating meta.json file:
175
+ ${metaJson}`);
176
+ await r2UploadFile(
177
+ client,
178
+ bucketId,
179
+ bucketPath,
180
+ "meta.json",
181
+ version,
182
+ metaJson,
183
+ "application/json",
184
+ isDryRun
185
+ );
186
+ }
187
+ await Promise.all(
188
+ files.map(async (file) => {
189
+ const name = correctPaths(file).replace(correctPaths(basePath), "");
190
+ const type = mime.lookup(name) || "application/octet-stream";
191
+ writeTrace(`Uploading file: ${name} (content-type: ${type})`);
192
+ await r2UploadFile(
193
+ client,
194
+ bucketId,
195
+ bucketPath,
196
+ name,
197
+ version,
198
+ await readFile(file, { encoding: "utf8" }),
199
+ type,
200
+ isDryRun
201
+ );
202
+ })
203
+ );
204
+ writeSuccess(
205
+ `Successfully uploaded the ${projectName} project to the Cloudflare R2 bucket.`,
206
+ config
207
+ );
208
+ return {
209
+ success: true
210
+ };
211
+ } catch (error) {
212
+ console.error("Failed to publish to Cloudflare R2 bucket");
213
+ console.error(error);
214
+ console.log("");
215
+ return {
216
+ success: false
217
+ };
218
+ }
219
+ }
220
+
221
+ export {
222
+ runExecutor
223
+ };
@@ -7,7 +7,7 @@ var require_package = __commonJS({
7
7
  "package.json"(exports, module) {
8
8
  module.exports = {
9
9
  name: "@storm-software/cloudflare-tools",
10
- version: "0.71.9",
10
+ version: "0.71.10",
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.59",
140
- "@storm-software/config-tools": "1.188.59",
141
- "@storm-software/workspace-tools": "1.294.3",
139
+ "@storm-software/config": "1.134.60",
140
+ "@storm-software/config-tools": "1.188.60",
141
+ "@storm-software/workspace-tools": "1.294.4",
142
142
  nx: "catalog:",
143
143
  tsup: "catalog:",
144
144
  wrangler: ">=3.58.0"
@@ -0,0 +1,265 @@
1
+ import {
2
+ generator_default
3
+ } from "./chunk-O2OONDQ5.mjs";
4
+ import {
5
+ findWorkspaceRoot,
6
+ getConfig
7
+ } from "./chunk-SGTAZO2Q.mjs";
8
+ import {
9
+ getStopwatch,
10
+ writeDebug,
11
+ writeError,
12
+ writeFatal,
13
+ writeInfo,
14
+ writeTrace
15
+ } from "./chunk-TPNHSNNZ.mjs";
16
+ import {
17
+ __dirname
18
+ } from "./chunk-TYYFTZLS.mjs";
19
+
20
+ // src/generators/worker/generator.ts
21
+ import {
22
+ convertNxGenerator,
23
+ ensurePackage,
24
+ formatFiles,
25
+ generateFiles,
26
+ joinPathFragments,
27
+ names,
28
+ readProjectConfiguration,
29
+ runTasksInSerial,
30
+ updateJson,
31
+ updateProjectConfiguration
32
+ } from "@nx/devkit";
33
+ import { determineProjectNameAndRootOptions } from "@nx/devkit/src/generators/project-name-and-root-utils";
34
+ import { applicationGenerator as nodeApplicationGenerator } from "@nx/node";
35
+ import { nxVersion } from "@nx/node/src/utils/versions";
36
+ import { join } from "path";
37
+
38
+ // src/generators/worker/libs/get-account-id.ts
39
+ function getAccountId(accountId) {
40
+ return `account_id = "${accountId}"`;
41
+ }
42
+
43
+ // src/generators/worker/libs/vitest-imports.ts
44
+ var vitestImports = `import { describe, expect, it, beforeAll, afterAll } from 'vitest';`;
45
+
46
+ // src/generators/worker/libs/vitest-script.ts
47
+ var vitestScript = `"test": "vitest run"`;
48
+
49
+ // src/generators/worker/generator.ts
50
+ async function applicationGenerator(tree, schema) {
51
+ const stopwatch = getStopwatch("Storm Worker generator");
52
+ let config;
53
+ try {
54
+ writeInfo(`\u26A1 Running the Storm Worker generator...
55
+
56
+ `, config);
57
+ const workspaceRoot = findWorkspaceRoot();
58
+ writeDebug(
59
+ `Loading the Storm Config from environment variables and storm.json file...
60
+ - workspaceRoot: ${workspaceRoot}`,
61
+ config
62
+ );
63
+ config = await getConfig(workspaceRoot);
64
+ writeTrace(
65
+ `Loaded Storm config into env:
66
+ ${Object.keys(process.env).map((key) => ` - ${key}=${JSON.stringify(process.env[key])}`).join("\n")}`,
67
+ config
68
+ );
69
+ const options = await normalizeOptions(tree, schema, config);
70
+ const tasks = [];
71
+ tasks.push(
72
+ await generator_default(tree, {
73
+ ...options,
74
+ skipFormat: true
75
+ })
76
+ );
77
+ tasks.push(
78
+ await nodeApplicationGenerator(tree, {
79
+ ...options,
80
+ framework: "none",
81
+ skipFormat: true,
82
+ unitTestRunner: options.unitTestRunner == "vitest" ? "none" : options.unitTestRunner,
83
+ e2eTestRunner: "none",
84
+ name: schema.name
85
+ })
86
+ );
87
+ if (options.unitTestRunner === "vitest") {
88
+ const { vitestGenerator, createOrEditViteConfig } = ensurePackage(
89
+ "@nx/vite",
90
+ nxVersion
91
+ );
92
+ const vitestTask = await vitestGenerator(tree, {
93
+ project: options.name,
94
+ uiFramework: "none",
95
+ coverageProvider: "v8",
96
+ skipFormat: true,
97
+ testEnvironment: "node"
98
+ });
99
+ tasks.push(vitestTask);
100
+ createOrEditViteConfig(
101
+ tree,
102
+ {
103
+ project: options.name,
104
+ includeLib: false,
105
+ includeVitest: true,
106
+ testEnvironment: "node"
107
+ },
108
+ true
109
+ );
110
+ }
111
+ addCloudflareFiles(tree, options);
112
+ updateTsAppConfig(tree, options);
113
+ addTargets(tree, options);
114
+ if (options.unitTestRunner === "none") {
115
+ removeTestFiles(tree, options);
116
+ }
117
+ if (!options.skipFormat) {
118
+ await formatFiles(tree);
119
+ }
120
+ if (options.template === "hono") {
121
+ tasks.push(() => {
122
+ const packageJsonPath = joinPathFragments(
123
+ options.directory ?? "",
124
+ "package.json"
125
+ );
126
+ if (tree.exists(packageJsonPath)) {
127
+ updateJson(tree, packageJsonPath, (json) => ({
128
+ ...json,
129
+ dependencies: {
130
+ hono: "4.4.0",
131
+ ...json?.dependencies
132
+ }
133
+ }));
134
+ }
135
+ });
136
+ }
137
+ return runTasksInSerial(...tasks);
138
+ } catch (error) {
139
+ return () => {
140
+ writeFatal(
141
+ "A fatal error occurred while running the generator - the process was forced to terminate",
142
+ config
143
+ );
144
+ writeError(
145
+ `An exception was thrown in the generator's process
146
+ - Details: ${error.message}
147
+ - Stacktrace: ${error.stack}`,
148
+ config
149
+ );
150
+ };
151
+ } finally {
152
+ stopwatch();
153
+ }
154
+ }
155
+ function updateTsAppConfig(tree, options) {
156
+ updateJson(tree, join(options.appProjectRoot, "tsconfig.app.json"), (json) => {
157
+ json.compilerOptions = {
158
+ ...json.compilerOptions,
159
+ esModuleInterop: true,
160
+ target: "es2021",
161
+ lib: ["es2021"],
162
+ module: "es2022",
163
+ moduleResolution: "node",
164
+ resolveJsonModule: true,
165
+ allowJs: true,
166
+ checkJs: false,
167
+ noEmit: true,
168
+ isolatedModules: true,
169
+ allowSyntheticDefaultImports: true,
170
+ forceConsistentCasingInFileNames: true,
171
+ strict: true,
172
+ skipLibCheck: true
173
+ };
174
+ json.compilerOptions.types = [
175
+ ...json.compilerOptions.types,
176
+ "@cloudflare/workers-types"
177
+ ];
178
+ return json;
179
+ });
180
+ }
181
+ function addCloudflareFiles(tree, options) {
182
+ tree.delete(join(options.appProjectRoot, "src/main.ts"));
183
+ generateFiles(
184
+ tree,
185
+ join(__dirname, "./files/common"),
186
+ options.appProjectRoot,
187
+ {
188
+ ...options,
189
+ tmpl: "",
190
+ name: options.name,
191
+ accountId: options.accountId ? getAccountId(options.accountId) : "",
192
+ vitestScript: options.unitTestRunner === "vitest" ? vitestScript : ""
193
+ }
194
+ );
195
+ if (options.template && options.template !== "none") {
196
+ generateFiles(
197
+ tree,
198
+ join(__dirname, `./files/${options.template}`),
199
+ join(options.appProjectRoot, "src"),
200
+ {
201
+ ...options,
202
+ tmpl: "",
203
+ name: options.name,
204
+ accountId: options.accountId ? getAccountId(options.accountId) : "",
205
+ vitestScript: options.unitTestRunner === "vitest" ? vitestScript : "",
206
+ vitestImports: options.unitTestRunner === "vitest" ? vitestImports : ""
207
+ }
208
+ );
209
+ }
210
+ }
211
+ function addTargets(tree, options) {
212
+ try {
213
+ const projectConfiguration = readProjectConfiguration(tree, options.name);
214
+ projectConfiguration.targets = {
215
+ ...projectConfiguration.targets ?? {},
216
+ serve: {
217
+ executor: "@storm-software/cloudflare-tools:serve",
218
+ options: {
219
+ port: options.port
220
+ }
221
+ },
222
+ "nx-release-publish": {
223
+ executor: "@storm-software/cloudflare-tools:cloudflare-publish"
224
+ }
225
+ };
226
+ if (projectConfiguration.targets.build) {
227
+ delete projectConfiguration.targets.build;
228
+ }
229
+ updateProjectConfiguration(tree, options.name, projectConfiguration);
230
+ } catch (e) {
231
+ console.error(e);
232
+ }
233
+ }
234
+ function removeTestFiles(tree, options) {
235
+ tree.delete(join(options.appProjectRoot, "src", "index.test.ts"));
236
+ }
237
+ async function normalizeOptions(host, options, config) {
238
+ const { projectName: appProjectName, projectRoot: appProjectRoot } = await determineProjectNameAndRootOptions(host, {
239
+ name: options.name,
240
+ projectType: "application",
241
+ directory: options.directory,
242
+ rootProject: options.rootProject
243
+ });
244
+ options.rootProject = appProjectRoot === ".";
245
+ return {
246
+ addPlugin: process.env.NX_ADD_PLUGINS !== "false",
247
+ accountId: process.env.STORM_BOT_CLOUDFLARE_ACCOUNT,
248
+ ...options,
249
+ name: names(appProjectName).fileName,
250
+ frontendProject: options.frontendProject ? names(options.frontendProject).fileName : void 0,
251
+ appProjectRoot,
252
+ unitTestRunner: options.unitTestRunner ?? "vitest",
253
+ rootProject: options.rootProject ?? false,
254
+ template: options.template ?? "fetch-handler",
255
+ port: options.port ?? 3e3
256
+ };
257
+ }
258
+ var generator_default2 = applicationGenerator;
259
+ var applicationSchematic = convertNxGenerator(applicationGenerator);
260
+
261
+ export {
262
+ applicationGenerator,
263
+ generator_default2 as generator_default,
264
+ applicationSchematic
265
+ };