Skip to content

Commit 0fe3260

Browse files
authored
chore: graduate workers + assets remix template (#8552)
* graduate remix * remix fixup * changeset * fix test * actually fix
1 parent 3b1d081 commit 0fe3260

File tree

12 files changed

+104
-87
lines changed

12 files changed

+104
-87
lines changed

.changeset/silent-trees-shout.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"create-cloudflare": patch
3+
---
4+
5+
Graduate remix Workers + Assets template from experimental
6+
7+
You will no longer need to pass in the `--experimental` flag to access this template.

packages/create-cloudflare/e2e-tests/frameworks/framework-test-config-experimental.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,6 @@ export default function getFrameworkTestConfigExperimental() {
4444
envInterfaceName: "Env",
4545
},
4646
},
47-
remix: {
48-
testCommitMessage: true,
49-
timeout: LONG_TIMEOUT,
50-
unsupportedPms: ["yarn"],
51-
unsupportedOSs: ["win32"],
52-
verifyDeploy: {
53-
route: "/",
54-
expectedText: "Welcome to Remix",
55-
},
56-
verifyPreview: {
57-
route: "/test",
58-
expectedText: "C3_TEST",
59-
},
60-
verifyBuildCfTypes: {
61-
outputFile: "worker-configuration.d.ts",
62-
envInterfaceName: "Env",
63-
},
64-
flags: ["--typescript", "--no-install", "--no-git-init"],
65-
},
6647
next: {
6748
testCommitMessage: true,
6849
flags: [

packages/create-cloudflare/e2e-tests/frameworks/framework-test-config.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,8 @@ export default function getFrameworkTestConfig(pm: string) {
248248
envInterfaceName: "Env",
249249
},
250250
},
251-
remix: {
251+
"remix:pages": {
252+
argv: ["--platform", "pages"],
252253
testCommitMessage: true,
253254
timeout: LONG_TIMEOUT,
254255
unsupportedPms: ["yarn"],
@@ -273,6 +274,26 @@ export default function getFrameworkTestConfig(pm: string) {
273274
},
274275
flags: ["--typescript", "--no-install", "--no-git-init"],
275276
},
277+
"remix:workers": {
278+
argv: ["--platform", "workers"],
279+
testCommitMessage: true,
280+
timeout: LONG_TIMEOUT,
281+
unsupportedPms: ["yarn"],
282+
unsupportedOSs: ["win32"],
283+
verifyDeploy: {
284+
route: "/",
285+
expectedText: "Welcome to Remix",
286+
},
287+
verifyPreview: {
288+
route: "/test",
289+
expectedText: "C3_TEST",
290+
},
291+
verifyBuildCfTypes: {
292+
outputFile: "worker-configuration.d.ts",
293+
envInterfaceName: "Env",
294+
},
295+
flags: ["--typescript", "--no-install", "--no-git-init"],
296+
},
276297
next: {
277298
promptHandlers: [
278299
{

packages/create-cloudflare/src/templates.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import {
2121
import honoTemplateExperimental from "templates-experimental/hono/c3";
2222
import nextTemplateExperimental from "templates-experimental/next/c3";
2323
import qwikTemplateExperimental from "templates-experimental/qwik/c3";
24-
import remixTemplateExperimental from "templates-experimental/remix/c3";
2524
import solidTemplateExperimental from "templates-experimental/solid/c3";
2625
import svelteTemplateExperimental from "templates-experimental/svelte/c3";
2726
import analogTemplate from "templates/analog/c3";
@@ -178,7 +177,6 @@ export function getFrameworkMap({ experimental = false }): TemplateMap {
178177
hono: honoTemplateExperimental,
179178
next: nextTemplateExperimental,
180179
qwik: qwikTemplateExperimental,
181-
remix: remixTemplateExperimental,
182180
solid: solidTemplateExperimental,
183181
svelte: svelteTemplateExperimental,
184182
};
Lines changed: 5 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,9 @@
1-
import { logRaw } from "@cloudflare/cli";
2-
import { brandColor, dim } from "@cloudflare/cli/colors";
3-
import { spinner } from "@cloudflare/cli/interactive";
4-
import { runFrameworkGenerator } from "frameworks/index";
5-
import { transformFile } from "helpers/codemod";
6-
import { detectPackageManager } from "helpers/packageManagers";
7-
import type { TemplateConfig } from "../../src/templates";
8-
import type { C3Context } from "types";
1+
import pages from "./pages/c3";
2+
import workers from "./workers/c3";
3+
import type { MultiPlatformTemplateConfig } from "../../src/templates";
94

10-
const { npm } = detectPackageManager();
11-
12-
const generate = async (ctx: C3Context) => {
13-
await runFrameworkGenerator(ctx, [
14-
ctx.project.name,
15-
"--template",
16-
"https://github.com/remix-run/remix/tree/main/templates/cloudflare",
17-
]);
18-
19-
logRaw(""); // newline
20-
};
21-
22-
const configure = async () => {
23-
const typeDefsPath = "load-context.ts";
24-
25-
const s = spinner();
26-
s.start(`Updating \`${typeDefsPath}\``);
27-
28-
// Remove the empty Env declaration from the template to allow the type from
29-
// worker-configuration.d.ts to take over
30-
transformFile(typeDefsPath, {
31-
visitTSInterfaceDeclaration(n) {
32-
if (n.node.id.type === "Identifier" && n.node.id.name !== "Env") {
33-
return this.traverse(n);
34-
}
35-
36-
// Removes the node
37-
n.replace();
38-
return false;
39-
},
40-
});
41-
42-
s.stop(`${brandColor("updated")} \`${dim(typeDefsPath)}\``);
43-
};
44-
45-
const config: TemplateConfig = {
46-
configVersion: 1,
47-
id: "remix",
48-
frameworkCli: "create-remix",
49-
platform: "pages",
5+
const config: MultiPlatformTemplateConfig = {
506
displayName: "Remix",
51-
copyFiles: {
52-
path: "./templates",
53-
},
54-
generate,
55-
configure,
56-
transformPackageJson: async () => ({
57-
scripts: {
58-
deploy: `${npm} run build && wrangler pages deploy`,
59-
preview: `${npm} run build && wrangler pages dev`,
60-
"cf-typegen": `wrangler types`,
61-
},
62-
}),
63-
devScript: "dev",
64-
deployScript: "deploy",
65-
previewScript: "preview",
7+
platformVariants: { pages, workers },
668
};
679
export default config;
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import { logRaw } from "@cloudflare/cli";
2+
import { brandColor, dim } from "@cloudflare/cli/colors";
3+
import { spinner } from "@cloudflare/cli/interactive";
4+
import { runFrameworkGenerator } from "frameworks/index";
5+
import { transformFile } from "helpers/codemod";
6+
import { detectPackageManager } from "helpers/packageManagers";
7+
import type { TemplateConfig } from "../../../src/templates";
8+
import type { C3Context } from "types";
9+
10+
const { npm } = detectPackageManager();
11+
12+
const generate = async (ctx: C3Context) => {
13+
await runFrameworkGenerator(ctx, [
14+
ctx.project.name,
15+
"--template",
16+
"https://github.com/remix-run/remix/tree/main/templates/cloudflare",
17+
]);
18+
19+
logRaw(""); // newline
20+
};
21+
22+
const configure = async () => {
23+
const typeDefsPath = "load-context.ts";
24+
25+
const s = spinner();
26+
s.start(`Updating \`${typeDefsPath}\``);
27+
28+
// Remove the empty Env declaration from the template to allow the type from
29+
// worker-configuration.d.ts to take over
30+
transformFile(typeDefsPath, {
31+
visitTSInterfaceDeclaration(n) {
32+
if (n.node.id.type === "Identifier" && n.node.id.name !== "Env") {
33+
return this.traverse(n);
34+
}
35+
36+
// Removes the node
37+
n.replace();
38+
return false;
39+
},
40+
});
41+
42+
s.stop(`${brandColor("updated")} \`${dim(typeDefsPath)}\``);
43+
};
44+
45+
const config: TemplateConfig = {
46+
configVersion: 1,
47+
id: "remix",
48+
frameworkCli: "create-remix",
49+
platform: "pages",
50+
displayName: "Remix",
51+
copyFiles: {
52+
path: "./templates",
53+
},
54+
path: "templates/remix/pages",
55+
generate,
56+
configure,
57+
transformPackageJson: async () => ({
58+
scripts: {
59+
deploy: `${npm} run build && wrangler pages deploy`,
60+
preview: `${npm} run build && wrangler pages dev`,
61+
"cf-typegen": `wrangler types`,
62+
},
63+
}),
64+
devScript: "dev",
65+
deployScript: "deploy",
66+
previewScript: "preview",
67+
};
68+
export default config;
File renamed without changes.
File renamed without changes.

packages/create-cloudflare/templates-experimental/remix/c3.ts renamed to packages/create-cloudflare/templates/remix/workers/c3.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { brandColor, dim } from "@cloudflare/cli/colors";
33
import { runFrameworkGenerator } from "frameworks/index";
44
import { detectPackageManager } from "helpers/packageManagers";
55
import { installPackages } from "helpers/packages";
6-
import type { TemplateConfig } from "../../src/templates";
6+
import type { TemplateConfig } from "../../../src/templates";
77
import type { C3Context } from "types";
88

99
const { npm } = detectPackageManager();
@@ -35,7 +35,7 @@ const config: TemplateConfig = {
3535
copyFiles: {
3636
path: "./templates",
3737
},
38-
path: "templates-experimental/remix",
38+
path: "templates/remix/workers",
3939
generate,
4040
configure,
4141
transformPackageJson: async () => ({
File renamed without changes.

0 commit comments

Comments
 (0)