create-cloudflare 0.0.0-e9f8a2fa → 0.0.0-ea6f0b74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/cli.js +1024 -1994
  2. package/dist/tsconfig.tsbuildinfo +1 -1
  3. package/package.json +20 -14
  4. package/templates/common/js/package.json +1 -1
  5. package/templates/common/ts/package.json +2 -2
  6. package/templates/common/ts/src/ab-test.ts +2 -2
  7. package/templates/common/ts/src/index.ts +2 -2
  8. package/templates/common/ts/src/proxy.ts +2 -2
  9. package/templates/common/ts/src/redirect.ts +2 -2
  10. package/templates/common/ts/tsconfig.json +1 -1
  11. package/templates/hello-world/js/package.json +3 -3
  12. package/templates/hello-world/js/vitest.config.js +8 -8
  13. package/templates/hello-world/ts/package.json +4 -4
  14. package/templates/hello-world/ts/src/index.ts +2 -2
  15. package/templates/hello-world/ts/test/tsconfig.json +6 -9
  16. package/templates/hello-world/ts/tsconfig.json +1 -1
  17. package/templates/hello-world/ts/vitest.config.mts +11 -0
  18. package/templates/hello-world-durable-object/c3.ts +1 -1
  19. package/templates/hello-world-durable-object/js/package.json +1 -1
  20. package/templates/hello-world-durable-object/js/src/index.js +1 -1
  21. package/templates/hello-world-durable-object/js/wrangler.toml +1 -1
  22. package/templates/hello-world-durable-object/ts/package.json +2 -2
  23. package/templates/hello-world-durable-object/ts/src/index.ts +3 -3
  24. package/templates/hello-world-durable-object/ts/tsconfig.json +1 -1
  25. package/templates/hello-world-durable-object/ts/wrangler.toml +2 -2
  26. package/templates/hello-world-python/py/package.json +1 -1
  27. package/templates/nuxt/c3.ts +5 -6
  28. package/templates/openapi/ts/package.json +2 -2
  29. package/templates/openapi/ts/src/index.ts +1 -1
  30. package/templates/pre-existing/js/package.json +1 -1
  31. package/templates/queues/js/package.json +1 -1
  32. package/templates/queues/ts/package.json +2 -2
  33. package/templates/queues/ts/src/index.ts +3 -3
  34. package/templates/queues/ts/tsconfig.json +1 -1
  35. package/templates/scheduled/js/package.json +1 -1
  36. package/templates/scheduled/ts/package.json +2 -2
  37. package/templates/scheduled/ts/src/index.ts +2 -2
  38. package/templates/scheduled/ts/tsconfig.json +1 -1
  39. package/templates/solid/c3.ts +7 -5
  40. package/templates/hello-world/ts/vitest.config.ts +0 -11
@@ -19,7 +19,7 @@ import apiRouter from './router';
19
19
  export default {
20
20
  // The fetch handler is invoked when this worker receives a HTTP(S) request
21
21
  // and should return a Response (optionally wrapped in a Promise)
22
- async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
22
+ async fetch(request, env, ctx): Promise<Response> {
23
23
  // You'll find it helpful to parse the request.url string into a URL object. Learn more at https://developer.mozilla.org/en-US/docs/Web/API/URL
24
24
  const url = new URL(request.url);
25
25
 
@@ -46,4 +46,4 @@ export default {
46
46
  { headers: { 'Content-Type': 'text/html' } }
47
47
  );
48
48
  },
49
- };
49
+ } satisfies ExportedHandler<Env>;
@@ -1,5 +1,5 @@
1
1
  export default {
2
- async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
2
+ async fetch(request, env, ctx): Promise<Response> {
3
3
  const url = new URL(request.url);
4
4
 
5
5
  const proxyUrl = url.searchParams.get('proxyUrl'); // get a query param value (?proxyUrl=...)
@@ -20,4 +20,4 @@ export default {
20
20
 
21
21
  return res;
22
22
  },
23
- };
23
+ } satisfies ExportedHandler<Env>;
@@ -1,5 +1,5 @@
1
1
  export default {
2
- async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
2
+ async fetch(request, env, ctx): Promise<Response> {
3
3
  const url = new URL(request.url);
4
4
  const redirectUrl = url.searchParams.get('redirectUrl'); // get a query param value (?redirectUrl=...)
5
5
 
@@ -10,4 +10,4 @@ export default {
10
10
  // The Response class has static methods to create common Response objects as a convenience
11
11
  return Response.redirect(redirectUrl);
12
12
  },
13
- };
13
+ } satisfies ExportedHandler<Env>;
@@ -13,7 +13,7 @@
13
13
  /* Language and Environment */
