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