create-cloudflare 0.0.0-89350a01 → 0.0.0-89355269
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 +259 -223
- package/package.json +2 -2
- package/templates/solid/c3.ts +52 -11
- package/templates/solid/js/vite.config.js +0 -12
- package/templates/solid/ts/vite.config.ts +0 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-cloudflare",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-89355269",
|
|
4
4
|
"description": "A CLI for creating and deploying new applications to Cloudflare.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -66,8 +66,8 @@
|
|
|
66
66
|
"which-pm-runs": "^1.1.0",
|
|
67
67
|
"yargs": "^17.7.1",
|
|
68
68
|
"yarn": "^1.22.19",
|
|
69
|
-
"wrangler": "3.30.1",
|
|
70
69
|
"@cloudflare/cli": "1.1.1",
|
|
70
|
+
"wrangler": "3.30.1",
|
|
71
71
|
"@cloudflare/workers-tsconfig": "0.0.0"
|
|
72
72
|
},
|
|
73
73
|
"engines": {
|
package/templates/solid/c3.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { logRaw } from "@cloudflare/cli";
|
|
1
|
+
import { logRaw, updateStatus } from "@cloudflare/cli";
|
|
2
|
+
import { blue } from "@cloudflare/cli/colors";
|
|
3
|
+
import { transformFile } from "helpers/codemod";
|
|
2
4
|
import { runFrameworkGenerator } from "helpers/command";
|
|
3
|
-
import { compatDateFlag } from "helpers/files";
|
|
5
|
+
import { compatDateFlag, usesTypescript } from "helpers/files";
|
|
4
6
|
import { detectPackageManager } from "helpers/packages";
|
|
7
|
+
import * as recast from "recast";
|
|
5
8
|
import type { TemplateConfig } from "../../src/templates";
|
|
6
9
|
import type { C3Context } from "types";
|
|
7
10
|
|
|
@@ -14,26 +17,64 @@ const generate = async (ctx: C3Context) => {
|
|
|
14
17
|
logRaw("");
|
|
15
18
|
};
|
|
16
19
|
|
|
20
|
+
const configure = async (ctx: C3Context) => {
|
|
21
|
+
usesTypescript(ctx);
|
|
22
|
+
const filePath = `app.config.${usesTypescript(ctx) ? "ts" : "js"}`;
|
|
23
|
+
|
|
24
|
+
updateStatus(`Updating configuration in ${blue(filePath)}`);
|
|
25
|
+
|
|
26
|
+
transformFile(filePath, {
|
|
27
|
+
visitCallExpression: function (n) {
|
|
28
|
+
const callee = n.node.callee as recast.types.namedTypes.Identifier;
|
|
29
|
+
if (callee.name !== "defineConfig") {
|
|
30
|
+
return this.traverse(n);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const b = recast.types.builders;
|
|
34
|
+
n.node.arguments = [
|
|
35
|
+
b.objectExpression([
|
|
36
|
+
b.objectProperty(
|
|
37
|
+
b.identifier("server"),
|
|
38
|
+
b.objectExpression([
|
|
39
|
+
b.objectProperty(
|
|
40
|
+
b.identifier("preset"),
|
|
41
|
+
b.stringLiteral("cloudflare-pages")
|
|
42
|
+
),
|
|
43
|
+
b.objectProperty(
|
|
44
|
+
b.identifier("rollupConfig"),
|
|
45
|
+
b.objectExpression([
|
|
46
|
+
b.objectProperty(
|
|
47
|
+
b.identifier("external"),
|
|
48
|
+
b.arrayExpression([b.stringLiteral("node:async_hooks")])
|
|
49
|
+
),
|
|
50
|
+
])
|
|
51
|
+
),
|
|
52
|
+
])
|
|
53
|
+
),
|
|
54
|
+
]),
|
|
55
|
+
];
|
|
56
|
+
|
|
57
|
+
return false;
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
|
|
17
62
|
const config: TemplateConfig = {
|
|
18
63
|
configVersion: 1,
|
|
19
64
|
id: "solid",
|
|
20
65
|
displayName: "Solid",
|
|
21
66
|
platform: "pages",
|
|
22
|
-
copyFiles: {
|
|
23
|
-
variants: {
|
|
24
|
-
js: { path: "./js" },
|
|
25
|
-
ts: { path: "./ts" },
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
67
|
generate,
|
|
68
|
+
configure,
|
|
29
69
|
transformPackageJson: async () => ({
|
|
30
70
|
scripts: {
|
|
31
|
-
|
|
32
|
-
|
|
71
|
+
preview: `${npm} run build && npx wrangler pages dev dist ${await compatDateFlag()} --compatibility-flag nodejs_compat`,
|
|
72
|
+
deploy: `${npm} run build && wrangler pages deploy ./dist`,
|
|
33
73
|
},
|
|
34
74
|
}),
|
|
35
75
|
devScript: "dev",
|
|
36
|
-
|
|
76
|
+
deployScript: "deploy",
|
|
77
|
+
previewScript: "preview",
|
|
37
78
|
compatibilityFlags: ["nodejs_compat"],
|
|
38
79
|
};
|
|
39
80
|
export default config;
|