Skip to content

Commit 2b37abe

Browse files
authored
chore: graduate hello world workers + assets templates (#8379)
* graduate hello world workers assets templates * changeset * fix tests * maybe fix tests * update labels * fix test * update c3-integration test
1 parent 4ad78ea commit 2b37abe

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+79
-76
lines changed

.changeset/angry-parents-post.md

Lines changed: 5 additions & 0 deletions

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

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,9 @@ describe.skipIf(experimental || frameworkToTest || isQuarantineMode())(
8282
);
8383

8484
expect(project.path).toExist();
85-
expect(output).toContain(`category Hello World example`);
86-
expect(output).toContain(`type Hello World Worker`);
85+
expect(output).toContain(`category Hello World Starter`);
86+
expect(output).toContain(`type Worker + Assets`);
8787
expect(output).toContain(`lang TypeScript`);
88-
expect(output).toContain(`no git`);
8988
expect(output).toContain(`no deploy`);
9089
},
9190
);
@@ -128,7 +127,6 @@ describe.skipIf(experimental || frameworkToTest || isQuarantineMode())(
128127
expect(project.path).toExist();
129128
expect(output).toContain(`type Scheduled Worker (Cron Trigger)`);
130129
expect(output).toContain(`lang JavaScript`);
131-
expect(output).toContain(`no git`);
132130
expect(output).toContain(`no deploy`);
133131
},
134132
);
@@ -179,9 +177,8 @@ describe.skipIf(experimental || frameworkToTest || isQuarantineMode())(
179177
);
180178

