create-kide-app 0.0.13 → 0.0.14
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 +2 -26
- package/package.json +1 -1
- package/templates/base/package.json +1 -2
- package/templates/local/db.ts +14 -18
- package/templates/local/drizzle.config.ts +2 -1
package/index.js
CHANGED
|
@@ -94,9 +94,6 @@ async function main() {
|
|
|
94
94
|
cpSync(path.join(targetDir, "db.ts"), path.join(projectDir, "src/cms/adapters/db.ts"));
|
|
95
95
|
cpSync(path.join(targetDir, "drizzle.config.ts"), path.join(projectDir, "drizzle.config.ts"));
|
|
96
96
|
|
|
97
|
-
// Write .npmrc to allow native module build scripts (pnpm 10+ blocks them by default)
|
|
98
|
-
writeFileSync(path.join(projectDir, ".npmrc"), "ignore-scripts=false\n");
|
|
99
|
-
|
|
100
97
|
if (target === "cloudflare") {
|
|
101
98
|
cpSync(path.join(targetDir, "storage.ts"), path.join(projectDir, "src/cms/adapters/storage.ts"));
|
|
102
99
|
const uploadsRouteDir = path.join(projectDir, "src/pages/uploads");
|
|
@@ -116,13 +113,8 @@ async function main() {
|
|
|
116
113
|
if (target === "cloudflare") {
|
|
117
114
|
delete pkg.dependencies["@astrojs/node"];
|
|
118
115
|
pkg.dependencies["@astrojs/cloudflare"] = "^13.0.0";
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
if (pkg.dependencies["better-sqlite3"]) {
|
|
122
|
-
if (!pkg.devDependencies) pkg.devDependencies = {};
|
|
123
|
-
pkg.devDependencies["better-sqlite3"] = pkg.dependencies["better-sqlite3"];
|
|
124
|
-
delete pkg.dependencies["better-sqlite3"];
|
|
125
|
-
}
|
|
116
|
+
// libsql is for local target only; Cloudflare uses D1 directly
|
|
117
|
+
delete pkg.dependencies["@libsql/client"];
|
|
126
118
|
delete pkg.dependencies["sharp"];
|
|
127
119
|
|
|
128
120
|
let wranglerContent = readFileSync(path.join(targetDir, "wrangler.toml"), "utf-8");
|
|
@@ -153,22 +145,6 @@ async function main() {
|
|
|
153
145
|
s.start("Installing dependencies");
|
|
154
146
|
try {
|
|
155
147
|
execSync(pm.install, { cwd: projectDir, stdio: "pipe" });
|
|
156
|
-
// Ensure better-sqlite3 native bindings are built (pnpm 10+ may block install scripts)
|
|
157
|
-
if (target === "local") {
|
|
158
|
-
try {
|
|
159
|
-
execSync("pnpm rebuild better-sqlite3", { cwd: projectDir, stdio: "pipe" });
|
|
160
|
-
} catch {
|
|
161
|
-
// Fallback: directly run prebuild-install in the package directory
|
|
162
|
-
try {
|
|
163
|
-
const sqliteDir = execSync("find node_modules/.pnpm -type d -name better-sqlite3 -path '*/node_modules/better-sqlite3' | head -1", {
|
|
164
|
-
cwd: projectDir,
|
|
165
|
-
}).toString().trim();
|
|
166
|
-
if (sqliteDir) {
|
|
167
|
-
execSync("npx prebuild-install || node-gyp rebuild", { cwd: path.join(projectDir, sqliteDir), stdio: "pipe" });
|
|
168
|
-
}
|
|
169
|
-
} catch {}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
148
|
s.stop("Dependencies installed");
|
|
173
149
|
} catch {
|
|
174
150
|
s.stop(`${pm.install} failed — run it manually`);
|
package/package.json
CHANGED
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"@kidecms/core": "latest",
|
|
19
19
|
"@astrojs/node": "^10.0.1",
|
|
20
20
|
"@astrojs/react": "^5.0.0",
|
|
21
|
+
"@libsql/client": "^0.15.0",
|
|
21
22
|
"@tailwindcss/typography": "^0.5.19",
|
|
22
23
|
"@tailwindcss/vite": "^4.2.1",
|
|
23
24
|
"astro": "^6.0.4",
|
|
24
|
-
"better-sqlite3": "^12.6.2",
|
|
25
25
|
"drizzle-orm": "^0.45.1",
|
|
26
26
|
"react": "^19.2.4",
|
|
27
27
|
"react-dom": "^19.2.4",
|
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@astrojs/check": "^0.9.7",
|
|
32
|
-
"@types/better-sqlite3": "^7.6.13",
|
|
33
32
|
"@types/react": "^19.2.14",
|
|
34
33
|
"@types/react-dom": "^19.2.3",
|
|
35
34
|
"drizzle-kit": "^0.31.9",
|
package/templates/local/db.ts
CHANGED
|
@@ -1,36 +1,32 @@
|
|
|
1
1
|
import { mkdirSync } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import
|
|
4
|
-
import { drizzle } from "drizzle-orm/
|
|
5
|
-
import { migrate } from "drizzle-orm/
|
|
3
|
+
import { createClient, type Client } from "@libsql/client";
|
|
4
|
+
import { drizzle } from "drizzle-orm/libsql";
|
|
5
|
+
import { migrate } from "drizzle-orm/libsql/migrator";
|
|
6
6
|
|
|
7
7
|
let dbInstance: ReturnType<typeof drizzle> | null = null;
|
|
8
|
-
let
|
|
8
|
+
let clientInstance: Client | null = null;
|
|
9
9
|
let migrated = false;
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const getDbUrl = () => {
|
|
12
12
|
const url = process.env.CMS_DATABASE_URL;
|
|
13
13
|
if (url) return url;
|
|
14
|
-
|
|
14
|
+
const dbPath = path.join(process.cwd(), "data", "cms.db");
|
|
15
|
+
mkdirSync(path.dirname(dbPath), { recursive: true });
|
|
16
|
+
return `file:${dbPath}`;
|
|
15
17
|
};
|
|
16
18
|
|
|
17
19
|
export const getDb = async () => {
|
|
18
20
|
if (dbInstance) return dbInstance;
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
sqliteInstance = new Database(dbPath);
|
|
24
|
-
sqliteInstance.pragma("journal_mode = WAL");
|
|
25
|
-
sqliteInstance.pragma("foreign_keys = ON");
|
|
26
|
-
|
|
27
|
-
dbInstance = drizzle(sqliteInstance);
|
|
22
|
+
clientInstance = createClient({ url: getDbUrl() });
|
|
23
|
+
dbInstance = drizzle(clientInstance);
|
|
28
24
|
|
|
29
25
|
// Auto-run pending migrations on first connection (production only — dev uses drizzle-kit push)
|
|
30
26
|
if (!migrated) {
|
|
31
27
|
const migrationsFolder = path.join(process.cwd(), "src/cms/migrations");
|
|
32
28
|
try {
|
|
33
|
-
migrate(dbInstance, { migrationsFolder });
|
|
29
|
+
await migrate(dbInstance, { migrationsFolder });
|
|
34
30
|
} catch {
|
|
35
31
|
// Ignore migration errors — tables may already exist via drizzle-kit push in dev
|
|
36
32
|
}
|
|
@@ -41,9 +37,9 @@ export const getDb = async () => {
|
|
|
41
37
|
};
|
|
42
38
|
|
|
43
39
|
export const closeDb = () => {
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
-
|
|
40
|
+
if (clientInstance) {
|
|
41
|
+
clientInstance.close();
|
|
42
|
+
clientInstance = null;
|
|
47
43
|
dbInstance = null;
|
|
48
44
|
migrated = false;
|
|
49
45
|
}
|
|
@@ -4,7 +4,8 @@ export default defineConfig({
|
|
|
4
4
|
schema: "./src/cms/.generated/schema.ts",
|
|
5
5
|
out: "./src/cms/migrations",
|
|
6
6
|
dialect: "sqlite",
|
|
7
|
+
driver: "libsql",
|
|
7
8
|
dbCredentials: {
|
|
8
|
-
url: process.env.CMS_DATABASE_URL ?? "
|
|
9
|
+
url: process.env.CMS_DATABASE_URL ?? "file:./data/cms.db",
|
|
9
10
|
},
|
|
10
11
|
});
|