create-kide-app 0.0.1 → 0.0.3
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
|
@@ -121,9 +121,10 @@ async function main() {
|
|
|
121
121
|
|
|
122
122
|
if (target === "cloudflare") {
|
|
123
123
|
delete pkg.dependencies["@astrojs/node"];
|
|
124
|
-
pkg.dependencies["@astrojs/cloudflare"] = "^
|
|
124
|
+
pkg.dependencies["@astrojs/cloudflare"] = "^13.0.0";
|
|
125
125
|
|
|
126
126
|
delete pkg.dependencies["better-sqlite3"];
|
|
127
|
+
delete pkg.dependencies["sharp"];
|
|
127
128
|
if (pkg.devDependencies) delete pkg.devDependencies["@types/better-sqlite3"];
|
|
128
129
|
if (pkg.pnpm?.onlyBuiltDependencies) {
|
|
129
130
|
pkg.pnpm.onlyBuiltDependencies = pkg.pnpm.onlyBuiltDependencies.filter((d) => d !== "better-sqlite3");
|
|
@@ -139,8 +140,8 @@ async function main() {
|
|
|
139
140
|
|
|
140
141
|
pkg.scripts.dev = "astro dev";
|
|
141
142
|
pkg.scripts.build = "astro build";
|
|
142
|
-
pkg.scripts.preview = "wrangler
|
|
143
|
-
pkg.scripts.deploy = "astro build && wrangler
|
|
143
|
+
pkg.scripts.preview = "astro build && wrangler dev --config dist/server/wrangler.json";
|
|
144
|
+
pkg.scripts.deploy = "astro build && wrangler deploy --config dist/server/wrangler.json";
|
|
144
145
|
}
|
|
145
146
|
|
|
146
147
|
writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`);
|
|
@@ -182,7 +183,7 @@ async function main() {
|
|
|
182
183
|
execSync(`${pm.exec} drizzle-kit push --force`, { cwd: projectDir, stdio: "pipe" });
|
|
183
184
|
s.stop("Schema pushed");
|
|
184
185
|
} catch {
|
|
185
|
-
s.stop("Schema
|
|
186
|
+
s.stop("Schema will be set up on first dev start");
|
|
186
187
|
}
|
|
187
188
|
s.start("Seeding demo content");
|
|
188
189
|
try {
|
|
@@ -218,16 +219,21 @@ async function main() {
|
|
|
218
219
|
} else {
|
|
219
220
|
p.note(
|
|
220
221
|
[
|
|
222
|
+
`cd ${projectName}`,
|
|
223
|
+
"",
|
|
221
224
|
"Set up Cloudflare resources:",
|
|
222
225
|
` ${pm.exec} wrangler d1 create ${projectName}-db`,
|
|
223
226
|
` ${pm.exec} wrangler r2 bucket create ${projectName}-assets`,
|
|
224
227
|
" # Add the database_id to wrangler.toml",
|
|
225
228
|
"",
|
|
229
|
+
"Push database schema:",
|
|
230
|
+
` ${pm.exec} wrangler d1 execute ${projectName}-db --remote --file=src/cms/migrations/0000_init.sql`,
|
|
231
|
+
"",
|
|
226
232
|
"Local development:",
|
|
227
|
-
`
|
|
233
|
+
` ${pm.run} dev`,
|
|
228
234
|
"",
|
|
229
235
|
"Deploy:",
|
|
230
|
-
|
|
236
|
+
" pnpm run deploy",
|
|
231
237
|
].join("\n"),
|
|
232
238
|
"Next steps",
|
|
233
239
|
);
|
package/package.json
CHANGED
|
@@ -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
|
-
|
|
8
|
-
|
|
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 ===
|
|
13
|
+
if (dbInstance && currentDb === db) return dbInstance;
|
|
15
14
|
|
|
16
|
-
currentDb =
|
|
17
|
-
dbInstance = drizzle(
|
|
15
|
+
currentDb = db;
|
|
16
|
+
dbInstance = drizzle(db);
|
|
18
17
|
return dbInstance;
|
|
19
18
|
};
|
|
20
19
|
|