@storm-software/cloudflare-tools 0.71.89 → 0.71.91
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 +24 -0
- package/README.md +1 -1
- package/dist/{chunk-P42MQNVF.mjs → chunk-536H3WK5.mjs} +18 -1
- package/dist/{chunk-IH7USDLX.js → chunk-COUZEHRU.js} +18 -18
- package/dist/{chunk-52X4GPEN.mjs → chunk-EXZP5MWY.mjs} +28 -7
- package/dist/{chunk-QWSTQIUA.js → chunk-GBAVURC4.js} +51 -34
- package/dist/{chunk-K4WFZ4BY.js → chunk-GG5WUYIL.js} +39 -39
- package/dist/{chunk-6JVDTXHT.js → chunk-JCQYTCUM.js} +5 -5
- package/dist/{chunk-3IB2OBMA.mjs → chunk-KM2LU3WU.mjs} +39 -39
- package/dist/{chunk-SYYVQEM6.js → chunk-LZPNL75H.js} +13 -13
- package/dist/{chunk-APKXAMXO.mjs → chunk-P53OIJC5.mjs} +10 -10
- package/dist/{chunk-2KWRE5Y5.js → chunk-PVCPJUY2.js} +28 -7
- package/dist/{chunk-E7SXH3BE.js → chunk-QY2K3DFK.js} +168 -168
- package/dist/{chunk-3G3KRE5C.mjs → chunk-RQTOQ3CF.mjs} +3 -3
- package/dist/chunk-UTKIVUDT.js +266 -0
- package/dist/{chunk-C26E7UHD.js → chunk-WDNXEDWS.js} +20 -20
- package/dist/chunk-XFZ2V7ZD.mjs +269 -0
- package/dist/{chunk-3SX7VAO7.mjs → chunk-XVKPJL76.mjs} +3 -3
- package/dist/{chunk-C6CPSE5U.mjs → chunk-YQSDJFL7.mjs} +3 -3
- package/dist/{chunk-OPXJUL5V.mjs → chunk-Z7TZ4UY6.mjs} +1 -1
- package/dist/executors.js +5 -5
- package/dist/executors.mjs +5 -5
- package/dist/generators.js +5 -5
- package/dist/generators.mjs +4 -4
- package/dist/index.js +8 -8
- package/dist/index.mjs +7 -7
- package/dist/src/executors/cloudflare-publish/executor.js +3 -3
- package/dist/src/executors/cloudflare-publish/executor.mjs +3 -3
- package/dist/src/executors/r2-upload-publish/executor.js +5 -5
- package/dist/src/executors/r2-upload-publish/executor.mjs +4 -4
- package/dist/src/executors/serve/executor.js +4 -4
- package/dist/src/executors/serve/executor.mjs +3 -3
- package/dist/src/generators/init/generator.js +2 -2
- package/dist/src/generators/init/generator.mjs +1 -1
- package/dist/src/generators/worker/generator.js +5 -5
- package/dist/src/generators/worker/generator.mjs +4 -4
- package/dist/src/utils/index.js +3 -3
- package/dist/src/utils/index.mjs +2 -2
- package/dist/src/utils/r2-bucket-helpers.js +3 -3
- package/dist/src/utils/r2-bucket-helpers.mjs +2 -2
- package/package.json +41 -41
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
generator_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-KM2LU3WU.mjs";
|
|
4
4
|
import {
|
|
5
5
|
findWorkspaceRoot,
|
|
6
6
|
getConfig
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-536H3WK5.mjs";
|
|
8
8
|
import {
|
|
9
9
|
brandIcon,
|
|
10
10
|
getStopwatch,
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
writeFatal,
|
|
14
14
|
writeInfo,
|
|
15
15
|
writeTrace
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-EXZP5MWY.mjs";
|
|
17
17
|
import {
|
|
18
18
|
__dirname
|
|
19
19
|
} from "./chunk-FVRCPE3R.mjs";
|
|
@@ -0,0 +1,266 @@
|
|
|
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
|
+
|
|
4
|
+
var _chunkGBAVURC4js = require('./chunk-GBAVURC4.js');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
var _chunkPVCPJUY2js = require('./chunk-PVCPJUY2.js');
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
var _chunkGG5WUYILjs = require('./chunk-GG5WUYIL.js');
|
|
17
|
+
|
|
18
|
+
// src/generators/worker/generator.ts
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
var _devkit = require('@nx/devkit');
|
|
31
|
+
var _projectnameandrootutils = require('@nx/devkit/src/generators/project-name-and-root-utils');
|
|
32
|
+
var _node = require('@nx/node');
|
|
33
|
+
var _versions = require('@nx/node/src/utils/versions');
|
|
34
|
+
var _path = require('path');
|
|
35
|
+
|
|
36
|
+
// src/generators/worker/libs/get-account-id.ts
|
|
37
|
+
function getAccountId(accountId) {
|
|
38
|
+
return `account_id = "${accountId}"`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// src/generators/worker/libs/vitest-imports.ts
|
|
42
|
+
var vitestImports = `import { describe, expect, it, beforeAll, afterAll } from 'vitest';`;
|
|
43
|
+
|
|
44
|
+
// src/generators/worker/libs/vitest-script.ts
|
|
45
|
+
var vitestScript = `"test": "vitest run"`;
|
|
46
|
+
|
|
47
|
+
// src/generators/worker/generator.ts
|
|
48
|
+
async function applicationGenerator(tree, schema) {
|
|
49
|
+
const stopwatch = _chunkPVCPJUY2js.getStopwatch.call(void 0, "Storm Worker generator");
|
|
50
|
+
let config;
|
|
51
|
+
try {
|
|
52
|
+
const workspaceRoot = _chunkGBAVURC4js.findWorkspaceRoot.call(void 0, );
|
|
53
|
+
config = await _chunkGBAVURC4js.getConfig.call(void 0, workspaceRoot);
|
|
54
|
+
_chunkPVCPJUY2js.writeInfo.call(void 0,
|
|
55
|
+
`${_chunkPVCPJUY2js.brandIcon.call(void 0, config)} Running the Storm Worker generator...
|
|
56
|
+
|
|
57
|
+
`,
|
|
58
|
+
config
|
|
59
|
+
);
|
|
60
|
+
_chunkPVCPJUY2js.writeDebug.call(void 0,
|
|
61
|
+
`Loading the Storm Config from environment variables and storm.json file...
|
|
62
|
+
- workspaceRoot: ${workspaceRoot}`,
|
|
63
|
+
config
|
|
64
|
+
);
|
|
65
|
+
_chunkPVCPJUY2js.writeTrace.call(void 0,
|
|
66
|
+
`Loaded Storm config into env:
|
|
67
|
+
${Object.keys(process.env).map((key) => ` - ${key}=${JSON.stringify(process.env[key])}`).join("\n")}`,
|
|
68
|
+
config
|
|
69
|
+
);
|
|
70
|
+
const options = await normalizeOptions(tree, schema, config);
|
|
71
|
+
const tasks = [];
|
|
72
|
+
tasks.push(
|
|
73
|
+
await _chunkGG5WUYILjs.generator_default.call(void 0, tree, {
|
|
74
|
+
...options,
|
|
75
|
+
skipFormat: true
|
|
76
|
+
})
|
|
77
|
+
);
|
|
78
|
+
tasks.push(
|
|
79
|
+
await _node.applicationGenerator.call(void 0, tree, {
|
|
80
|
+
...options,
|
|
81
|
+
framework: "none",
|
|
82
|
+
skipFormat: true,
|
|
83
|
+
unitTestRunner: options.unitTestRunner == "vitest" ? "none" : options.unitTestRunner,
|
|
84
|
+
e2eTestRunner: "none",
|
|
85
|
+
name: schema.name
|
|
86
|
+
})
|
|
87
|
+
);
|
|
88
|
+
if (options.unitTestRunner === "vitest") {
|
|
89
|
+
const { vitestGenerator, createOrEditViteConfig } = _devkit.ensurePackage.call(void 0,
|
|
90
|
+
"@nx/vite",
|
|
91
|
+
_versions.nxVersion
|
|
92
|
+
);
|
|
93
|
+
const vitestTask = await vitestGenerator(tree, {
|
|
94
|
+
project: options.name,
|
|
95
|
+
uiFramework: "none",
|
|
96
|
+
coverageProvider: "v8",
|
|
97
|
+
skipFormat: true,
|
|
98
|
+
testEnvironment: "node"
|
|
99
|
+
});
|
|
100
|
+
tasks.push(vitestTask);
|
|
101
|
+
createOrEditViteConfig(
|
|
102
|
+
tree,
|
|
103
|
+
{
|
|
104
|
+
project: options.name,
|
|
105
|
+
includeLib: false,
|
|
106
|
+
includeVitest: true,
|
|
107
|
+
testEnvironment: "node"
|
|
108
|
+
},
|
|
109
|
+
true
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
addCloudflareFiles(tree, options);
|
|
113
|
+
updateTsAppConfig(tree, options);
|
|
114
|
+
addTargets(tree, options);
|
|
115
|
+
if (options.unitTestRunner === "none") {
|
|
116
|
+
removeTestFiles(tree, options);
|
|
117
|
+
}
|
|
118
|
+
if (!options.skipFormat) {
|
|
119
|
+
await _devkit.formatFiles.call(void 0, tree);
|
|
120
|
+
}
|
|
121
|
+
if (options.template === "hono") {
|
|
122
|
+
tasks.push(() => {
|
|
123
|
+
const packageJsonPath = _devkit.joinPathFragments.call(void 0,
|
|
124
|
+
_nullishCoalesce(options.directory, () => ( "")),
|
|
125
|
+
"package.json"
|
|
126
|
+
);
|
|
127
|
+
if (tree.exists(packageJsonPath)) {
|
|
128
|
+
_devkit.updateJson.call(void 0, tree, packageJsonPath, (json) => ({
|
|
129
|
+
...json,
|
|
130
|
+
dependencies: {
|
|
131
|
+
hono: "4.4.0",
|
|
132
|
+
..._optionalChain([json, 'optionalAccess', _ => _.dependencies])
|
|
133
|
+
}
|
|
134
|
+
}));
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
return _devkit.runTasksInSerial.call(void 0, ...tasks);
|
|
139
|
+
} catch (error) {
|
|
140
|
+
return () => {
|
|
141
|
+
_chunkPVCPJUY2js.writeFatal.call(void 0,
|
|
142
|
+
"A fatal error occurred while running the generator - the process was forced to terminate",
|
|
143
|
+
config
|
|
144
|
+
);
|
|
145
|
+
_chunkPVCPJUY2js.writeError.call(void 0,
|
|
146
|
+
`An exception was thrown in the generator's process
|
|
147
|
+
- Details: ${error.message}
|
|
148
|
+
- Stacktrace: ${error.stack}`,
|
|
149
|
+
config
|
|
150
|
+
);
|
|
151
|
+
};
|
|
152
|
+
} finally {
|
|
153
|
+
stopwatch();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function updateTsAppConfig(tree, options) {
|
|
157
|
+
_devkit.updateJson.call(void 0, tree, _path.join.call(void 0, options.appProjectRoot, "tsconfig.app.json"), (json) => {
|
|
158
|
+
json.compilerOptions = {
|
|
159
|
+
...json.compilerOptions,
|
|
160
|
+
esModuleInterop: true,
|
|
161
|
+
target: "es2021",
|
|
162
|
+
lib: ["es2021"],
|
|
163
|
+
module: "es2022",
|
|
164
|
+
moduleResolution: "node",
|
|
165
|
+
resolveJsonModule: true,
|
|
166
|
+
allowJs: true,
|
|
167
|
+
checkJs: false,
|
|
168
|
+
noEmit: true,
|
|
169
|
+
isolatedModules: true,
|
|
170
|
+
allowSyntheticDefaultImports: true,
|
|
171
|
+
forceConsistentCasingInFileNames: true,
|
|
172
|
+
strict: true,
|
|
173
|
+
skipLibCheck: true
|
|
174
|
+
};
|
|
175
|
+
json.compilerOptions.types = [
|
|
176
|
+
...json.compilerOptions.types,
|
|
177
|
+
"@cloudflare/workers-types"
|
|
178
|
+
];
|
|
179
|
+
return json;
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
function addCloudflareFiles(tree, options) {
|
|
183
|
+
tree.delete(_path.join.call(void 0, options.appProjectRoot, "src/main.ts"));
|
|
184
|
+
_devkit.generateFiles.call(void 0,
|
|
185
|
+
tree,
|
|
186
|
+
_path.join.call(void 0, __dirname, "./files/common"),
|
|
187
|
+
options.appProjectRoot,
|
|
188
|
+
{
|
|
189
|
+
...options,
|
|
190
|
+
tmpl: "",
|
|
191
|
+
name: options.name,
|
|
192
|
+
accountId: options.accountId ? getAccountId(options.accountId) : "",
|
|
193
|
+
vitestScript: options.unitTestRunner === "vitest" ? vitestScript : ""
|
|
194
|
+
}
|
|
195
|
+
);
|
|
196
|
+
if (options.template && options.template !== "none") {
|
|
197
|
+
_devkit.generateFiles.call(void 0,
|
|
198
|
+
tree,
|
|
199
|
+
_path.join.call(void 0, __dirname, `./files/${options.template}`),
|
|
200
|
+
_path.join.call(void 0, options.appProjectRoot, "src"),
|
|
201
|
+
{
|
|
202
|
+
...options,
|
|
203
|
+
tmpl: "",
|
|
204
|
+
name: options.name,
|
|
205
|
+
accountId: options.accountId ? getAccountId(options.accountId) : "",
|
|
206
|
+
vitestScript: options.unitTestRunner === "vitest" ? vitestScript : "",
|
|
207
|
+
vitestImports: options.unitTestRunner === "vitest" ? vitestImports : ""
|
|
208
|
+
}
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
function addTargets(tree, options) {
|
|
213
|
+
try {
|
|
214
|
+
const projectConfiguration = _devkit.readProjectConfiguration.call(void 0, tree, options.name);
|
|
215
|
+
projectConfiguration.targets = {
|
|
216
|
+
..._nullishCoalesce(projectConfiguration.targets, () => ( {})),
|
|
217
|
+
serve: {
|
|
218
|
+
executor: "@storm-software/cloudflare-tools:serve",
|
|
219
|
+
options: {
|
|
220
|
+
port: options.port
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
"nx-release-publish": {
|
|
224
|
+
executor: "@storm-software/cloudflare-tools:cloudflare-publish"
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
if (projectConfiguration.targets.build) {
|
|
228
|
+
delete projectConfiguration.targets.build;
|
|
229
|
+
}
|
|
230
|
+
_devkit.updateProjectConfiguration.call(void 0, tree, options.name, projectConfiguration);
|
|
231
|
+
} catch (e) {
|
|
232
|
+
console.error(e);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
function removeTestFiles(tree, options) {
|
|
236
|
+
tree.delete(_path.join.call(void 0, options.appProjectRoot, "src", "index.test.ts"));
|
|
237
|
+
}
|
|
238
|
+
async function normalizeOptions(host, options, config) {
|
|
239
|
+
const { projectName: appProjectName, projectRoot: appProjectRoot } = await _projectnameandrootutils.determineProjectNameAndRootOptions.call(void 0, host, {
|
|
240
|
+
name: options.name,
|
|
241
|
+
projectType: "application",
|
|
242
|
+
directory: options.directory,
|
|
243
|
+
rootProject: options.rootProject
|
|
244
|
+
});
|
|
245
|
+
options.rootProject = appProjectRoot === ".";
|
|
246
|
+
return {
|
|
247
|
+
addPlugin: process.env.NX_ADD_PLUGINS !== "false",
|
|
248
|
+
accountId: process.env.STORM_BOT_CLOUDFLARE_ACCOUNT,
|
|
249
|
+
...options,
|
|
250
|
+
name: _devkit.names.call(void 0, appProjectName).fileName,
|
|
251
|
+
frontendProject: options.frontendProject ? _devkit.names.call(void 0, options.frontendProject).fileName : void 0,
|
|
252
|
+
appProjectRoot,
|
|
253
|
+
unitTestRunner: _nullishCoalesce(options.unitTestRunner, () => ( "vitest")),
|
|
254
|
+
rootProject: _nullishCoalesce(options.rootProject, () => ( false)),
|
|
255
|
+
template: _nullishCoalesce(options.template, () => ( "fetch-handler")),
|
|
256
|
+
port: _nullishCoalesce(options.port, () => ( 3e3))
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
var generator_default2 = applicationGenerator;
|
|
260
|
+
var applicationSchematic = _devkit.convertNxGenerator.call(void 0, applicationGenerator);
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
exports.applicationGenerator = applicationGenerator; exports.generator_default = generator_default2; exports.applicationSchematic = applicationSchematic;
|
|
@@ -1,27 +1,27 @@
|
|
|
1
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
2
|
|
|
3
3
|
|
|
4
|
+
var _chunkN7FW365Qjs = require('./chunk-N7FW365Q.js');
|
|
4
5
|
|
|
5
|
-
var _chunk6JVDTXHTjs = require('./chunk-6JVDTXHT.js');
|
|
6
6
|
|
|
7
7
|
|
|
8
|
+
var _chunkGBAVURC4js = require('./chunk-GBAVURC4.js');
|
|
8
9
|
|
|
9
|
-
var _chunkN7FW365Qjs = require('./chunk-N7FW365Q.js');
|
|
10
10
|
|
|
11
|
+
var _chunkKUGEZPUOjs = require('./chunk-KUGEZPUO.js');
|
|
11
12
|
|
|
12
13
|
|
|
13
|
-
var _chunkQWSTQIUAjs = require('./chunk-QWSTQIUA.js');
|
|
14
14
|
|
|
15
15
|
|
|
16
|
+
var _chunkJCQYTCUMjs = require('./chunk-JCQYTCUM.js');
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
|
|
20
21
|
|
|
21
|
-
var _chunk2KWRE5Y5js = require('./chunk-2KWRE5Y5.js');
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
var
|
|
24
|
+
var _chunkPVCPJUY2js = require('./chunk-PVCPJUY2.js');
|
|
25
25
|
|
|
26
26
|
// src/executors/r2-upload-publish/executor.ts
|
|
27
27
|
|
|
@@ -53,8 +53,8 @@ async function runExecutor(options, context) {
|
|
|
53
53
|
throw new Error("The executor requires projectsConfigurations.");
|
|
54
54
|
}
|
|
55
55
|
try {
|
|
56
|
-
const workspaceRoot =
|
|
57
|
-
const config = await
|
|
56
|
+
const workspaceRoot = _chunkGBAVURC4js.findWorkspaceRoot.call(void 0, );
|
|
57
|
+
const config = await _chunkGBAVURC4js.getConfig.call(void 0, workspaceRoot);
|
|
58
58
|
const projectName = _nullishCoalesce(_optionalChain([context, 'access', _7 => _7.projectsConfigurations, 'access', _8 => _8.projects, 'access', _9 => _9[context.projectName], 'optionalAccess', _10 => _10.name]), () => ( context.projectName));
|
|
59
59
|
const projectDetails = _chunkN7FW365Qjs.getPackageInfo.call(void 0,
|
|
60
60
|
context.projectsConfigurations.projects[context.projectName]
|
|
@@ -92,7 +92,7 @@ async function runExecutor(options, context) {
|
|
|
92
92
|
"The executor failed because the project graph is not available. Please run the build command again."
|
|
93
93
|
);
|
|
94
94
|
}
|
|
95
|
-
|
|
95
|
+
_chunkPVCPJUY2js.writeDebug.call(void 0,
|
|
96
96
|
`Publishing ${context.projectName} to the ${bucketId} R2 Bucket (at ${registry})`
|
|
97
97
|
);
|
|
98
98
|
const client = new (0, _clients3.S3Client)({
|
|
@@ -108,13 +108,13 @@ async function runExecutor(options, context) {
|
|
|
108
108
|
});
|
|
109
109
|
const version = _optionalChain([projectDetails, 'optionalAccess', _13 => _13.content, 'optionalAccess', _14 => _14.version]);
|
|
110
110
|
if (version) {
|
|
111
|
-
|
|
111
|
+
_chunkPVCPJUY2js.writeDebug.call(void 0, `Starting upload version ${version}`);
|
|
112
112
|
}
|
|
113
113
|
const basePath = options.path;
|
|
114
|
-
const files = await _glob.glob.call(void 0,
|
|
114
|
+
const files = await _glob.glob.call(void 0, _chunkPVCPJUY2js.joinPaths.call(void 0, basePath, "**/*"), {
|
|
115
115
|
ignore: "**/{*.stories.tsx,*.stories.ts,*.spec.tsx,*.spec.ts}"
|
|
116
116
|
});
|
|
117
|
-
const internalDependencies = await
|
|
117
|
+
const internalDependencies = await _chunkJCQYTCUMjs.getInternalDependencies.call(void 0,
|
|
118
118
|
context.projectName,
|
|
119
119
|
projectGraph
|
|
120
120
|
);
|
|
@@ -128,7 +128,7 @@ async function runExecutor(options, context) {
|
|
|
128
128
|
}, _nullishCoalesce(_optionalChain([projectDetails, 'optionalAccess', _15 => _15.content, 'access', _16 => _16.dependencies]), () => ( {})));
|
|
129
129
|
const release = _nullishCoalesce(options.tag, () => ( _child_process.execSync.call(void 0, "npm config get tag").toString().trim()));
|
|
130
130
|
if (options.clean === true) {
|
|
131
|
-
|
|
131
|
+
_chunkPVCPJUY2js.writeDebug.call(void 0, `Clearing out existing items in ${bucketPath}`);
|
|
132
132
|
if (!isDryRun) {
|
|
133
133
|
const response = await client.send(
|
|
134
134
|
new (0, _clients3.ListObjectsCommand)({
|
|
@@ -137,7 +137,7 @@ async function runExecutor(options, context) {
|
|
|
137
137
|
})
|
|
138
138
|
);
|
|
139
139
|
if (_optionalChain([response, 'optionalAccess', _17 => _17.Contents]) && response.Contents.length > 0) {
|
|
140
|
-
|
|
140
|
+
_chunkPVCPJUY2js.writeTrace.call(void 0,
|
|
141
141
|
`Deleting the following existing items from the R2 bucket path ${bucketPath}: ${response.Contents.map((item) => item.Key).join(", ")}`
|
|
142
142
|
);
|
|
143
143
|
await client.send(
|
|
@@ -152,12 +152,12 @@ async function runExecutor(options, context) {
|
|
|
152
152
|
})
|
|
153
153
|
);
|
|
154
154
|
} else {
|
|
155
|
-
|
|
155
|
+
_chunkPVCPJUY2js.writeDebug.call(void 0,
|
|
156
156
|
`No existing items to delete in the R2 bucket path ${bucketPath}`
|
|
157
157
|
);
|
|
158
158
|
}
|
|
159
159
|
} else {
|
|
160
|
-
|
|
160
|
+
_chunkPVCPJUY2js.writeWarning.call(void 0, "[Dry run]: Skipping R2 bucket clean.");
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
if (options.writeMetaJson === true) {
|
|
@@ -178,7 +178,7 @@ async function runExecutor(options, context) {
|
|
|
178
178
|
if (_optionalChain([projectDetails, 'optionalAccess', _22 => _22.type]) === "package.json") {
|
|
179
179
|
meta.devDependencies = _optionalChain([projectDetails, 'optionalAccess', _23 => _23.content, 'optionalAccess', _24 => _24.devDependencies]);
|
|
180
180
|
}
|
|
181
|
-
await
|
|
181
|
+
await _chunkJCQYTCUMjs.uploadFile.call(void 0,
|
|
182
182
|
client,
|
|
183
183
|
bucketId,
|
|
184
184
|
bucketPath,
|
|
@@ -194,22 +194,22 @@ async function runExecutor(options, context) {
|
|
|
194
194
|
if (_optionalChain([_fs.statSync.call(void 0, file, {
|
|
195
195
|
throwIfNoEntry: false
|
|
196
196
|
}), 'optionalAccess', _25 => _25.isFile, 'call', _26 => _26()])) {
|
|
197
|
-
const name =
|
|
197
|
+
const name = _chunkPVCPJUY2js.correctPaths.call(void 0, file).replace(_chunkPVCPJUY2js.correctPaths.call(void 0, basePath), "");
|
|
198
198
|
const type = _mimetypes2.default.lookup(name) || "application/octet-stream";
|
|
199
|
-
await
|
|
199
|
+
await _chunkJCQYTCUMjs.uploadFile.call(void 0,
|
|
200
200
|
client,
|
|
201
201
|
bucketId,
|
|
202
202
|
bucketPath,
|
|
203
203
|
name,
|
|
204
204
|
version,
|
|
205
|
-
await _promises.readFile.call(void 0, file,
|
|
205
|
+
await _promises.readFile.call(void 0, file, _chunkJCQYTCUMjs.getEncoding.call(void 0, type)),
|
|
206
206
|
type,
|
|
207
207
|
isDryRun
|
|
208
208
|
);
|
|
209
209
|
}
|
|
210
210
|
})
|
|
211
211
|
);
|
|
212
|
-
|
|
212
|
+
_chunkPVCPJUY2js.writeSuccess.call(void 0,
|
|
213
213
|
`Successfully uploaded the ${projectName} project to the Cloudflare R2 bucket.`,
|
|
214
214
|
config
|
|
215
215
|
);
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import {
|
|
2
|
+
findWorkspaceRoot,
|
|
3
|
+
getConfig
|
|
4
|
+
} from "./chunk-536H3WK5.mjs";
|
|
5
|
+
import {
|
|
6
|
+
brandIcon,
|
|
7
|
+
getStopwatch,
|
|
8
|
+
writeDebug,
|
|
9
|
+
writeError,
|
|
10
|
+
writeFatal,
|
|
11
|
+
writeInfo,
|
|
12
|
+
writeTrace
|
|
13
|
+
} from "./chunk-EXZP5MWY.mjs";
|
|
14
|
+
import {
|
|
15
|
+
generator_default
|
|
16
|
+
} from "./chunk-KM2LU3WU.mjs";
|
|
17
|
+
import {
|
|
18
|
+
__dirname
|
|
19
|
+
} from "./chunk-FVRCPE3R.mjs";
|
|
20
|
+
|
|
21
|
+
// src/generators/worker/generator.ts
|
|
22
|
+
import {
|
|
23
|
+
convertNxGenerator,
|
|
24
|
+
ensurePackage,
|
|
25
|
+
formatFiles,
|
|
26
|
+
generateFiles,
|
|
27
|
+
joinPathFragments,
|
|
28
|
+
names,
|
|
29
|
+
readProjectConfiguration,
|
|
30
|
+
runTasksInSerial,
|
|
31
|
+
updateJson,
|
|
32
|
+
updateProjectConfiguration
|
|
33
|
+
} from "@nx/devkit";
|
|
34
|
+
import { determineProjectNameAndRootOptions } from "@nx/devkit/src/generators/project-name-and-root-utils";
|
|
35
|
+
import { applicationGenerator as nodeApplicationGenerator } from "@nx/node";
|
|
36
|
+
import { nxVersion } from "@nx/node/src/utils/versions";
|
|
37
|
+
import { join } from "path";
|
|
38
|
+
|
|
39
|
+
// src/generators/worker/libs/get-account-id.ts
|
|
40
|
+
function getAccountId(accountId) {
|
|
41
|
+
return `account_id = "${accountId}"`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// src/generators/worker/libs/vitest-imports.ts
|
|
45
|
+
var vitestImports = `import { describe, expect, it, beforeAll, afterAll } from 'vitest';`;
|
|
46
|
+
|
|
47
|
+
// src/generators/worker/libs/vitest-script.ts
|
|
48
|
+
var vitestScript = `"test": "vitest run"`;
|
|
49
|
+
|
|
50
|
+
// src/generators/worker/generator.ts
|
|
51
|
+
async function applicationGenerator(tree, schema) {
|
|
52
|
+
const stopwatch = getStopwatch("Storm Worker generator");
|
|
53
|
+
let config;
|
|
54
|
+
try {
|
|
55
|
+
const workspaceRoot = findWorkspaceRoot();
|
|
56
|
+
config = await getConfig(workspaceRoot);
|
|
57
|
+
writeInfo(
|
|
58
|
+
`${brandIcon(config)} Running the Storm Worker generator...
|
|
59
|
+
|
|
60
|
+
`,
|
|
61
|
+
config
|
|
62
|
+
);
|
|
63
|
+
writeDebug(
|
|
64
|
+
`Loading the Storm Config from environment variables and storm.json file...
|
|
65
|
+
- workspaceRoot: ${workspaceRoot}`,
|
|
66
|
+
config
|
|
67
|
+
);
|
|
68
|
+
writeTrace(
|
|
69
|
+
`Loaded Storm config into env:
|
|
70
|
+
${Object.keys(process.env).map((key) => ` - ${key}=${JSON.stringify(process.env[key])}`).join("\n")}`,
|
|
71
|
+
config
|
|
72
|
+
);
|
|
73
|
+
const options = await normalizeOptions(tree, schema, config);
|
|
74
|
+
const tasks = [];
|
|
75
|
+
tasks.push(
|
|
76
|
+
await generator_default(tree, {
|
|
77
|
+
...options,
|
|
78
|
+
skipFormat: true
|
|
79
|
+
})
|
|
80
|
+
);
|
|
81
|
+
tasks.push(
|
|
82
|
+
await nodeApplicationGenerator(tree, {
|
|
83
|
+
...options,
|
|
84
|
+
framework: "none",
|
|
85
|
+
skipFormat: true,
|
|
86
|
+
unitTestRunner: options.unitTestRunner == "vitest" ? "none" : options.unitTestRunner,
|
|
87
|
+
e2eTestRunner: "none",
|
|
88
|
+
name: schema.name
|
|
89
|
+
})
|
|
90
|
+
);
|
|
91
|
+
if (options.unitTestRunner === "vitest") {
|
|
92
|
+
const { vitestGenerator, createOrEditViteConfig } = ensurePackage(
|
|
93
|
+
"@nx/vite",
|
|
94
|
+
nxVersion
|
|
95
|
+
);
|
|
96
|
+
const vitestTask = await vitestGenerator(tree, {
|
|
97
|
+
project: options.name,
|
|
98
|
+
uiFramework: "none",
|
|
99
|
+
coverageProvider: "v8",
|
|
100
|
+
skipFormat: true,
|
|
101
|
+
testEnvironment: "node"
|
|
102
|
+
});
|
|
103
|
+
tasks.push(vitestTask);
|
|
104
|
+
createOrEditViteConfig(
|
|
105
|
+
tree,
|
|
106
|
+
{
|
|
107
|
+
project: options.name,
|
|
108
|
+
includeLib: false,
|
|
109
|
+
includeVitest: true,
|
|
110
|
+
testEnvironment: "node"
|
|
111
|
+
},
|
|
112
|
+
true
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
addCloudflareFiles(tree, options);
|
|
116
|
+
updateTsAppConfig(tree, options);
|
|
117
|
+
addTargets(tree, options);
|
|
118
|
+
if (options.unitTestRunner === "none") {
|
|
119
|
+
removeTestFiles(tree, options);
|
|
120
|
+
}
|
|
121
|
+
if (!options.skipFormat) {
|
|
122
|
+
await formatFiles(tree);
|
|
123
|
+
}
|
|
124
|
+
if (options.template === "hono") {
|
|
125
|
+
tasks.push(() => {
|
|
126
|
+
const packageJsonPath = joinPathFragments(
|
|
127
|
+
options.directory ?? "",
|
|
128
|
+
"package.json"
|
|
129
|
+
);
|
|
130
|
+
if (tree.exists(packageJsonPath)) {
|
|
131
|
+
updateJson(tree, packageJsonPath, (json) => ({
|
|
132
|
+
...json,
|
|
133
|
+
dependencies: {
|
|
134
|
+
hono: "4.4.0",
|
|
135
|
+
...json?.dependencies
|
|
136
|
+
}
|
|
137
|
+
}));
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
return runTasksInSerial(...tasks);
|
|
142
|
+
} catch (error) {
|
|
143
|
+
return () => {
|
|
144
|
+
writeFatal(
|
|
145
|
+
"A fatal error occurred while running the generator - the process was forced to terminate",
|
|
146
|
+
config
|
|
147
|
+
);
|
|
148
|
+
writeError(
|
|
149
|
+
`An exception was thrown in the generator's process
|
|
150
|
+
- Details: ${error.message}
|
|
151
|
+
- Stacktrace: ${error.stack}`,
|
|
152
|
+
config
|
|
153
|
+
);
|
|
154
|
+
};
|
|
155
|
+
} finally {
|
|
156
|
+
stopwatch();
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function updateTsAppConfig(tree, options) {
|
|
160
|
+
updateJson(tree, join(options.appProjectRoot, "tsconfig.app.json"), (json) => {
|
|
161
|
+
json.compilerOptions = {
|
|
162
|
+
...json.compilerOptions,
|
|
163
|
+
esModuleInterop: true,
|
|
164
|
+
target: "es2021",
|
|
165
|
+
lib: ["es2021"],
|
|
166
|
+
module: "es2022",
|
|
167
|
+
moduleResolution: "node",
|
|
168
|
+
resolveJsonModule: true,
|
|
169
|
+
allowJs: true,
|
|
170
|
+
checkJs: false,
|
|
171
|
+
noEmit: true,
|
|
172
|
+
isolatedModules: true,
|
|
173
|
+
allowSyntheticDefaultImports: true,
|
|
174
|
+
forceConsistentCasingInFileNames: true,
|
|
175
|
+
strict: true,
|
|
176
|
+
skipLibCheck: true
|
|
177
|
+
};
|
|
178
|
+
json.compilerOptions.types = [
|
|
179
|
+
...json.compilerOptions.types,
|
|
180
|
+
"@cloudflare/workers-types"
|
|
181
|
+
];
|
|
182
|
+
return json;
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
function addCloudflareFiles(tree, options) {
|
|
186
|
+
tree.delete(join(options.appProjectRoot, "src/main.ts"));
|
|
187
|
+
generateFiles(
|
|
188
|
+
tree,
|
|
189
|
+
join(__dirname, "./files/common"),
|
|
190
|
+
options.appProjectRoot,
|
|
191
|
+
{
|
|
192
|
+
...options,
|
|
193
|
+
tmpl: "",
|
|
194
|
+
name: options.name,
|
|
195
|
+
accountId: options.accountId ? getAccountId(options.accountId) : "",
|
|
196
|
+
vitestScript: options.unitTestRunner === "vitest" ? vitestScript : ""
|
|
197
|
+
}
|
|
198
|
+
);
|
|
199
|
+
if (options.template && options.template !== "none") {
|
|
200
|
+
generateFiles(
|
|
201
|
+
tree,
|
|
202
|
+
join(__dirname, `./files/${options.template}`),
|
|
203
|
+
join(options.appProjectRoot, "src"),
|
|
204
|
+
{
|
|
205
|
+
...options,
|
|
206
|
+
tmpl: "",
|
|
207
|
+
name: options.name,
|
|
208
|
+
accountId: options.accountId ? getAccountId(options.accountId) : "",
|
|
209
|
+
vitestScript: options.unitTestRunner === "vitest" ? vitestScript : "",
|
|
210
|
+
vitestImports: options.unitTestRunner === "vitest" ? vitestImports : ""
|
|
211
|
+
}
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
function addTargets(tree, options) {
|
|
216
|
+
try {
|
|
217
|
+
const projectConfiguration = readProjectConfiguration(tree, options.name);
|
|
218
|
+
projectConfiguration.targets = {
|
|
219
|
+
...projectConfiguration.targets ?? {},
|
|
220
|
+
serve: {
|
|
221
|
+
executor: "@storm-software/cloudflare-tools:serve",
|
|
222
|
+
options: {
|
|
223
|
+
port: options.port
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
"nx-release-publish": {
|
|
227
|
+
executor: "@storm-software/cloudflare-tools:cloudflare-publish"
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
if (projectConfiguration.targets.build) {
|
|
231
|
+
delete projectConfiguration.targets.build;
|
|
232
|
+
}
|
|
233
|
+
updateProjectConfiguration(tree, options.name, projectConfiguration);
|
|
234
|
+
} catch (e) {
|
|
235
|
+
console.error(e);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
function removeTestFiles(tree, options) {
|
|
239
|
+
tree.delete(join(options.appProjectRoot, "src", "index.test.ts"));
|
|
240
|
+
}
|
|
241
|
+
async function normalizeOptions(host, options, config) {
|
|
242
|
+
const { projectName: appProjectName, projectRoot: appProjectRoot } = await determineProjectNameAndRootOptions(host, {
|
|
243
|
+
name: options.name,
|
|
244
|
+
projectType: "application",
|
|
245
|
+
directory: options.directory,
|
|
246
|
+
rootProject: options.rootProject
|
|
247
|
+
});
|
|
248
|
+
options.rootProject = appProjectRoot === ".";
|
|
249
|
+
return {
|
|
250
|
+
addPlugin: process.env.NX_ADD_PLUGINS !== "false",
|
|
251
|
+
accountId: process.env.STORM_BOT_CLOUDFLARE_ACCOUNT,
|
|
252
|
+
...options,
|
|
253
|
+
name: names(appProjectName).fileName,
|
|
254
|
+
frontendProject: options.frontendProject ? names(options.frontendProject).fileName : void 0,
|
|
255
|
+
appProjectRoot,
|
|
256
|
+
unitTestRunner: options.unitTestRunner ?? "vitest",
|
|
257
|
+
rootProject: options.rootProject ?? false,
|
|
258
|
+
template: options.template ?? "fetch-handler",
|
|
259
|
+
port: options.port ?? 3e3
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
var generator_default2 = applicationGenerator;
|
|
263
|
+
var applicationSchematic = convertNxGenerator(applicationGenerator);
|
|
264
|
+
|
|
265
|
+
export {
|
|
266
|
+
applicationGenerator,
|
|
267
|
+
generator_default2 as generator_default,
|
|
268
|
+
applicationSchematic
|
|
269
|
+
};
|