create-cloudflare 2.41.2 → 2.42.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.
- package/dist/cli.js +732 -724
- package/package.json +7 -7
- package/templates/astro/c3.ts +5 -93
- package/templates/astro/pages/c3.ts +98 -0
- package/{templates-experimental/astro → templates/astro/workers}/c3.ts +2 -2
- package/templates/astro/workers/templates/js/public/.assetsignore +2 -0
- package/templates/astro/workers/templates/ts/public/.assetsignore +2 -0
- package/templates/hello-world-durable-object/js/src/index.js +10 -9
- package/templates/hello-world-durable-object/js/wrangler.jsonc +1 -1
- package/templates/hello-world-durable-object/ts/src/index.ts +10 -9
- package/templates/hello-world-durable-object/ts/wrangler.jsonc +1 -1
- package/templates/hono/c3.ts +5 -66
- package/templates/hono/pages/c3.ts +42 -0
- package/templates/hono/pages/templates/src/index.tsx +12 -0
- package/templates/hono/{templates → pages/templates}/wrangler.jsonc +2 -1
- package/{templates-experimental/hono → templates/hono/workers}/c3.ts +2 -4
- package/templates/remix/c3.ts +5 -63
- package/templates/remix/pages/c3.ts +68 -0
- package/{templates-experimental/remix → templates/remix/workers}/c3.ts +2 -2
- package/templates/svelte/c3.ts +5 -154
- package/templates/svelte/pages/c3.ts +159 -0
- package/{templates-experimental/svelte → templates/svelte/workers}/c3.ts +3 -3
- package/templates/svelte/workers/templates/static/.assetsignore +2 -0
- package/templates/hono/snippets/appDeclaration.ts +0 -1
- package/templates-experimental/astro/templates/js/public/.assetsignore +0 -4
- package/templates-experimental/astro/templates/ts/public/.assetsignore +0 -4
- package/templates-experimental/svelte/templates/static/.assetsignore +0 -4
- /package/templates/astro/{templates → pages/templates}/js/wrangler.jsonc +0 -0
- /package/{templates-experimental/astro → templates/astro/pages}/templates/ts/src/env.d.ts +0 -0
- /package/{templates-experimental/astro → templates/astro/pages}/templates/ts/worker-configuration.d.ts +0 -0
- /package/templates/astro/{templates → pages/templates}/ts/wrangler.jsonc +0 -0
- /package/{templates-experimental/astro → templates/astro/workers}/templates/js/wrangler.jsonc +0 -0
- /package/templates/astro/{templates → workers/templates}/ts/src/env.d.ts +0 -0
- /package/templates/astro/{templates → workers/templates}/ts/worker-configuration.d.ts +0 -0
- /package/{templates-experimental/astro → templates/astro/workers}/templates/ts/wrangler.jsonc +0 -0
- /package/{templates-experimental/hono → templates/hono/pages}/templates/worker-configuration.d.ts +0 -0
- /package/{templates-experimental/hono → templates/hono/workers}/templates/public/index.html +0 -0
- /package/{templates-experimental/hono → templates/hono/workers}/templates/src/index.ts +0 -0
- /package/templates/hono/{templates → workers/templates}/worker-configuration.d.ts +0 -0
- /package/{templates-experimental/hono → templates/hono/workers}/templates/wrangler.jsonc +0 -0
- /package/templates/remix/{templates → pages/templates}/worker-configuration.d.ts +0 -0
- /package/templates/remix/{templates → pages/templates}/wrangler.jsonc +0 -0
- /package/{templates-experimental/remix → templates/remix/workers}/templates/public/.assetsignore +0 -0
- /package/{templates-experimental/remix → templates/remix/workers}/templates/worker-configuration.d.ts +0 -0
- /package/{templates-experimental/remix → templates/remix/workers}/templates/wrangler.toml +0 -0
- /package/templates/svelte/{templates → pages/templates}/wrangler.jsonc +0 -0
- /package/{templates-experimental/svelte → templates/svelte/workers}/templates/wrangler.jsonc +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-cloudflare",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.42.0",
|
|
4
4
|
"description": "A CLI for creating and deploying new applications to Cloudflare.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@babel/parser": "^7.21.3",
|
|
31
31
|
"@babel/types": "^7.21.4",
|
|
32
32
|
"@clack/prompts": "^0.6.3",
|
|
33
|
-
"@cloudflare/workers-types": "^4.
|
|
33
|
+
"@cloudflare/workers-types": "^4.20250319.0",
|
|
34
34
|
"@iarna/toml": "^3.0.0",
|
|
35
35
|
"@types/command-exists": "^1.2.0",
|
|
36
36
|
"@types/cross-spawn": "^6.0.2",
|
|
@@ -65,17 +65,17 @@
|
|
|
65
65
|
"undici": "^5.28.5",
|
|
66
66
|
"vite": "^5.4.14",
|
|
67
67
|
"vite-tsconfig-paths": "^4.0.8",
|
|
68
|
-
"vitest": "~3.0.
|
|
68
|
+
"vitest": "~3.0.8",
|
|
69
69
|
"which-pm-runs": "^1.1.0",
|
|
70
70
|
"wrap-ansi": "^9.0.0",
|
|
71
71
|
"xdg-app-paths": "^8.3.0",
|
|
72
72
|
"yargs": "^17.7.2",
|
|
73
73
|
"@cloudflare/cli": "1.1.1",
|
|
74
|
-
"@cloudflare/mock-npm-registry": "0.0.0",
|
|
75
74
|
"@cloudflare/eslint-config-worker": "1.1.0",
|
|
76
|
-
"@cloudflare/
|
|
77
|
-
"
|
|
78
|
-
"@cloudflare/workers-tsconfig": "0.0.0"
|
|
75
|
+
"@cloudflare/mock-npm-registry": "0.0.0",
|
|
76
|
+
"@cloudflare/vite-plugin": "0.1.14",
|
|
77
|
+
"@cloudflare/workers-tsconfig": "0.0.0",
|
|
78
|
+
"wrangler": "4.3.0"
|
|
79
79
|
},
|
|
80
80
|
"engines": {
|
|
81
81
|
"node": ">=18.14.1"
|
package/templates/astro/c3.ts
CHANGED
|
@@ -1,97 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { transformFile } from "helpers/codemod";
|
|
5
|
-
import { runCommand } from "helpers/command";
|
|
6
|
-
import { usesTypescript } from "helpers/files";
|
|
7
|
-
import { detectPackageManager } from "helpers/packageManagers";
|
|
8
|
-
import * as recast from "recast";
|
|
9
|
-
import type { TemplateConfig } from "../../src/templates";
|
|
10
|
-
import type { C3Context, PackageJson } from "types";
|
|
1
|
+
import pages from "./pages/c3";
|
|
2
|
+
import workers from "./workers/c3";
|
|
3
|
+
import type { MultiPlatformTemplateConfig } from "../../src/templates";
|
|
11
4
|
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
const generate = async (ctx: C3Context) => {
|
|
15
|
-
await runFrameworkGenerator(ctx, [ctx.project.name, "--no-install"]);
|
|
16
|
-
|
|
17
|
-
logRaw(""); // newline
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const configure = async () => {
|
|
21
|
-
await runCommand([npx, "astro", "add", "cloudflare", "-y"], {
|
|
22
|
-
silent: true,
|
|
23
|
-
startText: "Installing adapter",
|
|
24
|
-
doneText: `${brandColor("installed")} ${dim(
|
|
25
|
-
`via \`${npx} astro add cloudflare\``,
|
|
26
|
-
)}`,
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
updateAstroConfig();
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const updateAstroConfig = () => {
|
|
33
|
-
const filePath = "astro.config.mjs";
|
|
34
|
-
|
|
35
|
-
updateStatus(`Updating configuration in ${blue(filePath)}`);
|
|
36
|
-
|
|
37
|
-
transformFile(filePath, {
|
|
38
|
-
visitCallExpression: function (n) {
|
|
39
|
-
const callee = n.node.callee as recast.types.namedTypes.Identifier;
|
|
40
|
-
if (callee.name !== "cloudflare") {
|
|
41
|
-
return this.traverse(n);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const b = recast.types.builders;
|
|
45
|
-
n.node.arguments = [
|
|
46
|
-
b.objectExpression([
|
|
47
|
-
b.objectProperty(
|
|
48
|
-
b.identifier("platformProxy"),
|
|
49
|
-
b.objectExpression([
|
|
50
|
-
b.objectProperty(b.identifier("enabled"), b.booleanLiteral(true)),
|
|
51
|
-
]),
|
|
52
|
-
),
|
|
53
|
-
]),
|
|
54
|
-
];
|
|
55
|
-
|
|
56
|
-
return false;
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const config: TemplateConfig = {
|
|
62
|
-
configVersion: 1,
|
|
63
|
-
id: "astro",
|
|
64
|
-
frameworkCli: "create-astro",
|
|
65
|
-
platform: "pages",
|
|
5
|
+
const config: MultiPlatformTemplateConfig = {
|
|
66
6
|
displayName: "Astro",
|
|
67
|
-
|
|
68
|
-
async selectVariant(ctx) {
|
|
69
|
-
// Note: this `selectVariant` function should not be needed
|
|
70
|
-
// this is just a quick workaround until
|
|
71
|
-
// https://github.com/cloudflare/workers-sdk/issues/7495
|
|
72
|
-
// is resolved
|
|
73
|
-
return usesTypescript(ctx) ? "ts" : "js";
|
|
74
|
-
},
|
|
75
|
-
variants: {
|
|
76
|
-
js: {
|
|
77
|
-
path: "./templates/js",
|
|
78
|
-
},
|
|
79
|
-
ts: {
|
|
80
|
-
path: "./templates/ts",
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
devScript: "dev",
|
|
85
|
-
deployScript: "deploy",
|
|
86
|
-
previewScript: "preview",
|
|
87
|
-
generate,
|
|
88
|
-
configure,
|
|
89
|
-
transformPackageJson: async (pkgJson: PackageJson, ctx: C3Context) => ({
|
|
90
|
-
scripts: {
|
|
91
|
-
deploy: `astro build && wrangler pages deploy`,
|
|
92
|
-
preview: `astro build && wrangler pages dev`,
|
|
93
|
-
...(usesTypescript(ctx) && { "cf-typegen": `wrangler types` }),
|
|
94
|
-
},
|
|
95
|
-
}),
|
|
7
|
+
platformVariants: { pages, workers },
|
|
96
8
|
};
|
|
97
9
|
export default config;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { logRaw, updateStatus } from "@cloudflare/cli";
|
|
2
|
+
import { blue, brandColor, dim } from "@cloudflare/cli/colors";
|
|
3
|
+
import { runFrameworkGenerator } from "frameworks/index";
|
|
4
|
+
import { transformFile } from "helpers/codemod";
|
|
5
|
+
import { runCommand } from "helpers/command";
|
|
6
|
+
import { usesTypescript } from "helpers/files";
|
|
7
|
+
import { detectPackageManager } from "helpers/packageManagers";
|
|
8
|
+
import * as recast from "recast";
|
|
9
|
+
import type { TemplateConfig } from "../../../src/templates";
|
|
10
|
+
import type { C3Context, PackageJson } from "types";
|
|
11
|
+
|
|
12
|
+
const { npx } = detectPackageManager();
|
|
13
|
+
|
|
14
|
+
const generate = async (ctx: C3Context) => {
|
|
15
|
+
await runFrameworkGenerator(ctx, [ctx.project.name, "--no-install"]);
|
|
16
|
+
|
|
17
|
+
logRaw(""); // newline
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const configure = async () => {
|
|
21
|
+
await runCommand([npx, "astro", "add", "cloudflare", "-y"], {
|
|
22
|
+
silent: true,
|
|
23
|
+
startText: "Installing adapter",
|
|
24
|
+
doneText: `${brandColor("installed")} ${dim(
|
|
25
|
+
`via \`${npx} astro add cloudflare\``,
|
|
26
|
+
)}`,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
updateAstroConfig();
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const updateAstroConfig = () => {
|
|
33
|
+
const filePath = "astro.config.mjs";
|
|
34
|
+
|
|
35
|
+
updateStatus(`Updating configuration in ${blue(filePath)}`);
|
|
36
|
+
|
|
37
|
+
transformFile(filePath, {
|
|
38
|
+
visitCallExpression: function (n) {
|
|
39
|
+
const callee = n.node.callee as recast.types.namedTypes.Identifier;
|
|
40
|
+
if (callee.name !== "cloudflare") {
|
|
41
|
+
return this.traverse(n);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const b = recast.types.builders;
|
|
45
|
+
n.node.arguments = [
|
|
46
|
+
b.objectExpression([
|
|
47
|
+
b.objectProperty(
|
|
48
|
+
b.identifier("platformProxy"),
|
|
49
|
+
b.objectExpression([
|
|
50
|
+
b.objectProperty(b.identifier("enabled"), b.booleanLiteral(true)),
|
|
51
|
+
]),
|
|
52
|
+
),
|
|
53
|
+
]),
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
return false;
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const config: TemplateConfig = {
|
|
62
|
+
configVersion: 1,
|
|
63
|
+
id: "astro",
|
|
64
|
+
frameworkCli: "create-astro",
|
|
65
|
+
platform: "pages",
|
|
66
|
+
displayName: "Astro",
|
|
67
|
+
path: "templates/astro/pages",
|
|
68
|
+
copyFiles: {
|
|
69
|
+
async selectVariant(ctx) {
|
|
70
|
+
// Note: this `selectVariant` function should not be needed
|
|
71
|
+
// this is just a quick workaround until
|
|
72
|
+
// https://github.com/cloudflare/workers-sdk/issues/7495
|
|
73
|
+
// is resolved
|
|
74
|
+
return usesTypescript(ctx) ? "ts" : "js";
|
|
75
|
+
},
|
|
76
|
+
variants: {
|
|
77
|
+
js: {
|
|
78
|
+
path: "./templates/js",
|
|
79
|
+
},
|
|
80
|
+
ts: {
|
|
81
|
+
path: "./templates/ts",
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
devScript: "dev",
|
|
86
|
+
deployScript: "deploy",
|
|
87
|
+
previewScript: "preview",
|
|
88
|
+
generate,
|
|
89
|
+
configure,
|
|
90
|
+
transformPackageJson: async (pkgJson: PackageJson, ctx: C3Context) => ({
|
|
91
|
+
scripts: {
|
|
92
|
+
deploy: `astro build && wrangler pages deploy`,
|
|
93
|
+
preview: `astro build && wrangler pages dev`,
|
|
94
|
+
...(usesTypescript(ctx) && { "cf-typegen": `wrangler types` }),
|
|
95
|
+
},
|
|
96
|
+
}),
|
|
97
|
+
};
|
|
98
|
+
export default config;
|
|
@@ -6,7 +6,7 @@ import { runCommand } from "helpers/command";
|
|
|
6
6
|
import { usesTypescript } from "helpers/files";
|
|
7
7
|
import { detectPackageManager } from "helpers/packageManagers";
|
|
8
8
|
import * as recast from "recast";
|
|
9
|
-
import type { TemplateConfig } from "
|
|
9
|
+
import type { TemplateConfig } from "../../../src/templates";
|
|
10
10
|
import type { C3Context, PackageJson } from "types";
|
|
11
11
|
|
|
12
12
|
const { npx } = detectPackageManager();
|
|
@@ -84,7 +84,7 @@ const config: TemplateConfig = {
|
|
|
84
84
|
devScript: "dev",
|
|
85
85
|
deployScript: "deploy",
|
|
86
86
|
previewScript: "preview",
|
|
87
|
-
path: "templates
|
|
87
|
+
path: "templates/astro/workers",
|
|
88
88
|
generate,
|
|
89
89
|
configure,
|
|
90
90
|
transformPackageJson: async (pkgJson: PackageJson, ctx: C3Context) => ({
|
|
@@ -52,17 +52,18 @@ export default {
|
|
|
52
52
|
* @returns {Promise<Response>} The response to be sent back to the client
|
|
53
53
|
*/
|
|
54
54
|
async fetch(request, env, ctx) {
|
|
55
|
-
//
|
|
56
|
-
//
|
|
57
|
-
|
|
55
|
+
// Create a `DurableObjectId` for an instance of the `MyDurableObject`
|
|
56
|
+
// class named "foo". Requests from all Workers to the instance named
|
|
57
|
+
// "foo" will go to a single globally unique Durable Object instance.
|
|
58
|
+
const id = env.MY_DURABLE_OBJECT.idFromName("foo");
|
|
58
59
|
|
|
59
|
-
//
|
|
60
|
-
//
|
|
61
|
-
|
|
60
|
+
// Create a stub to open a communication channel with the Durable
|
|
61
|
+
// Object instance.
|
|
62
|
+
const stub = env.MY_DURABLE_OBJECT.get(id);
|
|
62
63
|
|
|
63
|
-
//
|
|
64
|
-
// Durable Object instance
|
|
65
|
-
|
|
64
|
+
// Call the `sayHello()` RPC method on the stub to invoke the method on
|
|
65
|
+
// the remote Durable Object instance
|
|
66
|
+
const greeting = await stub.sayHello("world");
|
|
66
67
|
|
|
67
68
|
return new Response(greeting);
|
|
68
69
|
},
|
|
@@ -48,17 +48,18 @@ export default {
|
|
|
48
48
|
* @returns The response to be sent back to the client
|
|
49
49
|
*/
|
|
50
50
|
async fetch(request, env, ctx): Promise<Response> {
|
|
51
|
-
//
|
|
52
|
-
//
|
|
53
|
-
|
|
51
|
+
// Create a `DurableObjectId` for an instance of the `MyDurableObject`
|
|
52
|
+
// class named "foo". Requests from all Workers to the instance named
|
|
53
|
+
// "foo" will go to a single globally unique Durable Object instance.
|
|
54
|
+
const id: DurableObjectId = env.MY_DURABLE_OBJECT.idFromName("foo");
|
|
54
55
|
|
|
55
|
-
//
|
|
56
|
-
//
|
|
57
|
-
|
|
56
|
+
// Create a stub to open a communication channel with the Durable
|
|
57
|
+
// Object instance.
|
|
58
|
+
const stub = env.MY_DURABLE_OBJECT.get(id);
|
|
58
59
|
|
|
59
|
-
//
|
|
60
|
-
// Durable Object instance
|
|
61
|
-
|
|
60
|
+
// Call the `sayHello()` RPC method on the stub to invoke the method on
|
|
61
|
+
// the remote Durable Object instance
|
|
62
|
+
const greeting = await stub.sayHello("world");
|
|
62
63
|
|
|
63
64
|
return new Response(greeting);
|
|
64
65
|
},
|
package/templates/hono/c3.ts
CHANGED
|
@@ -1,70 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { runFrameworkGenerator } from "frameworks/index";
|
|
5
|
-
import { loadTemplateSnippets, transformFile } from "helpers/codemod";
|
|
6
|
-
import { detectPackageManager } from "helpers/packageManagers";
|
|
7
|
-
import type { TemplateConfig } from "../../src/templates";
|
|
8
|
-
import type * as recast from "recast";
|
|
9
|
-
import type { C3Context } from "types";
|
|
1
|
+
import pages from "./pages/c3";
|
|
2
|
+
import workers from "./workers/c3";
|
|
3
|
+
import type { MultiPlatformTemplateConfig } from "../../src/templates";
|
|
10
4
|
|
|
11
|
-
const
|
|
12
|
-
const { name: pm } = detectPackageManager();
|
|
13
|
-
|
|
14
|
-
await runFrameworkGenerator(ctx, [
|
|
15
|
-
ctx.project.name,
|
|
16
|
-
"--template",
|
|
17
|
-
"cloudflare-workers",
|
|
18
|
-
"--install",
|
|
19
|
-
"--pm",
|
|
20
|
-
pm,
|
|
21
|
-
]);
|
|
22
|
-
|
|
23
|
-
logRaw(""); // newline
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const configure = async (ctx: C3Context) => {
|
|
27
|
-
const indexFile = "src/index.ts";
|
|
28
|
-
|
|
29
|
-
const s = spinner();
|
|
30
|
-
s.start(`Updating \`${indexFile}\``);
|
|
31
|
-
|
|
32
|
-
const snippets = loadTemplateSnippets(ctx);
|
|
33
|
-
|
|
34
|
-
transformFile(indexFile, {
|
|
35
|
-
visitVariableDeclarator(n) {
|
|
36
|
-
if (n.node.id.type === "Identifier" && n.node.id.name === "app") {
|
|
37
|
-
n.node.init = snippets
|
|
38
|
-
.appDeclarationTs[0] as recast.types.namedTypes.NewExpression;
|
|
39
|
-
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
s.stop(`${brandColor("updated")} \`${dim(indexFile)}\``);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const config: TemplateConfig = {
|
|
49
|
-
configVersion: 1,
|
|
50
|
-
id: "hono",
|
|
51
|
-
frameworkCli: "create-hono",
|
|
5
|
+
const config: MultiPlatformTemplateConfig = {
|
|
52
6
|
displayName: "Hono",
|
|
53
|
-
|
|
54
|
-
path: "./templates",
|
|
55
|
-
},
|
|
56
|
-
platform: "workers",
|
|
57
|
-
generate,
|
|
58
|
-
configure,
|
|
59
|
-
transformPackageJson: async () => ({
|
|
60
|
-
scripts: {
|
|
61
|
-
dev: "wrangler dev",
|
|
62
|
-
deploy: "wrangler deploy --minify",
|
|
63
|
-
"cf-typegen": "wrangler types --env-interface CloudflareBindings",
|
|
64
|
-
},
|
|
65
|
-
}),
|
|
66
|
-
devScript: "dev",
|
|
67
|
-
deployScript: "deploy",
|
|
68
|
-
previewScript: "dev",
|
|
7
|
+
platformVariants: { pages, workers },
|
|
69
8
|
};
|
|
70
9
|
export default config;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { logRaw } from "@cloudflare/cli";
|
|
2
|
+
import { runFrameworkGenerator } from "frameworks/index";
|
|
3
|
+
import { detectPackageManager } from "helpers/packageManagers";
|
|
4
|
+
import type { TemplateConfig } from "../../../src/templates";
|
|
5
|
+
import type { C3Context } from "types";
|
|
6
|
+
|
|
7
|
+
const generate = async (ctx: C3Context) => {
|
|
8
|
+
const { name: pm } = detectPackageManager();
|
|
9
|
+
|
|
10
|
+
await runFrameworkGenerator(ctx, [
|
|
11
|
+
ctx.project.name,
|
|
12
|
+
"--template",
|
|
13
|
+
"cloudflare-pages",
|
|
14
|
+
"--install",
|
|
15
|
+
"--pm",
|
|
16
|
+
pm,
|
|
17
|
+
]);
|
|
18
|
+
|
|
19
|
+
logRaw(""); // newline
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const config: TemplateConfig = {
|
|
23
|
+
configVersion: 1,
|
|
24
|
+
id: "hono",
|
|
25
|
+
frameworkCli: "create-hono",
|
|
26
|
+
displayName: "Hono",
|
|
27
|
+
copyFiles: {
|
|
28
|
+
path: "./templates",
|
|
29
|
+
},
|
|
30
|
+
path: "templates/hono/pages",
|
|
31
|
+
platform: "pages",
|
|
32
|
+
generate,
|
|
33
|
+
transformPackageJson: async () => ({
|
|
34
|
+
scripts: {
|
|
35
|
+
"cf-typegen": "wrangler types --env-interface CloudflareBindings",
|
|
36
|
+
},
|
|
37
|
+
}),
|
|
38
|
+
devScript: "dev",
|
|
39
|
+
deployScript: "deploy",
|
|
40
|
+
previewScript: "dev",
|
|
41
|
+
};
|
|
42
|
+
export default config;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { logRaw } from "@cloudflare/cli";
|
|
2
2
|
import { runFrameworkGenerator } from "frameworks/index";
|
|
3
3
|
import { detectPackageManager } from "helpers/packageManagers";
|
|
4
|
-
import type { TemplateConfig } from "
|
|
4
|
+
import type { TemplateConfig } from "../../../src/templates";
|
|
5
5
|
import type { C3Context } from "types";
|
|
6
6
|
|
|
7
7
|
const generate = async (ctx: C3Context) => {
|
|
@@ -28,12 +28,10 @@ const config: TemplateConfig = {
|
|
|
28
28
|
path: "./templates",
|
|
29
29
|
},
|
|
30
30
|
platform: "workers",
|
|
31
|
-
path: "templates
|
|
31
|
+
path: "templates/hono/workers",
|
|
32
32
|
generate,
|
|
33
33
|
transformPackageJson: async () => ({
|
|
34
34
|
scripts: {
|
|
35
|
-
dev: "wrangler dev",
|
|
36
|
-
deploy: "wrangler deploy --minify",
|
|
37
35
|
"cf-typegen": "wrangler types --env-interface CloudflareBindings",
|
|
38
36
|
},
|
|
39
37
|
}),
|
package/templates/remix/c3.ts
CHANGED
|
@@ -1,67 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
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";
|
|
1
|
+
import pages from "./pages/c3";
|
|
2
|
+
import workers from "./workers/c3";
|
|
3
|
+
import type { MultiPlatformTemplateConfig } from "../../src/templates";
|
|
9
4
|
|
|
10
|
-
const
|
|
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/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",
|
|
5
|
+
const config: MultiPlatformTemplateConfig = {
|
|
50
6
|
displayName: "Remix",
|
|
51
|
-
|
|
52
|
-
path: "./templates",
|
|
53
|
-
},
|
|
54
|
-
generate,
|
|
55
|
-
configure,
|
|
56
|
-
transformPackageJson: async () => ({
|
|
57
|
-
scripts: {
|
|
58
|
-
deploy: `${npm} run build && wrangler pages deploy`,
|
|
59
|
-
preview: `${npm} run build && wrangler pages dev`,
|
|
60
|
-
"cf-typegen": `wrangler types`,
|
|
61
|
-
},
|
|
62
|
-
}),
|
|
63
|
-
devScript: "dev",
|
|
64
|
-
deployScript: "deploy",
|
|
65
|
-
previewScript: "preview",
|
|
7
|
+
platformVariants: { pages, workers },
|
|
66
8
|
};
|
|
67
9
|
export default config;
|
|
@@ -0,0 +1,68 @@
|
|
|
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/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
|
+
displayName: "Remix",
|
|
51
|
+
copyFiles: {
|
|
52
|
+
path: "./templates",
|
|
53
|
+
},
|
|
54
|
+
path: "templates/remix/pages",
|
|
55
|
+
generate,
|
|
56
|
+
configure,
|
|
57
|
+
transformPackageJson: async () => ({
|
|
58
|
+
scripts: {
|
|
59
|
+
deploy: `${npm} run build && wrangler pages deploy`,
|
|
60
|
+
preview: `${npm} run build && wrangler pages dev`,
|
|
61
|
+
"cf-typegen": `wrangler types`,
|
|
62
|
+
},
|
|
63
|
+
}),
|
|
64
|
+
devScript: "dev",
|
|
65
|
+
deployScript: "deploy",
|
|
66
|
+
previewScript: "preview",
|
|
67
|
+
};
|
|
68
|
+
export default config;
|
|
@@ -3,7 +3,7 @@ import { brandColor, dim } from "@cloudflare/cli/colors";
|
|
|
3
3
|
import { runFrameworkGenerator } from "frameworks/index";
|
|
4
4
|
import { detectPackageManager } from "helpers/packageManagers";
|
|
5
5
|
import { installPackages } from "helpers/packages";
|
|
6
|
-
import type { TemplateConfig } from "
|
|
6
|
+
import type { TemplateConfig } from "../../../src/templates";
|
|
7
7
|
import type { C3Context } from "types";
|
|
8
8
|
|
|
9
9
|
const { npm } = detectPackageManager();
|
|
@@ -35,7 +35,7 @@ const config: TemplateConfig = {
|
|
|
35
35
|
copyFiles: {
|
|
36
36
|
path: "./templates",
|
|
37
37
|
},
|
|
38
|
-
path: "templates
|
|
38
|
+
path: "templates/remix/workers",
|
|
39
39
|
generate,
|
|
40
40
|
configure,
|
|
41
41
|
transformPackageJson: async () => ({
|