@betterstart/cli 0.1.65 → 0.1.67

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/dist/cli.js CHANGED
@@ -8694,7 +8694,6 @@ export const { signIn, signUp, signOut, useSession } = authClient
8694
8694
  function authMiddlewareTemplate() {
8695
8695
  return `import { headers } from 'next/headers'
8696
8696
  import { redirect } from 'next/navigation'
8697
- import { connection } from 'next/server'
8698
8697
  import { auth, type User } from './auth'
8699
8698
 
8700
8699
  export enum UserRole {
@@ -8711,7 +8710,6 @@ export function isUserRole(value: unknown): value is UserRole {
8711
8710
  * Get the current session from Better Auth
8712
8711
  */
8713
8712
  export async function getSession() {
8714
- await connection()
8715
8713
  const session = await auth.api.getSession({
8716
8714
  headers: await headers(),
8717
8715
  })
@@ -12399,12 +12397,21 @@ import path40 from "path";
12399
12397
 
12400
12398
  // src/init/templates/pages/authenticated-layout.ts
12401
12399
  function authenticatedLayoutTemplate() {
12402
- return `import { requireRole } from '@cms/auth/middleware'
12400
+ return `import { Suspense } from 'react'
12401
+ import { requireRole } from '@cms/auth/middleware'
12403
12402
  import { CmsSidebar } from '@cms/components/layout/cms-sidebar'
12404
12403
  import { SidebarInset, SidebarProvider } from '@cms/components/ui/sidebar'
12405
12404
  import { UserRole } from '@cms/types/auth'
12406
12405
 
12407
- export default async function CmsAuthLayout({ children }: { children: React.ReactNode }) {
12406
+ export default function CmsAuthLayout({ children }: { children: React.ReactNode }) {
12407
+ return (
12408
+ <Suspense fallback={<div className="flex items-center justify-center h-screen"><div className="text-muted-foreground">Loading...</div></div>}>
12409
+ <AuthenticatedShell>{children}</AuthenticatedShell>
12410
+ </Suspense>
12411
+ )
12412
+ }
12413
+
12414
+ async function AuthenticatedShell({ children }: { children: React.ReactNode }) {
12408
12415
  await requireRole([UserRole.ADMIN, UserRole.EDITOR])
12409
12416
 
12410
12417
  return (
@@ -15635,6 +15642,7 @@ var TEMPLATE_REGISTRY = {
15635
15642
  mailchimp: { relPath: "utils/mailchimp.ts", content: mailchimpUtilTemplate },
15636
15643
  // Auth
15637
15644
  "auth-middleware": { relPath: "lib/auth/middleware.ts", content: authMiddlewareTemplate },
15645
+ "auth-layout": { relPath: "app/(cms)/cms/(authenticated)/layout.tsx", content: authenticatedLayoutTemplate, base: "cwd" },
15638
15646
  // Lib
15639
15647
  r2: { relPath: "lib/r2.ts", content: r2ClientTemplate },
15640
15648
  "form-settings-action": { relPath: "lib/actions/form-settings.ts", content: formSettingsActionTemplate },
@@ -15673,7 +15681,7 @@ function getAllComponentNames() {
15673
15681
  const templateKeys = Object.keys(TEMPLATE_REGISTRY);
15674
15682
  return [.../* @__PURE__ */ new Set([...staticUi, ...templateKeys, "tiptap"])].sort();
15675
15683
  }
15676
- var updateComponentCommand = new Command7("update-component").description("Update individual CMS components from the latest CLI templates").argument("[components...]", "Component names to update (e.g., media-upload-field button)").option("--list", "List all available components").option("--all", "Update all components").option("--cwd <path>", "Project root path").action(async (components, options) => {
15684
+ var updateComponentCommand = new Command7("update").alias("update-component").description("Update CMS components from the latest CLI templates").argument("[components...]", "Component names to update (e.g., media-upload-field button)").option("--list", "List all available components").option("--all", "Update all components").option("--cwd <path>", "Project root path").action(async (components, options) => {
15677
15685
  const cwd = options.cwd ? path49.resolve(options.cwd) : process.cwd();
15678
15686
  if (options.list) {
15679
15687
  const all = getAllComponentNames();
@@ -15723,7 +15731,8 @@ var updateComponentCommand = new Command7("update-component").description("Updat
15723
15731
  for (const name of toUpdate) {
15724
15732
  if (TEMPLATE_REGISTRY[name]) {
15725
15733
  const entry = TEMPLATE_REGISTRY[name];
15726
- const destPath = path49.join(cms, entry.relPath);
15734
+ const baseDir = entry.base === "cwd" ? cwd : cms;
15735
+ const destPath = path49.join(baseDir, entry.relPath);
15727
15736
  fsExtra.ensureDirSync(path49.dirname(destPath));
15728
15737
  fs45.writeFileSync(destPath, entry.content(), "utf-8");
15729
15738
  clack2.log.success(`Updated ${entry.relPath}`);