@storm-software/cloudflare-tools 0.71.126 → 0.71.128
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-HLOR5IM3.js → chunk-4F562753.js} +4 -4
- package/dist/{chunk-CULHQTXS.mjs → chunk-6SXCZNHZ.mjs} +3 -3
- package/dist/{chunk-D4SJMIYF.mjs → chunk-6ZJP5W4Q.mjs} +4 -4
- package/dist/chunk-AVYOABJJ.js +266 -0
- package/dist/chunk-EBT36S6J.js +231 -0
- package/dist/chunk-FBBHHRSC.mjs +269 -0
- package/dist/{chunk-4QGEP2VP.mjs → chunk-IH75MSUE.mjs} +12 -10
- package/dist/chunk-IIS253RT.mjs +231 -0
- package/dist/{chunk-AMQMPMDN.js → chunk-R4V44O2F.js} +4 -4
- package/dist/{chunk-Q24LTSOU.js → chunk-VKHDTPKS.js} +12 -10
- package/dist/executors.js +1 -1
- package/dist/executors.mjs +1 -1
- package/dist/generators.js +3 -3
- package/dist/generators.mjs +2 -2
- package/dist/index.js +4 -4
- package/dist/index.mjs +3 -3
- package/dist/src/executors/cloudflare-publish/executor.js +1 -1
- package/dist/src/executors/cloudflare-publish/executor.mjs +1 -1
- package/dist/src/executors/serve/executor.js +2 -2
- package/dist/src/executors/serve/executor.mjs +1 -1
- 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 +3 -3
- package/dist/src/generators/worker/generator.mjs +2 -2
- package/package.json +5 -5
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import {
|
|
2
|
+
generator_default
|
|
3
|
+
} from "./chunk-6ZJP5W4Q.mjs";
|
|
4
|
+
import {
|
|
5
|
+
findWorkspaceRoot,
|
|
6
|
+
getConfig
|
|
7
|
+
} from "./chunk-5QM4JUN3.mjs";
|
|
8
|
+
import {
|
|
9
|
+
brandIcon,
|
|
10
|
+
getStopwatch,
|
|
11
|
+
writeDebug,
|
|
12
|
+
writeError,
|
|
13
|
+
writeFatal,
|
|
14
|
+
writeInfo,
|
|
15
|
+
writeTrace
|
|
16
|
+
} from "./chunk-ZDABHOZ2.mjs";
|
|
17
|
+
import {
|
|
18
|
+
__dirname
|
|
19
|
+
} from "./chunk-HS6L6NAM.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
|
+
};
|
|
@@ -1212,7 +1212,7 @@ async function napiExecutor(options, context, config) {
|
|
|
1212
1212
|
"The Napi Build process failed because the project could not be found in the project graph. Please run this command from a workspace root directory."
|
|
1213
1213
|
);
|
|
1214
1214
|
}
|
|
1215
|
-
const projectRoot = context.projectGraph?.nodes[context.projectName ?? ""]
|
|
1215
|
+
const projectRoot = context.projectGraph?.nodes[context.projectName ?? ""]?.data.root;
|
|
1216
1216
|
const packageJson = joinPaths(projectRoot ?? ".", "package.json");
|
|
1217
1217
|
if (!fileExists(packageJson)) {
|
|
1218
1218
|
throw new Error(`Could not find package.json at ${packageJson}`);
|
|
@@ -1226,27 +1226,29 @@ async function napiExecutor(options, context, config) {
|
|
|
1226
1226
|
if (options.cwd) {
|
|
1227
1227
|
normalizedOptions.cwd = correctPaths(options.cwd);
|
|
1228
1228
|
} else {
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
config.workspaceRoot,
|
|
1232
|
-
projectRoot || "."
|
|
1229
|
+
const absoluteProjectRoot = correctPaths(
|
|
1230
|
+
joinPaths(config.workspaceRoot, projectRoot || ".")
|
|
1233
1231
|
);
|
|
1232
|
+
normalizedOptions.cwd = absoluteProjectRoot;
|
|
1234
1233
|
if (normalizedOptions.outputDir) {
|
|
1235
1234
|
normalizedOptions.outputDir = relative(
|
|
1236
|
-
|
|
1235
|
+
normalizedOptions.cwd,
|
|
1237
1236
|
correctPaths(
|
|
1238
1237
|
isAbsolute(normalizedOptions.outputDir) ? normalizedOptions.outputDir : joinPaths(config.workspaceRoot, normalizedOptions.outputDir)
|
|
1239
1238
|
)
|
|
1240
1239
|
);
|
|
1241
1240
|
}
|
|
1242
1241
|
if (normalizedOptions.packageJsonPath) {
|
|
1243
|
-
normalizedOptions.packageJsonPath =
|
|
1244
|
-
|
|
1242
|
+
normalizedOptions.packageJsonPath = relative(
|
|
1243
|
+
normalizedOptions.cwd,
|
|
1244
|
+
correctPaths(
|
|
1245
|
+
isAbsolute(normalizedOptions.packageJsonPath) ? normalizedOptions.packageJsonPath : joinPaths(config.workspaceRoot, normalizedOptions.packageJsonPath)
|
|
1246
|
+
)
|
|
1245
1247
|
);
|
|
1246
1248
|
}
|
|
1247
1249
|
if (normalizedOptions.configPath) {
|
|
1248
1250
|
normalizedOptions.configPath = relative(
|
|
1249
|
-
|
|
1251
|
+
normalizedOptions.cwd,
|
|
1250
1252
|
correctPaths(
|
|
1251
1253
|
isAbsolute(normalizedOptions.configPath) ? normalizedOptions.configPath : joinPaths(config.workspaceRoot, normalizedOptions.configPath)
|
|
1252
1254
|
)
|
|
@@ -1254,7 +1256,7 @@ async function napiExecutor(options, context, config) {
|
|
|
1254
1256
|
}
|
|
1255
1257
|
if (normalizedOptions.manifestPath) {
|
|
1256
1258
|
normalizedOptions.manifestPath = relative(
|
|
1257
|
-
|
|
1259
|
+
normalizedOptions.cwd,
|
|
1258
1260
|
correctPaths(
|
|
1259
1261
|
isAbsolute(normalizedOptions.manifestPath) ? normalizedOptions.manifestPath : joinPaths(config.workspaceRoot, normalizedOptions.manifestPath)
|
|
1260
1262
|
)
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createCliOptions,
|
|
3
|
+
getPackageInfo
|
|
4
|
+
} from "./chunk-3MAI3FU2.mjs";
|
|
5
|
+
import {
|
|
6
|
+
findWorkspaceRoot,
|
|
7
|
+
getConfig
|
|
8
|
+
} from "./chunk-5QM4JUN3.mjs";
|
|
9
|
+
import {
|
|
10
|
+
createHttpHandler
|
|
11
|
+
} from "./chunk-SWYYMID7.mjs";
|
|
12
|
+
import {
|
|
13
|
+
getEncoding,
|
|
14
|
+
getInternalDependencies,
|
|
15
|
+
uploadFile
|
|
16
|
+
} from "./chunk-M3VAGNJQ.mjs";
|
|
17
|
+
import {
|
|
18
|
+
correctPaths,
|
|
19
|
+
joinPaths,
|
|
20
|
+
writeDebug,
|
|
21
|
+
writeSuccess,
|
|
22
|
+
writeTrace,
|
|
23
|
+
writeWarning
|
|
24
|
+
} from "./chunk-ZDABHOZ2.mjs";
|
|
25
|
+
|
|
26
|
+
// src/executors/r2-upload-publish/executor.ts
|
|
27
|
+
import {
|
|
28
|
+
DeleteObjectsCommand,
|
|
29
|
+
ListObjectsCommand,
|
|
30
|
+
S3Client
|
|
31
|
+
} from "@aws-sdk/client-s3";
|
|
32
|
+
import {
|
|
33
|
+
createProjectGraphAsync,
|
|
34
|
+
readCachedProjectGraph
|
|
35
|
+
} from "@nx/devkit";
|
|
36
|
+
import { glob } from "glob";
|
|
37
|
+
import mime from "mime-types";
|
|
38
|
+
import { execSync } from "node:child_process";
|
|
39
|
+
import { statSync } from "node:fs";
|
|
40
|
+
import { readFile } from "node:fs/promises";
|
|
41
|
+
async function runExecutor(options, context) {
|
|
42
|
+
const isDryRun = process.env.NX_DRY_RUN === "true" || options.dryRun || false;
|
|
43
|
+
if (!context.projectName) {
|
|
44
|
+
throw new Error("The executor requires a projectName.");
|
|
45
|
+
}
|
|
46
|
+
if (!options.path) {
|
|
47
|
+
throw new Error("The executor requires the `path` option to upload.");
|
|
48
|
+
}
|
|
49
|
+
console.info(
|
|
50
|
+
`\u{1F680} Running Storm Cloudflare Publish executor on the ${context.projectName} worker`
|
|
51
|
+
);
|
|
52
|
+
if (!context.projectName || !context.projectsConfigurations?.projects || !context.projectsConfigurations.projects[context.projectName] || !context.projectsConfigurations.projects[context.projectName]?.root) {
|
|
53
|
+
throw new Error("The executor requires projectsConfigurations.");
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
const workspaceRoot = findWorkspaceRoot();
|
|
57
|
+
const config = await getConfig(workspaceRoot);
|
|
58
|
+
const projectName = context.projectsConfigurations.projects[context.projectName]?.name ?? context.projectName;
|
|
59
|
+
const projectDetails = getPackageInfo(
|
|
60
|
+
context.projectsConfigurations.projects[context.projectName]
|
|
61
|
+
);
|
|
62
|
+
const bucketId = options.bucketId;
|
|
63
|
+
const bucketPath = options.bucketPath || "/";
|
|
64
|
+
if (!bucketId) {
|
|
65
|
+
throw new Error("The executor requires a bucketId.");
|
|
66
|
+
}
|
|
67
|
+
const args = createCliOptions({ ...options });
|
|
68
|
+
if (isDryRun) {
|
|
69
|
+
args.push("--dry-run");
|
|
70
|
+
}
|
|
71
|
+
const cloudflareAccountId = process.env.CLOUDFLARE_ACCOUNT_ID || process.env.STORM_BOT_CLOUDFLARE_ACCOUNT;
|
|
72
|
+
if (!options?.registry && !cloudflareAccountId) {
|
|
73
|
+
throw new Error(
|
|
74
|
+
"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."
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
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) {
|
|
78
|
+
throw new Error(
|
|
79
|
+
"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."
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
const registry = options?.registry ? options.registry : `https://${cloudflareAccountId}.r2.cloudflarestorage.com`;
|
|
83
|
+
let projectGraph;
|
|
84
|
+
try {
|
|
85
|
+
projectGraph = readCachedProjectGraph();
|
|
86
|
+
} catch {
|
|
87
|
+
await createProjectGraphAsync();
|
|
88
|
+
projectGraph = readCachedProjectGraph();
|
|
89
|
+
}
|
|
90
|
+
if (!projectGraph) {
|
|
91
|
+
throw new Error(
|
|
92
|
+
"The executor failed because the project graph is not available. Please run the build command again."
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
writeDebug(
|
|
96
|
+
`Publishing ${context.projectName} to the ${bucketId} R2 Bucket (at ${registry})`
|
|
97
|
+
);
|
|
98
|
+
const client = new S3Client({
|
|
99
|
+
region: "auto",
|
|
100
|
+
endpoint: registry,
|
|
101
|
+
credentials: {
|
|
102
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
103
|
+
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,
|
|
104
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
105
|
+
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
|
|
106
|
+
},
|
|
107
|
+
requestHandler: createHttpHandler()
|
|
108
|
+
});
|
|
109
|
+
const version = projectDetails?.content?.version;
|
|
110
|
+
if (version) {
|
|
111
|
+
writeDebug(`Starting upload version ${version}`);
|
|
112
|
+
}
|
|
113
|
+
const basePath = options.path;
|
|
114
|
+
const files = await glob(joinPaths(basePath, "**/*"), {
|
|
115
|
+
ignore: "**/{*.stories.tsx,*.stories.ts,*.spec.tsx,*.spec.ts}"
|
|
116
|
+
});
|
|
117
|
+
const internalDependencies = await getInternalDependencies(
|
|
118
|
+
context.projectName,
|
|
119
|
+
projectGraph
|
|
120
|
+
);
|
|
121
|
+
const dependencies = internalDependencies.filter(
|
|
122
|
+
(projectNode) => !projectNode.data.tags || projectNode.data.tags.every((tag) => tag.toLowerCase() !== "component")
|
|
123
|
+
).reduce((ret, dep) => {
|
|
124
|
+
if (!ret[dep.name]) {
|
|
125
|
+
ret[dep.name] = "latest";
|
|
126
|
+
}
|
|
127
|
+
return ret;
|
|
128
|
+
}, projectDetails?.content.dependencies ?? {});
|
|
129
|
+
const release = options.tag ?? execSync("npm config get tag").toString().trim();
|
|
130
|
+
if (options.clean === true) {
|
|
131
|
+
writeDebug(`Clearing out existing items in ${bucketPath}`);
|
|
132
|
+
if (!isDryRun) {
|
|
133
|
+
const response = await client.send(
|
|
134
|
+
new ListObjectsCommand({
|
|
135
|
+
Bucket: bucketId,
|
|
136
|
+
Prefix: !bucketPath || bucketPath === "/" ? void 0 : bucketPath
|
|
137
|
+
})
|
|
138
|
+
);
|
|
139
|
+
if (response?.Contents && response.Contents.length > 0) {
|
|
140
|
+
writeTrace(
|
|
141
|
+
`Deleting the following existing items from the R2 bucket path ${bucketPath}: ${response.Contents.map((item) => item.Key).join(", ")}`
|
|
142
|
+
);
|
|
143
|
+
await client.send(
|
|
144
|
+
new DeleteObjectsCommand({
|
|
145
|
+
Bucket: bucketId,
|
|
146
|
+
Delete: {
|
|
147
|
+
Objects: response.Contents.map((item) => ({
|
|
148
|
+
Key: item.Key
|
|
149
|
+
})),
|
|
150
|
+
Quiet: false
|
|
151
|
+
}
|
|
152
|
+
})
|
|
153
|
+
);
|
|
154
|
+
} else {
|
|
155
|
+
writeDebug(
|
|
156
|
+
`No existing items to delete in the R2 bucket path ${bucketPath}`
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
} else {
|
|
160
|
+
writeWarning("[Dry run]: Skipping R2 bucket clean.");
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (options.writeMetaJson === true) {
|
|
164
|
+
const meta = {
|
|
165
|
+
name: context.projectName,
|
|
166
|
+
version,
|
|
167
|
+
release,
|
|
168
|
+
description: projectDetails?.content?.description,
|
|
169
|
+
tags: projectDetails?.content?.keywords,
|
|
170
|
+
dependencies,
|
|
171
|
+
devDependencies: null,
|
|
172
|
+
internalDependencies: internalDependencies.filter(
|
|
173
|
+
(projectNode) => projectNode.data.tags && projectNode.data.tags.some(
|
|
174
|
+
(tag) => tag.toLowerCase() === "component"
|
|
175
|
+
)
|
|
176
|
+
).map((dep) => dep.name)
|
|
177
|
+
};
|
|
178
|
+
if (projectDetails?.type === "package.json") {
|
|
179
|
+
meta.devDependencies = projectDetails?.content?.devDependencies;
|
|
180
|
+
}
|
|
181
|
+
await uploadFile(
|
|
182
|
+
client,
|
|
183
|
+
bucketId,
|
|
184
|
+
bucketPath,
|
|
185
|
+
"meta.json",
|
|
186
|
+
version,
|
|
187
|
+
JSON.stringify(meta),
|
|
188
|
+
"application/json",
|
|
189
|
+
isDryRun
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
await Promise.all(
|
|
193
|
+
files.map(async (file) => {
|
|
194
|
+
if (statSync(file, {
|
|
195
|
+
throwIfNoEntry: false
|
|
196
|
+
})?.isFile()) {
|
|
197
|
+
const name = correctPaths(file).replace(correctPaths(basePath), "");
|
|
198
|
+
const type = mime.lookup(name) || "application/octet-stream";
|
|
199
|
+
await uploadFile(
|
|
200
|
+
client,
|
|
201
|
+
bucketId,
|
|
202
|
+
bucketPath,
|
|
203
|
+
name,
|
|
204
|
+
version,
|
|
205
|
+
await readFile(file, getEncoding(type)),
|
|
206
|
+
type,
|
|
207
|
+
isDryRun
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
})
|
|
211
|
+
);
|
|
212
|
+
writeSuccess(
|
|
213
|
+
`Successfully uploaded the ${projectName} project to the Cloudflare R2 bucket.`,
|
|
214
|
+
config
|
|
215
|
+
);
|
|
216
|
+
return {
|
|
217
|
+
success: true
|
|
218
|
+
};
|
|
219
|
+
} catch (error) {
|
|
220
|
+
console.error("Failed to publish to Cloudflare R2 bucket");
|
|
221
|
+
console.error(error);
|
|
222
|
+
console.log("");
|
|
223
|
+
return {
|
|
224
|
+
success: false
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export {
|
|
230
|
+
runExecutor
|
|
231
|
+
};
|
|
@@ -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.127",
|
|
11
11
|
private: false,
|
|
12
12
|
description: "A Nx plugin package that contains various executors, generators, and utilities that assist in managing Cloudflare services.",
|
|
13
13
|
keywords: [
|
|
@@ -156,9 +156,9 @@ var require_package = _chunkMCKGQKYUjs.__commonJS.call(void 0, {
|
|
|
156
156
|
"@nx/js": "catalog:",
|
|
157
157
|
"@nx/node": "catalog:",
|
|
158
158
|
"@nx/web": "catalog:",
|
|
159
|
-
"@storm-software/config": "1.137.
|
|
160
|
-
"@storm-software/config-tools": "1.189.
|
|
161
|
-
"@storm-software/workspace-tools": "1.295.
|
|
159
|
+
"@storm-software/config": "1.137.31",
|
|
160
|
+
"@storm-software/config-tools": "1.189.77",
|
|
161
|
+
"@storm-software/workspace-tools": "1.295.53",
|
|
162
162
|
nx: "catalog:",
|
|
163
163
|
tsup: "catalog:",
|
|
164
164
|
wrangler: ">=3.58.0"
|
|
@@ -1209,7 +1209,7 @@ async function napiExecutor(options, context, config) {
|
|
|
1209
1209
|
"The Napi Build process failed because the project could not be found in the project graph. Please run this command from a workspace root directory."
|
|
1210
1210
|
);
|
|
1211
1211
|
}
|
|
1212
|
-
const projectRoot = _optionalChain([context, 'access', _85 => _85.projectGraph, 'optionalAccess', _86 => _86.nodes, 'access', _87 => _87[_nullishCoalesce(context.projectName, () => ( ""))], '
|
|
1212
|
+
const projectRoot = _optionalChain([context, 'access', _85 => _85.projectGraph, 'optionalAccess', _86 => _86.nodes, 'access', _87 => _87[_nullishCoalesce(context.projectName, () => ( ""))], 'optionalAccess', _88 => _88.data, 'access', _89 => _89.root]);
|
|
1213
1213
|
const packageJson = _chunkRIBK362Wjs.joinPaths.call(void 0, _nullishCoalesce(projectRoot, () => ( ".")), "package.json");
|
|
1214
1214
|
if (!_fileutils.fileExists.call(void 0, packageJson)) {
|
|
1215
1215
|
throw new Error(`Could not find package.json at ${packageJson}`);
|
|
@@ -1223,27 +1223,29 @@ async function napiExecutor(options, context, config) {
|
|
|
1223
1223
|
if (options.cwd) {
|
|
1224
1224
|
normalizedOptions.cwd = _chunkRIBK362Wjs.correctPaths.call(void 0, options.cwd);
|
|
1225
1225
|
} else {
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
config.workspaceRoot,
|
|
1229
|
-
projectRoot || "."
|
|
1226
|
+
const absoluteProjectRoot = _chunkRIBK362Wjs.correctPaths.call(void 0,
|
|
1227
|
+
_chunkRIBK362Wjs.joinPaths.call(void 0, config.workspaceRoot, projectRoot || ".")
|
|
1230
1228
|
);
|
|
1229
|
+
normalizedOptions.cwd = absoluteProjectRoot;
|
|
1231
1230
|
if (normalizedOptions.outputDir) {
|
|
1232
1231
|
normalizedOptions.outputDir = _chunkRIBK362Wjs.relative.call(void 0,
|
|
1233
|
-
|
|
1232
|
+
normalizedOptions.cwd,
|
|
1234
1233
|
_chunkRIBK362Wjs.correctPaths.call(void 0,
|
|
1235
1234
|
_chunkRIBK362Wjs.isAbsolute.call(void 0, normalizedOptions.outputDir) ? normalizedOptions.outputDir : _chunkRIBK362Wjs.joinPaths.call(void 0, config.workspaceRoot, normalizedOptions.outputDir)
|
|
1236
1235
|
)
|
|
1237
1236
|
);
|
|
1238
1237
|
}
|
|
1239
1238
|
if (normalizedOptions.packageJsonPath) {
|
|
1240
|
-
normalizedOptions.packageJsonPath = _chunkRIBK362Wjs.
|
|
1241
|
-
|
|
1239
|
+
normalizedOptions.packageJsonPath = _chunkRIBK362Wjs.relative.call(void 0,
|
|
1240
|
+
normalizedOptions.cwd,
|
|
1241
|
+
_chunkRIBK362Wjs.correctPaths.call(void 0,
|
|
1242
|
+
_chunkRIBK362Wjs.isAbsolute.call(void 0, normalizedOptions.packageJsonPath) ? normalizedOptions.packageJsonPath : _chunkRIBK362Wjs.joinPaths.call(void 0, config.workspaceRoot, normalizedOptions.packageJsonPath)
|
|
1243
|
+
)
|
|
1242
1244
|
);
|
|
1243
1245
|
}
|
|
1244
1246
|
if (normalizedOptions.configPath) {
|
|
1245
1247
|
normalizedOptions.configPath = _chunkRIBK362Wjs.relative.call(void 0,
|
|
1246
|
-
|
|
1248
|
+
normalizedOptions.cwd,
|
|
1247
1249
|
_chunkRIBK362Wjs.correctPaths.call(void 0,
|
|
1248
1250
|
_chunkRIBK362Wjs.isAbsolute.call(void 0, normalizedOptions.configPath) ? normalizedOptions.configPath : _chunkRIBK362Wjs.joinPaths.call(void 0, config.workspaceRoot, normalizedOptions.configPath)
|
|
1249
1251
|
)
|
|
@@ -1251,7 +1253,7 @@ async function napiExecutor(options, context, config) {
|
|
|
1251
1253
|
}
|
|
1252
1254
|
if (normalizedOptions.manifestPath) {
|
|
1253
1255
|
normalizedOptions.manifestPath = _chunkRIBK362Wjs.relative.call(void 0,
|
|
1254
|
-
|
|
1256
|
+
normalizedOptions.cwd,
|
|
1255
1257
|
_chunkRIBK362Wjs.correctPaths.call(void 0,
|
|
1256
1258
|
_chunkRIBK362Wjs.isAbsolute.call(void 0, normalizedOptions.manifestPath) ? normalizedOptions.manifestPath : _chunkRIBK362Wjs.joinPaths.call(void 0, config.workspaceRoot, normalizedOptions.manifestPath)
|
|
1257
1259
|
)
|
package/dist/executors.js
CHANGED
|
@@ -3,7 +3,7 @@ require('./chunk-FKBCEMBX.js');
|
|
|
3
3
|
require('./chunk-KUGEZPUO.js');
|
|
4
4
|
require('./chunk-SIS5VQAU.js');
|
|
5
5
|
require('./chunk-QBD2OGUY.js');
|
|
6
|
-
require('./chunk-
|
|
6
|
+
require('./chunk-VKHDTPKS.js');
|
|
7
7
|
require('./chunk-N7FW365Q.js');
|
|
8
8
|
require('./chunk-OEP2XBU4.js');
|
|
9
9
|
require('./chunk-RIBK362W.js');
|
package/dist/executors.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import "./chunk-B6RWRHGX.mjs";
|
|
|
3
3
|
import "./chunk-SWYYMID7.mjs";
|
|
4
4
|
import "./chunk-M3VAGNJQ.mjs";
|
|
5
5
|
import "./chunk-R5VXASXL.mjs";
|
|
6
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-IH75MSUE.mjs";
|
|
7
7
|
import "./chunk-3MAI3FU2.mjs";
|
|
8
8
|
import "./chunk-5QM4JUN3.mjs";
|
|
9
9
|
import "./chunk-ZDABHOZ2.mjs";
|
package/dist/generators.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkAVYOABJJjs = require('./chunk-AVYOABJJ.js');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkR4V44O2Fjs = require('./chunk-R4V44O2F.js');
|
|
10
10
|
require('./chunk-OEP2XBU4.js');
|
|
11
11
|
require('./chunk-RIBK362W.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 = _chunkAVYOABJJjs.applicationGenerator; exports.applicationSchematic = _chunkAVYOABJJjs.applicationSchematic; exports.initGenerator = _chunkR4V44O2Fjs.initGenerator; exports.initSchematic = _chunkR4V44O2Fjs.initSchematic;
|
package/dist/generators.mjs
CHANGED
|
@@ -2,11 +2,11 @@ import "./chunk-3J7KBHMJ.mjs";
|
|
|
2
2
|
import {
|
|
3
3
|
applicationGenerator,
|
|
4
4
|
applicationSchematic
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-FBBHHRSC.mjs";
|
|
6
6
|
import {
|
|
7
7
|
initGenerator,
|
|
8
8
|
initSchematic
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-6ZJP5W4Q.mjs";
|
|
10
10
|
import "./chunk-5QM4JUN3.mjs";
|
|
11
11
|
import "./chunk-ZDABHOZ2.mjs";
|
|
12
12
|
import "./chunk-HS6L6NAM.mjs";
|