@murumets-ee/create 0.1.13 → 0.1.15

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/index.js DELETED
@@ -1,2104 +0,0 @@
1
- import{a as e,b as c,c as u,d as l,e as y}from"./chunk-CUB6XFPE.js";import{join as v}from"path";import{join as s}from"path";async function w(t,n){await e(s(t,"lib/auth.ts"),`import { getToolkitApp } from './app'
2
- import { getAuth } from '@murumets-ee/auth'
3
-
4
- export async function getAuthInstance() {
5
- await getToolkitApp()
6
- return getAuth()
7
- }
8
- `),await e(s(t,"lib/auth-client.ts"),`import { createClient } from '@murumets-ee/auth/client'
9
-
10
- export const authClient = createClient()
11
- `),await e(s(t,"app/api/auth/[...all]/route.ts"),`import { toNextJsHandler } from 'better-auth/next-js'
12
- import { getAuthInstance } from '../../../../lib/auth'
13
-
14
- let _handler: ReturnType<typeof toNextJsHandler> | null = null
15
-
16
- async function handler() {
17
- if (!_handler) {
18
- const auth = await getAuthInstance()
19
- _handler = toNextJsHandler(auth)
20
- }
21
- return _handler
22
- }
23
-
24
- export async function GET(req: Request) {
25
- const h = await handler()
26
- return h.GET(req)
27
- }
28
-
29
- export async function POST(req: Request) {
30
- const h = await handler()
31
- return h.POST(req)
32
- }
33
- `),await e(s(t,"app/[locale]/auth/layout.tsx"),`import { AuthProviders } from './providers'
34
- import type { ReactNode } from 'react'
35
-
36
- export default function AuthLayout({ children }: { children: ReactNode }) {
37
- return (
38
- <AuthProviders>
39
- <div className="flex min-h-[calc(100vh-3rem)] items-center justify-center px-4">
40
- {children}
41
- </div>
42
- </AuthProviders>
43
- )
44
- }
45
- `),await e(s(t,"app/[locale]/auth/providers.tsx"),`'use client'
46
-
47
- import { AuthUIProvider } from '@murumets-ee/auth-ui'
48
- import { authClient } from '@/lib/auth-client'
49
- import Link from 'next/link'
50
- import { useRouter } from 'next/navigation'
51
- import { useLocale } from 'next-intl'
52
- import type { ReactNode } from 'react'
53
-
54
- export function AuthProviders({ children }: { children: ReactNode }) {
55
- const router = useRouter()
56
- const locale = useLocale()
57
-
58
- return (
59
- <AuthUIProvider
60
- authClient={authClient as never}
61
- basePath="/auth"
62
- redirectTo="/"
63
- Link={Link}
64
- navigate={(url) => router.push(url)}
65
- resetPasswordUrl={\`/\${locale}/auth/reset-password\`}
66
- >
67
- {children}
68
- </AuthUIProvider>
69
- )
70
- }
71
- `),await e(s(t,"app/[locale]/auth/sign-in/page.tsx"),`import { SignInForm } from '@murumets-ee/auth-ui'
72
-
73
- export default function SignInPage() {
74
- return <SignInForm />
75
- }
76
- `),await e(s(t,"app/[locale]/auth/sign-up/page.tsx"),`import { SignUpForm } from '@murumets-ee/auth-ui'
77
-
78
- export default function SignUpPage() {
79
- return <SignUpForm />
80
- }
81
- `),await e(s(t,"app/[locale]/auth/forgot-password/page.tsx"),`import { ForgotPasswordForm } from '@murumets-ee/auth-ui'
82
-
83
- export default function ForgotPasswordPage() {
84
- return <ForgotPasswordForm />
85
- }
86
- `),await e(s(t,"app/[locale]/auth/reset-password/page.tsx"),`import { Suspense } from 'react'
87
- import { ResetPasswordContent } from './content'
88
-
89
- export default function ResetPasswordPage() {
90
- return (
91
- <Suspense>
92
- <ResetPasswordContent />
93
- </Suspense>
94
- )
95
- }
96
- `),await e(s(t,"app/[locale]/auth/reset-password/content.tsx"),`'use client'
97
-
98
- import { useSearchParams } from 'next/navigation'
99
- import { ResetPasswordForm } from '@murumets-ee/auth-ui'
100
-
101
- export function ResetPasswordContent() {
102
- const searchParams = useSearchParams()
103
- const token = searchParams.get('token')
104
-
105
- if (!token) {
106
- return (
107
- <div className="text-center">
108
- <h1 className="text-2xl font-bold text-zinc-900 dark:text-zinc-50">
109
- Invalid or expired link
110
- </h1>
111
- <p className="mt-2 text-zinc-500">
112
- Please request a new password reset.
113
- </p>
114
- </div>
115
- )
116
- }
117
-
118
- return <ResetPasswordForm token={token} />
119
- }
120
- `),await e(s(t,"app/[locale]/setup/page.tsx"),`import { redirect } from 'next/navigation'
121
- import { sql } from 'drizzle-orm'
122
- import { getToolkitApp } from '@/lib/app'
123
- import { SetupForm } from './form'
124
-
125
- export default async function SetupPage() {
126
- const app = await getToolkitApp()
127
- const result = await app.db.readOnly.execute<{ count: string }>(
128
- sql\`SELECT COUNT(*)::text as count FROM "user"\`,
129
- )
130
-
131
- if (Number(result[0]?.count) > 0) {
132
- redirect('/')
133
- }
134
-
135
- return (
136
- <div className="max-w-md mx-auto p-8">
137
- <h1 className="text-2xl font-bold mb-2">Create Admin</h1>
138
- <p className="text-sm text-zinc-500 dark:text-zinc-400 mb-6">
139
- No users found. Create the first admin account.
140
- </p>
141
- <SetupForm />
142
- </div>
143
- )
144
- }
145
- `),await e(s(t,"app/[locale]/setup/form.tsx"),`'use client'
146
-
147
- import { useState } from 'react'
148
- import { createFirstAdmin } from './actions'
149
-
150
- export function SetupForm() {
151
- const [result, setResult] = useState<{ ok?: boolean; error?: string; email?: string } | null>(null)
152
- const [loading, setLoading] = useState(false)
153
-
154
- async function handleSubmit(e: React.FormEvent<HTMLFormElement>) {
155
- e.preventDefault()
156
- setLoading(true)
157
- setResult(null)
158
- const res = await createFirstAdmin(new FormData(e.currentTarget))
159
- setResult(res)
160
- setLoading(false)
161
- }
162
-
163
- if (result?.ok) {
164
- return (
165
- <div className="space-y-2">
166
- <p className="text-green-600 dark:text-green-400">Admin created: {result.email}</p>
167
- <a href="/auth/sign-in" className="text-blue-600 dark:text-blue-400 hover:underline">
168
- Sign in &rarr;
169
- </a>
170
- </div>
171
- )
172
- }
173
-
174
- return (
175
- <form onSubmit={handleSubmit} className="flex flex-col gap-4">
176
- <label className="text-sm font-medium">
177
- Name
178
- <input
179
- name="name"
180
- required
181
- 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"
182
- />
183
- </label>
184
- <label className="text-sm font-medium">
185
- Email
186
- <input
187
- name="email"
188
- type="email"
189
- required
190
- 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"
191
- />
192
- </label>
193
- <label className="text-sm font-medium">
194
- Password (min 8 chars)
195
- <input
196
- name="password"
197
- type="password"
198
- required
199
- minLength={8}
200
- 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"
201
- />
202
- </label>
203
-
204
- {result?.error && <p className="text-red-600 dark:text-red-400 text-sm">{result.error}</p>}
205
-
206
- <button
207
- type="submit"
208
- disabled={loading}
209
- className="px-4 py-2 text-sm rounded-md bg-blue-600 text-white hover:bg-blue-500 disabled:opacity-50 transition-colors"
210
- >
211
- {loading ? 'Creating...' : 'Create Admin'}
212
- </button>
213
- </form>
214
- )
215
- }
216
- `),await e(s(t,"app/[locale]/setup/actions.ts"),`'use server'
217
-
218
- import { sql } from 'drizzle-orm'
219
- import { getToolkitApp } from '@/lib/app'
220
- import { getAuth } from '@murumets-ee/auth'
221
-
222
- /**
223
- * Create the first admin user. Locked down:
224
- * - Advisory lock prevents race conditions (two simultaneous requests)
225
- * - User count check inside the lock ensures only one admin can be created
226
- * - Once any user exists, this action permanently refuses
227
- */
228
- export async function createFirstAdmin(formData: FormData) {
229
- const email = formData.get('email') as string
230
- const password = formData.get('password') as string
231
- const name = formData.get('name') as string
232
-
233
- if (!email || !password || !name) {
234
- return { error: 'All fields are required' }
235
- }
236
-
237
- if (password.length < 8) {
238
- return { error: 'Password must be at least 8 characters' }
239
- }
240
-
241
- const app = await getToolkitApp()
242
-
243
- // Acquire advisory lock + check atomically in a transaction
244
- const canCreate = await app.db.readWrite.transaction(async (tx) => {
245
- // Advisory lock 1 = "setup lock". Blocks concurrent setup attempts.
246
- await tx.execute(sql\`SELECT pg_advisory_xact_lock(1)\`)
247
-
248
- const result = await tx.execute<{ count: string }>(
249
- sql\`SELECT COUNT(*)::text as count FROM "user"\`,
250
- )
251
- return Number(result[0]?.count) === 0
252
- })
253
-
254
- if (!canCreate) {
255
- return { error: 'Admin user already exists. Setup is complete.' }
256
- }
257
-
258
- const auth = getAuth()
259
-
260
- const adminUser = await auth.api.signUpEmail({
261
- body: { email, password, name },
262
- })
263
-
264
- await app.db.readWrite.execute(
265
- sql\`UPDATE "user" SET role = 'admin' WHERE id = \${adminUser.user.id}\`,
266
- )
267
-
268
- return { ok: true, email: adminUser.user.email }
269
- }
270
- `)}import{join as m}from"path";async function k(t,n){let{name:r}=n;await e(m(t,".env.example"),`DATABASE_URL=postgresql://${r}:${r}_dev_password@localhost:5432/${r}_dev
271
- BETTER_AUTH_SECRET=dev-secret-change-me-in-production-min-32-chars
272
- BETTER_AUTH_URL=http://localhost:3000
273
- LOG_LEVEL=debug
274
- NEXT_PUBLIC_APP_URL=http://localhost:3000
275
- QUEUE_WORKER=true
276
- RESEND_API_KEY=
277
- RESEND_WEBHOOK_SECRET=
278
- MAIL_FROM=noreply@example.com
279
- CSAT_SECRET=
280
- `),await e(m(t,".dockerignore"),`# Dependencies (installed inside Docker)
281
- node_modules/
282
- .pnpm-store/
283
-
284
- # Build outputs (rebuilt inside Docker)
285
- .next/
286
- out/
287
- dist/
288
-
289
- # Git
290
- .git/
291
- .gitignore
292
-
293
- # Environment files (pass via docker run --env-file)
294
- .env
295
- .env.*
296
- !.env.example
297
-
298
- # Docker files
299
- Dockerfile*
300
- .dockerignore
301
- docker-compose*.yml
302
-
303
- # Tests
304
- coverage/
305
- **/*.test.*
306
- **/*.spec.*
307
- **/vitest.config.*
308
- docker-compose.test.yml
309
-
310
- # Development tooling
311
- .vscode/
312
- .idea/
313
- .turbo/
314
- .cache/
315
- *.tsbuildinfo
316
-
317
- # Documentation
318
- *.md
319
- docs/
320
-
321
- # OS files
322
- .DS_Store
323
- Thumbs.db
324
- `),await e(m(t,"Dockerfile"),`# --- Base image ---
325
- # Node 22 LTS (Debian slim \u2014 glibc required for sharp image optimization)
326
- FROM node:22-slim AS base
327
-
328
- # --- Stage 1: Install dependencies ---
329
- FROM base AS deps
330
- WORKDIR /app
331
- RUN corepack enable pnpm
332
- COPY package.json pnpm-lock.yaml ./
333
- RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store \\
334
- pnpm install --frozen-lockfile
335
-
336
- # --- Stage 2: Build the application ---
337
- FROM base AS builder
338
- WORKDIR /app
339
- RUN corepack enable pnpm
340
- COPY --from=deps /app/node_modules ./node_modules
341
- COPY . .
342
- ENV NODE_ENV=production
343
- ENV NEXT_TELEMETRY_DISABLED=1
344
- # Dummy env vars so toolkit.config.ts doesn't throw at build time (no DB connection needed)
345
- ENV DATABASE_URL=postgresql://build:build@localhost:5432/build
346
- ENV BETTER_AUTH_SECRET=build-secret-not-used-at-runtime
347
- RUN pnpm build
348
-
349
- # --- Stage 3: Production runner ---
350
- FROM base AS runner
351
- WORKDIR /app
352
- ENV NODE_ENV=production
353
- ENV PORT=3000
354
- ENV HOSTNAME=0.0.0.0
355
- ENV NEXT_TELEMETRY_DISABLED=1
356
-
357
- # Copy standalone output (includes server.js + traced node_modules)
358
- COPY --from=builder --chown=node:node /app/.next/standalone ./
359
- # Copy static assets (JS/CSS chunks \u2014 excluded from standalone trace)
360
- COPY --from=builder --chown=node:node /app/.next/static ./.next/static
361
- # Copy public assets (favicon, robots.txt, images)
362
- COPY --from=builder --chown=node:node /app/public ./public
363
- # Copy migrations (applied at app startup by the toolkit migration runner)
364
- COPY --from=builder --chown=node:node /app/migrations ./migrations
365
-
366
- # Run as non-root user
367
- USER node
368
- EXPOSE 3000
369
- CMD ["node", "server.js"]
370
- `),await e(m(t,"docker-compose.yml"),`services:
371
- postgres:
372
- image: postgres:17-alpine
373
- container_name: ${r}-postgres
374
- restart: unless-stopped
375
- environment:
376
- POSTGRES_USER: ${r}
377
- POSTGRES_PASSWORD: ${r}_dev_password
378
- POSTGRES_DB: ${r}_dev
379
- ports:
380
- - "5432:5432"
381
- volumes:
382
- - postgres_data:/var/lib/postgresql/data
383
- healthcheck:
384
- test: ["CMD-SHELL", "pg_isready -U ${r} -d ${r}_dev"]
385
- interval: 10s
386
- timeout: 5s
387
- retries: 5
388
-
389
- volumes:
390
- postgres_data:
391
- name: ${r}_postgres_data
392
- `),await e(m(t,"docker-compose.prod.yml"),`services:
393
- app:
394
- build: .
395
- restart: unless-stopped
396
- env_file: .env
397
- depends_on:
398
- postgres:
399
- condition: service_healthy
400
- ports:
401
- - "3000:3000"
402
- networks:
403
- - internal
404
-
405
- postgres:
406
- image: postgres:17-alpine
407
- restart: unless-stopped
408
- environment:
409
- POSTGRES_USER: ${r}
410
- POSTGRES_PASSWORD: \${DB_PASSWORD}
411
- POSTGRES_DB: ${r}
412
- volumes:
413
- - postgres_data:/var/lib/postgresql/data
414
- healthcheck:
415
- test: ["CMD-SHELL", "pg_isready -U ${r} -d ${r}"]
416
- interval: 10s
417
- timeout: 5s
418
- retries: 5
419
- networks:
420
- - internal
421
-
422
- volumes:
423
- postgres_data:
424
-
425
- networks:
426
- internal:
427
- `),await y(m(t,".gitignore"),`
428
- # Toolkit generated files
429
- generated/
430
-
431
- # Environment
432
- .env*
433
- !.env.example
434
- `)}import{join as x}from"path";async function A(t,n){await e(x(t,"entities/index.ts"),`export { Article } from './article'
435
- export { Category } from './category'
436
- `),await e(x(t,"entities/article.ts"),`import { behavior, defineEntity, field } from '@murumets-ee/entity'
437
-
438
- export const Article = defineEntity({
439
- name: 'article',
440
- fields: {
441
- title: field.text({ required: true, maxLength: 200, indexed: true, translatable: true }),
442
- slug: field.slug({ from: 'title', unique: true }),
443
- excerpt: field.text({ maxLength: 500, translatable: true }),
444
- body: field.richtext(),
445
- viewCount: field.number({ default: 0, integer: true }),
446
- featured: field.boolean({ default: false }),
447
- publishDate: field.date(),
448
- contentType: field.select({ options: ['news', 'tutorial', 'announcement'], default: 'news' }),
449
- category: field.reference({ entity: 'category', required: false }),
450
- tags: field.reference({ entity: 'category', cardinality: 'many' }),
451
- coverImage: field.media({ accept: ['image/*'] }),
452
- },
453
- behaviors: [
454
- behavior.publishable(),
455
- behavior.auditable(),
456
- behavior.sluggable('title'),
457
- behavior.revisionable(),
458
- ],
459
- scope: 'global',
460
- access: {
461
- view: 'public',
462
- create: 'group.editor',
463
- update: 'group.editor',
464
- delete: 'group.admin',
465
- },
466
- })
467
- `),await e(x(t,"entities/category.ts"),`import { defineEntity, field } from '@murumets-ee/entity'
468
-
469
- export const Category = defineEntity({
470
- name: 'category',
471
- fields: {
472
- name: field.text({ required: true, maxLength: 100, indexed: true, translatable: true }),
473
- slug: field.slug({ from: 'name', unique: true }),
474
- description: field.text({ maxLength: 500, translatable: true }),
475
- },
476
- scope: 'global',
477
- access: {
478
- view: 'public',
479
- create: 'group.editor',
480
- update: 'group.editor',
481
- delete: 'group.admin',
482
- },
483
- })
484
- `)}import{join as N}from"path";async function T(t,n){await e(N(t,"i18n/routing.ts"),`import { defineRouting } from 'next-intl/routing'
485
-
486
- export const routing = defineRouting({
487
- locales: ['en'],
488
- defaultLocale: 'en',
489
- })
490
- `),await e(N(t,"i18n/request.ts"),`import { getRequestConfig } from 'next-intl/server'
491
- import { hasLocale } from 'next-intl'
492
- import { routing } from './routing'
493
- import { getAuthMessages } from '@murumets-ee/auth-ui/i18n'
494
-
495
- export default getRequestConfig(async ({ requestLocale }) => {
496
- const requested = await requestLocale
497
- const locale = hasLocale(routing.locales, requested)
498
- ? requested
499
- : routing.defaultLocale
500
-
501
- const authMessages = await getAuthMessages(locale)
502
-
503
- return {
504
- locale,
505
- messages: {
506
- ...authMessages,
507
- },
508
- }
509
- })
510
- `)}import{mkdir as S}from"fs/promises";import{join as o}from"path";var i={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",drizzleKit:"0.31.10",tsx:"4.19.2",babelReactCompiler:"1.0.0"};async function E(t,n,r){await L(t,n),r?.("Workspace root created"),r?.("Creating admin app..."),await $(t,n),r?.("Admin app created"),r?.("Creating web app..."),await M(t,n),r?.("Web app created"),await _(t,n),r?.("Shared config package created")}async function L(t,n){let{name:r}=n;await S(t,{recursive:!0}),await e(o(t,"pnpm-workspace.yaml"),`packages:
511
- - 'packages/*'
512
- - 'apps/*'
513
-
514
- ignoredBuiltDependencies:
515
- - sharp
516
- - unrs-resolver
517
- `),await e(o(t,"package.json"),`${JSON.stringify({name:`@${r}/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:`^${i.tsx}`,"drizzle-kit":`^${i.drizzleKit}`}},null,2)}
518
- `),await e(o(t,".gitignore"),`# dependencies
519
- node_modules/
520
-
521
- # build
522
- dist/
523
- .next/
524
- .turbo/
525
-
526
- # env
527
- .env*
528
- !.env.example
529
-
530
- # toolkit generated
531
- generated/
532
-
533
- # IDE
534
- .vscode/
535
- .idea/
536
-
537
- # OS
538
- .DS_Store
539
- Thumbs.db
540
-
541
- # logs
542
- *.log
543
-
544
- # migrations meta
545
- migrations/
546
-
547
- # turbo
548
- .turbo/
549
- `),await e(o(t,".env.example"),`DATABASE_URL=postgresql://${r}:${r}_dev_password@localhost:5432/${r}_dev
550
- BETTER_AUTH_SECRET=dev-secret-change-me-in-production-min-32-chars
551
- BETTER_AUTH_URL=http://localhost:3000
552
- LOG_LEVEL=debug
553
- NEXT_PUBLIC_APP_URL=http://localhost:3000
554
- QUEUE_WORKER=true
555
- RESEND_API_KEY=
556
- RESEND_WEBHOOK_SECRET=
557
- MAIL_FROM=noreply@example.com
558
- CSAT_SECRET=
559
- `),await e(o(t,"docker-compose.yml"),`services:
560
- postgres:
561
- image: postgres:17-alpine
562
- container_name: ${r}-postgres
563
- restart: unless-stopped
564
- environment:
565
- POSTGRES_USER: ${r}
566
- POSTGRES_PASSWORD: ${r}_dev_password
567
- POSTGRES_DB: ${r}_dev
568
- ports:
569
- - "5432:5432"
570
- volumes:
571
- - postgres_data:/var/lib/postgresql/data
572
- healthcheck:
573
- test: ["CMD-SHELL", "pg_isready -U ${r} -d ${r}_dev"]
574
- interval: 10s
575
- timeout: 5s
576
- retries: 5
577
-
578
- volumes:
579
- postgres_data:
580
- name: ${r}_postgres_data
581
- `)}async function _(t,n){let{name:r}=n,a=o(t,"packages/config");await e(o(a,"package.json"),`${JSON.stringify({name:`@${r}/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":`^${i.myorgCore}`,"@murumets-ee/db":`^${i.myorgDb}`,"@murumets-ee/entity":`^${i.myorgEntity}`,"@murumets-ee/logging":`^${i.myorgLogging}`,"@murumets-ee/auth":`^${i.myorgAuth}`,"better-auth":`^${i.betterAuth}`,"drizzle-orm":`^${i.drizzleOrm}`,postgres:`^${i.postgres}`,zod:`^${i.zod}`}},null,2)}
582
- `),await e(o(a,"tsconfig.json"),`${JSON.stringify({compilerOptions:{target:"ES2022",module:"ESNext",moduleResolution:"Bundler",strict:!0,esModuleInterop:!0,skipLibCheck:!0,resolveJsonModule:!0},include:["**/*.ts"]},null,2)}
583
- `),await e(o(a,"toolkit.config.ts"),`import { auth } from '@murumets-ee/auth/plugin'
584
- import { content } from '@murumets-ee/content/plugin'
585
- import { defineConfig } from '@murumets-ee/core'
586
- import { logging } from '@murumets-ee/logging/plugin'
587
- import { mail, ResendMailProvider } from '@murumets-ee/mail'
588
- import { media } from '@murumets-ee/media/plugin'
589
- import { queue } from '@murumets-ee/queue/plugin'
590
- import { settings } from '@murumets-ee/settings/plugin'
591
- import { storage } from '@murumets-ee/storage/plugin'
592
- import { taxonomy } from '@murumets-ee/taxonomy/plugin'
593
- import { ticketing } from '@murumets-ee/ticketing/plugin'
594
- import { Article, Category } from './entities'
595
- import * as authSchema from './generated/auth-schema'
596
-
597
- if (!process.env.DATABASE_URL) {
598
- throw new Error('DATABASE_URL environment variable is required')
599
- }
600
-
601
- export default defineConfig({
602
- db: {
603
- url: process.env.DATABASE_URL,
604
- poolMin: 2,
605
- poolMax: 10,
606
- },
607
- logging: {
608
- level: (process.env.LOG_LEVEL || 'info') as 'debug' | 'info' | 'warn' | 'error',
609
- name: '${r}',
610
- },
611
- entities: [Category, Article],
612
- plugins: [
613
- auth({ providers: ['email'], schema: authSchema }),
614
- content({
615
- locales: [{ code: 'en', label: 'English' }],
616
- defaultLocale: 'en',
617
- }),
618
- logging(),
619
- settings(),
620
- storage(),
621
- media(),
622
- taxonomy(),
623
- queue(),
624
- mail({
625
- provider: process.env.RESEND_API_KEY
626
- ? new ResendMailProvider({ apiKey: process.env.RESEND_API_KEY })
627
- : undefined,
628
- defaultFrom: process.env.MAIL_FROM ?? 'noreply@example.com',
629
- webhookSecret: process.env.RESEND_WEBHOOK_SECRET,
630
- }),
631
- ticketing({
632
- csatSecret: process.env.CSAT_SECRET,
633
- }),
634
- ],
635
- projectRoot: import.meta.dirname,
636
- })
637
- `),await e(o(a,"auth.config.ts"),`import { betterAuth } from 'better-auth'
638
- import { drizzleAdapter } from 'better-auth/adapters/drizzle'
639
- import { admin } from 'better-auth/plugins'
640
- import { organization } from 'better-auth/plugins/organization'
641
- import { drizzle } from 'drizzle-orm/postgres-js'
642
- import postgres from 'postgres'
643
-
644
- const sql = postgres(process.env.DATABASE_URL!)
645
- const db = drizzle(sql)
646
-
647
- export const auth = betterAuth({
648
- database: drizzleAdapter(db, { provider: 'pg' }),
649
- emailAndPassword: { enabled: true },
650
- plugins: [
651
- admin(),
652
- organization(),
653
- ],
654
- })
655
- `),await e(o(a,"drizzle.config.ts"),`import type { Config } from 'drizzle-kit'
656
-
657
- if (!process.env.DATABASE_URL) {
658
- throw new Error('DATABASE_URL environment variable is required')
659
- }
660
-
661
- export default {
662
- schema: ['./generated/schema.ts', './generated/auth-schema.ts'],
663
- out: './migrations',
664
- dialect: 'postgresql',
665
- dbCredentials: {
666
- url: process.env.DATABASE_URL,
667
- },
668
- } satisfies Config
669
- `),await e(o(a,"entities/index.ts"),`export { Article } from './article'
670
- export { Category } from './category'
671
- `),await e(o(a,"entities/article.ts"),`import { behavior, defineEntity, field } from '@murumets-ee/entity'
672
-
673
- export const Article = defineEntity({
674
- name: 'article',
675
- fields: {
676
- title: field.text({ required: true, maxLength: 200, indexed: true, translatable: true }),
677
- slug: field.slug({ from: 'title', unique: true }),
678
- excerpt: field.text({ maxLength: 500, translatable: true }),
679
- body: field.richtext(),
680
- viewCount: field.number({ default: 0, integer: true }),
681
- featured: field.boolean({ default: false }),
682
- publishDate: field.date(),
683
- contentType: field.select({ options: ['news', 'tutorial', 'announcement'], default: 'news' }),
684
- category: field.reference({ entity: 'category', required: false }),
685
- tags: field.reference({ entity: 'category', cardinality: 'many' }),
686
- coverImage: field.media({ accept: ['image/*'] }),
687
- },
688
- behaviors: [
689
- behavior.publishable(),
690
- behavior.auditable(),
691
- behavior.sluggable('title'),
692
- behavior.revisionable(),
693
- ],
694
- scope: 'global',
695
- access: {
696
- view: 'public',
697
- create: 'group.editor',
698
- update: 'group.editor',
699
- delete: 'group.admin',
700
- },
701
- })
702
- `),await e(o(a,"entities/category.ts"),`import { defineEntity, field } from '@murumets-ee/entity'
703
-
704
- export const Category = defineEntity({
705
- name: 'category',
706
- fields: {
707
- name: field.text({ required: true, maxLength: 100, indexed: true, translatable: true }),
708
- slug: field.slug({ from: 'name', unique: true }),
709
- description: field.text({ maxLength: 500, translatable: true }),
710
- },
711
- scope: 'global',
712
- access: {
713
- view: 'public',
714
- create: 'group.editor',
715
- update: 'group.editor',
716
- delete: 'group.admin',
717
- },
718
- })
719
- `),await e(o(a,"lib/app.ts"),`import { createApp, setApp, type ToolkitApp } from '@murumets-ee/core'
720
- import config from '../toolkit.config'
721
-
722
- let appInstance: ToolkitApp | null = null
723
-
724
- export async function getToolkitApp(): Promise<ToolkitApp> {
725
- if (!appInstance) {
726
- console.log('Initializing toolkit app...')
727
- appInstance = await createApp(config)
728
- setApp(appInstance)
729
- console.log('Toolkit app initialized')
730
- }
731
- return appInstance
732
- }
733
- `),await e(o(a,"lib/auth.ts"),`import { getToolkitApp } from './app'
734
- import { getAuth } from '@murumets-ee/auth'
735
-
736
- export async function getAuthInstance() {
737
- await getToolkitApp()
738
- return getAuth()
739
- }
740
- `),await e(o(a,"lib/auth-client.ts"),`import { createClient } from '@murumets-ee/auth/client'
741
-
742
- export const authClient = createClient()
743
- `),await e(o(a,"generated/auth-schema.ts"),`// This file is generated by better-auth CLI.
744
- // Run: npx @better-auth/cli generate --config auth.config.ts -y
745
- export {}
746
- `),await e(o(a,"scripts/generate-schema.ts"),`/**
747
- * Generate Drizzle schemas from entity definitions
748
- */
749
-
750
- import { mkdir, writeFile } from 'node:fs/promises'
751
- import { join } from 'node:path'
752
- import { generateSchemaCode, generateTranslationSchemaCode } from '@murumets-ee/entity'
753
- import config from '../toolkit.config'
754
-
755
- async function generateSchemas() {
756
- console.log('Generating Drizzle schemas from entity definitions...')
757
-
758
- const schemaDir = join(import.meta.dirname, '..', 'generated')
759
- await mkdir(schemaDir, { recursive: true })
760
-
761
- const imports: string[] = []
762
- const schemas: string[] = []
763
- let hasTranslations = false
764
-
765
- for (const entity of config.entities) {
766
- console.log(\` - Generating schema for \${entity.name}\`)
767
-
768
- const schemaCode = generateSchemaCode(entity)
769
- schemas.push(\`\\n// \${entity.name} table\`)
770
- schemas.push(schemaCode)
771
-
772
- const translationCode = generateTranslationSchemaCode(entity)
773
- if (translationCode) {
774
- hasTranslations = true
775
- schemas.push(\`\\n// \${entity.name} translations\`)
776
- schemas.push(translationCode)
777
- }
778
- }
779
-
780
- const pgCoreTypes = ['pgTable', 'varchar', 'text', 'boolean', 'timestamp', 'integer', 'doublePrecision', 'jsonb', 'uuid', 'index']
781
- if (hasTranslations) pgCoreTypes.push('unique')
782
- const pgCoreImports = \`import { \${pgCoreTypes.join(', ')} } from 'drizzle-orm/pg-core'\\n\`
783
- imports.push(pgCoreImports)
784
-
785
- const schemaFile = join(schemaDir, 'schema.ts')
786
- await writeFile(schemaFile, [...imports, ...schemas].join('\\n'))
787
-
788
- console.log(\`\\nSchemas written to: \${schemaFile}\`)
789
- console.log('Run \\\`pnpm db:migrate:generate\\\` to create migrations')
790
- }
791
-
792
- generateSchemas().catch(console.error)
793
- `),await e(o(a,"scripts/migrate.ts"),`/**
794
- * Run pending migrations
795
- */
796
-
797
- import { createDbClient, runMigrations } from '@murumets-ee/db'
798
-
799
- async function migrate() {
800
- console.log('Running migrations...')
801
-
802
- try {
803
- if (!process.env.DATABASE_URL) {
804
- throw new Error('DATABASE_URL environment variable is required')
805
- }
806
-
807
- const db = createDbClient({ url: process.env.DATABASE_URL })
808
- await runMigrations(db, import.meta.dirname + '/..')
809
-
810
- console.log('Migrations completed successfully')
811
- process.exit(0)
812
- } catch (error) {
813
- console.error('Migration failed:', error)
814
- process.exit(1)
815
- }
816
- }
817
-
818
- migrate()
819
- `),await e(o(a,"scripts/reset-db.ts"),`/**
820
- * Reset database (DROP all tables)
821
- * WARNING: Only for development
822
- */
823
-
824
- import postgres from 'postgres'
825
-
826
- async function resetDb() {
827
- const DATABASE_URL = process.env.DATABASE_URL
828
-
829
- if (!DATABASE_URL) {
830
- throw new Error('DATABASE_URL not set')
831
- }
832
-
833
- console.warn('WARNING: This will DROP ALL TABLES')
834
- console.log('Database:', DATABASE_URL.split('@')[1])
835
-
836
- const sql = postgres(DATABASE_URL)
837
-
838
- try {
839
- await sql\`
840
- DROP SCHEMA public CASCADE;
841
- CREATE SCHEMA public;
842
- GRANT ALL ON SCHEMA public TO PUBLIC;
843
- \`
844
-
845
- console.log('Database reset complete')
846
- } finally {
847
- await sql.end()
848
- }
849
- }
850
-
851
- resetDb().catch(console.error)
852
- `)}async function $(t,n){let{name:r}=n,a=o(t,"apps/admin");await S(o(t,"apps"),{recursive:!0}),l(`pnpm create next-app@${"16"} ${a} --typescript --tailwind --no-eslint --app --no-src-dir --turbopack --react-compiler --skip-install --import-alias "@/*"`),await u(a,["app/page.tsx","app/page.module.css","app/fonts","README.md","pnpm-workspace.yaml"]),await c(o(a,"package.json"),{dependencies:{[`@${r}/config`]:"workspace:*","@murumets-ee/auth-ui":`^${i.myorgAuthUi}`,"better-auth":`^${i.betterAuth}`,"next-intl":`^${i.nextIntl}`,"next-themes":`^${i.nextThemes}`,"lucide-react":`^${i.lucideReact}`,"react-hook-form":`^${i.reactHookForm}`,"@hookform/resolvers":`^${i.hookformResolvers}`,zod:`^${i.zod}`},devDependencies:{"babel-plugin-react-compiler":i.babelReactCompiler}});let{appendToFile:h}=await import("./utils-42K2ZGUL.js");await h(o(a,".gitignore"),`
853
- # Environment
854
- .env*
855
- !.env.example
856
- `),await e(o(a,"next.config.ts"),`import type { NextConfig } from 'next'
857
- import createNextIntlPlugin from 'next-intl/plugin'
858
-
859
- const withNextIntl = createNextIntlPlugin('./i18n/request.ts')
860
-
861
- const nextConfig: NextConfig = {
862
- reactCompiler: true,
863
- transpilePackages: [
864
- '@${r}/config',
865
- '@murumets-ee/core',
866
- '@murumets-ee/entity',
867
- '@murumets-ee/db',
868
- '@murumets-ee/logging',
869
- '@murumets-ee/auth-ui',
870
- ],
871
- serverExternalPackages: ['drizzle-orm', 'postgres'],
872
- experimental: {
873
- serverActions: {
874
- bodySizeLimit: '2mb',
875
- },
876
- },
877
- }
878
-
879
- export default withNextIntl(nextConfig)
880
- `),await e(o(a,"proxy.ts"),`import { NextRequest, NextResponse } from 'next/server'
881
- import { getSessionCookie } from 'better-auth/cookies'
882
- import createMiddleware from 'next-intl/middleware'
883
- import { routing } from './i18n/routing'
884
-
885
- const intlMiddleware = createMiddleware(routing)
886
-
887
- const protectedPaths = ['/setup']
888
-
889
- export function proxy(request: NextRequest) {
890
- const { pathname } = request.nextUrl
891
-
892
- const localePattern = new RegExp(\`^/(\${routing.locales.join('|')})\`)
893
- const pathWithoutLocale = pathname.replace(localePattern, '') || '/'
894
-
895
- if (protectedPaths.some((p) => pathWithoutLocale.startsWith(p))) {
896
- const session = getSessionCookie(request)
897
- if (!session) {
898
- const locale = pathname.match(localePattern)?.[1] || routing.defaultLocale
899
- return NextResponse.redirect(new URL(\`/\${locale}/auth/sign-in\`, request.url))
900
- }
901
- }
902
-
903
- return intlMiddleware(request)
904
- }
905
-
906
- export const config = {
907
- matcher: '/((?!api|_next|_vercel|.*\\\\..*).*)',
908
- }
909
- `),await e(o(a,"i18n/routing.ts"),`import { defineRouting } from 'next-intl/routing'
910
-
911
- export const routing = defineRouting({
912
- locales: ['en'],
913
- defaultLocale: 'en',
914
- })
915
- `),await e(o(a,"i18n/request.ts"),`import { getRequestConfig } from 'next-intl/server'
916
- import { hasLocale } from 'next-intl'
917
- import { routing } from './routing'
918
- import { getAuthMessages } from '@murumets-ee/auth-ui/i18n'
919
-
920
- export default getRequestConfig(async ({ requestLocale }) => {
921
- const requested = await requestLocale
922
- const locale = hasLocale(routing.locales, requested)
923
- ? requested
924
- : routing.defaultLocale
925
-
926
- const authMessages = await getAuthMessages(locale)
927
-
928
- return {
929
- locale,
930
- messages: {
931
- ...authMessages,
932
- },
933
- }
934
- })
935
- `),await e(o(a,"app/globals.css"),`@import "tailwindcss";
936
- @source "../node_modules/@murumets-ee/auth-ui/dist";
937
-
938
- @custom-variant dark (&:where(.dark, .dark *));
939
-
940
- :root {
941
- --background: #ffffff;
942
- --foreground: #171717;
943
- }
944
-
945
- @theme inline {
946
- --color-background: var(--background);
947
- --color-foreground: var(--foreground);
948
- --font-sans: var(--font-geist-sans);
949
- --font-mono: var(--font-geist-mono);
950
- }
951
-
952
- .dark {
953
- --background: #0a0a0a;
954
- --foreground: #ededed;
955
- }
956
-
957
- body {
958
- background: var(--background);
959
- color: var(--foreground);
960
- font-family: Arial, Helvetica, sans-serif;
961
- }
962
- `),await e(o(a,"app/theme-provider.tsx"),`'use client'
963
-
964
- import { ThemeProvider as NextThemesProvider } from 'next-themes'
965
- import type { ReactNode } from 'react'
966
-
967
- export function ThemeProvider({ children }: { children: ReactNode }) {
968
- return (
969
- <NextThemesProvider
970
- attribute="class"
971
- defaultTheme="system"
972
- enableSystem
973
- disableTransitionOnChange
974
- >
975
- {children}
976
- </NextThemesProvider>
977
- )
978
- }
979
- `),await e(o(a,"app/theme-toggle.tsx"),`'use client'
980
-
981
- import { useTheme } from 'next-themes'
982
- import { useState, useEffect } from 'react'
983
- import { Sun, Moon } from 'lucide-react'
984
-
985
- export function ThemeToggle() {
986
- const [mounted, setMounted] = useState(false)
987
- const { resolvedTheme, setTheme } = useTheme()
988
-
989
- useEffect(() => { setMounted(true) }, [])
990
-
991
- if (!mounted) {
992
- return <div className="h-8 w-8" />
993
- }
994
-
995
- return (
996
- <button
997
- type="button"
998
- onClick={() => setTheme(resolvedTheme === 'dark' ? 'light' : 'dark')}
999
- 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"
1000
- aria-label={resolvedTheme === 'dark' ? 'Switch to light mode' : 'Switch to dark mode'}
1001
- >
1002
- {resolvedTheme === 'dark' ? <Sun className="h-5 w-5" /> : <Moon className="h-5 w-5" />}
1003
- </button>
1004
- )
1005
- }
1006
- `),await e(o(a,"app/nav-header.tsx"),`'use client'
1007
-
1008
- import Link from 'next/link'
1009
- import { usePathname } from 'next/navigation'
1010
- import { ThemeToggle } from './theme-toggle'
1011
-
1012
- const links = [
1013
- { href: '/', label: 'Home' },
1014
- { href: '/auth/sign-in', label: 'Sign In' },
1015
- { href: '/setup', label: 'Setup' },
1016
- ]
1017
-
1018
- export function NavHeader() {
1019
- const pathname = usePathname()
1020
-
1021
- function isActive(href: string) {
1022
- return href === '/' ? pathname === '/' : pathname.startsWith(href)
1023
- }
1024
-
1025
- const linkClass = (href: string) =>
1026
- \`px-3 py-1.5 rounded-md text-sm transition-colors \${
1027
- isActive(href)
1028
- ? 'bg-zinc-200 text-zinc-900 dark:bg-zinc-800 dark:text-zinc-50'
1029
- : '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'
1030
- }\`
1031
-
1032
- return (
1033
- <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">
1034
- <nav className="max-w-6xl mx-auto flex items-center gap-1 px-4 h-12">
1035
- <span className="font-semibold text-sm text-zinc-700 dark:text-zinc-300 mr-3 select-none">
1036
- ${r} Admin
1037
- </span>
1038
- {links.map(({ href, label }) => (
1039
- <Link key={href} href={href} className={linkClass(href)}>
1040
- {label}
1041
- </Link>
1042
- ))}
1043
- <div className="ml-auto">
1044
- <ThemeToggle />
1045
- </div>
1046
- </nav>
1047
- </header>
1048
- )
1049
- }
1050
- `),await e(o(a,"app/layout.tsx"),`import './globals.css'
1051
-
1052
- export default function RootLayout({ children }: { children: React.ReactNode }) {
1053
- return children
1054
- }
1055
- `),await e(o(a,"app/[locale]/layout.tsx"),`import type { Metadata } from 'next'
1056
- import { Geist, Geist_Mono } from 'next/font/google'
1057
- import { NextIntlClientProvider } from 'next-intl'
1058
- import { getMessages } from 'next-intl/server'
1059
- import { notFound } from 'next/navigation'
1060
- import { routing } from '@/i18n/routing'
1061
- import { ThemeProvider } from '../theme-provider'
1062
- import { NavHeader } from '../nav-header'
1063
-
1064
- const geistSans = Geist({
1065
- variable: '--font-geist-sans',
1066
- subsets: ['latin'],
1067
- })
1068
-
1069
- const geistMono = Geist_Mono({
1070
- variable: '--font-geist-mono',
1071
- subsets: ['latin'],
1072
- })
1073
-
1074
- export const metadata: Metadata = {
1075
- title: '${r} Admin',
1076
- description: 'Built with Lumi CMS Toolkit',
1077
- }
1078
-
1079
- export default async function LocaleLayout({
1080
- children,
1081
- params,
1082
- }: {
1083
- children: React.ReactNode
1084
- params: Promise<{ locale: string }>
1085
- }) {
1086
- const { locale } = await params
1087
- if (!routing.locales.includes(locale as any)) notFound()
1088
-
1089
- const messages = await getMessages()
1090
-
1091
- return (
1092
- <html lang={locale} suppressHydrationWarning>
1093
- <body className={\`\${geistSans.variable} \${geistMono.variable} antialiased\`}>
1094
- <ThemeProvider>
1095
- <NextIntlClientProvider locale={locale} messages={messages}>
1096
- <NavHeader />
1097
- {children}
1098
- </NextIntlClientProvider>
1099
- </ThemeProvider>
1100
- </body>
1101
- </html>
1102
- )
1103
- }
1104
- `),await e(o(a,"app/[locale]/page.tsx"),`import { createQueryClient } from '@murumets-ee/core/clients'
1105
- import { Article, Category } from '@${r}/config/entities'
1106
- import { getToolkitApp } from '@${r}/config/app'
1107
-
1108
- export default async function HomePage() {
1109
- await getToolkitApp()
1110
- const articles = createQueryClient(Article)
1111
- const categories = createQueryClient(Category)
1112
-
1113
- const [articleList, categoryList] = await Promise.all([
1114
- articles.findMany({ limit: 10 }),
1115
- categories.findMany({}),
1116
- ])
1117
-
1118
- return (
1119
- <div className="min-h-screen p-8">
1120
- <div className="max-w-4xl mx-auto">
1121
- <h1 className="text-4xl font-bold mb-8">Welcome to ${r}</h1>
1122
-
1123
- <section className="mb-12">
1124
- <h2 className="text-2xl font-semibold mb-4">
1125
- Categories ({categoryList.length})
1126
- </h2>
1127
- <div className="grid gap-4 md:grid-cols-2">
1128
- {categoryList.map((cat) => (
1129
- <div
1130
- key={cat.id}
1131
- className="border border-zinc-200 dark:border-zinc-800 rounded-lg p-4"
1132
- >
1133
- <h3 className="font-semibold text-lg">{cat.name}</h3>
1134
- <p className="text-sm text-zinc-600 dark:text-zinc-400">
1135
- {cat.description}
1136
- </p>
1137
- </div>
1138
- ))}
1139
- </div>
1140
- </section>
1141
-
1142
- <section>
1143
- <h2 className="text-2xl font-semibold mb-4">
1144
- Articles ({articleList.length})
1145
- </h2>
1146
- {articleList.length === 0 ? (
1147
- <p className="text-zinc-500">No published articles yet.</p>
1148
- ) : (
1149
- <div className="space-y-4">
1150
- {articleList.map((article) => (
1151
- <div
1152
- key={article.id}
1153
- className="border border-zinc-200 dark:border-zinc-800 rounded-lg p-6"
1154
- >
1155
- <h3 className="text-xl font-bold">{article.title}</h3>
1156
- <p className="text-zinc-600 dark:text-zinc-400 mt-2">
1157
- {article.excerpt}
1158
- </p>
1159
- </div>
1160
- ))}
1161
- </div>
1162
- )}
1163
- </section>
1164
- </div>
1165
- </div>
1166
- )
1167
- }
1168
- `),await e(o(a,"app/api/auth/[...all]/route.ts"),`import { toNextJsHandler } from 'better-auth/next-js'
1169
- import { getAuthInstance } from '@${r}/config/auth'
1170
-
1171
- let _handler: ReturnType<typeof toNextJsHandler> | null = null
1172
-
1173
- async function handler() {
1174
- if (!_handler) {
1175
- const auth = await getAuthInstance()
1176
- _handler = toNextJsHandler(auth)
1177
- }
1178
- return _handler
1179
- }
1180
-
1181
- export async function GET(req: Request) {
1182
- return (await handler()).GET(req)
1183
- }
1184
-
1185
- export async function POST(req: Request) {
1186
- return (await handler()).POST(req)
1187
- }
1188
- `),await e(o(a,"app/[locale]/auth/layout.tsx"),`import { AuthProviders } from './providers'
1189
- import type { ReactNode } from 'react'
1190
-
1191
- export default function AuthLayout({ children }: { children: ReactNode }) {
1192
- return (
1193
- <AuthProviders>
1194
- <div className="flex min-h-[calc(100vh-3rem)] items-center justify-center px-4">
1195
- {children}
1196
- </div>
1197
- </AuthProviders>
1198
- )
1199
- }
1200
- `),await e(o(a,"app/[locale]/auth/providers.tsx"),`'use client'
1201
-
1202
- import { AuthUIProvider } from '@murumets-ee/auth-ui'
1203
- import { authClient } from '@${r}/config/auth-client'
1204
- import Link from 'next/link'
1205
- import { useRouter } from 'next/navigation'
1206
- import { useLocale } from 'next-intl'
1207
- import type { ReactNode } from 'react'
1208
-
1209
- export function AuthProviders({ children }: { children: ReactNode }) {
1210
- const router = useRouter()
1211
- const locale = useLocale()
1212
-
1213
- return (
1214
- <AuthUIProvider
1215
- authClient={authClient as never}
1216
- basePath="/auth"
1217
- redirectTo="/"
1218
- Link={Link}
1219
- navigate={(url) => router.push(url)}
1220
- resetPasswordUrl={\`/\${locale}/auth/reset-password\`}
1221
- >
1222
- {children}
1223
- </AuthUIProvider>
1224
- )
1225
- }
1226
- `),await e(o(a,"app/[locale]/auth/sign-in/page.tsx"),`import { SignInForm } from '@murumets-ee/auth-ui'
1227
-
1228
- export default function SignInPage() {
1229
- return <SignInForm />
1230
- }
1231
- `),await e(o(a,"app/[locale]/auth/sign-up/page.tsx"),`import { SignUpForm } from '@murumets-ee/auth-ui'
1232
-
1233
- export default function SignUpPage() {
1234
- return <SignUpForm />
1235
- }
1236
- `),await e(o(a,"app/[locale]/auth/forgot-password/page.tsx"),`import { ForgotPasswordForm } from '@murumets-ee/auth-ui'
1237
-
1238
- export default function ForgotPasswordPage() {
1239
- return <ForgotPasswordForm />
1240
- }
1241
- `),await e(o(a,"app/[locale]/auth/reset-password/page.tsx"),`import { Suspense } from 'react'
1242
- import { ResetPasswordContent } from './content'
1243
-
1244
- export default function ResetPasswordPage() {
1245
- return (
1246
- <Suspense>
1247
- <ResetPasswordContent />
1248
- </Suspense>
1249
- )
1250
- }
1251
- `),await e(o(a,"app/[locale]/auth/reset-password/content.tsx"),`'use client'
1252
-
1253
- import { useSearchParams } from 'next/navigation'
1254
- import { ResetPasswordForm } from '@murumets-ee/auth-ui'
1255
-
1256
- export function ResetPasswordContent() {
1257
- const searchParams = useSearchParams()
1258
- const token = searchParams.get('token')
1259
-
1260
- if (!token) {
1261
- return (
1262
- <div className="text-center">
1263
- <h1 className="text-2xl font-bold text-zinc-900 dark:text-zinc-50">
1264
- Invalid or expired link
1265
- </h1>
1266
- <p className="mt-2 text-zinc-500">
1267
- Please request a new password reset.
1268
- </p>
1269
- </div>
1270
- )
1271
- }
1272
-
1273
- return <ResetPasswordForm token={token} />
1274
- }
1275
- `),await e(o(a,"app/[locale]/setup/page.tsx"),`import { redirect } from 'next/navigation'
1276
- import { sql } from 'drizzle-orm'
1277
- import { getToolkitApp } from '@${r}/config/app'
1278
- import { SetupForm } from './form'
1279
-
1280
- export default async function SetupPage() {
1281
- const app = await getToolkitApp()
1282
- const result = await app.db.readOnly.execute<{ count: string }>(
1283
- sql\`SELECT COUNT(*)::text as count FROM "user"\`,
1284
- )
1285
-
1286
- if (Number(result[0]?.count) > 0) {
1287
- redirect('/')
1288
- }
1289
-
1290
- return (
1291
- <div className="max-w-md mx-auto p-8">
1292
- <h1 className="text-2xl font-bold mb-2">Create Admin</h1>
1293
- <p className="text-sm text-zinc-500 dark:text-zinc-400 mb-6">
1294
- No users found. Create the first admin account.
1295
- </p>
1296
- <SetupForm />
1297
- </div>
1298
- )
1299
- }
1300
- `),await e(o(a,"app/[locale]/setup/form.tsx"),`'use client'
1301
-
1302
- import { useState } from 'react'
1303
- import { createFirstAdmin } from './actions'
1304
-
1305
- export function SetupForm() {
1306
- const [result, setResult] = useState<{ ok?: boolean; error?: string; email?: string } | null>(null)
1307
- const [loading, setLoading] = useState(false)
1308
-
1309
- async function handleSubmit(e: React.FormEvent<HTMLFormElement>) {
1310
- e.preventDefault()
1311
- setLoading(true)
1312
- setResult(null)
1313
- const res = await createFirstAdmin(new FormData(e.currentTarget))
1314
- setResult(res)
1315
- setLoading(false)
1316
- }
1317
-
1318
- if (result?.ok) {
1319
- return (
1320
- <div className="space-y-2">
1321
- <p className="text-green-600 dark:text-green-400">Admin created: {result.email}</p>
1322
- <a href="/auth/sign-in" className="text-blue-600 dark:text-blue-400 hover:underline">
1323
- Sign in &rarr;
1324
- </a>
1325
- </div>
1326
- )
1327
- }
1328
-
1329
- return (
1330
- <form onSubmit={handleSubmit} className="flex flex-col gap-4">
1331
- <label className="text-sm font-medium">
1332
- Name
1333
- <input
1334
- name="name"
1335
- required
1336
- 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"
1337
- />
1338
- </label>
1339
- <label className="text-sm font-medium">
1340
- Email
1341
- <input
1342
- name="email"
1343
- type="email"
1344
- required
1345
- 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"
1346
- />
1347
- </label>
1348
- <label className="text-sm font-medium">
1349
- Password (min 8 chars)
1350
- <input
1351
- name="password"
1352
- type="password"
1353
- required
1354
- minLength={8}
1355
- 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"
1356
- />
1357
- </label>
1358
-
1359
- {result?.error && <p className="text-red-600 dark:text-red-400 text-sm">{result.error}</p>}
1360
-
1361
- <button
1362
- type="submit"
1363
- disabled={loading}
1364
- className="px-4 py-2 text-sm rounded-md bg-blue-600 text-white hover:bg-blue-500 disabled:opacity-50 transition-colors"
1365
- >
1366
- {loading ? 'Creating...' : 'Create Admin'}
1367
- </button>
1368
- </form>
1369
- )
1370
- }
1371
- `),await e(o(a,"app/[locale]/setup/actions.ts"),`'use server'
1372
-
1373
- import { sql } from 'drizzle-orm'
1374
- import { getToolkitApp } from '@${r}/config/app'
1375
- import { getAuth } from '@murumets-ee/auth'
1376
-
1377
- export async function createFirstAdmin(formData: FormData) {
1378
- const email = formData.get('email') as string
1379
- const password = formData.get('password') as string
1380
- const name = formData.get('name') as string
1381
-
1382
- if (!email || !password || !name) {
1383
- return { error: 'All fields are required' }
1384
- }
1385
-
1386
- if (password.length < 8) {
1387
- return { error: 'Password must be at least 8 characters' }
1388
- }
1389
-
1390
- const app = await getToolkitApp()
1391
-
1392
- const canCreate = await app.db.readWrite.transaction(async (tx) => {
1393
- await tx.execute(sql\`SELECT pg_advisory_xact_lock(1)\`)
1394
-
1395
- const result = await tx.execute<{ count: string }>(
1396
- sql\`SELECT COUNT(*)::text as count FROM "user"\`,
1397
- )
1398
- return Number(result[0]?.count) === 0
1399
- })
1400
-
1401
- if (!canCreate) {
1402
- return { error: 'Admin user already exists. Setup is complete.' }
1403
- }
1404
-
1405
- const auth = getAuth()
1406
-
1407
- const adminUser = await auth.api.signUpEmail({
1408
- body: { email, password, name },
1409
- })
1410
-
1411
- await app.db.readWrite.execute(
1412
- sql\`UPDATE "user" SET role = 'admin' WHERE id = \${adminUser.user.id}\`,
1413
- )
1414
-
1415
- return { ok: true, email: adminUser.user.email }
1416
- }
1417
- `)}async function M(t,n){let{name:r}=n,a=o(t,"apps/web");l(`pnpm create next-app@${"16"} ${a} --typescript --tailwind --no-eslint --app --no-src-dir --turbopack --react-compiler --skip-install --import-alias "@/*"`),await u(a,["app/page.tsx","app/page.module.css","app/fonts","README.md","pnpm-workspace.yaml"]),await c(o(a,"package.json"),{dependencies:{[`@${r}/config`]:"workspace:*","@murumets-ee/core":`^${i.myorgCore}`,"@murumets-ee/auth-ui":`^${i.myorgAuthUi}`,"next-intl":`^${i.nextIntl}`,"next-themes":`^${i.nextThemes}`,"lucide-react":`^${i.lucideReact}`},devDependencies:{"babel-plugin-react-compiler":i.babelReactCompiler}});let{appendToFile:h}=await import("./utils-42K2ZGUL.js");await h(o(a,".gitignore"),`
1418
- # Environment
1419
- .env*
1420
- !.env.example
1421
- `),await e(o(a,"next.config.ts"),`import type { NextConfig } from 'next'
1422
- import createNextIntlPlugin from 'next-intl/plugin'
1423
-
1424
- const withNextIntl = createNextIntlPlugin('./i18n/request.ts')
1425
-
1426
- const nextConfig: NextConfig = {
1427
- reactCompiler: true,
1428
- transpilePackages: [
1429
- '@${r}/config',
1430
- '@murumets-ee/core',
1431
- '@murumets-ee/entity',
1432
- '@murumets-ee/db',
1433
- '@murumets-ee/logging',
1434
- '@murumets-ee/auth-ui',
1435
- ],
1436
- serverExternalPackages: ['drizzle-orm', 'postgres'],
1437
- }
1438
-
1439
- export default withNextIntl(nextConfig)
1440
- `),await e(o(a,"proxy.ts"),`import createMiddleware from 'next-intl/middleware'
1441
- import { routing } from './i18n/routing'
1442
-
1443
- export default createMiddleware(routing)
1444
-
1445
- export const config = {
1446
- matcher: '/((?!api|_next|_vercel|.*\\\\..*).*)',
1447
- }
1448
- `),await e(o(a,"i18n/routing.ts"),`import { defineRouting } from 'next-intl/routing'
1449
-
1450
- export const routing = defineRouting({
1451
- locales: ['en'],
1452
- defaultLocale: 'en',
1453
- })
1454
- `),await e(o(a,"i18n/request.ts"),`import { getRequestConfig } from 'next-intl/server'
1455
- import { hasLocale } from 'next-intl'
1456
- import { routing } from './routing'
1457
- import { getAuthMessages } from '@murumets-ee/auth-ui/i18n'
1458
-
1459
- export default getRequestConfig(async ({ requestLocale }) => {
1460
- const requested = await requestLocale
1461
- const locale = hasLocale(routing.locales, requested)
1462
- ? requested
1463
- : routing.defaultLocale
1464
-
1465
- const authMessages = await getAuthMessages(locale)
1466
-
1467
- return {
1468
- locale,
1469
- messages: {
1470
- ...authMessages,
1471
- },
1472
- }
1473
- })
1474
- `),await e(o(a,"app/globals.css"),`@import "tailwindcss";
1475
- @source "../node_modules/@murumets-ee/auth-ui/dist";
1476
-
1477
- @custom-variant dark (&:where(.dark, .dark *));
1478
-
1479
- :root {
1480
- --background: #ffffff;
1481
- --foreground: #171717;
1482
- }
1483
-
1484
- @theme inline {
1485
- --color-background: var(--background);
1486
- --color-foreground: var(--foreground);
1487
- --font-sans: var(--font-geist-sans);
1488
- --font-mono: var(--font-geist-mono);
1489
- }
1490
-
1491
- .dark {
1492
- --background: #0a0a0a;
1493
- --foreground: #ededed;
1494
- }
1495
-
1496
- body {
1497
- background: var(--background);
1498
- color: var(--foreground);
1499
- font-family: Arial, Helvetica, sans-serif;
1500
- }
1501
- `),await e(o(a,"app/theme-provider.tsx"),`'use client'
1502
-
1503
- import { ThemeProvider as NextThemesProvider } from 'next-themes'
1504
- import type { ReactNode } from 'react'
1505
-
1506
- export function ThemeProvider({ children }: { children: ReactNode }) {
1507
- return (
1508
- <NextThemesProvider
1509
- attribute="class"
1510
- defaultTheme="system"
1511
- enableSystem
1512
- disableTransitionOnChange
1513
- >
1514
- {children}
1515
- </NextThemesProvider>
1516
- )
1517
- }
1518
- `),await e(o(a,"app/theme-toggle.tsx"),`'use client'
1519
-
1520
- import { useTheme } from 'next-themes'
1521
- import { useState, useEffect } from 'react'
1522
- import { Sun, Moon } from 'lucide-react'
1523
-
1524
- export function ThemeToggle() {
1525
- const [mounted, setMounted] = useState(false)
1526
- const { resolvedTheme, setTheme } = useTheme()
1527
-
1528
- useEffect(() => { setMounted(true) }, [])
1529
-
1530
- if (!mounted) {
1531
- return <div className="h-8 w-8" />
1532
- }
1533
-
1534
- return (
1535
- <button
1536
- type="button"
1537
- onClick={() => setTheme(resolvedTheme === 'dark' ? 'light' : 'dark')}
1538
- 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"
1539
- aria-label={resolvedTheme === 'dark' ? 'Switch to light mode' : 'Switch to dark mode'}
1540
- >
1541
- {resolvedTheme === 'dark' ? <Sun className="h-5 w-5" /> : <Moon className="h-5 w-5" />}
1542
- </button>
1543
- )
1544
- }
1545
- `),await e(o(a,"app/nav-header.tsx"),`'use client'
1546
-
1547
- import Link from 'next/link'
1548
- import { usePathname } from 'next/navigation'
1549
- import { ThemeToggle } from './theme-toggle'
1550
-
1551
- const links = [
1552
- { href: '/', label: 'Home' },
1553
- ]
1554
-
1555
- export function NavHeader() {
1556
- const pathname = usePathname()
1557
-
1558
- function isActive(href: string) {
1559
- return href === '/' ? pathname === '/' : pathname.startsWith(href)
1560
- }
1561
-
1562
- const linkClass = (href: string) =>
1563
- \`px-3 py-1.5 rounded-md text-sm transition-colors \${
1564
- isActive(href)
1565
- ? 'bg-zinc-200 text-zinc-900 dark:bg-zinc-800 dark:text-zinc-50'
1566
- : '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'
1567
- }\`
1568
-
1569
- return (
1570
- <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">
1571
- <nav className="max-w-6xl mx-auto flex items-center gap-1 px-4 h-12">
1572
- <span className="font-semibold text-sm text-zinc-700 dark:text-zinc-300 mr-3 select-none">
1573
- ${r}
1574
- </span>
1575
- {links.map(({ href, label }) => (
1576
- <Link key={href} href={href} className={linkClass(href)}>
1577
- {label}
1578
- </Link>
1579
- ))}
1580
- <div className="ml-auto">
1581
- <ThemeToggle />
1582
- </div>
1583
- </nav>
1584
- </header>
1585
- )
1586
- }
1587
- `),await e(o(a,"app/layout.tsx"),`import './globals.css'
1588
-
1589
- export default function RootLayout({ children }: { children: React.ReactNode }) {
1590
- return children
1591
- }
1592
- `),await e(o(a,"app/[locale]/layout.tsx"),`import type { Metadata } from 'next'
1593
- import { Geist, Geist_Mono } from 'next/font/google'
1594
- import { NextIntlClientProvider } from 'next-intl'
1595
- import { getMessages } from 'next-intl/server'
1596
- import { notFound } from 'next/navigation'
1597
- import { routing } from '@/i18n/routing'
1598
- import { ThemeProvider } from '../theme-provider'
1599
- import { NavHeader } from '../nav-header'
1600
-
1601
- const geistSans = Geist({
1602
- variable: '--font-geist-sans',
1603
- subsets: ['latin'],
1604
- })
1605
-
1606
- const geistMono = Geist_Mono({
1607
- variable: '--font-geist-mono',
1608
- subsets: ['latin'],
1609
- })
1610
-
1611
- export const metadata: Metadata = {
1612
- title: '${r}',
1613
- description: 'Built with Lumi CMS Toolkit',
1614
- }
1615
-
1616
- export default async function LocaleLayout({
1617
- children,
1618
- params,
1619
- }: {
1620
- children: React.ReactNode
1621
- params: Promise<{ locale: string }>
1622
- }) {
1623
- const { locale } = await params
1624
- if (!routing.locales.includes(locale as any)) notFound()
1625
-
1626
- const messages = await getMessages()
1627
-
1628
- return (
1629
- <html lang={locale} suppressHydrationWarning>
1630
- <body className={\`\${geistSans.variable} \${geistMono.variable} antialiased\`}>
1631
- <ThemeProvider>
1632
- <NextIntlClientProvider locale={locale} messages={messages}>
1633
- <NavHeader />
1634
- {children}
1635
- </NextIntlClientProvider>
1636
- </ThemeProvider>
1637
- </body>
1638
- </html>
1639
- )
1640
- }
1641
- `),await e(o(a,"app/[locale]/page.tsx"),`import { createQueryClient } from '@murumets-ee/core/clients'
1642
- import { Article, Category } from '@${r}/config/entities'
1643
- import { getToolkitApp } from '@${r}/config/app'
1644
-
1645
- export default async function HomePage() {
1646
- await getToolkitApp()
1647
- const articles = createQueryClient(Article)
1648
- const categories = createQueryClient(Category)
1649
-
1650
- const [articleList, categoryList] = await Promise.all([
1651
- articles.findMany({ limit: 10 }),
1652
- categories.findMany({}),
1653
- ])
1654
-
1655
- return (
1656
- <div className="min-h-screen p-8">
1657
- <div className="max-w-4xl mx-auto">
1658
- <h1 className="text-4xl font-bold mb-8">Welcome to ${r}</h1>
1659
-
1660
- <section className="mb-12">
1661
- <h2 className="text-2xl font-semibold mb-4">
1662
- Categories ({categoryList.length})
1663
- </h2>
1664
- <div className="grid gap-4 md:grid-cols-2">
1665
- {categoryList.map((cat) => (
1666
- <div
1667
- key={cat.id}
1668
- className="border border-zinc-200 dark:border-zinc-800 rounded-lg p-4"
1669
- >
1670
- <h3 className="font-semibold text-lg">{cat.name}</h3>
1671
- <p className="text-sm text-zinc-600 dark:text-zinc-400">
1672
- {cat.description}
1673
- </p>
1674
- </div>
1675
- ))}
1676
- </div>
1677
- </section>
1678
-
1679
- <section>
1680
- <h2 className="text-2xl font-semibold mb-4">
1681
- Articles ({articleList.length})
1682
- </h2>
1683
- {articleList.length === 0 ? (
1684
- <p className="text-zinc-500">No published articles yet.</p>
1685
- ) : (
1686
- <div className="space-y-4">
1687
- {articleList.map((article) => (
1688
- <div
1689
- key={article.id}
1690
- className="border border-zinc-200 dark:border-zinc-800 rounded-lg p-6"
1691
- >
1692
- <h3 className="text-xl font-bold">{article.title}</h3>
1693
- <p className="text-zinc-600 dark:text-zinc-400 mt-2">
1694
- {article.excerpt}
1695
- </p>
1696
- </div>
1697
- ))}
1698
- </div>
1699
- )}
1700
- </section>
1701
- </div>
1702
- </div>
1703
- )
1704
- }
1705
- `)}import{join as p}from"path";async function P(t,n){let{name:r}=n;await e(p(t,"next.config.ts"),`import type { NextConfig } from 'next'
1706
- import createNextIntlPlugin from 'next-intl/plugin'
1707
-
1708
- const withNextIntl = createNextIntlPlugin('./i18n/request.ts')
1709
-
1710
- const nextConfig: NextConfig = {
1711
- output: 'standalone',
1712
- reactCompiler: true,
1713
- transpilePackages: [
1714
- '@murumets-ee/core', '@murumets-ee/entity', '@murumets-ee/db',
1715
- '@murumets-ee/logging', '@murumets-ee/auth', '@murumets-ee/auth-ui',
1716
- '@murumets-ee/admin-ui', '@murumets-ee/content', '@murumets-ee/settings',
1717
- '@murumets-ee/storage', '@murumets-ee/media', '@murumets-ee/taxonomy',
1718
- '@murumets-ee/queue', '@murumets-ee/mail', '@murumets-ee/ticketing',
1719
- '@murumets-ee/ticketing-ui', '@murumets-ee/tokens', '@murumets-ee/ui',
1720
- ],
1721
- serverExternalPackages: ['drizzle-orm', 'postgres', 'pino', 'file-type'],
1722
- experimental: {
1723
- serverActions: {
1724
- bodySizeLimit: '2mb',
1725
- },
1726
- },
1727
- }
1728
-
1729
- export default withNextIntl(nextConfig)
1730
- `),await e(p(t,"proxy.ts"),`import { NextRequest, NextResponse } from 'next/server'
1731
- import { getSessionCookie } from 'better-auth/cookies'
1732
- import createMiddleware from 'next-intl/middleware'
1733
- import { routing } from './i18n/routing'
1734
-
1735
- const intlMiddleware = createMiddleware(routing)
1736
-
1737
- const protectedPaths = ['/setup']
1738
-
1739
- export function proxy(request: NextRequest) {
1740
- const { pathname } = request.nextUrl
1741
-
1742
- // Strip locale prefix to check actual path
1743
- const localePattern = new RegExp(\`^/(\${routing.locales.join('|')})\`)
1744
- const pathWithoutLocale = pathname.replace(localePattern, '') || '/'
1745
-
1746
- // Auth check for protected paths
1747
- if (protectedPaths.some((p) => pathWithoutLocale.startsWith(p))) {
1748
- const session = getSessionCookie(request)
1749
- if (!session) {
1750
- const locale = pathname.match(localePattern)?.[1] || routing.defaultLocale
1751
- return NextResponse.redirect(new URL(\`/\${locale}/auth/sign-in\`, request.url))
1752
- }
1753
- }
1754
-
1755
- // Locale routing
1756
- return intlMiddleware(request)
1757
- }
1758
-
1759
- export const config = {
1760
- matcher: '/((?!api|_next|_vercel|.*\\\\..*).*)',
1761
- }
1762
- `),await e(p(t,"app/layout.tsx"),`import './globals.css'
1763
-
1764
- export default function RootLayout({ children }: { children: React.ReactNode }) {
1765
- return children
1766
- }
1767
- `),await e(p(t,"app/[locale]/layout.tsx"),`import type { Metadata } from 'next'
1768
- import { Geist, Geist_Mono } from 'next/font/google'
1769
- import { NextIntlClientProvider } from 'next-intl'
1770
- import { getMessages } from 'next-intl/server'
1771
- import { notFound } from 'next/navigation'
1772
- import { routing } from '@/i18n/routing'
1773
- import { ThemeProvider } from '../theme-provider'
1774
- import { NavHeader } from '../nav-header'
1775
-
1776
- const geistSans = Geist({
1777
- variable: '--font-geist-sans',
1778
- subsets: ['latin'],
1779
- })
1780
-
1781
- const geistMono = Geist_Mono({
1782
- variable: '--font-geist-mono',
1783
- subsets: ['latin'],
1784
- })
1785
-
1786
- export const metadata: Metadata = {
1787
- title: '${r}',
1788
- description: 'Built with Lumi CMS Toolkit',
1789
- }
1790
-
1791
- export default async function LocaleLayout({
1792
- children,
1793
- params,
1794
- }: {
1795
- children: React.ReactNode
1796
- params: Promise<{ locale: string }>
1797
- }) {
1798
- const { locale } = await params
1799
- if (!routing.locales.includes(locale as any)) notFound()
1800
-
1801
- const messages = await getMessages()
1802
-
1803
- return (
1804
- <html lang={locale} suppressHydrationWarning>
1805
- <body className={\`\${geistSans.variable} \${geistMono.variable} antialiased\`}>
1806
- <ThemeProvider>
1807
- <NextIntlClientProvider locale={locale} messages={messages}>
1808
- <NavHeader />
1809
- {children}
1810
- </NextIntlClientProvider>
1811
- </ThemeProvider>
1812
- </body>
1813
- </html>
1814
- )
1815
- }
1816
- `),await e(p(t,"app/[locale]/page.tsx"),`import { createQueryClient } from '@murumets-ee/core/clients'
1817
- import { Article, Category } from '@/entities'
1818
- import { getToolkitApp } from '@/lib/app'
1819
-
1820
- export default async function HomePage() {
1821
- await getToolkitApp()
1822
- const articles = createQueryClient(Article)
1823
- const categories = createQueryClient(Category)
1824
-
1825
- const [articleList, categoryList] = await Promise.all([
1826
- articles.findMany({ limit: 10 }),
1827
- categories.findMany({}),
1828
- ])
1829
-
1830
- return (
1831
- <div className="min-h-screen p-8">
1832
- <div className="max-w-4xl mx-auto">
1833
- <h1 className="text-4xl font-bold mb-8">Welcome to ${r}</h1>
1834
-
1835
- <section className="mb-12">
1836
- <h2 className="text-2xl font-semibold mb-4">
1837
- Categories ({categoryList.length})
1838
- </h2>
1839
- <div className="grid gap-4 md:grid-cols-2">
1840
- {categoryList.map((cat) => (
1841
- <div
1842
- key={cat.id}
1843
- className="border border-zinc-200 dark:border-zinc-800 rounded-lg p-4"
1844
- >
1845
- <h3 className="font-semibold text-lg">{cat.name}</h3>
1846
- <p className="text-sm text-zinc-600 dark:text-zinc-400">
1847
- {cat.description}
1848
- </p>
1849
- </div>
1850
- ))}
1851
- </div>
1852
- </section>
1853
-
1854
- <section>
1855
- <h2 className="text-2xl font-semibold mb-4">
1856
- Articles ({articleList.length})
1857
- </h2>
1858
- {articleList.length === 0 ? (
1859
- <p className="text-zinc-500">No published articles yet.</p>
1860
- ) : (
1861
- <div className="space-y-4">
1862
- {articleList.map((article) => (
1863
- <div
1864
- key={article.id}
1865
- className="border border-zinc-200 dark:border-zinc-800 rounded-lg p-6"
1866
- >
1867
- <h3 className="text-xl font-bold">{article.title}</h3>
1868
- <p className="text-zinc-600 dark:text-zinc-400 mt-2">
1869
- {article.excerpt}
1870
- </p>
1871
- </div>
1872
- ))}
1873
- </div>
1874
- )}
1875
- </section>
1876
- </div>
1877
- </div>
1878
- )
1879
- }
1880
- `)}import{join as b}from"path";async function R(t,n){await e(b(t,"scripts/generate-schema.ts"),`import { execSync } from 'node:child_process'
1881
- execSync('npx @murumets-ee/cli generate', { stdio: 'inherit', cwd: import.meta.dirname + '/..' })
1882
- `),await e(b(t,"scripts/migrate.ts"),`import { execSync } from 'node:child_process'
1883
- execSync('npx @murumets-ee/cli migrate', { stdio: 'inherit', cwd: import.meta.dirname + '/..' })
1884
- `),await e(b(t,"scripts/reset-db.ts"),`import { execSync } from 'node:child_process'
1885
- execSync('npx @murumets-ee/cli reset --force', { stdio: 'inherit', cwd: import.meta.dirname + '/..' })
1886
- `)}import{join as f}from"path";async function z(t,n){let{name:r}=n;await e(f(t,"app/globals.css"),`@import "tailwindcss";
1887
- @source "../node_modules/@murumets-ee/auth-ui/dist";
1888
-
1889
- @custom-variant dark (&:where(.dark, .dark *));
1890
-
1891
- :root {
1892
- --background: #ffffff;
1893
- --foreground: #171717;
1894
- }
1895
-
1896
- @theme inline {
1897
- --color-background: var(--background);
1898
- --color-foreground: var(--foreground);
1899
- --font-sans: var(--font-geist-sans);
1900
- --font-mono: var(--font-geist-mono);
1901
- }
1902
-
1903
- .dark {
1904
- --background: #0a0a0a;
1905
- --foreground: #ededed;
1906
- }
1907
-
1908
- body {
1909
- background: var(--background);
1910
- color: var(--foreground);
1911
- font-family: Arial, Helvetica, sans-serif;
1912
- }
1913
- `),await e(f(t,"app/theme-provider.tsx"),`'use client'
1914
-
1915
- import { ThemeProvider as NextThemesProvider } from 'next-themes'
1916
- import type { ReactNode } from 'react'
1917
-
1918
- export function ThemeProvider({ children }: { children: ReactNode }) {
1919
- return (
1920
- <NextThemesProvider
1921
- attribute="class"
1922
- defaultTheme="system"
1923
- enableSystem
1924
- disableTransitionOnChange
1925
- >
1926
- {children}
1927
- </NextThemesProvider>
1928
- )
1929
- }
1930
- `),await e(f(t,"app/theme-toggle.tsx"),`'use client'
1931
-
1932
- import { useTheme } from 'next-themes'
1933
- import { useState, useEffect } from 'react'
1934
- import { Sun, Moon } from 'lucide-react'
1935
-
1936
- export function ThemeToggle() {
1937
- const [mounted, setMounted] = useState(false)
1938
- const { resolvedTheme, setTheme } = useTheme()
1939
-
1940
- useEffect(() => { setMounted(true) }, [])
1941
-
1942
- if (!mounted) {
1943
- return <div className="h-8 w-8" />
1944
- }
1945
-
1946
- return (
1947
- <button
1948
- type="button"
1949
- onClick={() => setTheme(resolvedTheme === 'dark' ? 'light' : 'dark')}
1950
- 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"
1951
- aria-label={resolvedTheme === 'dark' ? 'Switch to light mode' : 'Switch to dark mode'}
1952
- >
1953
- {resolvedTheme === 'dark' ? <Sun className="h-5 w-5" /> : <Moon className="h-5 w-5" />}
1954
- </button>
1955
- )
1956
- }
1957
- `),await e(f(t,"app/nav-header.tsx"),`'use client'
1958
-
1959
- import Link from 'next/link'
1960
- import { usePathname } from 'next/navigation'
1961
- import { ThemeToggle } from './theme-toggle'
1962
-
1963
- const links = [
1964
- { href: '/', label: 'Home' },
1965
- { href: '/auth/sign-in', label: 'Sign In' },
1966
- { href: '/setup', label: 'Setup' },
1967
- ]
1968
-
1969
- export function NavHeader() {
1970
- const pathname = usePathname()
1971
-
1972
- function isActive(href: string) {
1973
- return href === '/' ? pathname === '/' : pathname.startsWith(href)
1974
- }
1975
-
1976
- const linkClass = (href: string) =>
1977
- \`px-3 py-1.5 rounded-md text-sm transition-colors \${
1978
- isActive(href)
1979
- ? 'bg-zinc-200 text-zinc-900 dark:bg-zinc-800 dark:text-zinc-50'
1980
- : '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'
1981
- }\`
1982
-
1983
- return (
1984
- <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">
1985
- <nav className="max-w-6xl mx-auto flex items-center gap-1 px-4 h-12">
1986
- <span className="font-semibold text-sm text-zinc-700 dark:text-zinc-300 mr-3 select-none">
1987
- ${r}
1988
- </span>
1989
- {links.map(({ href, label }) => (
1990
- <Link key={href} href={href} className={linkClass(href)}>
1991
- {label}
1992
- </Link>
1993
- ))}
1994
- <div className="ml-auto">
1995
- <ThemeToggle />
1996
- </div>
1997
- </nav>
1998
- </header>
1999
- )
2000
- }
2001
- `)}import{join as d}from"path";async function C(t,n){let{name:r}=n;await e(d(t,"toolkit.config.ts"),`import { auth } from '@murumets-ee/auth/plugin'
2002
- import { content } from '@murumets-ee/content/plugin'
2003
- import { defineConfig } from '@murumets-ee/core'
2004
- import { logging } from '@murumets-ee/logging/plugin'
2005
- import { mail, ResendMailProvider } from '@murumets-ee/mail'
2006
- import { media } from '@murumets-ee/media/plugin'
2007
- import { queue } from '@murumets-ee/queue/plugin'
2008
- import { settings } from '@murumets-ee/settings/plugin'
2009
- import { storage } from '@murumets-ee/storage/plugin'
2010
- import { taxonomy } from '@murumets-ee/taxonomy/plugin'
2011
- import { ticketing } from '@murumets-ee/ticketing/plugin'
2012
- import { Article, Category } from './entities'
2013
- import * as authSchema from './generated/auth-schema'
2014
-
2015
- if (!process.env.DATABASE_URL) {
2016
- throw new Error('DATABASE_URL environment variable is required')
2017
- }
2018
-
2019
- export default defineConfig({
2020
- db: {
2021
- url: process.env.DATABASE_URL,
2022
- poolMin: 2,
2023
- poolMax: 10,
2024
- },
2025
- logging: {
2026
- level: (process.env.LOG_LEVEL || 'info') as 'debug' | 'info' | 'warn' | 'error',
2027
- name: '${r}',
2028
- },
2029
- entities: [Category, Article],
2030
- plugins: [
2031
- auth({ providers: ['email'], schema: authSchema }),
2032
- content({
2033
- locales: [{ code: 'en', label: 'English' }],
2034
- defaultLocale: 'en',
2035
- }),
2036
- logging(),
2037
- settings(),
2038
- storage(),
2039
- media(),
2040
- taxonomy(),
2041
- queue(),
2042
- mail({
2043
- provider: process.env.RESEND_API_KEY
2044
- ? new ResendMailProvider({ apiKey: process.env.RESEND_API_KEY })
2045
- : undefined,
2046
- defaultFrom: process.env.MAIL_FROM ?? 'noreply@example.com',
2047
- webhookSecret: process.env.RESEND_WEBHOOK_SECRET,
2048
- }),
2049
- ticketing({
2050
- csatSecret: process.env.CSAT_SECRET,
2051
- }),
2052
- ],
2053
- projectRoot: import.meta.dirname,
2054
- })
2055
- `),await e(d(t,"lib/app.ts"),`import { createApp, setApp, type ToolkitApp } from '@murumets-ee/core'
2056
- import config from '../toolkit.config'
2057
-
2058
- let appInstance: ToolkitApp | null = null
2059
-
2060
- export async function getToolkitApp(): Promise<ToolkitApp> {
2061
- if (!appInstance) {
2062
- console.log('Initializing toolkit app...')
2063
- appInstance = await createApp(config)
2064
- setApp(appInstance)
2065
- console.log('Toolkit app initialized')
2066
- }
2067
- return appInstance
2068
- }
2069
- `),await e(d(t,"drizzle.config.ts"),`import type { Config } from 'drizzle-kit'
2070
-
2071
- if (!process.env.DATABASE_URL) {
2072
- throw new Error('DATABASE_URL environment variable is required')
2073
- }
2074
-
2075
- export default {
2076
- schema: ['./generated/schema.ts', './generated/auth-schema.ts'],
2077
- out: './migrations',
2078
- dialect: 'postgresql',
2079
- dbCredentials: {
2080
- url: process.env.DATABASE_URL,
2081
- },
2082
- } satisfies Config
2083
- `),await e(d(t,"auth.config.ts"),`import { betterAuth } from 'better-auth'
2084
- import { drizzleAdapter } from 'better-auth/adapters/drizzle'
2085
- import { admin } from 'better-auth/plugins'
2086
- import { organization } from 'better-auth/plugins/organization'
2087
- import { drizzle } from 'drizzle-orm/postgres-js'
2088
- import postgres from 'postgres'
2089
-
2090
- const sql = postgres(process.env.DATABASE_URL!)
2091
- const db = drizzle(sql)
2092
-
2093
- export const auth = betterAuth({
2094
- database: drizzleAdapter(db, { provider: 'pg' }),
2095
- emailAndPassword: { enabled: true },
2096
- plugins: [
2097
- admin(),
2098
- organization(),
2099
- ],
2100
- })
2101
- `),await e(d(t,"generated/auth-schema.ts"),`// This file is generated by better-auth CLI.
2102
- // Run: npx @better-auth/cli generate --config auth.config.ts -y
2103
- export {}
2104
- `)}async function O(t,n){t.mode==="single"?await q(t,n):await I(t,n)}async function q(t,n){let r=v(process.cwd(),t.name);n?.("Creating Next.js app..."),l(`pnpm create next-app@${"16"} ${t.name} --typescript --tailwind --no-eslint --app --no-src-dir --turbopack --react-compiler --skip-install --import-alias "@/*"`),await u(r,["app/page.tsx","app/page.module.css","app/fonts","README.md"]),await c(v(r,"package.json"),{type:"module",dependencies:{"@murumets-ee/core":`^${i.myorgCore}`,"@murumets-ee/db":`^${i.myorgDb}`,"@murumets-ee/entity":`^${i.myorgEntity}`,"@murumets-ee/logging":`^${i.myorgLogging}`,"@murumets-ee/auth":`^${i.myorgAuth}`,"@murumets-ee/auth-ui":`^${i.myorgAuthUi}`,"@murumets-ee/admin-ui":`^${i.myorgAdminUi}`,"@murumets-ee/content":`^${i.myorgContent}`,"@murumets-ee/settings":`^${i.myorgSettings}`,"@murumets-ee/storage":`^${i.myorgStorage}`,"@murumets-ee/media":`^${i.myorgMedia}`,"@murumets-ee/taxonomy":`^${i.myorgTaxonomy}`,"@murumets-ee/queue":`^${i.myorgQueue}`,"@murumets-ee/mail":`^${i.myorgMail}`,"@murumets-ee/ticketing":`^${i.myorgTicketing}`,"@murumets-ee/ticketing-ui":`^${i.myorgTicketingUi}`,"@murumets-ee/tokens":`^${i.myorgTokens}`,"better-auth":`^${i.betterAuth}`,"drizzle-orm":`^${i.drizzleOrm}`,"next-intl":`^${i.nextIntl}`,"next-themes":`^${i.nextThemes}`,"lucide-react":`^${i.lucideReact}`,postgres:`^${i.postgres}`,"react-hook-form":`^${i.reactHookForm}`,"@hookform/resolvers":`^${i.hookformResolvers}`,zod:`^${i.zod}`},devDependencies:{"drizzle-kit":`^${i.drizzleKit}`,tsx:`^${i.tsx}`,"babel-plugin-react-compiler":i.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"}}),n?.("Adding toolkit files..."),await k(r,t),await A(r,t),await C(r,t),await w(r,t),await T(r,t),await P(r,t),await z(r,t),await R(r,t),t.installDeps&&(n?.("Installing dependencies..."),l("pnpm install",{cwd:r}))}async function I(t,n){let r=v(process.cwd(),t.name);n?.("Creating workspace..."),await E(r,t,n),t.installDeps&&(n?.("Installing dependencies..."),l("pnpm install",{cwd:r}))}export{O as scaffold};