Skip to content

Commit ce295bf

Browse files
Support Qwik in autoconfig (#11472)
* Support Qwik in autoconfig * remove unnecessary src/entry.cloudflare-pages.tsx step
1 parent 0c71b87 commit ce295bf

File tree

12 files changed

+237
-95
lines changed

12 files changed

+237
-95
lines changed

‎.changeset/famous-wasps-read.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"create-cloudflare": patch
3+
---
4+
5+
Support Qwik in `--experimental` mode

‎.changeset/forty-glasses-think.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wrangler": minor
3+
---
4+
5+
Support Qwik projects in autoconfig

‎.changeset/sweet-adults-open.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+
fix: remove unnecessary step in qwik templates
6+
7+
The step that modifies the `src/entry.cloudflare-pages.tsx` file doesn't seem to change the file in any way anymore, so it's been removed

‎packages/create-cloudflare/e2e/tests/cli/cli.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ describe("Create Cloudflare CLI", () => {
555555
npm create cloudflare -- --framework next -- --ts
556556
pnpm create cloudflare --framework next -- --ts
557557
Allowed Values:
558-
gatsby, svelte, docusaurus, astro, tanstack-start, angular, solid
558+
gatsby, svelte, docusaurus, astro, tanstack-start, angular, solid, qwik
559559
--platform=<value>
560560
Whether the application should be deployed to Pages or Workers. This is only applicable for Frameworks templates that support both Pages and Workers.
561561
Allowed Values:

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,31 @@ function getExperimentalFrameworkTestConfig(
793793
nodeCompat: true,
794794
verifyTypes: false,
795795
},
796+
{
797+
name: "qwik:workers",
798+
argv: ["--platform", "workers"],
799+
promptHandlers: [
800+
{
801+
matcher: /Yes looks good, finish update/,
802+
input: [keys.enter],
803+
},
804+
],
805+
flags: [],
806+
testCommitMessage: true,
807+
unsupportedOSs: ["win32"],
808+
unsupportedPms: ["yarn"],
809+
verifyDeploy: {
810+
route: "/",
811+
expectedText: "Welcome to Qwik",
812+
},
813+
verifyPreview: {
814+
previewArgs: ["--inspector-port=0"],
815+
route: "/",
816+
expectedText: "Welcome to Qwik",
817+
},
818+
nodeCompat: true,
819+
verifyTypes: false,
820+
},
796821
];
797822
}
798823

‎packages/create-cloudflare/src/templates.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ export function getFrameworkMap({ experimental = false }): TemplateMap {
243243
"tanstack-start": tanStackStartTemplate,
244244
angular: angularTemplate,
245245
solid: solidTemplate,
246+
qwik: qwikTemplate,
246247
};
247248
} else {
248249
return {

‎packages/create-cloudflare/templates/qwik/pages/c3.ts‎

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ const configure = async (ctx: C3Context) => {
2424
await runCommand(cmd);
2525

2626
addBindingsProxy(ctx);
27-
populateCloudflareEnv();
2827
};
2928

3029
const addBindingsProxy = (ctx: C3Context) => {
@@ -89,40 +88,6 @@ const addBindingsProxy = (ctx: C3Context) => {
8988
s.stop(`${brandColor("updated")} \`vite.config.ts\``);
9089
};
9190

92-
const populateCloudflareEnv = () => {
93-
const entrypointPath = "src/entry.cloudflare-pages.tsx";
94-
95-
const s = spinner();
96-
s.start(`Updating \`${entrypointPath}\``);
97-
98-
transformFile(entrypointPath, {
99-
visitTSInterfaceDeclaration: function (n) {
100-
const b = recast.types.builders;
101-
const id = n.node.id as recast.types.namedTypes.Identifier;
102-
if (id.name !== "QwikCityPlatform") {
103-
this.traverse(n);
104-
}
105-
106-
const newBody = [
107-
["env", "Env"],
108-
// Qwik doesn't supply `cf` to the platform object. Should they do so, uncomment this
109-
// ["cf", "CfProperties"],
110-
].map(([varName, type]) =>
111-
b.tsPropertySignature(
112-
b.identifier(varName),
113-
b.tsTypeAnnotation(b.tsTypeReference(b.identifier(type))),
114-
),
115-
);
116-
117-
n.node.body.body = newBody;
118-
119-
return false;
120-
},
121-
});
122-
123-
s.stop(`${brandColor("updated")} \`${entrypointPath}\``);
124-
};
125-
12691
const config: TemplateConfig = {
12792
configVersion: 1,
12893
id: "qwik",

‎packages/create-cloudflare/templates/qwik/workers/c3.ts‎

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ const configure = async (ctx: C3Context) => {
2727
removeFile("./public/_routes.json");
2828

2929
addBindingsProxy(ctx);
30-
populateCloudflareEnv();
3130
};
3231

3332
const addBindingsProxy = (ctx: C3Context) => {
@@ -92,40 +91,6 @@ const addBindingsProxy = (ctx: C3Context) => {
9291
s.stop(`${brandColor("updated")} \`vite.config.ts\``);
9392
};
9493

95-
const populateCloudflareEnv = () => {
96-
const entrypointPath = "src/entry.cloudflare-pages.tsx";
97-
98-
const s = spinner();
99-
s.start(`Updating \`${entrypointPath}\``);
100-
101-
transformFile(entrypointPath, {
102-
visitTSInterfaceDeclaration: function (n) {
103-
const b = recast.types.builders;
104-
const id = n.node.id as recast.types.namedTypes.Identifier;
105-
if (id.name !== "QwikCityPlatform") {
106-
this.traverse(n);
107-
}
108-
109-
const newBody = [
110-
["env", "Env"],
111-
// Qwik doesn't supply `cf` to the platform object. Should they do so, uncomment this
112-
// ["cf", "CfProperties"],
113-
].map(([varName, type]) =>
114-
b.tsPropertySignature(
115-
b.identifier(varName),
116-
b.tsTypeAnnotation(b.tsTypeReference(b.identifier(type))),
117-
),
118-
);
119-
120-
n.node.body.body = newBody;
121-
122-
return false;
123-
},
124-
});
125-
126-
s.stop(`${brandColor("updated")} \`${entrypointPath}\``);
127-
};
128-
12994
const config: TemplateConfig = {
13095
configVersion: 1,
13196
id: "qwik",

‎packages/wrangler/src/autoconfig/frameworks/get-framework.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Angular } from "./angular";
22
import { Astro } from "./astro";
3+
import { Qwik } from "./qwik";
34
import { SolidStart } from "./solid-start";
45
import { Static } from "./static";
56
import { SvelteKit } from "./sveltekit";
@@ -21,6 +22,8 @@ export function getFramework(detectedFramework?: {
2122
return new Angular(detectedFramework.name);
2223
case "solid-start":
2324
return new SolidStart(detectedFramework.name);
25+
case "qwik":
26+
return new Qwik(detectedFramework.name);
2427
default:
2528
return new Static(detectedFramework?.name);
2629
}

‎packages/wrangler/src/autoconfig/frameworks/index.ts‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,21 @@ export type ConfigurationOptions = {
77
dryRun: boolean;
88
};
99

10+
export type PackageJsonScriptsOverrides = {
11+
preview?: string; // default is `npm run build && wrangler dev`
12+
deploy?: string; // default is `npm run build && wrangler deploy`
13+
typegen?: string; // default is `wrangler types`
14+
};
15+
1016
export type ConfigurationResults = {
1117
wranglerConfig: RawConfig;
18+
// Scripts to override in the package.json. Most frameworks should not need to do this, as their default detected build command will be sufficient
19+
packageJsonScriptsOverrides?: PackageJsonScriptsOverrides;
1220
};
1321

1422
export abstract class Framework {
1523
constructor(public name: string = "Static") {}
1624

17-
// Override commands used to configure the project. Most frameworks should not need to do this, as their default detected build command will be sufficient
18-
preview?: string; // default is `npm run build && wrangler dev`
19-
deploy?: string; // default is `npm run build && wrangler deploy`
20-
typegen?: string; // default is `wrangler types`
21-
2225
/** Some frameworks (i.e. Nuxt) don't need additional configuration */
2326
get configured() {
2427
return false;

0 commit comments

Comments
 (0)