create-kide-app 0.0.3 → 0.0.5
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 +20 -17
- package/package.json +1 -1
- package/templates/cloudflare/drizzle.config.ts +9 -2
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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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();
|
|
@@ -123,14 +127,13 @@ async function main() {
|
|
|
123
127
|
delete pkg.dependencies["@astrojs/node"];
|
|
124
128
|
pkg.dependencies["@astrojs/cloudflare"] = "^13.0.0";
|
|
125
129
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
if (pkg.pnpm.onlyBuiltDependencies.length === 0) delete pkg.pnpm.onlyBuiltDependencies;
|
|
132
|
-
if (Object.keys(pkg.pnpm).length === 0) delete pkg.pnpm;
|
|
130
|
+
// Move better-sqlite3 to devDependencies — drizzle-kit needs it to push schema to local D1
|
|
131
|
+
if (pkg.dependencies["better-sqlite3"]) {
|
|
132
|
+
if (!pkg.devDependencies) pkg.devDependencies = {};
|
|
133
|
+
pkg.devDependencies["better-sqlite3"] = pkg.dependencies["better-sqlite3"];
|
|
134
|
+
delete pkg.dependencies["better-sqlite3"];
|
|
133
135
|
}
|
|
136
|
+
delete pkg.dependencies["sharp"];
|
|
134
137
|
|
|
135
138
|
let wranglerContent = readFileSync(path.join(targetDir, "wrangler.toml"), "utf-8");
|
|
136
139
|
wranglerContent = wranglerContent.replaceAll("{{PROJECT_NAME}}", projectName);
|
|
@@ -223,8 +226,8 @@ async function main() {
|
|
|
223
226
|
"",
|
|
224
227
|
"Set up Cloudflare resources:",
|
|
225
228
|
` ${pm.exec} wrangler d1 create ${projectName}-db`,
|
|
229
|
+
" # Copy the database_id to wrangler.toml",
|
|
226
230
|
` ${pm.exec} wrangler r2 bucket create ${projectName}-assets`,
|
|
227
|
-
" # Add the database_id to wrangler.toml",
|
|
228
231
|
"",
|
|
229
232
|
"Push database schema:",
|
|
230
233
|
` ${pm.exec} wrangler d1 execute ${projectName}-db --remote --file=src/cms/migrations/0000_init.sql`,
|
package/package.json
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
|
+
import { readdirSync } from "node:fs";
|
|
1
2
|
import { defineConfig } from "drizzle-kit";
|
|
2
3
|
|
|
4
|
+
function getLocalD1Path() {
|
|
5
|
+
const dir = ".wrangler/state/v3/d1/miniflare-D1DatabaseObject";
|
|
6
|
+
const file = readdirSync(dir).find((f) => f.endsWith(".sqlite") && f !== "*.sqlite");
|
|
7
|
+
if (!file) throw new Error(`No D1 sqlite file found in ${dir}`);
|
|
8
|
+
return `${dir}/${file}`;
|
|
9
|
+
}
|
|
10
|
+
|
|
3
11
|
export default defineConfig({
|
|
4
12
|
schema: "./src/cms/.generated/schema.ts",
|
|
5
13
|
out: "./src/cms/migrations",
|
|
6
14
|
dialect: "sqlite",
|
|
7
15
|
dbCredentials: {
|
|
8
|
-
|
|
9
|
-
url: ".wrangler/state/v3/d1/miniflare-D1DatabaseObject/*.sqlite",
|
|
16
|
+
url: getLocalD1Path(),
|
|
10
17
|
},
|
|
11
18
|
});
|