create-einja-app 0.1.1
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/README.md +307 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +1041 -0
- package/dist/cli.js.map +1 -0
- package/package.json +62 -0
- package/templates/turborepo-pandacss/.biomeignore +15 -0
- package/templates/turborepo-pandacss/.claude/hooks/einja/biome-format.sh +49 -0
- package/templates/turborepo-pandacss/.claude/hooks/einja/design-doc-check.sh +61 -0
- package/templates/turborepo-pandacss/.claude/hooks/einja/detect-secrets.sh +62 -0
- package/templates/turborepo-pandacss/.claude/hooks/einja/large-file-warning.sh +42 -0
- package/templates/turborepo-pandacss/.claude/hooks/einja/playwright-resize.sh +36 -0
- package/templates/turborepo-pandacss/.claude/hooks/einja/typecheck.sh +37 -0
- package/templates/turborepo-pandacss/.claude/hooks/einja/unset-volta-recursion.sh +32 -0
- package/templates/turborepo-pandacss/.claude/hooks/einja/validate-git-commit.sh +239 -0
- package/templates/turborepo-pandacss/.claude/hooks/einja/warn-index-ts.sh +34 -0
- package/templates/turborepo-pandacss/.claude/hooks/einja/warn-relative-import.sh +48 -0
- package/templates/turborepo-pandacss/.claude/settings.json +174 -0
- package/templates/turborepo-pandacss/.claude/skills/create-einja-app-release/SKILL.md +186 -0
- package/templates/turborepo-pandacss/.claude/skills/dev-cli-release/SKILL.md +173 -0
- package/templates/turborepo-pandacss/.cursor/commands/spec-create.md +227 -0
- package/templates/turborepo-pandacss/.cursor/commands/start-dev.md +98 -0
- package/templates/turborepo-pandacss/.cursor/commands/task-exec.md +287 -0
- package/templates/turborepo-pandacss/.cursor/commands/task-vibe-kanban-loop.md +532 -0
- package/templates/turborepo-pandacss/.cursor/commands/update-docs-by-task-specs.md +448 -0
- package/templates/turborepo-pandacss/.cursor/mcp.json +45 -0
- package/templates/turborepo-pandacss/.cursor/rules/api-rules.mdc +171 -0
- package/templates/turborepo-pandacss/.cursor/rules/api-test-rules.mdc +181 -0
- package/templates/turborepo-pandacss/.cursor/rules/base-code.mdc +70 -0
- package/templates/turborepo-pandacss/.cursor/rules/base-commit-rules.mdc +174 -0
- package/templates/turborepo-pandacss/.cursor/rules/base-design.mdc +12 -0
- package/templates/turborepo-pandacss/.cursor/rules/base-rules.mdc +231 -0
- package/templates/turborepo-pandacss/.cursor/rules/error-handling-rules.mdc +188 -0
- package/templates/turborepo-pandacss/.cursor/rules/refactor-rules.mdc +93 -0
- package/templates/turborepo-pandacss/.dockerignore +126 -0
- package/templates/turborepo-pandacss/.einja-sync.json +35 -0
- package/templates/turborepo-pandacss/.env.ci +25 -0
- package/templates/turborepo-pandacss/.env.example +35 -0
- package/templates/turborepo-pandacss/.env.personal.example +27 -0
- package/templates/turborepo-pandacss/.envrc +4 -0
- package/templates/turborepo-pandacss/.gitattributes +5 -0
- package/templates/turborepo-pandacss/.husky/pre-commit +1 -0
- package/templates/turborepo-pandacss/.lintstagedrc.js +24 -0
- package/templates/turborepo-pandacss/.mcp.json +45 -0
- package/templates/turborepo-pandacss/.node-version +1 -0
- package/templates/turborepo-pandacss/.templateignore +60 -0
- package/templates/turborepo-pandacss/.vscode/extensions.json +3 -0
- package/templates/turborepo-pandacss/CLAUDE.md +415 -0
- package/templates/turborepo-pandacss/README.md +322 -0
- package/templates/turborepo-pandacss/apps/web/middleware.ts +28 -0
- package/templates/turborepo-pandacss/apps/web/next.config.ts +10 -0
- package/templates/turborepo-pandacss/apps/web/package.json +80 -0
- package/templates/turborepo-pandacss/apps/web/panda.config.ts +114 -0
- package/templates/turborepo-pandacss/apps/web/postcss.config.cjs +6 -0
- package/templates/turborepo-pandacss/apps/web/public/file.svg +1 -0
- package/templates/turborepo-pandacss/apps/web/public/globe.svg +1 -0
- package/templates/turborepo-pandacss/apps/web/public/next.svg +1 -0
- package/templates/turborepo-pandacss/apps/web/public/vercel.svg +1 -0
- package/templates/turborepo-pandacss/apps/web/public/window.svg +1 -0
- package/templates/turborepo-pandacss/apps/web/src/app/(authenticated)/dashboard/page.tsx +79 -0
- package/templates/turborepo-pandacss/apps/web/src/app/(authenticated)/data/_components/UserTable.tsx +203 -0
- package/templates/turborepo-pandacss/apps/web/src/app/(authenticated)/data/page.tsx +57 -0
- package/templates/turborepo-pandacss/apps/web/src/app/(authenticated)/layout-client.tsx +31 -0
- package/templates/turborepo-pandacss/apps/web/src/app/(authenticated)/layout.tsx +17 -0
- package/templates/turborepo-pandacss/apps/web/src/app/(authenticated)/profile/page.tsx +59 -0
- package/templates/turborepo-pandacss/apps/web/src/app/api/auth/[...nextauth]/route.ts +3 -0
- package/templates/turborepo-pandacss/apps/web/src/app/api/auth/signup/route.ts +70 -0
- package/templates/turborepo-pandacss/apps/web/src/app/error.tsx +106 -0
- package/templates/turborepo-pandacss/apps/web/src/app/favicon.ico +0 -0
- package/templates/turborepo-pandacss/apps/web/src/app/global-error.tsx +110 -0
- package/templates/turborepo-pandacss/apps/web/src/app/globals.css +121 -0
- package/templates/turborepo-pandacss/apps/web/src/app/layout.tsx +28 -0
- package/templates/turborepo-pandacss/apps/web/src/app/not-found.tsx +54 -0
- package/templates/turborepo-pandacss/apps/web/src/app/page.module.css +165 -0
- package/templates/turborepo-pandacss/apps/web/src/app/page.test.tsx +52 -0
- package/templates/turborepo-pandacss/apps/web/src/app/page.tsx +284 -0
- package/templates/turborepo-pandacss/apps/web/src/app/signin/page.tsx +296 -0
- package/templates/turborepo-pandacss/apps/web/src/app/signup/page.tsx +395 -0
- package/templates/turborepo-pandacss/apps/web/src/application/use-cases/UserUseCases.test.ts +229 -0
- package/templates/turborepo-pandacss/apps/web/src/application/use-cases/UserUseCases.ts +115 -0
- package/templates/turborepo-pandacss/apps/web/src/components/auth/login-button.tsx +35 -0
- package/templates/turborepo-pandacss/apps/web/src/components/auth/logout-button.tsx +24 -0
- package/templates/turborepo-pandacss/apps/web/src/components/auth/user-avatar.test.tsx +68 -0
- package/templates/turborepo-pandacss/apps/web/src/components/auth/user-avatar.tsx +43 -0
- package/templates/turborepo-pandacss/apps/web/src/components/dashboard/dashboard-stats.tsx +128 -0
- package/templates/turborepo-pandacss/apps/web/src/components/providers/query-provider.tsx +30 -0
- package/templates/turborepo-pandacss/apps/web/src/components/providers/session-provider.tsx +12 -0
- package/templates/turborepo-pandacss/apps/web/src/components/shared/Sidebar.tsx +175 -0
- package/templates/turborepo-pandacss/apps/web/src/components/shared/header.tsx +166 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/accordion.tsx +64 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/alert-dialog.tsx +135 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/alert.tsx +60 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/aspect-ratio.tsx +9 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/avatar.tsx +41 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/badge.tsx +39 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/breadcrumb.tsx +101 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/button.tsx +56 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/card.tsx +75 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/checkbox.tsx +29 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/data-table.tsx +189 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/dialog-hook.tsx +210 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/dialog.tsx +129 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/drawer.tsx +124 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/dropdown-menu.tsx +228 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/form.tsx +152 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/hover-card.tsx +38 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/input.tsx +21 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/label.tsx +21 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/pagination.tsx +105 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/popover.tsx +42 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/progress.tsx +28 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/select.tsx +170 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/separator.tsx +28 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/skeleton.tsx +13 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/sonner.tsx +25 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/table.tsx +92 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/tabs.tsx +54 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/textarea.tsx +18 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/tooltip.tsx +57 -0
- package/templates/turborepo-pandacss/apps/web/src/components/ui/typography.tsx +158 -0
- package/templates/turborepo-pandacss/apps/web/src/lib/auth/guard.ts +36 -0
- package/templates/turborepo-pandacss/apps/web/src/lib/auth/index.ts +22 -0
- package/templates/turborepo-pandacss/apps/web/src/lib/prisma.ts +3 -0
- package/templates/turborepo-pandacss/apps/web/src/lib/utils.ts +6 -0
- package/templates/turborepo-pandacss/apps/web/test/globals.d.ts +1 -0
- package/templates/turborepo-pandacss/apps/web/test/matchers.d.ts +1 -0
- package/templates/turborepo-pandacss/apps/web/test/setup.ts +22 -0
- package/templates/turborepo-pandacss/apps/web/tsconfig.json +37 -0
- package/templates/turborepo-pandacss/apps/web/vitest.config.ts +20 -0
- package/templates/turborepo-pandacss/apps/web/vitest.d.ts +2 -0
- package/templates/turborepo-pandacss/biome.json +60 -0
- package/templates/turborepo-pandacss/components.json +21 -0
- package/templates/turborepo-pandacss/docker-compose.yml +27 -0
- package/templates/turborepo-pandacss/middleware.ts +32 -0
- package/templates/turborepo-pandacss/next.config.ts +10 -0
- package/templates/turborepo-pandacss/package-lock.json +9346 -0
- package/templates/turborepo-pandacss/package.json +64 -0
- package/templates/turborepo-pandacss/packages/config/package.json +41 -0
- package/templates/turborepo-pandacss/packages/config/panda.config.ts +114 -0
- package/templates/turborepo-pandacss/packages/config/src/index.ts +24 -0
- package/templates/turborepo-pandacss/packages/config/src/worktree-config-loader.ts +129 -0
- package/templates/turborepo-pandacss/packages/config/src/worktree-config.ts +75 -0
- package/templates/turborepo-pandacss/packages/config/tsconfig.build.json +19 -0
- package/templates/turborepo-pandacss/packages/config/tsconfig.json +24 -0
- package/templates/turborepo-pandacss/packages/config/typescript/base.json +19 -0
- package/templates/turborepo-pandacss/packages/front-core/package.json +24 -0
- package/templates/turborepo-pandacss/packages/front-core/src/auth/config.ts +84 -0
- package/templates/turborepo-pandacss/packages/front-core/src/auth/index.ts +5 -0
- package/templates/turborepo-pandacss/packages/front-core/src/auth/types/next-auth.d.ts +20 -0
- package/templates/turborepo-pandacss/packages/front-core/src/auth/utils.ts +29 -0
- package/templates/turborepo-pandacss/packages/front-core/src/context/index.ts +2 -0
- package/templates/turborepo-pandacss/packages/front-core/src/hooks/index.ts +2 -0
- package/templates/turborepo-pandacss/packages/front-core/src/index.ts +4 -0
- package/templates/turborepo-pandacss/packages/front-core/src/utils/index.ts +2 -0
- package/templates/turborepo-pandacss/packages/front-core/tsconfig.json +14 -0
- package/templates/turborepo-pandacss/packages/server-core/package.json +32 -0
- package/templates/turborepo-pandacss/packages/server-core/prisma/schema.prisma +102 -0
- package/templates/turborepo-pandacss/packages/server-core/prisma/seed.ts +67 -0
- package/templates/turborepo-pandacss/packages/server-core/prisma.config.ts +8 -0
- package/templates/turborepo-pandacss/packages/server-core/src/__generated__/fabbrica/index.d.ts +270 -0
- package/templates/turborepo-pandacss/packages/server-core/src/__generated__/fabbrica/index.js +484 -0
- package/templates/turborepo-pandacss/packages/server-core/src/core/result.test.ts +78 -0
- package/templates/turborepo-pandacss/packages/server-core/src/core/result.ts +53 -0
- package/templates/turborepo-pandacss/packages/server-core/src/domain/.gitkeep +0 -0
- package/templates/turborepo-pandacss/packages/server-core/src/domain/entities/User.test.ts +232 -0
- package/templates/turborepo-pandacss/packages/server-core/src/domain/entities/User.ts +105 -0
- package/templates/turborepo-pandacss/packages/server-core/src/domain/repository-interfaces/IUserRepository.ts +101 -0
- package/templates/turborepo-pandacss/packages/server-core/src/infrastructure/database/client.ts +15 -0
- package/templates/turborepo-pandacss/packages/server-core/src/infrastructure/database/mappers/UserMapper.test.ts +278 -0
- package/templates/turborepo-pandacss/packages/server-core/src/infrastructure/database/mappers/UserMapper.ts +103 -0
- package/templates/turborepo-pandacss/packages/server-core/src/infrastructure/database/repositories/UserRepository.test.ts +317 -0
- package/templates/turborepo-pandacss/packages/server-core/src/infrastructure/database/repositories/UserRepository.ts +169 -0
- package/templates/turborepo-pandacss/packages/server-core/src/testing/factories/index.ts +22 -0
- package/templates/turborepo-pandacss/packages/server-core/src/testing/factories/user.factory.ts +123 -0
- package/templates/turborepo-pandacss/packages/server-core/src/testing/fixtures/users.ts +92 -0
- package/templates/turborepo-pandacss/packages/server-core/src/testing/helpers/date.ts +49 -0
- package/templates/turborepo-pandacss/packages/server-core/src/testing/helpers/password.ts +50 -0
- package/templates/turborepo-pandacss/packages/server-core/src/testing/index.ts +26 -0
- package/templates/turborepo-pandacss/packages/server-core/tsconfig.json +14 -0
- package/templates/turborepo-pandacss/packages/server-core/vitest.config.ts +15 -0
- package/templates/turborepo-pandacss/packages/ui/package.json +37 -0
- package/templates/turborepo-pandacss/packages/ui/src/accordion.tsx +66 -0
- package/templates/turborepo-pandacss/packages/ui/src/alert-dialog.tsx +157 -0
- package/templates/turborepo-pandacss/packages/ui/src/alert.tsx +66 -0
- package/templates/turborepo-pandacss/packages/ui/src/aspect-ratio.tsx +11 -0
- package/templates/turborepo-pandacss/packages/ui/src/avatar.tsx +53 -0
- package/templates/turborepo-pandacss/packages/ui/src/badge.tsx +46 -0
- package/templates/turborepo-pandacss/packages/ui/src/breadcrumb.tsx +108 -0
- package/templates/turborepo-pandacss/packages/ui/src/button.tsx +59 -0
- package/templates/turborepo-pandacss/packages/ui/src/card.tsx +92 -0
- package/templates/turborepo-pandacss/packages/ui/src/checkbox.tsx +32 -0
- package/templates/turborepo-pandacss/packages/ui/src/data-table.tsx +216 -0
- package/templates/turborepo-pandacss/packages/ui/src/dialog-hook.tsx +226 -0
- package/templates/turborepo-pandacss/packages/ui/src/dialog.tsx +143 -0
- package/templates/turborepo-pandacss/packages/ui/src/drawer.tsx +135 -0
- package/templates/turborepo-pandacss/packages/ui/src/dropdown-menu.tsx +257 -0
- package/templates/turborepo-pandacss/packages/ui/src/form.tsx +168 -0
- package/templates/turborepo-pandacss/packages/ui/src/hover-card.tsx +44 -0
- package/templates/turborepo-pandacss/packages/ui/src/input.tsx +21 -0
- package/templates/turborepo-pandacss/packages/ui/src/label.tsx +24 -0
- package/templates/turborepo-pandacss/packages/ui/src/lib/utils.ts +6 -0
- package/templates/turborepo-pandacss/packages/ui/src/pagination.tsx +126 -0
- package/templates/turborepo-pandacss/packages/ui/src/popover.tsx +48 -0
- package/templates/turborepo-pandacss/packages/ui/src/progress.tsx +31 -0
- package/templates/turborepo-pandacss/packages/ui/src/select.tsx +185 -0
- package/templates/turborepo-pandacss/packages/ui/src/separator.tsx +28 -0
- package/templates/turborepo-pandacss/packages/ui/src/skeleton.tsx +13 -0
- package/templates/turborepo-pandacss/packages/ui/src/sonner.tsx +25 -0
- package/templates/turborepo-pandacss/packages/ui/src/table.tsx +116 -0
- package/templates/turborepo-pandacss/packages/ui/src/tabs.tsx +66 -0
- package/templates/turborepo-pandacss/packages/ui/src/textarea.tsx +18 -0
- package/templates/turborepo-pandacss/packages/ui/src/tooltip.tsx +61 -0
- package/templates/turborepo-pandacss/packages/ui/src/typography.tsx +187 -0
- package/templates/turborepo-pandacss/packages/ui/tsconfig.json +20 -0
- package/templates/turborepo-pandacss/panda.config.ts +114 -0
- package/templates/turborepo-pandacss/pnpm-lock.yaml +9032 -0
- package/templates/turborepo-pandacss/pnpm-workspace.yaml +11 -0
- package/templates/turborepo-pandacss/postcss.config.cjs +6 -0
- package/templates/turborepo-pandacss/prisma/schema.prisma +82 -0
- package/templates/turborepo-pandacss/public/file.svg +1 -0
- package/templates/turborepo-pandacss/public/globe.svg +1 -0
- package/templates/turborepo-pandacss/public/next.svg +1 -0
- package/templates/turborepo-pandacss/public/vercel.svg +1 -0
- package/templates/turborepo-pandacss/public/window.svg +1 -0
- package/templates/turborepo-pandacss/scripts/cli-template-update.ts +387 -0
- package/templates/turborepo-pandacss/scripts/env-show.ts +129 -0
- package/templates/turborepo-pandacss/scripts/env.ts +555 -0
- package/templates/turborepo-pandacss/scripts/init.sh +92 -0
- package/templates/turborepo-pandacss/scripts/setup-dev.ts +640 -0
- package/templates/turborepo-pandacss/scripts/template-update.ts +277 -0
- package/templates/turborepo-pandacss/scripts/worktree/dev.ts +872 -0
- package/templates/turborepo-pandacss/test/globals.d.ts +1 -0
- package/templates/turborepo-pandacss/test/setup.ts +22 -0
- package/templates/turborepo-pandacss/tsconfig.json +46 -0
- package/templates/turborepo-pandacss/turbo.json +57 -0
- package/templates/turborepo-pandacss/vitest.config.ts +20 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{projectName}}",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"packageManager": "pnpm@10.14.0",
|
|
6
|
+
"workspaces": [
|
|
7
|
+
"apps/*",
|
|
8
|
+
"packages/*"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"prepare": "husky",
|
|
12
|
+
"dev": "tsx scripts/worktree/dev.ts",
|
|
13
|
+
"dev:bg": "tsx scripts/worktree/dev.ts --background",
|
|
14
|
+
"dev:stop": "tsx scripts/worktree/dev.ts --stop",
|
|
15
|
+
"dev:status": "tsx scripts/worktree/dev.ts --status",
|
|
16
|
+
"dev:logs": "tail -f log/dev.log",
|
|
17
|
+
"dev:skip-setup": "turbo run dev",
|
|
18
|
+
"build": "dotenvx run -f .env.production -- turbo run build",
|
|
19
|
+
"build:staging": "dotenvx run -f .env.staging -- turbo run build",
|
|
20
|
+
"build:dev": "dotenvx run -f .env.development -- turbo run build",
|
|
21
|
+
"build:local": "turbo run build",
|
|
22
|
+
"start": "turbo run start",
|
|
23
|
+
"lint": "turbo run lint",
|
|
24
|
+
"lint:fix": "turbo run lint:fix",
|
|
25
|
+
"format": "turbo run format",
|
|
26
|
+
"format:fix": "turbo run format:fix",
|
|
27
|
+
"typecheck": "turbo run typecheck",
|
|
28
|
+
"test": "turbo run test",
|
|
29
|
+
"test:watch": "turbo run test:watch",
|
|
30
|
+
"test:ui": "turbo run test:ui",
|
|
31
|
+
"test:coverage": "turbo run test:coverage",
|
|
32
|
+
"prepush": "pnpm prepush:lint && pnpm prepush:typecheck && pnpm prepush:test",
|
|
33
|
+
"prepush:lint": "lint-staged",
|
|
34
|
+
"prepush:typecheck": "turbo run typecheck",
|
|
35
|
+
"prepush:test": "turbo run test",
|
|
36
|
+
"db:generate": "turbo run db:generate",
|
|
37
|
+
"db:push": "turbo run db:push",
|
|
38
|
+
"db:migrate": "turbo run db:migrate",
|
|
39
|
+
"db:studio": "turbo run db:studio",
|
|
40
|
+
"dev:setup": "tsx scripts/setup-dev.ts",
|
|
41
|
+
"env:update": "tsx scripts/env.ts",
|
|
42
|
+
"env:prepare": "tsx scripts/worktree/dev.ts --setup-only",
|
|
43
|
+
"cli-template:update": "tsx scripts/cli-template-update.ts",
|
|
44
|
+
"template:update": "tsx scripts/template-update.ts",
|
|
45
|
+
"dotenvx": "dotenvx",
|
|
46
|
+
"env:encrypt": "dotenvx encrypt",
|
|
47
|
+
"env:show": "tsx scripts/env-show.ts",
|
|
48
|
+
"task:loop": "einja task:loop"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@clack/prompts": "^0.11.0",
|
|
52
|
+
"@dotenvx/dotenvx": "^1.51.4",
|
|
53
|
+
"@einja/dev-cli": "workspace:*",
|
|
54
|
+
"@types/node": "^25.0.3",
|
|
55
|
+
"husky": "^9.1.7",
|
|
56
|
+
"lint-staged": "^16.1.0",
|
|
57
|
+
"tsx": "^4.7.0",
|
|
58
|
+
"turbo": "^2.5.8"
|
|
59
|
+
},
|
|
60
|
+
"volta": {
|
|
61
|
+
"node": "22.16.0",
|
|
62
|
+
"pnpm": "10.14.0"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@repo/config",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
"./biome": "./biome.json",
|
|
10
|
+
"./typescript": "./tsconfig.json",
|
|
11
|
+
"./panda": "./panda.config.ts",
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./worktree": {
|
|
18
|
+
"types": "./dist/worktree-config.d.ts",
|
|
19
|
+
"import": "./dist/worktree-config.js",
|
|
20
|
+
"default": "./dist/worktree-config.js"
|
|
21
|
+
},
|
|
22
|
+
"./worktree-loader": {
|
|
23
|
+
"types": "./dist/worktree-config-loader.d.ts",
|
|
24
|
+
"import": "./dist/worktree-config-loader.js",
|
|
25
|
+
"default": "./dist/worktree-config-loader.js"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsc -p tsconfig.build.json",
|
|
30
|
+
"typecheck": "tsc -p tsconfig.build.json --noEmit"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"zod": "^3.24.2"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@biomejs/biome": "1.9.4",
|
|
37
|
+
"@pandacss/dev": "^0.53.7",
|
|
38
|
+
"@types/node": "^22",
|
|
39
|
+
"typescript": "^5"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { defineConfig } from "@pandacss/dev";
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
// TailwindCSSとの共存のためpreflightを無効化
|
|
5
|
+
preflight: false,
|
|
6
|
+
|
|
7
|
+
// Where to look for your css declarations
|
|
8
|
+
include: ["./src/**/*.{js,jsx,ts,tsx}", "./pages/**/*.{js,jsx,ts,tsx}"],
|
|
9
|
+
|
|
10
|
+
// Files to exclude
|
|
11
|
+
exclude: [],
|
|
12
|
+
|
|
13
|
+
// Panda CSSクラスにプレフィックスを付けてTailwindと区別
|
|
14
|
+
prefix: "panda",
|
|
15
|
+
|
|
16
|
+
// Useful for theme customization
|
|
17
|
+
theme: {
|
|
18
|
+
extend: {
|
|
19
|
+
breakpoints: {
|
|
20
|
+
sm: "640px",
|
|
21
|
+
md: "768px",
|
|
22
|
+
lg: "1024px",
|
|
23
|
+
xl: "1280px",
|
|
24
|
+
"2xl": "1440px",
|
|
25
|
+
},
|
|
26
|
+
tokens: {
|
|
27
|
+
colors: {
|
|
28
|
+
// shadcnのカラーシステムと互換性を保つ
|
|
29
|
+
border: { value: "hsl(214.3 31.8% 91.4%)" },
|
|
30
|
+
input: { value: "hsl(214.3 31.8% 91.4%)" },
|
|
31
|
+
ring: { value: "hsl(222.2 84% 4.9%)" },
|
|
32
|
+
background: { value: "hsl(0 0% 100%)" },
|
|
33
|
+
foreground: { value: "hsl(222.2 84% 4.9%)" },
|
|
34
|
+
primary: {
|
|
35
|
+
DEFAULT: { value: "hsl(222.2 47.4% 11.2%)" },
|
|
36
|
+
foreground: { value: "hsl(210 40% 98%)" },
|
|
37
|
+
},
|
|
38
|
+
secondary: {
|
|
39
|
+
DEFAULT: { value: "hsl(210 40% 96%)" },
|
|
40
|
+
foreground: { value: "hsl(222.2 84% 4.9%)" },
|
|
41
|
+
},
|
|
42
|
+
destructive: {
|
|
43
|
+
DEFAULT: { value: "hsl(0 62.8% 30.6%)" },
|
|
44
|
+
foreground: { value: "hsl(210 40% 98%)" },
|
|
45
|
+
},
|
|
46
|
+
muted: {
|
|
47
|
+
DEFAULT: { value: "hsl(210 40% 96%)" },
|
|
48
|
+
foreground: { value: "hsl(215.4 16.3% 46.9%)" },
|
|
49
|
+
},
|
|
50
|
+
accent: {
|
|
51
|
+
DEFAULT: { value: "hsl(210 40% 96%)" },
|
|
52
|
+
foreground: { value: "hsl(222.2 84% 4.9%)" },
|
|
53
|
+
},
|
|
54
|
+
popover: {
|
|
55
|
+
DEFAULT: { value: "hsl(0 0% 100%)" },
|
|
56
|
+
foreground: { value: "hsl(222.2 84% 4.9%)" },
|
|
57
|
+
},
|
|
58
|
+
card: {
|
|
59
|
+
DEFAULT: { value: "hsl(0 0% 100%)" },
|
|
60
|
+
foreground: { value: "hsl(222.2 84% 4.9%)" },
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
recipes: {
|
|
65
|
+
// 独自のPanda CSSレシピを定義
|
|
66
|
+
pandaButton: {
|
|
67
|
+
className: "panda-button",
|
|
68
|
+
base: {
|
|
69
|
+
display: "inline-flex",
|
|
70
|
+
alignItems: "center",
|
|
71
|
+
justifyContent: "center",
|
|
72
|
+
borderRadius: "md",
|
|
73
|
+
fontSize: "sm",
|
|
74
|
+
fontWeight: "medium",
|
|
75
|
+
transition: "all 0.2s",
|
|
76
|
+
cursor: "pointer",
|
|
77
|
+
_disabled: {
|
|
78
|
+
pointerEvents: "none",
|
|
79
|
+
opacity: 0.5,
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
variants: {
|
|
83
|
+
variant: {
|
|
84
|
+
primary: {
|
|
85
|
+
bg: "primary",
|
|
86
|
+
color: "primary.foreground",
|
|
87
|
+
_hover: { opacity: 0.9 },
|
|
88
|
+
},
|
|
89
|
+
secondary: {
|
|
90
|
+
bg: "secondary",
|
|
91
|
+
color: "secondary.foreground",
|
|
92
|
+
_hover: { opacity: 0.8 },
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
size: {
|
|
96
|
+
sm: { h: "8", px: "3" },
|
|
97
|
+
md: { h: "10", px: "4" },
|
|
98
|
+
lg: { h: "12", px: "6" },
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
defaultVariants: {
|
|
102
|
+
variant: "primary",
|
|
103
|
+
size: "md",
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
// The output directory for your css system
|
|
111
|
+
outdir: "styled-system",
|
|
112
|
+
|
|
113
|
+
jsxFramework: "react",
|
|
114
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @repo/config - 共通設定パッケージ
|
|
3
|
+
*
|
|
4
|
+
* Worktree設定スキーマとローダーを提供。
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// Worktree設定スキーマと型
|
|
8
|
+
export {
|
|
9
|
+
worktreeConfigSchema,
|
|
10
|
+
appConfigSchema,
|
|
11
|
+
postgresConfigSchema,
|
|
12
|
+
defaultWorktreeConfig,
|
|
13
|
+
type WorktreeConfig,
|
|
14
|
+
type AppConfig,
|
|
15
|
+
type PostgresConfig,
|
|
16
|
+
} from "./worktree-config.js";
|
|
17
|
+
|
|
18
|
+
// Worktree設定ローダー
|
|
19
|
+
export {
|
|
20
|
+
loadWorktreeConfig,
|
|
21
|
+
generateWorktreeConfig,
|
|
22
|
+
hasWorktreeConfig,
|
|
23
|
+
findProjectRoot,
|
|
24
|
+
} from "./worktree-config-loader.js";
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Worktree設定ローダー
|
|
3
|
+
*
|
|
4
|
+
* worktree.config.jsonファイルの読み込み・生成を提供する。
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import fs from "node:fs";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
import {
|
|
10
|
+
type WorktreeConfig,
|
|
11
|
+
defaultWorktreeConfig,
|
|
12
|
+
worktreeConfigSchema,
|
|
13
|
+
} from "./worktree-config.js";
|
|
14
|
+
|
|
15
|
+
/** 設定ファイル名 */
|
|
16
|
+
const CONFIG_FILENAME = "worktree.config.json";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* プロジェクトルートを探索
|
|
20
|
+
*
|
|
21
|
+
* package.jsonが存在するディレクトリをプロジェクトルートとして検出。
|
|
22
|
+
*
|
|
23
|
+
* @param startDir - 探索開始ディレクトリ
|
|
24
|
+
* @returns プロジェクトルートのパス、見つからない場合はnull
|
|
25
|
+
*/
|
|
26
|
+
export function findProjectRoot(startDir: string = process.cwd()): string | null {
|
|
27
|
+
let currentDir = startDir;
|
|
28
|
+
|
|
29
|
+
while (currentDir !== path.dirname(currentDir)) {
|
|
30
|
+
if (fs.existsSync(path.join(currentDir, "package.json"))) {
|
|
31
|
+
return currentDir;
|
|
32
|
+
}
|
|
33
|
+
currentDir = path.dirname(currentDir);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Worktree設定を読み込む
|
|
41
|
+
*
|
|
42
|
+
* worktree.config.jsonが存在しない場合はデフォルト値を返す。
|
|
43
|
+
* 設定ファイルが存在する場合はバリデーション後に返す。
|
|
44
|
+
*
|
|
45
|
+
* @param projectRoot - プロジェクトルートのパス(省略時は自動検出)
|
|
46
|
+
* @returns Worktree設定
|
|
47
|
+
* @throws {Error} 設定ファイルのパースやバリデーションに失敗した場合
|
|
48
|
+
*/
|
|
49
|
+
export function loadWorktreeConfig(projectRoot?: string): WorktreeConfig {
|
|
50
|
+
const root = projectRoot ?? findProjectRoot();
|
|
51
|
+
|
|
52
|
+
if (!root) {
|
|
53
|
+
console.warn(
|
|
54
|
+
"プロジェクトルートが見つかりません。デフォルト設定を使用します。",
|
|
55
|
+
);
|
|
56
|
+
return defaultWorktreeConfig;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const configPath = path.join(root, CONFIG_FILENAME);
|
|
60
|
+
|
|
61
|
+
if (!fs.existsSync(configPath)) {
|
|
62
|
+
// 設定ファイルが存在しない場合はデフォルト値を返す
|
|
63
|
+
return defaultWorktreeConfig;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
try {
|
|
67
|
+
const configContent = fs.readFileSync(configPath, "utf-8");
|
|
68
|
+
const rawConfig = JSON.parse(configContent);
|
|
69
|
+
|
|
70
|
+
// Zodでバリデーション(デフォルト値も適用される)
|
|
71
|
+
const result = worktreeConfigSchema.safeParse(rawConfig);
|
|
72
|
+
|
|
73
|
+
if (!result.success) {
|
|
74
|
+
console.error("Worktree設定のバリデーションエラー:");
|
|
75
|
+
for (const issue of result.error.issues) {
|
|
76
|
+
console.error(` - ${issue.path.join(".")}: ${issue.message}`);
|
|
77
|
+
}
|
|
78
|
+
throw new Error("Worktree設定のバリデーションに失敗しました");
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return result.data;
|
|
82
|
+
} catch (error) {
|
|
83
|
+
if (error instanceof SyntaxError) {
|
|
84
|
+
throw new Error(`${CONFIG_FILENAME}のJSONパースに失敗しました: ${error.message}`);
|
|
85
|
+
}
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Worktree設定ファイルを生成
|
|
92
|
+
*
|
|
93
|
+
* @param projectRoot - プロジェクトルートのパス
|
|
94
|
+
* @param config - 書き込む設定(省略時はデフォルト設定)
|
|
95
|
+
*/
|
|
96
|
+
export function generateWorktreeConfig(
|
|
97
|
+
projectRoot: string,
|
|
98
|
+
config: Partial<WorktreeConfig> = {},
|
|
99
|
+
): void {
|
|
100
|
+
const configPath = path.join(projectRoot, CONFIG_FILENAME);
|
|
101
|
+
|
|
102
|
+
// デフォルト値とマージしてバリデーション
|
|
103
|
+
const result = worktreeConfigSchema.safeParse(config);
|
|
104
|
+
|
|
105
|
+
if (!result.success) {
|
|
106
|
+
throw new Error(
|
|
107
|
+
`設定のバリデーションに失敗しました: ${result.error.message}`,
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const content = JSON.stringify(result.data, null, "\t");
|
|
112
|
+
fs.writeFileSync(configPath, `${content}\n`, "utf-8");
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* 設定ファイルが存在するか確認
|
|
117
|
+
*
|
|
118
|
+
* @param projectRoot - プロジェクトルートのパス(省略時は自動検出)
|
|
119
|
+
* @returns 設定ファイルが存在する場合true
|
|
120
|
+
*/
|
|
121
|
+
export function hasWorktreeConfig(projectRoot?: string): boolean {
|
|
122
|
+
const root = projectRoot ?? findProjectRoot();
|
|
123
|
+
|
|
124
|
+
if (!root) {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return fs.existsSync(path.join(root, CONFIG_FILENAME));
|
|
129
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Worktree設定のスキーマ定義
|
|
3
|
+
*
|
|
4
|
+
* worktree.config.jsonファイルの型安全な読み込みを提供する。
|
|
5
|
+
* create-einja-appやpnpm devで使用される設定を定義。
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* アプリケーション設定スキーマ
|
|
12
|
+
*
|
|
13
|
+
* 各アプリケーションのポート範囲を定義。
|
|
14
|
+
* 新規アプリは配列に追加するだけで対応可能。
|
|
15
|
+
*/
|
|
16
|
+
export const appConfigSchema = z.object({
|
|
17
|
+
/** アプリケーションID(例: "web", "admin", "api") */
|
|
18
|
+
id: z
|
|
19
|
+
.string()
|
|
20
|
+
.min(1)
|
|
21
|
+
.regex(/^[a-z][a-z0-9_]*$/, {
|
|
22
|
+
message: "IDは小文字英字で始まり、小文字英数字とアンダースコアのみ使用可能",
|
|
23
|
+
}),
|
|
24
|
+
/** ポート範囲の開始値(1024-65535) */
|
|
25
|
+
portRangeStart: z.number().int().min(1024).max(65535),
|
|
26
|
+
/** ポート範囲のサイズ(デフォルト: 1000) */
|
|
27
|
+
rangeSize: z.number().int().min(1).max(10000).default(1000),
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* PostgreSQL設定スキーマ
|
|
32
|
+
*/
|
|
33
|
+
export const postgresConfigSchema = z.object({
|
|
34
|
+
/** PostgreSQLポート(デフォルト: 25432) */
|
|
35
|
+
port: z.number().int().min(1024).max(65535).default(25432),
|
|
36
|
+
/** Dockerコンテナ名(デフォルト: "einja-management-postgres") */
|
|
37
|
+
containerName: z.string().min(1).default("einja-management-postgres"),
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Worktree設定スキーマ
|
|
42
|
+
*
|
|
43
|
+
* worktree.config.jsonファイルの完全な構造を定義。
|
|
44
|
+
*/
|
|
45
|
+
export const worktreeConfigSchema = z.object({
|
|
46
|
+
/** スキーマバージョン(将来の互換性のため) */
|
|
47
|
+
schemaVersion: z.literal(1).default(1),
|
|
48
|
+
/** PostgreSQL設定 */
|
|
49
|
+
postgres: postgresConfigSchema.default({}),
|
|
50
|
+
/** アプリケーション設定の配列 */
|
|
51
|
+
apps: z
|
|
52
|
+
.array(appConfigSchema)
|
|
53
|
+
.default([{ id: "web", portRangeStart: 3000, rangeSize: 1000 }]),
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
/** Worktree設定の型 */
|
|
57
|
+
export type WorktreeConfig = z.infer<typeof worktreeConfigSchema>;
|
|
58
|
+
|
|
59
|
+
/** アプリケーション設定の型 */
|
|
60
|
+
export type AppConfig = z.infer<typeof appConfigSchema>;
|
|
61
|
+
|
|
62
|
+
/** PostgreSQL設定の型 */
|
|
63
|
+
export type PostgresConfig = z.infer<typeof postgresConfigSchema>;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* デフォルトのWorktree設定
|
|
67
|
+
*/
|
|
68
|
+
export const defaultWorktreeConfig: WorktreeConfig = {
|
|
69
|
+
schemaVersion: 1,
|
|
70
|
+
postgres: {
|
|
71
|
+
port: 25432,
|
|
72
|
+
containerName: "einja-management-postgres",
|
|
73
|
+
},
|
|
74
|
+
apps: [{ id: "web", portRangeStart: 3000, rangeSize: 1000 }],
|
|
75
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"lib": ["ES2022"],
|
|
5
|
+
"module": "NodeNext",
|
|
6
|
+
"moduleResolution": "NodeNext",
|
|
7
|
+
"strict": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"resolveJsonModule": true,
|
|
11
|
+
"isolatedModules": true,
|
|
12
|
+
"declaration": true,
|
|
13
|
+
"declarationMap": true,
|
|
14
|
+
"outDir": "./dist",
|
|
15
|
+
"rootDir": "./src"
|
|
16
|
+
},
|
|
17
|
+
"include": ["src/**/*.ts"],
|
|
18
|
+
"exclude": ["node_modules", "dist"]
|
|
19
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2017",
|
|
4
|
+
"lib": [
|
|
5
|
+
"dom",
|
|
6
|
+
"dom.iterable",
|
|
7
|
+
"esnext"
|
|
8
|
+
],
|
|
9
|
+
"allowJs": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"strict": true,
|
|
12
|
+
"noEmit": true,
|
|
13
|
+
"esModuleInterop": true,
|
|
14
|
+
"module": "esnext",
|
|
15
|
+
"moduleResolution": "bundler",
|
|
16
|
+
"resolveJsonModule": true,
|
|
17
|
+
"isolatedModules": true,
|
|
18
|
+
"jsx": "preserve",
|
|
19
|
+
"incremental": true
|
|
20
|
+
},
|
|
21
|
+
"exclude": [
|
|
22
|
+
"node_modules"
|
|
23
|
+
]
|
|
24
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"lib": ["ES2022"],
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"moduleResolution": "bundler",
|
|
7
|
+
"resolveJsonModule": true,
|
|
8
|
+
"allowJs": false,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"strict": true,
|
|
11
|
+
"noEmit": true,
|
|
12
|
+
"esModuleInterop": true,
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"incremental": true,
|
|
15
|
+
"noUncheckedIndexedAccess": true,
|
|
16
|
+
"forceConsistentCasingInFileNames": true
|
|
17
|
+
},
|
|
18
|
+
"exclude": ["node_modules", "dist"]
|
|
19
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@repo/front-core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"exports": {
|
|
6
|
+
".": "./src/index.ts",
|
|
7
|
+
"./auth": "./src/auth/index.ts",
|
|
8
|
+
"./hooks": "./src/hooks/index.ts",
|
|
9
|
+
"./utils": "./src/utils/index.ts",
|
|
10
|
+
"./context": "./src/context/index.ts"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@repo/server-core": "workspace:*",
|
|
14
|
+
"bcryptjs": "^3.0.2",
|
|
15
|
+
"next-auth": "^5.0.0-beta.28",
|
|
16
|
+
"zod": "^3.25.76"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@repo/config": "workspace:*",
|
|
20
|
+
"@types/bcryptjs": "^2.4.6",
|
|
21
|
+
"@types/node": "^22.18.13",
|
|
22
|
+
"typescript": "^5"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import bcrypt from "bcryptjs";
|
|
2
|
+
import type { NextAuthConfig } from "next-auth";
|
|
3
|
+
import Credentials from "next-auth/providers/credentials";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { prisma } from "{{packageName}}/server-core/infrastructure/database/client";
|
|
6
|
+
|
|
7
|
+
const credentialsSchema = z.object({
|
|
8
|
+
email: z.string().email(),
|
|
9
|
+
password: z.string().min(8),
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* NextAuth共通設定
|
|
14
|
+
* アプリ側でmergeAuthOptionsを使用して上書き可能
|
|
15
|
+
*/
|
|
16
|
+
export const baseAuthOptions: NextAuthConfig = {
|
|
17
|
+
session: {
|
|
18
|
+
strategy: "jwt",
|
|
19
|
+
},
|
|
20
|
+
providers: [
|
|
21
|
+
Credentials({
|
|
22
|
+
name: "credentials",
|
|
23
|
+
credentials: {
|
|
24
|
+
email: { label: "Email", type: "email" },
|
|
25
|
+
password: { label: "Password", type: "password" },
|
|
26
|
+
},
|
|
27
|
+
async authorize(credentials) {
|
|
28
|
+
try {
|
|
29
|
+
const { email, password } = credentialsSchema.parse(credentials);
|
|
30
|
+
|
|
31
|
+
const user = await prisma.user.findUnique({
|
|
32
|
+
where: { email },
|
|
33
|
+
select: {
|
|
34
|
+
id: true,
|
|
35
|
+
email: true,
|
|
36
|
+
name: true,
|
|
37
|
+
password: true,
|
|
38
|
+
image: true,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
if (!user || !user.password) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const isPasswordValid = await bcrypt.compare(password, user.password);
|
|
47
|
+
if (!isPasswordValid) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// lastLoginを更新
|
|
52
|
+
await prisma.user.update({
|
|
53
|
+
where: { id: user.id },
|
|
54
|
+
data: { lastLogin: new Date() },
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
id: user.id,
|
|
59
|
+
email: user.email,
|
|
60
|
+
name: user.name,
|
|
61
|
+
image: user.image,
|
|
62
|
+
};
|
|
63
|
+
} catch (error) {
|
|
64
|
+
console.error("Authentication error:", error);
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
}),
|
|
69
|
+
],
|
|
70
|
+
callbacks: {
|
|
71
|
+
async jwt({ token, user }) {
|
|
72
|
+
if (user) {
|
|
73
|
+
token.id = user.id;
|
|
74
|
+
}
|
|
75
|
+
return token;
|
|
76
|
+
},
|
|
77
|
+
async session({ session, token }) {
|
|
78
|
+
if (token) {
|
|
79
|
+
session.user.id = token.id as string;
|
|
80
|
+
}
|
|
81
|
+
return session;
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import "next-auth";
|
|
2
|
+
import type { DefaultSession } from "next-auth";
|
|
3
|
+
|
|
4
|
+
declare module "next-auth" {
|
|
5
|
+
interface Session {
|
|
6
|
+
user: {
|
|
7
|
+
id: string;
|
|
8
|
+
} & DefaultSession["user"];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface User {
|
|
12
|
+
id: string;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
declare module "next-auth/jwt" {
|
|
17
|
+
interface JWT {
|
|
18
|
+
id: string;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { NextAuthConfig } from "next-auth";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* アプリ固有のNextAuth設定オーバーライド用の型
|
|
5
|
+
* providersは通常上書きしないため除外
|
|
6
|
+
*/
|
|
7
|
+
type AuthConfigOverrides = Omit<Partial<NextAuthConfig>, "providers">;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* baseAuthOptionsとアプリ固有設定を安全にマージするユーティリティ
|
|
11
|
+
* callbacksやpagesなどのネストしたオブジェクトも適切にマージします
|
|
12
|
+
*/
|
|
13
|
+
export function mergeAuthOptions(
|
|
14
|
+
base: NextAuthConfig,
|
|
15
|
+
overrides: AuthConfigOverrides,
|
|
16
|
+
): NextAuthConfig {
|
|
17
|
+
return {
|
|
18
|
+
...base,
|
|
19
|
+
...overrides,
|
|
20
|
+
callbacks: {
|
|
21
|
+
...base.callbacks,
|
|
22
|
+
...overrides.callbacks,
|
|
23
|
+
},
|
|
24
|
+
pages: {
|
|
25
|
+
...base.pages,
|
|
26
|
+
...overrides.pages,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|