@betterstart/cli 0.1.19 → 0.1.21

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,6 +1,10 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ drizzleConfigTemplate
4
+ } from "./chunk-SAPJG4NO.js";
5
+
2
6
  // src/cli.ts
3
- import { Command as Command5 } from "commander";
7
+ import { Command as Command6 } from "commander";
4
8
 
5
9
  // src/commands/generate.ts
6
10
  import path22 from "path";
@@ -2754,11 +2758,11 @@ function generateActions(schema, cwd, actionsDir, options = {}) {
2754
2758
  const listFieldsWithRels = findListFieldsWithRelationships(dbFields);
2755
2759
  const hasListRels = listFieldsWithRels.length > 0;
2756
2760
  const allListRelQueries = [];
2757
- for (const { field: listField, path: path39 } of listFieldsWithRels) {
2761
+ for (const { field: listField, path: path40 } of listFieldsWithRels) {
2758
2762
  const rels = (listField.fields || []).filter((f) => f.type === "relationship" && f.relationship);
2759
2763
  for (const relField of rels) {
2760
2764
  allListRelQueries.push({
2761
- fieldPath: path39.join("_"),
2765
+ fieldPath: path40.join("_"),
2762
2766
  relField,
2763
2767
  relTable: toCamelCase3(relField.relationship),
2764
2768
  listFieldName: listField.name
@@ -8700,37 +8704,37 @@ function cmsGlobalsCssTemplate() {
8700
8704
  @custom-variant dark (&:is(.dark *));
8701
8705
 
8702
8706
  :root {
8703
- --background: oklch(0.9850 0 0);
8707
+ --background: oklch(0.985 0 0);
8704
8708
  --foreground: oklch(0 0 0);
8705
8709
  --card: oklch(1 0 0);
8706
8710
  --card-foreground: oklch(0 0 0);
8707
- --popover: oklch(0.9900 0 0);
8711
+ --popover: oklch(0.99 0 0);
8708
8712
  --popover-foreground: oklch(0 0 0);
8709
8713
  --primary: oklch(0 0 0);
8710
8714
  --primary-foreground: oklch(1 0 0);
8711
- --secondary: oklch(0.9700 0 0);
8715
+ --secondary: oklch(0.97 0 0);
8712
8716
  --secondary-foreground: oklch(0 0 0);
8713
- --muted: oklch(0.9700 0 0);
8714
- --muted-foreground: oklch(0.4400 0 0);
8715
- --accent: oklch(0.9700 0 0);
8717
+ --muted: oklch(0.97 0 0);
8718
+ --muted-foreground: oklch(0.44 0 0);
8719
+ --accent: oklch(0.97 0 0);
8716
8720
  --accent-foreground: oklch(0 0 0);
8717
- --destructive: oklch(0.6300 0.1900 23.0300);
8721
+ --destructive: oklch(0.63 0.19 23.03);
8718
8722
  --destructive-foreground: oklch(1 0 0);
8719
- --border: oklch(0.9200 0 0);
8720
- --input: oklch(0.9400 0 0);
8723
+ --border: oklch(0.92 0 0);
8724
+ --input: oklch(0.99 0 0);
8721
8725
  --ring: oklch(0 0 0);
8722
- --chart-1: oklch(0.8100 0.1700 75.3500);
8723
- --chart-2: oklch(0.5500 0.2200 264.5300);
8724
- --chart-3: oklch(0.7200 0 0);
8725
- --chart-4: oklch(0.9200 0 0);
8726
- --chart-5: oklch(0.5600 0 0);
8726
+ --chart-1: oklch(0.81 0.17 75.35);
8727
+ --chart-2: oklch(0.55 0.22 264.53);
8728
+ --chart-3: oklch(0.72 0 0);
8729
+ --chart-4: oklch(0.92 0 0);
8730
+ --chart-5: oklch(0.56 0 0);
8727
8731
  --sidebar: oklch(1 0 0);
8728
8732
  --sidebar-foreground: oklch(0 0 0);
8729
8733
  --sidebar-primary: oklch(0 0 0);
8730
8734
  --sidebar-primary-foreground: oklch(1 0 0);
8731
- --sidebar-accent: oklch(0.9400 0 0);
8735
+ --sidebar-accent: oklch(0.94 0 0);
8732
8736
  --sidebar-accent-foreground: oklch(0 0 0);
8733
- --sidebar-border: oklch(0.9400 0 0);
8737
+ --sidebar-border: oklch(0.94 0 0);
8734
8738
  --sidebar-ring: oklch(0 0 0);
8735
8739
  --font-sans: Geist, sans-serif;
8736
8740
  --font-serif: Georgia, serif;
@@ -8744,11 +8748,16 @@ function cmsGlobalsCssTemplate() {
8744
8748
  --shadow-color: hsl(0 0% 0%);
8745
8749
  --shadow-2xs: 0px 1px 3px 0px hsl(0 0% 0% / 0.01);
8746
8750
  --shadow-xs: 0px 1px 3px 0px hsl(0 0% 0% / 0.01);
8747
- --shadow-sm: 0px 1px 3px 0px hsl(0 0% 0% / 0.02), 0px 1px 2px -1px hsl(0 0% 0% / 0.02);
8748
- --shadow: 0px 1px 3px 0px hsl(0 0% 0% / 0.02), 0px 1px 2px -1px hsl(0 0% 0% / 0.02);
8749
- --shadow-md: 0px 1px 3px 0px hsl(0 0% 0% / 0.02), 0px 2px 4px -1px hsl(0 0% 0% / 0.02);
8750
- --shadow-lg: 0px 1px 3px 0px hsl(0 0% 0% / 0.02), 0px 4px 6px -1px hsl(0 0% 0% / 0.02);
8751
- --shadow-xl: 0px 1px 3px 0px hsl(0 0% 0% / 0.02), 0px 8px 10px -1px hsl(0 0% 0% / 0.02);
8751
+ --shadow-sm:
8752
+ 0px 1px 3px 0px hsl(0 0% 0% / 0.02), 0px 1px 2px -1px hsl(0 0% 0% / 0.02);
8753
+ --shadow:
8754
+ 0px 1px 3px 0px hsl(0 0% 0% / 0.02), 0px 1px 2px -1px hsl(0 0% 0% / 0.02);
8755
+ --shadow-md:
8756
+ 0px 1px 3px 0px hsl(0 0% 0% / 0.02), 0px 2px 4px -1px hsl(0 0% 0% / 0.02);
8757
+ --shadow-lg:
8758
+ 0px 1px 3px 0px hsl(0 0% 0% / 0.02), 0px 4px 6px -1px hsl(0 0% 0% / 0.02);
8759
+ --shadow-xl:
8760
+ 0px 1px 3px 0px hsl(0 0% 0% / 0.02), 0px 8px 10px -1px hsl(0 0% 0% / 0.02);
8752
8761
  --shadow-2xl: 0px 1px 3px 0px hsl(0 0% 0% / 0.05);
8753
8762
  --tracking-normal: 0em;
8754
8763
  --spacing: 0.25rem;
@@ -8757,36 +8766,36 @@ function cmsGlobalsCssTemplate() {
8757
8766
  .dark {
8758
8767
  --background: oklch(0 0 0);
8759
8768
  --foreground: oklch(1 0 0);
8760
- --card: oklch(0.1400 0 0);
8769
+ --card: oklch(0.14 0 0);
8761
8770
  --card-foreground: oklch(1 0 0);
8762
- --popover: oklch(0.1800 0 0);
8771
+ --popover: oklch(0.18 0 0);
8763
8772
  --popover-foreground: oklch(1 0 0);
8764
8773
  --primary: oklch(1 0 0);
8765
8774
  --primary-foreground: oklch(0 0 0);
8766
- --secondary: oklch(0.2500 0 0);
8775
+ --secondary: oklch(0.25 0 0);
8767
8776
  --secondary-foreground: oklch(1 0 0);
8768
- --muted: oklch(0.2300 0 0);
8769
- --muted-foreground: oklch(0.7200 0 0);
8770
- --accent: oklch(0.3200 0 0);
8777
+ --muted: oklch(0.23 0 0);
8778
+ --muted-foreground: oklch(0.72 0 0);
8779
+ --accent: oklch(0.32 0 0);
8771
8780
  --accent-foreground: oklch(1 0 0);
8772
- --destructive: oklch(0.6900 0.2000 23.9100);
8781
+ --destructive: oklch(0.69 0.2 23.91);
8773
8782
  --destructive-foreground: oklch(0 0 0);
8774
- --border: oklch(0.2600 0 0);
8775
- --input: oklch(0.3200 0 0);
8776
- --ring: oklch(0.7200 0 0);
8777
- --chart-1: oklch(0.8100 0.1700 75.3500);
8778
- --chart-2: oklch(0.5800 0.2100 260.8400);
8779
- --chart-3: oklch(0.5600 0 0);
8780
- --chart-4: oklch(0.4400 0 0);
8781
- --chart-5: oklch(0.9200 0 0);
8782
- --sidebar: oklch(0.1800 0 0);
8783
+ --border: oklch(0.26 0 0);
8784
+ --input: oklch(0.32 0 0);
8785
+ --ring: oklch(0.72 0 0);
8786
+ --chart-1: oklch(0.81 0.17 75.35);
8787
+ --chart-2: oklch(0.58 0.21 260.84);
8788
+ --chart-3: oklch(0.56 0 0);
8789
+ --chart-4: oklch(0.44 0 0);
8790
+ --chart-5: oklch(0.92 0 0);
8791
+ --sidebar: oklch(0.18 0 0);
8783
8792
  --sidebar-foreground: oklch(1 0 0);
8784
8793
  --sidebar-primary: oklch(1 0 0);
8785
8794
  --sidebar-primary-foreground: oklch(0 0 0);
8786
- --sidebar-accent: oklch(0.3200 0 0);
8795
+ --sidebar-accent: oklch(0.32 0 0);
8787
8796
  --sidebar-accent-foreground: oklch(1 0 0);
8788
- --sidebar-border: oklch(0.3200 0 0);
8789
- --sidebar-ring: oklch(0.7200 0 0);
8797
+ --sidebar-border: oklch(0.32 0 0);
8798
+ --sidebar-ring: oklch(0.72 0 0);
8790
8799
  --font-sans: Geist, sans-serif;
8791
8800
  --font-serif: Georgia, serif;
8792
8801
  --font-mono: Geist Mono, monospace;
@@ -8799,11 +8808,16 @@ function cmsGlobalsCssTemplate() {
8799
8808
  --shadow-color: hsl(0 0% 0%);
8800
8809
  --shadow-2xs: 0px 1px 3px 0px hsl(0 0% 0% / 0.01);
8801
8810
  --shadow-xs: 0px 1px 3px 0px hsl(0 0% 0% / 0.01);
8802
- --shadow-sm: 0px 1px 3px 0px hsl(0 0% 0% / 0.02), 0px 1px 2px -1px hsl(0 0% 0% / 0.02);
8803
- --shadow: 0px 1px 3px 0px hsl(0 0% 0% / 0.02), 0px 1px 2px -1px hsl(0 0% 0% / 0.02);
8804
- --shadow-md: 0px 1px 3px 0px hsl(0 0% 0% / 0.02), 0px 2px 4px -1px hsl(0 0% 0% / 0.02);
8805
- --shadow-lg: 0px 1px 3px 0px hsl(0 0% 0% / 0.02), 0px 4px 6px -1px hsl(0 0% 0% / 0.02);
8806
- --shadow-xl: 0px 1px 3px 0px hsl(0 0% 0% / 0.02), 0px 8px 10px -1px hsl(0 0% 0% / 0.02);
8811
+ --shadow-sm:
8812
+ 0px 1px 3px 0px hsl(0 0% 0% / 0.02), 0px 1px 2px -1px hsl(0 0% 0% / 0.02);
8813
+ --shadow:
8814
+ 0px 1px 3px 0px hsl(0 0% 0% / 0.02), 0px 1px 2px -1px hsl(0 0% 0% / 0.02);
8815
+ --shadow-md:
8816
+ 0px 1px 3px 0px hsl(0 0% 0% / 0.02), 0px 2px 4px -1px hsl(0 0% 0% / 0.02);
8817
+ --shadow-lg:
8818
+ 0px 1px 3px 0px hsl(0 0% 0% / 0.02), 0px 4px 6px -1px hsl(0 0% 0% / 0.02);
8819
+ --shadow-xl:
8820
+ 0px 1px 3px 0px hsl(0 0% 0% / 0.02), 0px 8px 10px -1px hsl(0 0% 0% / 0.02);
8807
8821
  --shadow-2xl: 0px 1px 3px 0px hsl(0 0% 0% / 0.05);
8808
8822
  }
8809
8823
 
@@ -11446,39 +11460,6 @@ export default db
11446
11460
  `;
11447
11461
  }
11448
11462
 
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
11463
  // src/init/templates/db/schema.ts
11483
11464
  function dbSchemaTemplate() {
11484
11465
  return `import { sql } from 'drizzle-orm'
@@ -13797,6 +13778,20 @@ var initCommand = new Command3("init").description("Scaffold CMS into a new or e
13797
13778
  s.start("Setting up database...");
13798
13779
  const dbFiles = scaffoldDatabase({ cwd, config });
13799
13780
  s.stop(`Created ${dbFiles.length} database files`);
13781
+ const drizzleConfigPath = path37.join(cwd, "drizzle.config.ts");
13782
+ if (!dbFiles.includes("drizzle.config.ts") && fs32.existsSync(drizzleConfigPath)) {
13783
+ if (!options.yes) {
13784
+ const overwrite = await p4.confirm({
13785
+ message: "drizzle.config.ts already exists. Overwrite with latest version?",
13786
+ initialValue: true
13787
+ });
13788
+ if (!p4.isCancel(overwrite) && overwrite) {
13789
+ const { drizzleConfigTemplate: drizzleConfigTemplate2 } = await import("./drizzle-config-KISB26BA.js");
13790
+ fs32.writeFileSync(drizzleConfigPath, drizzleConfigTemplate2(), "utf-8");
13791
+ p4.log.success("Updated drizzle.config.ts");
13792
+ }
13793
+ }
13794
+ }
13800
13795
  s.start("Setting up authentication...");
13801
13796
  const authFiles = scaffoldAuth({ cwd, config });
13802
13797
  s.stop(`Created ${authFiles.length} auth files`);
@@ -14305,12 +14300,33 @@ var removeCommand = new Command4("remove").alias("rm").description("Remove all g
14305
14300
  console.log("");
14306
14301
  });
14307
14302
 
14303
+ // src/commands/update-styles.ts
14304
+ import fs34 from "fs";
14305
+ import path39 from "path";
14306
+ import * as clack2 from "@clack/prompts";
14307
+ import { Command as Command5 } from "commander";
14308
+ var updateStylesCommand = new Command5("update-styles").description("Replace cms-globals.css with the latest version from the CLI").option("--cwd <path>", "Project root path").action(async (options) => {
14309
+ const cwd = options.cwd ? path39.resolve(options.cwd) : process.cwd();
14310
+ clack2.intro("BetterStart Update Styles");
14311
+ const config = await resolveConfig(cwd);
14312
+ const cmsDir = config.paths?.cms ?? "./cms";
14313
+ const targetPath = path39.join(cwd, cmsDir, "components", "cms-globals.css");
14314
+ if (!fs34.existsSync(targetPath)) {
14315
+ clack2.cancel(`cms-globals.css not found at ${path39.relative(cwd, targetPath)}`);
14316
+ process.exit(1);
14317
+ }
14318
+ fs34.writeFileSync(targetPath, cmsGlobalsCssTemplate(), "utf-8");
14319
+ clack2.log.success(`Updated ${path39.relative(cwd, targetPath)}`);
14320
+ clack2.outro("Styles updated");
14321
+ });
14322
+
14308
14323
  // src/cli.ts
14309
- var program = new Command5();
14324
+ var program = new Command6();
14310
14325
  program.name("betterstart").description("Scaffold a full-featured CMS into any Next.js 16 application").version("0.1.0");
14311
14326
  program.addCommand(initCommand);
14312
14327
  program.addCommand(generateCommand);
14313
14328
  program.addCommand(removeCommand);
14314
14329
  program.addCommand(seedCommand);
14330
+ program.addCommand(updateStylesCommand);
14315
14331
  program.parse();
14316
14332
  //# sourceMappingURL=cli.js.map