@storm-software/cloudflare-tools 0.70.49 → 0.71.0
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/README.md +9 -2
- package/dist/chunk-7ESZB4KW.mjs +220 -0
- package/dist/{chunk-6KHWP2MO.js → chunk-BPUFICBM.js} +2 -2
- package/dist/{chunk-3JEOBMM5.mjs → chunk-C6B32MBV.mjs} +12 -8
- package/dist/{chunk-D4JUMEIC.js → chunk-DRYNN63F.js} +7 -6
- package/dist/{chunk-2B7ISOXH.mjs → chunk-J2DOKDIF.mjs} +8 -7
- package/dist/{chunk-UEJFDB6Y.mjs → chunk-QN6OKPMU.mjs} +1 -1
- package/dist/chunk-VHMJXOF4.js +220 -0
- package/dist/{chunk-YAUK66IM.js → chunk-W5IPHIXB.js} +11 -7
- package/dist/{chunk-BIFOD6C3.mjs → chunk-XDQBFBX4.mjs} +1 -1
- package/dist/{chunk-Y5VPR2KX.mjs → chunk-ZFJIFXOW.mjs} +4 -4
- package/dist/executors.d.mts +1 -1
- package/dist/executors.d.ts +1 -1
- package/dist/executors.js +2 -2
- package/dist/executors.mjs +4 -4
- package/dist/generators.js +3 -3
- package/dist/generators.mjs +3 -3
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -5
- package/dist/index.mjs +6 -6
- package/dist/schema.d-elsO8UQp.d.mts +88 -0
- package/dist/schema.d-elsO8UQp.d.ts +88 -0
- package/dist/src/executors/cloudflare-publish/executor.js +1 -1
- package/dist/src/executors/cloudflare-publish/executor.mjs +3 -3
- package/dist/src/executors/r2-upload-publish/executor.d.mts +1 -1
- package/dist/src/executors/r2-upload-publish/executor.d.ts +1 -1
- package/dist/src/executors/r2-upload-publish/executor.js +2 -2
- package/dist/src/executors/r2-upload-publish/executor.mjs +2 -2
- package/dist/src/executors/r2-upload-publish/schema.d.ts +86 -7
- package/dist/src/executors/r2-upload-publish/schema.json +63 -22
- package/dist/src/executors/serve/executor.js +2 -2
- 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/docs/api/executors/r2-upload-publish/schema.md +93 -0
- package/package.json +13 -12
- package/dist/chunk-IH7ZJRS7.js +0 -262
- package/dist/chunk-JEMQ2Y24.mjs +0 -265
- package/dist/chunk-KSZZYFCQ.js +0 -209
- package/dist/chunk-OTDPGPH4.js +0 -209
- package/dist/chunk-S3HIZ32I.mjs +0 -209
- package/dist/chunk-WBUCIAVK.mjs +0 -209
- package/dist/schema.d-oSirXiCO.d.mts +0 -11
- package/dist/schema.d-oSirXiCO.d.ts +0 -11
package/dist/chunk-JEMQ2Y24.mjs
DELETED
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
generator_default
|
|
3
|
-
} from "./chunk-2B7ISOXH.mjs";
|
|
4
|
-
import {
|
|
5
|
-
findWorkspaceRoot,
|
|
6
|
-
getConfig
|
|
7
|
-
} from "./chunk-PTTJW7MW.mjs";
|
|
8
|
-
import {
|
|
9
|
-
getStopwatch,
|
|
10
|
-
writeDebug,
|
|
11
|
-
writeError,
|
|
12
|
-
writeFatal,
|
|
13
|
-
writeInfo,
|
|
14
|
-
writeTrace
|
|
15
|
-
} from "./chunk-6MATO2MJ.mjs";
|
|
16
|
-
import {
|
|
17
|
-
__dirname
|
|
18
|
-
} from "./chunk-UEJFDB6Y.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/chunk-KSZZYFCQ.js
DELETED
|
@@ -1,209 +0,0 @@
|
|
|
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 _chunkNU34IEWNjs = require('./chunk-NU34IEWN.js');
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _chunkFFOLWRMAjs = require('./chunk-FFOLWRMA.js');
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _chunkEQXEFXCVjs = require('./chunk-EQXEFXCV.js');
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var _chunk4BWM53AAjs = require('./chunk-4BWM53AA.js');
|
|
19
|
-
|
|
20
|
-
// src/executors/r2-upload-publish/executor.ts
|
|
21
|
-
var _clients3 = require('@aws-sdk/client-s3');
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
var _devkit = require('@nx/devkit');
|
|
27
|
-
var _glob = require('glob');
|
|
28
|
-
var _child_process = require('child_process');
|
|
29
|
-
var _promises = require('fs/promises');
|
|
30
|
-
async function runExecutor(options, context) {
|
|
31
|
-
const isDryRun = process.env.NX_DRY_RUN === "true" || options.dryRun || false;
|
|
32
|
-
if (!context.projectName) {
|
|
33
|
-
throw new Error("The executor requires a projectName.");
|
|
34
|
-
}
|
|
35
|
-
console.info(
|
|
36
|
-
`\u{1F680} Running Storm Cloudflare Publish executor on the ${context.projectName} worker`
|
|
37
|
-
);
|
|
38
|
-
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])) {
|
|
39
|
-
throw new Error("The executor requires projectsConfigurations.");
|
|
40
|
-
}
|
|
41
|
-
try {
|
|
42
|
-
const workspaceRoot = _chunkEQXEFXCVjs.findWorkspaceRoot.call(void 0, );
|
|
43
|
-
const config = await _chunkEQXEFXCVjs.getConfig.call(void 0, workspaceRoot);
|
|
44
|
-
const sourceRoot = _nullishCoalesce(_optionalChain([context, 'access', _7 => _7.projectsConfigurations, 'access', _8 => _8.projects, 'access', _9 => _9[context.projectName], 'optionalAccess', _10 => _10.sourceRoot]), () => ( workspaceRoot));
|
|
45
|
-
const projectName = _nullishCoalesce(_optionalChain([context, 'access', _11 => _11.projectsConfigurations, 'access', _12 => _12.projects, 'access', _13 => _13[context.projectName], 'optionalAccess', _14 => _14.name]), () => ( context.projectName));
|
|
46
|
-
const projectDetails = _chunkNU34IEWNjs.getPackageInfo.call(void 0,
|
|
47
|
-
context.projectsConfigurations.projects[context.projectName]
|
|
48
|
-
);
|
|
49
|
-
if (!_optionalChain([projectDetails, 'optionalAccess', _15 => _15.content])) {
|
|
50
|
-
throw new Error(
|
|
51
|
-
`Could not find the project details for ${context.projectName}`
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
const args = _chunkNU34IEWNjs.createCliOptions.call(void 0, { ...options });
|
|
55
|
-
if (isDryRun) {
|
|
56
|
-
args.push("--dry-run");
|
|
57
|
-
}
|
|
58
|
-
const cloudflareAccountId = process.env.STORM_BOT_CLOUDFLARE_ACCOUNT;
|
|
59
|
-
if (!_optionalChain([options, 'optionalAccess', _16 => _16.registry]) && !cloudflareAccountId) {
|
|
60
|
-
throw new Error(
|
|
61
|
-
"The Storm Registry URL is not set in the Storm config. Please set either the `extensions.cyclone.registry` or `config.extensions.cyclone.accountId` property in the Storm config."
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
if (!process.env.AWS_ACCESS_KEY_ID || !process.env.AWS_SECRET_ACCESS_KEY) {
|
|
65
|
-
throw new Error(
|
|
66
|
-
"The AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables are not set. Please set these environment variables to upload to the Cyclone Registry."
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
const endpoint = _optionalChain([options, 'optionalAccess', _17 => _17.registry]) ? options.registry : `https://${cloudflareAccountId}.r2.cloudflarestorage.com`;
|
|
70
|
-
let projectGraph;
|
|
71
|
-
try {
|
|
72
|
-
projectGraph = _devkit.readCachedProjectGraph.call(void 0, );
|
|
73
|
-
} catch (e) {
|
|
74
|
-
await _devkit.createProjectGraphAsync.call(void 0, );
|
|
75
|
-
projectGraph = _devkit.readCachedProjectGraph.call(void 0, );
|
|
76
|
-
}
|
|
77
|
-
if (!projectGraph) {
|
|
78
|
-
throw new Error(
|
|
79
|
-
"The executor failed because the project graph is not available. Please run the build command again."
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
_chunk4BWM53AAjs.writeInfo.call(void 0,
|
|
83
|
-
`Publishing ${context.projectName} to the Storm Registry at ${endpoint}`
|
|
84
|
-
);
|
|
85
|
-
const s3Client = new (0, _clients3.S3)({
|
|
86
|
-
region: "auto",
|
|
87
|
-
endpoint,
|
|
88
|
-
credentials: {
|
|
89
|
-
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
90
|
-
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
const version = _optionalChain([projectDetails, 'access', _18 => _18.content, 'optionalAccess', _19 => _19.version]);
|
|
94
|
-
_chunk4BWM53AAjs.writeInfo.call(void 0, `Generated component version: ${version}`);
|
|
95
|
-
const files = await _glob.glob.call(void 0, _devkit.joinPathFragments.call(void 0, sourceRoot, "**/*"), {
|
|
96
|
-
ignore: "**/{*.stories.tsx,*.stories.ts,*.spec.tsx,*.spec.ts}"
|
|
97
|
-
});
|
|
98
|
-
const projectPath = `registry/${context.projectName}`;
|
|
99
|
-
const internalDependencies = await _chunkFFOLWRMAjs.getInternalDependencies.call(void 0,
|
|
100
|
-
context.projectName,
|
|
101
|
-
projectGraph
|
|
102
|
-
);
|
|
103
|
-
const dependencies = internalDependencies.filter(
|
|
104
|
-
(projectNode) => !projectNode.data.tags || projectNode.data.tags.every((tag) => tag.toLowerCase() !== "component")
|
|
105
|
-
).reduce((ret, dep) => {
|
|
106
|
-
if (!ret[dep.name]) {
|
|
107
|
-
ret[dep.name] = "latest";
|
|
108
|
-
}
|
|
109
|
-
return ret;
|
|
110
|
-
}, _nullishCoalesce(projectDetails.content.dependencies, () => ( {})));
|
|
111
|
-
const release = _nullishCoalesce(options.tag, () => ( _child_process.execSync.call(void 0, "npm config get tag").toString().trim()));
|
|
112
|
-
_chunk4BWM53AAjs.writeInfo.call(void 0, `Clearing out existing items in ${projectPath}`);
|
|
113
|
-
if (!isDryRun) {
|
|
114
|
-
const response = await s3Client.listObjects({
|
|
115
|
-
Bucket: options.bucketId,
|
|
116
|
-
Prefix: projectPath
|
|
117
|
-
});
|
|
118
|
-
if (_optionalChain([response, 'optionalAccess', _20 => _20.Contents]) && response.Contents.length > 0) {
|
|
119
|
-
_chunk4BWM53AAjs.writeDebug.call(void 0,
|
|
120
|
-
`Deleting the following existing items from the component registry: ${response.Contents.map((item) => item.Key).join(", ")}`
|
|
121
|
-
);
|
|
122
|
-
await Promise.all(
|
|
123
|
-
response.Contents.map(
|
|
124
|
-
(item) => s3Client.deleteObjects({
|
|
125
|
-
Bucket: options.bucketId,
|
|
126
|
-
Delete: {
|
|
127
|
-
Objects: [
|
|
128
|
-
{
|
|
129
|
-
Key: item.Key
|
|
130
|
-
}
|
|
131
|
-
],
|
|
132
|
-
Quiet: false
|
|
133
|
-
}
|
|
134
|
-
})
|
|
135
|
-
)
|
|
136
|
-
);
|
|
137
|
-
} else {
|
|
138
|
-
_chunk4BWM53AAjs.writeDebug.call(void 0,
|
|
139
|
-
`No existing items to delete in the component registry path ${projectPath}`
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
} else {
|
|
143
|
-
_chunk4BWM53AAjs.writeWarning.call(void 0, "[Dry run]: skipping upload to the Cyclone Registry.");
|
|
144
|
-
}
|
|
145
|
-
const meta = {
|
|
146
|
-
name: context.projectName,
|
|
147
|
-
version,
|
|
148
|
-
release,
|
|
149
|
-
description: projectDetails.content.description,
|
|
150
|
-
tags: projectDetails.content.keywords,
|
|
151
|
-
dependencies,
|
|
152
|
-
devDependencies: null,
|
|
153
|
-
internalDependencies: internalDependencies.filter(
|
|
154
|
-
(projectNode) => projectNode.data.tags && projectNode.data.tags.some((tag) => tag.toLowerCase() === "component")
|
|
155
|
-
).map((dep) => dep.name)
|
|
156
|
-
};
|
|
157
|
-
if (projectDetails.type === "package.json") {
|
|
158
|
-
meta.devDependencies = projectDetails.content.devDependencies;
|
|
159
|
-
}
|
|
160
|
-
const metaJson = JSON.stringify(meta);
|
|
161
|
-
_chunk4BWM53AAjs.writeInfo.call(void 0, `Generating meta.json file:
|
|
162
|
-
${metaJson}`);
|
|
163
|
-
await _chunkFFOLWRMAjs.r2UploadFile.call(void 0,
|
|
164
|
-
s3Client,
|
|
165
|
-
options.bucketId,
|
|
166
|
-
projectPath,
|
|
167
|
-
"meta.json",
|
|
168
|
-
version,
|
|
169
|
-
metaJson,
|
|
170
|
-
"application/json",
|
|
171
|
-
isDryRun
|
|
172
|
-
);
|
|
173
|
-
await Promise.all(
|
|
174
|
-
files.map((file) => {
|
|
175
|
-
const fileName = file.replaceAll("\\", "/").replace(sourceRoot.replaceAll("\\", "/"), "");
|
|
176
|
-
return _promises.readFile.call(void 0, file, { encoding: "utf8" }).then(
|
|
177
|
-
(fileContent) => _chunkFFOLWRMAjs.r2UploadFile.call(void 0,
|
|
178
|
-
s3Client,
|
|
179
|
-
options.bucketId,
|
|
180
|
-
projectPath,
|
|
181
|
-
fileName,
|
|
182
|
-
version,
|
|
183
|
-
fileContent,
|
|
184
|
-
"text/plain",
|
|
185
|
-
isDryRun
|
|
186
|
-
)
|
|
187
|
-
);
|
|
188
|
-
})
|
|
189
|
-
);
|
|
190
|
-
_chunk4BWM53AAjs.writeSuccess.call(void 0,
|
|
191
|
-
`Successfully uploaded the ${projectName} component to the Cyclone Registry`,
|
|
192
|
-
config
|
|
193
|
-
);
|
|
194
|
-
return {
|
|
195
|
-
success: true
|
|
196
|
-
};
|
|
197
|
-
} catch (error) {
|
|
198
|
-
console.error("Failed to publish to Cloudflare Workers Registry");
|
|
199
|
-
console.error(error);
|
|
200
|
-
console.log("");
|
|
201
|
-
return {
|
|
202
|
-
success: false
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
exports.runExecutor = runExecutor;
|
package/dist/chunk-OTDPGPH4.js
DELETED
|
@@ -1,209 +0,0 @@
|
|
|
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 _chunkFFOLWRMAjs = require('./chunk-FFOLWRMA.js');
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _chunkNU34IEWNjs = require('./chunk-NU34IEWN.js');
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _chunkEQXEFXCVjs = require('./chunk-EQXEFXCV.js');
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var _chunk4BWM53AAjs = require('./chunk-4BWM53AA.js');
|
|
19
|
-
|
|
20
|
-
// src/executors/r2-upload-publish/executor.ts
|
|
21
|
-
var _clients3 = require('@aws-sdk/client-s3');
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
var _devkit = require('@nx/devkit');
|
|
27
|
-
var _glob = require('glob');
|
|
28
|
-
var _child_process = require('child_process');
|
|
29
|
-
var _promises = require('fs/promises');
|
|
30
|
-
async function runExecutor(options, context) {
|
|
31
|
-
const isDryRun = process.env.NX_DRY_RUN === "true" || options.dryRun || false;
|
|
32
|
-
if (!context.projectName) {
|
|
33
|
-
throw new Error("The executor requires a projectName.");
|
|
34
|
-
}
|
|
35
|
-
console.info(
|
|
36
|
-
`\u{1F680} Running Storm Cloudflare Publish executor on the ${context.projectName} worker`
|
|
37
|
-
);
|
|
38
|
-
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])) {
|
|
39
|
-
throw new Error("The executor requires projectsConfigurations.");
|
|
40
|
-
}
|
|
41
|
-
try {
|
|
42
|
-
const workspaceRoot = _chunkEQXEFXCVjs.findWorkspaceRoot.call(void 0, );
|
|
43
|
-
const config = await _chunkEQXEFXCVjs.getConfig.call(void 0, workspaceRoot);
|
|
44
|
-
const sourceRoot = _nullishCoalesce(_optionalChain([context, 'access', _7 => _7.projectsConfigurations, 'access', _8 => _8.projects, 'access', _9 => _9[context.projectName], 'optionalAccess', _10 => _10.sourceRoot]), () => ( workspaceRoot));
|
|
45
|
-
const projectName = _nullishCoalesce(_optionalChain([context, 'access', _11 => _11.projectsConfigurations, 'access', _12 => _12.projects, 'access', _13 => _13[context.projectName], 'optionalAccess', _14 => _14.name]), () => ( context.projectName));
|
|
46
|
-
const projectDetails = _chunkNU34IEWNjs.getPackageInfo.call(void 0,
|
|
47
|
-
context.projectsConfigurations.projects[context.projectName]
|
|
48
|
-
);
|
|
49
|
-
if (!_optionalChain([projectDetails, 'optionalAccess', _15 => _15.content])) {
|
|
50
|
-
throw new Error(
|
|
51
|
-
`Could not find the project details for ${context.projectName}`
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
const args = _chunkNU34IEWNjs.createCliOptions.call(void 0, { ...options });
|
|
55
|
-
if (isDryRun) {
|
|
56
|
-
args.push("--dry-run");
|
|
57
|
-
}
|
|
58
|
-
const cloudflareAccountId = process.env.STORM_BOT_CLOUDFLARE_ACCOUNT;
|
|
59
|
-
if (!_optionalChain([options, 'optionalAccess', _16 => _16.registry]) && !cloudflareAccountId) {
|
|
60
|
-
throw new Error(
|
|
61
|
-
"The Storm Registry URL is not set in the Storm config. Please set either the `extensions.cyclone.registry` or `config.extensions.cyclone.accountId` property in the Storm config."
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
if (!process.env.AWS_ACCESS_KEY_ID || !process.env.AWS_SECRET_ACCESS_KEY) {
|
|
65
|
-
throw new Error(
|
|
66
|
-
"The AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables are not set. Please set these environment variables to upload to the Cyclone Registry."
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
const endpoint = _optionalChain([options, 'optionalAccess', _17 => _17.registry]) ? options.registry : `https://${cloudflareAccountId}.r2.cloudflarestorage.com`;
|
|
70
|
-
let projectGraph;
|
|
71
|
-
try {
|
|
72
|
-
projectGraph = _devkit.readCachedProjectGraph.call(void 0, );
|
|
73
|
-
} catch (e) {
|
|
74
|
-
await _devkit.createProjectGraphAsync.call(void 0, );
|
|
75
|
-
projectGraph = _devkit.readCachedProjectGraph.call(void 0, );
|
|
76
|
-
}
|
|
77
|
-
if (!projectGraph) {
|
|
78
|
-
throw new Error(
|
|
79
|
-
"The executor failed because the project graph is not available. Please run the build command again."
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
_chunk4BWM53AAjs.writeInfo.call(void 0,
|
|
83
|
-
`Publishing ${context.projectName} to the Storm Registry at ${endpoint}`
|
|
84
|
-
);
|
|
85
|
-
const s3Client = new (0, _clients3.S3)({
|
|
86
|
-
region: "auto",
|
|
87
|
-
endpoint,
|
|
88
|
-
credentials: {
|
|
89
|
-
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
90
|
-
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
const version = _optionalChain([projectDetails, 'access', _18 => _18.content, 'optionalAccess', _19 => _19.version]);
|
|
94
|
-
_chunk4BWM53AAjs.writeInfo.call(void 0, `Generated component version: ${version}`);
|
|
95
|
-
const files = await _glob.glob.call(void 0, _devkit.joinPathFragments.call(void 0, sourceRoot, "**/*"), {
|
|
96
|
-
ignore: "**/{*.stories.tsx,*.stories.ts,*.spec.tsx,*.spec.ts}"
|
|
97
|
-
});
|
|
98
|
-
const projectPath = `registry/${context.projectName}`;
|
|
99
|
-
const internalDependencies = await _chunkFFOLWRMAjs.getInternalDependencies.call(void 0,
|
|
100
|
-
context.projectName,
|
|
101
|
-
projectGraph
|
|
102
|
-
);
|
|
103
|
-
const dependencies = internalDependencies.filter(
|
|
104
|
-
(projectNode) => !projectNode.data.tags || projectNode.data.tags.every((tag) => tag.toLowerCase() !== "component")
|
|
105
|
-
).reduce((ret, dep) => {
|
|
106
|
-
if (!ret[dep.name]) {
|
|
107
|
-
ret[dep.name] = "latest";
|
|
108
|
-
}
|
|
109
|
-
return ret;
|
|
110
|
-
}, _nullishCoalesce(projectDetails.content.dependencies, () => ( {})));
|
|
111
|
-
const release = _nullishCoalesce(options.tag, () => ( _child_process.execSync.call(void 0, "npm config get tag").toString().trim()));
|
|
112
|
-
_chunk4BWM53AAjs.writeInfo.call(void 0, `Clearing out existing items in ${projectPath}`);
|
|
113
|
-
if (!isDryRun) {
|
|
114
|
-
const response = await s3Client.listObjects({
|
|
115
|
-
Bucket: options.bucketId,
|
|
116
|
-
Prefix: projectPath
|
|
117
|
-
});
|
|
118
|
-
if (_optionalChain([response, 'optionalAccess', _20 => _20.Contents]) && response.Contents.length > 0) {
|
|
119
|
-
_chunk4BWM53AAjs.writeDebug.call(void 0,
|
|
120
|
-
`Deleting the following existing items from the component registry: ${response.Contents.map((item) => item.Key).join(", ")}`
|
|
121
|
-
);
|
|
122
|
-
await Promise.all(
|
|
123
|
-
response.Contents.map(
|
|
124
|
-
(item) => s3Client.deleteObjects({
|
|
125
|
-
Bucket: options.bucketId,
|
|
126
|
-
Delete: {
|
|
127
|
-
Objects: [
|
|
128
|
-
{
|
|
129
|
-
Key: item.Key
|
|
130
|
-
}
|
|
131
|
-
],
|
|
132
|
-
Quiet: false
|
|
133
|
-
}
|
|
134
|
-
})
|
|
135
|
-
)
|
|
136
|
-
);
|
|
137
|
-
} else {
|
|
138
|
-
_chunk4BWM53AAjs.writeDebug.call(void 0,
|
|
139
|
-
`No existing items to delete in the component registry path ${projectPath}`
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
} else {
|
|
143
|
-
_chunk4BWM53AAjs.writeWarning.call(void 0, "[Dry run]: skipping upload to the Cyclone Registry.");
|
|
144
|
-
}
|
|
145
|
-
const meta = {
|
|
146
|
-
name: context.projectName,
|
|
147
|
-
version,
|
|
148
|
-
release,
|
|
149
|
-
description: projectDetails.content.description,
|
|
150
|
-
tags: projectDetails.content.keywords,
|
|
151
|
-
dependencies,
|
|
152
|
-
devDependencies: null,
|
|
153
|
-
internalDependencies: internalDependencies.filter(
|
|
154
|
-
(projectNode) => projectNode.data.tags && projectNode.data.tags.some((tag) => tag.toLowerCase() === "component")
|
|
155
|
-
).map((dep) => dep.name)
|
|
156
|
-
};
|
|
157
|
-
if (projectDetails.type === "package.json") {
|
|
158
|
-
meta.devDependencies = projectDetails.content.devDependencies;
|
|
159
|
-
}
|
|
160
|
-
const metaJson = JSON.stringify(meta);
|
|
161
|
-
_chunk4BWM53AAjs.writeInfo.call(void 0, `Generating meta.json file:
|
|
162
|
-
${metaJson}`);
|
|
163
|
-
await _chunkFFOLWRMAjs.r2UploadFile.call(void 0,
|
|
164
|
-
s3Client,
|
|
165
|
-
options.bucketId,
|
|
166
|
-
projectPath,
|
|
167
|
-
"meta.json",
|
|
168
|
-
version,
|
|
169
|
-
metaJson,
|
|
170
|
-
"application/json",
|
|
171
|
-
isDryRun
|
|
172
|
-
);
|
|
173
|
-
await Promise.all(
|
|
174
|
-
files.map((file) => {
|
|
175
|
-
const fileName = file.replaceAll("\\", "/").replace(sourceRoot.replaceAll("\\", "/"), "");
|
|
176
|
-
return _promises.readFile.call(void 0, file, { encoding: "utf8" }).then(
|
|
177
|
-
(fileContent) => _chunkFFOLWRMAjs.r2UploadFile.call(void 0,
|
|
178
|
-
s3Client,
|
|
179
|
-
options.bucketId,
|
|
180
|
-
projectPath,
|
|
181
|
-
fileName,
|
|
182
|
-
version,
|
|
183
|
-
fileContent,
|
|
184
|
-
"text/plain",
|
|
185
|
-
isDryRun
|
|
186
|
-
)
|
|
187
|
-
);
|
|
188
|
-
})
|
|
189
|
-
);
|
|
190
|
-
_chunk4BWM53AAjs.writeSuccess.call(void 0,
|
|
191
|
-
`Successfully uploaded the ${projectName} component to the Cyclone Registry`,
|
|
192
|
-
config
|
|
193
|
-
);
|
|
194
|
-
return {
|
|
195
|
-
success: true
|
|
196
|
-
};
|
|
197
|
-
} catch (error) {
|
|
198
|
-
console.error("Failed to publish to Cloudflare Workers Registry");
|
|
199
|
-
console.error(error);
|
|
200
|
-
console.log("");
|
|
201
|
-
return {
|
|
202
|
-
success: false
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
exports.runExecutor = runExecutor;
|