@murumets-ee/create 0.1.12 → 0.1.14

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.mjs ADDED
@@ -0,0 +1,3246 @@
1
+ #!/usr/bin/env node
2
+ import*as e from"@clack/prompts";import t from"picocolors";import{dirname as n,join as r}from"node:path";import{execSync as i}from"node:child_process";import{appendFile as a,mkdir as o,readFile as s,rm as c,writeFile as l}from"node:fs/promises";var u=Object.defineProperty,d=(e,t)=>{let n={};for(var r in e)u(n,r,{get:e[r],enumerable:!0});return t||u(n,Symbol.toStringTag,{value:`Module`}),n};function f(e){let t={},n=e.slice(2);for(let e=0;e<n.length;e++){let r=n[e];if(r===`--mode`&&n[e+1]){let r=n[++e];(r===`single`||r===`multi`)&&(t.mode=r)}else r===`--install`?t.install=!0:r===`--no-install`?t.install=!1:!r.startsWith(`-`)&&!t.name&&(t.name=r)}return t}async function p(t){let n=f(process.argv),r=n.name??t;if(r&&n.mode&&n.install!==void 0)return{name:r,mode:n.mode,installDeps:n.install};e.intro(`@murumets-ee/create`);let i=r??await e.text({message:`Project name:`,placeholder:`my-project`,validate:e=>{if(!e)return`Project name is required`;if(!/^[a-z0-9-]+$/.test(e))return`Use lowercase letters, numbers, and hyphens only`}});if(e.isCancel(i))return e.cancel(`Cancelled.`),null;let a=n.mode??await e.select({message:`App setup:`,options:[{value:`single`,label:`Single app`,hint:`everything in one Next.js project`},{value:`multi`,label:`Admin + Frontend`,hint:`two apps in a pnpm workspace`}]});if(e.isCancel(a))return e.cancel(`Cancelled.`),null;let o=n.install??await e.confirm({message:`Install dependencies?`,initialValue:!0});return e.isCancel(o)?(e.cancel(`Cancelled.`),null):{name:i,mode:a,installDeps:o}}var m=d({appendToFile:()=>y,deleteFiles:()=>_,mergePackageJson:()=>g,runCommand:()=>v,writeFile:()=>h});async function h(e,t){await o(n(e),{recursive:!0}),await l(e,t,`utf-8`)}async function g(e,t){let n=await s(e,`utf-8`),r=JSON.parse(n);t.type&&(r.type=t.type),t.dependencies&&(r.dependencies={...r.dependencies,...t.dependencies}),t.devDependencies&&(r.devDependencies={...r.devDependencies,...t.devDependencies}),t.scripts&&(r.scripts={...r.scripts,...t.scripts}),await l(e,`${JSON.stringify(r,null,2)}\n`,`utf-8`)}async function _(e,t){for(let n of t)await c(r(e,n),{force:!0,recursive:!0})}function v(e,t){return i(e,{cwd:t?.cwd,stdio:`pipe`,encoding:`utf-8`})}async function y(e,t){await a(e,t,`utf-8`)}async function b(e,t){await h(r(e,`lib/admin-config.ts`),`import { Media } from '@murumets-ee/media'
3
+ import { Article, Category } from '@/entities'
4
+
5
+ /** All entities available in the admin (drives sidebar nav + CRUD) */
6
+ export const allEntities = [Article, Media, Category]
7
+
8
+ /** Taxonomy entities keyed by name */
9
+ export const taxonomyVocabularies = { category: Category }
10
+
11
+ /** Entities exposed via generic CRUD API handler */
12
+ export const crudEntities = [Article, Media]
13
+
14
+ /** Plugin resources for the permission catalog */
15
+ export const pluginResources = [
16
+ { resource: 'storage', actions: ['view', 'create', 'update', 'delete'] },
17
+ { resource: 'settings', actions: ['view', 'update'] },
18
+ { resource: 'audit-logs', actions: ['view'] },
19
+ { resource: 'permissions', actions: ['view', 'create', 'update', 'delete'] },
20
+ ]
21
+ `),await h(r(e,`lib/content-locale.ts`),`import { cookies } from 'next/headers'
22
+ import { hasLocale } from 'next-intl'
23
+ import { routing } from '@/i18n/routing'
24
+
25
+ /**
26
+ * Get the content editing locale from the cookie, falling back to the interface locale.
27
+ */
28
+ export async function getContentLocale(interfaceLocale: string): Promise<string> {
29
+ const jar = await cookies()
30
+ const raw = jar.get('content-locale')?.value
31
+ if (raw && hasLocale(routing.locales, raw)) return raw
32
+ return interfaceLocale
33
+ }
34
+ `),await h(r(e,`lib/with-admin-context.ts`),`import { getContentConfig } from '@murumets-ee/content/plugin'
35
+ import type { RequestContext } from '@murumets-ee/core'
36
+ import { runWithContextAsync } from '@murumets-ee/core'
37
+ import { getToolkitApp } from './app'
38
+ import { getContentLocale } from './content-locale'
39
+
40
+ export async function withAdminContext<T>(
41
+ interfaceLocale: string,
42
+ fn: (ctx: { locale: string; defaultLocale: string }) => Promise<T>,
43
+ ): Promise<T> {
44
+ const app = await getToolkitApp()
45
+ const contentLocale = await getContentLocale(interfaceLocale)
46
+ const { defaultLocale } = getContentConfig()
47
+
48
+ const context: RequestContext = {
49
+ locale: contentLocale,
50
+ defaultLocale,
51
+ app,
52
+ }
53
+
54
+ return runWithContextAsync(context, () => fn({ locale: contentLocale, defaultLocale }))
55
+ }
56
+ `),await h(r(e,`lib/load-roles.ts`),`import { buildInitialRoleDefinitions } from '@murumets-ee/auth'
57
+ import type { ToolkitApp } from '@murumets-ee/core'
58
+ import { createSettingsClient } from '@murumets-ee/settings'
59
+ import { permissionSettings } from '@/settings/permissions'
60
+
61
+ export async function loadRoles(
62
+ app: ToolkitApp,
63
+ ): Promise<Record<string, Record<string, string[]>>> {
64
+ const client = createSettingsClient(permissionSettings, { app })
65
+ const saved = await client.get('roles')
66
+
67
+ if (saved) return saved
68
+
69
+ // First run — seed built-in roles with zero permissions
70
+ const initial = buildInitialRoleDefinitions()
71
+ await client.set('roles', initial)
72
+ return initial
73
+ }
74
+ `),await h(r(e,`settings/permissions.ts`),`import { defineSettings, setting } from '@murumets-ee/settings'
75
+
76
+ export const permissionSettings = defineSettings({
77
+ namespace: 'permissions',
78
+ scope: 'global',
79
+ label: 'Permissions',
80
+ schema: {
81
+ roles: setting.json<Record<string, Record<string, string[]>>>(),
82
+ },
83
+ })
84
+ `),await h(r(e,`settings/site.ts`),`import { defineSettings, setting } from '@murumets-ee/settings'
85
+
86
+ export const siteSettings = defineSettings({
87
+ namespace: 'site',
88
+ scope: 'global',
89
+ label: 'Site Settings',
90
+ schema: {
91
+ siteName: setting.text({ default: 'My Site', label: 'Site Name', translatable: true }),
92
+ siteDescription: setting.text({ label: 'Site Description', translatable: true }),
93
+ maintenanceMode: setting.boolean({ default: false, label: 'Maintenance Mode' }),
94
+ postsPerPage: setting.number({
95
+ default: 10,
96
+ min: 1,
97
+ max: 100,
98
+ integer: true,
99
+ label: 'Posts Per Page',
100
+ }),
101
+ },
102
+ })
103
+ `),await h(r(e,`app/admin-layout.tsx`),`'use client'
104
+
105
+ import type { LinkComponent, SidebarNavGroup } from '@murumets-ee/admin-ui'
106
+ import { AdminShell } from '@murumets-ee/admin-ui'
107
+ import type { AdminNavGroup } from '@murumets-ee/admin-ui/server'
108
+ import {
109
+ Activity,
110
+ FileText,
111
+ FolderTree,
112
+ Home,
113
+ Image,
114
+ ImageDown,
115
+ Lock,
116
+ PenTool,
117
+ ShieldCheck,
118
+ Tags,
119
+ Users,
120
+ type LucideIcon,
121
+ } from 'lucide-react'
122
+ import type { ReactNode } from 'react'
123
+ import { Link, usePathname } from '@/i18n/navigation'
124
+
125
+ /** Map from icon name strings (from entity admin config) to Lucide components */
126
+ const ICON_MAP: Record<string, LucideIcon> = {
127
+ 'file-text': FileText,
128
+ 'folder-tree': FolderTree,
129
+ tags: Tags,
130
+ }
131
+
132
+ interface AdminLayoutProps {
133
+ children: ReactNode
134
+ defaultOpen?: boolean
135
+ headerActions?: ReactNode
136
+ sidebarFooter?: ReactNode
137
+ entityNavGroups?: AdminNavGroup[]
138
+ }
139
+
140
+ export function AdminLayout({
141
+ children,
142
+ defaultOpen,
143
+ headerActions,
144
+ sidebarFooter,
145
+ entityNavGroups,
146
+ }: AdminLayoutProps) {
147
+ const pathname = usePathname()
148
+
149
+ const dynamicGroups: SidebarNavGroup[] = (entityNavGroups ?? []).map((group) => ({
150
+ label: group.label,
151
+ items: group.items.map((item) => ({
152
+ label: item.label,
153
+ href: item.href,
154
+ icon: item.iconName ? ICON_MAP[item.iconName] : undefined,
155
+ })),
156
+ }))
157
+
158
+ const staticBefore: SidebarNavGroup = {
159
+ items: [
160
+ { label: 'Home', href: '/', icon: Home },
161
+ { label: 'Admin', href: '/admin', icon: PenTool },
162
+ ],
163
+ }
164
+
165
+ const systemGroup: SidebarNavGroup = {
166
+ label: 'System',
167
+ items: [
168
+ { label: 'Users', href: '/admin/users', icon: Users },
169
+ { label: 'Roles', href: '/admin/roles', icon: ShieldCheck },
170
+ { label: 'Permissions', href: '/admin/permissions', icon: Lock },
171
+ { label: 'Media', href: '/admin/media', icon: Image },
172
+ { label: 'Image Styles', href: '/admin/media/image-styles', icon: ImageDown },
173
+ { label: 'Activity', href: '/admin/activity', icon: Activity },
174
+ ],
175
+ }
176
+
177
+ const navGroups: SidebarNavGroup[] = [
178
+ staticBefore,
179
+ ...dynamicGroups,
180
+ systemGroup,
181
+ ]
182
+
183
+ return (
184
+ <AdminShell
185
+ defaultOpen={defaultOpen}
186
+ sidebar={{
187
+ navGroups,
188
+ pathname,
189
+ Link: Link as unknown as LinkComponent,
190
+ logo: (
191
+ <div className="flex h-8 items-center gap-2 px-2">
192
+ <span className="font-semibold text-sm text-zinc-700 dark:text-zinc-300 truncate">
193
+ Admin
194
+ </span>
195
+ </div>
196
+ ),
197
+ footer: sidebarFooter,
198
+ }}
199
+ header={{
200
+ actions: headerActions,
201
+ }}
202
+ >
203
+ {children}
204
+ </AdminShell>
205
+ )
206
+ }
207
+ `),await h(r(e,`app/[locale]/(shell)/layout.tsx`),`import { buildAdminNav } from '@murumets-ee/admin-ui/server'
208
+ import { cookies, headers } from 'next/headers'
209
+ import { redirect } from 'next/navigation'
210
+ import { Suspense } from 'react'
211
+ import { allEntities } from '@/lib/admin-config'
212
+ import { auth } from '@/lib/auth'
213
+ import { AdminLayout } from '../../admin-layout'
214
+ import { ThemeToggle } from '../../theme-toggle'
215
+
216
+ async function DynamicShell({
217
+ children,
218
+ interfaceLocale,
219
+ }: {
220
+ children: React.ReactNode
221
+ interfaceLocale: string
222
+ }) {
223
+ const h = await headers()
224
+ const session = await auth.api.getSession({ headers: h })
225
+ if (!session?.user) {
226
+ redirect(\`/\${interfaceLocale}/auth/sign-in\`)
227
+ }
228
+
229
+ const jar = await cookies()
230
+ const sidebarOpen = jar.get('sidebar:state')?.value !== 'false'
231
+ const entityNavGroups = buildAdminNav(allEntities, { basePath: '/admin' })
232
+
233
+ return (
234
+ <AdminLayout
235
+ defaultOpen={sidebarOpen}
236
+ entityNavGroups={entityNavGroups}
237
+ sidebarFooter={
238
+ <div className="flex justify-center gap-2">
239
+ <ThemeToggle />
240
+ </div>
241
+ }
242
+ >
243
+ {children}
244
+ </AdminLayout>
245
+ )
246
+ }
247
+
248
+ export default async function ShellLayout({
249
+ children,
250
+ params,
251
+ }: {
252
+ children: React.ReactNode
253
+ params: Promise<{ locale: string }>
254
+ }) {
255
+ const { locale } = await params
256
+
257
+ return (
258
+ <Suspense>
259
+ <DynamicShell interfaceLocale={locale}>{children}</DynamicShell>
260
+ </Suspense>
261
+ )
262
+ }
263
+ `),await h(r(e,`app/[locale]/(shell)/admin/layout.tsx`),`import { headers } from 'next/headers'
264
+ import { redirect } from 'next/navigation'
265
+ import { auth } from '@/lib/auth'
266
+
267
+ const ALLOWED_ROLES = new Set(['admin', 'editor'])
268
+
269
+ export default async function AdminGuardLayout({
270
+ children,
271
+ params,
272
+ }: {
273
+ children: React.ReactNode
274
+ params: Promise<{ locale: string }>
275
+ }) {
276
+ const { locale } = await params
277
+ const h = await headers()
278
+ const session = await auth.api.getSession({ headers: h })
279
+
280
+ if (!session?.user) {
281
+ redirect(\`/\${locale}/auth/sign-in\`)
282
+ }
283
+
284
+ const role = (session.user as Record<string, unknown>).role as string | undefined
285
+ if (!role || !ALLOWED_ROLES.has(role)) {
286
+ redirect(\`/\${locale}\`)
287
+ }
288
+
289
+ return <>{children}</>
290
+ }
291
+ `),await h(r(e,`app/[locale]/(shell)/admin/page.tsx`),`import { setRequestLocale } from 'next-intl/server'
292
+
293
+ export default async function AdminDashboard({ params }: { params: Promise<{ locale: string }> }) {
294
+ const { locale } = await params
295
+ setRequestLocale(locale)
296
+
297
+ return (
298
+ <div className="p-6">
299
+ <h1 className="text-2xl font-bold mb-4">Dashboard</h1>
300
+ <p className="text-muted-foreground">
301
+ Welcome to the admin panel. Use the sidebar to manage your content.
302
+ </p>
303
+ </div>
304
+ )
305
+ }
306
+ `),await h(r(e,`app/[locale]/(shell)/admin/[entity]/page.tsx`),`import { EntityList } from '@murumets-ee/admin-ui/entity-list'
307
+ import {
308
+ entityNameToSlug,
309
+ fetchEntityList,
310
+ getEntityLabel,
311
+ resolveEntityFromSlug,
312
+ toEntityMeta,
313
+ } from '@murumets-ee/admin-ui/server'
314
+ import { getContentConfig } from '@murumets-ee/content/plugin'
315
+ import { notFound } from 'next/navigation'
316
+ import { setRequestLocale } from 'next-intl/server'
317
+ import { allEntities, taxonomyVocabularies } from '@/lib/admin-config'
318
+ import { withAdminContext } from '@/lib/with-admin-context'
319
+
320
+ interface EntityListPageProps {
321
+ params: Promise<{ locale: string; entity: string }>
322
+ }
323
+
324
+ export default async function EntityListPage({ params }: EntityListPageProps) {
325
+ const { locale, entity: entitySlug } = await params
326
+ setRequestLocale(locale)
327
+
328
+ const entity = resolveEntityFromSlug(entitySlug, allEntities)
329
+ if (!entity) notFound()
330
+
331
+ const admin = entity.admin
332
+ const meta = toEntityMeta(entity)
333
+ const urlSlug = entityNameToSlug(entity.name)
334
+ const hasTranslatable = Object.values(entity.allFields).some((f) => f.translatable)
335
+ const isPublishable = entity.behaviors?.some((b) => b.name === 'publishable')
336
+ const isTaxonomy = entity.name in taxonomyVocabularies
337
+
338
+ return withAdminContext(locale, async ({ locale: contentLocale, defaultLocale }) => {
339
+ let locales: Array<{ code: string; label: string }> | undefined
340
+ if (hasTranslatable) {
341
+ try {
342
+ const config = getContentConfig()
343
+ locales = config.locales
344
+ } catch {
345
+ // content plugin not available
346
+ }
347
+ }
348
+
349
+ const initialData = await fetchEntityList(entity, {
350
+ sortField: admin?.defaultSort ?? 'createdAt',
351
+ sortDirection: admin?.defaultSortDirection ?? 'desc',
352
+ limit: admin?.pageSize ?? 20,
353
+ locale: contentLocale,
354
+ includeTranslationStatus: hasTranslatable,
355
+ })
356
+
357
+ return (
358
+ <div className="p-6">
359
+ <div className="mb-6">
360
+ <h1 className="text-2xl font-bold">{getEntityLabel(entity)}</h1>
361
+ {admin?.description && (
362
+ <p className="text-sm text-muted-foreground">{admin.description}</p>
363
+ )}
364
+ </div>
365
+ <EntityList
366
+ entity={meta}
367
+ allowDelete
368
+ allowStatusToggle={isPublishable}
369
+ {...(isTaxonomy ? { apiBasePath: '/api/admin/taxonomy', entityPath: entity.name } : {})}
370
+ defaultSort={admin?.defaultSort ?? 'createdAt'}
371
+ defaultSortDirection={admin?.defaultSortDirection ?? 'desc'}
372
+ hiddenColumns={admin?.hiddenColumns}
373
+ pageSize={admin?.pageSize}
374
+ locale={contentLocale}
375
+ locales={locales}
376
+ defaultLocale={defaultLocale}
377
+ showTranslationStatus={hasTranslatable && !!locales}
378
+ searchPlaceholder={\`Search \${getEntityLabel(entity).toLowerCase()}...\`}
379
+ editHref={\`/\${locale}/admin/\${urlSlug}/:id\`}
380
+ createHref={admin?.disableCreate ? undefined : \`/\${locale}/admin/\${urlSlug}/new\`}
381
+ initialData={initialData}
382
+ />
383
+ </div>
384
+ )
385
+ })
386
+ }
387
+ `),await h(r(e,`app/[locale]/(shell)/admin/[entity]/[id]/page.tsx`),`import {
388
+ entityNameToSlug,
389
+ fetchReferenceOptions,
390
+ getBlocksFieldName,
391
+ getEntityLabelSingular,
392
+ getReferenceFields,
393
+ inferRootFields,
394
+ resolveEntityFromSlug,
395
+ toEntityMeta,
396
+ } from '@murumets-ee/admin-ui/server'
397
+ import { buildPermissionChecker } from '@murumets-ee/auth'
398
+ import { ContentClient } from '@murumets-ee/content/client'
399
+ import { LockService } from '@murumets-ee/content/lock'
400
+ import { createAdminClient } from '@murumets-ee/core/clients'
401
+ import { getApp } from '@murumets-ee/core'
402
+ import { prepareBlockEditor } from '@murumets-ee/editor/server'
403
+ import { headers } from 'next/headers'
404
+ import { notFound } from 'next/navigation'
405
+ import { setRequestLocale } from 'next-intl/server'
406
+ import { GenericBlockEditor } from '@murumets-ee/admin-ui/content-editor'
407
+ import { GenericEntityForm } from '@murumets-ee/admin-ui/entity-form'
408
+ import { allEntities } from '@/lib/admin-config'
409
+ import { auth } from '@/lib/auth'
410
+ import { loadRoles } from '@/lib/load-roles'
411
+ import { withAdminContext } from '@/lib/with-admin-context'
412
+
413
+ interface EditEntityPageProps {
414
+ params: Promise<{ locale: string; entity: string; id: string }>
415
+ }
416
+
417
+ export default async function EditEntityPage({ params }: EditEntityPageProps) {
418
+ const { locale, entity: entitySlug, id } = await params
419
+ setRequestLocale(locale)
420
+
421
+ const entity = resolveEntityFromSlug(entitySlug, allEntities)
422
+ if (!entity) notFound()
423
+
424
+ const blocksField = getBlocksFieldName(entity)
425
+ const urlSlug = entityNameToSlug(entity.name)
426
+
427
+ return withAdminContext(locale, async ({ locale: contentLocale, defaultLocale }) => {
428
+ const client = createAdminClient(entity)
429
+ const isDefaultLocale = contentLocale === defaultLocale
430
+ const isNonDefaultLocale = !isDefaultLocale
431
+
432
+ const isVersionable = entity.behaviors?.some((b) => b.name === 'versionable') ?? false
433
+ const isPublishable = entity.behaviors?.some((b) => b.name === 'publishable') ?? false
434
+
435
+ let draft: { data: Record<string, unknown>; createdBy: string; createdByName: string | null; updatedAt: Date | string } | undefined
436
+ let canPublish = false
437
+ let lockResult: { acquired: boolean; lock?: { lockedBy: string; lockedByName: string | null; lockedAt: Date | string; expiresAt: Date | string } | null } | undefined
438
+ const enableLocking = isPublishable
439
+
440
+ if (isPublishable) {
441
+ try {
442
+ const app = getApp()
443
+ const contentClient = new ContentClient({ entity, db: app.db.readWrite })
444
+ const lockLocale = isDefaultLocale ? '_' : contentLocale
445
+
446
+ const draftEntry = await contentClient.getDraft(id, lockLocale)
447
+ if (draftEntry) {
448
+ draft = {
449
+ data: draftEntry.data,
450
+ createdBy: draftEntry.createdBy,
451
+ createdByName: draftEntry.createdByName,
452
+ updatedAt: draftEntry.updatedAt,
453
+ }
454
+ }
455
+
456
+ const session = await auth.api.getSession({ headers: await headers() })
457
+ if (session?.user) {
458
+ const role = (session.user as Record<string, unknown>).role as string | undefined
459
+ if (role) {
460
+ const roles = await loadRoles(app)
461
+ const checker = buildPermissionChecker(roles)
462
+ canPublish = checker(role, entity.name, 'publish')
463
+ }
464
+
465
+ const lockService = new LockService({ db: app.db.readWrite })
466
+ const result = await lockService.acquireLock(
467
+ entity.name, id, lockLocale,
468
+ { id: session.user.id, name: session.user.name ?? undefined },
469
+ )
470
+ if (result.acquired) {
471
+ lockResult = { acquired: true }
472
+ } else {
473
+ lockResult = { acquired: false, lock: result.lock }
474
+ }
475
+ }
476
+ } catch {
477
+ // Draft/permission/lock errors — proceed without
478
+ }
479
+ }
480
+
481
+ // Block editor entity
482
+ if (blocksField) {
483
+ const record = isDefaultLocale
484
+ ? await client.findById(id, { defaultLocale })
485
+ : await client.findById(id, { locale: contentLocale, defaultLocale })
486
+ if (!record) notFound()
487
+
488
+ const rootFields = inferRootFields(entity, blocksField)
489
+ const { blocks, initialData, mediaUrls, rootData, rootFieldDefs } =
490
+ await prepareBlockEditor(
491
+ entity as Parameters<typeof prepareBlockEditor>[0],
492
+ blocksField,
493
+ record,
494
+ { rootFields },
495
+ )
496
+
497
+ return (
498
+ <div className="flex h-[calc(100vh-3.5rem)] flex-col">
499
+ <div className="flex items-center gap-3 border-b px-6 py-3">
500
+ <h1 className="text-lg font-semibold">
501
+ {(record.title as string) ?? \`Untitled \${getEntityLabelSingular(entity)}\`}
502
+ </h1>
503
+ <span className="rounded bg-muted px-2 py-0.5 text-xs text-muted-foreground uppercase">
504
+ {contentLocale}
505
+ </span>
506
+ </div>
507
+ <div className="flex-1 overflow-hidden">
508
+ <GenericBlockEditor
509
+ key={contentLocale}
510
+ entityId={id}
511
+ entityName={entity.name}
512
+ blocksField={blocksField}
513
+ blocks={blocks}
514
+ initialData={initialData}
515
+ mediaUrls={mediaUrls}
516
+ rootData={rootData}
517
+ rootFieldDefs={rootFieldDefs}
518
+ saveLabel="Save"
519
+ locale={contentLocale}
520
+ defaultLocale={defaultLocale}
521
+ versionable={isVersionable}
522
+ isPublishable={isPublishable}
523
+ draft={draft}
524
+ canPublish={canPublish}
525
+ enableLocking={enableLocking}
526
+ lockResult={lockResult}
527
+ />
528
+ </div>
529
+ </div>
530
+ )
531
+ }
532
+
533
+ // Form entity
534
+ const [record, defaultLocaleData] = await Promise.all([
535
+ client.findById(id, { locale: contentLocale }),
536
+ isNonDefaultLocale ? client.findById(id) : Promise.resolve(null),
537
+ ])
538
+ if (!record) notFound()
539
+
540
+ const refFields = getReferenceFields(entity)
541
+ const referenceOptions: Record<string, Array<{ id: string; label: string }>> = {}
542
+
543
+ if (refFields.length > 0) {
544
+ const optionPromises = refFields.map(async ({ fieldName, entityName }) => {
545
+ const refEntity = allEntities.find((e) => e.name === entityName)
546
+ if (!refEntity) return { fieldName, options: [] }
547
+ const options = await fetchReferenceOptions(refEntity, { locale: contentLocale })
548
+ return { fieldName, options }
549
+ })
550
+ const results = await Promise.all(optionPromises)
551
+ for (const { fieldName, options } of results) {
552
+ referenceOptions[fieldName] = options
553
+ }
554
+ }
555
+
556
+ return (
557
+ <div className="p-6">
558
+ <div className="mb-6">
559
+ <h1 className="text-2xl font-bold">Edit {getEntityLabelSingular(entity)}</h1>
560
+ </div>
561
+ <GenericEntityForm
562
+ entity={toEntityMeta(entity)}
563
+ id={id}
564
+ locale={contentLocale}
565
+ defaultLocale={defaultLocale}
566
+ defaultLocaleData={
567
+ isNonDefaultLocale && defaultLocaleData
568
+ ? (defaultLocaleData as Record<string, unknown>)
569
+ : undefined
570
+ }
571
+ initialData={record as Record<string, unknown>}
572
+ referenceOptions={referenceOptions}
573
+ listUrl={\`/\${locale}/admin/\${urlSlug}\`}
574
+ versionable={isVersionable}
575
+ draft={draft}
576
+ canPublish={canPublish}
577
+ enableLocking={enableLocking}
578
+ lockResult={lockResult}
579
+ />
580
+ </div>
581
+ )
582
+ })
583
+ }
584
+ `),await h(r(e,`app/[locale]/(shell)/admin/[entity]/new/page.tsx`),`import {
585
+ entityNameToSlug,
586
+ fetchReferenceOptions,
587
+ getBlocksFieldName,
588
+ getEntityLabelSingular,
589
+ getReferenceFields,
590
+ resolveEntityFromSlug,
591
+ toEntityMeta,
592
+ } from '@murumets-ee/admin-ui/server'
593
+ import { createAdminClient } from '@murumets-ee/core/clients'
594
+ import { notFound, redirect } from 'next/navigation'
595
+ import { setRequestLocale } from 'next-intl/server'
596
+ import { GenericEntityForm } from '@murumets-ee/admin-ui/entity-form'
597
+ import { allEntities } from '@/lib/admin-config'
598
+ import { withAdminContext } from '@/lib/with-admin-context'
599
+
600
+ interface NewEntityPageProps {
601
+ params: Promise<{ locale: string; entity: string }>
602
+ }
603
+
604
+ export default async function NewEntityPage({ params }: NewEntityPageProps) {
605
+ const { locale, entity: entitySlug } = await params
606
+ setRequestLocale(locale)
607
+
608
+ const entity = resolveEntityFromSlug(entitySlug, allEntities)
609
+ if (!entity) notFound()
610
+ if (entity.admin?.disableCreate) notFound()
611
+
612
+ const blocksField = getBlocksFieldName(entity)
613
+ const urlSlug = entityNameToSlug(entity.name)
614
+
615
+ return withAdminContext(locale, async ({ locale: contentLocale }) => {
616
+ // Block editor entities: create a draft and redirect to the edit page
617
+ if (blocksField) {
618
+ const client = createAdminClient(entity)
619
+ const draft = await client.create({ title: 'Untitled' })
620
+ const newId = (draft as Record<string, unknown>).id as string
621
+ redirect(\`/\${locale}/admin/\${urlSlug}/\${newId}\`)
622
+ }
623
+
624
+ // Form entities: render the create form
625
+ const refFields = getReferenceFields(entity)
626
+ const referenceOptions: Record<string, Array<{ id: string; label: string }>> = {}
627
+
628
+ if (refFields.length > 0) {
629
+ const optionPromises = refFields.map(async ({ fieldName, entityName }) => {
630
+ const refEntity = allEntities.find((e) => e.name === entityName)
631
+ if (!refEntity) return { fieldName, options: [] }
632
+ const options = await fetchReferenceOptions(refEntity, { locale: contentLocale })
633
+ return { fieldName, options }
634
+ })
635
+ const results = await Promise.all(optionPromises)
636
+ for (const { fieldName, options } of results) {
637
+ referenceOptions[fieldName] = options
638
+ }
639
+ }
640
+
641
+ return (
642
+ <div className="p-6">
643
+ <div className="mb-6">
644
+ <h1 className="text-2xl font-bold">New {getEntityLabelSingular(entity)}</h1>
645
+ </div>
646
+ <GenericEntityForm
647
+ entity={toEntityMeta(entity)}
648
+ locale={contentLocale}
649
+ referenceOptions={referenceOptions}
650
+ listUrl={\`/\${locale}/admin/\${urlSlug}\`}
651
+ />
652
+ </div>
653
+ )
654
+ })
655
+ }
656
+ `),await h(r(e,`app/[locale]/(shell)/admin/media/page.tsx`),`import { EntityList } from '@murumets-ee/admin-ui/entity-list'
657
+ import { fetchEntityList, toEntityMeta } from '@murumets-ee/admin-ui/server'
658
+ import { Media } from '@murumets-ee/media'
659
+ import { getMediaClient } from '@murumets-ee/media/client'
660
+ import { setRequestLocale } from 'next-intl/server'
661
+
662
+ export default async function MediaListPage({ params }: { params: Promise<{ locale: string }> }) {
663
+ const { locale } = await params
664
+ setRequestLocale(locale)
665
+ const initialData = await fetchEntityList(Media, { sortField: 'createdAt' })
666
+
667
+ const mediaClient = await getMediaClient()
668
+ const ids = initialData.items.map((i) => i.id as string)
669
+ const thumbMap = await mediaClient.getVariantUrls(ids, 'thumbnail')
670
+ for (const item of initialData.items) {
671
+ item.thumbnailUrl = thumbMap.get(item.id as string) ?? ''
672
+ }
673
+
674
+ return (
675
+ <div className="p-6">
676
+ <div className="mb-6">
677
+ <h1 className="text-2xl font-bold">Media</h1>
678
+ <p className="text-sm text-muted-foreground">
679
+ Manage uploaded media files.
680
+ </p>
681
+ </div>
682
+ <EntityList
683
+ entity={toEntityMeta(Media)}
684
+ entityPath="media"
685
+ image={{ field: 'thumbnailUrl', size: 'sm', shape: 'rounded' }}
686
+ allowDelete
687
+ defaultSort="createdAt"
688
+ searchPlaceholder="Search media..."
689
+ editHref={\`/\${locale}/admin/media/:id\`}
690
+ initialData={initialData}
691
+ />
692
+ </div>
693
+ )
694
+ }
695
+ `),await h(r(e,`app/[locale]/(shell)/admin/media/[id]/page.tsx`),`import { toEntityMeta } from '@murumets-ee/admin-ui/server'
696
+ import { getCurrentApp } from '@murumets-ee/core'
697
+ import { createAdminClient } from '@murumets-ee/core/clients'
698
+ import { Media } from '@murumets-ee/media'
699
+ import { findMediaUsages } from '@murumets-ee/media/usage'
700
+ import { notFound } from 'next/navigation'
701
+ import { setRequestLocale } from 'next-intl/server'
702
+ import { withAdminContext } from '@/lib/with-admin-context'
703
+ import { MediaForm } from './media-form'
704
+ import { MediaUsagePanel } from './media-usage-panel'
705
+
706
+ interface MediaEditPageProps {
707
+ params: Promise<{ locale: string; id: string }>
708
+ }
709
+
710
+ export default async function MediaEditPage({ params }: MediaEditPageProps) {
711
+ const { locale, id } = await params
712
+ setRequestLocale(locale)
713
+
714
+ return withAdminContext(locale, async ({ locale: contentLocale }) => {
715
+ const app = getCurrentApp()!
716
+ const client = createAdminClient(Media)
717
+ const [mediaItem, usages] = await Promise.all([
718
+ client.findById(id, { locale: contentLocale }),
719
+ findMediaUsages(id, app.db.readWrite),
720
+ ])
721
+ if (!mediaItem) notFound()
722
+
723
+ return (
724
+ <div className="p-6">
725
+ <div className="mb-6">
726
+ <h1 className="text-2xl font-bold">Edit Media</h1>
727
+ </div>
728
+ <div className="grid grid-cols-1 gap-6 lg:grid-cols-3">
729
+ <div className="lg:col-span-2">
730
+ <MediaForm
731
+ entity={toEntityMeta(Media)}
732
+ id={id}
733
+ locale={contentLocale}
734
+ initialData={mediaItem as Record<string, unknown>}
735
+ />
736
+ </div>
737
+ <div>
738
+ <MediaUsagePanel usages={usages} locale={locale} />
739
+ </div>
740
+ </div>
741
+ </div>
742
+ )
743
+ })
744
+ }
745
+ `),await h(r(e,`app/[locale]/(shell)/admin/media/[id]/media-form.tsx`),`'use client'
746
+
747
+ import { EntityForm } from '@murumets-ee/admin-ui/entity-form'
748
+ import type { EntityMeta } from '@murumets-ee/admin-ui/entity-list'
749
+ import { useRouter } from 'next/navigation'
750
+
751
+ interface MediaFormProps {
752
+ entity: EntityMeta
753
+ id: string
754
+ locale?: string
755
+ initialData?: Record<string, unknown>
756
+ }
757
+
758
+ export function MediaForm({ entity, id, locale, initialData }: MediaFormProps) {
759
+ const router = useRouter()
760
+
761
+ return (
762
+ <EntityForm
763
+ entity={entity}
764
+ id={id}
765
+ locale={locale}
766
+ initialData={initialData}
767
+ entityPath="media"
768
+ layout="two-column"
769
+ fields={['title', 'alt', 'description', 'filename', 'mimeType', 'size', 'mediaType']}
770
+ fieldOverrides={{
771
+ filename: { readOnly: true, description: 'Original upload filename (read-only)' },
772
+ mimeType: { readOnly: true, label: 'MIME Type' },
773
+ size: { readOnly: true, description: 'File size in bytes' },
774
+ mediaType: { readOnly: true, label: 'Media Type' },
775
+ alt: { label: 'Alt Text', description: 'Alternative text for accessibility' },
776
+ }}
777
+ onSuccess={() => router.push(\`/\${locale}/admin/media\`)}
778
+ onCancel={() => router.back()}
779
+ />
780
+ )
781
+ }
782
+ `),await h(r(e,`app/[locale]/(shell)/admin/media/[id]/media-usage-panel.tsx`),`import type { MediaUsage } from '@murumets-ee/media/usage'
783
+
784
+ interface MediaUsagePanelProps {
785
+ usages: MediaUsage[]
786
+ locale: string
787
+ }
788
+
789
+ export function MediaUsagePanel({ usages, locale }: MediaUsagePanelProps) {
790
+ return (
791
+ <div className="rounded-lg border bg-card p-4">
792
+ <h3 className="mb-3 text-sm font-semibold">Used by</h3>
793
+
794
+ {usages.length === 0 && (
795
+ <p className="text-sm text-muted-foreground">
796
+ This media item is not referenced by any entity.
797
+ </p>
798
+ )}
799
+
800
+ {usages.length > 0 && (
801
+ <ul className="space-y-2">
802
+ {usages.map((usage) => {
803
+ const entitySlug = \`\${usage.entityName}s\`
804
+ const href = \`/\${locale}/admin/\${entitySlug}/\${usage.entityId}\`
805
+
806
+ return (
807
+ <li key={\`\${usage.entityName}-\${usage.entityId}-\${usage.fieldName}\`}>
808
+ <a
809
+ href={href}
810
+ className="block rounded-md border px-3 py-2 text-sm hover:bg-muted transition-colors"
811
+ >
812
+ <span className="font-medium capitalize">{usage.entityName}</span>
813
+ <span className="mx-1.5 text-muted-foreground">&middot;</span>
814
+ <span className="text-muted-foreground">{usage.fieldName}</span>
815
+ {usage.context === 'block' && (
816
+ <span className="ml-1.5 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground">
817
+ block
818
+ </span>
819
+ )}
820
+ </a>
821
+ </li>
822
+ )
823
+ })}
824
+ </ul>
825
+ )}
826
+ </div>
827
+ )
828
+ }
829
+ `),await h(r(e,`app/[locale]/(shell)/admin/media/image-styles/page.tsx`),`import { imageStylesSettings } from '@murumets-ee/media'
830
+ import { ImageStylesManager } from '@murumets-ee/media/image-styles'
831
+ import { createSettingsClient } from '@murumets-ee/settings'
832
+ import { setRequestLocale } from 'next-intl/server'
833
+ import { getToolkitApp } from '@/lib/app'
834
+
835
+ async function loadImageStyles() {
836
+ const app = await getToolkitApp()
837
+ const client = createSettingsClient(imageStylesSettings, { app })
838
+ const styles = await client.get('imageStyles')
839
+ return styles ?? {}
840
+ }
841
+
842
+ export default async function ImageStylesPage({ params }: { params: Promise<{ locale: string }> }) {
843
+ const { locale } = await params
844
+ setRequestLocale(locale)
845
+
846
+ const initialStyles = await loadImageStyles()
847
+
848
+ return (
849
+ <div className="p-6 max-w-4xl">
850
+ <ImageStylesManager initialStyles={initialStyles} />
851
+ </div>
852
+ )
853
+ }
854
+ `),await h(r(e,`app/[locale]/(shell)/admin/users/page.tsx`),`import type { UsersInitialData } from '@murumets-ee/admin-ui/users'
855
+ import { getAuth } from '@murumets-ee/auth'
856
+ import { headers } from 'next/headers'
857
+ import { setRequestLocale } from 'next-intl/server'
858
+ import { getToolkitApp } from '@/lib/app'
859
+ import { UsersPage } from './users-page'
860
+
861
+ export default async function UsersAdminPage({ params }: { params: Promise<{ locale: string }> }) {
862
+ const { locale } = await params
863
+ setRequestLocale(locale)
864
+
865
+ await getToolkitApp()
866
+ const auth = getAuth()
867
+
868
+ const result = await auth.api.listUsers({
869
+ headers: await headers(),
870
+ query: { limit: 20, sortBy: 'createdAt', sortDirection: 'desc' },
871
+ })
872
+
873
+ const initialData: UsersInitialData = {
874
+ users: result.users.map((u) => ({
875
+ id: u.id,
876
+ name: u.name,
877
+ email: u.email,
878
+ emailVerified: u.emailVerified,
879
+ image: u.image ?? null,
880
+ createdAt: u.createdAt instanceof Date ? u.createdAt.toISOString() : String(u.createdAt),
881
+ updatedAt: u.updatedAt instanceof Date ? u.updatedAt.toISOString() : String(u.updatedAt),
882
+ role: u.role ?? null,
883
+ banned: u.banned ?? null,
884
+ banReason: u.banReason ?? null,
885
+ banExpires:
886
+ u.banExpires instanceof Date
887
+ ? u.banExpires.toISOString()
888
+ : u.banExpires
889
+ ? String(u.banExpires)
890
+ : null,
891
+ })),
892
+ total: result.total,
893
+ }
894
+
895
+ return (
896
+ <div className="p-6">
897
+ <div className="mb-6">
898
+ <h1 className="text-2xl font-bold">Users</h1>
899
+ <p className="text-sm text-muted-foreground">Manage user accounts, roles, and access.</p>
900
+ </div>
901
+ <UsersPage initialData={initialData} />
902
+ </div>
903
+ )
904
+ }
905
+ `),await h(r(e,`app/[locale]/(shell)/admin/users/users-page.tsx`),`'use client'
906
+
907
+ import type { UsersInitialData } from '@murumets-ee/admin-ui/users'
908
+ import { UsersManagement } from '@murumets-ee/admin-ui/users'
909
+ import { createUsersApi } from '@murumets-ee/auth/client'
910
+ import { authClient } from '@/lib/auth-client'
911
+
912
+ const usersApi = createUsersApi(authClient)
913
+
914
+ export function UsersPage({ initialData }: { initialData: UsersInitialData }) {
915
+ const session = authClient.useSession()
916
+
917
+ return (
918
+ <UsersManagement
919
+ api={usersApi}
920
+ currentUserId={session.data?.user?.id}
921
+ roles={['admin', 'editor', 'viewer']}
922
+ initialData={initialData}
923
+ />
924
+ )
925
+ }
926
+ `),await h(r(e,`app/[locale]/(shell)/admin/permissions/page.tsx`),`import { PermissionsEditor } from '@murumets-ee/admin-ui/permissions'
927
+ import { BUILT_IN_ROLES, buildResourceCatalog } from '@murumets-ee/auth'
928
+ import { setRequestLocale } from 'next-intl/server'
929
+ import { allEntities, pluginResources } from '@/lib/admin-config'
930
+ import { getToolkitApp } from '@/lib/app'
931
+ import { loadRoles } from '@/lib/load-roles'
932
+
933
+ export default async function PermissionsPage({ params }: { params: Promise<{ locale: string }> }) {
934
+ const { locale } = await params
935
+ setRequestLocale(locale)
936
+
937
+ const app = await getToolkitApp()
938
+ const savedRoles = await loadRoles(app)
939
+ const statements = buildResourceCatalog(allEntities, pluginResources)
940
+
941
+ return (
942
+ <div className="p-6">
943
+ <div className="mb-6">
944
+ <h1 className="text-2xl font-bold">Permissions</h1>
945
+ <p className="text-sm text-muted-foreground">
946
+ Configure what each role can do. Admin always has full access.
947
+ </p>
948
+ </div>
949
+ <PermissionsEditor
950
+ statements={statements}
951
+ roles={Object.keys(savedRoles)}
952
+ builtInRoles={[...BUILT_IN_ROLES]}
953
+ initialPermissions={savedRoles}
954
+ />
955
+ </div>
956
+ )
957
+ }
958
+ `),await h(r(e,`app/[locale]/(shell)/admin/roles/page.tsx`),`import { RolesEditor } from '@murumets-ee/admin-ui/permissions'
959
+ import { BUILT_IN_ROLES } from '@murumets-ee/auth'
960
+ import { setRequestLocale } from 'next-intl/server'
961
+ import { getToolkitApp } from '@/lib/app'
962
+ import { loadRoles } from '@/lib/load-roles'
963
+
964
+ export default async function RolesPage({ params }: { params: Promise<{ locale: string }> }) {
965
+ const { locale } = await params
966
+ setRequestLocale(locale)
967
+
968
+ const app = await getToolkitApp()
969
+ const savedRoles = await loadRoles(app)
970
+
971
+ const roles = [
972
+ { name: 'admin', builtIn: true, permissionCount: 0 },
973
+ ...Object.entries(savedRoles).map(([name, perms]) => ({
974
+ name,
975
+ builtIn: (BUILT_IN_ROLES as readonly string[]).includes(name),
976
+ permissionCount: Object.values(perms).flat().length,
977
+ })),
978
+ ]
979
+
980
+ return (
981
+ <div className="p-6">
982
+ <div className="mb-6">
983
+ <h1 className="text-2xl font-bold">Roles</h1>
984
+ <p className="text-sm text-muted-foreground">
985
+ Manage user roles. Built-in roles cannot be deleted.
986
+ </p>
987
+ </div>
988
+ <RolesEditor roles={roles} permissionsHref={\`/\${locale}/admin/permissions\`} />
989
+ </div>
990
+ )
991
+ }
992
+ `),await h(r(e,`app/[locale]/(shell)/admin/activity/page.tsx`),`import { AuditLog } from '@murumets-ee/admin-ui/audit-log'
993
+ import { fetchAuditLogData } from '@murumets-ee/admin-ui/server'
994
+ import { setRequestLocale } from 'next-intl/server'
995
+ import { withAdminContext } from '@/lib/with-admin-context'
996
+
997
+ export default async function ActivityPage({ params }: { params: Promise<{ locale: string }> }) {
998
+ const { locale } = await params
999
+ setRequestLocale(locale)
1000
+
1001
+ return withAdminContext(locale, async () => {
1002
+ const initialData = await fetchAuditLogData()
1003
+
1004
+ return (
1005
+ <div className="p-6">
1006
+ <div className="mb-6">
1007
+ <h1 className="text-2xl font-bold">Activity Log</h1>
1008
+ <p className="text-sm text-muted-foreground">
1009
+ Track all content changes across your CMS.
1010
+ </p>
1011
+ </div>
1012
+ <AuditLog
1013
+ initialData={initialData}
1014
+ editHrefPattern={\`/\${locale}/admin/:entityType/:entityId\`}
1015
+ />
1016
+ </div>
1017
+ )
1018
+ })
1019
+ }
1020
+ `),await h(r(e,`app/api/admin/[...path]/route.ts`),`import { createAdminApiHandler } from '@murumets-ee/admin-ui/server'
1021
+ import { buildPermissionChecker, buildResourceCatalog } from '@murumets-ee/auth'
1022
+ import { permissionRoutes } from '@murumets-ee/auth/admin'
1023
+ import { ContentClient } from '@murumets-ee/content/client'
1024
+ import { LockService } from '@murumets-ee/content/lock'
1025
+ import type { PermissionChecker } from '@murumets-ee/core'
1026
+ import { getApp } from '@murumets-ee/core'
1027
+ import {
1028
+ AuditLogClient,
1029
+ createAuditDbWriter,
1030
+ createAuditLogger,
1031
+ createLogger,
1032
+ } from '@murumets-ee/logging'
1033
+ import { logRoutes } from '@murumets-ee/logging/admin'
1034
+ import { mediaRoutes } from '@murumets-ee/media/admin'
1035
+ import { createSettingsClient } from '@murumets-ee/settings'
1036
+ import { settingsRoutes } from '@murumets-ee/settings/admin'
1037
+ import { storageRoutes } from '@murumets-ee/storage/admin'
1038
+ import { taxonomyRoutes } from '@murumets-ee/taxonomy/admin'
1039
+ import {
1040
+ allEntities,
1041
+ crudEntities,
1042
+ pluginResources,
1043
+ taxonomyVocabularies,
1044
+ } from '@/lib/admin-config'
1045
+ import { getToolkitApp } from '@/lib/app'
1046
+ import { auth } from '@/lib/auth'
1047
+ import { loadRoles } from '@/lib/load-roles'
1048
+ import { permissionSettings } from '@/settings/permissions'
1049
+ import { siteSettings } from '@/settings/site'
1050
+
1051
+ await getToolkitApp()
1052
+
1053
+ let _auditLogger: ReturnType<typeof createAuditLogger> | null = null
1054
+ let _checker: PermissionChecker | null = null
1055
+
1056
+ const routes = [
1057
+ mediaRoutes(),
1058
+ storageRoutes(),
1059
+ settingsRoutes(siteSettings),
1060
+ taxonomyRoutes(taxonomyVocabularies),
1061
+ logRoutes(() => new AuditLogClient(getApp().db.readWrite)),
1062
+ permissionRoutes({
1063
+ getStatements: () => buildResourceCatalog(allEntities, pluginResources),
1064
+ loadRoles: async () => loadRoles(getApp()),
1065
+ saveRoles: async (roles) => {
1066
+ const app = getApp()
1067
+ const client = createSettingsClient(permissionSettings, { app })
1068
+ await client.set('roles', roles)
1069
+ },
1070
+ onSave: () => {
1071
+ _checker = null
1072
+ },
1073
+ }),
1074
+ ]
1075
+
1076
+ const handler = createAdminApiHandler({
1077
+ authenticate: async (req) => {
1078
+ const session = await auth.api.getSession({ headers: req.headers })
1079
+ if (!session?.user) return null
1080
+ const role = (session.user as Record<string, unknown>).role as string | undefined
1081
+ return { id: session.user.id, role, name: session.user.name, email: session.user.email }
1082
+ },
1083
+ defaultLocale: 'en',
1084
+ entities: crudEntities,
1085
+ routes,
1086
+ loadPermissions: async () => {
1087
+ if (_checker) return _checker
1088
+ const roles = await loadRoles(getApp())
1089
+ _checker = buildPermissionChecker(roles)
1090
+ return _checker
1091
+ },
1092
+ auditLogger: {
1093
+ log: async (entry) => {
1094
+ if (!_auditLogger) {
1095
+ const app = getApp()
1096
+ _auditLogger = createAuditLogger({
1097
+ logger: createLogger({ name: 'audit' }),
1098
+ dbWriter: createAuditDbWriter(app.db.readWrite),
1099
+ })
1100
+ }
1101
+ return _auditLogger.log(entry)
1102
+ },
1103
+ },
1104
+ contentClientFactory: (entity) =>
1105
+ new ContentClient({ entity, db: getApp().db.readWrite }),
1106
+ lockServiceFactory: () =>
1107
+ new LockService({ db: getApp().db.readWrite }),
1108
+ })
1109
+
1110
+ export const { GET, POST, PATCH, DELETE } = handler
1111
+ `)}async function x(e,t){await h(r(e,`lib/auth.ts`),`import { getToolkitApp } from './app'
1112
+ import { getAuth } from '@murumets-ee/auth'
1113
+
1114
+ export async function getAuthInstance() {
1115
+ await getToolkitApp()
1116
+ return getAuth()
1117
+ }
1118
+ `),await h(r(e,`lib/auth-client.ts`),`import { createClient } from '@murumets-ee/auth/client'
1119
+
1120
+ export const authClient = createClient()
1121
+ `),await h(r(e,`app/api/auth/[...all]/route.ts`),`import { toNextJsHandler } from 'better-auth/next-js'
1122
+ import { getAuthInstance } from '../../../../lib/auth'
1123
+
1124
+ let _handler: ReturnType<typeof toNextJsHandler> | null = null
1125
+
1126
+ async function handler() {
1127
+ if (!_handler) {
1128
+ const auth = await getAuthInstance()
1129
+ _handler = toNextJsHandler(auth)
1130
+ }
1131
+ return _handler
1132
+ }
1133
+
1134
+ export async function GET(req: Request) {
1135
+ const h = await handler()
1136
+ return h.GET(req)
1137
+ }
1138
+
1139
+ export async function POST(req: Request) {
1140
+ const h = await handler()
1141
+ return h.POST(req)
1142
+ }
1143
+ `),await h(r(e,`app/[locale]/auth/layout.tsx`),`import { AuthProviders } from './providers'
1144
+ import type { ReactNode } from 'react'
1145
+
1146
+ export default function AuthLayout({ children }: { children: ReactNode }) {
1147
+ return (
1148
+ <AuthProviders>
1149
+ <div className="flex min-h-[calc(100vh-3rem)] items-center justify-center px-4">
1150
+ {children}
1151
+ </div>
1152
+ </AuthProviders>
1153
+ )
1154
+ }
1155
+ `),await h(r(e,`app/[locale]/auth/providers.tsx`),`'use client'
1156
+
1157
+ import { AuthUIProvider } from '@murumets-ee/auth-ui'
1158
+ import { authClient } from '@/lib/auth-client'
1159
+ import Link from 'next/link'
1160
+ import { useRouter } from 'next/navigation'
1161
+ import { useLocale } from 'next-intl'
1162
+ import type { ReactNode } from 'react'
1163
+
1164
+ export function AuthProviders({ children }: { children: ReactNode }) {
1165
+ const router = useRouter()
1166
+ const locale = useLocale()
1167
+
1168
+ return (
1169
+ <AuthUIProvider
1170
+ authClient={authClient as never}
1171
+ basePath="/auth"
1172
+ redirectTo="/"
1173
+ Link={Link}
1174
+ navigate={(url) => router.push(url)}
1175
+ resetPasswordUrl={\`/\${locale}/auth/reset-password\`}
1176
+ >
1177
+ {children}
1178
+ </AuthUIProvider>
1179
+ )
1180
+ }
1181
+ `),await h(r(e,`app/[locale]/auth/sign-in/page.tsx`),`import { SignInForm } from '@murumets-ee/auth-ui'
1182
+
1183
+ export default function SignInPage() {
1184
+ return <SignInForm />
1185
+ }
1186
+ `),await h(r(e,`app/[locale]/auth/sign-up/page.tsx`),`import { SignUpForm } from '@murumets-ee/auth-ui'
1187
+
1188
+ export default function SignUpPage() {
1189
+ return <SignUpForm />
1190
+ }
1191
+ `),await h(r(e,`app/[locale]/auth/forgot-password/page.tsx`),`import { ForgotPasswordForm } from '@murumets-ee/auth-ui'
1192
+
1193
+ export default function ForgotPasswordPage() {
1194
+ return <ForgotPasswordForm />
1195
+ }
1196
+ `),await h(r(e,`app/[locale]/auth/reset-password/page.tsx`),`import { Suspense } from 'react'
1197
+ import { ResetPasswordContent } from './content'
1198
+
1199
+ export default function ResetPasswordPage() {
1200
+ return (
1201
+ <Suspense>
1202
+ <ResetPasswordContent />
1203
+ </Suspense>
1204
+ )
1205
+ }
1206
+ `),await h(r(e,`app/[locale]/auth/reset-password/content.tsx`),`'use client'
1207
+
1208
+ import { useSearchParams } from 'next/navigation'
1209
+ import { ResetPasswordForm } from '@murumets-ee/auth-ui'
1210
+
1211
+ export function ResetPasswordContent() {
1212
+ const searchParams = useSearchParams()
1213
+ const token = searchParams.get('token')
1214
+
1215
+ if (!token) {
1216
+ return (
1217
+ <div className="text-center">
1218
+ <h1 className="text-2xl font-bold text-zinc-900 dark:text-zinc-50">
1219
+ Invalid or expired link
1220
+ </h1>
1221
+ <p className="mt-2 text-zinc-500">
1222
+ Please request a new password reset.
1223
+ </p>
1224
+ </div>
1225
+ )
1226
+ }
1227
+
1228
+ return <ResetPasswordForm token={token} />
1229
+ }
1230
+ `),await h(r(e,`app/[locale]/setup/page.tsx`),`import { redirect } from 'next/navigation'
1231
+ import { sql } from 'drizzle-orm'
1232
+ import { getToolkitApp } from '@/lib/app'
1233
+ import { SetupForm } from './form'
1234
+
1235
+ export default async function SetupPage() {
1236
+ const app = await getToolkitApp()
1237
+ const result = await app.db.readOnly.execute<{ count: string }>(
1238
+ sql\`SELECT COUNT(*)::text as count FROM "user"\`,
1239
+ )
1240
+
1241
+ if (Number(result[0]?.count) > 0) {
1242
+ redirect('/')
1243
+ }
1244
+
1245
+ return (
1246
+ <div className="max-w-md mx-auto p-8">
1247
+ <h1 className="text-2xl font-bold mb-2">Create Admin</h1>
1248
+ <p className="text-sm text-zinc-500 dark:text-zinc-400 mb-6">
1249
+ No users found. Create the first admin account.
1250
+ </p>
1251
+ <SetupForm />
1252
+ </div>
1253
+ )
1254
+ }
1255
+ `),await h(r(e,`app/[locale]/setup/form.tsx`),`'use client'
1256
+
1257
+ import { useState } from 'react'
1258
+ import { createFirstAdmin } from './actions'
1259
+
1260
+ export function SetupForm() {
1261
+ const [result, setResult] = useState<{ ok?: boolean; error?: string; email?: string } | null>(null)
1262
+ const [loading, setLoading] = useState(false)
1263
+
1264
+ async function handleSubmit(e: React.FormEvent<HTMLFormElement>) {
1265
+ e.preventDefault()
1266
+ setLoading(true)
1267
+ setResult(null)
1268
+ const res = await createFirstAdmin(new FormData(e.currentTarget))
1269
+ setResult(res)
1270
+ setLoading(false)
1271
+ }
1272
+
1273
+ if (result?.ok) {
1274
+ return (
1275
+ <div className="space-y-2">
1276
+ <p className="text-green-600 dark:text-green-400">Admin created: {result.email}</p>
1277
+ <a href="/auth/sign-in" className="text-blue-600 dark:text-blue-400 hover:underline">
1278
+ Sign in &rarr;
1279
+ </a>
1280
+ </div>
1281
+ )
1282
+ }
1283
+
1284
+ return (
1285
+ <form onSubmit={handleSubmit} className="flex flex-col gap-4">
1286
+ <label className="text-sm font-medium">
1287
+ Name
1288
+ <input
1289
+ name="name"
1290
+ required
1291
+ className="mt-1 block w-full px-3 py-2 bg-zinc-100 dark:bg-zinc-900 border border-zinc-300 dark:border-zinc-700 rounded-md text-sm focus:outline-none focus:ring-1 focus:ring-blue-500"
1292
+ />
1293
+ </label>
1294
+ <label className="text-sm font-medium">
1295
+ Email
1296
+ <input
1297
+ name="email"
1298
+ type="email"
1299
+ required
1300
+ className="mt-1 block w-full px-3 py-2 bg-zinc-100 dark:bg-zinc-900 border border-zinc-300 dark:border-zinc-700 rounded-md text-sm focus:outline-none focus:ring-1 focus:ring-blue-500"
1301
+ />
1302
+ </label>
1303
+ <label className="text-sm font-medium">
1304
+ Password (min 8 chars)
1305
+ <input
1306
+ name="password"
1307
+ type="password"
1308
+ required
1309
+ minLength={8}
1310
+ className="mt-1 block w-full px-3 py-2 bg-zinc-100 dark:bg-zinc-900 border border-zinc-300 dark:border-zinc-700 rounded-md text-sm focus:outline-none focus:ring-1 focus:ring-blue-500"
1311
+ />
1312
+ </label>
1313
+
1314
+ {result?.error && <p className="text-red-600 dark:text-red-400 text-sm">{result.error}</p>}
1315
+
1316
+ <button
1317
+ type="submit"
1318
+ disabled={loading}
1319
+ className="px-4 py-2 text-sm rounded-md bg-blue-600 text-white hover:bg-blue-500 disabled:opacity-50 transition-colors"
1320
+ >
1321
+ {loading ? 'Creating...' : 'Create Admin'}
1322
+ </button>
1323
+ </form>
1324
+ )
1325
+ }
1326
+ `),await h(r(e,`app/[locale]/setup/actions.ts`),`'use server'
1327
+
1328
+ import { sql } from 'drizzle-orm'
1329
+ import { getToolkitApp } from '@/lib/app'
1330
+ import { getAuth } from '@murumets-ee/auth'
1331
+
1332
+ /**
1333
+ * Create the first admin user. Locked down:
1334
+ * - Advisory lock prevents race conditions (two simultaneous requests)
1335
+ * - User count check inside the lock ensures only one admin can be created
1336
+ * - Once any user exists, this action permanently refuses
1337
+ */
1338
+ export async function createFirstAdmin(formData: FormData) {
1339
+ const email = formData.get('email') as string
1340
+ const password = formData.get('password') as string
1341
+ const name = formData.get('name') as string
1342
+
1343
+ if (!email || !password || !name) {
1344
+ return { error: 'All fields are required' }
1345
+ }
1346
+
1347
+ if (password.length < 8) {
1348
+ return { error: 'Password must be at least 8 characters' }
1349
+ }
1350
+
1351
+ const app = await getToolkitApp()
1352
+
1353
+ // Acquire advisory lock + check atomically in a transaction
1354
+ const canCreate = await app.db.readWrite.transaction(async (tx) => {
1355
+ // Advisory lock 1 = "setup lock". Blocks concurrent setup attempts.
1356
+ await tx.execute(sql\`SELECT pg_advisory_xact_lock(1)\`)
1357
+
1358
+ const result = await tx.execute<{ count: string }>(
1359
+ sql\`SELECT COUNT(*)::text as count FROM "user"\`,
1360
+ )
1361
+ return Number(result[0]?.count) === 0
1362
+ })
1363
+
1364
+ if (!canCreate) {
1365
+ return { error: 'Admin user already exists. Setup is complete.' }
1366
+ }
1367
+
1368
+ const auth = getAuth()
1369
+
1370
+ const adminUser = await auth.api.signUpEmail({
1371
+ body: { email, password, name },
1372
+ })
1373
+
1374
+ await app.db.readWrite.execute(
1375
+ sql\`UPDATE "user" SET role = 'admin' WHERE id = \${adminUser.user.id}\`,
1376
+ )
1377
+
1378
+ return { ok: true, email: adminUser.user.email }
1379
+ }
1380
+ `)}async function S(e,t){let{name:n}=t;await h(r(e,`.env.example`),`DATABASE_URL=postgresql://${n}:${n}_dev_password@localhost:5432/${n}_dev
1381
+ BETTER_AUTH_SECRET=dev-secret-change-me-in-production-min-32-chars
1382
+ BETTER_AUTH_URL=http://localhost:3000
1383
+ LOG_LEVEL=debug
1384
+ NEXT_PUBLIC_APP_URL=http://localhost:3000
1385
+ # Queue worker — by default runs embedded in the web process.
1386
+ # Set to "false" in production and run "pnpm worker" as a separate process.
1387
+ # QUEUE_WORKER=false
1388
+ RESEND_API_KEY=
1389
+ RESEND_WEBHOOK_SECRET=
1390
+ MAIL_FROM=noreply@example.com
1391
+ CSAT_SECRET=
1392
+ `),await h(r(e,`.dockerignore`),`# Dependencies (installed inside Docker)
1393
+ node_modules/
1394
+ .pnpm-store/
1395
+
1396
+ # Build outputs (rebuilt inside Docker)
1397
+ .next/
1398
+ out/
1399
+ dist/
1400
+
1401
+ # Git
1402
+ .git/
1403
+ .gitignore
1404
+
1405
+ # Environment files (pass via docker run --env-file)
1406
+ .env
1407
+ .env.*
1408
+ !.env.example
1409
+
1410
+ # Docker files
1411
+ Dockerfile*
1412
+ .dockerignore
1413
+ docker-compose*.yml
1414
+
1415
+ # Tests
1416
+ coverage/
1417
+ **/*.test.*
1418
+ **/*.spec.*
1419
+ **/vitest.config.*
1420
+ docker-compose.test.yml
1421
+
1422
+ # Development tooling
1423
+ .vscode/
1424
+ .idea/
1425
+ .turbo/
1426
+ .cache/
1427
+ *.tsbuildinfo
1428
+
1429
+ # Documentation
1430
+ *.md
1431
+ docs/
1432
+
1433
+ # OS files
1434
+ .DS_Store
1435
+ Thumbs.db
1436
+ `),await h(r(e,`Dockerfile`),`# --- Base image ---
1437
+ # Node 22 LTS (Debian slim — glibc required for sharp image optimization)
1438
+ FROM node:22-slim AS base
1439
+
1440
+ # --- Stage 1: Install dependencies ---
1441
+ FROM base AS deps
1442
+ WORKDIR /app
1443
+ RUN corepack enable pnpm
1444
+ COPY package.json pnpm-lock.yaml ./
1445
+ RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store \\
1446
+ pnpm install --frozen-lockfile
1447
+
1448
+ # --- Stage 2: Build the application ---
1449
+ FROM base AS builder
1450
+ WORKDIR /app
1451
+ RUN corepack enable pnpm
1452
+ COPY --from=deps /app/node_modules ./node_modules
1453
+ COPY . .
1454
+ ENV NODE_ENV=production
1455
+ ENV NEXT_TELEMETRY_DISABLED=1
1456
+ # Dummy env vars so toolkit.config.ts doesn't throw at build time (no DB connection needed)
1457
+ ENV DATABASE_URL=postgresql://build:build@localhost:5432/build
1458
+ ENV BETTER_AUTH_SECRET=build-secret-not-used-at-runtime
1459
+ RUN pnpm build
1460
+
1461
+ # --- Stage 3: Production runner ---
1462
+ FROM base AS runner
1463
+ WORKDIR /app
1464
+ ENV NODE_ENV=production
1465
+ ENV PORT=3000
1466
+ ENV HOSTNAME=0.0.0.0
1467
+ ENV NEXT_TELEMETRY_DISABLED=1
1468
+
1469
+ # Copy standalone output (includes server.js + traced node_modules)
1470
+ COPY --from=builder --chown=node:node /app/.next/standalone ./
1471
+ # Copy static assets (JS/CSS chunks — excluded from standalone trace)
1472
+ COPY --from=builder --chown=node:node /app/.next/static ./.next/static
1473
+ # Copy public assets (favicon, robots.txt, images)
1474
+ COPY --from=builder --chown=node:node /app/public ./public
1475
+ # Copy migrations (applied at app startup by the toolkit migration runner)
1476
+ COPY --from=builder --chown=node:node /app/migrations ./migrations
1477
+
1478
+ # Run as non-root user
1479
+ USER node
1480
+ EXPOSE 3000
1481
+ CMD ["node", "server.js"]
1482
+ `),await h(r(e,`docker-compose.yml`),`services:
1483
+ postgres:
1484
+ image: postgres:17-alpine
1485
+ container_name: ${n}-postgres
1486
+ restart: unless-stopped
1487
+ environment:
1488
+ POSTGRES_USER: ${n}
1489
+ POSTGRES_PASSWORD: ${n}_dev_password
1490
+ POSTGRES_DB: ${n}_dev
1491
+ ports:
1492
+ - "5432:5432"
1493
+ volumes:
1494
+ - postgres_data:/var/lib/postgresql/data
1495
+ healthcheck:
1496
+ test: ["CMD-SHELL", "pg_isready -U ${n} -d ${n}_dev"]
1497
+ interval: 10s
1498
+ timeout: 5s
1499
+ retries: 5
1500
+
1501
+ volumes:
1502
+ postgres_data:
1503
+ name: ${n}_postgres_data
1504
+ `),await h(r(e,`docker-compose.prod.yml`),`services:
1505
+ app:
1506
+ build: .
1507
+ restart: unless-stopped
1508
+ env_file: .env
1509
+ depends_on:
1510
+ postgres:
1511
+ condition: service_healthy
1512
+ ports:
1513
+ - "3000:3000"
1514
+ networks:
1515
+ - internal
1516
+
1517
+ postgres:
1518
+ image: postgres:17-alpine
1519
+ restart: unless-stopped
1520
+ environment:
1521
+ POSTGRES_USER: ${n}
1522
+ POSTGRES_PASSWORD: \${DB_PASSWORD}
1523
+ POSTGRES_DB: ${n}
1524
+ volumes:
1525
+ - postgres_data:/var/lib/postgresql/data
1526
+ healthcheck:
1527
+ test: ["CMD-SHELL", "pg_isready -U ${n} -d ${n}"]
1528
+ interval: 10s
1529
+ timeout: 5s
1530
+ retries: 5
1531
+ networks:
1532
+ - internal
1533
+
1534
+ volumes:
1535
+ postgres_data:
1536
+
1537
+ networks:
1538
+ internal:
1539
+ `),await y(r(e,`.gitignore`),`
1540
+ # Toolkit generated files
1541
+ generated/
1542
+
1543
+ # Environment
1544
+ .env*
1545
+ !.env.example
1546
+ `)}async function C(e,t){await h(r(e,`entities/index.ts`),`export { Article } from './article'
1547
+ export { Category } from './category'
1548
+ `),await h(r(e,`entities/article.ts`),`import { behavior, defineEntity, field } from '@murumets-ee/entity'
1549
+
1550
+ export const Article = defineEntity({
1551
+ name: 'article',
1552
+ fields: {
1553
+ title: field.text({ required: true, maxLength: 200, indexed: true, translatable: true }),
1554
+ slug: field.slug({ from: 'title', unique: true }),
1555
+ excerpt: field.text({ maxLength: 500, translatable: true }),
1556
+ body: field.richtext(),
1557
+ viewCount: field.number({ default: 0, integer: true }),
1558
+ featured: field.boolean({ default: false }),
1559
+ publishDate: field.date(),
1560
+ contentType: field.select({ options: ['news', 'tutorial', 'announcement'], default: 'news' }),
1561
+ category: field.reference({ entity: 'category', required: false }),
1562
+ tags: field.reference({ entity: 'category', cardinality: 'many' }),
1563
+ coverImage: field.media({ accept: ['image/*'] }),
1564
+ },
1565
+ behaviors: [
1566
+ behavior.publishable(),
1567
+ behavior.auditable(),
1568
+ behavior.sluggable('title'),
1569
+ behavior.revisionable(),
1570
+ ],
1571
+ scope: 'global',
1572
+ access: {
1573
+ view: 'public',
1574
+ create: 'group.editor',
1575
+ update: 'group.editor',
1576
+ delete: 'group.admin',
1577
+ },
1578
+ })
1579
+ `),await h(r(e,`entities/category.ts`),`import { defineEntity, field } from '@murumets-ee/entity'
1580
+
1581
+ export const Category = defineEntity({
1582
+ name: 'category',
1583
+ fields: {
1584
+ name: field.text({ required: true, maxLength: 100, indexed: true, translatable: true }),
1585
+ slug: field.slug({ from: 'name', unique: true }),
1586
+ description: field.text({ maxLength: 500, translatable: true }),
1587
+ },
1588
+ scope: 'global',
1589
+ access: {
1590
+ view: 'public',
1591
+ create: 'group.editor',
1592
+ update: 'group.editor',
1593
+ delete: 'group.admin',
1594
+ },
1595
+ })
1596
+ `)}async function w(e,t){await h(r(e,`i18n/routing.ts`),`import { defineRouting } from 'next-intl/routing'
1597
+
1598
+ export const routing = defineRouting({
1599
+ locales: ['en'],
1600
+ defaultLocale: 'en',
1601
+ })
1602
+ `),await h(r(e,`i18n/request.ts`),`import { getRequestConfig } from 'next-intl/server'
1603
+ import { hasLocale } from 'next-intl'
1604
+ import { routing } from './routing'
1605
+ import { getAuthMessages } from '@murumets-ee/auth-ui/i18n'
1606
+
1607
+ export default getRequestConfig(async ({ requestLocale }) => {
1608
+ const requested = await requestLocale
1609
+ const locale = hasLocale(routing.locales, requested)
1610
+ ? requested
1611
+ : routing.defaultLocale
1612
+
1613
+ const authMessages = await getAuthMessages(locale)
1614
+
1615
+ return {
1616
+ locale,
1617
+ messages: {
1618
+ ...authMessages,
1619
+ },
1620
+ }
1621
+ })
1622
+ `)}const T={myorgCore:`0.1.0`,myorgDb:`0.1.0`,myorgEntity:`0.1.0`,myorgLogging:`0.1.0`,myorgAuth:`0.1.0`,myorgAuthUi:`0.1.0`,myorgAdminUi:`0.1.0`,myorgContent:`0.1.0`,myorgContentApi:`0.1.0`,myorgSettings:`0.1.0`,myorgStorage:`0.1.0`,myorgMedia:`0.1.0`,myorgTaxonomy:`0.1.0`,myorgQueue:`0.1.0`,myorgMail:`0.1.0`,myorgTicketing:`0.1.0`,myorgTicketingUi:`0.1.0`,myorgEditor:`0.1.0`,myorgBlocks:`0.1.0`,myorgTokens:`0.1.0`,myorgUi:`0.1.0`,myorgCli:`0.1.0`,betterAuth:`1.4.0`,drizzleOrm:`0.45.1`,nextIntl:`4.8.2`,nextThemes:`0.4.6`,lucideReact:`0.563.0`,postgres:`3.4.5`,reactHookForm:`7.71.1`,hookformResolvers:`5.2.2`,zod:`3.24.1`,tanstackReactQuery:`5.60.5`,tanstackReactTable:`8.21.3`,drizzleKit:`0.31.10`,tsx:`4.19.2`,babelReactCompiler:`1.0.0`};async function E(e,t,n){await D(e,t),n?.(`Workspace root created`),n?.(`Creating admin app...`),await k(e,t),n?.(`Admin app created`),n?.(`Creating web app...`),await A(e,t),n?.(`Web app created`),await O(e,t),n?.(`Shared config package created`)}async function D(e,t){let{name:n}=t;await o(e,{recursive:!0}),await h(r(e,`pnpm-workspace.yaml`),`packages:
1623
+ - 'packages/*'
1624
+ - 'apps/*'
1625
+
1626
+ ignoredBuiltDependencies:
1627
+ - sharp
1628
+ - unrs-resolver
1629
+ `),await h(r(e,`package.json`),`${JSON.stringify({name:`@${n}/monorepo`,version:`0.0.0`,private:!0,type:`module`,scripts:{dev:`turbo dev`,build:`turbo build`,"db:generate":`tsx --env-file=.env packages/config/scripts/generate-schema.ts`,"db:migrate:generate":`drizzle-kit generate --config packages/config/drizzle.config.ts`,"db:migrate":`tsx --env-file=.env packages/config/scripts/migrate.ts`,"db:reset":`tsx --env-file=.env packages/config/scripts/reset-db.ts`},devDependencies:{turbo:`^2.3.3`,typescript:`^5.7.3`,tsx:`^${T.tsx}`,"drizzle-kit":`^${T.drizzleKit}`}},null,2)}\n`),await h(r(e,`.gitignore`),`# dependencies
1630
+ node_modules/
1631
+
1632
+ # build
1633
+ dist/
1634
+ .next/
1635
+ .turbo/
1636
+
1637
+ # env
1638
+ .env*
1639
+ !.env.example
1640
+
1641
+ # toolkit generated
1642
+ generated/
1643
+
1644
+ # IDE
1645
+ .vscode/
1646
+ .idea/
1647
+
1648
+ # OS
1649
+ .DS_Store
1650
+ Thumbs.db
1651
+
1652
+ # logs
1653
+ *.log
1654
+
1655
+ # migrations meta
1656
+ migrations/
1657
+
1658
+ # turbo
1659
+ .turbo/
1660
+ `),await h(r(e,`.env.example`),`DATABASE_URL=postgresql://${n}:${n}_dev_password@localhost:5432/${n}_dev
1661
+ BETTER_AUTH_SECRET=dev-secret-change-me-in-production-min-32-chars
1662
+ BETTER_AUTH_URL=http://localhost:3000
1663
+ LOG_LEVEL=debug
1664
+ NEXT_PUBLIC_APP_URL=http://localhost:3000
1665
+ QUEUE_WORKER=true
1666
+ RESEND_API_KEY=
1667
+ RESEND_WEBHOOK_SECRET=
1668
+ MAIL_FROM=noreply@example.com
1669
+ CSAT_SECRET=
1670
+ `),await h(r(e,`docker-compose.yml`),`services:
1671
+ postgres:
1672
+ image: postgres:17-alpine
1673
+ container_name: ${n}-postgres
1674
+ restart: unless-stopped
1675
+ environment:
1676
+ POSTGRES_USER: ${n}
1677
+ POSTGRES_PASSWORD: ${n}_dev_password
1678
+ POSTGRES_DB: ${n}_dev
1679
+ ports:
1680
+ - "5432:5432"
1681
+ volumes:
1682
+ - postgres_data:/var/lib/postgresql/data
1683
+ healthcheck:
1684
+ test: ["CMD-SHELL", "pg_isready -U ${n} -d ${n}_dev"]
1685
+ interval: 10s
1686
+ timeout: 5s
1687
+ retries: 5
1688
+
1689
+ volumes:
1690
+ postgres_data:
1691
+ name: ${n}_postgres_data
1692
+ `)}async function O(e,t){let{name:n}=t,i=r(e,`packages/config`);await h(r(i,`package.json`),`${JSON.stringify({name:`@${n}/config`,version:`0.1.0`,private:!0,type:`module`,exports:{".":`./toolkit.config.ts`,"./entities":`./entities/index.ts`,"./entities/*":`./entities/*`,"./app":`./lib/app.ts`,"./auth":`./lib/auth.ts`,"./auth-client":`./lib/auth-client.ts`},dependencies:{"@murumets-ee/core":`^${T.myorgCore}`,"@murumets-ee/db":`^${T.myorgDb}`,"@murumets-ee/entity":`^${T.myorgEntity}`,"@murumets-ee/logging":`^${T.myorgLogging}`,"@murumets-ee/auth":`^${T.myorgAuth}`,"better-auth":`^${T.betterAuth}`,"drizzle-orm":`^${T.drizzleOrm}`,postgres:`^${T.postgres}`,zod:`^${T.zod}`}},null,2)}\n`),await h(r(i,`tsconfig.json`),`${JSON.stringify({compilerOptions:{target:`ES2022`,module:`ESNext`,moduleResolution:`Bundler`,strict:!0,esModuleInterop:!0,skipLibCheck:!0,resolveJsonModule:!0},include:[`**/*.ts`]},null,2)}\n`),await h(r(i,`toolkit.config.ts`),`import { auth } from '@murumets-ee/auth/plugin'
1693
+ import { content } from '@murumets-ee/content/plugin'
1694
+ import { defineConfig } from '@murumets-ee/core'
1695
+ import { logging } from '@murumets-ee/logging/plugin'
1696
+ import { mail, ResendMailProvider } from '@murumets-ee/mail'
1697
+ import { media } from '@murumets-ee/media/plugin'
1698
+ import { queue } from '@murumets-ee/queue/plugin'
1699
+ import { settings } from '@murumets-ee/settings/plugin'
1700
+ import { storage } from '@murumets-ee/storage/plugin'
1701
+ import { taxonomy } from '@murumets-ee/taxonomy/plugin'
1702
+ import { ticketing } from '@murumets-ee/ticketing/plugin'
1703
+ import { Article, Category } from './entities'
1704
+ import * as authSchema from './generated/auth-schema'
1705
+
1706
+ if (!process.env.DATABASE_URL) {
1707
+ throw new Error('DATABASE_URL environment variable is required')
1708
+ }
1709
+
1710
+ export default defineConfig({
1711
+ db: {
1712
+ url: process.env.DATABASE_URL,
1713
+ poolMin: 2,
1714
+ poolMax: 10,
1715
+ },
1716
+ logging: {
1717
+ level: (process.env.LOG_LEVEL || 'info') as 'debug' | 'info' | 'warn' | 'error',
1718
+ name: '${n}',
1719
+ },
1720
+ entities: [Category, Article],
1721
+ plugins: [
1722
+ auth({ providers: ['email'], schema: authSchema }),
1723
+ content({
1724
+ locales: [{ code: 'en', label: 'English' }],
1725
+ defaultLocale: 'en',
1726
+ }),
1727
+ logging(),
1728
+ settings(),
1729
+ storage(),
1730
+ media(),
1731
+ taxonomy(),
1732
+ queue(),
1733
+ mail({
1734
+ provider: process.env.RESEND_API_KEY
1735
+ ? new ResendMailProvider({ apiKey: process.env.RESEND_API_KEY })
1736
+ : undefined,
1737
+ defaultFrom: process.env.MAIL_FROM ?? 'noreply@example.com',
1738
+ webhookSecret: process.env.RESEND_WEBHOOK_SECRET,
1739
+ }),
1740
+ ticketing({
1741
+ csatSecret: process.env.CSAT_SECRET,
1742
+ }),
1743
+ ],
1744
+ projectRoot: import.meta.dirname,
1745
+ })
1746
+ `),await h(r(i,`auth.config.ts`),`import { betterAuth } from 'better-auth'
1747
+ import { drizzleAdapter } from 'better-auth/adapters/drizzle'
1748
+ import { admin } from 'better-auth/plugins'
1749
+ import { organization } from 'better-auth/plugins/organization'
1750
+ import { drizzle } from 'drizzle-orm/postgres-js'
1751
+ import postgres from 'postgres'
1752
+
1753
+ const sql = postgres(process.env.DATABASE_URL!)
1754
+ const db = drizzle(sql)
1755
+
1756
+ export const auth = betterAuth({
1757
+ database: drizzleAdapter(db, { provider: 'pg' }),
1758
+ emailAndPassword: { enabled: true },
1759
+ plugins: [
1760
+ admin(),
1761
+ organization(),
1762
+ ],
1763
+ })
1764
+ `),await h(r(i,`drizzle.config.ts`),`import type { Config } from 'drizzle-kit'
1765
+
1766
+ if (!process.env.DATABASE_URL) {
1767
+ throw new Error('DATABASE_URL environment variable is required')
1768
+ }
1769
+
1770
+ export default {
1771
+ schema: ['./generated/schema.ts', './generated/auth-schema.ts'],
1772
+ out: './migrations',
1773
+ dialect: 'postgresql',
1774
+ dbCredentials: {
1775
+ url: process.env.DATABASE_URL,
1776
+ },
1777
+ } satisfies Config
1778
+ `),await h(r(i,`entities/index.ts`),`export { Article } from './article'
1779
+ export { Category } from './category'
1780
+ `),await h(r(i,`entities/article.ts`),`import { behavior, defineEntity, field } from '@murumets-ee/entity'
1781
+
1782
+ export const Article = defineEntity({
1783
+ name: 'article',
1784
+ fields: {
1785
+ title: field.text({ required: true, maxLength: 200, indexed: true, translatable: true }),
1786
+ slug: field.slug({ from: 'title', unique: true }),
1787
+ excerpt: field.text({ maxLength: 500, translatable: true }),
1788
+ body: field.richtext(),
1789
+ viewCount: field.number({ default: 0, integer: true }),
1790
+ featured: field.boolean({ default: false }),
1791
+ publishDate: field.date(),
1792
+ contentType: field.select({ options: ['news', 'tutorial', 'announcement'], default: 'news' }),
1793
+ category: field.reference({ entity: 'category', required: false }),
1794
+ tags: field.reference({ entity: 'category', cardinality: 'many' }),
1795
+ coverImage: field.media({ accept: ['image/*'] }),
1796
+ },
1797
+ behaviors: [
1798
+ behavior.publishable(),
1799
+ behavior.auditable(),
1800
+ behavior.sluggable('title'),
1801
+ behavior.revisionable(),
1802
+ ],
1803
+ scope: 'global',
1804
+ access: {
1805
+ view: 'public',
1806
+ create: 'group.editor',
1807
+ update: 'group.editor',
1808
+ delete: 'group.admin',
1809
+ },
1810
+ })
1811
+ `),await h(r(i,`entities/category.ts`),`import { defineEntity, field } from '@murumets-ee/entity'
1812
+
1813
+ export const Category = defineEntity({
1814
+ name: 'category',
1815
+ fields: {
1816
+ name: field.text({ required: true, maxLength: 100, indexed: true, translatable: true }),
1817
+ slug: field.slug({ from: 'name', unique: true }),
1818
+ description: field.text({ maxLength: 500, translatable: true }),
1819
+ },
1820
+ scope: 'global',
1821
+ access: {
1822
+ view: 'public',
1823
+ create: 'group.editor',
1824
+ update: 'group.editor',
1825
+ delete: 'group.admin',
1826
+ },
1827
+ })
1828
+ `),await h(r(i,`lib/app.ts`),`import { createApp, setApp, type ToolkitApp } from '@murumets-ee/core'
1829
+ import config from '../toolkit.config'
1830
+
1831
+ let appInstance: ToolkitApp | null = null
1832
+
1833
+ export async function getToolkitApp(): Promise<ToolkitApp> {
1834
+ if (!appInstance) {
1835
+ appInstance = await createApp(config)
1836
+ setApp(appInstance)
1837
+ }
1838
+ return appInstance
1839
+ }
1840
+ `),await h(r(i,`lib/auth.ts`),`import { getToolkitApp } from './app'
1841
+ import { getAuth } from '@murumets-ee/auth'
1842
+
1843
+ export async function getAuthInstance() {
1844
+ await getToolkitApp()
1845
+ return getAuth()
1846
+ }
1847
+ `),await h(r(i,`lib/auth-client.ts`),`import { createClient } from '@murumets-ee/auth/client'
1848
+
1849
+ export const authClient = createClient()
1850
+ `),await h(r(i,`generated/auth-schema.ts`),`// This file is generated by better-auth CLI.
1851
+ // Run: npx @better-auth/cli generate --config auth.config.ts -y
1852
+ export {}
1853
+ `),await h(r(i,`scripts/generate-schema.ts`),`/**
1854
+ * Generate Drizzle schemas from entity definitions
1855
+ */
1856
+
1857
+ import { mkdir, writeFile } from 'node:fs/promises'
1858
+ import { join } from 'node:path'
1859
+ import { generateSchemaCode, generateTranslationSchemaCode } from '@murumets-ee/entity'
1860
+ import config from '../toolkit.config'
1861
+
1862
+ async function generateSchemas() {
1863
+ console.log('Generating Drizzle schemas from entity definitions...')
1864
+
1865
+ const schemaDir = join(import.meta.dirname, '..', 'generated')
1866
+ await mkdir(schemaDir, { recursive: true })
1867
+
1868
+ const imports: string[] = []
1869
+ const schemas: string[] = []
1870
+ let hasTranslations = false
1871
+
1872
+ for (const entity of config.entities) {
1873
+ console.log(\` - Generating schema for \${entity.name}\`)
1874
+
1875
+ const schemaCode = generateSchemaCode(entity)
1876
+ schemas.push(\`\\n// \${entity.name} table\`)
1877
+ schemas.push(schemaCode)
1878
+
1879
+ const translationCode = generateTranslationSchemaCode(entity)
1880
+ if (translationCode) {
1881
+ hasTranslations = true
1882
+ schemas.push(\`\\n// \${entity.name} translations\`)
1883
+ schemas.push(translationCode)
1884
+ }
1885
+ }
1886
+
1887
+ const pgCoreTypes = ['pgTable', 'varchar', 'text', 'boolean', 'timestamp', 'integer', 'doublePrecision', 'jsonb', 'uuid', 'index']
1888
+ if (hasTranslations) pgCoreTypes.push('unique')
1889
+ const pgCoreImports = \`import { \${pgCoreTypes.join(', ')} } from 'drizzle-orm/pg-core'\\n\`
1890
+ imports.push(pgCoreImports)
1891
+
1892
+ const schemaFile = join(schemaDir, 'schema.ts')
1893
+ await writeFile(schemaFile, [...imports, ...schemas].join('\\n'))
1894
+
1895
+ console.log(\`\\nSchemas written to: \${schemaFile}\`)
1896
+ console.log('Run \\\`pnpm db:migrate:generate\\\` to create migrations')
1897
+ }
1898
+
1899
+ generateSchemas().catch(console.error)
1900
+ `),await h(r(i,`scripts/migrate.ts`),`/**
1901
+ * Run pending migrations
1902
+ */
1903
+
1904
+ import { createDbClient, runMigrations } from '@murumets-ee/db'
1905
+
1906
+ async function migrate() {
1907
+ console.log('Running migrations...')
1908
+
1909
+ try {
1910
+ if (!process.env.DATABASE_URL) {
1911
+ throw new Error('DATABASE_URL environment variable is required')
1912
+ }
1913
+
1914
+ const db = createDbClient({ url: process.env.DATABASE_URL })
1915
+ await runMigrations(db, import.meta.dirname + '/..')
1916
+
1917
+ console.log('Migrations completed successfully')
1918
+ process.exit(0)
1919
+ } catch (error) {
1920
+ console.error('Migration failed:', error)
1921
+ process.exit(1)
1922
+ }
1923
+ }
1924
+
1925
+ migrate()
1926
+ `),await h(r(i,`scripts/reset-db.ts`),`/**
1927
+ * Reset database (DROP all tables)
1928
+ * WARNING: Only for development
1929
+ */
1930
+
1931
+ import postgres from 'postgres'
1932
+
1933
+ async function resetDb() {
1934
+ const DATABASE_URL = process.env.DATABASE_URL
1935
+
1936
+ if (!DATABASE_URL) {
1937
+ throw new Error('DATABASE_URL not set')
1938
+ }
1939
+
1940
+ console.warn('WARNING: This will DROP ALL TABLES')
1941
+ console.log('Database:', DATABASE_URL.split('@')[1])
1942
+
1943
+ const sql = postgres(DATABASE_URL)
1944
+
1945
+ try {
1946
+ await sql\`
1947
+ DROP SCHEMA public CASCADE;
1948
+ CREATE SCHEMA public;
1949
+ GRANT ALL ON SCHEMA public TO PUBLIC;
1950
+ \`
1951
+
1952
+ console.log('Database reset complete')
1953
+ } finally {
1954
+ await sql.end()
1955
+ }
1956
+ }
1957
+
1958
+ resetDb().catch(console.error)
1959
+ `)}async function k(e,t){let{name:n}=t,i=r(e,`apps/admin`);await o(r(e,`apps`),{recursive:!0}),v(`pnpm create next-app@16 ${i} --typescript --tailwind --no-eslint --app --no-src-dir --turbopack --react-compiler --skip-install --import-alias "@/*"`),await _(i,[`app/page.tsx`,`app/page.module.css`,`app/fonts`,`README.md`,`pnpm-workspace.yaml`]),await g(r(i,`package.json`),{dependencies:{[`@${n}/config`]:`workspace:*`,"@murumets-ee/auth-ui":`^${T.myorgAuthUi}`,"better-auth":`^${T.betterAuth}`,"next-intl":`^${T.nextIntl}`,"next-themes":`^${T.nextThemes}`,"lucide-react":`^${T.lucideReact}`,"react-hook-form":`^${T.reactHookForm}`,"@hookform/resolvers":`^${T.hookformResolvers}`,zod:`^${T.zod}`},devDependencies:{"babel-plugin-react-compiler":T.babelReactCompiler}});let{appendToFile:a}=await Promise.resolve().then(()=>m);await a(r(i,`.gitignore`),`
1960
+ # Environment
1961
+ .env*
1962
+ !.env.example
1963
+ `),await h(r(i,`next.config.ts`),`import type { NextConfig } from 'next'
1964
+ import createNextIntlPlugin from 'next-intl/plugin'
1965
+
1966
+ const withNextIntl = createNextIntlPlugin('./i18n/request.ts')
1967
+
1968
+ const nextConfig: NextConfig = {
1969
+ reactCompiler: true,
1970
+ transpilePackages: [
1971
+ '@${n}/config',
1972
+ '@murumets-ee/core',
1973
+ '@murumets-ee/entity',
1974
+ '@murumets-ee/db',
1975
+ '@murumets-ee/logging',
1976
+ '@murumets-ee/auth-ui',
1977
+ ],
1978
+ serverExternalPackages: ['drizzle-orm', 'postgres'],
1979
+ experimental: {
1980
+ serverActions: {
1981
+ bodySizeLimit: '2mb',
1982
+ },
1983
+ },
1984
+ }
1985
+
1986
+ export default withNextIntl(nextConfig)
1987
+ `),await h(r(i,`proxy.ts`),`import { NextRequest, NextResponse } from 'next/server'
1988
+ import { getSessionCookie } from 'better-auth/cookies'
1989
+ import createMiddleware from 'next-intl/middleware'
1990
+ import { routing } from './i18n/routing'
1991
+
1992
+ const intlMiddleware = createMiddleware(routing)
1993
+
1994
+ const protectedPaths = ['/setup']
1995
+
1996
+ export function proxy(request: NextRequest) {
1997
+ const { pathname } = request.nextUrl
1998
+
1999
+ const localePattern = new RegExp(\`^/(\${routing.locales.join('|')})\`)
2000
+ const pathWithoutLocale = pathname.replace(localePattern, '') || '/'
2001
+
2002
+ if (protectedPaths.some((p) => pathWithoutLocale.startsWith(p))) {
2003
+ const session = getSessionCookie(request)
2004
+ if (!session) {
2005
+ const locale = pathname.match(localePattern)?.[1] || routing.defaultLocale
2006
+ return NextResponse.redirect(new URL(\`/\${locale}/auth/sign-in\`, request.url))
2007
+ }
2008
+ }
2009
+
2010
+ return intlMiddleware(request)
2011
+ }
2012
+
2013
+ export const config = {
2014
+ matcher: '/((?!api|_next|_vercel|.*\\\\..*).*)',
2015
+ }
2016
+ `),await h(r(i,`i18n/routing.ts`),`import { defineRouting } from 'next-intl/routing'
2017
+
2018
+ export const routing = defineRouting({
2019
+ locales: ['en'],
2020
+ defaultLocale: 'en',
2021
+ })
2022
+ `),await h(r(i,`i18n/request.ts`),`import { getRequestConfig } from 'next-intl/server'
2023
+ import { hasLocale } from 'next-intl'
2024
+ import { routing } from './routing'
2025
+ import { getAuthMessages } from '@murumets-ee/auth-ui/i18n'
2026
+
2027
+ export default getRequestConfig(async ({ requestLocale }) => {
2028
+ const requested = await requestLocale
2029
+ const locale = hasLocale(routing.locales, requested)
2030
+ ? requested
2031
+ : routing.defaultLocale
2032
+
2033
+ const authMessages = await getAuthMessages(locale)
2034
+
2035
+ return {
2036
+ locale,
2037
+ messages: {
2038
+ ...authMessages,
2039
+ },
2040
+ }
2041
+ })
2042
+ `),await h(r(i,`app/globals.css`),`@import "tailwindcss";
2043
+ @source "../node_modules/@murumets-ee/auth-ui/dist";
2044
+
2045
+ @custom-variant dark (&:where(.dark, .dark *));
2046
+
2047
+ :root {
2048
+ --background: #ffffff;
2049
+ --foreground: #171717;
2050
+ }
2051
+
2052
+ @theme inline {
2053
+ --color-background: var(--background);
2054
+ --color-foreground: var(--foreground);
2055
+ --font-sans: var(--font-geist-sans);
2056
+ --font-mono: var(--font-geist-mono);
2057
+ }
2058
+
2059
+ .dark {
2060
+ --background: #0a0a0a;
2061
+ --foreground: #ededed;
2062
+ }
2063
+
2064
+ body {
2065
+ background: var(--background);
2066
+ color: var(--foreground);
2067
+ font-family: Arial, Helvetica, sans-serif;
2068
+ }
2069
+ `),await h(r(i,`app/theme-provider.tsx`),`'use client'
2070
+
2071
+ import { ThemeProvider as NextThemesProvider } from 'next-themes'
2072
+ import type { ReactNode } from 'react'
2073
+
2074
+ export function ThemeProvider({ children }: { children: ReactNode }) {
2075
+ return (
2076
+ <NextThemesProvider
2077
+ attribute="class"
2078
+ defaultTheme="system"
2079
+ enableSystem
2080
+ disableTransitionOnChange
2081
+ >
2082
+ {children}
2083
+ </NextThemesProvider>
2084
+ )
2085
+ }
2086
+ `),await h(r(i,`app/theme-toggle.tsx`),`'use client'
2087
+
2088
+ import { useTheme } from 'next-themes'
2089
+ import { useState, useEffect } from 'react'
2090
+ import { Sun, Moon } from 'lucide-react'
2091
+
2092
+ export function ThemeToggle() {
2093
+ const [mounted, setMounted] = useState(false)
2094
+ const { resolvedTheme, setTheme } = useTheme()
2095
+
2096
+ useEffect(() => { setMounted(true) }, [])
2097
+
2098
+ if (!mounted) {
2099
+ return <div className="h-8 w-8" />
2100
+ }
2101
+
2102
+ return (
2103
+ <button
2104
+ type="button"
2105
+ onClick={() => setTheme(resolvedTheme === 'dark' ? 'light' : 'dark')}
2106
+ className="rounded-md p-1.5 text-zinc-400 transition-colors hover:bg-zinc-100 hover:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-200 cursor-pointer"
2107
+ aria-label={resolvedTheme === 'dark' ? 'Switch to light mode' : 'Switch to dark mode'}
2108
+ >
2109
+ {resolvedTheme === 'dark' ? <Sun className="h-5 w-5" /> : <Moon className="h-5 w-5" />}
2110
+ </button>
2111
+ )
2112
+ }
2113
+ `),await h(r(i,`app/nav-header.tsx`),`'use client'
2114
+
2115
+ import Link from 'next/link'
2116
+ import { usePathname } from 'next/navigation'
2117
+ import { ThemeToggle } from './theme-toggle'
2118
+
2119
+ const links = [
2120
+ { href: '/', label: 'Home' },
2121
+ { href: '/auth/sign-in', label: 'Sign In' },
2122
+ { href: '/setup', label: 'Setup' },
2123
+ ]
2124
+
2125
+ export function NavHeader() {
2126
+ const pathname = usePathname()
2127
+
2128
+ function isActive(href: string) {
2129
+ return href === '/' ? pathname === '/' : pathname.startsWith(href)
2130
+ }
2131
+
2132
+ const linkClass = (href: string) =>
2133
+ \`px-3 py-1.5 rounded-md text-sm transition-colors \${
2134
+ isActive(href)
2135
+ ? 'bg-zinc-200 text-zinc-900 dark:bg-zinc-800 dark:text-zinc-50'
2136
+ : 'text-zinc-500 hover:text-zinc-700 hover:bg-zinc-100 dark:text-zinc-400 dark:hover:text-zinc-200 dark:hover:bg-zinc-800/50'
2137
+ }\`
2138
+
2139
+ return (
2140
+ <header className="sticky top-0 z-50 backdrop-blur-md border-b bg-white/80 border-zinc-200 dark:bg-zinc-950/80 dark:border-zinc-800">
2141
+ <nav className="max-w-6xl mx-auto flex items-center gap-1 px-4 h-12">
2142
+ <span className="font-semibold text-sm text-zinc-700 dark:text-zinc-300 mr-3 select-none">
2143
+ ${n} Admin
2144
+ </span>
2145
+ {links.map(({ href, label }) => (
2146
+ <Link key={href} href={href} className={linkClass(href)}>
2147
+ {label}
2148
+ </Link>
2149
+ ))}
2150
+ <div className="ml-auto">
2151
+ <ThemeToggle />
2152
+ </div>
2153
+ </nav>
2154
+ </header>
2155
+ )
2156
+ }
2157
+ `),await h(r(i,`app/layout.tsx`),`import './globals.css'
2158
+
2159
+ export default function RootLayout({ children }: { children: React.ReactNode }) {
2160
+ return children
2161
+ }
2162
+ `),await h(r(i,`app/[locale]/layout.tsx`),`import type { Metadata } from 'next'
2163
+ import { Geist, Geist_Mono } from 'next/font/google'
2164
+ import { NextIntlClientProvider } from 'next-intl'
2165
+ import { getMessages } from 'next-intl/server'
2166
+ import { notFound } from 'next/navigation'
2167
+ import { routing } from '@/i18n/routing'
2168
+ import { ThemeProvider } from '../theme-provider'
2169
+ import { NavHeader } from '../nav-header'
2170
+
2171
+ const geistSans = Geist({
2172
+ variable: '--font-geist-sans',
2173
+ subsets: ['latin'],
2174
+ })
2175
+
2176
+ const geistMono = Geist_Mono({
2177
+ variable: '--font-geist-mono',
2178
+ subsets: ['latin'],
2179
+ })
2180
+
2181
+ export const metadata: Metadata = {
2182
+ title: '${n} Admin',
2183
+ description: 'Built with Lumi CMS Toolkit',
2184
+ }
2185
+
2186
+ export default async function LocaleLayout({
2187
+ children,
2188
+ params,
2189
+ }: {
2190
+ children: React.ReactNode
2191
+ params: Promise<{ locale: string }>
2192
+ }) {
2193
+ const { locale } = await params
2194
+ if (!routing.locales.includes(locale as any)) notFound()
2195
+
2196
+ const messages = await getMessages()
2197
+
2198
+ return (
2199
+ <html lang={locale} suppressHydrationWarning>
2200
+ <body className={\`\${geistSans.variable} \${geistMono.variable} antialiased\`}>
2201
+ <ThemeProvider>
2202
+ <NextIntlClientProvider locale={locale} messages={messages}>
2203
+ <NavHeader />
2204
+ {children}
2205
+ </NextIntlClientProvider>
2206
+ </ThemeProvider>
2207
+ </body>
2208
+ </html>
2209
+ )
2210
+ }
2211
+ `),await h(r(i,`app/[locale]/page.tsx`),`import { createQueryClient } from '@murumets-ee/core/clients'
2212
+ import { Article, Category } from '@${n}/config/entities'
2213
+ import { getToolkitApp } from '@${n}/config/app'
2214
+
2215
+ export default async function HomePage() {
2216
+ await getToolkitApp()
2217
+ const articles = createQueryClient(Article)
2218
+ const categories = createQueryClient(Category)
2219
+
2220
+ const [articleList, categoryList] = await Promise.all([
2221
+ articles.findMany({ limit: 10 }),
2222
+ categories.findMany({}),
2223
+ ])
2224
+
2225
+ return (
2226
+ <div className="min-h-screen p-8">
2227
+ <div className="max-w-4xl mx-auto">
2228
+ <h1 className="text-4xl font-bold mb-8">Welcome to ${n}</h1>
2229
+
2230
+ <section className="mb-12">
2231
+ <h2 className="text-2xl font-semibold mb-4">
2232
+ Categories ({categoryList.length})
2233
+ </h2>
2234
+ <div className="grid gap-4 md:grid-cols-2">
2235
+ {categoryList.map((cat) => (
2236
+ <div
2237
+ key={cat.id}
2238
+ className="border border-zinc-200 dark:border-zinc-800 rounded-lg p-4"
2239
+ >
2240
+ <h3 className="font-semibold text-lg">{cat.name}</h3>
2241
+ <p className="text-sm text-zinc-600 dark:text-zinc-400">
2242
+ {cat.description}
2243
+ </p>
2244
+ </div>
2245
+ ))}
2246
+ </div>
2247
+ </section>
2248
+
2249
+ <section>
2250
+ <h2 className="text-2xl font-semibold mb-4">
2251
+ Articles ({articleList.length})
2252
+ </h2>
2253
+ {articleList.length === 0 ? (
2254
+ <p className="text-zinc-500">No published articles yet.</p>
2255
+ ) : (
2256
+ <div className="space-y-4">
2257
+ {articleList.map((article) => (
2258
+ <div
2259
+ key={article.id}
2260
+ className="border border-zinc-200 dark:border-zinc-800 rounded-lg p-6"
2261
+ >
2262
+ <h3 className="text-xl font-bold">{article.title}</h3>
2263
+ <p className="text-zinc-600 dark:text-zinc-400 mt-2">
2264
+ {article.excerpt}
2265
+ </p>
2266
+ </div>
2267
+ ))}
2268
+ </div>
2269
+ )}
2270
+ </section>
2271
+ </div>
2272
+ </div>
2273
+ )
2274
+ }
2275
+ `),await h(r(i,`app/api/auth/[...all]/route.ts`),`import { toNextJsHandler } from 'better-auth/next-js'
2276
+ import { getAuthInstance } from '@${n}/config/auth'
2277
+
2278
+ let _handler: ReturnType<typeof toNextJsHandler> | null = null
2279
+
2280
+ async function handler() {
2281
+ if (!_handler) {
2282
+ const auth = await getAuthInstance()
2283
+ _handler = toNextJsHandler(auth)
2284
+ }
2285
+ return _handler
2286
+ }
2287
+
2288
+ export async function GET(req: Request) {
2289
+ return (await handler()).GET(req)
2290
+ }
2291
+
2292
+ export async function POST(req: Request) {
2293
+ return (await handler()).POST(req)
2294
+ }
2295
+ `),await h(r(i,`app/[locale]/auth/layout.tsx`),`import { AuthProviders } from './providers'
2296
+ import type { ReactNode } from 'react'
2297
+
2298
+ export default function AuthLayout({ children }: { children: ReactNode }) {
2299
+ return (
2300
+ <AuthProviders>
2301
+ <div className="flex min-h-[calc(100vh-3rem)] items-center justify-center px-4">
2302
+ {children}
2303
+ </div>
2304
+ </AuthProviders>
2305
+ )
2306
+ }
2307
+ `),await h(r(i,`app/[locale]/auth/providers.tsx`),`'use client'
2308
+
2309
+ import { AuthUIProvider } from '@murumets-ee/auth-ui'
2310
+ import { authClient } from '@${n}/config/auth-client'
2311
+ import Link from 'next/link'
2312
+ import { useRouter } from 'next/navigation'
2313
+ import { useLocale } from 'next-intl'
2314
+ import type { ReactNode } from 'react'
2315
+
2316
+ export function AuthProviders({ children }: { children: ReactNode }) {
2317
+ const router = useRouter()
2318
+ const locale = useLocale()
2319
+
2320
+ return (
2321
+ <AuthUIProvider
2322
+ authClient={authClient as never}
2323
+ basePath="/auth"
2324
+ redirectTo="/"
2325
+ Link={Link}
2326
+ navigate={(url) => router.push(url)}
2327
+ resetPasswordUrl={\`/\${locale}/auth/reset-password\`}
2328
+ >
2329
+ {children}
2330
+ </AuthUIProvider>
2331
+ )
2332
+ }
2333
+ `),await h(r(i,`app/[locale]/auth/sign-in/page.tsx`),`import { SignInForm } from '@murumets-ee/auth-ui'
2334
+
2335
+ export default function SignInPage() {
2336
+ return <SignInForm />
2337
+ }
2338
+ `),await h(r(i,`app/[locale]/auth/sign-up/page.tsx`),`import { SignUpForm } from '@murumets-ee/auth-ui'
2339
+
2340
+ export default function SignUpPage() {
2341
+ return <SignUpForm />
2342
+ }
2343
+ `),await h(r(i,`app/[locale]/auth/forgot-password/page.tsx`),`import { ForgotPasswordForm } from '@murumets-ee/auth-ui'
2344
+
2345
+ export default function ForgotPasswordPage() {
2346
+ return <ForgotPasswordForm />
2347
+ }
2348
+ `),await h(r(i,`app/[locale]/auth/reset-password/page.tsx`),`import { Suspense } from 'react'
2349
+ import { ResetPasswordContent } from './content'
2350
+
2351
+ export default function ResetPasswordPage() {
2352
+ return (
2353
+ <Suspense>
2354
+ <ResetPasswordContent />
2355
+ </Suspense>
2356
+ )
2357
+ }
2358
+ `),await h(r(i,`app/[locale]/auth/reset-password/content.tsx`),`'use client'
2359
+
2360
+ import { useSearchParams } from 'next/navigation'
2361
+ import { ResetPasswordForm } from '@murumets-ee/auth-ui'
2362
+
2363
+ export function ResetPasswordContent() {
2364
+ const searchParams = useSearchParams()
2365
+ const token = searchParams.get('token')
2366
+
2367
+ if (!token) {
2368
+ return (
2369
+ <div className="text-center">
2370
+ <h1 className="text-2xl font-bold text-zinc-900 dark:text-zinc-50">
2371
+ Invalid or expired link
2372
+ </h1>
2373
+ <p className="mt-2 text-zinc-500">
2374
+ Please request a new password reset.
2375
+ </p>
2376
+ </div>
2377
+ )
2378
+ }
2379
+
2380
+ return <ResetPasswordForm token={token} />
2381
+ }
2382
+ `),await h(r(i,`app/[locale]/setup/page.tsx`),`import { redirect } from 'next/navigation'
2383
+ import { sql } from 'drizzle-orm'
2384
+ import { getToolkitApp } from '@${n}/config/app'
2385
+ import { SetupForm } from './form'
2386
+
2387
+ export default async function SetupPage() {
2388
+ const app = await getToolkitApp()
2389
+ const result = await app.db.readOnly.execute<{ count: string }>(
2390
+ sql\`SELECT COUNT(*)::text as count FROM "user"\`,
2391
+ )
2392
+
2393
+ if (Number(result[0]?.count) > 0) {
2394
+ redirect('/')
2395
+ }
2396
+
2397
+ return (
2398
+ <div className="max-w-md mx-auto p-8">
2399
+ <h1 className="text-2xl font-bold mb-2">Create Admin</h1>
2400
+ <p className="text-sm text-zinc-500 dark:text-zinc-400 mb-6">
2401
+ No users found. Create the first admin account.
2402
+ </p>
2403
+ <SetupForm />
2404
+ </div>
2405
+ )
2406
+ }
2407
+ `),await h(r(i,`app/[locale]/setup/form.tsx`),`'use client'
2408
+
2409
+ import { useState } from 'react'
2410
+ import { createFirstAdmin } from './actions'
2411
+
2412
+ export function SetupForm() {
2413
+ const [result, setResult] = useState<{ ok?: boolean; error?: string; email?: string } | null>(null)
2414
+ const [loading, setLoading] = useState(false)
2415
+
2416
+ async function handleSubmit(e: React.FormEvent<HTMLFormElement>) {
2417
+ e.preventDefault()
2418
+ setLoading(true)
2419
+ setResult(null)
2420
+ const res = await createFirstAdmin(new FormData(e.currentTarget))
2421
+ setResult(res)
2422
+ setLoading(false)
2423
+ }
2424
+
2425
+ if (result?.ok) {
2426
+ return (
2427
+ <div className="space-y-2">
2428
+ <p className="text-green-600 dark:text-green-400">Admin created: {result.email}</p>
2429
+ <a href="/auth/sign-in" className="text-blue-600 dark:text-blue-400 hover:underline">
2430
+ Sign in &rarr;
2431
+ </a>
2432
+ </div>
2433
+ )
2434
+ }
2435
+
2436
+ return (
2437
+ <form onSubmit={handleSubmit} className="flex flex-col gap-4">
2438
+ <label className="text-sm font-medium">
2439
+ Name
2440
+ <input
2441
+ name="name"
2442
+ required
2443
+ className="mt-1 block w-full px-3 py-2 bg-zinc-100 dark:bg-zinc-900 border border-zinc-300 dark:border-zinc-700 rounded-md text-sm focus:outline-none focus:ring-1 focus:ring-blue-500"
2444
+ />
2445
+ </label>
2446
+ <label className="text-sm font-medium">
2447
+ Email
2448
+ <input
2449
+ name="email"
2450
+ type="email"
2451
+ required
2452
+ className="mt-1 block w-full px-3 py-2 bg-zinc-100 dark:bg-zinc-900 border border-zinc-300 dark:border-zinc-700 rounded-md text-sm focus:outline-none focus:ring-1 focus:ring-blue-500"
2453
+ />
2454
+ </label>
2455
+ <label className="text-sm font-medium">
2456
+ Password (min 8 chars)
2457
+ <input
2458
+ name="password"
2459
+ type="password"
2460
+ required
2461
+ minLength={8}
2462
+ className="mt-1 block w-full px-3 py-2 bg-zinc-100 dark:bg-zinc-900 border border-zinc-300 dark:border-zinc-700 rounded-md text-sm focus:outline-none focus:ring-1 focus:ring-blue-500"
2463
+ />
2464
+ </label>
2465
+
2466
+ {result?.error && <p className="text-red-600 dark:text-red-400 text-sm">{result.error}</p>}
2467
+
2468
+ <button
2469
+ type="submit"
2470
+ disabled={loading}
2471
+ className="px-4 py-2 text-sm rounded-md bg-blue-600 text-white hover:bg-blue-500 disabled:opacity-50 transition-colors"
2472
+ >
2473
+ {loading ? 'Creating...' : 'Create Admin'}
2474
+ </button>
2475
+ </form>
2476
+ )
2477
+ }
2478
+ `),await h(r(i,`app/[locale]/setup/actions.ts`),`'use server'
2479
+
2480
+ import { sql } from 'drizzle-orm'
2481
+ import { getToolkitApp } from '@${n}/config/app'
2482
+ import { getAuth } from '@murumets-ee/auth'
2483
+
2484
+ export async function createFirstAdmin(formData: FormData) {
2485
+ const email = formData.get('email') as string
2486
+ const password = formData.get('password') as string
2487
+ const name = formData.get('name') as string
2488
+
2489
+ if (!email || !password || !name) {
2490
+ return { error: 'All fields are required' }
2491
+ }
2492
+
2493
+ if (password.length < 8) {
2494
+ return { error: 'Password must be at least 8 characters' }
2495
+ }
2496
+
2497
+ const app = await getToolkitApp()
2498
+
2499
+ const canCreate = await app.db.readWrite.transaction(async (tx) => {
2500
+ await tx.execute(sql\`SELECT pg_advisory_xact_lock(1)\`)
2501
+
2502
+ const result = await tx.execute<{ count: string }>(
2503
+ sql\`SELECT COUNT(*)::text as count FROM "user"\`,
2504
+ )
2505
+ return Number(result[0]?.count) === 0
2506
+ })
2507
+
2508
+ if (!canCreate) {
2509
+ return { error: 'Admin user already exists. Setup is complete.' }
2510
+ }
2511
+
2512
+ const auth = getAuth()
2513
+
2514
+ const adminUser = await auth.api.signUpEmail({
2515
+ body: { email, password, name },
2516
+ })
2517
+
2518
+ await app.db.readWrite.execute(
2519
+ sql\`UPDATE "user" SET role = 'admin' WHERE id = \${adminUser.user.id}\`,
2520
+ )
2521
+
2522
+ return { ok: true, email: adminUser.user.email }
2523
+ }
2524
+ `)}async function A(e,t){let{name:n}=t,i=r(e,`apps/web`);v(`pnpm create next-app@16 ${i} --typescript --tailwind --no-eslint --app --no-src-dir --turbopack --react-compiler --skip-install --import-alias "@/*"`),await _(i,[`app/page.tsx`,`app/page.module.css`,`app/fonts`,`README.md`,`pnpm-workspace.yaml`]),await g(r(i,`package.json`),{dependencies:{[`@${n}/config`]:`workspace:*`,"@murumets-ee/core":`^${T.myorgCore}`,"@murumets-ee/auth-ui":`^${T.myorgAuthUi}`,"next-intl":`^${T.nextIntl}`,"next-themes":`^${T.nextThemes}`,"lucide-react":`^${T.lucideReact}`},devDependencies:{"babel-plugin-react-compiler":T.babelReactCompiler}});let{appendToFile:a}=await Promise.resolve().then(()=>m);await a(r(i,`.gitignore`),`
2525
+ # Environment
2526
+ .env*
2527
+ !.env.example
2528
+ `),await h(r(i,`next.config.ts`),`import type { NextConfig } from 'next'
2529
+ import createNextIntlPlugin from 'next-intl/plugin'
2530
+
2531
+ const withNextIntl = createNextIntlPlugin('./i18n/request.ts')
2532
+
2533
+ const nextConfig: NextConfig = {
2534
+ reactCompiler: true,
2535
+ transpilePackages: [
2536
+ '@${n}/config',
2537
+ '@murumets-ee/core',
2538
+ '@murumets-ee/entity',
2539
+ '@murumets-ee/db',
2540
+ '@murumets-ee/logging',
2541
+ '@murumets-ee/auth-ui',
2542
+ ],
2543
+ serverExternalPackages: ['drizzle-orm', 'postgres'],
2544
+ }
2545
+
2546
+ export default withNextIntl(nextConfig)
2547
+ `),await h(r(i,`proxy.ts`),`import createMiddleware from 'next-intl/middleware'
2548
+ import { routing } from './i18n/routing'
2549
+
2550
+ export default createMiddleware(routing)
2551
+
2552
+ export const config = {
2553
+ matcher: '/((?!api|_next|_vercel|.*\\\\..*).*)',
2554
+ }
2555
+ `),await h(r(i,`i18n/routing.ts`),`import { defineRouting } from 'next-intl/routing'
2556
+
2557
+ export const routing = defineRouting({
2558
+ locales: ['en'],
2559
+ defaultLocale: 'en',
2560
+ })
2561
+ `),await h(r(i,`i18n/request.ts`),`import { getRequestConfig } from 'next-intl/server'
2562
+ import { hasLocale } from 'next-intl'
2563
+ import { routing } from './routing'
2564
+ import { getAuthMessages } from '@murumets-ee/auth-ui/i18n'
2565
+
2566
+ export default getRequestConfig(async ({ requestLocale }) => {
2567
+ const requested = await requestLocale
2568
+ const locale = hasLocale(routing.locales, requested)
2569
+ ? requested
2570
+ : routing.defaultLocale
2571
+
2572
+ const authMessages = await getAuthMessages(locale)
2573
+
2574
+ return {
2575
+ locale,
2576
+ messages: {
2577
+ ...authMessages,
2578
+ },
2579
+ }
2580
+ })
2581
+ `),await h(r(i,`app/globals.css`),`@import "tailwindcss";
2582
+ @source "../node_modules/@murumets-ee/auth-ui/dist";
2583
+
2584
+ @custom-variant dark (&:where(.dark, .dark *));
2585
+
2586
+ :root {
2587
+ --background: #ffffff;
2588
+ --foreground: #171717;
2589
+ }
2590
+
2591
+ @theme inline {
2592
+ --color-background: var(--background);
2593
+ --color-foreground: var(--foreground);
2594
+ --font-sans: var(--font-geist-sans);
2595
+ --font-mono: var(--font-geist-mono);
2596
+ }
2597
+
2598
+ .dark {
2599
+ --background: #0a0a0a;
2600
+ --foreground: #ededed;
2601
+ }
2602
+
2603
+ body {
2604
+ background: var(--background);
2605
+ color: var(--foreground);
2606
+ font-family: Arial, Helvetica, sans-serif;
2607
+ }
2608
+ `),await h(r(i,`app/theme-provider.tsx`),`'use client'
2609
+
2610
+ import { ThemeProvider as NextThemesProvider } from 'next-themes'
2611
+ import type { ReactNode } from 'react'
2612
+
2613
+ export function ThemeProvider({ children }: { children: ReactNode }) {
2614
+ return (
2615
+ <NextThemesProvider
2616
+ attribute="class"
2617
+ defaultTheme="system"
2618
+ enableSystem
2619
+ disableTransitionOnChange
2620
+ >
2621
+ {children}
2622
+ </NextThemesProvider>
2623
+ )
2624
+ }
2625
+ `),await h(r(i,`app/theme-toggle.tsx`),`'use client'
2626
+
2627
+ import { useTheme } from 'next-themes'
2628
+ import { useState, useEffect } from 'react'
2629
+ import { Sun, Moon } from 'lucide-react'
2630
+
2631
+ export function ThemeToggle() {
2632
+ const [mounted, setMounted] = useState(false)
2633
+ const { resolvedTheme, setTheme } = useTheme()
2634
+
2635
+ useEffect(() => { setMounted(true) }, [])
2636
+
2637
+ if (!mounted) {
2638
+ return <div className="h-8 w-8" />
2639
+ }
2640
+
2641
+ return (
2642
+ <button
2643
+ type="button"
2644
+ onClick={() => setTheme(resolvedTheme === 'dark' ? 'light' : 'dark')}
2645
+ className="rounded-md p-1.5 text-zinc-400 transition-colors hover:bg-zinc-100 hover:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-200 cursor-pointer"
2646
+ aria-label={resolvedTheme === 'dark' ? 'Switch to light mode' : 'Switch to dark mode'}
2647
+ >
2648
+ {resolvedTheme === 'dark' ? <Sun className="h-5 w-5" /> : <Moon className="h-5 w-5" />}
2649
+ </button>
2650
+ )
2651
+ }
2652
+ `),await h(r(i,`app/nav-header.tsx`),`'use client'
2653
+
2654
+ import Link from 'next/link'
2655
+ import { usePathname } from 'next/navigation'
2656
+ import { ThemeToggle } from './theme-toggle'
2657
+
2658
+ const links = [
2659
+ { href: '/', label: 'Home' },
2660
+ ]
2661
+
2662
+ export function NavHeader() {
2663
+ const pathname = usePathname()
2664
+
2665
+ function isActive(href: string) {
2666
+ return href === '/' ? pathname === '/' : pathname.startsWith(href)
2667
+ }
2668
+
2669
+ const linkClass = (href: string) =>
2670
+ \`px-3 py-1.5 rounded-md text-sm transition-colors \${
2671
+ isActive(href)
2672
+ ? 'bg-zinc-200 text-zinc-900 dark:bg-zinc-800 dark:text-zinc-50'
2673
+ : 'text-zinc-500 hover:text-zinc-700 hover:bg-zinc-100 dark:text-zinc-400 dark:hover:text-zinc-200 dark:hover:bg-zinc-800/50'
2674
+ }\`
2675
+
2676
+ return (
2677
+ <header className="sticky top-0 z-50 backdrop-blur-md border-b bg-white/80 border-zinc-200 dark:bg-zinc-950/80 dark:border-zinc-800">
2678
+ <nav className="max-w-6xl mx-auto flex items-center gap-1 px-4 h-12">
2679
+ <span className="font-semibold text-sm text-zinc-700 dark:text-zinc-300 mr-3 select-none">
2680
+ ${n}
2681
+ </span>
2682
+ {links.map(({ href, label }) => (
2683
+ <Link key={href} href={href} className={linkClass(href)}>
2684
+ {label}
2685
+ </Link>
2686
+ ))}
2687
+ <div className="ml-auto">
2688
+ <ThemeToggle />
2689
+ </div>
2690
+ </nav>
2691
+ </header>
2692
+ )
2693
+ }
2694
+ `),await h(r(i,`app/layout.tsx`),`import './globals.css'
2695
+
2696
+ export default function RootLayout({ children }: { children: React.ReactNode }) {
2697
+ return children
2698
+ }
2699
+ `),await h(r(i,`app/[locale]/layout.tsx`),`import type { Metadata } from 'next'
2700
+ import { Geist, Geist_Mono } from 'next/font/google'
2701
+ import { NextIntlClientProvider } from 'next-intl'
2702
+ import { getMessages } from 'next-intl/server'
2703
+ import { notFound } from 'next/navigation'
2704
+ import { routing } from '@/i18n/routing'
2705
+ import { ThemeProvider } from '../theme-provider'
2706
+ import { NavHeader } from '../nav-header'
2707
+
2708
+ const geistSans = Geist({
2709
+ variable: '--font-geist-sans',
2710
+ subsets: ['latin'],
2711
+ })
2712
+
2713
+ const geistMono = Geist_Mono({
2714
+ variable: '--font-geist-mono',
2715
+ subsets: ['latin'],
2716
+ })
2717
+
2718
+ export const metadata: Metadata = {
2719
+ title: '${n}',
2720
+ description: 'Built with Lumi CMS Toolkit',
2721
+ }
2722
+
2723
+ export default async function LocaleLayout({
2724
+ children,
2725
+ params,
2726
+ }: {
2727
+ children: React.ReactNode
2728
+ params: Promise<{ locale: string }>
2729
+ }) {
2730
+ const { locale } = await params
2731
+ if (!routing.locales.includes(locale as any)) notFound()
2732
+
2733
+ const messages = await getMessages()
2734
+
2735
+ return (
2736
+ <html lang={locale} suppressHydrationWarning>
2737
+ <body className={\`\${geistSans.variable} \${geistMono.variable} antialiased\`}>
2738
+ <ThemeProvider>
2739
+ <NextIntlClientProvider locale={locale} messages={messages}>
2740
+ <NavHeader />
2741
+ {children}
2742
+ </NextIntlClientProvider>
2743
+ </ThemeProvider>
2744
+ </body>
2745
+ </html>
2746
+ )
2747
+ }
2748
+ `),await h(r(i,`app/[locale]/page.tsx`),`import { createQueryClient } from '@murumets-ee/core/clients'
2749
+ import { Article, Category } from '@${n}/config/entities'
2750
+ import { getToolkitApp } from '@${n}/config/app'
2751
+
2752
+ export default async function HomePage() {
2753
+ await getToolkitApp()
2754
+ const articles = createQueryClient(Article)
2755
+ const categories = createQueryClient(Category)
2756
+
2757
+ const [articleList, categoryList] = await Promise.all([
2758
+ articles.findMany({ limit: 10 }),
2759
+ categories.findMany({}),
2760
+ ])
2761
+
2762
+ return (
2763
+ <div className="min-h-screen p-8">
2764
+ <div className="max-w-4xl mx-auto">
2765
+ <h1 className="text-4xl font-bold mb-8">Welcome to ${n}</h1>
2766
+
2767
+ <section className="mb-12">
2768
+ <h2 className="text-2xl font-semibold mb-4">
2769
+ Categories ({categoryList.length})
2770
+ </h2>
2771
+ <div className="grid gap-4 md:grid-cols-2">
2772
+ {categoryList.map((cat) => (
2773
+ <div
2774
+ key={cat.id}
2775
+ className="border border-zinc-200 dark:border-zinc-800 rounded-lg p-4"
2776
+ >
2777
+ <h3 className="font-semibold text-lg">{cat.name}</h3>
2778
+ <p className="text-sm text-zinc-600 dark:text-zinc-400">
2779
+ {cat.description}
2780
+ </p>
2781
+ </div>
2782
+ ))}
2783
+ </div>
2784
+ </section>
2785
+
2786
+ <section>
2787
+ <h2 className="text-2xl font-semibold mb-4">
2788
+ Articles ({articleList.length})
2789
+ </h2>
2790
+ {articleList.length === 0 ? (
2791
+ <p className="text-zinc-500">No published articles yet.</p>
2792
+ ) : (
2793
+ <div className="space-y-4">
2794
+ {articleList.map((article) => (
2795
+ <div
2796
+ key={article.id}
2797
+ className="border border-zinc-200 dark:border-zinc-800 rounded-lg p-6"
2798
+ >
2799
+ <h3 className="text-xl font-bold">{article.title}</h3>
2800
+ <p className="text-zinc-600 dark:text-zinc-400 mt-2">
2801
+ {article.excerpt}
2802
+ </p>
2803
+ </div>
2804
+ ))}
2805
+ </div>
2806
+ )}
2807
+ </section>
2808
+ </div>
2809
+ </div>
2810
+ )
2811
+ }
2812
+ `)}async function j(e,t){let{name:n}=t;await h(r(e,`next.config.ts`),`import type { NextConfig } from 'next'
2813
+ import createNextIntlPlugin from 'next-intl/plugin'
2814
+
2815
+ const withNextIntl = createNextIntlPlugin('./i18n/request.ts')
2816
+
2817
+ const nextConfig: NextConfig = {
2818
+ output: 'standalone',
2819
+ reactCompiler: true,
2820
+ transpilePackages: [
2821
+ '@murumets-ee/core', '@murumets-ee/entity', '@murumets-ee/db',
2822
+ '@murumets-ee/logging', '@murumets-ee/auth', '@murumets-ee/auth-ui',
2823
+ '@murumets-ee/admin-ui', '@murumets-ee/content', '@murumets-ee/settings',
2824
+ '@murumets-ee/storage', '@murumets-ee/media', '@murumets-ee/taxonomy',
2825
+ '@murumets-ee/queue', '@murumets-ee/mail', '@murumets-ee/ticketing',
2826
+ '@murumets-ee/ticketing-ui', '@murumets-ee/tokens', '@murumets-ee/ui',
2827
+ ],
2828
+ serverExternalPackages: ['drizzle-orm', 'postgres', 'pino', 'file-type'],
2829
+ experimental: {
2830
+ serverActions: {
2831
+ bodySizeLimit: '2mb',
2832
+ },
2833
+ },
2834
+ }
2835
+
2836
+ export default withNextIntl(nextConfig)
2837
+ `),await h(r(e,`proxy.ts`),`import { NextRequest, NextResponse } from 'next/server'
2838
+ import { getSessionCookie } from 'better-auth/cookies'
2839
+ import createMiddleware from 'next-intl/middleware'
2840
+ import { routing } from './i18n/routing'
2841
+
2842
+ const intlMiddleware = createMiddleware(routing)
2843
+
2844
+ const protectedPaths = ['/setup']
2845
+
2846
+ export function proxy(request: NextRequest) {
2847
+ const { pathname } = request.nextUrl
2848
+
2849
+ // Strip locale prefix to check actual path
2850
+ const localePattern = new RegExp(\`^/(\${routing.locales.join('|')})\`)
2851
+ const pathWithoutLocale = pathname.replace(localePattern, '') || '/'
2852
+
2853
+ // Auth check for protected paths
2854
+ if (protectedPaths.some((p) => pathWithoutLocale.startsWith(p))) {
2855
+ const session = getSessionCookie(request)
2856
+ if (!session) {
2857
+ const locale = pathname.match(localePattern)?.[1] || routing.defaultLocale
2858
+ return NextResponse.redirect(new URL(\`/\${locale}/auth/sign-in\`, request.url))
2859
+ }
2860
+ }
2861
+
2862
+ // Locale routing
2863
+ return intlMiddleware(request)
2864
+ }
2865
+
2866
+ export const config = {
2867
+ matcher: '/((?!api|_next|_vercel|.*\\\\..*).*)',
2868
+ }
2869
+ `),await h(r(e,`app/layout.tsx`),`import './globals.css'
2870
+
2871
+ export default function RootLayout({ children }: { children: React.ReactNode }) {
2872
+ return children
2873
+ }
2874
+ `),await h(r(e,`app/[locale]/layout.tsx`),`import type { Metadata } from 'next'
2875
+ import { Geist, Geist_Mono } from 'next/font/google'
2876
+ import { NextIntlClientProvider } from 'next-intl'
2877
+ import { getMessages } from 'next-intl/server'
2878
+ import { notFound } from 'next/navigation'
2879
+ import { routing } from '@/i18n/routing'
2880
+ import { ThemeProvider } from '../theme-provider'
2881
+ import { NavHeader } from '../nav-header'
2882
+
2883
+ const geistSans = Geist({
2884
+ variable: '--font-geist-sans',
2885
+ subsets: ['latin'],
2886
+ })
2887
+
2888
+ const geistMono = Geist_Mono({
2889
+ variable: '--font-geist-mono',
2890
+ subsets: ['latin'],
2891
+ })
2892
+
2893
+ export const metadata: Metadata = {
2894
+ title: '${n}',
2895
+ description: 'Built with Lumi CMS Toolkit',
2896
+ }
2897
+
2898
+ export default async function LocaleLayout({
2899
+ children,
2900
+ params,
2901
+ }: {
2902
+ children: React.ReactNode
2903
+ params: Promise<{ locale: string }>
2904
+ }) {
2905
+ const { locale } = await params
2906
+ if (!routing.locales.includes(locale as any)) notFound()
2907
+
2908
+ const messages = await getMessages()
2909
+
2910
+ return (
2911
+ <html lang={locale} suppressHydrationWarning>
2912
+ <body className={\`\${geistSans.variable} \${geistMono.variable} antialiased\`}>
2913
+ <ThemeProvider>
2914
+ <NextIntlClientProvider locale={locale} messages={messages}>
2915
+ <NavHeader />
2916
+ {children}
2917
+ </NextIntlClientProvider>
2918
+ </ThemeProvider>
2919
+ </body>
2920
+ </html>
2921
+ )
2922
+ }
2923
+ `),await h(r(e,`app/[locale]/page.tsx`),`import { createQueryClient } from '@murumets-ee/core/clients'
2924
+ import { Article, Category } from '@/entities'
2925
+ import { getToolkitApp } from '@/lib/app'
2926
+
2927
+ export default async function HomePage() {
2928
+ await getToolkitApp()
2929
+ const articles = createQueryClient(Article)
2930
+ const categories = createQueryClient(Category)
2931
+
2932
+ const [articleList, categoryList] = await Promise.all([
2933
+ articles.findMany({ limit: 10 }),
2934
+ categories.findMany({}),
2935
+ ])
2936
+
2937
+ return (
2938
+ <div className="min-h-screen p-8">
2939
+ <div className="max-w-4xl mx-auto">
2940
+ <h1 className="text-4xl font-bold mb-8">Welcome to ${n}</h1>
2941
+
2942
+ <section className="mb-12">
2943
+ <h2 className="text-2xl font-semibold mb-4">
2944
+ Categories ({categoryList.length})
2945
+ </h2>
2946
+ <div className="grid gap-4 md:grid-cols-2">
2947
+ {categoryList.map((cat) => (
2948
+ <div
2949
+ key={cat.id}
2950
+ className="border border-zinc-200 dark:border-zinc-800 rounded-lg p-4"
2951
+ >
2952
+ <h3 className="font-semibold text-lg">{cat.name}</h3>
2953
+ <p className="text-sm text-zinc-600 dark:text-zinc-400">
2954
+ {cat.description}
2955
+ </p>
2956
+ </div>
2957
+ ))}
2958
+ </div>
2959
+ </section>
2960
+
2961
+ <section>
2962
+ <h2 className="text-2xl font-semibold mb-4">
2963
+ Articles ({articleList.length})
2964
+ </h2>
2965
+ {articleList.length === 0 ? (
2966
+ <p className="text-zinc-500">No published articles yet.</p>
2967
+ ) : (
2968
+ <div className="space-y-4">
2969
+ {articleList.map((article) => (
2970
+ <div
2971
+ key={article.id}
2972
+ className="border border-zinc-200 dark:border-zinc-800 rounded-lg p-6"
2973
+ >
2974
+ <h3 className="text-xl font-bold">{article.title}</h3>
2975
+ <p className="text-zinc-600 dark:text-zinc-400 mt-2">
2976
+ {article.excerpt}
2977
+ </p>
2978
+ </div>
2979
+ ))}
2980
+ </div>
2981
+ )}
2982
+ </section>
2983
+ </div>
2984
+ </div>
2985
+ )
2986
+ }
2987
+ `)}async function M(e,t){await h(r(e,`scripts/generate-schema.ts`),`import { execSync } from 'node:child_process'
2988
+ execSync('npx @murumets-ee/cli generate', { stdio: 'inherit', cwd: import.meta.dirname + '/..' })
2989
+ `),await h(r(e,`scripts/migrate.ts`),`import { execSync } from 'node:child_process'
2990
+ execSync('npx @murumets-ee/cli migrate', { stdio: 'inherit', cwd: import.meta.dirname + '/..' })
2991
+ `),await h(r(e,`scripts/reset-db.ts`),`import { execSync } from 'node:child_process'
2992
+ execSync('npx @murumets-ee/cli reset --force', { stdio: 'inherit', cwd: import.meta.dirname + '/..' })
2993
+ `),await h(r(e,`scripts/worker.ts`),`/**
2994
+ * Standalone queue worker process.
2995
+ *
2996
+ * Run separately from the Next.js web server:
2997
+ * pnpm worker (or: tsx --env-file=.env scripts/worker.ts)
2998
+ *
2999
+ * The web server should set QUEUE_WORKER=false so it only enqueues jobs.
3000
+ * This process handles job execution.
3001
+ */
3002
+
3003
+ import { createApp, setApp } from '@murumets-ee/core'
3004
+ import config from '../toolkit.config'
3005
+
3006
+ process.env.QUEUE_WORKER = 'true'
3007
+
3008
+ const app = await createApp(config)
3009
+ setApp(app)
3010
+
3011
+ app.logger.info('Queue worker process running. Press Ctrl+C to stop.')
3012
+
3013
+ const shutdown = async () => {
3014
+ app.logger.info('Shutting down queue worker...')
3015
+
3016
+ const worker = (globalThis as Record<symbol, unknown>)[
3017
+ Symbol.for('@murumets-ee/queue:worker')
3018
+ ] as { stop: () => Promise<void> } | undefined
3019
+
3020
+ if (worker) {
3021
+ await worker.stop()
3022
+ }
3023
+
3024
+ process.exit(0)
3025
+ }
3026
+
3027
+ process.on('SIGINT', shutdown)
3028
+ process.on('SIGTERM', shutdown)
3029
+ `)}async function N(e,t){let{name:n}=t;await h(r(e,`app/globals.css`),`@import "tailwindcss";
3030
+ @source "../node_modules/@murumets-ee/auth-ui/dist";
3031
+
3032
+ @custom-variant dark (&:where(.dark, .dark *));
3033
+
3034
+ :root {
3035
+ --background: #ffffff;
3036
+ --foreground: #171717;
3037
+ }
3038
+
3039
+ @theme inline {
3040
+ --color-background: var(--background);
3041
+ --color-foreground: var(--foreground);
3042
+ --font-sans: var(--font-geist-sans);
3043
+ --font-mono: var(--font-geist-mono);
3044
+ }
3045
+
3046
+ .dark {
3047
+ --background: #0a0a0a;
3048
+ --foreground: #ededed;
3049
+ }
3050
+
3051
+ body {
3052
+ background: var(--background);
3053
+ color: var(--foreground);
3054
+ font-family: Arial, Helvetica, sans-serif;
3055
+ }
3056
+ `),await h(r(e,`app/theme-provider.tsx`),`'use client'
3057
+
3058
+ import { ThemeProvider as NextThemesProvider } from 'next-themes'
3059
+ import type { ReactNode } from 'react'
3060
+
3061
+ export function ThemeProvider({ children }: { children: ReactNode }) {
3062
+ return (
3063
+ <NextThemesProvider
3064
+ attribute="class"
3065
+ defaultTheme="system"
3066
+ enableSystem
3067
+ disableTransitionOnChange
3068
+ >
3069
+ {children}
3070
+ </NextThemesProvider>
3071
+ )
3072
+ }
3073
+ `),await h(r(e,`app/theme-toggle.tsx`),`'use client'
3074
+
3075
+ import { useTheme } from 'next-themes'
3076
+ import { useState, useEffect } from 'react'
3077
+ import { Sun, Moon } from 'lucide-react'
3078
+
3079
+ export function ThemeToggle() {
3080
+ const [mounted, setMounted] = useState(false)
3081
+ const { resolvedTheme, setTheme } = useTheme()
3082
+
3083
+ useEffect(() => { setMounted(true) }, [])
3084
+
3085
+ if (!mounted) {
3086
+ return <div className="h-8 w-8" />
3087
+ }
3088
+
3089
+ return (
3090
+ <button
3091
+ type="button"
3092
+ onClick={() => setTheme(resolvedTheme === 'dark' ? 'light' : 'dark')}
3093
+ className="rounded-md p-1.5 text-zinc-400 transition-colors hover:bg-zinc-100 hover:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-200 cursor-pointer"
3094
+ aria-label={resolvedTheme === 'dark' ? 'Switch to light mode' : 'Switch to dark mode'}
3095
+ >
3096
+ {resolvedTheme === 'dark' ? <Sun className="h-5 w-5" /> : <Moon className="h-5 w-5" />}
3097
+ </button>
3098
+ )
3099
+ }
3100
+ `),await h(r(e,`app/nav-header.tsx`),`'use client'
3101
+
3102
+ import Link from 'next/link'
3103
+ import { usePathname } from 'next/navigation'
3104
+ import { ThemeToggle } from './theme-toggle'
3105
+
3106
+ const links = [
3107
+ { href: '/', label: 'Home' },
3108
+ { href: '/auth/sign-in', label: 'Sign In' },
3109
+ { href: '/setup', label: 'Setup' },
3110
+ ]
3111
+
3112
+ export function NavHeader() {
3113
+ const pathname = usePathname()
3114
+
3115
+ function isActive(href: string) {
3116
+ return href === '/' ? pathname === '/' : pathname.startsWith(href)
3117
+ }
3118
+
3119
+ const linkClass = (href: string) =>
3120
+ \`px-3 py-1.5 rounded-md text-sm transition-colors \${
3121
+ isActive(href)
3122
+ ? 'bg-zinc-200 text-zinc-900 dark:bg-zinc-800 dark:text-zinc-50'
3123
+ : 'text-zinc-500 hover:text-zinc-700 hover:bg-zinc-100 dark:text-zinc-400 dark:hover:text-zinc-200 dark:hover:bg-zinc-800/50'
3124
+ }\`
3125
+
3126
+ return (
3127
+ <header className="sticky top-0 z-50 backdrop-blur-md border-b bg-white/80 border-zinc-200 dark:bg-zinc-950/80 dark:border-zinc-800">
3128
+ <nav className="max-w-6xl mx-auto flex items-center gap-1 px-4 h-12">
3129
+ <span className="font-semibold text-sm text-zinc-700 dark:text-zinc-300 mr-3 select-none">
3130
+ ${n}
3131
+ </span>
3132
+ {links.map(({ href, label }) => (
3133
+ <Link key={href} href={href} className={linkClass(href)}>
3134
+ {label}
3135
+ </Link>
3136
+ ))}
3137
+ <div className="ml-auto">
3138
+ <ThemeToggle />
3139
+ </div>
3140
+ </nav>
3141
+ </header>
3142
+ )
3143
+ }
3144
+ `)}async function P(e,t){let{name:n}=t;await h(r(e,`toolkit.config.ts`),`import { auth } from '@murumets-ee/auth/plugin'
3145
+ import { content } from '@murumets-ee/content/plugin'
3146
+ import { defineConfig } from '@murumets-ee/core'
3147
+ import { logging } from '@murumets-ee/logging/plugin'
3148
+ import { mail, ResendMailProvider } from '@murumets-ee/mail'
3149
+ import { media } from '@murumets-ee/media/plugin'
3150
+ import { queue } from '@murumets-ee/queue/plugin'
3151
+ import { settings } from '@murumets-ee/settings/plugin'
3152
+ import { storage } from '@murumets-ee/storage/plugin'
3153
+ import { taxonomy } from '@murumets-ee/taxonomy/plugin'
3154
+ import { ticketing } from '@murumets-ee/ticketing/plugin'
3155
+ import { Article, Category } from './entities'
3156
+ import * as authSchema from './generated/auth-schema'
3157
+
3158
+ if (!process.env.DATABASE_URL) {
3159
+ throw new Error('DATABASE_URL environment variable is required')
3160
+ }
3161
+
3162
+ export default defineConfig({
3163
+ db: {
3164
+ url: process.env.DATABASE_URL,
3165
+ poolMin: 2,
3166
+ poolMax: 10,
3167
+ },
3168
+ logging: {
3169
+ level: (process.env.LOG_LEVEL || 'info') as 'debug' | 'info' | 'warn' | 'error',
3170
+ name: '${n}',
3171
+ },
3172
+ entities: [Category, Article],
3173
+ plugins: [
3174
+ auth({ providers: ['email'], schema: authSchema }),
3175
+ content({
3176
+ locales: [{ code: 'en', label: 'English' }],
3177
+ defaultLocale: 'en',
3178
+ }),
3179
+ logging(),
3180
+ settings(),
3181
+ storage(),
3182
+ media(),
3183
+ taxonomy(),
3184
+ queue(),
3185
+ mail({
3186
+ provider: process.env.RESEND_API_KEY
3187
+ ? new ResendMailProvider({ apiKey: process.env.RESEND_API_KEY })
3188
+ : undefined,
3189
+ defaultFrom: process.env.MAIL_FROM ?? 'noreply@example.com',
3190
+ webhookSecret: process.env.RESEND_WEBHOOK_SECRET,
3191
+ }),
3192
+ ticketing({
3193
+ csatSecret: process.env.CSAT_SECRET,
3194
+ }),
3195
+ ],
3196
+ projectRoot: import.meta.dirname,
3197
+ })
3198
+ `),await h(r(e,`lib/app.ts`),`import { createApp, setApp, type ToolkitApp } from '@murumets-ee/core'
3199
+ import config from '../toolkit.config'
3200
+
3201
+ let appInstance: ToolkitApp | null = null
3202
+
3203
+ export async function getToolkitApp(): Promise<ToolkitApp> {
3204
+ if (!appInstance) {
3205
+ appInstance = await createApp(config)
3206
+ setApp(appInstance)
3207
+ }
3208
+ return appInstance
3209
+ }
3210
+ `),await h(r(e,`drizzle.config.ts`),`import type { Config } from 'drizzle-kit'
3211
+
3212
+ if (!process.env.DATABASE_URL) {
3213
+ throw new Error('DATABASE_URL environment variable is required')
3214
+ }
3215
+
3216
+ export default {
3217
+ schema: ['./generated/schema.ts', './generated/auth-schema.ts'],
3218
+ out: './migrations',
3219
+ dialect: 'postgresql',
3220
+ dbCredentials: {
3221
+ url: process.env.DATABASE_URL,
3222
+ },
3223
+ } satisfies Config
3224
+ `),await h(r(e,`auth.config.ts`),`import { betterAuth } from 'better-auth'
3225
+ import { drizzleAdapter } from 'better-auth/adapters/drizzle'
3226
+ import { admin } from 'better-auth/plugins'
3227
+ import { organization } from 'better-auth/plugins/organization'
3228
+ import { drizzle } from 'drizzle-orm/postgres-js'
3229
+ import postgres from 'postgres'
3230
+
3231
+ const sql = postgres(process.env.DATABASE_URL!)
3232
+ const db = drizzle(sql)
3233
+
3234
+ export const auth = betterAuth({
3235
+ database: drizzleAdapter(db, { provider: 'pg' }),
3236
+ emailAndPassword: { enabled: true },
3237
+ plugins: [
3238
+ admin(),
3239
+ organization(),
3240
+ ],
3241
+ })
3242
+ `),await h(r(e,`generated/auth-schema.ts`),`// This file is generated by better-auth CLI.
3243
+ // Run: npx @better-auth/cli generate --config auth.config.ts -y
3244
+ export {}
3245
+ `)}async function F(e,t){e.mode===`single`?await I(e,t):await L(e,t)}async function I(e,t){let n=r(process.cwd(),e.name);t?.(`Creating Next.js app...`),v(`pnpm create next-app@16 ${e.name} --typescript --tailwind --no-eslint --app --no-src-dir --turbopack --react-compiler --skip-install --import-alias "@/*"`),await _(n,[`app/page.tsx`,`app/page.module.css`,`app/fonts`,`README.md`]),await g(r(n,`package.json`),{type:`module`,dependencies:{"@murumets-ee/core":`^${T.myorgCore}`,"@murumets-ee/db":`^${T.myorgDb}`,"@murumets-ee/entity":`^${T.myorgEntity}`,"@murumets-ee/logging":`^${T.myorgLogging}`,"@murumets-ee/auth":`^${T.myorgAuth}`,"@murumets-ee/auth-ui":`^${T.myorgAuthUi}`,"@murumets-ee/admin-ui":`^${T.myorgAdminUi}`,"@murumets-ee/content":`^${T.myorgContent}`,"@murumets-ee/settings":`^${T.myorgSettings}`,"@murumets-ee/storage":`^${T.myorgStorage}`,"@murumets-ee/media":`^${T.myorgMedia}`,"@murumets-ee/taxonomy":`^${T.myorgTaxonomy}`,"@murumets-ee/queue":`^${T.myorgQueue}`,"@murumets-ee/mail":`^${T.myorgMail}`,"@murumets-ee/ticketing":`^${T.myorgTicketing}`,"@murumets-ee/ticketing-ui":`^${T.myorgTicketingUi}`,"@murumets-ee/tokens":`^${T.myorgTokens}`,"@murumets-ee/editor":`^${T.myorgEditor}`,"@murumets-ee/blocks":`^${T.myorgBlocks}`,"@murumets-ee/ui":`^${T.myorgUi}`,"better-auth":`^${T.betterAuth}`,"drizzle-orm":`^${T.drizzleOrm}`,"next-intl":`^${T.nextIntl}`,"next-themes":`^${T.nextThemes}`,"lucide-react":`^${T.lucideReact}`,postgres:`^${T.postgres}`,"@tanstack/react-query":`^${T.tanstackReactQuery}`,"@tanstack/react-table":`^${T.tanstackReactTable}`,"react-hook-form":`^${T.reactHookForm}`,"@hookform/resolvers":`^${T.hookformResolvers}`,zod:`^${T.zod}`},devDependencies:{"drizzle-kit":`^${T.drizzleKit}`,tsx:`^${T.tsx}`,"babel-plugin-react-compiler":T.babelReactCompiler},scripts:{"db:generate":`tsx --env-file=.env scripts/generate-schema.ts`,"db:migrate:generate":`drizzle-kit generate`,"db:migrate":`tsx --env-file=.env scripts/migrate.ts`,"db:reset":`tsx --env-file=.env scripts/reset-db.ts`,worker:`tsx --env-file=.env scripts/worker.ts`}}),t?.(`Adding toolkit files...`),await S(n,e),await C(n,e),await P(n,e),await x(n,e),await w(n,e),await j(n,e),await N(n,e),await b(n,e),await M(n,e),e.installDeps&&(t?.(`Installing dependencies...`),v(`pnpm install`,{cwd:n}))}async function L(e,t){let n=r(process.cwd(),e.name);t?.(`Creating workspace...`),await E(n,e,t),e.installDeps&&(t?.(`Installing dependencies...`),v(`pnpm install`,{cwd:n}))}async function R(){let n=process.argv[2],r=await p(n);if(!r)return;let i=e.spinner();try{i.start(`Creating Next.js app...`),await F(r,e=>{i.stop(`${t.green(`✓`)} Done`),i.start(e)}),i.stop(`${t.green(`✓`)} Done`);let n=[`cd ${r.name}`,`cp .env.example .env`,`docker compose up -d`,`npx @murumets-ee/cli setup`,`pnpm db:migrate`,`pnpm dev`,`# Visit /setup to create your first admin user`];e.note(n.join(`
3246
+ `),`Next steps`),e.outro(`${t.green(`Success!`)} Your project is ready.`)}catch(n){i.stop(t.red(`Failed.`)),e.log.error(n instanceof Error?n.message:String(n)),process.exit(1)}}R();export{};