@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
|
@@ -0,0 +1,219 @@
|
|
|
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 _chunkN7FW365Qjs = require('./chunk-N7FW365Q.js');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
var _chunkUAKLE2QOjs = require('./chunk-UAKLE2QO.js');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
var _chunkVKMAYBQXjs = require('./chunk-VKMAYBQX.js');
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
var _chunkZ2WQB55Rjs = require('./chunk-Z2WQB55R.js');
|
|
21
|
+
|
|
22
|
+
// src/executors/r2-upload-publish/executor.ts
|
|
23
|
+
var _clients3 = require('@aws-sdk/client-s3');
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
var _devkit = require('@nx/devkit');
|
|
28
|
+
var _glob = require('glob');
|
|
29
|
+
var _mimetypes = require('mime-types'); var _mimetypes2 = _interopRequireDefault(_mimetypes);
|
|
30
|
+
var _child_process = require('child_process');
|
|
31
|
+
var _promises = require('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 || !_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])) {
|
|
41
|
+
throw new Error("The executor requires projectsConfigurations.");
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
const workspaceRoot = _chunkVKMAYBQXjs.findWorkspaceRoot.call(void 0, );
|
|
45
|
+
const config = await _chunkVKMAYBQXjs.getConfig.call(void 0, workspaceRoot);
|
|
46
|
+
const sourceRoot = _nullishCoalesce(_optionalChain([context, 'access', _7 => _7.projectsConfigurations, 'access', _8 => _8.projects, 'access', _9 => _9[context.projectName], 'optionalAccess', _10 => _10.sourceRoot]), () => ( workspaceRoot));
|
|
47
|
+
const projectName = _nullishCoalesce(_optionalChain([context, 'access', _11 => _11.projectsConfigurations, 'access', _12 => _12.projects, 'access', _13 => _13[context.projectName], 'optionalAccess', _14 => _14.name]), () => ( context.projectName));
|
|
48
|
+
const projectDetails = _chunkN7FW365Qjs.getPackageInfo.call(void 0,
|
|
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 = _chunkN7FW365Qjs.createCliOptions.call(void 0, { ...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 (!_optionalChain([options, 'optionalAccess', _15 => _15.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 = _optionalChain([options, 'optionalAccess', _16 => _16.registry]) ? options.registry : `https://${cloudflareAccountId}.r2.cloudflarestorage.com`;
|
|
72
|
+
let projectGraph;
|
|
73
|
+
try {
|
|
74
|
+
projectGraph = _devkit.readCachedProjectGraph.call(void 0, );
|
|
75
|
+
} catch (e) {
|
|
76
|
+
await _devkit.createProjectGraphAsync.call(void 0, );
|
|
77
|
+
projectGraph = _devkit.readCachedProjectGraph.call(void 0, );
|
|
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
|
+
_chunkZ2WQB55Rjs.writeDebug.call(void 0,
|
|
85
|
+
`Publishing ${context.projectName} to the ${bucketId} R2 Bucket (at ${registry})`
|
|
86
|
+
);
|
|
87
|
+
const client = new (0, _clients3.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 = _optionalChain([projectDetails, 'optionalAccess', _17 => _17.content, 'optionalAccess', _18 => _18.version]);
|
|
96
|
+
if (version) {
|
|
97
|
+
_chunkZ2WQB55Rjs.writeDebug.call(void 0, `Starting upload version ${version}`);
|
|
98
|
+
}
|
|
99
|
+
const basePath = options.path || sourceRoot;
|
|
100
|
+
const files = await _glob.glob.call(void 0, _chunkZ2WQB55Rjs.joinPaths.call(void 0, basePath, "**/*"), {
|
|
101
|
+
ignore: "**/{*.stories.tsx,*.stories.ts,*.spec.tsx,*.spec.ts}"
|
|
102
|
+
});
|
|
103
|
+
const internalDependencies = await _chunkUAKLE2QOjs.getInternalDependencies.call(void 0,
|
|
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
|
+
}, _nullishCoalesce(_optionalChain([projectDetails, 'optionalAccess', _19 => _19.content, 'access', _20 => _20.dependencies]), () => ( {})));
|
|
115
|
+
const release = _nullishCoalesce(options.tag, () => ( _child_process.execSync.call(void 0, "npm config get tag").toString().trim()));
|
|
116
|
+
if (options.clean === true) {
|
|
117
|
+
_chunkZ2WQB55Rjs.writeDebug.call(void 0, `Clearing out existing items in ${bucketPath}`);
|
|
118
|
+
if (!isDryRun) {
|
|
119
|
+
const response = await client.listObjects({
|
|
120
|
+
Bucket: bucketId,
|
|
121
|
+
Prefix: bucketPath
|
|
122
|
+
});
|
|
123
|
+
if (_optionalChain([response, 'optionalAccess', _21 => _21.Contents]) && response.Contents.length > 0) {
|
|
124
|
+
_chunkZ2WQB55Rjs.writeTrace.call(void 0,
|
|
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
|
+
_chunkZ2WQB55Rjs.writeDebug.call(void 0,
|
|
144
|
+
`No existing items to delete in the R2 bucket path ${bucketPath}`
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
} else {
|
|
148
|
+
_chunkZ2WQB55Rjs.writeWarning.call(void 0, "[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: _optionalChain([projectDetails, 'optionalAccess', _22 => _22.content, 'optionalAccess', _23 => _23.description]),
|
|
157
|
+
tags: _optionalChain([projectDetails, 'optionalAccess', _24 => _24.content, 'optionalAccess', _25 => _25.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 (_optionalChain([projectDetails, 'optionalAccess', _26 => _26.type]) === "package.json") {
|
|
167
|
+
meta.devDependencies = _optionalChain([projectDetails, 'optionalAccess', _27 => _27.content, 'optionalAccess', _28 => _28.devDependencies]);
|
|
168
|
+
}
|
|
169
|
+
const metaJson = JSON.stringify(meta);
|
|
170
|
+
_chunkZ2WQB55Rjs.writeTrace.call(void 0, `Generating meta.json file:
|
|
171
|
+
${metaJson}`);
|
|
172
|
+
await _chunkUAKLE2QOjs.r2UploadFile.call(void 0,
|
|
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 = _chunkZ2WQB55Rjs.correctPaths.call(void 0, file).replace(_chunkZ2WQB55Rjs.correctPaths.call(void 0, basePath), "");
|
|
186
|
+
const type = _mimetypes2.default.lookup(name) || "application/octet-stream";
|
|
187
|
+
_chunkZ2WQB55Rjs.writeTrace.call(void 0, `Uploading file: ${name} (content-type: ${type})`);
|
|
188
|
+
await _chunkUAKLE2QOjs.r2UploadFile.call(void 0,
|
|
189
|
+
client,
|
|
190
|
+
bucketId,
|
|
191
|
+
bucketPath,
|
|
192
|
+
name,
|
|
193
|
+
version,
|
|
194
|
+
await _promises.readFile.call(void 0, file, { encoding: "utf8" }),
|
|
195
|
+
type,
|
|
196
|
+
isDryRun
|
|
197
|
+
);
|
|
198
|
+
})
|
|
199
|
+
);
|
|
200
|
+
_chunkZ2WQB55Rjs.writeSuccess.call(void 0,
|
|
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
|
+
|
|
218
|
+
|
|
219
|
+
exports.runExecutor = runExecutor;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
generator_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-QRMW3ECS.mjs";
|
|
4
4
|
import {
|
|
5
5
|
findWorkspaceRoot,
|
|
6
6
|
getConfig
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
} from "./chunk-TPNHSNNZ.mjs";
|
|
16
16
|
import {
|
|
17
17
|
__dirname
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-TYYFTZLS.mjs";
|
|
19
19
|
|
|
20
20
|
// src/generators/worker/generator.ts
|
|
21
21
|
import {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__commonJS
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-TYYFTZLS.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.71.
|
|
10
|
+
version: "0.71.7",
|
|
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.
|
|
140
|
-
"@storm-software/config-tools": "1.188.
|
|
141
|
-
"@storm-software/workspace-tools": "1.
|
|
139
|
+
"@storm-software/config": "1.134.57",
|
|
140
|
+
"@storm-software/config-tools": "1.188.57",
|
|
141
|
+
"@storm-software/workspace-tools": "1.294.1",
|
|
142
142
|
nx: "catalog:",
|
|
143
143
|
tsup: "catalog:",
|
|
144
144
|
wrangler: ">=3.58.0"
|
|
@@ -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=
|
|
12
|
+
// ../../node_modules/.pnpm/tsup@8.4.0_patch_hash=751a554d775c3572381af4e7e5fa22eeda6dd6856012fb1cf521d6806eb2dc74__c3e4998479ad18f48a2d876d2ab799a7/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);
|
|
@@ -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.71.
|
|
10
|
+
version: "0.71.7",
|
|
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.
|
|
140
|
-
"@storm-software/config-tools": "1.188.
|
|
141
|
-
"@storm-software/workspace-tools": "1.
|
|
139
|
+
"@storm-software/config": "1.134.57",
|
|
140
|
+
"@storm-software/config-tools": "1.188.57",
|
|
141
|
+
"@storm-software/workspace-tools": "1.294.1",
|
|
142
142
|
nx: "catalog:",
|
|
143
143
|
tsup: "catalog:",
|
|
144
144
|
wrangler: ">=3.58.0"
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import {
|
|
2
|
+
findWorkspaceRoot,
|
|
3
|
+
getConfig
|
|
4
|
+
} from "./chunk-SGTAZO2Q.mjs";
|
|
5
|
+
import {
|
|
6
|
+
getStopwatch,
|
|
7
|
+
writeDebug,
|
|
8
|
+
writeError,
|
|
9
|
+
writeFatal,
|
|
10
|
+
writeInfo,
|
|
11
|
+
writeTrace
|
|
12
|
+
} from "./chunk-TPNHSNNZ.mjs";
|
|
13
|
+
import {
|
|
14
|
+
generator_default
|
|
15
|
+
} from "./chunk-QRMW3ECS.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
|
+
};
|
package/dist/executors.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "./chunk-YSCEY447.mjs";
|
|
2
|
-
import "./chunk-
|
|
3
|
-
import "./chunk-
|
|
2
|
+
import "./chunk-F6FHDDUJ.mjs";
|
|
3
|
+
import "./chunk-FWIGE74R.mjs";
|
|
4
4
|
import "./chunk-WSBHUYOP.mjs";
|
|
5
5
|
import "./chunk-5CMG7SUH.mjs";
|
|
6
6
|
import "./chunk-3MAI3FU2.mjs";
|
|
7
7
|
import "./chunk-SGTAZO2Q.mjs";
|
|
8
8
|
import "./chunk-TPNHSNNZ.mjs";
|
|
9
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-TYYFTZLS.mjs";
|
package/dist/generators.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkH5H4H2SOjs = require('./chunk-H5H4H2SO.js');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkVNUNYZX4js = require('./chunk-VNUNYZX4.js');
|
|
10
10
|
require('./chunk-VKMAYBQX.js');
|
|
11
11
|
require('./chunk-Z2WQB55R.js');
|
|
12
12
|
require('./chunk-MCKGQKYU.js');
|
|
@@ -15,4 +15,4 @@ require('./chunk-MCKGQKYU.js');
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
exports.applicationGenerator =
|
|
18
|
+
exports.applicationGenerator = _chunkH5H4H2SOjs.applicationGenerator; exports.applicationSchematic = _chunkH5H4H2SOjs.applicationSchematic; exports.initGenerator = _chunkVNUNYZX4js.initGenerator; exports.initSchematic = _chunkVNUNYZX4js.initSchematic;
|
package/dist/generators.mjs
CHANGED
|
@@ -2,14 +2,14 @@ import "./chunk-3J7KBHMJ.mjs";
|
|
|
2
2
|
import {
|
|
3
3
|
applicationGenerator,
|
|
4
4
|
applicationSchematic
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-QDPNOX6S.mjs";
|
|
6
6
|
import {
|
|
7
7
|
initGenerator,
|
|
8
8
|
initSchematic
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-QRMW3ECS.mjs";
|
|
10
10
|
import "./chunk-SGTAZO2Q.mjs";
|
|
11
11
|
import "./chunk-TPNHSNNZ.mjs";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-TYYFTZLS.mjs";
|
|
13
13
|
export {
|
|
14
14
|
applicationGenerator,
|
|
15
15
|
applicationSchematic,
|
package/dist/index.js
CHANGED
|
@@ -3,11 +3,11 @@ require('./chunk-DHBG5ASJ.js');
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkH5H4H2SOjs = require('./chunk-H5H4H2SO.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkVNUNYZX4js = require('./chunk-VNUNYZX4.js');
|
|
11
11
|
require('./chunk-CVGPWUNP.js');
|
|
12
12
|
require('./chunk-QBD2OGUY.js');
|
|
13
13
|
require('./chunk-J5JJZJO5.js');
|
|
@@ -155,4 +155,4 @@ function createPackageJson(projectJsonPath, workspaceRoot) {
|
|
|
155
155
|
|
|
156
156
|
|
|
157
157
|
|
|
158
|
-
exports.applicationGenerator =
|
|
158
|
+
exports.applicationGenerator = _chunkH5H4H2SOjs.applicationGenerator; exports.applicationSchematic = _chunkH5H4H2SOjs.applicationSchematic; exports.createNodesV2 = createNodesV2; exports.getInternalDependencies = _chunkUAKLE2QOjs.getInternalDependencies; exports.initGenerator = _chunkVNUNYZX4js.initGenerator; exports.initSchematic = _chunkVNUNYZX4js.initSchematic; exports.name = name; exports.r2UploadFile = _chunkUAKLE2QOjs.r2UploadFile;
|
package/dist/index.mjs
CHANGED
|
@@ -3,14 +3,14 @@ import "./chunk-3J7KBHMJ.mjs";
|
|
|
3
3
|
import {
|
|
4
4
|
applicationGenerator,
|
|
5
5
|
applicationSchematic
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-QDPNOX6S.mjs";
|
|
7
7
|
import {
|
|
8
8
|
initGenerator,
|
|
9
9
|
initSchematic
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-QRMW3ECS.mjs";
|
|
11
11
|
import "./chunk-7Z5PILRU.mjs";
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-F6FHDDUJ.mjs";
|
|
13
|
+
import "./chunk-FWIGE74R.mjs";
|
|
14
14
|
import "./chunk-WSBHUYOP.mjs";
|
|
15
15
|
import {
|
|
16
16
|
getInternalDependencies,
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
} from "./chunk-3MAI3FU2.mjs";
|
|
23
23
|
import "./chunk-SGTAZO2Q.mjs";
|
|
24
24
|
import "./chunk-TPNHSNNZ.mjs";
|
|
25
|
-
import "./chunk-
|
|
25
|
+
import "./chunk-TYYFTZLS.mjs";
|
|
26
26
|
|
|
27
27
|
// src/plugins/index.ts
|
|
28
28
|
import {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runExecutor
|
|
3
|
-
} from "../../../chunk-
|
|
4
|
-
import "../../../chunk-
|
|
3
|
+
} from "../../../chunk-F6FHDDUJ.mjs";
|
|
4
|
+
import "../../../chunk-FWIGE74R.mjs";
|
|
5
5
|
import "../../../chunk-3MAI3FU2.mjs";
|
|
6
6
|
import "../../../chunk-SGTAZO2Q.mjs";
|
|
7
7
|
import "../../../chunk-TPNHSNNZ.mjs";
|
|
8
|
-
import "../../../chunk-
|
|
8
|
+
import "../../../chunk-TYYFTZLS.mjs";
|
|
9
9
|
export {
|
|
10
10
|
runExecutor as default
|
|
11
11
|
};
|