@murumets-ee/create 0.1.7 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,17 +1,36 @@
1
1
  #!/usr/bin/env node
2
- import{a as e,b as g,c as f,d as u,e as T}from"./chunk-ZAX4VH4C.js";import*as c from"@clack/prompts";import y from"picocolors";import*as s from"@clack/prompts";function I(t){let n={},r=t.slice(2);for(let o=0;o<r.length;o++){let l=r[o];if(l==="--mode"&&r[o+1]){let p=r[++o];(p==="single"||p==="multi")&&(n.mode=p)}else l==="--install"?n.install=!0:l==="--no-install"?n.install=!1:!l.startsWith("-")&&!n.name&&(n.name=l)}return n}async function S(t){let n=I(process.argv),r=n.name??t;if(r&&n.mode&&n.install!==void 0)return{name:r,mode:n.mode,installDeps:n.install};s.intro("@murumets-ee/create");let o=r??await s.text({message:"Project name:",placeholder:"my-project",validate:N=>{if(!N)return"Project name is required";if(!/^[a-z0-9-]+$/.test(N))return"Use lowercase letters, numbers, and hyphens only"}});if(s.isCancel(o))return s.cancel("Cancelled."),null;let l=n.mode??await s.select({message:"App setup:",options:[{value:"single",label:"Single app",hint:"everything in one Next.js project"},{value:"multi",label:"Admin + Frontend",hint:"two apps in a pnpm workspace"}]});if(s.isCancel(l))return s.cancel("Cancelled."),null;let p=n.install??await s.confirm({message:"Install dependencies?",initialValue:!0});return s.isCancel(p)?(s.cancel("Cancelled."),null):{name:o,mode:l,installDeps:p}}import{join as A}from"path";import{join as m}from"path";async function E(t,n){await e(m(t,"lib/auth.ts"),`import { getToolkitApp } from './app'
2
+ import{a as e,b as g,c as f,d as u,e as T}from"./chunk-ZAX4VH4C.js";import*as c from"@clack/prompts";import y from"picocolors";import*as s from"@clack/prompts";function U(t){let n={},r=t.slice(2);for(let o=0;o<r.length;o++){let l=r[o];if(l==="--mode"&&r[o+1]){let p=r[++o];(p==="single"||p==="multi")&&(n.mode=p)}else l==="--install"?n.install=!0:l==="--no-install"?n.install=!1:!l.startsWith("-")&&!n.name&&(n.name=l)}return n}async function S(t){let n=U(process.argv),r=n.name??t;if(r&&n.mode&&n.install!==void 0)return{name:r,mode:n.mode,installDeps:n.install};s.intro("@murumets-ee/create");let o=r??await s.text({message:"Project name:",placeholder:"my-project",validate:N=>{if(!N)return"Project name is required";if(!/^[a-z0-9-]+$/.test(N))return"Use lowercase letters, numbers, and hyphens only"}});if(s.isCancel(o))return s.cancel("Cancelled."),null;let l=n.mode??await s.select({message:"App setup:",options:[{value:"single",label:"Single app",hint:"everything in one Next.js project"},{value:"multi",label:"Admin + Frontend",hint:"two apps in a pnpm workspace"}]});if(s.isCancel(l))return s.cancel("Cancelled."),null;let p=n.install??await s.confirm({message:"Install dependencies?",initialValue:!0});return s.isCancel(p)?(s.cancel("Cancelled."),null):{name:o,mode:l,installDeps:p}}import{join as A}from"path";import{join as m}from"path";async function E(t,n){await e(m(t,"lib/auth.ts"),`import { getToolkitApp } from './app'
3
3
  import { getAuth } from '@murumets-ee/auth'
4
4
 
5
- await getToolkitApp()
6
-
7
- export const auth = getAuth()
5
+ export async function getAuthInstance() {
6
+ await getToolkitApp()
7
+ return getAuth()
8
+ }
8
9
  `),await e(m(t,"lib/auth-client.ts"),`import { createClient } from '@murumets-ee/auth/client'
9
10
 
10
11
  export const authClient = createClient()
11
12
  `),await e(m(t,"app/api/auth/[...all]/route.ts"),`import { toNextJsHandler } from 'better-auth/next-js'
12
- import { auth } from '../../../../lib/auth'
13
+ import { getAuthInstance } from '../../../../lib/auth'
14
+
15
+ let _handler: ReturnType<typeof toNextJsHandler> | null = null
16
+
17
+ async function handler() {
18
+ if (!_handler) {
19
+ const auth = await getAuthInstance()
20
+ _handler = toNextJsHandler(auth)
21
+ }
22
+ return _handler
23
+ }
13
24
 
14
- export const { GET, POST } = toNextJsHandler(auth)
25
+ export async function GET(req: Request) {
26
+ const h = await handler()
27
+ return h.GET(req)
28
+ }
29
+
30
+ export async function POST(req: Request) {
31
+ const h = await handler()
32
+ return h.POST(req)
33
+ }
15
34
  `),await e(m(t,"app/[locale]/auth/layout.tsx"),`import { AuthProviders } from './providers'
16
35
  import type { ReactNode } from 'react'
17
36
 
@@ -413,7 +432,7 @@ generated/
413
432
  # Environment
414
433
  .env*
415
434
  !.env.example
416
- `)}import{join as w}from"path";async function z(t,n){await e(w(t,"entities/index.ts"),`export { Article } from './article'
435
+ `)}import{join as w}from"path";async function R(t,n){await e(w(t,"entities/index.ts"),`export { Article } from './article'
417
436
  export { Category } from './category'
418
437
  `),await e(w(t,"entities/article.ts"),`import { behavior, defineEntity, field } from '@murumets-ee/entity'
419
438
 
@@ -463,13 +482,13 @@ export const Category = defineEntity({
463
482
  delete: 'group.admin',
464
483
  },
465
484
  })
466
- `)}import{join as R}from"path";async function C(t,n){await e(R(t,"i18n/routing.ts"),`import { defineRouting } from 'next-intl/routing'
485
+ `)}import{join as z}from"path";async function C(t,n){await e(z(t,"i18n/routing.ts"),`import { defineRouting } from 'next-intl/routing'
467
486
 
468
487
  export const routing = defineRouting({
469
488
  locales: ['en'],
470
489
  defaultLocale: 'en',
471
490
  })
472
- `),await e(R(t,"i18n/request.ts"),`import { getRequestConfig } from 'next-intl/server'
491
+ `),await e(z(t,"i18n/request.ts"),`import { getRequestConfig } from 'next-intl/server'
473
492
  import { hasLocale } from 'next-intl'
474
493
  import { routing } from './routing'
475
494
  import { getAuthMessages } from '@murumets-ee/auth-ui/i18n'
@@ -565,6 +584,7 @@ volumes:
565
584
  `),await e(a(o,"toolkit.config.ts"),`import { auth } from '@murumets-ee/auth/plugin'
566
585
  import { content } from '@murumets-ee/content/plugin'
567
586
  import { defineConfig } from '@murumets-ee/core'
587
+ import { logging } from '@murumets-ee/logging/plugin'
568
588
  import { mail, ResendMailProvider } from '@murumets-ee/mail'
569
589
  import { media } from '@murumets-ee/media/plugin'
570
590
  import { queue } from '@murumets-ee/queue/plugin'
@@ -596,6 +616,7 @@ export default defineConfig({
596
616
  locales: [{ code: 'en', label: 'English' }],
597
617
  defaultLocale: 'en',
598
618
  }),
619
+ logging(),
599
620
  settings(),
600
621
  storage(),
601
622
  media(),
@@ -713,9 +734,10 @@ export async function getToolkitApp(): Promise<ToolkitApp> {
713
734
  `),await e(a(o,"lib/auth.ts"),`import { getToolkitApp } from './app'
714
735
  import { getAuth } from '@murumets-ee/auth'
715
736
 
716
- await getToolkitApp()
717
-
718
- export const auth = getAuth()
737
+ export async function getAuthInstance() {
738
+ await getToolkitApp()
739
+ return getAuth()
740
+ }
719
741
  `),await e(a(o,"lib/auth-client.ts"),`import { createClient } from '@murumets-ee/auth/client'
720
742
 
721
743
  export const authClient = createClient()
@@ -1144,9 +1166,25 @@ export default async function HomePage() {
1144
1166
  )
1145
1167
  }
1146
1168
  `),await e(a(o,"app/api/auth/[...all]/route.ts"),`import { toNextJsHandler } from 'better-auth/next-js'
1147
- import { auth } from '@${r}/config/auth'
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
+ }
1148
1180
 
