@storm-software/cloudflare-tools
Version:
A Nx plugin package that contains various executors, generators, and utilities that assist in managing Cloudflare services.
45 lines (42 loc) • 1.24 kB
JavaScript
import {
writeDebug,
writeWarning
} from "./chunk-LVQQJNPK.mjs";
// src/utils/r2-bucket-helpers.ts
import { createHash } from "node:crypto";
var r2UploadFile = async (client, bucketName, projectPath, fileName, version, fileContent, contentType = "text/plain", isDryRun = false) => {
const checksum = createHash("sha256").update(fileContent).digest("base64");
const fileKey = `${projectPath}/${fileName.startsWith("/") ? fileName.substring(1) : fileName}`;
writeDebug(`Uploading file: ${fileKey}`);
if (!isDryRun) {
await client.putObject({
Bucket: bucketName,
Key: fileKey,
Body: fileContent.replaceAll(' from "@cyclone-ui/', ' from "../'),
ContentType: contentType,
Metadata: {
version,
checksum
}
});
} else {
writeWarning("[Dry run]: skipping upload to the Cyclone Registry.");
}
};
var getInternalDependencies = (projectName, graph) => {
const allDeps = graph.dependencies[projectName] ?? [];
return Array.from(
allDeps.reduce(
(acc, node) => {
const found = graph.nodes[node.target];
if (found) acc.push(found);
return acc;
},
[]
)
);
};
export {
r2UploadFile,
getInternalDependencies
};