create-cloudflare 0.0.0-e60a675d → 0.0.0-e61444cb
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.
- package/dist/cli.js +1520 -2324
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +23 -24
- package/templates/analog/c3.ts +4 -4
- package/templates/analog/templates/wrangler.toml +7 -0
- package/templates/angular/c3.ts +2 -2
- package/templates/astro/c3.ts +3 -3
- package/templates/astro/templates/wrangler.toml +7 -0
- package/templates/common/js/package.json +1 -1
- package/templates/common/js/wrangler.toml +7 -0
- package/templates/common/ts/package.json +2 -2
- package/templates/common/ts/src/ab-test.ts +2 -2
- package/templates/common/ts/src/index.ts +2 -2
- package/templates/common/ts/src/proxy.ts +2 -2
- package/templates/common/ts/src/redirect.ts +2 -2
- package/templates/common/ts/tsconfig.json +1 -1
- package/templates/common/ts/wrangler.toml +7 -0
- package/templates/hello-world/js/package.json +3 -3
- package/templates/hello-world/js/vitest.config.js +8 -8
- package/templates/hello-world/js/wrangler.toml +7 -0
- package/templates/hello-world/ts/package.json +4 -4
- package/templates/hello-world/ts/src/index.ts +2 -2
- package/templates/hello-world/ts/test/tsconfig.json +6 -9
- package/templates/hello-world/ts/tsconfig.json +1 -1
- package/templates/hello-world/ts/vitest.config.mts +11 -0
- package/templates/hello-world/ts/wrangler.toml +7 -0
- package/templates/hello-world-durable-object/c3.ts +1 -1
- package/templates/hello-world-durable-object/js/package.json +1 -1
- package/templates/hello-world-durable-object/js/src/index.js +18 -14
- package/templates/hello-world-durable-object/js/wrangler.toml +8 -1
- package/templates/hello-world-durable-object/ts/package.json +2 -3
- package/templates/hello-world-durable-object/ts/src/index.ts +42 -17
- package/templates/hello-world-durable-object/ts/tsconfig.json +1 -1
- package/templates/hello-world-durable-object/ts/wrangler.toml +9 -2
- package/templates/hello-world-python/py/package.json +1 -1
- package/templates/hello-world-python/py/wrangler.toml +7 -0
- package/templates/hono/c3.ts +53 -0
- package/templates/hono/snippets/appDeclaration.ts +1 -0
- package/templates/hono/snippets/bindingsType.ts +3 -0
- package/templates/hono/templates/worker-configuration.d.ts +4 -0
- package/templates/hono/templates/wrangler.toml +107 -0
- package/templates/next/README.md +1 -1
- package/templates/next/c3.ts +9 -7
- package/templates/next/wrangler.toml +7 -0
- package/templates/nuxt/c3.ts +8 -9
- package/templates/nuxt/templates/wrangler.toml +7 -0
- package/templates/openapi/ts/README.md +3 -3
- package/templates/openapi/ts/package.json +5 -3
- package/templates/openapi/ts/src/endpoints/taskCreate.ts +26 -16
- package/templates/openapi/ts/src/endpoints/taskDelete.ts +20 -19
- package/templates/openapi/ts/src/endpoints/taskFetch.ts +30 -23
- package/templates/openapi/ts/src/endpoints/taskList.ts +27 -24
- package/templates/openapi/ts/src/index.ts +14 -20
- package/templates/openapi/ts/src/types.ts +9 -8
- package/templates/openapi/ts/wrangler.toml +7 -0
- package/templates/pre-existing/c3.ts +5 -5
- package/templates/pre-existing/js/package.json +1 -1
- package/templates/queues/js/package.json +1 -1
- package/templates/queues/js/wrangler.toml +7 -0
- package/templates/queues/ts/package.json +2 -2
- package/templates/queues/ts/src/index.ts +3 -3
- package/templates/queues/ts/tsconfig.json +1 -1
- package/templates/queues/ts/wrangler.toml +7 -0
- package/templates/qwik/c3.ts +3 -3
- package/templates/qwik/templates/wrangler.toml +7 -0
- package/templates/remix/templates/wrangler.toml +7 -0
- package/templates/scheduled/js/package.json +3 -3
- package/templates/scheduled/js/src/index.js +8 -1
- package/templates/scheduled/js/wrangler.toml +7 -0
- package/templates/scheduled/ts/package.json +4 -4
- package/templates/scheduled/ts/src/index.ts +3 -3
- package/templates/scheduled/ts/tsconfig.json +1 -1
- package/templates/scheduled/ts/wrangler.toml +7 -0
- package/templates/solid/c3.ts +11 -9
- package/templates/solid/templates/wrangler.toml +7 -0
- package/templates/svelte/c3.ts +6 -6
- package/templates/svelte/js/wrangler.toml +7 -0
- package/templates/svelte/ts/wrangler.toml +7 -0
- package/templates/hello-world/ts/vitest.config.ts +0 -11
|
@@ -6,13 +6,20 @@
|
|
|
6
6
|
* https://developers.cloudflare.com/workers/platform/triggers/cron-triggers/
|
|
7
7
|
*
|
|
8
8
|
* - Run `npm run dev` in your terminal to start a development server
|
|
9
|
-
* -
|
|
9
|
+
* - Run `curl "http://localhost:8787/__scheduled?cron=*+*+*+*+*"` to see your worker in action
|
|
10
10
|
* - Run `npm run deploy` to publish your worker
|
|
11
11
|
*
|
|
12
12
|
* Learn more at https://developers.cloudflare.com/workers/
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
export default {
|
|
16
|
+
async fetch(req) {
|
|
17
|
+
const url = new URL(req.url)
|
|
18
|
+
url.pathname = "/__scheduled";
|
|
19
|
+
url.searchParams.append("cron", "* * * * *");
|
|
20
|
+
return new Response(`To test the scheduled handler, ensure you have used the "--test-scheduled" then try running "curl ${url.href}".`);
|
|
21
|
+
},
|
|
22
|
+
|
|
16
23
|
// The scheduled handler is invoked at the interval set in our wrangler.toml's
|
|
17
24
|
// [[triggers]] configuration.
|
|
18
25
|
async scheduled(event, env, ctx) {
|
|
@@ -9,6 +9,13 @@ compatibility_date = "<TBD>"
|
|
|
9
9
|
[triggers]
|
|
10
10
|
crons = ["* * * * *"] # * * * * * = run every minute
|
|
11
11
|
|
|
12
|
+
# Automatically place your workloads in an optimal location to minimize latency.
|
|
13
|
+
# If you are running back-end logic in a Worker, running it closer to your back-end infrastructure
|
|
14
|
+
# rather than the end user may result in better performance.
|
|
15
|
+
# Docs: https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement
|
|
16
|
+
# [placement]
|
|
17
|
+
# mode = "smart"
|
|
18
|
+
|
|
12
19
|
# Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
|
|
13
20
|
# Docs:
|
|
14
21
|
# - https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
"private": true,
|
|
5
5
|
"scripts": {
|
|
6
6
|
"deploy": "wrangler deploy",
|
|
7
|
-
"dev": "wrangler dev",
|
|
8
|
-
"start": "wrangler dev",
|
|
7
|
+
"dev": "wrangler dev --test-scheduled",
|
|
8
|
+
"start": "wrangler dev --test-scheduled",
|
|
9
9
|
"cf-typegen": "wrangler types"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"typescript": "^5.
|
|
13
|
-
"wrangler": "^3.
|
|
12
|
+
"typescript": "^5.5.2",
|
|
13
|
+
"wrangler": "^3.60.3"
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* https://developers.cloudflare.com/workers/platform/triggers/cron-triggers/
|
|
7
7
|
*
|
|
8
8
|
* - Run `npm run dev` in your terminal to start a development server
|
|
9
|
-
* -
|
|
9
|
+
* - Run `curl "http://localhost:8787/__scheduled?cron=*+*+*+*+*"` to see your worker in action
|
|
10
10
|
* - Run `npm run deploy` to publish your worker
|
|
11
11
|
*
|
|
12
12
|
* Bind resources to your worker in `wrangler.toml`. After adding bindings, a type definition for the
|
|
@@ -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
|
|
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' */
|
|
@@ -9,6 +9,13 @@ compatibility_date = "<TBD>"
|
|
|
9
9
|
[triggers]
|
|
10
10
|
crons = ["* * * * *"] # * * * * * = run every minute
|
|
11
11
|
|
|
12
|
+
# Automatically place your workloads in an optimal location to minimize latency.
|
|
13
|
+
# If you are running back-end logic in a Worker, running it closer to your back-end infrastructure
|
|
14
|
+
# rather than the end user may result in better performance.
|
|
15
|
+
# Docs: https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement
|
|
16
|
+
# [placement]
|
|
17
|
+
# mode = "smart"
|
|
18
|
+
|
|
12
19
|
# Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
|
|
13
20
|
# Docs:
|
|
14
21
|
# - https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
|
package/templates/solid/c3.ts
CHANGED
|
@@ -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,28 +32,30 @@ const configure = async (ctx: C3Context) => {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
const b = recast.types.builders;
|
|
35
|
-
|
|
36
|
-
|
|
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([
|
|
40
42
|
b.objectProperty(
|
|
41
43
|
b.identifier("preset"),
|
|
42
|
-
b.stringLiteral("cloudflare-pages")
|
|
44
|
+
b.stringLiteral("cloudflare-pages"),
|
|
43
45
|
),
|
|
44
46
|
b.objectProperty(
|
|
45
47
|
b.identifier("rollupConfig"),
|
|
46
48
|
b.objectExpression([
|
|
47
49
|
b.objectProperty(
|
|
48
50
|
b.identifier("external"),
|
|
49
|
-
b.arrayExpression([b.stringLiteral("node:async_hooks")])
|
|
51
|
+
b.arrayExpression([b.stringLiteral("node:async_hooks")]),
|
|
50
52
|
),
|
|
51
|
-
])
|
|
53
|
+
]),
|
|
52
54
|
),
|
|
53
|
-
])
|
|
55
|
+
]),
|
|
54
56
|
),
|
|
55
|
-
]
|
|
56
|
-
|
|
57
|
+
],
|
|
58
|
+
);
|
|
57
59
|
|
|
58
60
|
return false;
|
|
59
61
|
},
|
|
@@ -4,6 +4,13 @@ compatibility_date = "<TBD>"
|
|
|
4
4
|
compatibility_flags = ["nodejs_compat"]
|
|
5
5
|
pages_build_output_dir = "./dist"
|
|
6
6
|
|
|
7
|
+
# Automatically place your workloads in an optimal location to minimize latency.
|
|
8
|
+
# If you are running back-end logic in a Pages Function, running it closer to your back-end infrastructure
|
|
9
|
+
# rather than the end user may result in better performance.
|
|
10
|
+
# Docs: https://developers.cloudflare.com/pages/functions/smart-placement/#smart-placement
|
|
11
|
+
# [placement]
|
|
12
|
+
# mode = "smart"
|
|
13
|
+
|
|
7
14
|
# Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
|
|
8
15
|
# Note: Use secrets to store sensitive data.
|
|
9
16
|
# Docs: https://developers.cloudflare.com/pages/functions/bindings/#environment-variables
|
package/templates/svelte/c3.ts
CHANGED
|
@@ -69,21 +69,21 @@ const updateTypeDefinitions = (ctx: C3Context) => {
|
|
|
69
69
|
b.tsInterfaceBody([
|
|
70
70
|
b.tsPropertySignature(
|
|
71
71
|
b.identifier("env"),
|
|
72
|
-
b.tsTypeAnnotation(b.tsTypeReference(b.identifier("Env")))
|
|
72
|
+
b.tsTypeAnnotation(b.tsTypeReference(b.identifier("Env"))),
|
|
73
73
|
),
|
|
74
74
|
b.tsPropertySignature(
|
|
75
75
|
b.identifier("cf"),
|
|
76
76
|
b.tsTypeAnnotation(
|
|
77
|
-
b.tsTypeReference(b.identifier("CfProperties"))
|
|
78
|
-
)
|
|
77
|
+
b.tsTypeReference(b.identifier("CfProperties")),
|
|
78
|
+
),
|
|
79
79
|
),
|
|
80
80
|
b.tsPropertySignature(
|
|
81
81
|
b.identifier("ctx"),
|
|
82
82
|
b.tsTypeAnnotation(
|
|
83
|
-
b.tsTypeReference(b.identifier("ExecutionContext"))
|
|
84
|
-
)
|
|
83
|
+
b.tsTypeReference(b.identifier("ExecutionContext")),
|
|
84
|
+
),
|
|
85
85
|
),
|
|
86
|
-
])
|
|
86
|
+
]),
|
|
87
87
|
);
|
|
88
88
|
|
|
89
89
|
moduleBlock.body.unshift(platformInterface);
|
|
@@ -3,6 +3,13 @@ name = "<TBD>"
|
|
|
3
3
|
compatibility_date = "<TBD>"
|
|
4
4
|
pages_build_output_dir = ".svelte-kit/cloudflare"
|
|
5
5
|
|
|
6
|
+
# Automatically place your workloads in an optimal location to minimize latency.
|
|
7
|
+
# If you are running back-end logic in a Pages Function, running it closer to your back-end infrastructure
|
|
8
|
+
# rather than the end user may result in better performance.
|
|
9
|
+
# Docs: https://developers.cloudflare.com/pages/functions/smart-placement/#smart-placement
|
|
10
|
+
# [placement]
|
|
11
|
+
# mode = "smart"
|
|
12
|
+
|
|
6
13
|
# Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
|
|
7
14
|
# Docs:
|
|
8
15
|
# - https://developers.cloudflare.com/pages/functions/bindings/#environment-variables
|
|
@@ -3,6 +3,13 @@ name = "<TBD>"
|
|
|
3
3
|
compatibility_date = "<TBD>"
|
|
4
4
|
pages_build_output_dir = ".svelte-kit/cloudflare"
|
|
5
5
|
|
|
6
|
+
# Automatically place your workloads in an optimal location to minimize latency.
|
|
7
|
+
# If you are running back-end logic in a Pages Function, running it closer to your back-end infrastructure
|
|
8
|
+
# rather than the end user may result in better performance.
|
|
9
|
+
# Docs: https://developers.cloudflare.com/pages/functions/smart-placement/#smart-placement
|
|
10
|
+
# [placement]
|
|
11
|
+
# mode = "smart"
|
|
12
|
+
|
|
6
13
|
# Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
|
|
7
14
|
# Docs:
|
|
8
15
|
# - https://developers.cloudflare.com/pages/functions/bindings/#environment-variables
|