1149
- export const { GET, POST } = toNextJsHandler(auth)
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
+ }
1150
1188
  `),await e(a(o,"app/[locale]/auth/layout.tsx"),`import { AuthProviders } from './providers'
1151
1189
  import type { ReactNode } from 'react'
1152
1190
 
@@ -1962,6 +2000,7 @@ export function NavHeader() {
1962
2000
  `)}import{join as x}from"path";async function q(t,n){let{name:r}=n;await e(x(t,"toolkit.config.ts"),`import { auth } from '@murumets-ee/auth/plugin'
1963
2001
  import { content } from '@murumets-ee/content/plugin'
1964
2002
  import { defineConfig } from '@murumets-ee/core'
2003
+ import { logging } from '@murumets-ee/logging/plugin'
1965
2004
  import { mail, ResendMailProvider } from '@murumets-ee/mail'
1966
2005
  import { media } from '@murumets-ee/media/plugin'
1967
2006
  import { queue } from '@murumets-ee/queue/plugin'
@@ -1993,6 +2032,7 @@ export default defineConfig({
1993
2032
  locales: [{ code: 'en', label: 'English' }],
1994
2033
  defaultLocale: 'en',
1995
2034
  }),
2035
+ logging(),
1996
2036
  settings(),
1997
2037
  storage(),
1998
2038
  media(),
@@ -2060,5 +2100,5 @@ export const auth = betterAuth({
2060
2100
  `),await e(x(t,"generated/auth-schema.ts"),`// This file is generated by better-auth CLI.
2061
2101
  // Run: npx @better-auth/cli generate --config auth.config.ts -y
2062
2102
  export {}
2063
- `)}async function U(t,n){t.mode==="single"?await W(t,n):await j(t,n)}async function W(t,n){let r=A(process.cwd(),t.name);n?.("Creating Next.js app..."),u(`pnpm create next-app@${"16"} ${t.name} --typescript --tailwind --no-eslint --app --no-src-dir --turbopack --react-compiler --skip-install --import-alias "@/*"`),await f(r,["app/page.tsx","app/page.module.css","app/fonts","README.md"]),await g(A(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 P(r,t),await z(r,t),await q(r,t),await E(r,t),await C(r,t),await $(r,t),await O(r,t),await M(r,t),t.installDeps&&(n?.("Installing dependencies..."),u("pnpm install",{cwd:r}))}async function j(t,n){let r=A(process.cwd(),t.name);n?.("Creating workspace..."),await _(r,t,n),t.installDeps&&(n?.("Installing dependencies..."),u("pnpm install",{cwd:r}))}async function G(){let t=process.argv[2],n=await S(t);if(!n)return;let r=c.spinner();try{r.start("Creating Next.js app..."),await U(n,l=>{r.stop(`${y.green("\u2713")} Done`),r.start(l)}),r.stop(`${y.green("\u2713")} Done`);let o=[`cd ${n.name}`,"cp .env.example .env","docker compose up -d","npx @murumets-ee/cli setup","pnpm db:migrate","pnpm dev","# Visit /setup to create your first admin user"];c.note(o.join(`
2064
- `),"Next steps"),c.outro(`${y.green("Success!")} Your project is ready.`)}catch(o){r.stop(y.red("Failed.")),c.log.error(o instanceof Error?o.message:String(o)),process.exit(1)}}G();
2103
+ `)}async function I(t,n){t.mode==="single"?await W(t,n):await G(t,n)}async function W(t,n){let r=A(process.cwd(),t.name);n?.("Creating Next.js app..."),u(`pnpm create next-app@${"16"} ${t.name} --typescript --tailwind --no-eslint --app --no-src-dir --turbopack --react-compiler --skip-install --import-alias "@/*"`),await f(r,["app/page.tsx","app/page.module.css","app/fonts","README.md"]),await g(A(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 P(r,t),await R(r,t),await q(r,t),await E(r,t),await C(r,t),await $(r,t),await O(r,t),await M(r,t),t.installDeps&&(n?.("Installing dependencies..."),u("pnpm install",{cwd:r}))}async function G(t,n){let r=A(process.cwd(),t.name);n?.("Creating workspace..."),await _(r,t,n),t.installDeps&&(n?.("Installing dependencies..."),u("pnpm install",{cwd:r}))}async function j(){let t=process.argv[2],n=await S(t);if(!n)return;let r=c.spinner();try{r.start("Creating Next.js app..."),await I(n,l=>{r.stop(`${y.green("\u2713")} Done`),r.start(l)}),r.stop(`${y.green("\u2713")} Done`);let o=[`cd ${n.name}`,"cp .env.example .env","docker compose up -d","npx @murumets-ee/cli setup","pnpm db:migrate","pnpm dev","# Visit /setup to create your first admin user"];c.note(o.join(`
2104
+ `),"Next steps"),c.outro(`${y.green("Success!")} Your project is ready.`)}catch(o){r.stop(y.red("Failed.")),c.log.error(o instanceof Error?o.message:String(o)),process.exit(1)}}j();