create-cloudflare 0.0.0-96b79b3f → 0.0.0-96e4e165

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.
@@ -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
 
@@ -9,31 +12,70 @@ const { npm } = detectPackageManager();
9
12
 
10
13
  const generate = async (ctx: C3Context) => {
11
14
  // Run the create-solid command
12
- await runFrameworkGenerator(ctx, [ctx.project.name]);
15
+ // -s flag forces solid-start
16
+ await runFrameworkGenerator(ctx, ["-p", ctx.project.name, "-s"]);
13
17
 
14
18
  logRaw("");
15
19
  };
16
20
 
21
+ const configure = async (ctx: C3Context) => {
22
+ usesTypescript(ctx);
23
+ const filePath = `app.config.${usesTypescript(ctx) ? "ts" : "js"}`;
24
+
25
+ updateStatus(`Updating configuration in ${blue(filePath)}`);
26
+
27
+ transformFile(filePath, {
28
+ visitCallExpression: function (n) {
29
+ const callee = n.node.callee as recast.types.namedTypes.Identifier;
30
+ if (callee.name !== "defineConfig") {
31
+ return this.traverse(n);
32
+ }
33
+
34
+ const b = recast.types.builders;
35
+ n.node.arguments = [
36
+ b.objectExpression([
37
+ b.objectProperty(
38
+ b.identifier("server"),
39
+ b.objectExpression([
40
+ b.objectProperty(
41
+ b.identifier("preset"),
42
+ b.stringLiteral("cloudflare-pages")
43
+ ),
44
+ b.objectProperty(
45
+ b.identifier("rollupConfig"),
46
+ b.objectExpression([
47
+ b.objectProperty(
48
+ b.identifier("external"),
49
+ b.arrayExpression([b.stringLiteral("node:async_hooks")])
50
+ ),
51
+ ])
52
+ ),
53
+ ])
54
+ ),
55
+ ]),
56
+ ];
57
+
58
+ return false;
59
+ },
60
+ });
61
+ };
62
+
17
63
  const config: TemplateConfig = {
18
64
  configVersion: 1,
19
65
  id: "solid",
20
66
  displayName: "Solid",
21
67
  platform: "pages",
22
- copyFiles: {
23
- variants: {
24
- js: { path: "./js" },
25
- ts: { path: "./ts" },
26
- },
27
- },
28
68
  generate,
69
+ configure,
29
70
  transformPackageJson: async () => ({
30
71
  scripts: {
31
- "pages:preview": `${npm} run build && npx wrangler pages dev dist ${await compatDateFlag()} --compatibility-flag nodejs_compat`,
32
- "pages:deploy": `${npm} run build && wrangler pages deploy ./dist`,
72
+ preview: `${npm} run build && npx wrangler pages dev dist ${await compatDateFlag()} --compatibility-flag nodejs_compat`,
73
+ deploy: `${npm} run build && wrangler pages deploy ./dist`,
33
74
  },
34
75
  }),
35
76
  devScript: "dev",
36
- previewScript: "pages:preview",
77
+ deployScript: "deploy",
78
+ previewScript: "preview",
37
79
  compatibilityFlags: ["nodejs_compat"],
38
80
  };
39
81
  export default config;
@@ -1,12 +0,0 @@
1
- import { defineConfig } from "@solidjs/start/config";
2
-
3
- export default defineConfig({
4
- start: {
5
- server: {
6
- preset: "cloudflare-pages",
7
- rollupConfig: {
8
- external: ["node:async_hooks"]
9
- },
10
- }
11
- }
12
- });
@@ -1,12 +0,0 @@
1
- import { defineConfig } from "@solidjs/start/config";
2
-
3
- export default defineConfig({
4
- start: {
5
- server: {
6
- preset: "cloudflare-pages",
7
- rollupConfig: {
8
- external: ["node:async_hooks"]
9
- },
10
- }
11
- }
12
- });