@murumets-ee/create 0.2.0 → 0.3.0

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.mjs CHANGED
@@ -1,1176 +1,57 @@
1
- import{a as e,n as t,r as n,t as r}from"./utils-DHetVfSn.mjs";import{existsSync as i,readFileSync as a}from"node:fs";import{mkdir as o,readFile as s,readdir as c,writeFile as l}from"node:fs/promises";import{dirname as u,join as d}from"node:path";import{fileURLToPath as f}from"node:url";import{extract as p}from"tar";const m={myorgCore:`0.1.6`,myorgDb:`0.1.5`,myorgEntity:`0.2.0`,myorgLogging:`0.1.6`,myorgAuth:`0.1.5`,myorgAuthUi:`0.1.5`,myorgAdminUi:`0.2.0`,myorgContent:`0.2.0`,myorgContentApi:`0.1.5`,myorgSettings:`0.1.6`,myorgStorage:`0.1.6`,myorgMedia:`0.2.0`,myorgTaxonomy:`0.1.5`,myorgQueue:`0.1.6`,myorgMail:`0.1.5`,myorgTicketing:`0.2.0`,myorgTicketingUi:`0.2.0`,myorgEditor:`0.1.5`,myorgBlocks:`0.1.5`,myorgTokens:`0.1.5`,myorgUi:`0.1.5`,myorgCli:`0.1.10`,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`,next:`16.1.6`,react:`19.2.3`,reactDom:`19.2.3`,drizzleKit:`0.31.10`,tsx:`4.19.2`,babelReactCompiler:`1.0.0`};async function h(e,t,n){await g(e,t),n?.(`Workspace root created`),n?.(`Creating admin app...`),await v(e,t),n?.(`Admin app created`),n?.(`Creating web app...`),await y(e,t),n?.(`Web app created`),await _(e,t),n?.(`Shared config package created`)}async function g(t,n){let{name:r}=n;await o(t,{recursive:!0}),await e(d(t,`pnpm-workspace.yaml`),`packages:
2
- - 'packages/*'
3
- - 'apps/*'
4
-
5
- ignoredBuiltDependencies:
6
- - sharp
7
- - unrs-resolver
8
- `),await e(d(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:`^${m.tsx}`,"drizzle-kit":`^${m.drizzleKit}`}},null,2)}\n`),await e(d(t,`.gitignore`),`# dependencies
9
- node_modules/
10
-
11
- # build
12
- dist/
13
- .next/
14
- .turbo/
15
-
16
- # env
17
- .env*
18
- !.env.example
19
-
20
- # toolkit generated
21
- generated/
22
-
23
- # IDE
24
- .vscode/
25
- .idea/
26
-
27
- # OS
28
- .DS_Store
29
- Thumbs.db
30
-
31
- # logs
32
- *.log
33
-
34
- # migrations meta
35
- migrations/
36
-
37
- # turbo
38
- .turbo/
39
- `),await e(d(t,`.env.example`),`DATABASE_URL=postgresql://${r}:${r}_dev_password@localhost:5432/${r}_dev
40
- BETTER_AUTH_SECRET=dev-secret-change-me-in-production-min-32-chars
41
- BETTER_AUTH_URL=http://localhost:3000
42
- LOG_LEVEL=debug
43
- NEXT_PUBLIC_APP_URL=http://localhost:3000
44
- QUEUE_WORKER=true
45
- RESEND_API_KEY=
46
- RESEND_WEBHOOK_SECRET=
47
- MAIL_FROM=noreply@example.com
48
- CSAT_SECRET=
49
- `),await e(d(t,`docker-compose.yml`),`services:
50
- postgres:
51
- image: postgres:17-alpine
52
- container_name: ${r}-postgres
53
- restart: unless-stopped
54
- environment:
55
- POSTGRES_USER: ${r}
56
- POSTGRES_PASSWORD: ${r}_dev_password
57
- POSTGRES_DB: ${r}_dev
58
- ports:
59
- - "5432:5432"
60
- volumes:
61
- - postgres_data:/var/lib/postgresql/data
62
- healthcheck:
63
- test: ["CMD-SHELL", "pg_isready -U ${r} -d ${r}_dev"]
64
- interval: 10s
65
- timeout: 5s
66
- retries: 5
67
-
68
- volumes:
69
- postgres_data:
70
- name: ${r}_postgres_data
71
- `)}async function _(t,n){let{name:r}=n,i=d(t,`packages/config`);await e(d(i,`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":`^${m.myorgCore}`,"@murumets-ee/db":`^${m.myorgDb}`,"@murumets-ee/entity":`^${m.myorgEntity}`,"@murumets-ee/logging":`^${m.myorgLogging}`,"@murumets-ee/auth":`^${m.myorgAuth}`,"better-auth":`^${m.betterAuth}`,"drizzle-orm":`^${m.drizzleOrm}`,postgres:`^${m.postgres}`,zod:`^${m.zod}`}},null,2)}\n`),await e(d(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 e(d(i,`toolkit.config.ts`),`import { auth } from '@murumets-ee/auth/plugin'
72
- import { content } from '@murumets-ee/content/plugin'
73
- import { defineConfig } from '@murumets-ee/core'
74
- import { logging } from '@murumets-ee/logging/plugin'
75
- import { mail, ResendMailProvider } from '@murumets-ee/mail'
76
- import { media } from '@murumets-ee/media/plugin'
77
- import { queue } from '@murumets-ee/queue/plugin'
78
- import { settings } from '@murumets-ee/settings/plugin'
79
- import { storage } from '@murumets-ee/storage/plugin'
80
- import { taxonomy } from '@murumets-ee/taxonomy/plugin'
81
- import { ticketing } from '@murumets-ee/ticketing/plugin'
82
- import { Article, Category } from './entities'
83
- import * as authSchema from './generated/auth-schema'
84
-
85
- if (!process.env.DATABASE_URL) {
86
- throw new Error('DATABASE_URL environment variable is required')
87
- }
88
-
89
- export default defineConfig({
90
- db: {
91
- url: process.env.DATABASE_URL,
92
- poolMin: 2,
93
- poolMax: 10,
94
- },
95
- logging: {
96
- level: (process.env.LOG_LEVEL || 'info') as 'debug' | 'info' | 'warn' | 'error',
97
- name: '${r}',
98
- },
99
- entities: [Category, Article],
100
- plugins: [
101
- auth({ providers: ['email'], schema: authSchema }),
102
- content({
103
- locales: [{ code: 'en', label: 'English' }],
104
- defaultLocale: 'en',
105
- }),
106
- logging(),
107
- settings(),
108
- storage(),
109
- media(),
110
- taxonomy(),
111
- queue(),
112
- mail({
113
- provider: process.env.RESEND_API_KEY
114
- ? new ResendMailProvider({ apiKey: process.env.RESEND_API_KEY })
115
- : undefined,
116
- defaultFrom: process.env.MAIL_FROM ?? 'noreply@example.com',
117
- webhookSecret: process.env.RESEND_WEBHOOK_SECRET,
118
- }),
119
- ticketing({
120
- csatSecret: process.env.CSAT_SECRET,
121
- }),
122
- ],
123
- projectRoot: import.meta.dirname,
124
- })
125
- `),await e(d(i,`auth.config.ts`),`import { betterAuth } from 'better-auth'
126
- import { drizzleAdapter } from 'better-auth/adapters/drizzle'
127
- import { admin } from 'better-auth/plugins'
128
- import { organization } from 'better-auth/plugins/organization'
129
- import { drizzle } from 'drizzle-orm/postgres-js'
130
- import postgres from 'postgres'
131
-
132
- const sql = postgres(process.env.DATABASE_URL!)
133
- const db = drizzle(sql)
134
-
135
- export const auth = betterAuth({
136
- database: drizzleAdapter(db, { provider: 'pg' }),
137
- emailAndPassword: { enabled: true },
138
- plugins: [
139
- admin(),
140
- organization(),
141
- ],
142
- })
143
- `),await e(d(i,`drizzle.config.ts`),`import type { Config } from 'drizzle-kit'
144
-
145
- if (!process.env.DATABASE_URL) {
146
- throw new Error('DATABASE_URL environment variable is required')
147
- }
148
-
149
- export default {
150
- schema: ['./generated/schema.ts', './generated/auth-schema.ts'],
151
- out: './migrations',
152
- dialect: 'postgresql',
153
- dbCredentials: {
154
- url: process.env.DATABASE_URL,
155
- },
156
- } satisfies Config
157
- `),await e(d(i,`entities/index.ts`),`export { Article } from './article'
158
- export { Category } from './category'
159
- `),await e(d(i,`entities/article.ts`),`import { behavior, defineEntity, field } from '@murumets-ee/entity'
160
-
161
- export const Article = defineEntity({
162
- name: 'article',
163
- fields: {
164
- title: field.text({ required: true, maxLength: 200, indexed: true, translatable: true }),
165
- slug: field.slug({ from: 'title', unique: true }),
166
- excerpt: field.text({ maxLength: 500, translatable: true }),
167
- body: field.richtext(),
168
- viewCount: field.number({ default: 0, integer: true }),
169
- featured: field.boolean({ default: false }),
170
- publishDate: field.date(),
171
- contentType: field.select({ options: ['news', 'tutorial', 'announcement'], default: 'news' }),
172
- category: field.reference({ entity: 'category', required: false }),
173
- tags: field.reference({ entity: 'category', cardinality: 'many' }),
174
- coverImage: field.media({ accept: ['image/*'] }),
175
- },
176
- behaviors: [
177
- behavior.publishable(),
178
- behavior.auditable(),
179
- behavior.sluggable('title'),
180
- behavior.revisionable(),
181
- ],
182
- scope: 'global',
183
- access: {
184
- view: 'public',
185
- create: 'group.editor',
186
- update: 'group.editor',
187
- delete: 'group.admin',
188
- },
189
- })
190
- `),await e(d(i,`entities/category.ts`),`import { defineEntity, field } from '@murumets-ee/entity'
191
-
192
- export const Category = defineEntity({
193
- name: 'category',
194
- fields: {
195
- name: field.text({ required: true, maxLength: 100, indexed: true, translatable: true }),
196
- slug: field.slug({ from: 'name', unique: true }),
197
- description: field.text({ maxLength: 500, translatable: true }),
198
- },
199
- scope: 'global',
200
- access: {
201
- view: 'public',
202
- create: 'group.editor',
203
- update: 'group.editor',
204
- delete: 'group.admin',
205
- },
206
- })
207
- `),await e(d(i,`lib/app.ts`),`import { createApp, setApp, type ToolkitApp } from '@murumets-ee/core'
208
- import config from '../toolkit.config'
209
-
210
- let appInstance: ToolkitApp | null = null
211
-
212
- export async function getToolkitApp(): Promise<ToolkitApp> {
213
- if (!appInstance) {
214
- appInstance = await createApp(config)
215
- setApp(appInstance)
216
- }
217
- return appInstance
218
- }
219
- `),await e(d(i,`lib/auth.ts`),`import { getAuth } from '@murumets-ee/auth'
220
- import { getToolkitApp } from './app'
221
-
222
- await getToolkitApp()
223
-
224
- export const auth = getAuth()
225
- `),await e(d(i,`lib/auth-client.ts`),`import { createClient } from '@murumets-ee/auth/client'
226
-
227
- export const authClient = createClient()
228
- `),await e(d(i,`generated/auth-schema.ts`),`// This file is generated by better-auth CLI.
229
- // Run: npx @better-auth/cli generate --config auth.config.ts -y
230
- export {}
231
- `),await e(d(i,`scripts/generate-schema.ts`),`/**
232
- * Generate Drizzle schemas from entity definitions
233
- */
234
-
235
- import { mkdir, writeFile } from 'node:fs/promises'
236
- import { join } from 'node:path'
237
- import { generateSchemaCode, generateTranslationSchemaCode } from '@murumets-ee/entity'
238
- import config from '../toolkit.config'
239
-
240
- async function generateSchemas() {
241
- console.log('Generating Drizzle schemas from entity definitions...')
242
-
243
- const schemaDir = join(import.meta.dirname, '..', 'generated')
244
- await mkdir(schemaDir, { recursive: true })
245
-
246
- const imports: string[] = []
247
- const schemas: string[] = []
248
- let hasTranslations = false
249
-
250
- for (const entity of config.entities) {
251
- console.log(\` - Generating schema for \${entity.name}\`)
252
-
253
- const schemaCode = generateSchemaCode(entity)
254
- schemas.push(\`\\n// \${entity.name} table\`)
255
- schemas.push(schemaCode)
256
-
257
- const translationCode = generateTranslationSchemaCode(entity)
258
- if (translationCode) {
259
- hasTranslations = true
260
- schemas.push(\`\\n// \${entity.name} translations\`)
261
- schemas.push(translationCode)
262
- }
263
- }
264
-
265
- const pgCoreTypes = ['pgTable', 'varchar', 'text', 'boolean', 'timestamp', 'integer', 'doublePrecision', 'jsonb', 'uuid', 'index']
266
- if (hasTranslations) pgCoreTypes.push('unique')
267
- const pgCoreImports = \`import { \${pgCoreTypes.join(', ')} } from 'drizzle-orm/pg-core'\\n\`
268
- imports.push(pgCoreImports)
269
-
270
- const schemaFile = join(schemaDir, 'schema.ts')
271
- await writeFile(schemaFile, [...imports, ...schemas].join('\\n'))
272
-
273
- console.log(\`\\nSchemas written to: \${schemaFile}\`)
274
- console.log('Run \\\`pnpm db:migrate:generate\\\` to create migrations')
275
- }
276
-
277
- generateSchemas().catch(console.error)
278
- `),await e(d(i,`scripts/migrate.ts`),`/**
279
- * Run pending migrations
280
- */
281
-
282
- import { createDbClient, runMigrations } from '@murumets-ee/db'
283
-
284
- async function migrate() {
285
- console.log('Running migrations...')
286
-
287
- try {
288
- if (!process.env.DATABASE_URL) {
289
- throw new Error('DATABASE_URL environment variable is required')
290
- }
291
-
292
- const db = createDbClient({ url: process.env.DATABASE_URL })
293
- await runMigrations(db, import.meta.dirname + '/..')
294
-
295
- console.log('Migrations completed successfully')
296
- process.exit(0)
297
- } catch (error) {
298
- console.error('Migration failed:', error)
299
- process.exit(1)
300
- }
301
- }
302
-
303
- migrate()
304
- `),await e(d(i,`scripts/reset-db.ts`),`/**
305
- * Reset database (DROP all tables)
306
- * WARNING: Only for development
1
+ import{existsSync as e,readFileSync as t}from"node:fs";import{readFile as n,readdir as r,rm as i,writeFile as a}from"node:fs/promises";import{dirname as o,join as s}from"node:path";import{fileURLToPath as c}from"node:url";import{extract as l}from"tar";import{execSync as u}from"node:child_process";async function d(e,t){for(let n of t)await i(s(e,n),{force:!0,recursive:!0})}function f(e,t){return u(e,{cwd:t?.cwd,stdio:`pipe`,encoding:`utf-8`})}const p=new Set([`.ts`,`.tsx`,`.mts`,`.json`,`.md`,`.yml`,`.yaml`,`.css`,`.html`]),m=new Set([`.env.example`,`Dockerfile`,`.gitignore`]),h=`__PROJECT_NAME__`,g=`__PROJECT_NAME_TITLE__`;async function _(e,t){await v(e,t)}async function v(e,t){let n=s(process.cwd(),e.name);t?.(`Creating Next.js app...`),f(`pnpm create next-app@16 ${e.name} --typescript --tailwind --no-eslint --app --no-src-dir --turbopack --react-compiler --skip-install --import-alias "@/*"`),await d(n,[`app/page.tsx`,`app/page.module.css`,`app/fonts`,`app/globals.css`,`README.md`]),t?.(`Extracting template...`),await y(n),e.template===`blank`&&(t?.(`Stripping demo content for blank template...`),await x(n)),t?.(`Personalizing template...`),await S(n,e.name),e.installDeps&&(t?.(`Installing dependencies...`),f(`pnpm install`,{cwd:n}))}async function y(t){let n=b();if(!e(n))throw Error(`Template tarball missing: ${n}\nRun \`pnpm --filter @murumets-ee/create build:templates\` first.`);await l({file:n,cwd:t})}function b(){let n=o(c(import.meta.url)),r=n;for(let n=0;n<5;n++){let n=s(r,`package.json`);if(e(n))try{if(JSON.parse(t(n,`utf-8`)).name===`@murumets-ee/create`)return s(r,`templates`,`template-demo.tar.gz`)}catch{}let i=o(r);if(i===r)break;r=i}throw Error(`Could not find @murumets-ee/create package root above ${n}. template-demo.tar.gz cannot be located.`)}async function x(t){let o=s(t,`entities`);if(e(o)){let e=await r(o);for(let t of e)t!==`index.ts`&&await i(s(o,t),{force:!0});await a(s(o,`index.ts`),`// Add your entities here and export them.
2
+ // See https://github.com/murumets-ee/lumi-cms for documentation.
3
+
4
+ export const projectEntities = [] as const
5
+ export const projectTaxonomies = [] as const
6
+ `,`utf-8`)}let c=s(t,`seeds`);if(e(c)){let e=await r(c);for(let t of e)t!==`index.ts`&&await i(s(c,t),{force:!0});await a(s(c,`index.ts`),`import type { AdminSeeder } from '@murumets-ee/admin-ui/pages'
7
+
8
+ export const projectSeeders: AdminSeeder[] = []
9
+ `,`utf-8`)}await i(s(t,`app`,`[locale]`,`(shell)`,`demos`),{recursive:!0,force:!0});let l=s(t,`app`,`admin-layout.tsx`);if(e(l)){let e=await n(l,`utf-8`);e=e.replace(/\n\s*\/\/.*demo.*[\s\S]*?const demosGroup[\s\S]*?\}\n/i,`
10
+ `),e=e.replace(`, demosGroup`,``),e=e.replace(/\s*GalleryHorizontalEnd,\n/,`
11
+ `),e=e.replace(/\s*HardDrive,\n/,`
12
+ `),e=e.replace(/\s*Palette,\n/,`
13
+ `),await a(l,e,`utf-8`)}let u=s(t,`toolkit.config.ts`);if(e(u)){let e=await n(u,`utf-8`);e=e.replace(/import \{[^}]+\} from '\.\/entities'/,`import { projectEntities } from './entities'`),e=e.replace(/entities: \[[^\]]+\]/,`entities: [...projectEntities]`),await a(u,e,`utf-8`)}let d=s(t,`lib`,`admin-config.ts`);e(d)&&await a(d,`/**
14
+ * Shared admin configuration — entities + route resource metadata.
15
+ *
16
+ * Add your own entities to the arrays below after defining them in entities/.
307
17
  */
308
18
 
309
- import postgres from 'postgres'
310
-
311
- async function resetDb() {
312
- const DATABASE_URL = process.env.DATABASE_URL
313
-
314
- if (!DATABASE_URL) {
315
- throw new Error('DATABASE_URL not set')
316
- }
317
-
318
- console.warn('WARNING: This will DROP ALL TABLES')
319
- console.log('Database:', DATABASE_URL.split('@')[1])
320
-
321
- const sql = postgres(DATABASE_URL)
322
-
323
- try {
324
- await sql\`
325
- DROP SCHEMA public CASCADE;
326
- CREATE SCHEMA public;
327
- GRANT ALL ON SCHEMA public TO PUBLIC;
328
- \`
329
-
330
- console.log('Database reset complete')
331
- } finally {
332
- await sql.end()
333
- }
334
- }
335
-
336
- resetDb().catch(console.error)
337
- `)}async function v(i,a){let{name:s}=a,c=d(i,`apps/admin`);await o(d(i,`apps`),{recursive:!0}),n(`pnpm create next-app@16 ${c} --typescript --tailwind --no-eslint --app --no-src-dir --turbopack --react-compiler --skip-install --import-alias "@/*"`),await r(c,[`app/page.tsx`,`app/page.module.css`,`app/fonts`,`README.md`,`pnpm-workspace.yaml`]),await t(d(c,`package.json`),{dependencies:{[`@${s}/config`]:`workspace:*`,"@murumets-ee/auth-ui":`^${m.myorgAuthUi}`,"better-auth":`^${m.betterAuth}`,"next-intl":`^${m.nextIntl}`,"next-themes":`^${m.nextThemes}`,"lucide-react":`^${m.lucideReact}`,"react-hook-form":`^${m.reactHookForm}`,"@hookform/resolvers":`^${m.hookformResolvers}`,zod:`^${m.zod}`},devDependencies:{"babel-plugin-react-compiler":m.babelReactCompiler}});let{appendToFile:l}=await import(`./utils-DHetVfSn.mjs`).then(e=>e.i);await l(d(c,`.gitignore`),`
338
- # Environment
339
- .env*
340
- !.env.example
341
- `),await e(d(c,`next.config.ts`),`import type { NextConfig } from 'next'
342
- import createNextIntlPlugin from 'next-intl/plugin'
343
-
344
- const withNextIntl = createNextIntlPlugin('./i18n/request.ts')
345
-
346
- const nextConfig: NextConfig = {
347
- reactCompiler: true,
348
- transpilePackages: [
349
- '@${s}/config',
350
- '@murumets-ee/core',
351
- '@murumets-ee/entity',
352
- '@murumets-ee/db',
353
- '@murumets-ee/logging',
354
- '@murumets-ee/auth-ui',
355
- ],
356
- serverExternalPackages: ['drizzle-orm', 'postgres'],
357
- experimental: {
358
- serverActions: {
359
- bodySizeLimit: '2mb',
360
- },
361
- },
362
- }
363
-
364
- export default withNextIntl(nextConfig)
365
- `),await e(d(c,`proxy.ts`),`import { NextRequest, NextResponse } from 'next/server'
366
- import { getSessionCookie } from 'better-auth/cookies'
367
- import createMiddleware from 'next-intl/middleware'
368
- import { routing } from './i18n/routing'
369
-
370
- const intlMiddleware = createMiddleware(routing)
371
-
372
- const protectedPaths = ['/setup']
373
-
374
- export function proxy(request: NextRequest) {
375
- const { pathname } = request.nextUrl
376
-
377
- const localePattern = new RegExp(\`^/(\${routing.locales.join('|')})\`)
378
- const pathWithoutLocale = pathname.replace(localePattern, '') || '/'
379
-
380
- if (protectedPaths.some((p) => pathWithoutLocale.startsWith(p))) {
381
- const session = getSessionCookie(request)
382
- if (!session) {
383
- const locale = pathname.match(localePattern)?.[1] || routing.defaultLocale
384
- return NextResponse.redirect(new URL(\`/\${locale}/auth/sign-in\`, request.url))
385
- }
386
- }
387
-
388
- return intlMiddleware(request)
389
- }
390
-
391
- export const config = {
392
- matcher: '/((?!api|_next|_vercel|.*\\\\..*).*)',
393
- }
394
- `),await e(d(c,`i18n/routing.ts`),`import { defineRouting } from 'next-intl/routing'
395
-
396
- export const routing = defineRouting({
397
- locales: ['en'],
398
- defaultLocale: 'en',
399
- })
400
- `),await e(d(c,`i18n/request.ts`),`import { getRequestConfig } from 'next-intl/server'
401
- import { hasLocale } from 'next-intl'
402
- import { routing } from './routing'
403
- import { getAuthMessages } from '@murumets-ee/auth-ui/i18n'
404
-
405
- export default getRequestConfig(async ({ requestLocale }) => {
406
- const requested = await requestLocale
407
- const locale = hasLocale(routing.locales, requested)
408
- ? requested
409
- : routing.defaultLocale
410
-
411
- const authMessages = await getAuthMessages(locale)
412
-
413
- return {
414
- locale,
415
- messages: {
416
- ...authMessages,
417
- },
418
- }
419
- })
420
- `),await e(d(c,`app/globals.css`),`@import "tailwindcss";
421
- @source "../node_modules/@murumets-ee/auth-ui/dist";
422
-
423
- @custom-variant dark (&:where(.dark, .dark *));
424
-
425
- :root {
426
- --background: #ffffff;
427
- --foreground: #171717;
428
- }
429
-
430
- @theme inline {
431
- --color-background: var(--background);
432
- --color-foreground: var(--foreground);
433
- --font-sans: var(--font-geist-sans);
434
- --font-mono: var(--font-geist-mono);
435
- }
436
-
437
- .dark {
438
- --background: #0a0a0a;
439
- --foreground: #ededed;
440
- }
441
-
442
- body {
443
- background: var(--background);
444
- color: var(--foreground);
445
- font-family: Arial, Helvetica, sans-serif;
446
- }
447
- `),await e(d(c,`app/theme-provider.tsx`),`'use client'
448
-
449
- import { ThemeProvider as NextThemesProvider } from 'next-themes'
450
- import type { ReactNode } from 'react'
451
-
452
- export function ThemeProvider({ children }: { children: ReactNode }) {
453
- return (
454
- <NextThemesProvider
455
- attribute="class"
456
- defaultTheme="system"
457
- enableSystem
458
- disableTransitionOnChange
459
- >
460
- {children}
461
- </NextThemesProvider>
462
- )
463
- }
464
- `),await e(d(c,`app/theme-toggle.tsx`),`'use client'
465
-
466
- import { useTheme } from 'next-themes'
467
- import { useState, useEffect } from 'react'
468
- import { Sun, Moon } from 'lucide-react'
469
-
470
- export function ThemeToggle() {
471
- const [mounted, setMounted] = useState(false)
472
- const { resolvedTheme, setTheme } = useTheme()
473
-
474
- useEffect(() => { setMounted(true) }, [])
475
-
476
- if (!mounted) {
477
- return <div className="h-8 w-8" />
478
- }
479
-
480
- return (
481
- <button
482
- type="button"
483
- onClick={() => setTheme(resolvedTheme === 'dark' ? 'light' : 'dark')}
484
- 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"
485
- aria-label={resolvedTheme === 'dark' ? 'Switch to light mode' : 'Switch to dark mode'}
486
- >
487
- {resolvedTheme === 'dark' ? <Sun className="h-5 w-5" /> : <Moon className="h-5 w-5" />}
488
- </button>
489
- )
490
- }
491
- `),await e(d(c,`app/nav-header.tsx`),`'use client'
492
-
493
- import Link from 'next/link'
494
- import { usePathname } from 'next/navigation'
495
- import { ThemeToggle } from './theme-toggle'
496
-
497
- const links = [
498
- { href: '/', label: 'Home' },
499
- { href: '/auth/sign-in', label: 'Sign In' },
500
- { href: '/setup', label: 'Setup' },
19
+ import { Media } from '@murumets-ee/media'
20
+ import {
21
+ Ticket,
22
+ TicketMessage,
23
+ TicketAttachment,
24
+ Department,
25
+ TicketTag,
26
+ } from '@murumets-ee/ticketing'
27
+
28
+ /** All content entities registered in the admin API. */
29
+ export const allEntities = [
30
+ Media,
31
+ Ticket, TicketMessage, TicketAttachment, Department, TicketTag,
501
32
  ]
502
33
 
503
- export function NavHeader() {
504
- const pathname = usePathname()
505
-
506
- function isActive(href: string) {
507
- return href === '/' ? pathname === '/' : pathname.startsWith(href)
508
- }
509
-
510
- const linkClass = (href: string) =>
511
- \`px-3 py-1.5 rounded-md text-sm transition-colors \${
512
- isActive(href)
513
- ? 'bg-zinc-200 text-zinc-900 dark:bg-zinc-800 dark:text-zinc-50'
514
- : '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'
515
- }\`
516
-
517
- return (
518
- <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">
519
- <nav className="max-w-6xl mx-auto flex items-center gap-1 px-4 h-12">
520
- <span className="font-semibold text-sm text-zinc-700 dark:text-zinc-300 mr-3 select-none">
521
- ${s} Admin
522
- </span>
523
- {links.map(({ href, label }) => (
524
- <Link key={href} href={href} className={linkClass(href)}>
525
- {label}
526
- </Link>
527
- ))}
528
- <div className="ml-auto">
529
- <ThemeToggle />
530
- </div>
531
- </nav>
532
- </header>
533
- )
534
- }
535
- `),await e(d(c,`app/layout.tsx`),`import './globals.css'
536
-
537
- export default function RootLayout({ children }: { children: React.ReactNode }) {
538
- return children
539
- }
540
- `),await e(d(c,`app/[locale]/layout.tsx`),`import type { Metadata } from 'next'
541
- import { Geist, Geist_Mono } from 'next/font/google'
542
- import { NextIntlClientProvider } from 'next-intl'
543
- import { getMessages } from 'next-intl/server'
544
- import { notFound } from 'next/navigation'
545
- import { routing } from '@/i18n/routing'
546
- import { ThemeProvider } from '../theme-provider'
547
- import { NavHeader } from '../nav-header'
548
-
549
- const geistSans = Geist({
550
- variable: '--font-geist-sans',
551
- subsets: ['latin'],
552
- })
553
-
554
- const geistMono = Geist_Mono({
555
- variable: '--font-geist-mono',
556
- subsets: ['latin'],
557
- })
34
+ /** Taxonomy vocabularies. */
35
+ export const taxonomyVocabularies = {}
558
36
 
559
- export const metadata: Metadata = {
560
- title: '${s} Admin',
561
- description: 'Built with Lumi CMS Toolkit',
562
- }
563
-
564
- export default async function LocaleLayout({
565
- children,
566
- params,
567
- }: {
568
- children: React.ReactNode
569
- params: Promise<{ locale: string }>
570
- }) {
571
- const { locale } = await params
572
- if (!routing.locales.includes(locale as any)) notFound()
573
-
574
- const messages = await getMessages()
575
-
576
- return (
577
- <html lang={locale} suppressHydrationWarning>
578
- <body className={\`\${geistSans.variable} \${geistMono.variable} antialiased\`}>
579
- <ThemeProvider>
580
- <NextIntlClientProvider locale={locale} messages={messages}>
581
- <NavHeader />
582
- {children}
583
- </NextIntlClientProvider>
584
- </ThemeProvider>
585
- </body>
586
- </html>
587
- )
588
- }
589
- `),await e(d(c,`app/[locale]/page.tsx`),`import { createQueryClient } from '@murumets-ee/core/clients'
590
- import { Article, Category } from '@${s}/config/entities'
591
- import { getToolkitApp } from '@${s}/config/app'
592
-
593
- export default async function HomePage() {
594
- await getToolkitApp()
595
- const articles = createQueryClient(Article)
596
- const categories = createQueryClient(Category)
597
-
598
- const [articleList, categoryList] = await Promise.all([
599
- articles.findMany({ limit: 10 }),
600
- categories.findMany({}),
601
- ])
602
-
603
- return (
604
- <div className="min-h-screen p-8">
605
- <div className="max-w-4xl mx-auto">
606
- <h1 className="text-4xl font-bold mb-8">Welcome to ${s}</h1>
607
-
608
- <section className="mb-12">
609
- <h2 className="text-2xl font-semibold mb-4">
610
- Categories ({categoryList.length})
611
- </h2>
612
- <div className="grid gap-4 md:grid-cols-2">
613
- {categoryList.map((cat) => (
614
- <div
615
- key={cat.id}
616
- className="border border-zinc-200 dark:border-zinc-800 rounded-lg p-4"
617
- >
618
- <h3 className="font-semibold text-lg">{cat.name}</h3>
619
- <p className="text-sm text-zinc-600 dark:text-zinc-400">
620
- {cat.description}
621
- </p>
622
- </div>
623
- ))}
624
- </div>
625
- </section>
626
-
627
- <section>
628
- <h2 className="text-2xl font-semibold mb-4">
629
- Articles ({articleList.length})
630
- </h2>
631
- {articleList.length === 0 ? (
632
- <p className="text-zinc-500">No published articles yet.</p>
633
- ) : (
634
- <div className="space-y-4">
635
- {articleList.map((article) => (
636
- <div
637
- key={article.id}
638
- className="border border-zinc-200 dark:border-zinc-800 rounded-lg p-6"
639
- >
640
- <h3 className="text-xl font-bold">{article.title}</h3>
641
- <p className="text-zinc-600 dark:text-zinc-400 mt-2">
642
- {article.excerpt}
643
- </p>
644
- </div>
645
- ))}
646
- </div>
647
- )}
648
- </section>
649
- </div>
650
- </div>
651
- )
652
- }
653
- `),await e(d(c,`app/api/auth/[...all]/route.ts`),`import { toNextJsHandler } from 'better-auth/next-js'
654
- import { auth } from '@${s}/config/auth'
655
-
656
- const { GET, POST } = toNextJsHandler(auth)
657
- export { GET, POST }
658
- `),await e(d(c,`app/[locale]/auth/layout.tsx`),`import { AuthProviders } from './providers'
659
- import type { ReactNode } from 'react'
660
-
661
- export default function AuthLayout({ children }: { children: ReactNode }) {
662
- return (
663
- <AuthProviders>
664
- <div className="flex min-h-[calc(100vh-3rem)] items-center justify-center px-4">
665
- {children}
666
- </div>
667
- </AuthProviders>
668
- )
669
- }
670
- `),await e(d(c,`app/[locale]/auth/providers.tsx`),`'use client'
671
-
672
- import { AuthUIProvider } from '@murumets-ee/auth-ui'
673
- import { authClient } from '@${s}/config/auth-client'
674
- import Link from 'next/link'
675
- import { useRouter } from 'next/navigation'
676
- import { useLocale } from 'next-intl'
677
- import type { ReactNode } from 'react'
678
-
679
- export function AuthProviders({ children }: { children: ReactNode }) {
680
- const router = useRouter()
681
- const locale = useLocale()
682
-
683
- return (
684
- <AuthUIProvider
685
- authClient={authClient as never}
686
- basePath="/auth"
687
- redirectTo="/"
688
- Link={Link}
689
- navigate={(url) => router.push(url)}
690
- resetPasswordUrl={\`/\${locale}/auth/reset-password\`}
691
- >
692
- {children}
693
- </AuthUIProvider>
694
- )
695
- }
696
- `),await e(d(c,`app/[locale]/auth/sign-in/page.tsx`),`import { SignInForm } from '@murumets-ee/auth-ui'
697
-
698
- export default function SignInPage() {
699
- return <SignInForm />
700
- }
701
- `),await e(d(c,`app/[locale]/auth/sign-up/page.tsx`),`import { SignUpForm } from '@murumets-ee/auth-ui'
702
-
703
- export default function SignUpPage() {
704
- return <SignUpForm />
705
- }
706
- `),await e(d(c,`app/[locale]/auth/forgot-password/page.tsx`),`import { ForgotPasswordForm } from '@murumets-ee/auth-ui'
707
-
708
- export default function ForgotPasswordPage() {
709
- return <ForgotPasswordForm />
710
- }
711
- `),await e(d(c,`app/[locale]/auth/reset-password/page.tsx`),`import { Suspense } from 'react'
712
- import { ResetPasswordContent } from './content'
713
-
714
- export default function ResetPasswordPage() {
715
- return (
716
- <Suspense>
717
- <ResetPasswordContent />
718
- </Suspense>
719
- )
720
- }
721
- `),await e(d(c,`app/[locale]/auth/reset-password/content.tsx`),`'use client'
722
-
723
- import { useSearchParams } from 'next/navigation'
724
- import { ResetPasswordForm } from '@murumets-ee/auth-ui'
725
-
726
- export function ResetPasswordContent() {
727
- const searchParams = useSearchParams()
728
- const token = searchParams.get('token')
729
-
730
- if (!token) {
731
- return (
732
- <div className="text-center">
733
- <h1 className="text-2xl font-bold text-zinc-900 dark:text-zinc-50">
734
- Invalid or expired link
735
- </h1>
736
- <p className="mt-2 text-zinc-500">
737
- Please request a new password reset.
738
- </p>
739
- </div>
740
- )
741
- }
742
-
743
- return <ResetPasswordForm token={token} />
744
- }
745
- `),await e(d(c,`app/[locale]/setup/page.tsx`),`import { redirect } from 'next/navigation'
746
- import { sql } from 'drizzle-orm'
747
- import { getToolkitApp } from '@${s}/config/app'
748
- import { SetupForm } from './form'
749
-
750
- export default async function SetupPage() {
751
- const app = await getToolkitApp()
752
- const result = await app.db.readOnly.execute<{ count: string }>(
753
- sql\`SELECT COUNT(*)::text as count FROM "user"\`,
754
- )
755
-
756
- if (Number(result[0]?.count) > 0) {
757
- redirect('/')
758
- }
759
-
760
- return (
761
- <div className="max-w-md mx-auto p-8">
762
- <h1 className="text-2xl font-bold mb-2">Create Admin</h1>
763
- <p className="text-sm text-zinc-500 dark:text-zinc-400 mb-6">
764
- No users found. Create the first admin account.
765
- </p>
766
- <SetupForm />
767
- </div>
768
- )
769
- }
770
- `),await e(d(c,`app/[locale]/setup/form.tsx`),`'use client'
771
-
772
- import { useState } from 'react'
773
- import { createFirstAdmin } from './actions'
774
-
775
- export function SetupForm() {
776
- const [result, setResult] = useState<{ ok?: boolean; error?: string; email?: string } | null>(null)
777
- const [loading, setLoading] = useState(false)
778
-
779
- async function handleSubmit(e: React.FormEvent<HTMLFormElement>) {
780
- e.preventDefault()
781
- setLoading(true)
782
- setResult(null)
783
- const res = await createFirstAdmin(new FormData(e.currentTarget))
784
- setResult(res)
785
- setLoading(false)
786
- }
787
-
788
- if (result?.ok) {
789
- return (
790
- <div className="space-y-2">
791
- <p className="text-green-600 dark:text-green-400">Admin created: {result.email}</p>
792
- <a href="/auth/sign-in" className="text-blue-600 dark:text-blue-400 hover:underline">
793
- Sign in &rarr;
794
- </a>
795
- </div>
796
- )
797
- }
798
-
799
- return (
800
- <form onSubmit={handleSubmit} className="flex flex-col gap-4">
801
- <label className="text-sm font-medium">
802
- Name
803
- <input
804
- name="name"
805
- required
806
- 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"
807
- />
808
- </label>
809
- <label className="text-sm font-medium">
810
- Email
811
- <input
812
- name="email"
813
- type="email"
814
- required
815
- 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"
816
- />
817
- </label>
818
- <label className="text-sm font-medium">
819
- Password (min 8 chars)
820
- <input
821
- name="password"
822
- type="password"
823
- required
824
- minLength={8}
825
- 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"
826
- />
827
- </label>
828
-
829
- {result?.error && <p className="text-red-600 dark:text-red-400 text-sm">{result.error}</p>}
830
-
831
- <button
832
- type="submit"
833
- disabled={loading}
834
- className="px-4 py-2 text-sm rounded-md bg-blue-600 text-white hover:bg-blue-500 disabled:opacity-50 transition-colors"
835
- >
836
- {loading ? 'Creating...' : 'Create Admin'}
837
- </button>
838
- </form>
839
- )
840
- }
841
- `),await e(d(c,`app/[locale]/setup/actions.ts`),`'use server'
842
-
843
- import { sql } from 'drizzle-orm'
844
- import { getToolkitApp } from '@${s}/config/app'
845
- import { getAuth } from '@murumets-ee/auth'
846
-
847
- export async function createFirstAdmin(formData: FormData) {
848
- const email = formData.get('email') as string
849
- const password = formData.get('password') as string
850
- const name = formData.get('name') as string
851
-
852
- if (!email || !password || !name) {
853
- return { error: 'All fields are required' }
854
- }
855
-
856
- if (password.length < 8) {
857
- return { error: 'Password must be at least 8 characters' }
858
- }
859
-
860
- const app = await getToolkitApp()
861
-
862
- const canCreate = await app.db.readWrite.transaction(async (tx) => {
863
- await tx.execute(sql\`SELECT pg_advisory_xact_lock(1)\`)
864
-
865
- const result = await tx.execute<{ count: string }>(
866
- sql\`SELECT COUNT(*)::text as count FROM "user"\`,
867
- )
868
- return Number(result[0]?.count) === 0
869
- })
870
-
871
- if (!canCreate) {
872
- return { error: 'Admin user already exists. Setup is complete.' }
873
- }
874
-
875
- const auth = getAuth()
876
-
877
- const adminUser = await auth.api.signUpEmail({
878
- body: { email, password, name },
879
- })
880
-
881
- await app.db.readWrite.execute(
882
- sql\`UPDATE "user" SET role = 'admin' WHERE id = \${adminUser.user.id}\`,
883
- )
884
-
885
- return { ok: true, email: adminUser.user.email }
886
- }
887
- `)}async function y(i,a){let{name:o}=a,s=d(i,`apps/web`);n(`pnpm create next-app@16 ${s} --typescript --tailwind --no-eslint --app --no-src-dir --turbopack --react-compiler --skip-install --import-alias "@/*"`),await r(s,[`app/page.tsx`,`app/page.module.css`,`app/fonts`,`README.md`,`pnpm-workspace.yaml`]),await t(d(s,`package.json`),{dependencies:{[`@${o}/config`]:`workspace:*`,"@murumets-ee/core":`^${m.myorgCore}`,"@murumets-ee/auth-ui":`^${m.myorgAuthUi}`,"next-intl":`^${m.nextIntl}`,"next-themes":`^${m.nextThemes}`,"lucide-react":`^${m.lucideReact}`},devDependencies:{"babel-plugin-react-compiler":m.babelReactCompiler}});let{appendToFile:c}=await import(`./utils-DHetVfSn.mjs`).then(e=>e.i);await c(d(s,`.gitignore`),`
888
- # Environment
889
- .env*
890
- !.env.example
891
- `),await e(d(s,`next.config.ts`),`import type { NextConfig } from 'next'
892
- import createNextIntlPlugin from 'next-intl/plugin'
893
-
894
- const withNextIntl = createNextIntlPlugin('./i18n/request.ts')
895
-
896
- const nextConfig: NextConfig = {
897
- reactCompiler: true,
898
- transpilePackages: [
899
- '@${o}/config',
900
- '@murumets-ee/core',
901
- '@murumets-ee/entity',
902
- '@murumets-ee/db',
903
- '@murumets-ee/logging',
904
- '@murumets-ee/auth-ui',
905
- ],
906
- serverExternalPackages: ['drizzle-orm', 'postgres'],
907
- }
908
-
909
- export default withNextIntl(nextConfig)
910
- `),await e(d(s,`proxy.ts`),`import createMiddleware from 'next-intl/middleware'
911
- import { routing } from './i18n/routing'
912
-
913
- export default createMiddleware(routing)
914
-
915
- export const config = {
916
- matcher: '/((?!api|_next|_vercel|.*\\\\..*).*)',
917
- }
918
- `),await e(d(s,`i18n/routing.ts`),`import { defineRouting } from 'next-intl/routing'
919
-
920
- export const routing = defineRouting({
921
- locales: ['en'],
922
- defaultLocale: 'en',
923
- })
924
- `),await e(d(s,`i18n/request.ts`),`import { getRequestConfig } from 'next-intl/server'
925
- import { hasLocale } from 'next-intl'
926
- import { routing } from './routing'
927
- import { getAuthMessages } from '@murumets-ee/auth-ui/i18n'
928
-
929
- export default getRequestConfig(async ({ requestLocale }) => {
930
- const requested = await requestLocale
931
- const locale = hasLocale(routing.locales, requested)
932
- ? requested
933
- : routing.defaultLocale
934
-
935
- const authMessages = await getAuthMessages(locale)
936
-
937
- return {
938
- locale,
939
- messages: {
940
- ...authMessages,
941
- },
942
- }
943
- })
944
- `),await e(d(s,`app/globals.css`),`@import "tailwindcss";
945
- @source "../node_modules/@murumets-ee/auth-ui/dist";
946
-
947
- @custom-variant dark (&:where(.dark, .dark *));
948
-
949
- :root {
950
- --background: #ffffff;
951
- --foreground: #171717;
952
- }
953
-
954
- @theme inline {
955
- --color-background: var(--background);
956
- --color-foreground: var(--foreground);
957
- --font-sans: var(--font-geist-sans);
958
- --font-mono: var(--font-geist-mono);
959
- }
960
-
961
- .dark {
962
- --background: #0a0a0a;
963
- --foreground: #ededed;
964
- }
965
-
966
- body {
967
- background: var(--background);
968
- color: var(--foreground);
969
- font-family: Arial, Helvetica, sans-serif;
970
- }
971
- `),await e(d(s,`app/theme-provider.tsx`),`'use client'
972
-
973
- import { ThemeProvider as NextThemesProvider } from 'next-themes'
974
- import type { ReactNode } from 'react'
975
-
976
- export function ThemeProvider({ children }: { children: ReactNode }) {
977
- return (
978
- <NextThemesProvider
979
- attribute="class"
980
- defaultTheme="system"
981
- enableSystem
982
- disableTransitionOnChange
983
- >
984
- {children}
985
- </NextThemesProvider>
986
- )
987
- }
988
- `),await e(d(s,`app/theme-toggle.tsx`),`'use client'
989
-
990
- import { useTheme } from 'next-themes'
991
- import { useState, useEffect } from 'react'
992
- import { Sun, Moon } from 'lucide-react'
993
-
994
- export function ThemeToggle() {
995
- const [mounted, setMounted] = useState(false)
996
- const { resolvedTheme, setTheme } = useTheme()
997
-
998
- useEffect(() => { setMounted(true) }, [])
999
-
1000
- if (!mounted) {
1001
- return <div className="h-8 w-8" />
1002
- }
1003
-
1004
- return (
1005
- <button
1006
- type="button"
1007
- onClick={() => setTheme(resolvedTheme === 'dark' ? 'light' : 'dark')}
1008
- 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"
1009
- aria-label={resolvedTheme === 'dark' ? 'Switch to light mode' : 'Switch to dark mode'}
1010
- >
1011
- {resolvedTheme === 'dark' ? <Sun className="h-5 w-5" /> : <Moon className="h-5 w-5" />}
1012
- </button>
1013
- )
1014
- }
1015
- `),await e(d(s,`app/nav-header.tsx`),`'use client'
1016
-
1017
- import Link from 'next/link'
1018
- import { usePathname } from 'next/navigation'
1019
- import { ThemeToggle } from './theme-toggle'
1020
-
1021
- const links = [
1022
- { href: '/', label: 'Home' },
37
+ /** Entities exposed via generic CRUD handler (subset of allEntities). */
38
+ export const crudEntities = [
39
+ Media,
40
+ Ticket, TicketMessage, TicketAttachment,
1023
41
  ]
1024
42
 
1025
- export function NavHeader() {
1026
- const pathname = usePathname()
1027
-
1028
- function isActive(href: string) {
1029
- return href === '/' ? pathname === '/' : pathname.startsWith(href)
1030
- }
1031
-
1032
- const linkClass = (href: string) =>
1033
- \`px-3 py-1.5 rounded-md text-sm transition-colors \${
1034
- isActive(href)
1035
- ? 'bg-zinc-200 text-zinc-900 dark:bg-zinc-800 dark:text-zinc-50'
1036
- : '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'
1037
- }\`
1038
-
1039
- return (
1040
- <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">
1041
- <nav className="max-w-6xl mx-auto flex items-center gap-1 px-4 h-12">
1042
- <span className="font-semibold text-sm text-zinc-700 dark:text-zinc-300 mr-3 select-none">
1043
- ${o}
1044
- </span>
1045
- {links.map(({ href, label }) => (
1046
- <Link key={href} href={href} className={linkClass(href)}>
1047
- {label}
1048
- </Link>
1049
- ))}
1050
- <div className="ml-auto">
1051
- <ThemeToggle />
1052
- </div>
1053
- </nav>
1054
- </header>
1055
- )
1056
- }
1057
- `),await e(d(s,`app/layout.tsx`),`import './globals.css'
1058
-
1059
- export default function RootLayout({ children }: { children: React.ReactNode }) {
1060
- return children
1061
- }
1062
- `),await e(d(s,`app/[locale]/layout.tsx`),`import type { Metadata } from 'next'
1063
- import { Geist, Geist_Mono } from 'next/font/google'
1064
- import { NextIntlClientProvider } from 'next-intl'
1065
- import { getMessages } from 'next-intl/server'
1066
- import { notFound } from 'next/navigation'
1067
- import { routing } from '@/i18n/routing'
1068
- import { ThemeProvider } from '../theme-provider'
1069
- import { NavHeader } from '../nav-header'
1070
-
1071
- const geistSans = Geist({
1072
- variable: '--font-geist-sans',
1073
- subsets: ['latin'],
1074
- })
1075
-
1076
- const geistMono = Geist_Mono({
1077
- variable: '--font-geist-mono',
1078
- subsets: ['latin'],
1079
- })
1080
-
1081
- export const metadata: Metadata = {
1082
- title: '${o}',
1083
- description: 'Built with Lumi CMS Toolkit',
1084
- }
1085
-
1086
- export default async function LocaleLayout({
1087
- children,
1088
- params,
1089
- }: {
1090
- children: React.ReactNode
1091
- params: Promise<{ locale: string }>
1092
- }) {
1093
- const { locale } = await params
1094
- if (!routing.locales.includes(locale as any)) notFound()
1095
-
1096
- const messages = await getMessages()
1097
-
1098
- return (
1099
- <html lang={locale} suppressHydrationWarning>
1100
- <body className={\`\${geistSans.variable} \${geistMono.variable} antialiased\`}>
1101
- <ThemeProvider>
1102
- <NextIntlClientProvider locale={locale} messages={messages}>
1103
- <NavHeader />
1104
- {children}
1105
- </NextIntlClientProvider>
1106
- </ThemeProvider>
1107
- </body>
1108
- </html>
1109
- )
1110
- }
1111
- `),await e(d(s,`app/[locale]/page.tsx`),`import { createQueryClient } from '@murumets-ee/core/clients'
1112
- import { Article, Category } from '@${o}/config/entities'
1113
- import { getToolkitApp } from '@${o}/config/app'
1114
-
1115
- export default async function HomePage() {
1116
- await getToolkitApp()
1117
- const articles = createQueryClient(Article)
1118
- const categories = createQueryClient(Category)
1119
-
1120
- const [articleList, categoryList] = await Promise.all([
1121
- articles.findMany({ limit: 10 }),
1122
- categories.findMany({}),
1123
- ])
1124
-
1125
- return (
1126
- <div className="min-h-screen p-8">
1127
- <div className="max-w-4xl mx-auto">
1128
- <h1 className="text-4xl font-bold mb-8">Welcome to ${o}</h1>
1129
-
1130
- <section className="mb-12">
1131
- <h2 className="text-2xl font-semibold mb-4">
1132
- Categories ({categoryList.length})
1133
- </h2>
1134
- <div className="grid gap-4 md:grid-cols-2">
1135
- {categoryList.map((cat) => (
1136
- <div
1137
- key={cat.id}
1138
- className="border border-zinc-200 dark:border-zinc-800 rounded-lg p-4"
1139
- >
1140
- <h3 className="font-semibold text-lg">{cat.name}</h3>
1141
- <p className="text-sm text-zinc-600 dark:text-zinc-400">
1142
- {cat.description}
1143
- </p>
1144
- </div>
1145
- ))}
1146
- </div>
1147
- </section>
43
+ /**
44
+ * Plugin route resource declarations.
45
+ */
46
+ export const pluginResources: { resource: string; actions: readonly string[] }[] = [
47
+ { resource: 'storage', actions: ['view', 'create', 'update', 'delete'] },
48
+ { resource: 'settings', actions: ['view', 'update'] },
49
+ { resource: 'audit-logs', actions: ['view'] },
50
+ { resource: 'permissions', actions: ['view', 'create', 'update', 'delete'] },
51
+ { resource: 'ticketing', actions: ['view', 'create', 'update', 'delete'] },
52
+ ]
53
+ `,`utf-8`);let f=s(t,`app`,`api`,`content`,`[...path]`,`route.ts`);if(e(f)){let e=await n(f,`utf-8`);e=e.replace(/import \{[^}]+\} from '@\/entities'\n/,``),e=e.replace(/entities: \[[^\]]+\]/,`entities: []`),await a(f,e,`utf-8`)}let p=s(t,`app`,`[locale]`,`(shell)`,`admin`,`page.tsx`);e(p)&&await a(p,`import { pages } from '@/lib/admin-pages'
1148
54
 
1149
- <section>
1150
- <h2 className="text-2xl font-semibold mb-4">
1151
- Articles ({articleList.length})
1152
- </h2>
1153
- {articleList.length === 0 ? (
1154
- <p className="text-zinc-500">No published articles yet.</p>
1155
- ) : (
1156
- <div className="space-y-4">
1157
- {articleList.map((article) => (
1158
- <div
1159
- key={article.id}
1160
- className="border border-zinc-200 dark:border-zinc-800 rounded-lg p-6"
1161
- >
1162
- <h3 className="text-xl font-bold">{article.title}</h3>
1163
- <p className="text-zinc-600 dark:text-zinc-400 mt-2">
1164
- {article.excerpt}
1165
- </p>
1166
- </div>
1167
- ))}
1168
- </div>
1169
- )}
1170
- </section>
1171
- </div>
1172
- </div>
1173
- )
1174
- }
1175
- `)}const b=new Set([`.ts`,`.tsx`,`.mts`,`.json`,`.md`,`.yml`,`.yaml`,`.css`,`.html`]),x=new Set([`.env.example`,`Dockerfile`,`.gitignore`]),S=`__PROJECT_NAME__`,C=`__PROJECT_NAME_TITLE__`;async function w(e,t){e.mode===`single`?await T(e,t):await E(e,t)}async function T(e,t){let i=d(process.cwd(),e.name);t?.(`Creating Next.js app...`),n(`pnpm create next-app@16 ${e.name} --typescript --tailwind --no-eslint --app --no-src-dir --turbopack --react-compiler --skip-install --import-alias "@/*"`),await r(i,[`app/page.tsx`,`app/page.module.css`,`app/fonts`,`app/globals.css`,`README.md`]),t?.(`Extracting template...`),await D(e.template,i),t?.(`Personalizing template...`),await k(i,e.name),e.installDeps&&(t?.(`Installing dependencies...`),n(`pnpm install`,{cwd:i}))}async function E(e,t){let r=d(process.cwd(),e.name);t?.(`Creating workspace...`),await h(r,e,t),e.installDeps&&(t?.(`Installing dependencies...`),n(`pnpm install`,{cwd:r}))}async function D(e,t){let n=O(e);if(!i(n))throw Error(`Template tarball missing: ${n}\nRun \`pnpm --filter @murumets-ee/create build:templates\` first.`);await p({file:n,cwd:t})}function O(e){let t=u(f(import.meta.url)),n=t;for(let t=0;t<5;t++){let t=d(n,`package.json`);if(i(t))try{if(JSON.parse(a(t,`utf-8`)).name===`@murumets-ee/create`)return d(n,`templates`,`template-${e}.tar.gz`)}catch{}let r=u(n);if(r===n)break;n=r}throw Error(`Could not find @murumets-ee/create package root above ${t}. template-${e}.tar.gz cannot be located.`)}async function k(e,t){let n=N(t);for await(let r of j(e)){if(!M(r))continue;let e=await s(r,`utf-8`);!e.includes(S)&&!e.includes(C)||await l(r,e.split(C).join(n).split(S).join(t),`utf-8`)}}const A=new Set([`node_modules`,`dist`,`build`,`coverage`,`out`]);async function*j(e){let t=await c(e,{withFileTypes:!0});for(let n of t){let t=d(e,n.name);if(n.isDirectory()){if(A.has(n.name)||n.name.startsWith(`.`))continue;yield*j(t)}else n.isFile()&&(yield t)}}function M(e){let t=e.lastIndexOf(`/`),n=t>=0?e.slice(t+1):e;if(x.has(n))return!0;let r=n.lastIndexOf(`.`);if(r<0)return!1;let i=n.slice(r);return b.has(i)}function N(e){return e.split(/[-_\s]+/).filter(Boolean).map(e=>e[0]?.toUpperCase()+e.slice(1)).join(` `)}export{w as scaffold};
55
+ export default pages.DashboardPage
56
+ `,`utf-8`)}async function S(e,t){let r=E(t);for await(let i of w(e)){if(!T(i))continue;let e=await n(i,`utf-8`);!e.includes(h)&&!e.includes(g)||await a(i,e.split(g).join(r).split(h).join(t),`utf-8`)}}const C=new Set([`node_modules`,`dist`,`build`,`coverage`,`out`]);async function*w(e){let t=await r(e,{withFileTypes:!0});for(let n of t){let t=s(e,n.name);if(n.isDirectory()){if(C.has(n.name)||n.name.startsWith(`.`))continue;yield*w(t)}else n.isFile()&&(yield t)}}function T(e){let t=e.lastIndexOf(`/`),n=t>=0?e.slice(t+1):e;if(m.has(n))return!0;let r=n.lastIndexOf(`.`);if(r<0)return!1;let i=n.slice(r);return p.has(i)}function E(e){return e.split(/[-_\s]+/).filter(Boolean).map(e=>e[0]?.toUpperCase()+e.slice(1)).join(` `)}export{_ as scaffold};
1176
57
  //# sourceMappingURL=index.mjs.map