create-cloudflare 0.0.0-4e69fb6f0 → 0.0.0-4e7345e13
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 +246 -209
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/templates/analog/c3.ts +0 -24
- package/templates/analog/templates/env.d.ts +1 -1
- package/templates/angular/pages/c3.ts +3 -3
- package/templates/angular/pages/templates/wrangler.jsonc +5 -0
- package/templates/angular/workers/c3.ts +1 -0
- package/templates/astro/workers/templates/js/wrangler.jsonc +2 -1
- package/templates/astro/workers/templates/ts/wrangler.jsonc +2 -1
- package/templates/common/ts/tsconfig.json +0 -3
- package/templates/docusaurus/pages/c3.ts +1 -0
- package/templates/docusaurus/workers/c3.ts +1 -0
- package/templates/gatsby/pages/c3.ts +1 -0
- package/templates/gatsby/workers/c3.ts +1 -0
- package/templates/hello-world/js/package.json +1 -1
- package/templates/hello-world/py/README.md +2 -2
- package/templates/hello-world/py/pyproject.toml +1 -1
- package/templates/hello-world/py/src/entry.py +3 -2
- package/templates/hello-world/ts/package.json +1 -1
- package/templates/hello-world/ts/test/index.spec.ts +0 -1
- package/templates/hello-world/ts/test/tsconfig.json +1 -1
- package/templates/hello-world/ts/tsconfig.json +0 -2
- package/templates/hello-world-assets-only/c3.ts +2 -2
- package/templates/hello-world-assets-only/templates/public/index.html +1 -0
- package/templates/hello-world-assets-only/templates/wrangler.jsonc +1 -0
- package/templates/hello-world-durable-object/c3.ts +3 -0
- package/templates/hello-world-durable-object/py/.python-version +1 -0
- package/templates/hello-world-durable-object/py/README.md +23 -0
- package/templates/hello-world-durable-object/py/__dot__gitignore +68 -0
- package/templates/hello-world-durable-object/py/package.json +13 -0
- package/templates/hello-world-durable-object/py/pyproject.toml +9 -0
- package/templates/hello-world-durable-object/py/src/entry.py +66 -0
- package/templates/hello-world-durable-object/py/uv.lock +22 -0
- package/templates/hello-world-durable-object/py/wrangler.jsonc +27 -0
- package/templates/hello-world-durable-object/ts/tsconfig.json +0 -2
- package/templates/hello-world-durable-object-with-assets/c3.ts +3 -0
- package/templates/hello-world-durable-object-with-assets/js/public/index.html +1 -0
- package/templates/hello-world-durable-object-with-assets/js/wrangler.jsonc +1 -1
- package/templates/hello-world-durable-object-with-assets/py/.python-version +1 -0
- package/templates/hello-world-durable-object-with-assets/py/README.md +23 -0
- package/templates/hello-world-durable-object-with-assets/py/__dot__gitignore +68 -0
- package/templates/hello-world-durable-object-with-assets/py/package.json +13 -0
- package/templates/hello-world-durable-object-with-assets/py/public/index.html +20 -0
- package/templates/hello-world-durable-object-with-assets/py/pyproject.toml +9 -0
- package/templates/hello-world-durable-object-with-assets/py/src/entry.py +66 -0
- package/templates/hello-world-durable-object-with-assets/py/uv.lock +22 -0
- package/templates/hello-world-durable-object-with-assets/py/wrangler.jsonc +31 -0
- package/templates/hello-world-durable-object-with-assets/ts/public/index.html +1 -0
- package/templates/hello-world-durable-object-with-assets/ts/tsconfig.json +0 -2
- package/templates/hello-world-durable-object-with-assets/ts/wrangler.jsonc +1 -1
- package/templates/hello-world-with-assets/c3.ts +3 -2
- package/templates/hello-world-with-assets/js/package.json +1 -1
- package/templates/hello-world-with-assets/js/public/index.html +1 -0
- package/templates/hello-world-with-assets/js/wrangler.jsonc +3 -2
- package/templates/hello-world-with-assets/py/.python-version +1 -0
- package/templates/hello-world-with-assets/py/README.md +23 -0
- package/templates/hello-world-with-assets/py/public/index.html +1 -0
- package/templates/hello-world-with-assets/py/pyproject.toml +9 -0
- package/templates/hello-world-with-assets/py/src/entry.py +9 -7
- package/templates/hello-world-with-assets/py/uv.lock +22 -0
- package/templates/hello-world-with-assets/py/wrangler.jsonc +1 -1
- package/templates/hello-world-with-assets/ts/package.json +1 -1
- package/templates/hello-world-with-assets/ts/public/index.html +1 -0
- package/templates/hello-world-with-assets/ts/test/tsconfig.json +1 -1
- package/templates/hello-world-with-assets/ts/tsconfig.json +0 -2
- package/templates/hello-world-with-assets/ts/wrangler.jsonc +2 -2
- package/templates/hono/pages/c3.ts +4 -1
- package/templates/hono/workers/c3.ts +3 -1
- package/templates/next/pages/c3.ts +6 -10
- package/templates/next/workers/c3.ts +8 -11
- package/templates/next/workers/templates/open-next.config.ts +5 -2
- package/templates/next/workers/templates/wrangler.jsonc +2 -1
- package/templates/nuxt/pages/c3.ts +2 -26
- package/templates/nuxt/pages/templates/env.d.ts +1 -1
- package/templates/nuxt/workers/c3.ts +2 -26
- package/templates/nuxt/workers/templates/env.d.ts +1 -1
- package/templates/openapi/ts/__dot__gitignore +1 -0
- package/templates/openapi/ts/package.json +7 -6
- package/templates/openapi/ts/src/endpoints/taskCreate.ts +2 -2
- package/templates/openapi/ts/src/endpoints/taskDelete.ts +2 -2
- package/templates/openapi/ts/src/endpoints/taskFetch.ts +2 -2
- package/templates/openapi/ts/src/endpoints/taskList.ts +2 -2
- package/templates/openapi/ts/src/index.ts +4 -1
- package/templates/openapi/ts/src/types.ts +3 -0
- package/templates/openapi/ts/tsconfig.json +18 -21
- package/templates/pre-existing/c3.ts +1 -1
- package/templates/queues/ts/tsconfig.json +0 -2
- package/templates/qwik/pages/c3.ts +1 -0
- package/templates/qwik/workers/c3.ts +3 -4
- package/templates/qwik/workers/templates/wrangler.jsonc +2 -1
- package/templates/react/pages/c3.ts +4 -2
- package/templates/react/pages/templates/wrangler.jsonc +5 -0
- package/templates/react/workers/c3.ts +1 -1
- package/templates/react/workers/ts/tsconfig.worker.json +2 -2
- package/templates/react-router/c3.ts +0 -12
- package/templates/remix/pages/c3.ts +1 -0
- package/templates/remix/pages/templates/worker-configuration.d.ts +1 -1
- package/templates/remix/workers/c3.ts +1 -0
- package/templates/remix/workers/templates/wrangler.toml +1 -1
- package/templates/scheduled/ts/tsconfig.json +0 -2
- package/templates/solid/c3.ts +1 -0
- package/templates/svelte/pages/c3.ts +3 -3
- package/templates/svelte/workers/c3.ts +3 -3
- package/templates/vue/pages/c3.ts +5 -3
- package/templates/vue/pages/templates/wrangler.jsonc +5 -0
- package/templates/vue/workers/ts/tsconfig.worker.json +1 -1
- package/templates-experimental/solid/c3.ts +1 -1
- package/templates/analog/templates/worker-configuration.d.ts +0 -4
- package/templates/astro/workers/templates/ts/worker-configuration.d.ts +0 -4
- package/templates/common/ts/worker-configuration.d.ts +0 -4
- package/templates/hello-world/ts/worker-configuration.d.ts +0 -8
- package/templates/hello-world-durable-object/ts/worker-configuration.d.ts +0 -7
- package/templates/hello-world-durable-object-with-assets/ts/worker-configuration.d.ts +0 -8
- package/templates/hello-world-with-assets/ts/worker-configuration.d.ts +0 -7
- package/templates/hono/pages/templates/worker-configuration.d.ts +0 -4
- package/templates/hono/workers/templates/worker-configuration.d.ts +0 -4
- package/templates/next/pages/env.d.ts +0 -5
- package/templates/next/workers/templates/cloudflare-env.d.ts +0 -5
- package/templates/nuxt/pages/templates/worker-configuration.d.ts +0 -4
- package/templates/nuxt/workers/templates/worker-configuration.d.ts +0 -4
- package/templates/openapi/ts/worker-configuration.d.ts +0 -4
- package/templates/queues/ts/worker-configuration.d.ts +0 -5
- package/templates/react/workers/ts/worker-configuration.d.ts +0 -5
- package/templates/react-router/templates/worker-configuration.d.ts +0 -8
- package/templates/scheduled/ts/worker-configuration.d.ts +0 -4
- package/templates/vue/workers/ts/worker-configuration.d.ts +0 -6
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Logs
|
|
2
|
+
|
|
3
|
+
logs
|
|
4
|
+
_.log
|
|
5
|
+
npm-debug.log_
|
|
6
|
+
yarn-debug.log*
|
|
7
|
+
yarn-error.log*
|
|
8
|
+
lerna-debug.log*
|
|
9
|
+
.pnpm-debug.log*
|
|
10
|
+
|
|
11
|
+
# Diagnostic reports (https://nodejs.org/api/report.html)
|
|
12
|
+
|
|
13
|
+
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
|
|
14
|
+
|
|
15
|
+
# Runtime data
|
|
16
|
+
|
|
17
|
+
pids
|
|
18
|
+
_.pid
|
|
19
|
+
_.seed
|
|
20
|
+
\*.pid.lock
|
|
21
|
+
|
|
22
|
+
# Dependency directories
|
|
23
|
+
|
|
24
|
+
node_modules/
|
|
25
|
+
jspm_packages/
|
|
26
|
+
|
|
27
|
+
# TypeScript cache
|
|
28
|
+
|
|
29
|
+
\*.tsbuildinfo
|
|
30
|
+
|
|
31
|
+
# Optional npm cache directory
|
|
32
|
+
|
|
33
|
+
.npm
|
|
34
|
+
|
|
35
|
+
# Optional eslint cache
|
|
36
|
+
|
|
37
|
+
.eslintcache
|
|
38
|
+
|
|
39
|
+
# Optional stylelint cache
|
|
40
|
+
|
|
41
|
+
.stylelintcache
|
|
42
|
+
|
|
43
|
+
# Optional REPL history
|
|
44
|
+
|
|
45
|
+
.node_repl_history
|
|
46
|
+
|
|
47
|
+
# Output of 'npm pack'
|
|
48
|
+
|
|
49
|
+
\*.tgz
|
|
50
|
+
|
|
51
|
+
# dotenv environment variable files
|
|
52
|
+
|
|
53
|
+
.env
|
|
54
|
+
.env.development.local
|
|
55
|
+
.env.test.local
|
|
56
|
+
.env.production.local
|
|
57
|
+
.env.local
|
|
58
|
+
|
|
59
|
+
# public
|
|
60
|
+
|
|
61
|
+
# Stores VSCode versions used for testing VSCode extensions
|
|
62
|
+
|
|
63
|
+
.vscode-test
|
|
64
|
+
|
|
65
|
+
# wrangler project
|
|
66
|
+
|
|
67
|
+
.dev.vars
|
|
68
|
+
.wrangler/
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>Hello, World!</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<h1 id="heading"></h1>
|
|
10
|
+
<p>This page comes from a static asset stored at `public/index.html` as configured in `wrangler.jsonc`.</p>
|
|
11
|
+
<script>
|
|
12
|
+
fetch('/message')
|
|
13
|
+
.then((resp) => resp.text())
|
|
14
|
+
.then((text) => {
|
|
15
|
+
const h1 = document.getElementById('heading');
|
|
16
|
+
h1.textContent = text;
|
|
17
|
+
});
|
|
18
|
+
</script>
|
|
19
|
+
</body>
|
|
20
|
+
</html>
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
from workers import DurableObject, Response
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
* Welcome to Cloudflare Workers! This is your first Durable Objects application.
|
|
5
|
+
*
|
|
6
|
+
* - Run `npm run dev` in your terminal to start a development server
|
|
7
|
+
* - Open a browser tab at http://localhost:8787/ to see your Durable Object in action
|
|
8
|
+
* - Run `npm run deploy` to publish your application
|
|
9
|
+
*
|
|
10
|
+
* Learn more at https://developers.cloudflare.com/durable-objects
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
"""
|
|
14
|
+
* Env provides a mechanism to reference bindings declared in wrangler.jsonc within Python
|
|
15
|
+
*
|
|
16
|
+
* @typedef {Object} Env
|
|
17
|
+
* @property {DurableObjectNamespace} MY_DURABLE_OBJECT - The Durable Object namespace binding
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
# A Durable Object's behavior is defined in an exported Python class
|
|
21
|
+
class MyDurableObject(DurableObject):
|
|
22
|
+
"""
|
|
23
|
+
* The constructor is invoked once upon creation of the Durable Object, i.e. the first call to
|
|
24
|
+
* `DurableObjectStub::get` for a given identifier (no-op constructors can be omitted)
|
|
25
|
+
*
|
|
26
|
+
* @param {DurableObjectState} ctx - The interface for interacting with Durable Object state
|
|
27
|
+
* @param {Env} env - The interface to reference bindings declared in wrangler.jsonc
|
|
28
|
+
"""
|
|
29
|
+
def __init__(self, ctx, env):
|
|
30
|
+
super().__init__(ctx, env)
|
|
31
|
+
|
|
32
|
+
"""
|
|
33
|
+
* The Durable Object exposes an RPC method `say_hello` which will be invoked when when a Durable
|
|
34
|
+
* Object instance receives a request from a Worker via the same method invocation on the stub
|
|
35
|
+
*
|
|
36
|
+
* @param {string} name - The name provided to a Durable Object instance from a Worker
|
|
37
|
+
* @returns {Promise<string>} The greeting to be sent back to the Worker
|
|
38
|
+
"""
|
|
39
|
+
async def say_hello(self, name):
|
|
40
|
+
return f"Hello, {name}!"
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
"""
|
|
44
|
+
* This is the standard fetch handler for a Cloudflare Worker
|
|
45
|
+
*
|
|
46
|
+
* @param {Request} request - The request submitted to the Worker from the client
|
|
47
|
+
* @param {Env} env - The interface to reference bindings declared in wrangler.jsonc
|
|
48
|
+
* @param {ExecutionContext} ctx - The execution context of the Worker
|
|
49
|
+
* @returns {Promise<Response>} The response to be sent back to the client
|
|
50
|
+
"""
|
|
51
|
+
async def on_fetch(request, env, ctx):
|
|
52
|
+
# Create a `DurableObjectId` for an instance of the `MyDurableObject`
|
|
53
|
+
# class named "foo". Requests from all Workers to the instance named
|
|
54
|
+
# "foo" will go to a single globally unique Durable Object instance.
|
|
55
|
+
id = env.MY_DURABLE_OBJECT.idFromName("foo")
|
|
56
|
+
|
|
57
|
+
# Create a stub to open a communication channel with the Durable
|
|
58
|
+
# Object instance.
|
|
59
|
+
stub = env.MY_DURABLE_OBJECT.get(id)
|
|
60
|
+
|
|
61
|
+
# Call the `say_hello()` RPC method on the stub to invoke the method on
|
|
62
|
+
# the remote Durable Object instance
|
|
63
|
+
greeting = await stub.say_hello("world")
|
|
64
|
+
|
|
65
|
+
return Response(greeting)
|
|
66
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
version = 1
|
|
2
|
+
requires-python = ">=3.12"
|
|
3
|
+
|
|
4
|
+
[[package]]
|
|
5
|
+
name = "<TBD>"
|
|
6
|
+
version = "0.1.0"
|
|
7
|
+
source = { virtual = "." }
|
|
8
|
+
dependencies = [
|
|
9
|
+
{ name = "webtypy" },
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
[package.metadata]
|
|
13
|
+
requires-dist = [{ name = "webtypy", specifier = ">=0.1.7" }]
|
|
14
|
+
|
|
15
|
+
[[package]]
|
|
16
|
+
name = "webtypy"
|
|
17
|
+
version = "0.1.7"
|
|
18
|
+
source = { registry = "https://pypi.org/simple" }
|
|
19
|
+
sdist = { url = "https://files.pythonhosted.org/packages/5e/89/c7a0311fdc73809fc2415be97767f085ff3e00c86546430034dc8465fee7/webtypy-0.1.7.tar.gz", hash = "sha256:1b7212719a949c802f3d60fac5f0d952eb503a92121409cf1ad9847d7c76a336", size = 104505 }
|
|
20
|
+
wheels = [
|
|
21
|
+
{ url = "https://files.pythonhosted.org/packages/61/91/c731bdaa605279e00b28bfd2bf0ae67f48061d16890fb1c026924bfbd242/webtypy-0.1.7-py3-none-any.whl", hash = "sha256:f35e6d73a4e08783e23adfac271a11cda3a2bd1105499db70e4819244efed0ae", size = 103519 },
|
|
22
|
+
]
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "<TBD>",
|
|
3
|
+
"main": "src/entry.py",
|
|
4
|
+
"compatibility_date": "<TBD>",
|
|
5
|
+
"compatibility_flags": [
|
|
6
|
+
"python_workers"
|
|
7
|
+
],
|
|
8
|
+
"assets": {
|
|
9
|
+
// The path to the directory containing the `index.html` file to be served at `/`
|
|
10
|
+
"directory": "./public"
|
|
11
|
+
},
|
|
12
|
+
"migrations": [
|
|
13
|
+
{
|
|
14
|
+
"new_sqlite_classes": [
|
|
15
|
+
"MyDurableObject"
|
|
16
|
+
],
|
|
17
|
+
"tag": "v1"
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"durable_objects": {
|
|
21
|
+
"bindings": [
|
|
22
|
+
{
|
|
23
|
+
"class_name": "MyDurableObject",
|
|
24
|
+
"name": "MY_DURABLE_OBJECT"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
"observability": {
|
|
29
|
+
"enabled": true
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -13,8 +13,6 @@
|
|
|
13
13
|
"module": "es2022",
|
|
14
14
|
/* Specify how TypeScript looks up a file from a given module specifier. */
|
|
15
15
|
"moduleResolution": "node",
|
|
16
|
-
/* Specify type package names to be included without being referenced in a source file. */
|
|
17
|
-
"types": ["@cloudflare/workers-types"],
|
|
18
16
|
/* Enable importing .json files */
|
|
19
17
|
"resolveJsonModule": true,
|
|
20
18
|
|
|
@@ -4,8 +4,9 @@ const config: TemplateConfig = {
|
|
|
4
4
|
configVersion: 1,
|
|
5
5
|
id: "hello-world-with-assets",
|
|
6
6
|
path: "templates/hello-world-with-assets",
|
|
7
|
-
displayName: "
|
|
8
|
-
description:
|
|
7
|
+
displayName: "SSR / full-stack app",
|
|
8
|
+
description:
|
|
9
|
+
"For sites with a backend API, or server-side rendering (SSR). Uses Static Assets with a Worker.",
|
|
9
10
|
platform: "workers",
|
|
10
11
|
copyFiles: {
|
|
11
12
|
variants: {
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
</head>
|
|
8
8
|
<body>
|
|
9
9
|
<h1 id="heading"></h1>
|
|
10
|
+
<p>This page comes from a static asset stored at `public/index.html` as configured in `wrangler.jsonc`.</p>
|
|
10
11
|
<button id="button" type="button">Fetch a random UUID</button>
|
|
11
12
|
<output id="random" for="button"></output>
|
|
12
13
|
<script>
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
"main": "src/index.js",
|
|
4
4
|
"compatibility_date": "<TBD>",
|
|
5
5
|
"compatibility_flags": [
|
|
6
|
-
"nodejs_compat"
|
|
6
|
+
"nodejs_compat",
|
|
7
|
+
"global_fetch_strictly_public"
|
|
7
8
|
],
|
|
8
9
|
"assets": {
|
|
9
|
-
|
|
10
|
+
// The path to the directory containing the `index.html` file to be served at `/`
|
|
10
11
|
"directory": "./public"
|
|
11
12
|
},
|
|
12
13
|
"observability": {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.12
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
## Usage
|
|
2
|
+
|
|
3
|
+
You can run the Worker defined by your new project by executing `wrangler dev` in this
|
|
4
|
+
directory. This will start up an HTTP server and will allow you to iterate on your
|
|
5
|
+
Worker without having to restart `wrangler`.
|
|
6
|
+
|
|
7
|
+
### Types and autocomplete
|
|
8
|
+
|
|
9
|
+
This project also includes a pyproject.toml and uv.lock file with some requirements which
|
|
10
|
+
set up autocomplete and type hints for this Python Workers project.
|
|
11
|
+
|
|
12
|
+
To get these installed you'll need `uv`, which you can install by following
|
|
13
|
+
https://docs.astral.sh/uv/getting-started/installation/.
|
|
14
|
+
|
|
15
|
+
Once `uv` is installed, you can run the following:
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
uv venv
|
|
19
|
+
uv sync
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Then point your editor's Python plugin at the `.venv` directory. You should then have working
|
|
23
|
+
autocomplete and type information in your editor.
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
</head>
|
|
8
8
|
<body>
|
|
9
9
|
<h1 id="heading"></h1>
|
|
10
|
+
<p>This page comes from a static asset stored at `public/index.html` as configured in `wrangler.jsonc`.</p>
|
|
10
11
|
<button id="button" type="button">Fetch a random UUID</button>
|
|
11
12
|
<output id="random" for="button"></output>
|
|
12
13
|
<script>
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
from
|
|
1
|
+
from workers import Response
|
|
2
|
+
from uuid import uuid4
|
|
3
|
+
from urllib.parse import urlparse
|
|
2
4
|
|
|
3
5
|
async def on_fetch(request, env):
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
url = urlparse(request.url)
|
|
7
|
+
if url.path == '/message':
|
|
8
|
+
return Response('Hello, World!')
|
|
9
|
+
if url.path == '/random':
|
|
10
|
+
return Response(uuid4())
|
|
11
|
+
return Response('Not Found', status=404)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
version = 1
|
|
2
|
+
requires-python = ">=3.12"
|
|
3
|
+
|
|
4
|
+
[[package]]
|
|
5
|
+
name = "<TBD>"
|
|
6
|
+
version = "0.1.0"
|
|
7
|
+
source = { virtual = "." }
|
|
8
|
+
dependencies = [
|
|
9
|
+
{ name = "webtypy" },
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
[package.metadata]
|
|
13
|
+
requires-dist = [{ name = "webtypy", specifier = ">=0.1.7" }]
|
|
14
|
+
|
|
15
|
+
[[package]]
|
|
16
|
+
name = "webtypy"
|
|
17
|
+
version = "0.1.7"
|
|
18
|
+
source = { registry = "https://pypi.org/simple" }
|
|
19
|
+
sdist = { url = "https://files.pythonhosted.org/packages/5e/89/c7a0311fdc73809fc2415be97767f085ff3e00c86546430034dc8465fee7/webtypy-0.1.7.tar.gz", hash = "sha256:1b7212719a949c802f3d60fac5f0d952eb503a92121409cf1ad9847d7c76a336", size = 104505 }
|
|
20
|
+
wheels = [
|
|
21
|
+
{ url = "https://files.pythonhosted.org/packages/61/91/c731bdaa605279e00b28bfd2bf0ae67f48061d16890fb1c026924bfbd242/webtypy-0.1.7-py3-none-any.whl", hash = "sha256:f35e6d73a4e08783e23adfac271a11cda3a2bd1105499db70e4819244efed0ae", size = 103519 },
|
|
22
|
+
]
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
</head>
|
|
8
8
|
<body>
|
|
9
9
|
<h1 id="heading"></h1>
|
|
10
|
+
<p>This page comes from a static asset stored at `public/index.html` as configured in `wrangler.jsonc`.</p>
|
|
10
11
|
<button id="button" type="button">Fetch a random UUID</button>
|
|
11
12
|
<output id="random" for="button"></output>
|
|
12
13
|
<script>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"extends": "../tsconfig.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
|
-
"types": ["@cloudflare/
|
|
4
|
+
"types": ["@cloudflare/vitest-pool-workers"]
|
|
5
5
|
},
|
|
6
6
|
"include": ["./**/*.ts", "../worker-configuration.d.ts"],
|
|
7
7
|
"exclude": []
|
|
@@ -13,8 +13,6 @@
|
|
|
13
13
|
"module": "es2022",
|
|
14
14
|
/* Specify how TypeScript looks up a file from a given module specifier. */
|
|
15
15
|
"moduleResolution": "Bundler",
|
|
16
|
-
/* Specify type package names to be included without being referenced in a source file. */
|
|
17
|
-
"types": ["@cloudflare/workers-types"],
|
|
18
16
|
/* Enable importing .json files */
|
|
19
17
|
"resolveJsonModule": true,
|
|
20
18
|
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
"main": "src/index.ts",
|
|
4
4
|
"compatibility_date": "<TBD>",
|
|
5
5
|
"compatibility_flags": [
|
|
6
|
-
"
|
|
6
|
+
"global_fetch_strictly_public"
|
|
7
7
|
],
|
|
8
8
|
"assets": {
|
|
9
|
-
|
|
9
|
+
// The path to the directory containing the `index.html` file to be served at `/`
|
|
10
10
|
"directory": "./public"
|
|
11
11
|
},
|
|
12
12
|
"observability": {
|
|
@@ -19,6 +19,8 @@ const generate = async (ctx: C3Context) => {
|
|
|
19
19
|
logRaw(""); // newline
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
+
const envInterfaceName = "CloudflareBindings";
|
|
23
|
+
|
|
22
24
|
const config: TemplateConfig = {
|
|
23
25
|
configVersion: 1,
|
|
24
26
|
id: "hono",
|
|
@@ -33,12 +35,13 @@ const config: TemplateConfig = {
|
|
|
33
35
|
generate,
|
|
34
36
|
transformPackageJson: async () => ({
|
|
35
37
|
scripts: {
|
|
36
|
-
"cf-typegen":
|
|
38
|
+
"cf-typegen": `wrangler types --env-interface ${envInterfaceName}`,
|
|
37
39
|
preview: "vite build && wrangler pages dev",
|
|
38
40
|
},
|
|
39
41
|
}),
|
|
40
42
|
devScript: "dev",
|
|
41
43
|
deployScript: "deploy",
|
|
42
44
|
previewScript: "preview",
|
|
45
|
+
envInterfaceName,
|
|
43
46
|
};
|
|
44
47
|
export default config;
|
|
@@ -19,6 +19,7 @@ const generate = async (ctx: C3Context) => {
|
|
|
19
19
|
logRaw(""); // newline
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
+
const envInterfaceName = "CloudflareBindings";
|
|
22
23
|
const config: TemplateConfig = {
|
|
23
24
|
configVersion: 1,
|
|
24
25
|
id: "hono",
|
|
@@ -32,11 +33,12 @@ const config: TemplateConfig = {
|
|
|
32
33
|
generate,
|
|
33
34
|
transformPackageJson: async () => ({
|
|
34
35
|
scripts: {
|
|
35
|
-
"cf-typegen":
|
|
36
|
+
"cf-typegen": `wrangler types --env-interface ${envInterfaceName}`,
|
|
36
37
|
},
|
|
37
38
|
}),
|
|
38
39
|
devScript: "dev",
|
|
39
40
|
deployScript: "deploy",
|
|
40
41
|
previewScript: "dev",
|
|
42
|
+
envInterfaceName,
|
|
41
43
|
};
|
|
42
44
|
export default config;
|
|
@@ -75,14 +75,6 @@ const configure = async (ctx: C3Context) => {
|
|
|
75
75
|
|
|
76
76
|
const usesTs = usesTypescript(ctx);
|
|
77
77
|
|
|
78
|
-
if (usesTs) {
|
|
79
|
-
copyFile(
|
|
80
|
-
join(getTemplatePath(ctx), "env.d.ts"),
|
|
81
|
-
join(projectPath, "env.d.ts"),
|
|
82
|
-
);
|
|
83
|
-
updateStatus("Created an env.d.ts file");
|
|
84
|
-
}
|
|
85
|
-
|
|
86
78
|
const installEslintPlugin = await shouldInstallNextOnPagesEslintPlugin(ctx);
|
|
87
79
|
|
|
88
80
|
if (installEslintPlugin) {
|
|
@@ -145,7 +137,6 @@ export const writeEslintrc = async (ctx: C3Context): Promise<void> => {
|
|
|
145
137
|
const addDevDependencies = async (installEslintPlugin: boolean) => {
|
|
146
138
|
const packages = [
|
|
147
139
|
"@cloudflare/next-on-pages@1",
|
|
148
|
-
"@cloudflare/workers-types",
|
|
149
140
|
"vercel",
|
|
150
141
|
...(installEslintPlugin ? ["eslint-plugin-next-on-pages"] : []),
|
|
151
142
|
];
|
|
@@ -156,6 +147,9 @@ const addDevDependencies = async (installEslintPlugin: boolean) => {
|
|
|
156
147
|
});
|
|
157
148
|
};
|
|
158
149
|
|
|
150
|
+
const envInterfaceName = "CloudflareEnv";
|
|
151
|
+
const typesPath = "./env.d.ts";
|
|
152
|
+
|
|
159
153
|
export default {
|
|
160
154
|
configVersion: 1,
|
|
161
155
|
id: "next",
|
|
@@ -213,7 +207,7 @@ export default {
|
|
|
213
207
|
preview: `${pagesBuildRunCommand} && wrangler pages dev`,
|
|
214
208
|
deploy: `${pagesBuildRunCommand} && wrangler pages deploy`,
|
|
215
209
|
...(usesTypescript(ctx) && {
|
|
216
|
-
"cf-typegen": `wrangler types --env-interface
|
|
210
|
+
"cf-typegen": `wrangler types --env-interface ${envInterfaceName} ${typesPath}`,
|
|
217
211
|
}),
|
|
218
212
|
},
|
|
219
213
|
};
|
|
@@ -222,4 +216,6 @@ export default {
|
|
|
222
216
|
previewScript: "preview",
|
|
223
217
|
deployScript: "deploy",
|
|
224
218
|
compatibilityFlags: ["nodejs_compat"],
|
|
219
|
+
typesPath,
|
|
220
|
+
envInterfaceName,
|
|
225
221
|
} as TemplateConfig;
|
|
@@ -11,14 +11,9 @@ const generate = async (ctx: C3Context) => {
|
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
const configure = async (ctx: C3Context) => {
|
|
14
|
-
|
|
15
|
-
"@opennextjs/cloudflare@~1.0.0-beta.0 || ^1.0.0",
|
|
16
|
-
"@cloudflare/workers-types",
|
|
17
|
-
];
|
|
18
|
-
await installPackages(packages, {
|
|
19
|
-
dev: true,
|
|
14
|
+
await installPackages(["@opennextjs/cloudflare@^1.0.2"], {
|
|
20
15
|
startText: "Adding the Cloudflare adapter",
|
|
21
|
-
doneText: `${brandColor(`installed`)}
|
|
16
|
+
doneText: `${brandColor(`installed`)} @opennextjs/cloudflare)}`,
|
|
22
17
|
});
|
|
23
18
|
|
|
24
19
|
const usesTs = usesTypescript(ctx);
|
|
@@ -47,13 +42,14 @@ const updateNextConfig = (usesTs: boolean) => {
|
|
|
47
42
|
s.stop(`${brandColor(`updated`)} ${dim(`\`${configFile}\``)}`);
|
|
48
43
|
};
|
|
49
44
|
|
|
45
|
+
const envInterfaceName = "CloudflareEnv";
|
|
46
|
+
const typesPath = "./cloudflare-env.d.ts";
|
|
50
47
|
export default {
|
|
51
48
|
configVersion: 1,
|
|
52
49
|
id: "next",
|
|
53
50
|
frameworkCli: "create-next-app",
|
|
54
|
-
frameworkCliPinnedVersion: "~15.2.4",
|
|
55
51
|
platform: "workers",
|
|
56
|
-
displayName: "Next.js
|
|
52
|
+
displayName: "Next.js",
|
|
57
53
|
path: "templates/next/workers",
|
|
58
54
|
copyFiles: {
|
|
59
55
|
path: "./templates",
|
|
@@ -64,11 +60,12 @@ export default {
|
|
|
64
60
|
scripts: {
|
|
65
61
|
deploy: `opennextjs-cloudflare build && opennextjs-cloudflare deploy`,
|
|
66
62
|
preview: `opennextjs-cloudflare build && opennextjs-cloudflare preview`,
|
|
67
|
-
"cf-typegen": `wrangler types --env-interface
|
|
63
|
+
"cf-typegen": `wrangler types --env-interface ${envInterfaceName} ${typesPath}`,
|
|
68
64
|
},
|
|
69
65
|
}),
|
|
70
66
|
devScript: "dev",
|
|
71
67
|
previewScript: "preview",
|
|
72
68
|
deployScript: "deploy",
|
|
73
|
-
|
|
69
|
+
typesPath,
|
|
70
|
+
envInterfaceName,
|
|
74
71
|
} as TemplateConfig;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { defineCloudflareConfig } from "@opennextjs/cloudflare";
|
|
2
|
-
import r2IncrementalCache from "@opennextjs/cloudflare/overrides/incremental-cache/r2-incremental-cache";
|
|
3
2
|
|
|
4
3
|
export default defineCloudflareConfig({
|
|
5
|
-
|
|
4
|
+
// Uncomment to enable R2 cache,
|
|
5
|
+
// It should be imported as:
|
|
6
|
+
// `import r2IncrementalCache from "@opennextjs/cloudflare/overrides/incremental-cache/r2-incremental-cache";`
|
|
7
|
+
// See https://opennext.js.org/cloudflare/caching for more details
|
|
8
|
+
// incrementalCache: r2IncrementalCache,
|
|
6
9
|
});
|