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
package/dist/cli.js
ADDED
|
@@ -0,0 +1,1041 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/cli.ts
|
|
4
|
+
import { Command } from "commander";
|
|
5
|
+
import { readFileSync as readFileSync4 } from "fs";
|
|
6
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
7
|
+
import { dirname as dirname3, join as join10 } from "path";
|
|
8
|
+
|
|
9
|
+
// src/commands/create.ts
|
|
10
|
+
import { existsSync as existsSync3 } from "fs";
|
|
11
|
+
import { resolve } from "path";
|
|
12
|
+
import ora2 from "ora";
|
|
13
|
+
|
|
14
|
+
// src/prompts/project.ts
|
|
15
|
+
import inquirer from "inquirer";
|
|
16
|
+
async function promptProjectConfig(defaultProjectName) {
|
|
17
|
+
const answers = await inquirer.prompt([
|
|
18
|
+
{
|
|
19
|
+
type: "input",
|
|
20
|
+
name: "projectName",
|
|
21
|
+
message: "\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u540D:",
|
|
22
|
+
default: defaultProjectName || "my-project",
|
|
23
|
+
validate: (input) => {
|
|
24
|
+
const regex = /^[a-zA-Z][a-zA-Z0-9_-]{0,49}$/;
|
|
25
|
+
if (!regex.test(input)) {
|
|
26
|
+
return "\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u540D\u306F\u82F1\u5B57\u3067\u59CB\u307E\u308A\u3001\u82F1\u6570\u5B57\u30FB\u30CF\u30A4\u30D5\u30F3\u30FB\u30A2\u30F3\u30C0\u30FC\u30B9\u30B3\u30A2\u306E\u307F\u4F7F\u7528\u3067\u304D\u307E\u3059\uFF081\u301C50\u6587\u5B57\uFF09";
|
|
27
|
+
}
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
type: "input",
|
|
33
|
+
name: "packageScope",
|
|
34
|
+
message: "\u30D1\u30C3\u30B1\u30FC\u30B8\u30B9\u30B3\u30FC\u30D7:",
|
|
35
|
+
default: "@repo",
|
|
36
|
+
validate: (input) => {
|
|
37
|
+
const regex = /^@[a-zA-Z][a-zA-Z0-9_-]{0,49}$/;
|
|
38
|
+
if (!regex.test(input)) {
|
|
39
|
+
return "\u30D1\u30C3\u30B1\u30FC\u30B8\u30B9\u30B3\u30FC\u30D7\u306F@\u3067\u59CB\u307E\u308A\u3001\u82F1\u6570\u5B57\u30FB\u30CF\u30A4\u30D5\u30F3\u30FB\u30A2\u30F3\u30C0\u30FC\u30B9\u30B3\u30A2\u306E\u307F\u4F7F\u7528\u3067\u304D\u307E\u3059";
|
|
40
|
+
}
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
type: "list",
|
|
46
|
+
name: "template",
|
|
47
|
+
message: "\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8:",
|
|
48
|
+
choices: [
|
|
49
|
+
{
|
|
50
|
+
name: "turborepo-pandacss (\u30D5\u30EB\u30B9\u30BF\u30C3\u30AF\u7BA1\u7406\u753B\u9762)",
|
|
51
|
+
value: "turborepo-pandacss"
|
|
52
|
+
},
|
|
53
|
+
{ name: "minimal (\u6700\u5C0F\u69CB\u6210)", value: "minimal" }
|
|
54
|
+
],
|
|
55
|
+
default: "turborepo-pandacss"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
type: "list",
|
|
59
|
+
name: "authMethod",
|
|
60
|
+
message: "\u8A8D\u8A3C\u65B9\u5F0F:",
|
|
61
|
+
choices: [
|
|
62
|
+
{ name: "NextAuth.js (Google OAuth)", value: "google" },
|
|
63
|
+
{ name: "NextAuth.js (Credentials)", value: "credentials" },
|
|
64
|
+
{ name: "NextAuth.js (GitHub OAuth)", value: "github" },
|
|
65
|
+
{ name: "\u306A\u3057", value: "none" }
|
|
66
|
+
],
|
|
67
|
+
default: "google"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
type: "checkbox",
|
|
71
|
+
name: "tools",
|
|
72
|
+
message: "\u74B0\u5883\u30C4\u30FC\u30EB\u3092\u9078\u629E\uFF08\u8907\u6570\u9078\u629E\u53EF\uFF09:",
|
|
73
|
+
choices: [
|
|
74
|
+
{
|
|
75
|
+
name: "direnv\uFF08\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3054\u3068\u306E\u74B0\u5883\u5909\u6570\u7BA1\u7406\uFF09",
|
|
76
|
+
value: "direnv",
|
|
77
|
+
checked: true
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: "dotenvx\uFF08.env\u6697\u53F7\u5316\uFF09",
|
|
81
|
+
value: "dotenvx",
|
|
82
|
+
checked: true
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: "Volta\uFF08Node.js\u30D0\u30FC\u30B8\u30E7\u30F3\u7BA1\u7406\uFF09",
|
|
86
|
+
value: "volta",
|
|
87
|
+
checked: true
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
type: "confirm",
|
|
93
|
+
name: "setupEinjaCli",
|
|
94
|
+
message: "@einja/cli \u3092\u81EA\u52D5\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3057\u307E\u3059\u304B\uFF1F",
|
|
95
|
+
default: true
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
type: "confirm",
|
|
99
|
+
name: "customizeWorktree",
|
|
100
|
+
message: "Worktree\u8A2D\u5B9A\u3092\u30AB\u30B9\u30BF\u30DE\u30A4\u30BA\u3057\u307E\u3059\u304B\uFF1F",
|
|
101
|
+
default: false
|
|
102
|
+
}
|
|
103
|
+
]);
|
|
104
|
+
const toolsArray = answers.tools;
|
|
105
|
+
const tools = {
|
|
106
|
+
direnv: toolsArray.includes("direnv"),
|
|
107
|
+
dotenvx: toolsArray.includes("dotenvx"),
|
|
108
|
+
volta: toolsArray.includes("volta"),
|
|
109
|
+
biome: true,
|
|
110
|
+
husky: true
|
|
111
|
+
};
|
|
112
|
+
let worktreeConfig;
|
|
113
|
+
if (answers.customizeWorktree) {
|
|
114
|
+
const worktreeAnswers = await inquirer.prompt([
|
|
115
|
+
{
|
|
116
|
+
type: "input",
|
|
117
|
+
name: "postgresPort",
|
|
118
|
+
message: "PostgreSQL\u30DD\u30FC\u30C8\u756A\u53F7:",
|
|
119
|
+
default: "25432",
|
|
120
|
+
validate: (input) => {
|
|
121
|
+
const port = Number.parseInt(input, 10);
|
|
122
|
+
if (Number.isNaN(port) || port < 1024 || port > 65535) {
|
|
123
|
+
return "\u30DD\u30FC\u30C8\u756A\u53F7\u306F1024\u301C65535\u306E\u7BC4\u56F2\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044";
|
|
124
|
+
}
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
type: "input",
|
|
130
|
+
name: "containerName",
|
|
131
|
+
message: "Docker\u30B3\u30F3\u30C6\u30CA\u540D:",
|
|
132
|
+
default: `${answers.projectName}-postgres`
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
type: "input",
|
|
136
|
+
name: "appId",
|
|
137
|
+
message: "\u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3ID:",
|
|
138
|
+
default: "web"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
type: "input",
|
|
142
|
+
name: "portRangeStart",
|
|
143
|
+
message: "\u30A2\u30D7\u30EA\u30DD\u30FC\u30C8\u7BC4\u56F2\u958B\u59CB:",
|
|
144
|
+
default: "3000",
|
|
145
|
+
validate: (input) => {
|
|
146
|
+
const port = Number.parseInt(input, 10);
|
|
147
|
+
if (Number.isNaN(port) || port < 1024 || port > 65535) {
|
|
148
|
+
return "\u30DD\u30FC\u30C8\u756A\u53F7\u306F1024\u301C65535\u306E\u7BC4\u56F2\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044";
|
|
149
|
+
}
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
type: "input",
|
|
155
|
+
name: "rangeSize",
|
|
156
|
+
message: "\u30DD\u30FC\u30C8\u7BC4\u56F2\u30B5\u30A4\u30BA:",
|
|
157
|
+
default: "1000",
|
|
158
|
+
validate: (input) => {
|
|
159
|
+
const size = Number.parseInt(input, 10);
|
|
160
|
+
if (Number.isNaN(size) || size < 1 || size > 1e4) {
|
|
161
|
+
return "\u7BC4\u56F2\u30B5\u30A4\u30BA\u306F1\u301C10000\u306E\u7BC4\u56F2\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044";
|
|
162
|
+
}
|
|
163
|
+
return true;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
]);
|
|
167
|
+
worktreeConfig = {
|
|
168
|
+
postgres: {
|
|
169
|
+
port: Number.parseInt(worktreeAnswers.postgresPort, 10),
|
|
170
|
+
containerName: worktreeAnswers.containerName
|
|
171
|
+
},
|
|
172
|
+
apps: [
|
|
173
|
+
{
|
|
174
|
+
id: worktreeAnswers.appId,
|
|
175
|
+
portRangeStart: Number.parseInt(worktreeAnswers.portRangeStart, 10),
|
|
176
|
+
rangeSize: Number.parseInt(worktreeAnswers.rangeSize, 10)
|
|
177
|
+
}
|
|
178
|
+
]
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
return {
|
|
182
|
+
projectName: answers.projectName,
|
|
183
|
+
packageScope: answers.packageScope,
|
|
184
|
+
template: answers.template,
|
|
185
|
+
authMethod: answers.authMethod,
|
|
186
|
+
tools,
|
|
187
|
+
setupEinjaCli: answers.setupEinjaCli,
|
|
188
|
+
worktreeConfig
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// src/generators/template.ts
|
|
193
|
+
import fsExtra from "fs-extra";
|
|
194
|
+
import { glob } from "glob";
|
|
195
|
+
import { dirname as dirname2, join as join2, relative } from "path";
|
|
196
|
+
import { fileURLToPath } from "url";
|
|
197
|
+
|
|
198
|
+
// src/utils/fs.ts
|
|
199
|
+
import { existsSync, readFileSync, writeFileSync, appendFileSync, mkdirSync } from "fs";
|
|
200
|
+
import { join, dirname } from "path";
|
|
201
|
+
function writeWithStrategy(filePath, content, strategy) {
|
|
202
|
+
const exists = existsSync(filePath);
|
|
203
|
+
if (!exists) {
|
|
204
|
+
ensureDir(dirname(filePath));
|
|
205
|
+
writeFileSync(filePath, content, "utf-8");
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
208
|
+
switch (strategy) {
|
|
209
|
+
case "overwrite": {
|
|
210
|
+
writeFileSync(filePath, content, "utf-8");
|
|
211
|
+
return true;
|
|
212
|
+
}
|
|
213
|
+
case "merge": {
|
|
214
|
+
const existingContent = readFileSync(filePath, "utf-8");
|
|
215
|
+
const mergedContent = mergeContent(existingContent, content);
|
|
216
|
+
writeFileSync(filePath, mergedContent, "utf-8");
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
case "skip": {
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
default: {
|
|
223
|
+
const _exhaustiveCheck = strategy;
|
|
224
|
+
throw new Error(`Unknown strategy: ${_exhaustiveCheck}`);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
function mergeContent(existing, newContent) {
|
|
229
|
+
if (existing.includes(newContent)) {
|
|
230
|
+
return existing;
|
|
231
|
+
}
|
|
232
|
+
return `${existing}
|
|
233
|
+
${newContent}`;
|
|
234
|
+
}
|
|
235
|
+
function ensureDir(dirPath) {
|
|
236
|
+
if (!existsSync(dirPath)) {
|
|
237
|
+
mkdirSync(dirPath, { recursive: true });
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
function appendToGitignore(targetDir, line) {
|
|
241
|
+
const gitignorePath = join(targetDir, ".gitignore");
|
|
242
|
+
if (!existsSync(gitignorePath)) {
|
|
243
|
+
writeFileSync(gitignorePath, `${line}
|
|
244
|
+
`, "utf-8");
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
const content = readFileSync(gitignorePath, "utf-8");
|
|
248
|
+
if (content.includes(line)) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
appendFileSync(gitignorePath, `
|
|
252
|
+
${line}
|
|
253
|
+
`, "utf-8");
|
|
254
|
+
}
|
|
255
|
+
function fileExists(filePath) {
|
|
256
|
+
return existsSync(filePath);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// src/utils/logger.ts
|
|
260
|
+
import chalk from "chalk";
|
|
261
|
+
function info(message) {
|
|
262
|
+
console.log(chalk.blue("\u2139"), message);
|
|
263
|
+
}
|
|
264
|
+
function success(message) {
|
|
265
|
+
console.log(chalk.green("\u2714"), message);
|
|
266
|
+
}
|
|
267
|
+
function warn(message) {
|
|
268
|
+
console.log(chalk.yellow("\u26A0"), message);
|
|
269
|
+
}
|
|
270
|
+
function error(message) {
|
|
271
|
+
console.error(chalk.red("\u2716"), message);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// src/generators/template.ts
|
|
275
|
+
var { copySync, readFileSync: readFileSync2, writeFileSync: writeFileSync2, existsSync: existsSync2, removeSync } = fsExtra;
|
|
276
|
+
function getTemplatePath(templateName) {
|
|
277
|
+
const __filename3 = fileURLToPath(import.meta.url);
|
|
278
|
+
const __dirname3 = dirname2(__filename3);
|
|
279
|
+
const distPath = join2(__dirname3, "../templates", templateName);
|
|
280
|
+
const srcPath = join2(__dirname3, "../../templates", templateName);
|
|
281
|
+
if (existsSync2(distPath)) {
|
|
282
|
+
return distPath;
|
|
283
|
+
}
|
|
284
|
+
if (existsSync2(srcPath)) {
|
|
285
|
+
return srcPath;
|
|
286
|
+
}
|
|
287
|
+
return distPath;
|
|
288
|
+
}
|
|
289
|
+
function getAuthExcludePatterns(authMethod) {
|
|
290
|
+
if (authMethod === "none") {
|
|
291
|
+
return [
|
|
292
|
+
"**/api/auth/**",
|
|
293
|
+
"**/packages/auth/**",
|
|
294
|
+
"**/signin/**",
|
|
295
|
+
"**/signup/**"
|
|
296
|
+
];
|
|
297
|
+
}
|
|
298
|
+
return [];
|
|
299
|
+
}
|
|
300
|
+
function replacePlaceholders(content, variables) {
|
|
301
|
+
let result = content;
|
|
302
|
+
result = result.replaceAll("{{projectName}}", variables.projectName);
|
|
303
|
+
result = result.replaceAll("{{packageName}}/", `${variables.packageName}/`);
|
|
304
|
+
result = result.replaceAll("{{packageName}}", variables.packageName);
|
|
305
|
+
result = result.replaceAll("{{description}}", variables.description);
|
|
306
|
+
result = result.replaceAll("@repo/", `${variables.packageName}/`);
|
|
307
|
+
return result;
|
|
308
|
+
}
|
|
309
|
+
function processFileVariables(filePath, variables) {
|
|
310
|
+
const binaryExtensions = [".png", ".jpg", ".jpeg", ".gif", ".ico", ".woff", ".woff2", ".ttf", ".eot"];
|
|
311
|
+
if (binaryExtensions.some((ext) => filePath.endsWith(ext))) {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
try {
|
|
315
|
+
const content = readFileSync2(filePath, "utf-8");
|
|
316
|
+
const replaced = replacePlaceholders(content, variables);
|
|
317
|
+
if (content !== replaced) {
|
|
318
|
+
writeFileSync2(filePath, replaced, "utf-8");
|
|
319
|
+
}
|
|
320
|
+
} catch (error2) {
|
|
321
|
+
warn(`\u5909\u6570\u7F6E\u63DB\u3092\u30B9\u30AD\u30C3\u30D7: ${filePath}`);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
function renameTemplateFiles(targetPath) {
|
|
325
|
+
const templateFiles = glob.sync("**/*.template", {
|
|
326
|
+
cwd: targetPath,
|
|
327
|
+
absolute: true,
|
|
328
|
+
dot: true
|
|
329
|
+
});
|
|
330
|
+
for (const file of templateFiles) {
|
|
331
|
+
const newPath = file.replace(/\.template$/, "");
|
|
332
|
+
copySync(file, newPath);
|
|
333
|
+
removeSync(file);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
function excludeAuthFiles(targetPath, authMethod) {
|
|
337
|
+
const excludePatterns = getAuthExcludePatterns(authMethod);
|
|
338
|
+
if (excludePatterns.length === 0) {
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
info("\u8A8D\u8A3C\u65B9\u5F0F\u306B\u5FDC\u3058\u305F\u30D5\u30A1\u30A4\u30EB\u3092\u9664\u5916\u4E2D...");
|
|
342
|
+
for (const pattern of excludePatterns) {
|
|
343
|
+
const files = glob.sync(pattern, {
|
|
344
|
+
cwd: targetPath,
|
|
345
|
+
absolute: true,
|
|
346
|
+
dot: true
|
|
347
|
+
});
|
|
348
|
+
for (const file of files) {
|
|
349
|
+
removeSync(file);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
async function generateTemplate(config, targetPath) {
|
|
354
|
+
const templatePath = getTemplatePath(config.template);
|
|
355
|
+
if (!existsSync2(templatePath)) {
|
|
356
|
+
throw new Error(`\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: ${config.template}`);
|
|
357
|
+
}
|
|
358
|
+
info("\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u3092\u30B3\u30D4\u30FC\u4E2D...");
|
|
359
|
+
await ensureDir(targetPath);
|
|
360
|
+
copySync(templatePath, targetPath, {
|
|
361
|
+
filter: (src) => {
|
|
362
|
+
const relativePath = relative(templatePath, src);
|
|
363
|
+
const excludePatterns = [
|
|
364
|
+
"node_modules",
|
|
365
|
+
".git",
|
|
366
|
+
".next",
|
|
367
|
+
".turbo",
|
|
368
|
+
"out",
|
|
369
|
+
"dist",
|
|
370
|
+
"logs",
|
|
371
|
+
".env",
|
|
372
|
+
".env.local",
|
|
373
|
+
".DS_Store",
|
|
374
|
+
"Thumbs.db",
|
|
375
|
+
"coverage"
|
|
376
|
+
];
|
|
377
|
+
const excludeExtensions = [".log"];
|
|
378
|
+
const pathSegments = relativePath.split(/[/\\]/);
|
|
379
|
+
const matchesExcludePattern = excludePatterns.some(
|
|
380
|
+
(pattern) => pathSegments.includes(pattern)
|
|
381
|
+
);
|
|
382
|
+
const matchesExtension = excludeExtensions.some(
|
|
383
|
+
(ext) => relativePath.endsWith(ext)
|
|
384
|
+
);
|
|
385
|
+
return !matchesExcludePattern && !matchesExtension;
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
excludeAuthFiles(targetPath, config.authMethod);
|
|
389
|
+
renameTemplateFiles(targetPath);
|
|
390
|
+
info("\u30D7\u30EC\u30FC\u30B9\u30DB\u30EB\u30C0\u30FC\u5909\u6570\u3092\u7F6E\u63DB\u4E2D...");
|
|
391
|
+
const variables = {
|
|
392
|
+
projectName: config.projectName,
|
|
393
|
+
packageName: config.packageScope,
|
|
394
|
+
description: `${config.projectName} - Einja Management Template`
|
|
395
|
+
};
|
|
396
|
+
const allFiles = glob.sync("**/*", {
|
|
397
|
+
cwd: targetPath,
|
|
398
|
+
absolute: true,
|
|
399
|
+
nodir: true,
|
|
400
|
+
dot: true
|
|
401
|
+
});
|
|
402
|
+
for (const file of allFiles) {
|
|
403
|
+
processFileVariables(file, variables);
|
|
404
|
+
}
|
|
405
|
+
success("\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u5C55\u958B\u5B8C\u4E86");
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// src/generators/post-setup.ts
|
|
409
|
+
import { execa, execaSync } from "execa";
|
|
410
|
+
import chalk2 from "chalk";
|
|
411
|
+
import inquirer2 from "inquirer";
|
|
412
|
+
import ora from "ora";
|
|
413
|
+
function isDirenvAvailable() {
|
|
414
|
+
try {
|
|
415
|
+
execaSync("which", ["direnv"]);
|
|
416
|
+
return true;
|
|
417
|
+
} catch {
|
|
418
|
+
return false;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
async function promptAndExecuteDirenvAllow(targetPath) {
|
|
422
|
+
try {
|
|
423
|
+
const { shouldAllow } = await inquirer2.prompt([
|
|
424
|
+
{
|
|
425
|
+
type: "confirm",
|
|
426
|
+
name: "shouldAllow",
|
|
427
|
+
message: "direnv allow \u3092\u5B9F\u884C\u3057\u307E\u3059\u304B\uFF1F\uFF08\u74B0\u5883\u5909\u6570\u3092\u6709\u52B9\u5316\u3057\u307E\u3059\uFF09",
|
|
428
|
+
default: true
|
|
429
|
+
}
|
|
430
|
+
]);
|
|
431
|
+
if (shouldAllow) {
|
|
432
|
+
try {
|
|
433
|
+
await execa("direnv", ["allow"], { cwd: targetPath });
|
|
434
|
+
success("direnv allow \u3092\u5B9F\u884C\u3057\u307E\u3057\u305F");
|
|
435
|
+
} catch (error2) {
|
|
436
|
+
warn("direnv allow \u306E\u5B9F\u884C\u306B\u5931\u6557\u3057\u307E\u3057\u305F");
|
|
437
|
+
info("\u5F8C\u3067\u624B\u52D5\u3067 'direnv allow' \u3092\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
438
|
+
}
|
|
439
|
+
} else {
|
|
440
|
+
info("direnv allow \u3092\u30B9\u30AD\u30C3\u30D7\u3057\u307E\u3057\u305F");
|
|
441
|
+
info("\u5F8C\u3067\u624B\u52D5\u3067 'direnv allow' \u3092\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
442
|
+
}
|
|
443
|
+
} catch (error2) {
|
|
444
|
+
info("direnv allow \u3092\u30B9\u30AD\u30C3\u30D7\u3057\u307E\u3057\u305F");
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
function printCompletionMessage(config) {
|
|
448
|
+
console.log();
|
|
449
|
+
success("\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E\u4F5C\u6210\u304C\u5B8C\u4E86\u3057\u307E\u3057\u305F\uFF01");
|
|
450
|
+
console.log();
|
|
451
|
+
console.log(chalk2.bold("\u6B21\u306E\u30B9\u30C6\u30C3\u30D7:"));
|
|
452
|
+
console.log();
|
|
453
|
+
console.log(chalk2.cyan(` cd ${config.projectName}`));
|
|
454
|
+
console.log(chalk2.cyan(" docker-compose up -d postgres"));
|
|
455
|
+
console.log(chalk2.cyan(" pnpm dev"));
|
|
456
|
+
console.log();
|
|
457
|
+
console.log(chalk2.gray("\u958B\u767A\u30B5\u30FC\u30D0\u30FC: http://localhost:3000"));
|
|
458
|
+
console.log();
|
|
459
|
+
console.log(chalk2.gray("\u8A73\u7D30\u306F README.md \u3092\u3054\u78BA\u8A8D\u304F\u3060\u3055\u3044\u3002"));
|
|
460
|
+
console.log();
|
|
461
|
+
}
|
|
462
|
+
async function execPostSetup(config, targetPath, options) {
|
|
463
|
+
const { skipGit, skipInstall } = options;
|
|
464
|
+
if (!skipGit) {
|
|
465
|
+
const gitSpinner = ora("Git\u30EA\u30DD\u30B8\u30C8\u30EA\u3092\u521D\u671F\u5316\u4E2D...").start();
|
|
466
|
+
try {
|
|
467
|
+
await execa("git", ["init"], { cwd: targetPath });
|
|
468
|
+
await execa("git", ["add", "."], { cwd: targetPath });
|
|
469
|
+
await execa("git", ["commit", "-m", "Initial commit"], { cwd: targetPath });
|
|
470
|
+
gitSpinner.succeed("Git\u30EA\u30DD\u30B8\u30C8\u30EA\u3092\u521D\u671F\u5316\u3057\u307E\u3057\u305F");
|
|
471
|
+
} catch (error2) {
|
|
472
|
+
gitSpinner.fail("Git\u30EA\u30DD\u30B8\u30C8\u30EA\u306E\u521D\u671F\u5316\u306B\u5931\u6557\u3057\u307E\u3057\u305F");
|
|
473
|
+
warn("\u5F8C\u3067\u624B\u52D5\u3067 'git init' \u3092\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
if (!skipInstall) {
|
|
477
|
+
const installSpinner = ora("\u4F9D\u5B58\u95A2\u4FC2\u3092\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u4E2D...").start();
|
|
478
|
+
try {
|
|
479
|
+
await execa("pnpm", ["install"], { cwd: targetPath });
|
|
480
|
+
installSpinner.succeed("\u4F9D\u5B58\u95A2\u4FC2\u3092\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u3057\u307E\u3057\u305F");
|
|
481
|
+
const prismaSpinner = ora("Prisma\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8\u3092\u751F\u6210\u4E2D...").start();
|
|
482
|
+
try {
|
|
483
|
+
await execa("pnpm", ["db:generate"], { cwd: targetPath });
|
|
484
|
+
prismaSpinner.succeed("Prisma\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8\u3092\u751F\u6210\u3057\u307E\u3057\u305F");
|
|
485
|
+
} catch (error2) {
|
|
486
|
+
prismaSpinner.fail("Prisma\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8\u306E\u751F\u6210\u306B\u5931\u6557\u3057\u307E\u3057\u305F");
|
|
487
|
+
warn("\u5F8C\u3067\u624B\u52D5\u3067 'pnpm db:generate' \u3092\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
488
|
+
}
|
|
489
|
+
} catch (error2) {
|
|
490
|
+
installSpinner.fail("\u4F9D\u5B58\u95A2\u4FC2\u306E\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u306B\u5931\u6557\u3057\u307E\u3057\u305F");
|
|
491
|
+
warn("\u5F8C\u3067\u624B\u52D5\u3067 'pnpm install' \u3092\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
if (config.tools.direnv && isDirenvAvailable()) {
|
|
495
|
+
await promptAndExecuteDirenvAllow(targetPath);
|
|
496
|
+
}
|
|
497
|
+
if (config.setupEinjaCli) {
|
|
498
|
+
const einjaSpinner = ora("@einja/cli \u3092\u521D\u671F\u5316\u4E2D...").start();
|
|
499
|
+
try {
|
|
500
|
+
await execa("npx", ["@einja/cli", "init"], { cwd: targetPath });
|
|
501
|
+
einjaSpinner.succeed("@einja/cli \u3092\u521D\u671F\u5316\u3057\u307E\u3057\u305F");
|
|
502
|
+
} catch (error2) {
|
|
503
|
+
einjaSpinner.fail("@einja/cli \u306E\u521D\u671F\u5316\u306B\u5931\u6557\u3057\u307E\u3057\u305F");
|
|
504
|
+
warn("\u5F8C\u3067\u624B\u52D5\u3067 'npx @einja/cli init' \u3092\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
printCompletionMessage(config);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
// src/commands/create.ts
|
|
511
|
+
function validateProjectName(projectName) {
|
|
512
|
+
const regex = /^[a-zA-Z][a-zA-Z0-9_-]{0,49}$/;
|
|
513
|
+
if (!regex.test(projectName)) {
|
|
514
|
+
return "\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u540D\u306F\u82F1\u5B57\u3067\u59CB\u307E\u308A\u3001\u82F1\u6570\u5B57\u30FB\u30CF\u30A4\u30D5\u30F3\u30FB\u30A2\u30F3\u30C0\u30FC\u30B9\u30B3\u30A2\u306E\u307F\u4F7F\u7528\u3067\u304D\u307E\u3059\uFF081\u301C50\u6587\u5B57\uFF09";
|
|
515
|
+
}
|
|
516
|
+
return void 0;
|
|
517
|
+
}
|
|
518
|
+
function checkProjectExists(targetPath) {
|
|
519
|
+
return existsSync3(targetPath);
|
|
520
|
+
}
|
|
521
|
+
async function createCommand(projectName, options) {
|
|
522
|
+
try {
|
|
523
|
+
let config;
|
|
524
|
+
if (options.yes && projectName) {
|
|
525
|
+
const error2 = validateProjectName(projectName);
|
|
526
|
+
if (error2) {
|
|
527
|
+
error(error2);
|
|
528
|
+
process.exit(1);
|
|
529
|
+
}
|
|
530
|
+
config = {
|
|
531
|
+
projectName,
|
|
532
|
+
packageScope: "@repo",
|
|
533
|
+
template: options.template || "turborepo-pandacss",
|
|
534
|
+
authMethod: "google",
|
|
535
|
+
tools: {
|
|
536
|
+
direnv: true,
|
|
537
|
+
dotenvx: true,
|
|
538
|
+
volta: true,
|
|
539
|
+
biome: true,
|
|
540
|
+
husky: true
|
|
541
|
+
},
|
|
542
|
+
setupEinjaCli: true,
|
|
543
|
+
worktreeConfig: void 0
|
|
544
|
+
};
|
|
545
|
+
info(`\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u540D: ${config.projectName}`);
|
|
546
|
+
info(`\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8: ${config.template}`);
|
|
547
|
+
info(`\u8A8D\u8A3C\u65B9\u5F0F: ${config.authMethod}`);
|
|
548
|
+
} else {
|
|
549
|
+
config = await promptProjectConfig(projectName);
|
|
550
|
+
}
|
|
551
|
+
const targetPath = resolve(process.cwd(), config.projectName);
|
|
552
|
+
if (checkProjectExists(targetPath)) {
|
|
553
|
+
error(`\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA '${config.projectName}' \u306F\u65E2\u306B\u5B58\u5728\u3057\u307E\u3059`);
|
|
554
|
+
info("\u5225\u306E\u540D\u524D\u3092\u6307\u5B9A\u3059\u308B\u304B\u3001\u65E2\u5B58\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3092\u524A\u9664\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
555
|
+
process.exit(1);
|
|
556
|
+
}
|
|
557
|
+
const spinner = ora2("\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u3092\u4F5C\u6210\u4E2D...").start();
|
|
558
|
+
try {
|
|
559
|
+
await generateTemplate(config, targetPath);
|
|
560
|
+
spinner.succeed("\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u3092\u4F5C\u6210\u3057\u307E\u3057\u305F");
|
|
561
|
+
} catch (error2) {
|
|
562
|
+
spinner.fail("\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E\u4F5C\u6210\u306B\u5931\u6557\u3057\u307E\u3057\u305F");
|
|
563
|
+
throw error2;
|
|
564
|
+
}
|
|
565
|
+
await execPostSetup(config, targetPath, {
|
|
566
|
+
skipGit: options.skipGit,
|
|
567
|
+
skipInstall: options.skipInstall
|
|
568
|
+
});
|
|
569
|
+
} catch (error2) {
|
|
570
|
+
error("\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F:");
|
|
571
|
+
if (error2 instanceof Error) {
|
|
572
|
+
error(error2.message);
|
|
573
|
+
} else {
|
|
574
|
+
error(String(error2));
|
|
575
|
+
}
|
|
576
|
+
process.exit(1);
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
// src/commands/setup.ts
|
|
581
|
+
import { existsSync as existsSync4 } from "fs";
|
|
582
|
+
import { join as join9 } from "path";
|
|
583
|
+
import ora3 from "ora";
|
|
584
|
+
|
|
585
|
+
// src/prompts/setup.ts
|
|
586
|
+
import inquirer3 from "inquirer";
|
|
587
|
+
async function promptSetupConfig() {
|
|
588
|
+
const answers = await inquirer3.prompt([
|
|
589
|
+
{
|
|
590
|
+
type: "checkbox",
|
|
591
|
+
name: "tools",
|
|
592
|
+
message: "\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3059\u308B\u30C4\u30FC\u30EB\u3092\u9078\u629E\uFF08\u8907\u6570\u9078\u629E\u53EF\uFF09:",
|
|
593
|
+
choices: [
|
|
594
|
+
{
|
|
595
|
+
name: "direnv\uFF08\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3054\u3068\u306E\u74B0\u5883\u5909\u6570\u7BA1\u7406\uFF09",
|
|
596
|
+
value: "direnv",
|
|
597
|
+
checked: true
|
|
598
|
+
},
|
|
599
|
+
{
|
|
600
|
+
name: "dotenvx\uFF08.env\u6697\u53F7\u5316\uFF09",
|
|
601
|
+
value: "dotenvx",
|
|
602
|
+
checked: true
|
|
603
|
+
},
|
|
604
|
+
{
|
|
605
|
+
name: "Volta\uFF08Node.js\u30D0\u30FC\u30B8\u30E7\u30F3\u7BA1\u7406\uFF09",
|
|
606
|
+
value: "volta",
|
|
607
|
+
checked: true
|
|
608
|
+
},
|
|
609
|
+
{
|
|
610
|
+
name: "Biome\uFF08Linter / Formatter\uFF09",
|
|
611
|
+
value: "biome",
|
|
612
|
+
checked: false
|
|
613
|
+
},
|
|
614
|
+
{
|
|
615
|
+
name: "Husky + lint-staged\uFF08Git hooks\uFF09",
|
|
616
|
+
value: "husky",
|
|
617
|
+
checked: false
|
|
618
|
+
}
|
|
619
|
+
]
|
|
620
|
+
},
|
|
621
|
+
{
|
|
622
|
+
type: "list",
|
|
623
|
+
name: "conflictStrategy",
|
|
624
|
+
message: "\u65E2\u5B58\u30D5\u30A1\u30A4\u30EB\u304C\u3042\u308B\u5834\u5408\u306E\u52D5\u4F5C:",
|
|
625
|
+
choices: [
|
|
626
|
+
{
|
|
627
|
+
name: "\u30DE\u30FC\u30B8\uFF08\u65E2\u5B58\u8A2D\u5B9A\u3092\u4FDD\u6301\u3057\u3064\u3064\u8FFD\u52A0\uFF09",
|
|
628
|
+
value: "merge"
|
|
629
|
+
},
|
|
630
|
+
{
|
|
631
|
+
name: "\u4E0A\u66F8\u304D",
|
|
632
|
+
value: "overwrite"
|
|
633
|
+
},
|
|
634
|
+
{
|
|
635
|
+
name: "\u30B9\u30AD\u30C3\u30D7",
|
|
636
|
+
value: "skip"
|
|
637
|
+
}
|
|
638
|
+
],
|
|
639
|
+
default: "merge"
|
|
640
|
+
}
|
|
641
|
+
]);
|
|
642
|
+
const toolsArray = answers.tools;
|
|
643
|
+
const tools = {
|
|
644
|
+
direnv: toolsArray.includes("direnv"),
|
|
645
|
+
dotenvx: toolsArray.includes("dotenvx"),
|
|
646
|
+
volta: toolsArray.includes("volta"),
|
|
647
|
+
biome: toolsArray.includes("biome"),
|
|
648
|
+
husky: toolsArray.includes("husky")
|
|
649
|
+
};
|
|
650
|
+
return {
|
|
651
|
+
tools,
|
|
652
|
+
conflictStrategy: answers.conflictStrategy
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
// src/generators/tools/direnv.ts
|
|
657
|
+
import { join as join3 } from "path";
|
|
658
|
+
import { execSync } from "child_process";
|
|
659
|
+
import inquirer4 from "inquirer";
|
|
660
|
+
var ENVRC_CONTENT = `# direnv configuration
|
|
661
|
+
# Load .env if it exists
|
|
662
|
+
dotenv_if_exists
|
|
663
|
+
|
|
664
|
+
# Allow local overrides
|
|
665
|
+
dotenv_if_exists .env.local
|
|
666
|
+
`;
|
|
667
|
+
var ENVRC_EXAMPLE_CONTENT = `# Example direnv configuration
|
|
668
|
+
# Copy this file to .envrc and run 'direnv allow'
|
|
669
|
+
|
|
670
|
+
# Load environment variables from .env
|
|
671
|
+
dotenv_if_exists
|
|
672
|
+
|
|
673
|
+
# Load local overrides
|
|
674
|
+
dotenv_if_exists .env.local
|
|
675
|
+
`;
|
|
676
|
+
function setupDirenv(options) {
|
|
677
|
+
const { targetDir, conflictStrategy } = options;
|
|
678
|
+
const envrcPath = join3(targetDir, ".envrc");
|
|
679
|
+
const envrcExamplePath = join3(targetDir, ".envrc.example");
|
|
680
|
+
writeWithStrategy(envrcPath, ENVRC_CONTENT, conflictStrategy);
|
|
681
|
+
writeWithStrategy(envrcExamplePath, ENVRC_EXAMPLE_CONTENT, conflictStrategy);
|
|
682
|
+
appendToGitignore(targetDir, ".envrc");
|
|
683
|
+
}
|
|
684
|
+
async function promptDirenvAllow(targetDir) {
|
|
685
|
+
try {
|
|
686
|
+
const { shouldAllow } = await inquirer4.prompt([
|
|
687
|
+
{
|
|
688
|
+
type: "confirm",
|
|
689
|
+
name: "shouldAllow",
|
|
690
|
+
message: "direnv allow \u3092\u5B9F\u884C\u3057\u307E\u3059\u304B\uFF1F\uFF08\u74B0\u5883\u5909\u6570\u3092\u6709\u52B9\u5316\u3057\u307E\u3059\uFF09",
|
|
691
|
+
default: true
|
|
692
|
+
}
|
|
693
|
+
]);
|
|
694
|
+
if (shouldAllow) {
|
|
695
|
+
try {
|
|
696
|
+
execSync("direnv allow", { cwd: targetDir, stdio: "inherit" });
|
|
697
|
+
success("direnv allow \u3092\u5B9F\u884C\u3057\u307E\u3057\u305F");
|
|
698
|
+
} catch (error2) {
|
|
699
|
+
warn("direnv allow \u306E\u5B9F\u884C\u306B\u5931\u6557\u3057\u307E\u3057\u305F");
|
|
700
|
+
info("\u5F8C\u3067\u624B\u52D5\u3067 'direnv allow' \u3092\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
701
|
+
}
|
|
702
|
+
} else {
|
|
703
|
+
info("direnv allow \u3092\u30B9\u30AD\u30C3\u30D7\u3057\u307E\u3057\u305F");
|
|
704
|
+
info("\u5F8C\u3067\u624B\u52D5\u3067 'direnv allow' \u3092\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
705
|
+
}
|
|
706
|
+
} catch (error2) {
|
|
707
|
+
info("direnv allow \u3092\u30B9\u30AD\u30C3\u30D7\u3057\u307E\u3057\u305F");
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
// src/generators/tools/dotenvx.ts
|
|
712
|
+
import { join as join5 } from "path";
|
|
713
|
+
|
|
714
|
+
// src/utils/package-json.ts
|
|
715
|
+
import { readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
716
|
+
import { join as join4 } from "path";
|
|
717
|
+
function readPackageJson(targetDir) {
|
|
718
|
+
const packageJsonPath2 = join4(targetDir, "package.json");
|
|
719
|
+
if (!fileExists(packageJsonPath2)) {
|
|
720
|
+
return {};
|
|
721
|
+
}
|
|
722
|
+
const content = readFileSync3(packageJsonPath2, "utf-8");
|
|
723
|
+
return JSON.parse(content);
|
|
724
|
+
}
|
|
725
|
+
function writePackageJson(targetDir, data) {
|
|
726
|
+
const packageJsonPath2 = join4(targetDir, "package.json");
|
|
727
|
+
const content = JSON.stringify(data, null, 2);
|
|
728
|
+
writeFileSync3(packageJsonPath2, `${content}
|
|
729
|
+
`, "utf-8");
|
|
730
|
+
}
|
|
731
|
+
function addScripts(targetDir, scripts) {
|
|
732
|
+
const pkg = readPackageJson(targetDir);
|
|
733
|
+
pkg.scripts = { ...pkg.scripts, ...scripts };
|
|
734
|
+
writePackageJson(targetDir, pkg);
|
|
735
|
+
}
|
|
736
|
+
function addDependencies(targetDir, dependencies, dev = false) {
|
|
737
|
+
const pkg = readPackageJson(targetDir);
|
|
738
|
+
if (dev) {
|
|
739
|
+
pkg.devDependencies = { ...pkg.devDependencies, ...dependencies };
|
|
740
|
+
} else {
|
|
741
|
+
pkg.dependencies = { ...pkg.dependencies, ...dependencies };
|
|
742
|
+
}
|
|
743
|
+
writePackageJson(targetDir, pkg);
|
|
744
|
+
}
|
|
745
|
+
function addVoltaField(targetDir, nodeVersion, pnpmVersion) {
|
|
746
|
+
const pkg = readPackageJson(targetDir);
|
|
747
|
+
pkg.volta = {
|
|
748
|
+
node: nodeVersion,
|
|
749
|
+
pnpm: pnpmVersion
|
|
750
|
+
};
|
|
751
|
+
writePackageJson(targetDir, pkg);
|
|
752
|
+
}
|
|
753
|
+
function addLintStaged(targetDir, config) {
|
|
754
|
+
const pkg = readPackageJson(targetDir);
|
|
755
|
+
pkg["lint-staged"] = { ...pkg["lint-staged"], ...config };
|
|
756
|
+
writePackageJson(targetDir, pkg);
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
// src/generators/tools/dotenvx.ts
|
|
760
|
+
var ENV_EXAMPLE_CONTENT = `# Environment variables template
|
|
761
|
+
# Copy this file to .env and fill in the values
|
|
762
|
+
|
|
763
|
+
# Database
|
|
764
|
+
DATABASE_URL="postgresql://user:password@localhost:25432/dbname"
|
|
765
|
+
|
|
766
|
+
# NextAuth
|
|
767
|
+
NEXTAUTH_URL="http://localhost:3000"
|
|
768
|
+
NEXTAUTH_SECRET="your-secret-here"
|
|
769
|
+
|
|
770
|
+
# OAuth (if using)
|
|
771
|
+
# GOOGLE_CLIENT_ID=""
|
|
772
|
+
# GOOGLE_CLIENT_SECRET=""
|
|
773
|
+
# GITHUB_CLIENT_ID=""
|
|
774
|
+
# GITHUB_CLIENT_SECRET=""
|
|
775
|
+
`;
|
|
776
|
+
function setupDotenvx(options) {
|
|
777
|
+
const { targetDir, conflictStrategy } = options;
|
|
778
|
+
addDependencies(targetDir, {
|
|
779
|
+
"@dotenvx/dotenvx": "^1.29.0"
|
|
780
|
+
});
|
|
781
|
+
addScripts(targetDir, {
|
|
782
|
+
"env:encrypt": "dotenvx encrypt",
|
|
783
|
+
"env:decrypt": "dotenvx decrypt"
|
|
784
|
+
});
|
|
785
|
+
const envExamplePath = join5(targetDir, ".env.example");
|
|
786
|
+
writeWithStrategy(envExamplePath, ENV_EXAMPLE_CONTENT, conflictStrategy);
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
// src/generators/tools/volta.ts
|
|
790
|
+
import { join as join6 } from "path";
|
|
791
|
+
var NODE_VERSION = "22.16.0";
|
|
792
|
+
var PNPM_VERSION = "9.15.0";
|
|
793
|
+
var NODE_VERSION_CONTENT = `${NODE_VERSION}
|
|
794
|
+
`;
|
|
795
|
+
function setupVolta(options) {
|
|
796
|
+
const { targetDir, conflictStrategy } = options;
|
|
797
|
+
addVoltaField(targetDir, NODE_VERSION, PNPM_VERSION);
|
|
798
|
+
const nodeVersionPath = join6(targetDir, ".node-version");
|
|
799
|
+
writeWithStrategy(nodeVersionPath, NODE_VERSION_CONTENT, conflictStrategy);
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
// src/generators/tools/biome.ts
|
|
803
|
+
import { join as join7 } from "path";
|
|
804
|
+
var BIOME_CONFIG = `{
|
|
805
|
+
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
|
|
806
|
+
"vcs": {
|
|
807
|
+
"enabled": true,
|
|
808
|
+
"clientKind": "git",
|
|
809
|
+
"useIgnoreFile": true
|
|
810
|
+
},
|
|
811
|
+
"files": {
|
|
812
|
+
"ignoreUnknown": false,
|
|
813
|
+
"ignore": ["node_modules", "dist", ".next", "out", "build", "coverage"]
|
|
814
|
+
},
|
|
815
|
+
"formatter": {
|
|
816
|
+
"enabled": true,
|
|
817
|
+
"indentStyle": "space",
|
|
818
|
+
"indentWidth": 2,
|
|
819
|
+
"lineEnding": "lf",
|
|
820
|
+
"lineWidth": 100
|
|
821
|
+
},
|
|
822
|
+
"organizeImports": {
|
|
823
|
+
"enabled": true
|
|
824
|
+
},
|
|
825
|
+
"linter": {
|
|
826
|
+
"enabled": true,
|
|
827
|
+
"rules": {
|
|
828
|
+
"recommended": true
|
|
829
|
+
}
|
|
830
|
+
},
|
|
831
|
+
"javascript": {
|
|
832
|
+
"formatter": {
|
|
833
|
+
"quoteStyle": "double",
|
|
834
|
+
"trailingCommas": "es5",
|
|
835
|
+
"semicolons": "always",
|
|
836
|
+
"arrowParentheses": "always"
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
`;
|
|
841
|
+
var VSCODE_SETTINGS = `{
|
|
842
|
+
"editor.defaultFormatter": "biomejs.biome",
|
|
843
|
+
"editor.formatOnSave": true,
|
|
844
|
+
"editor.codeActionsOnSave": {
|
|
845
|
+
"quickfix.biome": "explicit",
|
|
846
|
+
"source.organizeImports.biome": "explicit"
|
|
847
|
+
},
|
|
848
|
+
"[javascript]": {
|
|
849
|
+
"editor.defaultFormatter": "biomejs.biome"
|
|
850
|
+
},
|
|
851
|
+
"[typescript]": {
|
|
852
|
+
"editor.defaultFormatter": "biomejs.biome"
|
|
853
|
+
},
|
|
854
|
+
"[json]": {
|
|
855
|
+
"editor.defaultFormatter": "biomejs.biome"
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
`;
|
|
859
|
+
function setupBiome(options) {
|
|
860
|
+
const { targetDir, conflictStrategy } = options;
|
|
861
|
+
const biomeConfigPath = join7(targetDir, "biome.json");
|
|
862
|
+
writeWithStrategy(biomeConfigPath, BIOME_CONFIG, conflictStrategy);
|
|
863
|
+
addDependencies(
|
|
864
|
+
targetDir,
|
|
865
|
+
{
|
|
866
|
+
"@biomejs/biome": "^1.9.4"
|
|
867
|
+
},
|
|
868
|
+
true
|
|
869
|
+
);
|
|
870
|
+
addScripts(targetDir, {
|
|
871
|
+
lint: "biome lint .",
|
|
872
|
+
"lint:fix": "biome lint --write .",
|
|
873
|
+
format: "biome format .",
|
|
874
|
+
"format:fix": "biome format --write ."
|
|
875
|
+
});
|
|
876
|
+
const vscodeDir = join7(targetDir, ".vscode");
|
|
877
|
+
ensureDir(vscodeDir);
|
|
878
|
+
const vscodeSettingsPath = join7(vscodeDir, "settings.json");
|
|
879
|
+
writeWithStrategy(vscodeSettingsPath, VSCODE_SETTINGS, conflictStrategy);
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
// src/generators/tools/husky.ts
|
|
883
|
+
import { join as join8 } from "path";
|
|
884
|
+
import { writeFileSync as writeFileSync4 } from "fs";
|
|
885
|
+
var PRE_COMMIT_HOOK = `#!/usr/bin/env sh
|
|
886
|
+
. "$(dirname -- "$0")/_/husky.sh"
|
|
887
|
+
|
|
888
|
+
pnpm lint-staged
|
|
889
|
+
`;
|
|
890
|
+
function setupHusky(options) {
|
|
891
|
+
const { targetDir } = options;
|
|
892
|
+
addDependencies(
|
|
893
|
+
targetDir,
|
|
894
|
+
{
|
|
895
|
+
husky: "^9.1.7",
|
|
896
|
+
"lint-staged": "^15.2.11"
|
|
897
|
+
},
|
|
898
|
+
true
|
|
899
|
+
);
|
|
900
|
+
addScripts(targetDir, {
|
|
901
|
+
prepare: "husky"
|
|
902
|
+
});
|
|
903
|
+
addLintStaged(targetDir, {
|
|
904
|
+
"*.{js,jsx,ts,tsx}": ["biome format --write", "biome lint --write"],
|
|
905
|
+
"*.{json,md,yml,yaml}": ["biome format --write"]
|
|
906
|
+
});
|
|
907
|
+
const huskyDir = join8(targetDir, ".husky");
|
|
908
|
+
ensureDir(huskyDir);
|
|
909
|
+
const preCommitPath = join8(huskyDir, "pre-commit");
|
|
910
|
+
writeFileSync4(preCommitPath, PRE_COMMIT_HOOK, { mode: 493 });
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
// src/commands/setup.ts
|
|
914
|
+
async function setupCommand() {
|
|
915
|
+
const targetDir = process.cwd();
|
|
916
|
+
const packageJsonPath2 = join9(targetDir, "package.json");
|
|
917
|
+
if (!existsSync4(packageJsonPath2)) {
|
|
918
|
+
error("\u30A8\u30E9\u30FC: package.json\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093");
|
|
919
|
+
info("\u3053\u306E\u30B3\u30DE\u30F3\u30C9\u306F\u65E2\u5B58\u306E\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3067\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
920
|
+
process.exit(1);
|
|
921
|
+
}
|
|
922
|
+
info("\u65E2\u5B58\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u3078\u306E\u30C4\u30FC\u30EB\u8FFD\u52A0\u3092\u958B\u59CB\u3057\u307E\u3059");
|
|
923
|
+
info("");
|
|
924
|
+
const config = await promptSetupConfig();
|
|
925
|
+
info("");
|
|
926
|
+
info("\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3092\u958B\u59CB\u3057\u307E\u3059...");
|
|
927
|
+
info("");
|
|
928
|
+
const options = {
|
|
929
|
+
targetDir,
|
|
930
|
+
conflictStrategy: config.conflictStrategy
|
|
931
|
+
};
|
|
932
|
+
let setupCount = 0;
|
|
933
|
+
if (config.tools.direnv) {
|
|
934
|
+
const spin = ora3("direnv \u3092\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3057\u3066\u3044\u307E\u3059...").start();
|
|
935
|
+
try {
|
|
936
|
+
setupDirenv(options);
|
|
937
|
+
spin.succeed("direnv \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u5B8C\u4E86");
|
|
938
|
+
setupCount++;
|
|
939
|
+
} catch (error2) {
|
|
940
|
+
spin.fail("direnv \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u5931\u6557");
|
|
941
|
+
error(
|
|
942
|
+
error2 instanceof Error ? error2.message : "\u4E88\u671F\u3057\u306A\u3044\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F"
|
|
943
|
+
);
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
if (config.tools.dotenvx) {
|
|
947
|
+
const spin = ora3("dotenvx \u3092\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3057\u3066\u3044\u307E\u3059...").start();
|
|
948
|
+
try {
|
|
949
|
+
setupDotenvx(options);
|
|
950
|
+
spin.succeed("dotenvx \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u5B8C\u4E86");
|
|
951
|
+
setupCount++;
|
|
952
|
+
} catch (error2) {
|
|
953
|
+
spin.fail("dotenvx \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u5931\u6557");
|
|
954
|
+
error(
|
|
955
|
+
error2 instanceof Error ? error2.message : "\u4E88\u671F\u3057\u306A\u3044\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F"
|
|
956
|
+
);
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
if (config.tools.volta) {
|
|
960
|
+
const spin = ora3("Volta \u3092\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3057\u3066\u3044\u307E\u3059...").start();
|
|
961
|
+
try {
|
|
962
|
+
setupVolta(options);
|
|
963
|
+
spin.succeed("Volta \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u5B8C\u4E86");
|
|
964
|
+
setupCount++;
|
|
965
|
+
} catch (error2) {
|
|
966
|
+
spin.fail("Volta \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u5931\u6557");
|
|
967
|
+
error(
|
|
968
|
+
error2 instanceof Error ? error2.message : "\u4E88\u671F\u3057\u306A\u3044\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F"
|
|
969
|
+
);
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
if (config.tools.biome) {
|
|
973
|
+
const spin = ora3("Biome \u3092\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3057\u3066\u3044\u307E\u3059...").start();
|
|
974
|
+
try {
|
|
975
|
+
setupBiome(options);
|
|
976
|
+
spin.succeed("Biome \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u5B8C\u4E86");
|
|
977
|
+
setupCount++;
|
|
978
|
+
} catch (error2) {
|
|
979
|
+
spin.fail("Biome \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u5931\u6557");
|
|
980
|
+
error(
|
|
981
|
+
error2 instanceof Error ? error2.message : "\u4E88\u671F\u3057\u306A\u3044\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F"
|
|
982
|
+
);
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
if (config.tools.husky) {
|
|
986
|
+
const spin = ora3("Husky \u3092\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3057\u3066\u3044\u307E\u3059...").start();
|
|
987
|
+
try {
|
|
988
|
+
setupHusky(options);
|
|
989
|
+
spin.succeed("Husky \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u5B8C\u4E86");
|
|
990
|
+
setupCount++;
|
|
991
|
+
} catch (error2) {
|
|
992
|
+
spin.fail("Husky \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u5931\u6557");
|
|
993
|
+
error(
|
|
994
|
+
error2 instanceof Error ? error2.message : "\u4E88\u671F\u3057\u306A\u3044\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F"
|
|
995
|
+
);
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
info("");
|
|
999
|
+
if (config.tools.direnv) {
|
|
1000
|
+
await promptDirenvAllow(targetDir);
|
|
1001
|
+
info("");
|
|
1002
|
+
}
|
|
1003
|
+
success(`\u2705 \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u304C\u5B8C\u4E86\u3057\u307E\u3057\u305F\uFF01\uFF08${setupCount}\u500B\u306E\u30C4\u30FC\u30EB\uFF09`);
|
|
1004
|
+
info("");
|
|
1005
|
+
info("\u6B21\u306E\u30B9\u30C6\u30C3\u30D7:");
|
|
1006
|
+
if (config.tools.direnv) {
|
|
1007
|
+
info(" 1. .envrc \u3092\u7DE8\u96C6\u3057\u3066\u74B0\u5883\u5909\u6570\u3092\u8A2D\u5B9A");
|
|
1008
|
+
info(" 2. direnv allow \u3092\u5B9F\u884C\uFF08\u307E\u3060\u306E\u5834\u5408\uFF09");
|
|
1009
|
+
}
|
|
1010
|
+
if (config.tools.dotenvx) {
|
|
1011
|
+
info(" - .env.example \u3092\u30B3\u30D4\u30FC\u3057\u3066 .env \u3092\u4F5C\u6210");
|
|
1012
|
+
info(" - \u5FC5\u8981\u306B\u5FDC\u3058\u3066 pnpm env:encrypt \u3067\u6697\u53F7\u5316");
|
|
1013
|
+
}
|
|
1014
|
+
if (config.tools.biome) {
|
|
1015
|
+
info(" - pnpm lint \u3067\u30B3\u30FC\u30C9\u3092\u30C1\u30A7\u30C3\u30AF");
|
|
1016
|
+
info(" - pnpm format:fix \u3067\u30D5\u30A9\u30FC\u30DE\u30C3\u30C8");
|
|
1017
|
+
}
|
|
1018
|
+
if (config.tools.husky) {
|
|
1019
|
+
info(" - pnpm install \u3067Husky\u30D5\u30C3\u30AF\u3092\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB");
|
|
1020
|
+
}
|
|
1021
|
+
info("");
|
|
1022
|
+
success("\u958B\u767A\u3092\u958B\u59CB\u3067\u304D\u307E\u3059\uFF01");
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
// src/cli.ts
|
|
1026
|
+
var __filename2 = fileURLToPath2(import.meta.url);
|
|
1027
|
+
var __dirname2 = dirname3(__filename2);
|
|
1028
|
+
var packageJsonPath = join10(__dirname2, "../package.json");
|
|
1029
|
+
var packageJson = JSON.parse(readFileSync4(packageJsonPath, "utf-8"));
|
|
1030
|
+
var program = new Command();
|
|
1031
|
+
program.name("create-einja-app").description("CLI tool to create new projects with Einja Management Template").version(packageJson.version);
|
|
1032
|
+
program.argument("[project-name]", "Project name").option("--template <template>", "Template to use", "turborepo-pandacss").option("--skip-git", "Skip git initialization").option("--skip-install", "Skip package installation").option("-y, --yes", "Skip interactive prompts").action(
|
|
1033
|
+
async (projectName, options) => {
|
|
1034
|
+
await createCommand(projectName, options);
|
|
1035
|
+
}
|
|
1036
|
+
);
|
|
1037
|
+
program.command("setup").description("Setup tools for existing project").action(async () => {
|
|
1038
|
+
await setupCommand();
|
|
1039
|
+
});
|
|
1040
|
+
program.parse();
|
|
1041
|
+
//# sourceMappingURL=cli.js.map
|