Skip to content

Commit f463dd2

Browse files
authored
Changed port in playwright config file (#7428)
1 parent 073293f commit f463dd2

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

.changeset/lovely-kiwis-grab.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+
Use correct port in playwright config file for generated SvelteKit apps

packages/create-cloudflare/templates/svelte/c3.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { existsSync } from "node:fs";
12
import { platform } from "node:os";
23
import { logRaw, updateStatus } from "@cloudflare/cli";
34
import { blue, brandColor, dim } from "@cloudflare/cli/colors";
@@ -28,6 +29,7 @@ const configure = async (ctx: C3Context) => {
2829
});
2930

3031
updateSvelteConfig();
32+
updatePlaywrightConfig(usesTypescript(ctx));
3133
updateTypeDefinitions(ctx);
3234
};
3335

@@ -49,6 +51,34 @@ const updateSvelteConfig = () => {
4951
});
5052
};
5153

54+
const updatePlaywrightConfig = (shouldUseTypescript: boolean) => {
55+
const filePath = `playwright.config.${shouldUseTypescript ? "ts" : "js"}`;
56+
if (!existsSync(filePath)) {
57+
return;
58+
}
59+
60+
updateStatus(`Changing webServer port in ${blue(filePath)}`);
61+
62+
transformFile(filePath, {
63+
visitObjectExpression: function (n) {
64+
const portProp = n.node.properties.find((prop) => {
65+
if (!("key" in prop) || !("name" in prop.key)) {
66+
return false;
67+
}
68+
69+
return prop.key.name === "port";
70+
});
71+
72+
if (!portProp || !("value" in portProp) || !("value" in portProp.value)) {
73+
return this.traverse(n);
74+
}
75+
76+
portProp.value.value = 8788;
77+
return false;
78+
},
79+
});
80+
};
81+
5282
const updateTypeDefinitions = (ctx: C3Context) => {
5383
if (!usesTypescript(ctx)) {
5484
return;

0 commit comments

Comments
 (0)