import alchemy from "alchemy";
import { GitHubComment } from "alchemy/github";
import { CloudflareStateStore } from "alchemy/state";
import { R2Bucket, TanStackStart } from "alchemy/cloudflare";
const app = await alchemy("alchemy-start", {
stateStore: (scope) => new CloudflareStateStore(scope),
});
const r2 = await R2Bucket("r2");
export const website = await TanStackStart("website", {
bindings: {
R2: r2,
},
});
console.log({
url: website.url,
});
if (process.env.PULL_REQUEST) {
const previewUrl = worker.url;
await GitHubComment("pr-preview-comment", {
owner: process.env.GITHUB_REPOSITORY_OWNER || "your-username",
repository: process.env.GITHUB_REPOSITORY_NAME || "alchemy-start",
issueNumber: Number(process.env.PULL_REQUEST),
body: `
## 🚀 Preview Deployed
Your preview is ready!
**Preview URL:** ${previewUrl}
This preview was built from commit ${process.env.GITHUB_SHA}
---
<sub>🤖 This comment will be updated automatically when you push new commits to this PR.</sub>`,
});
}
await app.finalize();