Skip to content

Commit

Permalink
make sure C3 works with the latest astro versions (experimental)
Browse files Browse the repository at this point in the history
  • Loading branch information
dario-piotrowicz committed Dec 10, 2024
1 parent 62fded8 commit 2cf4c69
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 2 deletions.
18 changes: 16 additions & 2 deletions packages/create-cloudflare/templates-experimental/astro/c3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { blue, brandColor, dim } from "@cloudflare/cli/colors";
import { runFrameworkGenerator } from "frameworks/index";
import { loadTemplateSnippets, transformFile } from "helpers/codemod";
import { runCommand } from "helpers/command";
import { usesTypescript } from "helpers/files";
import { hasTsConfig, usesTypescript } from "helpers/files";
import { detectPackageManager } from "helpers/packageManagers";
import * as recast from "recast";
import type { TemplateConfig } from "../../src/templates";
Expand Down Expand Up @@ -95,7 +95,21 @@ const config: TemplateConfig = {
platform: "workers",
displayName: "Astro",
copyFiles: {
path: "./templates",
async selectVariant(ctx) {
// Note: this `selectVariant` function should not be needed
// this is just a quick workaround until
// https://github.com/cloudflare/workers-sdk/issues/7495
// is resolved
return hasTsConfig(ctx.project.path) ? "ts" : "js";
},
variants: {
js: {
path: "./templates/js",
},
ts: {
path: "./templates/ts",
},
},
},
devScript: "dev",
deployScript: "deploy",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type Runtime = import("@astrojs/cloudflare").Runtime<Env>;

declare namespace App {
interface Locals extends Runtime {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
_worker.js
_routes.json
_headers
_redirects
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#:schema node_modules/wrangler/config-schema.json
name = "<TBD>"
compatibility_date = "<TBD>"
compatibility_flags = ["nodejs_compat_v2"]
main = "./dist/_worker.js/index.js"
assets = { directory = "./dist", binding = "ASSETS" }

# Workers Logs
# Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/
# Configuration: https://developers.cloudflare.com/workers/observability/logs/workers-logs/#enable-workers-logs
[observability]
enabled = true

0 comments on commit 2cf4c69

Please sign in to comment.