@murumets-ee/create 0.1.7 → 0.1.8
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 +52 -16
- package/dist/index.js +47 -11
- package/package.json +1 -1
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
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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 {
|
|
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
|
|
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
|
|
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
|
|
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(
|
|
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'
|
|
@@ -713,9 +732,10 @@ export async function getToolkitApp(): Promise<ToolkitApp> {
|
|
|
713
732
|
`),await e(a(o,"lib/auth.ts"),`import { getToolkitApp } from './app'
|
|
714
733
|
import { getAuth } from '@murumets-ee/auth'
|
|
715
734
|
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
735
|
+
export async function getAuthInstance() {
|
|
736
|
+
await getToolkitApp()
|
|
737
|
+
return getAuth()
|
|
738
|
+
}
|
|
719
739
|
`),await e(a(o,"lib/auth-client.ts"),`import { createClient } from '@murumets-ee/auth/client'
|
|
720
740
|
|
|
721
741
|
export const authClient = createClient()
|
|
@@ -1144,9 +1164,25 @@ export default async function HomePage() {
|
|
|
1144
1164
|
)
|
|
1145
1165
|
}
|
|
1146
1166
|
`),await e(a(o,"app/api/auth/[...all]/route.ts"),`import { toNextJsHandler } from 'better-auth/next-js'
|
|
1147
|
-
import {
|
|
1167
|
+
import { getAuthInstance } from '@${r}/config/auth'
|
|
1168
|
+
|
|
1169
|
+
let _handler: ReturnType<typeof toNextJsHandler> | null = null
|
|
1170
|
+
|
|
1171
|
+
async function handler() {
|
|
1172
|
+
if (!_handler) {
|
|
1173
|
+
const auth = await getAuthInstance()
|
|
1174
|
+
_handler = toNextJsHandler(auth)
|
|
1175
|
+
}
|
|
1176
|
+
return _handler
|
|
1177
|
+
}
|
|
1148
1178
|
|
|
1149
|
-
export
|
|
1179
|
+
export async function GET(req: Request) {
|
|
1180
|
+
return (await handler()).GET(req)
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
export async function POST(req: Request) {
|
|
1184
|
+
return (await handler()).POST(req)
|
|
1185
|
+
}
|
|
1150
1186
|
`),await e(a(o,"app/[locale]/auth/layout.tsx"),`import { AuthProviders } from './providers'
|
|
1151
1187
|
import type { ReactNode } from 'react'
|
|
1152
1188
|
|
|
@@ -2060,5 +2096,5 @@ export const auth = betterAuth({
|
|
|
2060
2096
|
`),await e(x(t,"generated/auth-schema.ts"),`// This file is generated by better-auth CLI.
|
|
2061
2097
|
// Run: npx @better-auth/cli generate --config auth.config.ts -y
|
|
2062
2098
|
export {}
|
|
2063
|
-
`)}async function
|
|
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)}}
|
|
2099
|
+
`)}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(`
|
|
2100
|
+
`),"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();
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,35 @@
|
|
|
1
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
2
|
import { getAuth } from '@murumets-ee/auth'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
export async function getAuthInstance() {
|
|
5
|
+
await getToolkitApp()
|
|
6
|
+
return getAuth()
|
|
7
|
+
}
|
|
7
8
|
`),await e(s(t,"lib/auth-client.ts"),`import { createClient } from '@murumets-ee/auth/client'
|
|
8
9
|
|
|
9
10
|
export const authClient = createClient()
|
|
10
11
|
`),await e(s(t,"app/api/auth/[...all]/route.ts"),`import { toNextJsHandler } from 'better-auth/next-js'
|
|
11
|
-
import {
|
|
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
|
+
}
|
|
12
23
|
|
|
13
|
-
export
|
|
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
|
+
}
|
|
14
33
|
`),await e(s(t,"app/[locale]/auth/layout.tsx"),`import { AuthProviders } from './providers'
|
|
15
34
|
import type { ReactNode } from 'react'
|
|
16
35
|
|
|
@@ -712,9 +731,10 @@ export async function getToolkitApp(): Promise<ToolkitApp> {
|
|
|
712
731
|
`),await e(o(a,"lib/auth.ts"),`import { getToolkitApp } from './app'
|
|
713
732
|
import { getAuth } from '@murumets-ee/auth'
|
|
714
733
|
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
734
|
+
export async function getAuthInstance() {
|
|
735
|
+
await getToolkitApp()
|
|
736
|
+
return getAuth()
|
|
737
|
+
}
|
|
718
738
|
`),await e(o(a,"lib/auth-client.ts"),`import { createClient } from '@murumets-ee/auth/client'
|
|
719
739
|
|
|
720
740
|
export const authClient = createClient()
|
|
@@ -1143,9 +1163,25 @@ export default async function HomePage() {
|
|
|
1143
1163
|
)
|
|
1144
1164
|
}
|
|
1145
1165
|
`),await e(o(a,"app/api/auth/[...all]/route.ts"),`import { toNextJsHandler } from 'better-auth/next-js'
|
|
1146
|
-
import {
|
|
1166
|
+
import { getAuthInstance } from '@${r}/config/auth'
|
|
1167
|
+
|
|
1168
|
+
let _handler: ReturnType<typeof toNextJsHandler> | null = null
|
|
1169
|
+
|
|
1170
|
+
async function handler() {
|
|
1171
|
+
if (!_handler) {
|
|
1172
|
+
const auth = await getAuthInstance()
|
|
1173
|
+
_handler = toNextJsHandler(auth)
|
|
1174
|
+
}
|
|
1175
|
+
return _handler
|
|
1176
|
+
}
|
|
1147
1177
|
|
|
1148
|
-
export
|
|
1178
|
+
export async function GET(req: Request) {
|
|
1179
|
+
return (await handler()).GET(req)
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
export async function POST(req: Request) {
|
|
1183
|
+
return (await handler()).POST(req)
|
|
1184
|
+
}
|
|
1149
1185
|
`),await e(o(a,"app/[locale]/auth/layout.tsx"),`import { AuthProviders } from './providers'
|
|
1150
1186
|
import type { ReactNode } from 'react'
|
|
1151
1187
|
|
|
@@ -2059,4 +2095,4 @@ export const auth = betterAuth({
|
|
|
2059
2095
|
`),await e(d(t,"generated/auth-schema.ts"),`// This file is generated by better-auth CLI.
|
|
2060
2096
|
// Run: npx @better-auth/cli generate --config auth.config.ts -y
|
|
2061
2097
|
export {}
|
|
2062
|
-
`)}async function O(t,n){t.mode==="single"?await q(t,n):await
|
|
2098
|
+
`)}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};
|