@betterstart/cli 0.1.65 → 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 +14 -5
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
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 {
|
|
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
|
|
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 },
|
|
@@ -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
|
|
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}`);
|