create-cloudflare 2.51.7 → 2.52.0

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 (34) hide show
  1. package/dist/cli.js +474 -756
  2. package/package.json +6 -6
  3. package/templates/hello-world/py/__dot__gitignore +5 -0
  4. package/templates/hello-world-durable-object/py/__dot__gitignore +5 -0
  5. package/templates/hello-world-durable-object-with-assets/py/__dot__gitignore +5 -0
  6. package/templates/hello-world-with-assets/py/__dot__gitignore +5 -0
  7. package/templates/hello-world-workflows/js/wrangler.jsonc +1 -1
  8. package/templates/next/c3.ts +68 -7
  9. package/templates/react-router/c3.ts +2 -1
  10. package/templates/waku/c3.ts +35 -0
  11. package/templates/waku/wrangler.jsonc +19 -0
  12. package/templates/next/pages/README.md +0 -67
  13. package/templates/next/pages/app/js/app/api/hello/route.js +0 -21
  14. package/templates/next/pages/app/js/app/not-found.js +0 -58
  15. package/templates/next/pages/app/ts/app/api/hello/route.ts +0 -21
  16. package/templates/next/pages/app/ts/app/not-found.tsx +0 -58
  17. package/templates/next/pages/c3.ts +0 -222
  18. package/templates/next/pages/pages/js/pages/api/hello.js +0 -23
  19. package/templates/next/pages/pages/ts/pages/api/hello.ts +0 -24
  20. package/templates/next/pages/wrangler.jsonc +0 -8
  21. package/templates/next/workers/c3.ts +0 -71
  22. package/templates/remix/c3.ts +0 -10
  23. package/templates/remix/pages/c3.ts +0 -70
  24. package/templates/remix/pages/templates/worker-configuration.d.ts +0 -4
  25. package/templates/remix/pages/templates/wrangler.jsonc +0 -5
  26. package/templates/remix/workers/c3.ts +0 -53
  27. package/templates/remix/workers/templates/public/.assetsignore +0 -0
  28. package/templates/remix/workers/templates/worker-configuration.d.ts +0 -4
  29. package/templates/remix/workers/templates/wrangler.toml +0 -11
  30. /package/templates/next/{workers/templates → templates}/.dev.vars +0 -0
  31. /package/templates/next/{workers/templates → templates}/__dot__gitignore +0 -0
  32. /package/templates/next/{workers/templates → templates}/open-next.config.ts +0 -0
  33. /package/templates/next/{workers/templates → templates}/public/_headers +0 -0
  34. /package/templates/next/{workers/templates → templates}/wrangler.jsonc +0 -0
