create-cloudflare 2.64.8 → 2.65.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.
@@ -4,7 +4,7 @@ import { spinner } from "@cloudflare/cli/interactive";
4
4
  import { runFrameworkGenerator } from "frameworks/index";
5
5
  import { loadTemplateSnippets, transformFile } from "helpers/codemod";
6
6
  import { quoteShellArgs, runCommand } from "helpers/command";
7
- import { removeFile, usesTypescript } from "helpers/files";
7
+ import { usesTypescript } from "helpers/files";
8
8
  import { detectPackageManager } from "helpers/packageManagers";
9
9
  import * as recast from "recast";
10
10
  import type { TemplateConfig } from "../../../src/templates";
@@ -17,15 +17,18 @@ const generate = async (ctx: C3Context) => {
17
17
  };
18
18
 
19
19
  const configure = async (ctx: C3Context) => {
20
- // Add the pages integration
20
+ // Add the workers integration
21
21
  // For some reason `pnpx qwik add` fails for qwik so we use `pnpm qwik add` instead.
22
- const cmd = [name === "pnpm" ? npm : npx, "qwik", "add", "cloudflare-pages"];
22
+ const cmd = [
23
+ name === "pnpm" ? npm : npx,
24
+ "qwik",
25
+ "add",
26
+ "cloudflare-workers",
27
+ "--skipConfirmation=true",
28
+ ];
23
29
  endSection(`Running ${quoteShellArgs(cmd)}`);
24
30
  await runCommand(cmd);
25
31
 
26
- // Remove the extraneous Pages files
27
- removeFile("./public/_routes.json");
28
-
29
32
  addBindingsProxy(ctx);
30
33
  };
31
34
 
