create-kide-app 0.0.2 → 0.0.4

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/index.js CHANGED
@@ -57,15 +57,19 @@ async function main() {
57
57
  process.exit(0);
58
58
  }
59
59
 
60
- // 3. Demo content
61
- const seedDemo = await p.confirm({
62
- message: "Seed database with demo content?",
63
- initialValue: false,
64
- });
65
-
66
- if (p.isCancel(seedDemo)) {
67
- p.cancel("Setup cancelled.");
68
- process.exit(0);
60
+ // 3. Demo content (local only — Cloudflare uses remote D1)
61
+ let seedDemo = false;
62
+ if (target === "local") {
63
+ const seed = await p.confirm({
64
+ message: "Seed database with demo content?",
65
+ initialValue: false,
66
+ });
67
+
68
+ if (p.isCancel(seed)) {
69
+ p.cancel("Setup cancelled.");
70
+ process.exit(0);
71
+ }
72
+ seedDemo = seed;
69
73
  }
70
74
 
71
75
  const s = p.spinner();
@@ -121,9 +125,10 @@ async function main() {
121
125
 
122
126
  if (target === "cloudflare") {
123
127
  delete pkg.dependencies["@astrojs/node"];
124
- pkg.dependencies["@astrojs/cloudflare"] = "^12.0.0";
128
+ pkg.dependencies["@astrojs/cloudflare"] = "^13.0.0";
125
129
 
126
130
  delete pkg.dependencies["better-sqlite3"];
131
+ delete pkg.dependencies["sharp"];
127
132
  if (pkg.devDependencies) delete pkg.devDependencies["@types/better-sqlite3"];
128
133
  if (pkg.pnpm?.onlyBuiltDependencies) {
129
134
  pkg.pnpm.onlyBuiltDependencies = pkg.pnpm.onlyBuiltDependencies.filter((d) => d !== "better-sqlite3");
@@ -139,8 +144,8 @@ async function main() {
139
144
 
140
145
  pkg.scripts.dev = "astro dev";
141
146
  pkg.scripts.build = "astro build";
142
- pkg.scripts.preview = "wrangler pages dev ./dist";
143
- pkg.scripts.deploy = "astro build && wrangler pages deploy ./dist";
147
+ pkg.scripts.preview = "astro build && wrangler dev --config dist/server/wrangler.json";
148
+ pkg.scripts.deploy = "astro build && wrangler deploy --config dist/server/wrangler.json";
144
149
  }
145
150
 
146
151
  writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`);
@@ -218,16 +223,21 @@ async function main() {
218
223
  } else {
219
224
  p.note(
220
225
  [
226
+ `cd ${projectName}`,
227
+ "",
221
228
  "Set up Cloudflare resources:",
222
229
  ` ${pm.exec} wrangler d1 create ${projectName}-db`,
230
+ " # Copy the database_id to wrangler.toml",
223
231
  ` ${pm.exec} wrangler r2 bucket create ${projectName}-assets`,
224
- " # Add the database_id to wrangler.toml",
232
+ "",
233
+ "Push database schema:",
234
+ ` ${pm.exec} wrangler d1 execute ${projectName}-db --remote --file=src/cms/migrations/0000_init.sql`,
225
235
  "",
226
236
  "Local development:",
227
- ` cd ${projectName} && ${pm.run} dev`,
237
+ ` ${pm.run} dev`,
228
238
  "",
229
239
  "Deploy:",
230
- ` ${pm.run} deploy`,
240
+ " pnpm run deploy",
231
241
  ].join("\n"),
232
242
  "Next steps",
233
243
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-kide-app",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "Scaffold a new Kide CMS project",
5
5
  "author": "Matti Hernesniemi",
6
6
  "license": "MIT",
@@ -9,16 +9,8 @@ import cmsIntegration from "./src/cms/integration";
9
9
  export default defineConfig({
10
10
  output: "server",
11
11
  integrations: [react(), cmsIntegration()],
12
- adapter: cloudflare({
13
- platformProxy: {
14
- enabled: true,
15
- },
16
- }),
12
+ adapter: cloudflare(),
17
13
  vite: {
18
14
  plugins: [tailwindcss()],
19
- resolve: {
20
- // Ensure Cloudflare-compatible modules are used
21
- conditions: ["workerd", "worker", "browser"],
22
- },
23
15
  },
24
16
  });
@@ -1,20 +1,19 @@
1
+ import { env } from "cloudflare:workers";
1
2
  import { drizzle } from "drizzle-orm/d1";
2
3
 
3
4
  let dbInstance: ReturnType<typeof drizzle> | null = null;
4
5
  let currentDb: D1Database | null = null;
5
6
 
6
7
  export const getDb = async () => {
7
- // Access the D1 binding from the Cloudflare runtime context
8
- // The binding is set in wrangler.toml as "CMS_DB"
9
- const env = (globalThis as any).__env__;
10
- if (!env?.CMS_DB) {
8
+ const db = (env as any).CMS_DB as D1Database | undefined;
9
+ if (!db) {
11
10
  throw new Error("D1 database binding CMS_DB not found. Check wrangler.toml.");
12
11
  }
13
12
 
14
- if (dbInstance && currentDb === env.CMS_DB) return dbInstance;
13
+ if (dbInstance && currentDb === db) return dbInstance;
15
14
 
16
- currentDb = env.CMS_DB;
17
- dbInstance = drizzle(env.CMS_DB);
15
+ currentDb = db;
16
+ dbInstance = drizzle(db);
18
17
  return dbInstance;
19
18
  };
20
19