181179
expect(project.path).toExist();
182-
expect(output).toContain(`type Hello World Worker`);
180+
expect(output).toContain(`type Worker + Assets`);
183181
expect(output).toContain(`lang TypeScript`);
184-
expect(output).toContain(`no git`);
185182
expect(output).toContain(`no deploy`);
186183
} finally {
187184
fs.rmSync(existingFilePath, {
@@ -272,8 +269,8 @@ describe.skipIf(experimental || frameworkToTest || isQuarantineMode())(
272269
);
273270

274271
expect(project.path).toExist();
275-
expect(output).toContain(`category Hello World example`);
276-
expect(output).toContain(`type Hello World Worker`);
272+
expect(output).toContain(`category Hello World Starter`);
273+
expect(output).toContain(`type Worker only`);
277274
expect(output).toContain(`lang Python`);
278275
},
279276
);
@@ -379,15 +376,15 @@ describe.skipIf(experimental || frameworkToTest || isQuarantineMode())(
379376
matcher: /What would you like to start with\?/,
380377
input: {
381378
type: "select",
382-
target: "Hello World example",
379+
target: "Hello World Starter",
383380
assertDefaultSelection: "Framework Starter",
384381
},
385382
},
386383
{
387384
matcher: /Which template would you like to use\?/,
388385
input: {
389386
type: "select",
390-
target: "Hello World Worker Using Durable Objects",
387+
target: "Worker + Durable Objects",
391388
},
392389
},
393390
{
@@ -401,9 +398,8 @@ describe.skipIf(experimental || frameworkToTest || isQuarantineMode())(
401398
matcher: /Which template would you like to use\?/,
402399
input: {
403400
type: "select",
404-
target: "Hello World Worker",
405-
assertDefaultSelection:
406-
"Hello World Worker Using Durable Objects",
401+
target: "Worker only",
402+
assertDefaultSelection: "Worker + Durable Objects",
407403
},
408404
},
409405
{
@@ -418,7 +414,7 @@ describe.skipIf(experimental || frameworkToTest || isQuarantineMode())(
418414
);
419415

420416
expect(project.path).toExist();
421-
expect(output).toContain(`type Hello World Worker`);
417+
expect(output).toContain(`type Worker only`);
422418
expect(output).toContain(`lang JavaScript`);
423419
},
424420
);

packages/create-cloudflare/e2e-tests/workers.test.ts

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,35 @@ type WorkerTestConfig = RunnerConfig & {
3232

3333
function getWorkerTests(opts: { experimental: boolean }): WorkerTestConfig[] {
3434
if (opts.experimental) {
35+
// none currently
36+
return [];
37+
} else {
3538
return [
39+
{
40+
template: "hello-world",
41+
variants: ["ts", "js"],
42+
verifyDeploy: {
43+
route: "/",
44+
expectedText: "Hello World!",
45+
},
46+
verifyPreview: {
47+
route: "/",
48+
expectedText: "Hello World!",
49+
},
50+
verifyTest: true,
51+
},
52+
{
53+
template: "hello-world",
54+
variants: ["python"],
55+
verifyDeploy: {
56+
route: "/",
57+
expectedText: "Hello World!",
58+
},
59+
verifyPreview: {
60+
route: "/",
61+
expectedText: "Hello World!",
62+
},
63+
},
3664
{
3765
template: "hello-world-with-assets",
3866
variants: ["ts", "js"],
@@ -78,34 +106,6 @@ function getWorkerTests(opts: { experimental: boolean }): WorkerTestConfig[] {
78106
verifyPreview: null,
79107
argv: ["--category", "hello-world"],
80108
},
81-
];
82-
} else {
83-
return [
84-
{
85-
template: "hello-world",
86-
variants: ["ts", "js"],
87-
verifyDeploy: {
88-
route: "/",
89-
expectedText: "Hello World!",
90-
},
91-
verifyPreview: {
92-
route: "/",
93-
expectedText: "Hello World!",
94-
},
95-
verifyTest: true,
96-
},
97-
{
98-
template: "hello-world",
99-
variants: ["python"],
100-
verifyDeploy: {
101-
route: "/",
102-
expectedText: "Hello World!",
103-
},
104-
verifyPreview: {
105-
route: "/",
106-
expectedText: "Hello World!",
107-
},
108-
},
109109
{
110110
template: "common",
111111
variants: ["ts", "js"],
@@ -155,6 +155,7 @@ describe
155155
.skipIf(
156156
getFrameworkToTest({ experimental }) ||
157157
isQuarantineMode() ||
158+
workerTests.length === 0 ||
158159
process.platform === "win32",
159160
)
160161
.concurrent(`E2E: Workers templates`, () => {

packages/create-cloudflare/src/helpers/args.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ export const cliDefinition: ArgumentsDefinition = {
7070
const experimental = Boolean(args?.["experimental"]);
7171
if (experimental) {
7272
return [
73-
{ name: "hello-world", description: "Hello World example" },
73+
{ name: "hello-world", description: "Hello World Starter" },
7474
{ name: "web-framework", description: "Framework Starter" },
7575
];
7676
} else {
7777
return [
78-
{ name: "hello-world", description: "Hello World example" },
78+
{ name: "hello-world", description: "Hello World Starter" },
7979
{ name: "web-framework", description: "Framework Starter" },
8080
{ name: "demo", description: "Application Starter" },
8181
{

packages/create-cloudflare/src/helpers/cli.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const isUpdateAvailable = async () => {
4848
export const C3_DEFAULTS: C3Args = {
4949
projectName: new Haikunator().haikunate({ tokenHex: true }),
5050
category: "hello-world",
51-
type: "hello-world",
51+
type: "hello-world-with-assets",
5252
framework: "analog",
5353
experimental: false,
5454
autoUpdate: true,
@@ -57,11 +57,11 @@ export const C3_DEFAULTS: C3Args = {
5757
open: true,
5858
lang: "ts",
5959
template:
60-
"cloudflare/workers-sdk/packages/create-cloudflare/templates/hello-world",
60+
"cloudflare/workers-sdk/packages/create-cloudflare/templates/hello-world-with-assets",
6161
};
6262

6363
export const WRANGLER_DEFAULTS = {
6464
...C3_DEFAULTS,
65-
type: "hello-world",
65+
type: "hello-world-with-assets",
6666
deploy: false,
6767
};

packages/create-cloudflare/src/templates.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ import {
1919
writeJSON,
2020
} from "helpers/files";
2121
import astroTemplateExperimental from "templates-experimental/astro/c3";
22-
import assetsOnlyTemplateExperimental from "templates-experimental/hello-world-assets-only/c3";
23-
import helloWorldWithDurableObjectAssetsTemplateExperimental from "templates-experimental/hello-world-durable-object-with-assets/c3";
24-
import helloWorldWithAssetsTemplateExperimental from "templates-experimental/hello-world-with-assets/c3";
2522
import honoTemplateExperimental from "templates-experimental/hono/c3";
2623
import nextTemplateExperimental from "templates-experimental/next/c3";
2724
import qwikTemplateExperimental from "templates-experimental/qwik/c3";
@@ -34,8 +31,11 @@ import astroTemplate from "templates/astro/c3";
3431
import commonTemplate from "templates/common/c3";
3532
import docusaurusTemplate from "templates/docusaurus/c3";
3633
import gatsbyTemplate from "templates/gatsby/c3";
34+
import assetsOnlyTemplate from "templates/hello-world-assets-only/c3";
35+
import helloWorldWithDurableObjectAssetsTemplate from "templates/hello-world-durable-object-with-assets/c3";
3736
import helloWorldDurableObjectTemplate from "templates/hello-world-durable-object/c3";
38-
import helloWorldTemplate from "templates/hello-world/c3";
37+
import helloWorldWithAssetsTemplate from "templates/hello-world-with-assets/c3";
38+
import helloWorldWorkerTemplate from "templates/hello-world/c3";
3939
import honoTemplate from "templates/hono/c3";
4040
import nextTemplate from "templates/next/c3";
4141
import nuxtTemplate from "templates/nuxt/c3";
@@ -206,19 +206,18 @@ export function getFrameworkMap({ experimental = false }): TemplateMap {
206206

207207
export function getTemplateMap({ experimental = false }) {
208208
if (experimental) {
209-
return {
210-
"hello-world-assets-only": assetsOnlyTemplateExperimental,
211-
"hello-world-with-assets": helloWorldWithAssetsTemplateExperimental,
212-
"hello-world-durable-object-with-assets":
213-
helloWorldWithDurableObjectAssetsTemplateExperimental,
214-
} as Record<string, TemplateConfig>;
209+
return {} as Record<string, TemplateConfig>;
215210
} else {
216211
return {
217-
"hello-world": helloWorldTemplate,
212+
"hello-world": helloWorldWorkerTemplate,
213+
"hello-world-assets-only": assetsOnlyTemplate,
214+
"hello-world-with-assets": helloWorldWithAssetsTemplate,
215+
"hello-world-durable-object": helloWorldDurableObjectTemplate,
216+
"hello-world-durable-object-with-assets":
217+
helloWorldWithDurableObjectAssetsTemplate,
218218
common: commonTemplate,
219219
scheduled: scheduledTemplate,
220220
queues: queuesTemplate,
221-
"hello-world-durable-object": helloWorldDurableObjectTemplate,
222221
openapi: openapiTemplate,
223222
"pre-existing": preExistingTemplate,
224223
} as Record<string, TemplateConfig>;
@@ -366,9 +365,10 @@ export const createContext = async (
366365

367366
const categoryOptions = [
368367
{
369-
label: "Hello World example",
368+
label: "Hello World Starter",
370369
value: "hello-world",
371-
description: "Select from barebones examples to get started with Workers",
370+
description:
371+
"Select from basic scaffolds to get started with Workers, Assets and Durable Objects",
372372
},
373373
{
374374
label: "Framework Starter",
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ import type { TemplateConfig } from "../../src/templates";
33
const config: TemplateConfig = {
44
configVersion: 1,
55
id: "hello-world-assets-only",
6-
path: "templates-experimental/hello-world-assets-only",
7-
displayName: "Hello World - Assets-only",
8-
description: "Get started with a basic Worker that only serves static assets",
6+
path: "templates/hello-world-assets-only",
7+
displayName: "Assets only",
8+
description:
9+
"For static sites (including SPAs) or when using your own backend",
910
platform: "workers",
1011
copyFiles: {
1112
path: "./templates",
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)