@@ -46,7 +49,7 @@ const addBindingsProxy = (ctx: C3Context) => {
46
49
  // Insert the env declaration after the last import (but before the rest of the body)
47
50
  visitProgram: function (n) {
48
51
  const lastImportIndex = n.node.body.findLastIndex(
49
- (t) => t.type === "ImportDeclaration",
52
+ (t) => t.type === "ImportDeclaration"
50
53
  );
51
54
  const lastImport = n.get("body", lastImportIndex);
52
55
  lastImport.insertAfter(...snippets.getPlatformProxyTs);
@@ -44,7 +44,7 @@ async function getVariant(ctx: C3Context) {
44
44
  const selected = variantsOptions.find((v) => v.value === ctx.args.variant);
45
45
  if (!selected) {
46
46
  throw new Error(
47
- `Unknown variant "${ctx.args.variant}". Valid variants are: ${variantsOptions.map((v) => v.value).join(", ")}`,
47
+ `Unknown variant "${ctx.args.variant}". Valid variants are: ${variantsOptions.map((v) => v.value).join(", ")}`
48
48
  );
49
49
  }
50
50
  return selected.value;
@@ -54,12 +54,12 @@ function transformViteConfig(ctx: C3Context) {
54
54
  // import {cloudflare} from "@cloudflare/vite-plugin";
55
55
  // ```
56
56
  const lastImportIndex = n.node.body.findLastIndex(
57
- (statement) => statement.type === "ImportDeclaration",
57
+ (statement) => statement.type === "ImportDeclaration"
58
58
  );
59
59
  const lastImport = n.get("body", lastImportIndex);
60
60
  const importAst = b.importDeclaration(
61
61
  [b.importSpecifier(b.identifier("cloudflare"))],
62
- b.stringLiteral("@cloudflare/vite-plugin"),
62
+ b.stringLiteral("@cloudflare/vite-plugin")
63
63
  );
64
64
  lastImport.insertAfter(importAst);
65
65
 
@@ -81,7 +81,7 @@ function transformViteConfig(ctx: C3Context) {
81
81
  const pluginsProp = config.properties.find((prop) => isPluginsProp(prop));
82
82
  assert(pluginsProp && t.ArrayExpression.check(pluginsProp.value));
83
83
  pluginsProp.value.elements.push(
84
- b.callExpression(b.identifier("cloudflare"), []),
84
+ b.callExpression(b.identifier("cloudflare"), [])
85
85
  );
86
86
 
87
87
  return false;
@@ -90,7 +90,7 @@ function transformViteConfig(ctx: C3Context) {
90
90
  }
91
91
 
92
92
  function isPluginsProp(
93
- prop: unknown,
93
+ prop: unknown
94
94
  ): prop is types.namedTypes.ObjectProperty | types.namedTypes.Property {
95
95
  return (
96
96
  (t.Property.check(prop) || t.ObjectProperty.check(prop)) &&
@@ -142,11 +142,11 @@ async function getVariant(ctx: C3Context) {
142
142
  // If variant is provided via CLI args, use it directly
143
143
  if (ctx.args.variant) {
144
144
  const selected = variantsOptions.find(
145
- (variant) => variant.value === ctx.args.variant,
145
+ (variant) => variant.value === ctx.args.variant
146
146
  );
147
147
  if (!selected) {
148
148
  throw new Error(
149
- `Unknown variant "${ctx.args.variant}". Valid variants are: ${variantsOptions.map((v) => v.value).join(", ")}`,
149
+ `Unknown variant "${ctx.args.variant}". Valid variants are: ${variantsOptions.map((v) => v.value).join(", ")}`
150
150
  );
151
151
  }
152
152
  return selected;
@@ -34,7 +34,7 @@ const configure = async (ctx: C3Context) => {
34
34
  const b = recast.types.builders;
35
35
  const presetProp = b.objectProperty(
36
36
  b.identifier("preset"),
37
- b.stringLiteral("cloudflare-module"),
37
+ b.stringLiteral("cloudflare-module")
38
38
  );
39
39
 
40
40
  if (n.node.arguments.length === 0) {
@@ -42,7 +42,7 @@ const configure = async (ctx: C3Context) => {
42
42
  } else {
43
43
  mergeObjectProperties(
44
44
  n.node.arguments[0] as recast.types.namedTypes.ObjectExpression,
45
- [presetProp],
45
+ [presetProp]
46
46
  );
47
47
  }
48
48
 
@@ -98,21 +98,21 @@ const updateTypeDefinitions = (ctx: C3Context) => {
98
98
  b.tsInterfaceBody([
99
99
  b.tsPropertySignature(
100
100
  b.identifier("env"),
101
- b.tsTypeAnnotation(b.tsTypeReference(b.identifier("Env"))),
101
+ b.tsTypeAnnotation(b.tsTypeReference(b.identifier("Env")))
102
102
  ),
103
103
  b.tsPropertySignature(
104
104
  b.identifier("cf"),
105
105
  b.tsTypeAnnotation(
106
- b.tsTypeReference(b.identifier("CfProperties")),
107
- ),
106
+ b.tsTypeReference(b.identifier("CfProperties"))
107
+ )
108
108
  ),
109
109
  b.tsPropertySignature(
110
110
  b.identifier("ctx"),
111
111
  b.tsTypeAnnotation(
112
- b.tsTypeReference(b.identifier("ExecutionContext")),
113
- ),
112
+ b.tsTypeReference(b.identifier("ExecutionContext"))
113
+ )
114
114
  ),
115
- ]),
115
+ ])
116
116
  );
117
117
 
118
118
  moduleBlock.body.unshift(platformInterface);
@@ -68,21 +68,21 @@ const updateTypeDefinitions = (ctx: C3Context) => {
68
68
  b.tsInterfaceBody([
69
69
  b.tsPropertySignature(
70
70
  b.identifier("env"),
71
- b.tsTypeAnnotation(b.tsTypeReference(b.identifier("Env"))),
71
+ b.tsTypeAnnotation(b.tsTypeReference(b.identifier("Env")))
72
72
  ),
73
73
  b.tsPropertySignature(
74
74
  b.identifier("cf"),
75
75
  b.tsTypeAnnotation(
76
- b.tsTypeReference(b.identifier("CfProperties")),
77
- ),
76
+ b.tsTypeReference(b.identifier("CfProperties"))
77
+ )
78
78
  ),
79
79
  b.tsPropertySignature(
80
80
  b.identifier("ctx"),
81
81
  b.tsTypeAnnotation(
82
- b.tsTypeReference(b.identifier("ExecutionContext")),
83
- ),
82
+ b.tsTypeReference(b.identifier("ExecutionContext"))
83
+ )
84
84
  ),
85
- ]),
85
+ ])
86
86
  );
87
87
 
88
88
  moduleBlock.body.unshift(platformInterface);