@betterstart/cli 0.1.19 → 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
|
|
|
@@ -11446,39 +11450,6 @@ export default db
|
|
|
11446
11450
|
`;
|
|
11447
11451
|
}
|
|
11448
11452
|
|
|
11449
|
-
// src/init/templates/db/drizzle-config.ts
|
|
11450
|
-
function drizzleConfigTemplate() {
|
|
11451
|
-
return `import { readFileSync } from 'node:fs'
|
|
11452
|
-
import { resolve } from 'node:path'
|
|
11453
|
-
import { defineConfig } from 'drizzle-kit'
|
|
11454
|
-
|
|
11455
|
-
// Load .env.local (avoids @next/env dependency for drizzle-kit)
|
|
11456
|
-
for (const envFile of ['.env.local', '.env']) {
|
|
11457
|
-
try {
|
|
11458
|
-
const content = readFileSync(resolve(process.cwd(), envFile), 'utf-8')
|
|
11459
|
-
for (const line of content.split('\\n')) {
|
|
11460
|
-
const trimmed = line.trim()
|
|
11461
|
-
if (!trimmed || trimmed.startsWith('#')) continue
|
|
11462
|
-
const eqIdx = trimmed.indexOf('=')
|
|
11463
|
-
if (eqIdx === -1) continue
|
|
11464
|
-
const key = trimmed.slice(0, eqIdx).trim()
|
|
11465
|
-
const val = trimmed.slice(eqIdx + 1).trim().replace(/^['"]|['"]$/g, '')
|
|
11466
|
-
if (!process.env[key]) process.env[key] = val
|
|
11467
|
-
}
|
|
11468
|
-
} catch {}
|
|
11469
|
-
}
|
|
11470
|
-
|
|
11471
|
-
export default defineConfig({
|
|
11472
|
-
out: './cms/db/migrations',
|
|
11473
|
-
schema: './cms/db/schema.ts',
|
|
11474
|
-
dialect: 'postgresql',
|
|
11475
|
-
dbCredentials: {
|
|
11476
|
-
url: process.env.BETTERSTART_DATABASE_URL!,
|
|
11477
|
-
},
|
|
11478
|
-
})
|
|
11479
|
-
`;
|
|
11480
|
-
}
|
|
11481
|
-
|
|
11482
11453
|
// src/init/templates/db/schema.ts
|
|
11483
11454
|
function dbSchemaTemplate() {
|
|
11484
11455
|
return `import { sql } from 'drizzle-orm'
|
|
@@ -13797,6 +13768,20 @@ var initCommand = new Command3("init").description("Scaffold CMS into a new or e
|
|
|
13797
13768
|
s.start("Setting up database...");
|
|
13798
13769
|
const dbFiles = scaffoldDatabase({ cwd, config });
|
|
13799
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
|
+
}
|
|
13800
13785
|
s.start("Setting up authentication...");
|
|
13801
13786
|
const authFiles = scaffoldAuth({ cwd, config });
|
|
13802
13787
|
s.stop(`Created ${authFiles.length} auth files`);
|