14
14
  "target": "es2021" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
15
15
  "lib": ["es2021"] /* Specify a set of bundled library declaration files that describe the target runtime environment. */,
16
- "jsx": "react" /* Specify what JSX code is generated. */,
16
+ "jsx": "react-jsx" /* Specify what JSX code is generated. */,
17
17
  // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
18
18
  // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
19
19
  // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */
@@ -9,8 +9,8 @@
9
9
  "test": "vitest"
10
10
  },
11
11
  "devDependencies": {
12
- "wrangler": "^3.0.0",
13
- "vitest": "1.3.0",
14
- "@cloudflare/vitest-pool-workers": "^0.1.0"
12
+ "@cloudflare/vitest-pool-workers": "^0.4.5",
13
+ "wrangler": "^3.60.3",
14
+ "vitest": "1.5.0"
15
15
  }
16
16
  }
@@ -1,11 +1,11 @@
1
- import { defineWorkersConfig } from "@cloudflare/vitest-pool-workers/config";
1
+ import { defineWorkersConfig } from '@cloudflare/vitest-pool-workers/config';
2
2
 
3
3
  export default defineWorkersConfig({
4
- test: {
5
- poolOptions: {
6
- workers: {
7
- wrangler: { configPath: "./wrangler.toml" },
8
- },
9
- },
10
- },
4
+ test: {
5
+ poolOptions: {
6
+ workers: {
7
+ wrangler: { configPath: './wrangler.toml' },
8
+ },
9
+ },
10
+ },
11
11
  });
@@ -10,9 +10,9 @@
10
10
  "cf-typegen": "wrangler types"
11
11
  },
12
12
  "devDependencies": {
13
- "typescript": "^5.0.4",
14
- "wrangler": "^3.0.0",
15
- "vitest": "1.3.0",
16
- "@cloudflare/vitest-pool-workers": "^0.1.0"
13
+ "@cloudflare/vitest-pool-workers": "^0.4.5",
14
+ "typescript": "^5.4.5",
15
+ "vitest": "1.5.0",
16
+ "wrangler": "^3.60.3"
17
17
  }
18
18
  }
@@ -12,7 +12,7 @@
12
12
  */
13
13
 
14
14
  export default {
15
- async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
15
+ async fetch(request, env, ctx): Promise<Response> {
16
16
  return new Response('Hello World!');
17
17
  },
18
- };
18
+ } satisfies ExportedHandler<Env>;
@@ -1,11 +1,8 @@
1
1
  {
2
- "extends": "../tsconfig.json",
3
- "compilerOptions": {
4
- "types": [
5
- "@cloudflare/workers-types/experimental",
6
- "@cloudflare/vitest-pool-workers"
7
- ]
8
- },
9
- "include": ["./**/*.ts", "../src/env.d.ts"],
10
- "exclude": []
2
+ "extends": "../tsconfig.json",
3
+ "compilerOptions": {
4
+ "types": ["@cloudflare/workers-types/experimental", "@cloudflare/vitest-pool-workers"]
5
+ },
6
+ "include": ["./**/*.ts", "../src/env.d.ts"],
7
+ "exclude": []
11
8
  }
@@ -13,7 +13,7 @@
13
13
  /* Language and Environment */
14
14
  "target": "es2021" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
15
15
  "lib": ["es2021"] /* Specify a set of bundled library declaration files that describe the target runtime environment. */,
16
- "jsx": "react" /* Specify what JSX code is generated. */,
16
+ "jsx": "react-jsx" /* Specify what JSX code is generated. */,
17
17
  // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
18
18
  // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
19
19
  // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */
