create-cloudflare 2.21.1 → 2.21.2
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 +449 -326
- package/package.json +6 -13
- package/templates/analog/c3.ts +4 -4
- package/templates/angular/c3.ts +2 -2
- package/templates/astro/c3.ts +3 -3
- package/templates/hono/c3.ts +1 -1
- package/templates/next/c3.ts +8 -6
- package/templates/nuxt/c3.ts +3 -3
- package/templates/pre-existing/c3.ts +5 -5
- package/templates/qwik/c3.ts +3 -3
- package/templates/scheduled/js/package.json +2 -2
- package/templates/scheduled/js/src/index.js +8 -1
- package/templates/scheduled/ts/package.json +2 -2
- package/templates/scheduled/ts/src/index.ts +1 -1
- package/templates/solid/c3.ts +4 -4
- package/templates/svelte/c3.ts +6 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-cloudflare",
|
|
3
|
-
"version": "2.21.
|
|
3
|
+
"version": "2.21.2",
|
|
4
4
|
"description": "A CLI for creating and deploying new applications to Cloudflare.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -29,8 +29,7 @@
|
|
|
29
29
|
"@babel/parser": "^7.21.3",
|
|
30
30
|
"@babel/types": "^7.21.4",
|
|
31
31
|
"@clack/prompts": "^0.6.3",
|
|
32
|
-
"@cloudflare/
|
|
33
|
-
"@cloudflare/workers-types": "^4.20240419.0",
|
|
32
|
+
"@cloudflare/workers-types": "^4.20240512.0",
|
|
34
33
|
"@iarna/toml": "^3.0.0",
|
|
35
34
|
"@types/command-exists": "^1.2.0",
|
|
36
35
|
"@types/cross-spawn": "^6.0.2",
|
|
@@ -58,19 +57,17 @@
|
|
|
58
57
|
"indent-string": "^5.0.0",
|
|
59
58
|
"magic-string": "^0.30.5",
|
|
60
59
|
"open": "^8.4.0",
|
|
61
|
-
"pnpm": "^8.10.0",
|
|
62
60
|
"recast": "^0.22.0",
|
|
63
61
|
"semver": "^7.5.1",
|
|
64
|
-
"
|
|
65
|
-
"undici": "5.28.3",
|
|
62
|
+
"undici": "5.28.4",
|
|
66
63
|
"vite-tsconfig-paths": "^4.0.8",
|
|
67
64
|
"which-pm-runs": "^1.1.0",
|
|
68
65
|
"wrap-ansi": "^9.0.0",
|
|
69
66
|
"yargs": "^17.7.1",
|
|
70
|
-
"yarn": "^1.22.19",
|
|
71
67
|
"@cloudflare/cli": "1.1.1",
|
|
68
|
+
"@cloudflare/eslint-config-worker": "1.1.0",
|
|
72
69
|
"@cloudflare/workers-tsconfig": "0.0.0",
|
|
73
|
-
"wrangler": "3.
|
|
70
|
+
"wrangler": "3.57.0"
|
|
74
71
|
},
|
|
75
72
|
"engines": {
|
|
76
73
|
"node": ">=18.14.1"
|
|
@@ -84,11 +81,7 @@
|
|
|
84
81
|
"check:lint": "eslint .",
|
|
85
82
|
"check:type": "tsc",
|
|
86
83
|
"lint": "eslint",
|
|
87
|
-
"test:e2e
|
|
88
|
-
"test:e2e:npm": "pnpm run build && cross-env TEST_PM=npm vitest run --config ./vitest-e2e.config.ts",
|
|
89
|
-
"test:e2e:pnpm": "pnpm run build && cross-env TEST_PM=pnpm vitest run --config ./vitest-e2e.config.ts",
|
|
90
|
-
"test:e2e:bun": "pnpm run build && cross-env TEST_PM=bun vitest run --config ./vitest-e2e.config.ts",
|
|
91
|
-
"test:e2e:yarn": "pnpm run build && cross-env TEST_PM=yarn vitest run --config ./vitest-e2e.config.ts",
|
|
84
|
+
"test:e2e": "vitest run --config ./vitest-e2e.config.ts",
|
|
92
85
|
"test:unit": "vitest run --config ./vitest.config.ts",
|
|
93
86
|
"test:unit:watch": "vitest --config ./vitest.config.ts",
|
|
94
87
|
"watch": "node -r esbuild-register scripts/build.ts --watch",
|
package/templates/analog/c3.ts
CHANGED
|
@@ -76,7 +76,7 @@ const updateViteConfig = (ctx: C3Context) => {
|
|
|
76
76
|
transformFile(configFile, {
|
|
77
77
|
visitProgram(n) {
|
|
78
78
|
const lastImportIndex = n.node.body.findLastIndex(
|
|
79
|
-
(t) => t.type === "ImportDeclaration"
|
|
79
|
+
(t) => t.type === "ImportDeclaration",
|
|
80
80
|
);
|
|
81
81
|
const lastImport = n.get("body", lastImportIndex);
|
|
82
82
|
lastImport.insertAfter(...snippets.devBindingsModuleTs);
|
|
@@ -91,13 +91,13 @@ const updateViteConfig = (ctx: C3Context) => {
|
|
|
91
91
|
b.objectExpression([
|
|
92
92
|
b.objectProperty(
|
|
93
93
|
b.identifier("preset"),
|
|
94
|
-
b.stringLiteral("cloudflare-pages")
|
|
94
|
+
b.stringLiteral("cloudflare-pages"),
|
|
95
95
|
),
|
|
96
96
|
b.objectProperty(
|
|
97
97
|
b.identifier("modules"),
|
|
98
|
-
b.arrayExpression([b.identifier("devBindingsModule")])
|
|
98
|
+
b.arrayExpression([b.identifier("devBindingsModule")]),
|
|
99
99
|
),
|
|
100
|
-
])
|
|
100
|
+
]),
|
|
101
101
|
);
|
|
102
102
|
|
|
103
103
|
n.node.arguments = [b.objectExpression([pluginArguments])];
|
package/templates/angular/c3.ts
CHANGED
|
@@ -30,7 +30,7 @@ async function installCFWorker() {
|
|
|
30
30
|
dev: true,
|
|
31
31
|
startText: "Installing adapter dependencies",
|
|
32
32
|
doneText: `${brandColor("installed")} ${dim(`via \`${npm} install\``)}`,
|
|
33
|
-
}
|
|
33
|
+
},
|
|
34
34
|
);
|
|
35
35
|
}
|
|
36
36
|
async function updateAppCode() {
|
|
@@ -45,7 +45,7 @@ async function updateAppCode() {
|
|
|
45
45
|
"import { provideHttpClient, withFetch } from '@angular/common/http';\n" +
|
|
46
46
|
appConfig.replace(
|
|
47
47
|
"providers: [",
|
|
48
|
-
"providers: [provideHttpClient(withFetch()), "
|
|
48
|
+
"providers: [provideHttpClient(withFetch()), ",
|
|
49
49
|
);
|
|
50
50
|
writeFile(resolve(appConfigPath), newAppConfig);
|
|
51
51
|
s.stop(`${brandColor(`updated`)} ${dim(appConfigPath)}`);
|
package/templates/astro/c3.ts
CHANGED
|
@@ -22,7 +22,7 @@ const configure = async (ctx: C3Context) => {
|
|
|
22
22
|
silent: true,
|
|
23
23
|
startText: "Installing adapter",
|
|
24
24
|
doneText: `${brandColor("installed")} ${dim(
|
|
25
|
-
`via \`${npx} astro add cloudflare
|
|
25
|
+
`via \`${npx} astro add cloudflare\``,
|
|
26
26
|
)}`,
|
|
27
27
|
});
|
|
28
28
|
|
|
@@ -49,7 +49,7 @@ const updateAstroConfig = () => {
|
|
|
49
49
|
b.identifier("platformProxy"),
|
|
50
50
|
b.objectExpression([
|
|
51
51
|
b.objectProperty(b.identifier("enabled"), b.booleanLiteral(true)),
|
|
52
|
-
])
|
|
52
|
+
]),
|
|
53
53
|
),
|
|
54
54
|
]),
|
|
55
55
|
];
|
|
@@ -77,7 +77,7 @@ const updateEnvDeclaration = (ctx: C3Context) => {
|
|
|
77
77
|
// Preserve comments with the new body
|
|
78
78
|
const comments = n.get("comments").value;
|
|
79
79
|
n.node.comments = comments.map((c: recast.types.namedTypes.CommentLine) =>
|
|
80
|
-
b.commentLine(c.value)
|
|
80
|
+
b.commentLine(c.value),
|
|
81
81
|
);
|
|
82
82
|
|
|
83
83
|
// Add the patch
|
package/templates/hono/c3.ts
CHANGED
|
@@ -35,7 +35,7 @@ const configure = async (ctx: C3Context) => {
|
|
|
35
35
|
// Insert the env declaration after the last import (but before the rest of the body)
|
|
36
36
|
visitProgram: function (n) {
|
|
37
37
|
const lastImportIndex = n.node.body.findLastIndex(
|
|
38
|
-
(t) => t.type === "ImportDeclaration"
|
|
38
|
+
(t) => t.type === "ImportDeclaration",
|
|
39
39
|
);
|
|
40
40
|
const lastImport = n.get("body", lastImportIndex);
|
|
41
41
|
lastImport.insertAfter(...snippets.bindingsTypeTs);
|
package/templates/next/c3.ts
CHANGED
|
@@ -35,7 +35,7 @@ const generate = async (ctx: C3Context) => {
|
|
|
35
35
|
// (instead of making it a special case which needs extra care)
|
|
36
36
|
const newTomlContent = wranglerToml.replace(
|
|
37
37
|
/#\s+\[\[kv_namespaces\]\]\n#\s+binding\s+=\s+"MY_KV_NAMESPACE"\n#\s+id\s+=\s+"[a-zA-Z0-9]+?"/,
|
|
38
|
-
($1) => `# KV Example:\n${$1}
|
|
38
|
+
($1) => `# KV Example:\n${$1}`,
|
|
39
39
|
);
|
|
40
40
|
|
|
41
41
|
if (!/# KV Example/.test(newTomlContent)) {
|
|
@@ -97,7 +97,7 @@ const configure = async (ctx: C3Context) => {
|
|
|
97
97
|
if (usesTs) {
|
|
98
98
|
copyFile(
|
|
99
99
|
join(getTemplatePath(ctx), "env.d.ts"),
|
|
100
|
-
join(projectPath, "env.d.ts")
|
|
100
|
+
join(projectPath, "env.d.ts"),
|
|
101
101
|
);
|
|
102
102
|
updateStatus("Created an env.d.ts file");
|
|
103
103
|
}
|
|
@@ -112,7 +112,7 @@ const configure = async (ctx: C3Context) => {
|
|
|
112
112
|
|
|
113
113
|
copyFile(
|
|
114
114
|
join(getTemplatePath(ctx), "README.md"),
|
|
115
|
-
join(projectPath, "README.md")
|
|
115
|
+
join(projectPath, "README.md"),
|
|
116
116
|
);
|
|
117
117
|
updateStatus("Updated the README file");
|
|
118
118
|
|
|
@@ -120,15 +120,17 @@ const configure = async (ctx: C3Context) => {
|
|
|
120
120
|
};
|
|
121
121
|
|
|
122
122
|
export const shouldInstallNextOnPagesEslintPlugin = async (
|
|
123
|
-
ctx: C3Context
|
|
123
|
+
ctx: C3Context,
|
|
124
124
|
): Promise<boolean> => {
|
|
125
125
|
const eslintUsage = usesEslint(ctx);
|
|
126
126
|
|
|
127
|
-
if (!eslintUsage.used)
|
|
127
|
+
if (!eslintUsage.used) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
128
130
|
|
|
129
131
|
if (eslintUsage.configType !== ".eslintrc.json") {
|
|
130
132
|
warn(
|
|
131
|
-
`Expected .eslintrc.json from Next.js scaffolding but found ${eslintUsage.configType} instead
|
|
133
|
+
`Expected .eslintrc.json from Next.js scaffolding but found ${eslintUsage.configType} instead`,
|
|
132
134
|
);
|
|
133
135
|
return false;
|
|
134
136
|
}
|
package/templates/nuxt/c3.ts
CHANGED
|
@@ -82,14 +82,14 @@ const updateNuxtConfig = () => {
|
|
|
82
82
|
b.objectExpression([
|
|
83
83
|
b.objectProperty(
|
|
84
84
|
b.identifier("preset"),
|
|
85
|
-
b.stringLiteral("cloudflare-pages")
|
|
85
|
+
b.stringLiteral("cloudflare-pages"),
|
|
86
86
|
),
|
|
87
|
-
])
|
|
87
|
+
]),
|
|
88
88
|
);
|
|
89
89
|
|
|
90
90
|
const moduleDef = b.objectProperty(
|
|
91
91
|
b.identifier("modules"),
|
|
92
|
-
b.arrayExpression([b.stringLiteral("nitro-cloudflare-dev")])
|
|
92
|
+
b.arrayExpression([b.stringLiteral("nitro-cloudflare-dev")]),
|
|
93
93
|
);
|
|
94
94
|
|
|
95
95
|
transformFile(configFile, {
|
|
@@ -23,7 +23,7 @@ export async function copyExistingWorkerFiles(ctx: C3Context) {
|
|
|
23
23
|
"Please specify the name of the existing worker in this account?",
|
|
24
24
|
label: "worker",
|
|
25
25
|
defaultValue: ctx.project.name,
|
|
26
|
-
}
|
|
26
|
+
},
|
|
27
27
|
);
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -46,22 +46,22 @@ export async function copyExistingWorkerFiles(ctx: C3Context) {
|
|
|
46
46
|
env: { CLOUDFLARE_ACCOUNT_ID: ctx.account?.id },
|
|
47
47
|
startText: "Downloading existing worker files",
|
|
48
48
|
doneText: `${brandColor("downloaded")} ${dim(
|
|
49
|
-
`existing "${ctx.args.existingScript}" worker files
|
|
49
|
+
`existing "${ctx.args.existingScript}" worker files`,
|
|
50
50
|
)}`,
|
|
51
|
-
}
|
|
51
|
+
},
|
|
52
52
|
);
|
|
53
53
|
|
|
54
54
|
// copy src/* files from the downloaded worker
|
|
55
55
|
await cp(
|
|
56
56
|
join(tempdir, ctx.args.existingScript, "src"),
|
|
57
57
|
join(ctx.project.path, "src"),
|
|
58
|
-
{ recursive: true }
|
|
58
|
+
{ recursive: true },
|
|
59
59
|
);
|
|
60
60
|
|
|
61
61
|
// copy wrangler.toml from the downloaded worker
|
|
62
62
|
await cp(
|
|
63
63
|
join(tempdir, ctx.args.existingScript, "wrangler.toml"),
|
|
64
|
-
join(ctx.project.path, "wrangler.toml")
|
|
64
|
+
join(ctx.project.path, "wrangler.toml"),
|
|
65
65
|
);
|
|
66
66
|
}
|
|
67
67
|
|
package/templates/qwik/c3.ts
CHANGED
|
@@ -43,7 +43,7 @@ const addBindingsProxy = (ctx: C3Context) => {
|
|
|
43
43
|
// Insert the env declaration after the last import (but before the rest of the body)
|
|
44
44
|
visitProgram: function (n) {
|
|
45
45
|
const lastImportIndex = n.node.body.findLastIndex(
|
|
46
|
-
(t) => t.type === "ImportDeclaration"
|
|
46
|
+
(t) => t.type === "ImportDeclaration",
|
|
47
47
|
);
|
|
48
48
|
const lastImport = n.get("body", lastImportIndex);
|
|
49
49
|
lastImport.insertAfter(...snippets.getPlatformProxyTs);
|
|
@@ -109,8 +109,8 @@ const populateCloudflareEnv = () => {
|
|
|
109
109
|
].map(([varName, type]) =>
|
|
110
110
|
b.tsPropertySignature(
|
|
111
111
|
b.identifier(varName),
|
|
112
|
-
b.tsTypeAnnotation(b.tsTypeReference(b.identifier(type)))
|
|
113
|
-
)
|
|
112
|
+
b.tsTypeAnnotation(b.tsTypeReference(b.identifier(type))),
|
|
113
|
+
),
|
|
114
114
|
);
|
|
115
115
|
|
|
116
116
|
n.node.body.body = newBody;
|
|
@@ -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) {
|
|
@@ -4,8 +4,8 @@
|
|
|
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": {
|
|
@@ -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
|
package/templates/solid/c3.ts
CHANGED
|
@@ -39,18 +39,18 @@ const configure = async (ctx: C3Context) => {
|
|
|
39
39
|
b.objectExpression([
|
|
40
40
|
b.objectProperty(
|
|
41
41
|
b.identifier("preset"),
|
|
42
|
-
b.stringLiteral("cloudflare-pages")
|
|
42
|
+
b.stringLiteral("cloudflare-pages"),
|
|
43
43
|
),
|
|
44
44
|
b.objectProperty(
|
|
45
45
|
b.identifier("rollupConfig"),
|
|
46
46
|
b.objectExpression([
|
|
47
47
|
b.objectProperty(
|
|
48
48
|
b.identifier("external"),
|
|
49
|
-
b.arrayExpression([b.stringLiteral("node:async_hooks")])
|
|
49
|
+
b.arrayExpression([b.stringLiteral("node:async_hooks")]),
|
|
50
50
|
),
|
|
51
|
-
])
|
|
51
|
+
]),
|
|
52
52
|
),
|
|
53
|
-
])
|
|
53
|
+
]),
|
|
54
54
|
),
|
|
55
55
|
]),
|
|
56
56
|
];
|
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);
|