Skip to content

Commit eb76082

Browse files
C3: replace Svelte's pages:dev with pages:preview and add optional previewScript to the c3 summary (#4850)
* C3: replace svelteKit `pages:dev` script with `pages:preview` * C3: add new optional `previewScript` to summary
1 parent 75f99d7 commit eb76082

File tree

7 files changed

+37
-8
lines changed

7 files changed

+37
-8
lines changed

.changeset/forty-needles-turn.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"create-cloudflare": minor
3+
---
4+
5+
introduce a new optional `previewScript` to the C3 summary
6+
7+
such script is to be used to locally preview the application (using wrangler)

.changeset/four-teachers-push.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"create-cloudflare": patch
3+
---
4+
5+
update the svelteKit c3 scripts
6+
7+
replace the incorrect `pages:dev` with a new `pages:preview` script
8+
(and use the standard `dev` script as the `devScript`)

packages/create-cloudflare/src/common.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -286,36 +286,44 @@ export const printSummary = async (ctx: C3Context) => {
286286
const dirRelativePath = relative(ctx.originalCWD, ctx.project.path);
287287
const nextSteps = [
288288
dirRelativePath
289-
? [`Navigate to the new directory`, `cd ${dirRelativePath}`]
289+
? ["Navigate to the new directory", `cd ${dirRelativePath}`]
290290
: [],
291291
[
292-
`Run the development server`,
292+
"Run the development server",
293293
quoteShellArgs([npm, "run", ctx.template.devScript ?? "start"]),
294294
],
295+
...(ctx.template.previewScript
296+
? [
297+
[
298+
"Preview your application",
299+
quoteShellArgs([npm, "run", ctx.template.previewScript]),
300+
],
301+
]
302+
: []),
295303
[
296-
`Deploy your application`,
304+
"Deploy your application",
297305
quoteShellArgs([npm, "run", ctx.template.deployScript ?? "deploy"]),
298306
],
299307
[
300-
`Read the documentation`,
308+
"Read the documentation",
301309
`https://developers.cloudflare.com/${ctx.template.platform}`,
302310
],
303-
[`Stuck? Join us at`, `https://discord.gg/cloudflaredev`],
311+
["Stuck? Join us at", "https://discord.gg/cloudflaredev"],
304312
];
305313

306314
if (ctx.deployment.url) {
307315
const msg = [
308316
`${gray(shapes.leftT)}`,
309317
`${bgGreen(" SUCCESS ")}`,
310-
`${dim(`View your deployed application at`)}`,
318+
`${dim("View your deployed application at")}`,
311319
`${blue(ctx.deployment.url)}`,
312320
].join(" ");
313321
logRaw(msg);
314322
} else {
315323
const msg = [
316324
`${gray(shapes.leftT)}`,
317325
`${bgGreen(" APPLICATION CREATED ")}`,
318-
`${dim(`Deploy your application with`)}`,
326+
`${dim("Deploy your application with")}`,
319327
`${blue(
320328
quoteShellArgs([npm, "run", ctx.template.deployScript ?? "deploy"])
321329
)}`,

packages/create-cloudflare/src/templates.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ export type TemplateConfig = {
7373
deployScript?: string;
7474
/** The key of the package.json "scripts" entry for developing the project. Defaults to `pages:dev` */
7575
devScript?: string;
76+
/** The key of the package.json "scripts" entry for previewing the project. Defaults to undefined (there might not be such script) */
77+
previewScript?: string;
7678

7779
/** The file path of the template. This is used internally and isn't a user facing config value.*/
7880
path?: string;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ export default {
178178
platform: "pages",
179179
displayName: "Next",
180180
devScript: "dev",
181+
previewScript: "pages:preview",
181182
generate,
182183
configure,
183184
transformPackageJson: async () => {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const config: TemplateConfig = {
3232
},
3333
}),
3434
devScript: "dev",
35+
previewScript: "pages:preview",
3536
compatibilityFlags: ["nodejs_compat"],
3637
};
3738
export default config;

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,11 @@ const config: TemplateConfig = {
6767
configure,
6868
transformPackageJson: async () => ({
6969
scripts: {
70-
"pages:dev": `wrangler pages dev ${await compatDateFlag()} --proxy 5173 -- ${npm} run dev`,
70+
"pages:preview": `${npm} run build && wrangler pages dev .svelte-kit/cloudflare`,
7171
"pages:deploy": `${npm} run build && wrangler pages deploy .svelte-kit/cloudflare`,
7272
},
7373
}),
74+
devScript: "dev",
75+
previewScript: "pages:preview",
7476
};
7577
export default config;

0 commit comments

Comments
 (0)