@betterstart/cli 0.1.64 → 0.1.66

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 (
@@ -15633,6 +15640,9 @@ var TEMPLATE_REGISTRY = {
15633
15640
  validation: { relPath: "utils/validation.ts", content: validationUtilTemplate },
15634
15641
  webhook: { relPath: "utils/webhook.ts", content: webhookUtilTemplate },
15635
15642
  mailchimp: { relPath: "utils/mailchimp.ts", content: mailchimpUtilTemplate },
15643
+ // Auth
15644
+ "auth-middleware": { relPath: "lib/auth/middleware.ts", content: authMiddlewareTemplate },
15645
+ "auth-layout": { relPath: "app/(cms)/cms/(authenticated)/layout.tsx", content: authenticatedLayoutTemplate, base: "cwd" },
15636
15646
  // Lib
15637
15647
  r2: { relPath: "lib/r2.ts", content: r2ClientTemplate },
15638
15648
  "form-settings-action": { relPath: "lib/actions/form-settings.ts", content: formSettingsActionTemplate },
@@ -15721,7 +15731,8 @@ var updateComponentCommand = new Command7("update-component").description("Updat
15721
15731
  for (const name of toUpdate) {
15722
15732
  if (TEMPLATE_REGISTRY[name]) {
15723
15733
  const entry = TEMPLATE_REGISTRY[name];
15724
- const destPath = path49.join(cms, entry.relPath);
15734
+ const baseDir = entry.base === "cwd" ? cwd : cms;
15735
+ const destPath = path49.join(baseDir, entry.relPath);
15725
15736
  fsExtra.ensureDirSync(path49.dirname(destPath));
15726
15737
  fs45.writeFileSync(destPath, entry.content(), "utf-8");
15727
15738
  clack2.log.success(`Updated ${entry.relPath}`);