@@ -0,0 +1,11 @@
1
+ import { defineWorkersConfig } from '@cloudflare/vitest-pool-workers/config';
2
+
3
+ export default defineWorkersConfig({
4
+ test: {
5
+ poolOptions: {
6
+ workers: {
7
+ wrangler: { configPath: './wrangler.toml' },
8
+ },
9
+ },
10
+ },
11
+ });
@@ -1,7 +1,7 @@
1
1
  export default {
2
2
  configVersion: 1,
3
3
  id: "hello-world-durable-object",
4
- displayName: '"Hello World" Durable Object',
4
+ displayName: "Co-ordination / multiplayer API (using Durable Objects)",
5
5
  platform: "workers",
6
6
  copyFiles: {
7
7
  variants: {
@@ -8,6 +8,6 @@
8
8
  "start": "wrangler dev"
9
9
  },
10
10
  "devDependencies": {
11
- "wrangler": "^3.0.0"
11
+ "wrangler": "^3.60.3"
12
12
  }
13
13
  }
@@ -32,7 +32,7 @@ export class MyDurableObject extends DurableObject {
32
32
 
33
33
  /**
34
34
  * The Durable Object exposes an RPC method sayHello which will be invoked when when a Durable
35
- * Object instance receives a request from a Worker via the same method invokation on the stub
35
+ * Object instance receives a request from a Worker via the same method invocation on the stub
36
36
  *
37
37
  * @param {string} name - The name provided to a Durable Object instance from a Worker
38
38
  * @returns {Promise<string>} The greeting to be sent back to the Worker
@@ -1,6 +1,6 @@
1
1
  #:schema node_modules/wrangler/config-schema.json
2
2
  name = "<TBD>"
3
- main = "src/index.ts"
3
+ main = "src/index.js"
4
4
  compatibility_date = "<TBD>"
5
5
 
6
6
  # Automatically place your workloads in an optimal location to minimize latency.
@@ -9,7 +9,7 @@
9
9
  "cf-typegen": "wrangler types"
10
10
  },
11
11
  "devDependencies": {
12
- "typescript": "^5.0.4",
13
- "wrangler": "^3.0.0"
12
+ "typescript": "^5.4.5",
13
+ "wrangler": "^3.60.3"
14
14
  }
15
15
  }
@@ -49,7 +49,7 @@ export class MyDurableObject extends DurableObject {
49
49
 
50
50
  /**
51
51
  * The Durable Object exposes an RPC method sayHello which will be invoked when when a Durable
52
- * Object instance receives a request from a Worker via the same method invokation on the stub
52
+ * Object instance receives a request from a Worker via the same method invocation on the stub
53
53
  *
54
54
  * @param name - The name provided to a Durable Object instance from a Worker
55
55
  * @returns The greeting to be sent back to the Worker
@@ -68,7 +68,7 @@ export default {
68
68
  * @param ctx - The execution context of the Worker
69
69
  * @returns The response to be sent back to the client
70
70
  */
71
- async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
71
+ async fetch(request, env, ctx): Promise<Response> {
72
72
  // We will create a `DurableObjectId` using the pathname from the Worker request
73
73
  // This id refers to a unique instance of our 'MyDurableObject' class above
74
74
  let id: DurableObjectId = env.MY_DURABLE_OBJECT.idFromName(new URL(request.url).pathname);
@@ -83,4 +83,4 @@ export default {
83
83
 
84
84
  return new Response(greeting);
85
85
  },
86
- };
86
+ } satisfies ExportedHandler<Env>;
@@ -13,7 +13,7 @@
13
13
  /* Language and Environment */
14
14
  "target": "es2021" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
15
15
  "lib": ["es2021"] /* Specify a set of bundled library declaration files that describe the target runtime environment. */,
16
- "jsx": "react" /* Specify what JSX code is generated. */,
16
+ "jsx": "react-jsx" /* Specify what JSX code is generated. */,
17
17
  // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
18
18
  // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
19
19
  // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */
@@ -48,13 +48,13 @@ compatibility_date = "<TBD>"
48
48
 
49
49
  # Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model.
50
50
  # Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps.
51
- # Docs: https://developers.cloudflare.com/workers/runtime-apis/durable-objects
51
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
52
52
  [[durable_objects.bindings]]
53
53
  name = "MY_DURABLE_OBJECT"
54
54
  class_name = "MyDurableObject"
55
55
 
56
56
  # Durable Object migrations.
57
- # Docs: https://developers.cloudflare.com/workers/learning/using-durable-objects#configure-durable-object-classes-with-migrations
57
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#migrations
58
58
  [[migrations]]
59
59
  tag = "v1"
60
60
  new_classes = ["MyDurableObject"]
@@ -8,6 +8,6 @@
8
8
  "start": "wrangler dev"
9
9
  },
