@betterstart/cli 0.1.18 → 0.1.20
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.
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// src/init/templates/db/drizzle-config.ts
|
|
2
|
+
function drizzleConfigTemplate() {
|
|
3
|
+
return `import { readFileSync } from 'node:fs'
|
|
4
|
+
import { resolve } from 'node:path'
|
|
5
|
+
import { defineConfig } from 'drizzle-kit'
|
|
6
|
+
|
|
7
|
+
// Load .env.local (avoids @next/env dependency for drizzle-kit)
|
|
8
|
+
for (const envFile of ['.env.local', '.env']) {
|
|
9
|
+
try {
|
|
10
|
+
const content = readFileSync(resolve(process.cwd(), envFile), 'utf-8')
|
|
11
|
+
for (const line of content.split('\\n')) {
|
|
12
|
+
const trimmed = line.trim()
|
|
13
|
+
if (!trimmed || trimmed.startsWith('#')) continue
|
|
14
|
+
const eqIdx = trimmed.indexOf('=')
|
|
15
|
+
if (eqIdx === -1) continue
|
|
16
|
+
const key = trimmed.slice(0, eqIdx).trim()
|
|
17
|
+
const val = trimmed.slice(eqIdx + 1).trim().replace(/^['"]|['"]$/g, '')
|
|
18
|
+
if (!process.env[key]) process.env[key] = val
|
|
19
|
+
}
|
|
20
|
+
} catch {}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default defineConfig({
|
|
24
|
+
out: './cms/db/migrations',
|
|
25
|
+
schema: './cms/db/schema.ts',
|
|
26
|
+
dialect: 'postgresql',
|
|
27
|
+
dbCredentials: {
|
|
28
|
+
url: process.env.BETTERSTART_DATABASE_URL!,
|
|
29
|
+
},
|
|
30
|
+
})
|
|
31
|
+
`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export {
|
|
35
|
+
drizzleConfigTemplate
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=chunk-SAPJG4NO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/init/templates/db/drizzle-config.ts"],"sourcesContent":["/**\n * Template: cms/db/drizzle.config.ts\n * Drizzle Kit configuration for CMS database\n */\nexport function drizzleConfigTemplate(): string {\n return `import { readFileSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport { defineConfig } from 'drizzle-kit'\n\n// Load .env.local (avoids @next/env dependency for drizzle-kit)\nfor (const envFile of ['.env.local', '.env']) {\n try {\n const content = readFileSync(resolve(process.cwd(), envFile), 'utf-8')\n for (const line of content.split('\\\\n')) {\n const trimmed = line.trim()\n if (!trimmed || trimmed.startsWith('#')) continue\n const eqIdx = trimmed.indexOf('=')\n if (eqIdx === -1) continue\n const key = trimmed.slice(0, eqIdx).trim()\n const val = trimmed.slice(eqIdx + 1).trim().replace(/^['\"]|['\"]$/g, '')\n if (!process.env[key]) process.env[key] = val\n }\n } catch {}\n}\n\nexport default defineConfig({\n out: './cms/db/migrations',\n schema: './cms/db/schema.ts',\n dialect: 'postgresql',\n dbCredentials: {\n url: process.env.BETTERSTART_DATABASE_URL!,\n },\n})\n`\n}\n"],"mappings":";AAIO,SAAS,wBAAgC;AAC9C,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6BT;","names":[]}
|
package/dist/cli.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
drizzleConfigTemplate
|
|
4
|
+
} from "./chunk-SAPJG4NO.js";
|
|
5
|
+
|
|
2
6
|
// src/cli.ts
|
|
3
7
|
import { Command as Command5 } from "commander";
|
|
4
8
|
|
|
@@ -7721,8 +7725,9 @@ function runPostGenerate(cwd, schemaName, options = {}) {
|
|
|
7721
7725
|
console.log(ok ? " Database schema synced" : " Database push failed (run db:push manually)");
|
|
7722
7726
|
} else {
|
|
7723
7727
|
console.log("\n Running drizzle-kit push...");
|
|
7728
|
+
const drizzleBin = path21.join(cwd, "node_modules", ".bin", "drizzle-kit");
|
|
7724
7729
|
try {
|
|
7725
|
-
execFileSync2(
|
|
7730
|
+
execFileSync2(drizzleBin, ["push", "--force"], { cwd, stdio: "pipe" });
|
|
7726
7731
|
result.dbPush = "success";
|
|
7727
7732
|
console.log(" Database schema synced");
|
|
7728
7733
|
} catch {
|
|
@@ -7739,8 +7744,9 @@ function runPostGenerate(cwd, schemaName, options = {}) {
|
|
|
7739
7744
|
result.lintFix = ok ? "success" : "failed";
|
|
7740
7745
|
console.log(ok ? " Code formatted" : " Lint fix had issues (run lint:fix manually)");
|
|
7741
7746
|
} else {
|
|
7747
|
+
const biomeBin = path21.join(cwd, "node_modules", ".bin", "biome");
|
|
7742
7748
|
try {
|
|
7743
|
-
execFileSync2(
|
|
7749
|
+
execFileSync2(biomeBin, ["check", "--write", "."], { cwd, stdio: "pipe" });
|
|
7744
7750
|
result.lintFix = "success";
|
|
7745
7751
|
console.log(" Code formatted with Biome");
|
|
7746
7752
|
} catch {
|
|
@@ -11444,24 +11450,6 @@ export default db
|
|
|
11444
11450
|
`;
|
|
11445
11451
|
}
|
|
11446
11452
|
|
|
11447
|
-
// src/init/templates/db/drizzle-config.ts
|
|
11448
|
-
function drizzleConfigTemplate() {
|
|
11449
|
-
return `import { loadEnvConfig } from '@next/env'
|
|
11450
|
-
import { defineConfig } from 'drizzle-kit'
|
|
11451
|
-
|
|
11452
|
-
loadEnvConfig(process.cwd())
|
|
11453
|
-
|
|
11454
|
-
export default defineConfig({
|
|
11455
|
-
out: './cms/db/migrations',
|
|
11456
|
-
schema: './cms/db/schema.ts',
|
|
11457
|
-
dialect: 'postgresql',
|
|
11458
|
-
dbCredentials: {
|
|
11459
|
-
url: process.env.BETTERSTART_DATABASE_URL!,
|
|
11460
|
-
},
|
|
11461
|
-
})
|
|
11462
|
-
`;
|
|
11463
|
-
}
|
|
11464
|
-
|
|
11465
11453
|
// src/init/templates/db/schema.ts
|
|
11466
11454
|
function dbSchemaTemplate() {
|
|
11467
11455
|
return `import { sql } from 'drizzle-orm'
|
|
@@ -13780,6 +13768,20 @@ var initCommand = new Command3("init").description("Scaffold CMS into a new or e
|
|
|
13780
13768
|
s.start("Setting up database...");
|
|
13781
13769
|
const dbFiles = scaffoldDatabase({ cwd, config });
|
|
13782
13770
|
s.stop(`Created ${dbFiles.length} database files`);
|
|
13771
|
+
const drizzleConfigPath = path37.join(cwd, "drizzle.config.ts");
|
|
13772
|
+
if (!dbFiles.includes("drizzle.config.ts") && fs32.existsSync(drizzleConfigPath)) {
|
|
13773
|
+
if (!options.yes) {
|
|
13774
|
+
const overwrite = await p4.confirm({
|
|
13775
|
+
message: "drizzle.config.ts already exists. Overwrite with latest version?",
|
|
13776
|
+
initialValue: true
|
|
13777
|
+
});
|
|
13778
|
+
if (!p4.isCancel(overwrite) && overwrite) {
|
|
13779
|
+
const { drizzleConfigTemplate: drizzleConfigTemplate2 } = await import("./drizzle-config-KISB26BA.js");
|
|
13780
|
+
fs32.writeFileSync(drizzleConfigPath, drizzleConfigTemplate2(), "utf-8");
|
|
13781
|
+
p4.log.success("Updated drizzle.config.ts");
|
|
13782
|
+
}
|
|
13783
|
+
}
|
|
13784
|
+
}
|
|
13783
13785
|
s.start("Setting up authentication...");
|
|
13784
13786
|
const authFiles = scaffoldAuth({ cwd, config });
|
|
13785
13787
|
s.stop(`Created ${authFiles.length} auth files`);
|