@@ -1,23 +0,0 @@
1
- import { getRequestContext } from '@cloudflare/next-on-pages'
2
-
3
- export const config = {
4
- runtime: 'edge',
5
- }
6
-
7
- export default async function handler(req) {
8
- let responseText = 'Hello World'
9
-
10
- // In the edge runtime you can use Bindings that are available in your application
11
- // (for more details see:
12
- // - https://developers.cloudflare.com/pages/framework-guides/deploy-a-nextjs-site/#use-bindings-in-your-nextjs-application
13
- // - https://developers.cloudflare.com/pages/functions/bindings/
14
- // )
15
- //
16
- // KV Example:
17
- // const myKv = getRequestContext().env.MY_KV_NAMESPACE
18
- // await myKv.put('suffix', ' from a KV store!')
19
- // const suffix = await myKv.get('suffix')
20
- // responseText += suffix
21
-
22
- return new Response(responseText)
23
- }
@@ -1,24 +0,0 @@
1
- import type { NextRequest } from 'next/server'
2
- import { getRequestContext } from '@cloudflare/next-on-pages'
3
-
4
- export const config = {
5
- runtime: 'edge',
6
- }
7
-
8
- export default async function handler(req: NextRequest) {
9
- let responseText = 'Hello World'
10
-
11
- // In the edge runtime you can use Bindings that are available in your application
12
- // (for more details see:
13
- // - https://developers.cloudflare.com/pages/framework-guides/deploy-a-nextjs-site/#use-bindings-in-your-nextjs-application
14
- // - https://developers.cloudflare.com/pages/functions/bindings/
15
- // )
16
- //
17
- // KV Example:
18
- // const myKv = getRequestContext().env.MY_KV_NAMESPACE
19
- // await myKv.put('suffix', ' from a KV store!')
20
- // const suffix = await myKv.get('suffix')
21
- // responseText += suffix
22
-
23
- return new Response(responseText)
24
- }
@@ -1,8 +0,0 @@
1
- {
2
- "name": "<TBD>",
3
- "compatibility_date": "<TBD>",
4
- "compatibility_flags": [
5
- "nodejs_compat"
6
- ],
7
- "pages_build_output_dir": ".vercel/output/static"
8
- }
@@ -1,71 +0,0 @@
1
- import { brandColor, dim } from "@cloudflare/cli/colors";
2
- import { spinner } from "@cloudflare/cli/interactive";
3
- import { runFrameworkGenerator } from "frameworks/index";
4
- import { readFile, usesTypescript, writeFile } from "helpers/files";
5
- import { installPackages } from "helpers/packages";
6
- import type { TemplateConfig } from "../../../src/templates";
7
- import type { C3Context } from "types";
8
-
9
- const generate = async (ctx: C3Context) => {
10
- await runFrameworkGenerator(ctx, [ctx.project.name]);
11
- };
12
-
13
- const configure = async (ctx: C3Context) => {
14
- await installPackages(["@opennextjs/cloudflare@^1.3.0"], {
15
- startText: "Adding the Cloudflare adapter",
16
- doneText: `${brandColor(`installed`)} @opennextjs/cloudflare)}`,
17
- });
18
-
19
- const usesTs = usesTypescript(ctx);
20
-
21
- updateNextConfig(usesTs);
22
- };
23
-
24
- const updateNextConfig = (usesTs: boolean) => {
25
- const s = spinner();
26
-
27
- const configFile = `next.config.${usesTs ? "ts" : "mjs"}`;
28
- s.start(`Updating \`${configFile}\``);
29
-
30
- const configContent = readFile(configFile);
31
-
32
- const updatedConfigFile =
33
- configContent +
34
- `
35
- // added by create cloudflare to enable calling \`getCloudflareContext()\` in \`next dev\`
36
- import { initOpenNextCloudflareForDev } from '@opennextjs/cloudflare';
37
- initOpenNextCloudflareForDev();
38
- `.replace(/\n\t*/g, "\n");
39
-
40
- writeFile(configFile, updatedConfigFile);
41
-
42
- s.stop(`${brandColor(`updated`)} ${dim(`\`${configFile}\``)}`);
43
- };
44
-
45
- const envInterfaceName = "CloudflareEnv";
46
- const typesPath = "./cloudflare-env.d.ts";
47
- export default {
48
- configVersion: 1,
49
- id: "next",
50
- frameworkCli: "create-next-app",
51
- platform: "workers",
52
- displayName: "Next.js",
53
- path: "templates/next/workers",
54
- copyFiles: {
55
- path: "./templates",
56
- },
57
- generate,
58
- configure,
59
- transformPackageJson: async () => ({
60
- scripts: {
61
- deploy: `opennextjs-cloudflare build && opennextjs-cloudflare deploy`,
62
- preview: `opennextjs-cloudflare build && opennextjs-cloudflare preview`,
63
- "cf-typegen": `wrangler types --env-interface ${envInterfaceName} ${typesPath}`,
64
- },
65
- }),
66
- devScript: "dev",
67
- previewScript: "preview",
68
- deployScript: "deploy",
69
- typesPath,
70
- envInterfaceName,
71
- } as TemplateConfig;
@@ -1,10 +0,0 @@
1
- import pages from "./pages/c3";
2
- import workers from "./workers/c3";
3
- import type { MultiPlatformTemplateConfig } from "../../src/templates";
4
-
5
- const config: MultiPlatformTemplateConfig = {
6
- displayName: "Remix",
7
- platformVariants: { pages, workers },
8
- hidden: true,
9
- };
10
- export default config;
@@ -1,70 +0,0 @@
1
- import { logRaw } from "@cloudflare/cli";
2
- import { brandColor, dim } from "@cloudflare/cli/colors";
3
- import { spinner } from "@cloudflare/cli/interactive";
4
- import { runFrameworkGenerator } from "frameworks/index";
5
- import { transformFile } from "helpers/codemod";
6
- import { detectPackageManager } from "helpers/packageManagers";
7
- import type { TemplateConfig } from "../../../src/templates";
8
- import type { C3Context } from "types";
9
-
10
- const { npm } = detectPackageManager();
11
-
12
- const generate = async (ctx: C3Context) => {
13
- await runFrameworkGenerator(ctx, [
14
- ctx.project.name,
15
- "--template",
16
- "https://github.com/remix-run/remix/tree/main-prev/templates/cloudflare",
17
- ]);
18
-
19
- logRaw(""); // newline
20
- };
21
-
22
- const configure = async () => {
23
- const typeDefsPath = "load-context.ts";
24
-
25
- const s = spinner();
26
- s.start(`Updating \`${typeDefsPath}\``);
27
-
28
- // Remove the empty Env declaration from the template to allow the type from
29
- // worker-configuration.d.ts to take over
30
- transformFile(typeDefsPath, {
31
- visitTSInterfaceDeclaration(n) {
32
- if (n.node.id.type === "Identifier" && n.node.id.name !== "Env") {
33
- return this.traverse(n);
34
- }
35
-
36
- // Removes the node
37
- n.replace();
38
- return false;
39
- },
40
- });
41
-
42
- s.stop(`${brandColor("updated")} \`${dim(typeDefsPath)}\``);
43
- };
44
-
45
- const config: TemplateConfig = {
46
- configVersion: 1,
47
- id: "remix",
48
- frameworkCli: "create-remix",
49
- platform: "pages",
50
- hidden: true,
51
- displayName: "Remix",
52
- copyFiles: {
53
- path: "./templates",
54
- },
55
- path: "templates/remix/pages",
56
- generate,
57
- configure,
58
- transformPackageJson: async () => ({
59
- scripts: {
60
- deploy: `${npm} run build && wrangler pages deploy`,
61
- preview: `${npm} run build && wrangler pages dev`,
62
- "cf-typegen": `wrangler types`,
63
- },
64
- }),
65
- devScript: "dev",
66
- deployScript: "deploy",
67
- previewScript: "preview",
68
- workersTypes: "installed",
69
- };
70
- export default config;
@@ -1,4 +0,0 @@
1
- // Generated by Wrangler
2
- // After adding bindings to `wrangler.toml`, regenerate this interface via `npm run cf-typegen`
3
- interface Env {
4
- }
@@ -1,5 +0,0 @@
1
- {
2
- "name": "<TBD>",
3
- "compatibility_date": "<TBD>",
4
- "pages_build_output_dir": "./build/client"
5
- }
@@ -1,53 +0,0 @@
1
- import { logRaw } from "@cloudflare/cli";
2
- import { brandColor, dim } from "@cloudflare/cli/colors";
3
- import { runFrameworkGenerator } from "frameworks/index";
4
- import { detectPackageManager } from "helpers/packageManagers";
5
- import { installPackages } from "helpers/packages";
6
- import type { TemplateConfig } from "../../../src/templates";
7
- import type { C3Context } from "types";
8
-
9
- const { npm } = detectPackageManager();
10
-
11
- const generate = async (ctx: C3Context) => {
12
- await runFrameworkGenerator(ctx, [
13
- ctx.project.name,
14
- "--template",
15
- "https://github.com/remix-run/remix/tree/main-prev/templates/cloudflare-workers",
16
- ]);
17
-
18
- logRaw(""); // newline
19
- };
20
-
21
- const configure = async () => {
22
- await installPackages(["wrangler@latest"], {
23
- dev: true,
24
- startText: "Updating the Wrangler version",
25
- doneText: `${brandColor(`updated`)} ${dim("wrangler@latest")}`,
26
- });
27
- };
28
-
29
- const config: TemplateConfig = {
30
- configVersion: 1,
31
- id: "remix",
32
- frameworkCli: "create-remix",
33
- platform: "workers",
34
- displayName: "Remix",
35
- copyFiles: {
36
- path: "./templates",
37
- },
38
- path: "templates/remix/workers",
39
- generate,
40
- configure,
41
- transformPackageJson: async () => ({
42
- scripts: {
43
- deploy: `${npm} run build && wrangler deploy`,
44
- preview: `${npm} run build && wrangler dev`,
45
- "cf-typegen": `wrangler types`,
46
- },
47
- }),
48
- devScript: "dev",
49
- deployScript: "deploy",
50
- previewScript: "preview",
51
- workersTypes: "installed",
52
- };
53
- export default config;
@@ -1,4 +0,0 @@
1
- // Generated by Wrangler
2
- // After adding bindings to `wrangler.toml`, regenerate this interface via `npm run cf-typegen`
3
- interface Env {
4
- }
@@ -1,11 +0,0 @@
1
- #:schema node_modules/wrangler/config-schema.json
2
- name = "<TBD>"
3
- compatibility_date = "<TBD>"
4
- main = "./server.ts"
5
- assets = { directory = "./build/client" }
6
-
7
- # Workers Logs
8
- # Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/
9
- # Configuration: https://developers.cloudflare.com/workers/observability/logs/workers-logs/#enable-workers-logs
10
- [observability]
11
- enabled = true