Skip to content

Commit

Permalink
feat(create-cloudflare): update experimental remix template to be bas…
Browse files Browse the repository at this point in the history
…ed on its worker template (#7170)

* feat(create-cloudflare): update experimental remix template to be based on its worker template

* add changeset

* remove unused imports

* fix deploy command

* fix entrypoint file path
  • Loading branch information
edmundhung authored Nov 7, 2024
1 parent a4f5647 commit f292294
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 31 deletions.
5 changes: 5 additions & 0 deletions .changeset/young-lions-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-cloudflare": minor
---

feat: update experimental remix template to be based on its worker template
27 changes: 1 addition & 26 deletions packages/create-cloudflare/templates-experimental/remix/c3.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { logRaw } from "@cloudflare/cli";
import { brandColor, dim } from "@cloudflare/cli/colors";
import { spinner } from "@cloudflare/cli/interactive";
import { runFrameworkGenerator } from "frameworks/index";
import { transformFile } from "helpers/codemod";
import { detectPackageManager } from "helpers/packageManagers";
import { installPackages } from "helpers/packages";
import type { TemplateConfig } from "../../src/templates";
Expand All @@ -14,7 +12,7 @@ const generate = async (ctx: C3Context) => {
await runFrameworkGenerator(ctx, [
ctx.project.name,
"--template",
"https://github.com/remix-run/remix/tree/main/templates/cloudflare",
"https://github.com/remix-run/remix/tree/main/templates/cloudflare-workers",
]);

logRaw(""); // newline
Expand All @@ -26,27 +24,6 @@ const configure = async () => {
startText: "Updating the Wrangler version",
doneText: `${brandColor(`updated`)} ${dim("wrangler@latest")}`,
});

const typeDefsPath = "load-context.ts";

const s = spinner();
s.start(`Updating \`${typeDefsPath}\``);

// Remove the empty Env declaration from the template to allow the type from
// worker-configuration.d.ts to take over
transformFile(typeDefsPath, {
visitTSInterfaceDeclaration(n) {
if (n.node.id.type === "Identifier" && n.node.id.name !== "Env") {
return this.traverse(n);
}

// Removes the node
n.replace();
return false;
},
});

s.stop(`${brandColor("updated")} \`${dim(typeDefsPath)}\``);
};

const config: TemplateConfig = {
Expand All @@ -63,8 +40,6 @@ const config: TemplateConfig = {
configure,
transformPackageJson: async () => ({
scripts: {
build:
"remix vite:build && wrangler pages functions build --outdir build/worker",
deploy: `${npm} run build && wrangler deploy`,
preview: `${npm} run build && wrangler dev`,
"cf-typegen": `wrangler types`,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
_worker.js
_routes.json
_headers
_redirects
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#:schema node_modules/wrangler/config-schema.json
name = "<TBD>"
compatibility_date = "<TBD>"
main = "./build/worker/index.js"
main = "./server.ts"
assets = { directory = "./build/client" }

# Workers Logs
Expand Down

0 comments on commit f292294

Please sign in to comment.