@murumets-ee/create 0.1.6 → 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 +55 -16
- package/dist/index.js +52 -13
- 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
|
|
|
@@ -323,6 +342,9 @@ COPY --from=deps /app/node_modules ./node_modules
|
|
|
323
342
|
COPY . .
|
|
324
343
|
ENV NODE_ENV=production
|
|
325
344
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
345
|
+
# Dummy env vars so toolkit.config.ts doesn't throw at build time (no DB connection needed)
|
|
346
|
+
ENV DATABASE_URL=postgresql://build:build@localhost:5432/build
|
|
347
|
+
ENV BETTER_AUTH_SECRET=build-secret-not-used-at-runtime
|
|
326
348
|
RUN pnpm build
|
|
327
349
|
|
|
328
350
|
# --- Stage 3: Production runner ---
|
|
@@ -410,7 +432,7 @@ generated/
|
|
|
410
432
|
# Environment
|
|
411
433
|
.env*
|
|
412
434
|
!.env.example
|
|
413
|
-
`)}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'
|
|
414
436
|
export { Category } from './category'
|
|
415
437
|
`),await e(w(t,"entities/article.ts"),`import { behavior, defineEntity, field } from '@murumets-ee/entity'
|
|
416
438
|
|
|
@@ -460,13 +482,13 @@ export const Category = defineEntity({
|
|
|
460
482
|
delete: 'group.admin',
|
|
461
483
|
},
|
|
462
484
|
})
|
|
463
|
-
`)}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'
|
|
464
486
|
|
|
465
487
|
export const routing = defineRouting({
|
|
466
488
|
locales: ['en'],
|
|
467
489
|
defaultLocale: 'en',
|
|
468
490
|
})
|
|
469
|
-
`),await e(
|
|
491
|
+
`),await e(z(t,"i18n/request.ts"),`import { getRequestConfig } from 'next-intl/server'
|
|
470
492
|
import { hasLocale } from 'next-intl'
|
|
471
493
|
import { routing } from './routing'
|
|
472
494
|
import { getAuthMessages } from '@murumets-ee/auth-ui/i18n'
|
|
@@ -710,9 +732,10 @@ export async function getToolkitApp(): Promise<ToolkitApp> {
|
|
|
710
732
|
`),await e(a(o,"lib/auth.ts"),`import { getToolkitApp } from './app'
|
|
711
733
|
import { getAuth } from '@murumets-ee/auth'
|
|
712
734
|
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
735
|
+
export async function getAuthInstance() {
|
|
736
|
+
await getToolkitApp()
|
|
737
|
+
return getAuth()
|
|
738
|
+
}
|
|
716
739
|
`),await e(a(o,"lib/auth-client.ts"),`import { createClient } from '@murumets-ee/auth/client'
|
|
717
740
|
|
|
718
741
|
export const authClient = createClient()
|
|
@@ -1141,9 +1164,25 @@ export default async function HomePage() {
|
|
|
1141
1164
|
)
|
|
1142
1165
|
}
|
|
1143
1166
|
`),await e(a(o,"app/api/auth/[...all]/route.ts"),`import { toNextJsHandler } from 'better-auth/next-js'
|
|
1144
|
-
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
|
+
}
|
|
1145
1178
|
|
|
1146
|
-
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
|
+
}
|
|
1147
1186
|
`),await e(a(o,"app/[locale]/auth/layout.tsx"),`import { AuthProviders } from './providers'
|
|
1148
1187
|
import type { ReactNode } from 'react'
|
|
1149
1188
|
|
|
@@ -2057,5 +2096,5 @@ export const auth = betterAuth({
|
|
|
2057
2096
|
`),await e(x(t,"generated/auth-schema.ts"),`// This file is generated by better-auth CLI.
|
|
2058
2097
|
// Run: npx @better-auth/cli generate --config auth.config.ts -y
|
|
2059
2098
|
export {}
|
|
2060
|
-
`)}async function
|
|
2061
|
-
`),"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
|
|
|
@@ -322,6 +341,9 @@ COPY --from=deps /app/node_modules ./node_modules
|
|
|
322
341
|
COPY . .
|
|
323
342
|
ENV NODE_ENV=production
|
|
324
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
|
|
325
347
|
RUN pnpm build
|
|
326
348
|
|
|
327
349
|
# --- Stage 3: Production runner ---
|
|
@@ -709,9 +731,10 @@ export async function getToolkitApp(): Promise<ToolkitApp> {
|
|
|
709
731
|
`),await e(o(a,"lib/auth.ts"),`import { getToolkitApp } from './app'
|
|
710
732
|
import { getAuth } from '@murumets-ee/auth'
|
|
711
733
|
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
734
|
+
export async function getAuthInstance() {
|
|
735
|
+
await getToolkitApp()
|
|
736
|
+
return getAuth()
|
|
737
|
+
}
|
|
715
738
|
`),await e(o(a,"lib/auth-client.ts"),`import { createClient } from '@murumets-ee/auth/client'
|
|
716
739
|
|
|
717
740
|
export const authClient = createClient()
|
|
@@ -1140,9 +1163,25 @@ export default async function HomePage() {
|
|
|
1140
1163
|
)
|
|
1141
1164
|
}
|
|
1142
1165
|
`),await e(o(a,"app/api/auth/[...all]/route.ts"),`import { toNextJsHandler } from 'better-auth/next-js'
|
|
1143
|
-
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
|
+
}
|
|
1144
1177
|
|
|
1145
|
-
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
|
+
}
|
|
1146
1185
|
`),await e(o(a,"app/[locale]/auth/layout.tsx"),`import { AuthProviders } from './providers'
|
|
1147
1186
|
import type { ReactNode } from 'react'
|
|
1148
1187
|
|
|
@@ -1834,13 +1873,13 @@ export default async function HomePage() {
|
|
|
1834
1873
|
</div>
|
|
1835
1874
|
)
|
|
1836
1875
|
}
|
|
1837
|
-
`)}import{join as b}from"path";async function
|
|
1876
|
+
`)}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'
|
|
1838
1877
|
execSync('npx @murumets-ee/cli generate', { stdio: 'inherit', cwd: import.meta.dirname + '/..' })
|
|
1839
1878
|
`),await e(b(t,"scripts/migrate.ts"),`import { execSync } from 'node:child_process'
|
|
1840
1879
|
execSync('npx @murumets-ee/cli migrate', { stdio: 'inherit', cwd: import.meta.dirname + '/..' })
|
|
1841
1880
|
`),await e(b(t,"scripts/reset-db.ts"),`import { execSync } from 'node:child_process'
|
|
1842
1881
|
execSync('npx @murumets-ee/cli reset --force', { stdio: 'inherit', cwd: import.meta.dirname + '/..' })
|
|
1843
|
-
`)}import{join as f}from"path";async function
|
|
1882
|
+
`)}import{join as f}from"path";async function z(t,n){let{name:r}=n;await e(f(t,"app/globals.css"),`@import "tailwindcss";
|
|
1844
1883
|
@source "../node_modules/@murumets-ee/auth-ui/dist";
|
|
1845
1884
|
|
|
1846
1885
|
@custom-variant dark (&:where(.dark, .dark *));
|
|
@@ -2056,4 +2095,4 @@ export const auth = betterAuth({
|
|
|
2056
2095
|
`),await e(d(t,"generated/auth-schema.ts"),`// This file is generated by better-auth CLI.
|
|
2057
2096
|
// Run: npx @better-auth/cli generate --config auth.config.ts -y
|
|
2058
2097
|
export {}
|
|
2059
|
-
`)}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};
|