10
10
  "devDependencies": {
11
- "wrangler": "^3.0.0"
11
+ "wrangler": "^3.60.3"
12
12
  }
13
13
  }
@@ -2,7 +2,7 @@ import { logRaw } from "@cloudflare/cli";
2
2
  import { brandColor, dim } from "@cloudflare/cli/colors";
3
3
  import { spinner } from "@cloudflare/cli/interactive";
4
4
  import { runFrameworkGenerator } from "frameworks/index";
5
- import { transformFile } from "helpers/codemod";
5
+ import { mergeObjectProperties, transformFile } from "helpers/codemod";
6
6
  import { getLatestTypesEntrypoint } from "helpers/compatDate";
7
7
  import { readFile, writeFile } from "helpers/files";
8
8
  import { detectPackageManager } from "helpers/packageManagers";
@@ -96,11 +96,10 @@ const updateNuxtConfig = () => {
96
96
  visitCallExpression: function (n) {
97
97
  const callee = n.node.callee as recast.types.namedTypes.Identifier;
98
98
  if (callee.name === "defineNuxtConfig") {
99
- const obj = n.node
100
- .arguments[0] as recast.types.namedTypes.ObjectExpression;
101
-
102
- obj.properties.push(presetDef);
103
- obj.properties.push(moduleDef);
99
+ mergeObjectProperties(
100
+ n.node.arguments[0] as recast.types.namedTypes.ObjectExpression,
101
+ [presetDef, moduleDef],
102
+ );
104
103
  }
105
104
 
106
105
  return this.traverse(n);
@@ -12,8 +12,8 @@
12
12
  "@cloudflare/itty-router-openapi": "^1.0.1"
13
13
  },
14
14
  "devDependencies": {
15
- "@types/node": "^20.5.7",
15
+ "@types/node": "20.8.3",
16
16
  "@types/service-worker-mock": "^2.0.1",
17
- "wrangler": "^3.0.0"
17
+ "wrangler": "^3.60.3"
18
18
  }
19
19
  }
@@ -26,4 +26,4 @@ router.all("*", () =>
26
26
 
27
27
  export default {
28
28
  fetch: router.handle,
29
- };
29
+ } satisfies ExportedHandler;
@@ -8,6 +8,6 @@
8
8
  "start": "wrangler dev"
9
9
  },
10
10
  "devDependencies": {
11
- "wrangler": "^3.0.0"
11
+ "wrangler": "^3.60.3"
12
12
  }
13
13
  }
@@ -8,6 +8,6 @@
8
8
  "start": "wrangler dev"
9
9
  },
10
10
  "devDependencies": {
11
- "wrangler": "^3.0.0"
11
+ "wrangler": "^3.60.3"
12
12
  }
13
13
  }
@@ -9,7 +9,7 @@
9
9
  "cf-typegen": "wrangler types"
10
10
  },
11
11
  "devDependencies": {
12
- "typescript": "^5.0.4",
13
- "wrangler": "^3.0.0"
12
+ "typescript": "^5.4.5",
13
+ "wrangler": "^3.60.3"
14
14
  }
15
15
  }
@@ -18,7 +18,7 @@ export default {
18
18
  // Our fetch handler is invoked on a HTTP request: we can send a message to a queue
19
19
  // during (or after) a request.
20
20
  // https://developers.cloudflare.com/queues/platform/javascript-apis/#producer
21
- async fetch(req: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
21
+ async fetch(req, env, ctx): Promise<Response> {
22
22
  // To send a message on a queue, we need to create the queue first
23
23
  // https://developers.cloudflare.com/queues/get-started/#3-create-a-queue
24
24
  await env.MY_QUEUE.send({
@@ -30,7 +30,7 @@ export default {
30
30
  },
31
31
  // The queue handler is invoked when a batch of messages is ready to be delivered
32
32
  // https://developers.cloudflare.com/queues/platform/javascript-apis/#messagebatch
33
- async queue(batch: MessageBatch<Error>, env: Env): Promise<void> {
33
+ async queue(batch, env): Promise<void> {
34
34
  // A queue consumer can make requests to other endpoints on the Internet,
35
35
  // write to R2 object storage, query a D1 Database, and much more.
36
36
  for (let message of batch.messages) {
@@ -38,4 +38,4 @@ export default {
38
38
  console.log(`message ${message.id} processed: ${JSON.stringify(message.body)}`);
39
39
  }
40
40
  },
41
- };
41
+ } satisfies ExportedHandler<Env, Error>;
@@ -13,7 +13,7 @@
13
13
  /* Language and Environment */
14
14
  "target": "es2021" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
15
15
  "lib": ["es2021"] /* Specify a set of bundled library declaration files that describe the target runtime environment. */,
16
- "jsx": "react" /* Specify what JSX code is generated. */,
16
+ "jsx": "react-jsx" /* Specify what JSX code is generated. */,
17
17
  // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
18
18
  // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
19
19
  // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */
@@ -8,6 +8,6 @@
8
8
  "start": "wrangler dev --test-scheduled"
9
9
  },
10
10
  "devDependencies": {
11
- "wrangler": "^3.0.0"
11
+ "wrangler": "^3.60.3"
12
12
  }
13
13
  }
@@ -9,7 +9,7 @@
9
9
  "cf-typegen": "wrangler types"
10
10
  },
11
11
  "devDependencies": {
12
- "typescript": "^5.0.4",
13
- "wrangler": "^3.0.0"
12
+ "typescript": "^5.4.5",
13
+ "wrangler": "^3.60.3"
14
14
  }
15
15
  }
@@ -18,7 +18,7 @@
18
18
  export default {
19
19
  // The scheduled handler is invoked at the interval set in our wrangler.toml's
20
20
  // [[triggers]] configuration.
21
- async scheduled(event: ScheduledEvent, env: Env, ctx: ExecutionContext): Promise<void> {
21
+ async scheduled(event, env, ctx): Promise<void> {
22
22
  // A Cron Trigger can make requests to other endpoints on the Internet,
23
23
  // publish to a Queue, query a D1 Database, and much more.
24
24
  //
@@ -30,4 +30,4 @@ export default {
30
30
  // In this template, we'll just log the result:
31
31
  console.log(`trigger fired at ${event.cron}: ${wasSuccessful}`);
32
32
  },
33
- };
33
+ } satisfies ExportedHandler<Env>;
@@ -13,7 +13,7 @@
13
13
  /* Language and Environment */
14
14
  "target": "es2021" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
15
15
  "lib": ["es2021"] /* Specify a set of bundled library declaration files that describe the target runtime environment. */,
16
- "jsx": "react" /* Specify what JSX code is generated. */,
16
+ "jsx": "react-jsx" /* Specify what JSX code is generated. */,
17
17
  // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
18
18
  // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
19
19
  // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */
@@ -1,7 +1,7 @@
1
1
  import { logRaw, updateStatus } from "@cloudflare/cli";
2
2
  import { blue } from "@cloudflare/cli/colors";
3
3
  import { runFrameworkGenerator } from "frameworks/index";
4
- import { transformFile } from "helpers/codemod";
4
+ import { mergeObjectProperties, transformFile } from "helpers/codemod";
5
5
  import { usesTypescript } from "helpers/files";
6
6
  import { detectPackageManager } from "helpers/packageManagers";
7
7
  import * as recast from "recast";
@@ -32,8 +32,10 @@ const configure = async (ctx: C3Context) => {
32
32
  }
33
33
 
34
34
  const b = recast.types.builders;
35
- n.node.arguments = [
36
- b.objectExpression([
35
+
36
+ mergeObjectProperties(
37
+ n.node.arguments[0] as recast.types.namedTypes.ObjectExpression,
38
+ [
37
39
  b.objectProperty(
38
40
  b.identifier("server"),
39
41
  b.objectExpression([
@@ -52,8 +54,8 @@ const configure = async (ctx: C3Context) => {
52
54
  ),
53
55
  ]),
54
56
  ),
55
- ]),
56
- ];
57
+ ],
58
+ );
57
59
 
58
60
  return false;
59
61
  },
@@ -1,11 +0,0 @@
1
- import { defineWorkersConfig } from "@cloudflare/vitest-pool-workers/config";
2
-
3
- export default defineWorkersConfig({
4
- test: {
5
- poolOptions: {
6
- workers: {
7
- wrangler: { configPath: "./wrangler.toml" },
8
- },
9
- },
10
- },
11
- });