260703_01_FST: First Commit
This commit is contained in:
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
node_modules/
|
||||
dist/
|
||||
*.tgz
|
||||
.idea/
|
||||
*.iml
|
||||
2
.npmrc
Normal file
2
.npmrc
Normal file
@@ -0,0 +1,2 @@
|
||||
@kri:registry=https://gitea.kric.com/api/packages/KRi/npm/
|
||||
//gitea.kric.com/api/packages/KRi/npm/:_authToken=${GITEA_NPM_TOKEN}
|
||||
57
README.md
Normal file
57
README.md
Normal file
@@ -0,0 +1,57 @@
|
||||
# @kri/create-next-app
|
||||
|
||||
KRI 표준 Next.js 프로젝트 생성 CLI입니다.
|
||||
|
||||
## 사전 준비
|
||||
|
||||
사용자 npm 설정에서 `@kri` scope와 Gitea 토큰이 설정되어 있어야 합니다.
|
||||
|
||||
```ini
|
||||
@kri:registry=https://gitea.kric.com/api/packages/KRi/npm/
|
||||
//gitea.kric.com/api/packages/KRi/npm/:_authToken=${GITEA_NPM_TOKEN}
|
||||
```
|
||||
|
||||
## 개발
|
||||
|
||||
```powershell
|
||||
npm install
|
||||
npm run typecheck
|
||||
npm run build
|
||||
node .\dist\cli.js test-front --yes --skip-install
|
||||
```
|
||||
|
||||
## 사용
|
||||
|
||||
```powershell
|
||||
npx @kri/create-next-app survey-front
|
||||
```
|
||||
|
||||
질문 없이 기본값으로 생성:
|
||||
|
||||
```powershell
|
||||
npx @kri/create-next-app survey-front --yes
|
||||
```
|
||||
|
||||
주요 옵션은 `--help`로 확인합니다.
|
||||
|
||||
## 생성 과정
|
||||
|
||||
1. 표준 템플릿 복사
|
||||
2. Next.js 및 shadcn 호환 npm 의존성 설치
|
||||
3. `@kri/common@latest` 설치 후 exact 버전 기록
|
||||
4. KRI UI Registry 9개 항목 설치
|
||||
5. TypeScript 검사
|
||||
6. Next.js production build
|
||||
|
||||
UI Registry: `https://ui-registry.kric.com/r`
|
||||
|
||||
## 생성되는 환경 파일
|
||||
|
||||
`.env`, `.env.local`, `.env.development`, `.env.production`, `.env.example`을 생성합니다. `.env.local`과 `.env`는 기본적으로 Git에서 제외되며, `.env.development`와 `.env.production`은 Jenkins 빌드에 사용할 수 있도록 추적 가능합니다.
|
||||
|
||||
|
||||
## 호환성 정책
|
||||
|
||||
- `@kri/common`은 프로젝트 생성 시점의 최신 버전을 설치하고 exact 버전으로 기록합니다.
|
||||
- Next.js 생태계 호환성을 위해 생성 프로젝트의 TypeScript는 최신 5.x, ESLint는 최신 9.x를 사용합니다.
|
||||
- shadcn 기본 컴포넌트가 사용하는 `class-variance-authority`, `clsx`, `tailwind-merge`, `lucide-react`를 기본 의존성에 포함합니다.
|
||||
176
package-lock.json
generated
Normal file
176
package-lock.json
generated
Normal file
@@ -0,0 +1,176 @@
|
||||
{
|
||||
"name": "@kri/create-next-app",
|
||||
"version": "0.1.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@kri/create-next-app",
|
||||
"version": "0.1.0",
|
||||
"license": "UNLICENSED",
|
||||
"bin": {
|
||||
"kri-create-next-app": "dist/cli.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "latest",
|
||||
"rimraf": "latest",
|
||||
"typescript": "latest"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "26.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-26.1.0.tgz",
|
||||
"integrity": "sha512-O0A1G3xPGy4w7AgQdAQYUlQ+BKk2Oovw8eRpofyp5KdBZULnbe+WqaOVNrm705SHphCiG4XHsACrSmPu1f+Kgw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"undici-types": "~8.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/balanced-match": {
|
||||
"version": "4.0.4",
|
||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz",
|
||||
"integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": "18 || 20 || >=22"
|
||||
}
|
||||
},
|
||||
"node_modules/brace-expansion": {
|
||||
"version": "5.0.7",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.7.tgz",
|
||||
"integrity": "sha512-7oFy703dxfY3/NLxC1fh2SUCQ0H9rmAY+5EpDVfXjUTTs+HEwR2nYaqLv+GWcTsumwxPfiz6CzCNkwXwBUwqCA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"balanced-match": "^4.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": "18 || 20 || >=22"
|
||||
}
|
||||
},
|
||||
"node_modules/glob": {
|
||||
"version": "13.0.6",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-13.0.6.tgz",
|
||||
"integrity": "sha512-Wjlyrolmm8uDpm/ogGyXZXb1Z+Ca2B8NbJwqBVg0axK9GbBeoS7yGV6vjXnYdGm6X53iehEuxxbyiKp8QmN4Vw==",
|
||||
"dev": true,
|
||||
"license": "BlueOak-1.0.0",
|
||||
"dependencies": {
|
||||
"minimatch": "^10.2.2",
|
||||
"minipass": "^7.1.3",
|
||||
"path-scurry": "^2.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": "18 || 20 || >=22"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/lru-cache": {
|
||||
"version": "11.5.1",
|
||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.1.tgz",
|
||||
"integrity": "sha512-RPimw/7aMdv2oqRrxKwvZXcPfwBrn/JZ2xYcY9Hus/6LaS3VOAKVWKWgNLCFSiOm1ESXinjsDlidVU7JlnCN2A==",
|
||||
"dev": true,
|
||||
"license": "BlueOak-1.0.0",
|
||||
"engines": {
|
||||
"node": "20 || >=22"
|
||||
}
|
||||
},
|
||||
"node_modules/minimatch": {
|
||||
"version": "10.2.5",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.5.tgz",
|
||||
"integrity": "sha512-MULkVLfKGYDFYejP07QOurDLLQpcjk7Fw+7jXS2R2czRQzR56yHRveU5NDJEOviH+hETZKSkIk5c+T23GjFUMg==",
|
||||
"dev": true,
|
||||
"license": "BlueOak-1.0.0",
|
||||
"dependencies": {
|
||||
"brace-expansion": "^5.0.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": "18 || 20 || >=22"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/minipass": {
|
||||
"version": "7.1.3",
|
||||
"resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.3.tgz",
|
||||
"integrity": "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==",
|
||||
"dev": true,
|
||||
"license": "BlueOak-1.0.0",
|
||||
"engines": {
|
||||
"node": ">=16 || 14 >=14.17"
|
||||
}
|
||||
},
|
||||
"node_modules/package-json-from-dist": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz",
|
||||
"integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==",
|
||||
"dev": true,
|
||||
"license": "BlueOak-1.0.0"
|
||||
},
|
||||
"node_modules/path-scurry": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.2.tgz",
|
||||
"integrity": "sha512-3O/iVVsJAPsOnpwWIeD+d6z/7PmqApyQePUtCndjatj/9I5LylHvt5qluFaBT3I5h3r1ejfR056c+FCv+NnNXg==",
|
||||
"dev": true,
|
||||
"license": "BlueOak-1.0.0",
|
||||
"dependencies": {
|
||||
"lru-cache": "^11.0.0",
|
||||
"minipass": "^7.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": "18 || 20 || >=22"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/rimraf": {
|
||||
"version": "6.1.3",
|
||||
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-6.1.3.tgz",
|
||||
"integrity": "sha512-LKg+Cr2ZF61fkcaK1UdkH2yEBBKnYjTyWzTJT6KNPcSPaiT7HSdhtMXQuN5wkTX0Xu72KQ1l8S42rlmexS2hSA==",
|
||||
"dev": true,
|
||||
"license": "BlueOak-1.0.0",
|
||||
"dependencies": {
|
||||
"glob": "^13.0.3",
|
||||
"package-json-from-dist": "^1.0.1"
|
||||
},
|
||||
"bin": {
|
||||
"rimraf": "dist/esm/bin.mjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": "20 || >=22"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "6.0.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.3.tgz",
|
||||
"integrity": "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.17"
|
||||
}
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
"version": "8.3.0",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.3.0.tgz",
|
||||
"integrity": "sha512-j375ScV60dom+YkPFIfTLcOiPxkN/buHz5GobjLhixFuANaNs3C9l4GmrWqejgXWJ7BbJcFYpTEUkS1Ge8bpZQ==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
}
|
||||
33
package.json
Normal file
33
package.json
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "@kri/create-next-app",
|
||||
"version": "0.1.0",
|
||||
"description": "Create a KRI standard Next.js application",
|
||||
"type": "module",
|
||||
"bin": {
|
||||
"kri-create-next-app": "./dist/cli.js"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"templates",
|
||||
"README.md"
|
||||
],
|
||||
"scripts": {
|
||||
"clean": "rimraf dist",
|
||||
"build": "npm run clean && tsc -p tsconfig.json",
|
||||
"typecheck": "tsc -p tsconfig.json --noEmit",
|
||||
"prepack": "npm run build"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "latest",
|
||||
"rimraf": "latest",
|
||||
"typescript": "latest"
|
||||
},
|
||||
"publishConfig": {
|
||||
"registry": "https://gitea.kric.com/api/packages/KRi/npm/",
|
||||
"access": "restricted"
|
||||
},
|
||||
"license": "UNLICENSED"
|
||||
}
|
||||
130
src/args.ts
Normal file
130
src/args.ts
Normal file
@@ -0,0 +1,130 @@
|
||||
import path from "node:path";
|
||||
import type { ParsedArguments } from "./types.js";
|
||||
|
||||
const requireValue = (args: string[], index: number, option: string): string => {
|
||||
const value = args[index + 1];
|
||||
if (!value || value.startsWith("-")) {
|
||||
throw new Error(`${option} 옵션의 값이 필요합니다.`);
|
||||
}
|
||||
return value;
|
||||
};
|
||||
|
||||
export function parseArguments(argv: string[]): ParsedArguments {
|
||||
const parsed: ParsedArguments = {
|
||||
yes: false,
|
||||
install: true,
|
||||
installUi: true,
|
||||
build: true,
|
||||
jenkins: true,
|
||||
force: false,
|
||||
help: false,
|
||||
};
|
||||
|
||||
for (let index = 0; index < argv.length; index += 1) {
|
||||
const arg = argv[index];
|
||||
|
||||
if (!arg.startsWith("-")) {
|
||||
if (parsed.projectName) throw new Error(`알 수 없는 인자입니다: ${arg}`);
|
||||
parsed.projectName = arg;
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (arg) {
|
||||
case "--help":
|
||||
case "-h":
|
||||
parsed.help = true;
|
||||
break;
|
||||
case "--yes":
|
||||
case "-y":
|
||||
parsed.yes = true;
|
||||
break;
|
||||
case "--force":
|
||||
parsed.force = true;
|
||||
break;
|
||||
case "--skip-install":
|
||||
parsed.install = false;
|
||||
parsed.installUi = false;
|
||||
parsed.build = false;
|
||||
break;
|
||||
case "--skip-ui":
|
||||
parsed.installUi = false;
|
||||
break;
|
||||
case "--skip-build":
|
||||
parsed.build = false;
|
||||
break;
|
||||
case "--no-jenkins":
|
||||
parsed.jenkins = false;
|
||||
break;
|
||||
case "--target-dir":
|
||||
parsed.targetDir = path.resolve(requireValue(argv, index, arg));
|
||||
index += 1;
|
||||
break;
|
||||
case "--display-name":
|
||||
parsed.displayName = requireValue(argv, index, arg);
|
||||
index += 1;
|
||||
break;
|
||||
case "--description":
|
||||
parsed.description = requireValue(argv, index, arg);
|
||||
index += 1;
|
||||
break;
|
||||
case "--port": {
|
||||
const value = Number(requireValue(argv, index, arg));
|
||||
if (!Number.isInteger(value) || value < 1 || value > 65535) {
|
||||
throw new Error("--port는 1~65535 사이의 정수여야 합니다.");
|
||||
}
|
||||
parsed.port = value;
|
||||
index += 1;
|
||||
break;
|
||||
}
|
||||
case "--repo-url":
|
||||
parsed.repoUrl = requireValue(argv, index, arg);
|
||||
index += 1;
|
||||
break;
|
||||
case "--app-root":
|
||||
parsed.appRoot = requireValue(argv, index, arg);
|
||||
index += 1;
|
||||
break;
|
||||
case "--service-name":
|
||||
parsed.serviceName = requireValue(argv, index, arg);
|
||||
index += 1;
|
||||
break;
|
||||
case "--branch":
|
||||
parsed.branch = requireValue(argv, index, arg);
|
||||
index += 1;
|
||||
break;
|
||||
case "--agent-label":
|
||||
parsed.agentLabel = requireValue(argv, index, arg);
|
||||
index += 1;
|
||||
break;
|
||||
default:
|
||||
throw new Error(`알 수 없는 옵션입니다: ${arg}`);
|
||||
}
|
||||
}
|
||||
|
||||
return parsed;
|
||||
}
|
||||
|
||||
export function printHelp(): void {
|
||||
console.log(`
|
||||
사용법:
|
||||
npx @kri/create-next-app <project-name> [options]
|
||||
|
||||
옵션:
|
||||
--display-name <name> 화면 표시 이름
|
||||
--description <text> 프로젝트 설명
|
||||
--port <number> 개발/실행 포트 (기본 4000)
|
||||
--repo-url <url> Gitea 저장소 URL
|
||||
--app-root <path> Ubuntu 배포 경로
|
||||
--service-name <name> systemd 서비스 이름
|
||||
--branch <name> 배포 브랜치 (기본 master)
|
||||
--agent-label <label> Jenkins Agent label (기본 ubuntu-build)
|
||||
--target-dir <path> 생성 경로
|
||||
--yes, -y 질문 없이 기본값 사용
|
||||
--skip-install npm 설치, UI 설치, 검증 생략
|
||||
--skip-ui KRI UI Registry 설치 생략
|
||||
--skip-build typecheck/build 생략
|
||||
--no-jenkins Jenkinsfile 생성 안 함
|
||||
--force 비어 있지 않은 대상 폴더 사용
|
||||
--help, -h 도움말
|
||||
`);
|
||||
}
|
||||
97
src/cli.ts
Normal file
97
src/cli.ts
Normal file
@@ -0,0 +1,97 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import path from "node:path";
|
||||
import process from "node:process";
|
||||
import { parseArguments, printHelp } from "./args.js";
|
||||
import { createProject } from "./create-project.js";
|
||||
import { ask, confirm } from "./prompts.js";
|
||||
import type { CliOptions } from "./types.js";
|
||||
|
||||
const PROJECT_NAME_PATTERN = /^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/;
|
||||
|
||||
function validateProjectName(name: string): string {
|
||||
const normalized = name.trim();
|
||||
if (!PROJECT_NAME_PATTERN.test(normalized)) {
|
||||
throw new Error("프로젝트명은 npm package 이름으로 사용할 수 있는 영문 소문자, 숫자, -, _, . 조합이어야 합니다.");
|
||||
}
|
||||
return normalized;
|
||||
}
|
||||
|
||||
async function resolveOptions(): Promise<CliOptions> {
|
||||
const parsed = parseArguments(process.argv.slice(2));
|
||||
if (parsed.help) {
|
||||
printHelp();
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
let projectName = parsed.projectName;
|
||||
if (!projectName && !parsed.yes) projectName = await ask("프로젝트명");
|
||||
if (!projectName) throw new Error("프로젝트명이 필요합니다.");
|
||||
projectName = validateProjectName(projectName);
|
||||
|
||||
const displayName = parsed.displayName
|
||||
?? (parsed.yes ? projectName : await ask("프로젝트 표시 이름", projectName));
|
||||
const description = parsed.description
|
||||
?? (parsed.yes ? `${displayName} 시스템` : await ask("프로젝트 설명", `${displayName} 시스템`));
|
||||
const portText = parsed.port
|
||||
? String(parsed.port)
|
||||
: parsed.yes
|
||||
? "4000"
|
||||
: await ask("개발/실행 포트", "4000");
|
||||
const port = Number(portText);
|
||||
if (!Number.isInteger(port) || port < 1 || port > 65535) throw new Error("포트는 1~65535 사이의 정수여야 합니다.");
|
||||
|
||||
const repoDefault = `https://gitea.kric.com/Project/${projectName}.git`;
|
||||
const repoUrl = parsed.repoUrl ?? (parsed.yes ? repoDefault : await ask("Gitea Repository URL", repoDefault));
|
||||
const appRootDefault = `/opt/project/${projectName}`;
|
||||
const appRoot = parsed.appRoot ?? (parsed.yes ? appRootDefault : await ask("Ubuntu 배포 경로", appRootDefault));
|
||||
const serviceDefault = `${projectName}.service`;
|
||||
const serviceName = parsed.serviceName ?? (parsed.yes ? serviceDefault : await ask("systemd 서비스 이름", serviceDefault));
|
||||
const branch = parsed.branch ?? "master";
|
||||
const agentLabel = parsed.agentLabel ?? "ubuntu-build";
|
||||
const targetDir = parsed.targetDir ?? path.resolve(process.cwd(), projectName);
|
||||
const jenkins = parsed.yes ? parsed.jenkins : parsed.jenkins && await confirm("Jenkinsfile을 생성할까요?", true);
|
||||
|
||||
return {
|
||||
projectName,
|
||||
targetDir,
|
||||
displayName,
|
||||
description,
|
||||
port,
|
||||
repoUrl,
|
||||
appRoot,
|
||||
serviceName,
|
||||
branch,
|
||||
agentLabel,
|
||||
yes: parsed.yes,
|
||||
install: parsed.install,
|
||||
installUi: parsed.installUi,
|
||||
build: parsed.build,
|
||||
jenkins,
|
||||
force: parsed.force,
|
||||
};
|
||||
}
|
||||
|
||||
async function main(): Promise<void> {
|
||||
const major = Number(process.versions.node.split(".")[0]);
|
||||
if (major < 20) throw new Error(`Node.js 20 이상이 필요합니다. 현재: ${process.version}`);
|
||||
|
||||
const options = await resolveOptions();
|
||||
console.log(`
|
||||
[KRI] ${options.projectName} 생성 시작`);
|
||||
console.log(`[KRI] target=${options.targetDir}`);
|
||||
|
||||
await createProject(options);
|
||||
|
||||
console.log("\n[KRI] 프로젝트 생성 완료");
|
||||
console.log(` cd ${options.targetDir}`);
|
||||
if (!options.install) console.log(" npm install");
|
||||
console.log(` npm run dev`);
|
||||
}
|
||||
|
||||
main().catch((error: unknown) => {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
console.error(`
|
||||
[ERROR] ${message}`);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
13
src/constants.ts
Normal file
13
src/constants.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
export const REGISTRY_BASE_URL = "https://ui-registry.kric.com/r";
|
||||
|
||||
export const KRI_REGISTRY_ITEMS = [
|
||||
"kri-select",
|
||||
"kri-date-range-picker",
|
||||
"kri-password",
|
||||
"kri-auto-complete",
|
||||
"kri-data-table",
|
||||
"kri-loading-overlay",
|
||||
"kri-editor",
|
||||
"kri-layout",
|
||||
"kri-dialog",
|
||||
] as const;
|
||||
114
src/create-project.ts
Normal file
114
src/create-project.ts
Normal file
@@ -0,0 +1,114 @@
|
||||
import { fileURLToPath } from "node:url";
|
||||
import path from "node:path";
|
||||
import { writeFile } from "node:fs/promises";
|
||||
import { KRI_REGISTRY_ITEMS, REGISTRY_BASE_URL } from "./constants.js";
|
||||
import { copyTemplate, ensureTargetDirectory, removeJenkinsfile, replacePlaceholders } from "./files.js";
|
||||
import { run } from "./process.js";
|
||||
import type { CliOptions } from "./types.js";
|
||||
|
||||
const currentDir = path.dirname(fileURLToPath(import.meta.url));
|
||||
const templateDir = path.resolve(currentDir, "../templates/base");
|
||||
|
||||
function packageJson(options: CliOptions) {
|
||||
return {
|
||||
name: options.projectName,
|
||||
version: "0.1.0",
|
||||
private: true,
|
||||
scripts: {
|
||||
dev: `next dev -p ${options.port}`,
|
||||
build: "next build",
|
||||
start: `next start -p ${options.port}`,
|
||||
lint: "eslint",
|
||||
typecheck: "tsc --noEmit",
|
||||
},
|
||||
dependencies: {
|
||||
"@kri/common": "latest",
|
||||
"@tanstack/react-query": "latest",
|
||||
"class-variance-authority": "latest",
|
||||
clsx: "latest",
|
||||
jotai: "latest",
|
||||
"lucide-react": "latest",
|
||||
next: "latest",
|
||||
react: "latest",
|
||||
"react-dom": "latest",
|
||||
"server-only": "latest",
|
||||
sonner: "latest",
|
||||
"tailwind-merge": "latest",
|
||||
},
|
||||
devDependencies: {
|
||||
"@tailwindcss/postcss": "latest",
|
||||
"@types/node": "latest",
|
||||
"@types/react": "latest",
|
||||
"@types/react-dom": "latest",
|
||||
"babel-plugin-react-compiler": "latest",
|
||||
eslint: "^9",
|
||||
"eslint-config-next": "latest",
|
||||
tailwindcss: "latest",
|
||||
"tw-animate-css": "latest",
|
||||
typescript: "^5",
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export async function createProject(options: CliOptions): Promise<void> {
|
||||
await ensureTargetDirectory(options.targetDir, options.force);
|
||||
await copyTemplate(templateDir, options.targetDir);
|
||||
|
||||
if (!options.jenkins) await removeJenkinsfile(options.targetDir);
|
||||
|
||||
await replacePlaceholders(options.targetDir, {
|
||||
"__PROJECT_NAME__": options.projectName,
|
||||
"__DISPLAY_NAME__": options.displayName,
|
||||
"__DESCRIPTION__": options.description,
|
||||
"__PORT__": String(options.port),
|
||||
"__REPO_URL__": options.repoUrl,
|
||||
"__APP_ROOT__": options.appRoot,
|
||||
"__SERVICE_NAME__": options.serviceName,
|
||||
"__BRANCH__": options.branch,
|
||||
"__AGENT_LABEL__": options.agentLabel,
|
||||
});
|
||||
|
||||
await writeFile(
|
||||
path.join(options.targetDir, "package.json"),
|
||||
`${JSON.stringify(packageJson(options), null, 2)}
|
||||
`,
|
||||
"utf8",
|
||||
);
|
||||
|
||||
if (!options.install) {
|
||||
console.log("[SKIP] npm install");
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("\n[1/4] npm 의존성 설치");
|
||||
await run("npm", ["install"], options.targetDir);
|
||||
|
||||
console.log("\n[2/4] 최신 @kri/common 설치");
|
||||
await run("npm", ["install", "--save-exact", "@kri/common@latest"], options.targetDir);
|
||||
|
||||
if (options.installUi) {
|
||||
console.log("\n[3/4] shadcn 및 KRI UI Registry 설치");
|
||||
await run("npx", ["--yes", "shadcn@latest", "add", "card", "--yes", "--overwrite"], options.targetDir);
|
||||
for (const item of KRI_REGISTRY_ITEMS) {
|
||||
await run(
|
||||
"npx",
|
||||
["--yes", "shadcn@latest", "add", `${REGISTRY_BASE_URL}/${item}.json`, "--yes", "--overwrite"],
|
||||
options.targetDir,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
console.log("[SKIP] UI Registry 설치");
|
||||
}
|
||||
|
||||
if (options.build) {
|
||||
if (!options.installUi) {
|
||||
console.warn("[WARN] --skip-ui 때문에 typecheck/build를 생략합니다.");
|
||||
return;
|
||||
}
|
||||
console.log("\n[4/4] TypeScript 및 production build 검증");
|
||||
await run("npm", ["run", "typecheck"], options.targetDir);
|
||||
await run("npm", ["run", "build"], options.targetDir);
|
||||
} else {
|
||||
console.log("[SKIP] typecheck/build");
|
||||
}
|
||||
}
|
||||
64
src/files.ts
Normal file
64
src/files.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import { cp, mkdir, readdir, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
|
||||
const RENAMES: Record<string, string> = {
|
||||
"_gitignore": ".gitignore",
|
||||
"_npmrc": ".npmrc",
|
||||
"_env": ".env",
|
||||
"_env.local": ".env.local",
|
||||
"_env.development": ".env.development",
|
||||
"_env.production": ".env.production",
|
||||
"_env.example": ".env.example",
|
||||
"README.md.template": "README.md",
|
||||
"Jenkinsfile.template": "Jenkinsfile",
|
||||
};
|
||||
|
||||
export async function ensureTargetDirectory(targetDir: string, force: boolean): Promise<void> {
|
||||
await mkdir(targetDir, { recursive: true });
|
||||
const entries = await readdir(targetDir);
|
||||
if (entries.length > 0 && !force) {
|
||||
throw new Error(`대상 폴더가 비어 있지 않습니다: ${targetDir}
|
||||
--force 옵션을 사용하거나 빈 폴더를 선택하세요.`);
|
||||
}
|
||||
}
|
||||
|
||||
export async function copyTemplate(templateDir: string, targetDir: string): Promise<void> {
|
||||
await cp(templateDir, targetDir, { recursive: true, force: true });
|
||||
|
||||
for (const [sourceName, targetName] of Object.entries(RENAMES)) {
|
||||
const source = path.join(targetDir, sourceName);
|
||||
try {
|
||||
await stat(source);
|
||||
await rename(source, path.join(targetDir, targetName));
|
||||
} catch {
|
||||
// 선택 파일은 없을 수 있습니다.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function removeJenkinsfile(targetDir: string): Promise<void> {
|
||||
await rm(path.join(targetDir, "Jenkinsfile"), { force: true });
|
||||
}
|
||||
|
||||
export async function replacePlaceholders(rootDir: string, replacements: Record<string, string>): Promise<void> {
|
||||
const visit = async (directory: string): Promise<void> => {
|
||||
const entries = await readdir(directory, { withFileTypes: true });
|
||||
for (const entry of entries) {
|
||||
const fullPath = path.join(directory, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
await visit(fullPath);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!entry.isFile() || /\.(png|ico|jpg|jpeg|gif|webp)$/i.test(entry.name)) continue;
|
||||
|
||||
let content = await readFile(fullPath, "utf8");
|
||||
for (const [key, value] of Object.entries(replacements)) {
|
||||
content = content.split(key).join(value);
|
||||
}
|
||||
await writeFile(fullPath, content, "utf8");
|
||||
}
|
||||
};
|
||||
|
||||
await visit(rootDir);
|
||||
}
|
||||
33
src/process.ts
Normal file
33
src/process.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { spawn } from "node:child_process";
|
||||
|
||||
export async function run(command: string, args: string[], cwd: string): Promise<void> {
|
||||
const isWindows = process.platform === "win32";
|
||||
const executable = isWindows ? (process.env.ComSpec ?? "cmd.exe") : command;
|
||||
const executableArgs = isWindows
|
||||
? ["/d", "/s", "/c", `${command}.cmd`, ...args]
|
||||
: args;
|
||||
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
const child = spawn(executable, executableArgs, {
|
||||
cwd,
|
||||
env: process.env,
|
||||
stdio: "inherit",
|
||||
shell: false,
|
||||
windowsHide: true,
|
||||
});
|
||||
|
||||
child.once("error", reject);
|
||||
child.once("exit", (code, signal) => {
|
||||
if (code === 0) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
reject(
|
||||
new Error(
|
||||
`${command} ${args.join(" ")} 실패 (code=${code ?? "null"}, signal=${signal ?? "none"})`,
|
||||
),
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
20
src/prompts.ts
Normal file
20
src/prompts.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { createInterface } from "node:readline/promises";
|
||||
import { stdin as input, stdout as output } from "node:process";
|
||||
|
||||
export async function ask(question: string, defaultValue?: string): Promise<string> {
|
||||
const rl = createInterface({ input, output });
|
||||
try {
|
||||
const suffix = defaultValue ? ` (${defaultValue})` : "";
|
||||
const answer = (await rl.question(`${question}${suffix}: `)).trim();
|
||||
return answer || defaultValue || "";
|
||||
} finally {
|
||||
rl.close();
|
||||
}
|
||||
}
|
||||
|
||||
export async function confirm(question: string, defaultValue = true): Promise<boolean> {
|
||||
const defaultText = defaultValue ? "Y/n" : "y/N";
|
||||
const answer = (await ask(`${question} [${defaultText}]`)).toLowerCase();
|
||||
if (!answer) return defaultValue;
|
||||
return answer === "y" || answer === "yes" || answer === "예";
|
||||
}
|
||||
38
src/types.ts
Normal file
38
src/types.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
export interface CliOptions {
|
||||
projectName: string;
|
||||
targetDir: string;
|
||||
displayName: string;
|
||||
description: string;
|
||||
port: number;
|
||||
repoUrl: string;
|
||||
appRoot: string;
|
||||
serviceName: string;
|
||||
branch: string;
|
||||
agentLabel: string;
|
||||
yes: boolean;
|
||||
install: boolean;
|
||||
installUi: boolean;
|
||||
build: boolean;
|
||||
jenkins: boolean;
|
||||
force: boolean;
|
||||
}
|
||||
|
||||
export interface ParsedArguments {
|
||||
projectName?: string;
|
||||
targetDir?: string;
|
||||
displayName?: string;
|
||||
description?: string;
|
||||
port?: number;
|
||||
repoUrl?: string;
|
||||
appRoot?: string;
|
||||
serviceName?: string;
|
||||
branch?: string;
|
||||
agentLabel?: string;
|
||||
yes: boolean;
|
||||
install: boolean;
|
||||
installUi: boolean;
|
||||
build: boolean;
|
||||
jenkins: boolean;
|
||||
force: boolean;
|
||||
help: boolean;
|
||||
}
|
||||
111
templates/base/Jenkinsfile.template
Normal file
111
templates/base/Jenkinsfile.template
Normal file
@@ -0,0 +1,111 @@
|
||||
pipeline {
|
||||
agent none
|
||||
|
||||
environment {
|
||||
AGENT_LABEL = '__AGENT_LABEL__'
|
||||
|
||||
REPO_URL = '__REPO_URL__'
|
||||
BRANCH = '__BRANCH__'
|
||||
|
||||
SERVICE_NAME = '__SERVICE_NAME__'
|
||||
APP_ROOT = '__APP_ROOT__'
|
||||
|
||||
BUILD_ENV_SOURCE = '.env.production'
|
||||
BUILD_ENV_TARGET = '.env.production'
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Git Pull') {
|
||||
agent { label "${env.AGENT_LABEL}" }
|
||||
steps {
|
||||
deleteDir()
|
||||
dir('src') {
|
||||
git branch: env.BRANCH, url: env.REPO_URL
|
||||
sh '''#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
echo "[INFO] git=$(git --version)"
|
||||
echo "[INFO] branch=$(git rev-parse --abbrev-ref HEAD)"
|
||||
echo "[INFO] commit=$(git rev-parse --short HEAD)"
|
||||
'''
|
||||
}
|
||||
stash name: 'src', includes: 'src/**,src/.*,src/**/.*', excludes: 'src/.git/**'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build') {
|
||||
agent { label "${env.AGENT_LABEL}" }
|
||||
steps {
|
||||
deleteDir()
|
||||
unstash 'src'
|
||||
dir('src') {
|
||||
sh '''#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
: "${BUILD_ENV_SOURCE:?BUILD_ENV_SOURCE is not set}"
|
||||
: "${BUILD_ENV_TARGET:?BUILD_ENV_TARGET is not set}"
|
||||
test -f "${BUILD_ENV_SOURCE}"
|
||||
|
||||
if [ "${BUILD_ENV_SOURCE}" != "${BUILD_ENV_TARGET}" ]; then
|
||||
rm -f "${BUILD_ENV_TARGET}" .env.local .env.production.local || true
|
||||
cp -f "${BUILD_ENV_SOURCE}" "${BUILD_ENV_TARGET}"
|
||||
else
|
||||
rm -f .env.local .env.production.local || true
|
||||
fi
|
||||
|
||||
rm -rf .next out artifact.tgz
|
||||
npm ci
|
||||
nice -n 10 npm run build
|
||||
|
||||
test -f .next/standalone/server.js
|
||||
test -d .next/static
|
||||
test -f .next/BUILD_ID
|
||||
|
||||
mkdir -p out
|
||||
cp -a .next/standalone/. out/
|
||||
mkdir -p out/.next
|
||||
cp -a .next/static out/.next/static
|
||||
cp -a .next/BUILD_ID out/.next/BUILD_ID
|
||||
cp -f "${BUILD_ENV_TARGET}" out/.env.production
|
||||
|
||||
if [ -d public ]; then
|
||||
cp -a public out/public
|
||||
fi
|
||||
|
||||
tar -czf artifact.tgz -C out .
|
||||
'''
|
||||
stash name: 'artifact', includes: 'artifact.tgz'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Apply + Deploy (Local)') {
|
||||
agent { label "${env.AGENT_LABEL}" }
|
||||
steps {
|
||||
deleteDir()
|
||||
unstash 'artifact'
|
||||
sh '''#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
mkdir -p "${APP_ROOT}/releases"
|
||||
TS="$(date +%Y%m%d_%H%M%S)"
|
||||
RELEASE_DIR="${APP_ROOT}/releases/${TS}"
|
||||
mkdir -p "${RELEASE_DIR}"
|
||||
tar -xzf artifact.tgz -C "${RELEASE_DIR}"
|
||||
ln -sfn "${RELEASE_DIR}" "${APP_ROOT}/current"
|
||||
test -f "${APP_ROOT}/current/server.js"
|
||||
test -d "${APP_ROOT}/current/.next/static"
|
||||
test -f "${APP_ROOT}/current/.next/BUILD_ID"
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
||||
stage('Service Restart') {
|
||||
agent { label "${env.AGENT_LABEL}" }
|
||||
steps {
|
||||
sh '''#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
sudo -n /usr/bin/systemctl restart "$SERVICE_NAME"
|
||||
sudo -n /usr/bin/systemctl status "$SERVICE_NAME" --no-pager -l | head -n 80
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
35
templates/base/README.md.template
Normal file
35
templates/base/README.md.template
Normal file
@@ -0,0 +1,35 @@
|
||||
# __DISPLAY_NAME__
|
||||
|
||||
__DESCRIPTION__
|
||||
|
||||
## 실행
|
||||
|
||||
```powershell
|
||||
npm run dev
|
||||
```
|
||||
|
||||
기본 포트: `__PORT__`
|
||||
|
||||
## 환경변수
|
||||
|
||||
프로젝트 생성 시 `.env`, `.env.local`, `.env.development`, `.env.production`, `.env.example`이 함께 생성됩니다.
|
||||
|
||||
- `.env`: 모든 환경 공통값
|
||||
- `.env.local`: 개발자 PC 전용값(Git 제외)
|
||||
- `.env.development`: 개발 빌드값
|
||||
- `.env.production`: 운영 빌드값
|
||||
- `.env.example`: 환경변수 작성 예시
|
||||
|
||||
`.env.local`은 다른 환경 파일보다 우선 적용되므로 운영 빌드에서는 제거하거나 Jenkins 정책에 맞게 관리합니다.
|
||||
|
||||
## 공통 자원
|
||||
|
||||
- npm package: `@kri/common`
|
||||
- UI Registry: `https://ui-registry.kric.com/r`
|
||||
|
||||
## 검증
|
||||
|
||||
```powershell
|
||||
npm run typecheck
|
||||
npm run build
|
||||
```
|
||||
3
templates/base/_env
Normal file
3
templates/base/_env
Normal file
@@ -0,0 +1,3 @@
|
||||
NEXT_PUBLIC_API_BASE=/api
|
||||
NEXT_PUBLIC_STORE_KEY=kri-local-storage-key-32-bytes!!
|
||||
NEXT_PUBLIC_STORE_IV=kri-local-iv-16!
|
||||
3
templates/base/_env.development
Normal file
3
templates/base/_env.development
Normal file
@@ -0,0 +1,3 @@
|
||||
NEXT_PUBLIC_ENV=development
|
||||
ENV=development
|
||||
API_SERVER=http://localhost:8080
|
||||
9
templates/base/_env.example
Normal file
9
templates/base/_env.example
Normal file
@@ -0,0 +1,9 @@
|
||||
# 모든 환경 공통
|
||||
NEXT_PUBLIC_API_BASE=/api
|
||||
NEXT_PUBLIC_STORE_KEY=change-this-storage-key-32-bytes
|
||||
NEXT_PUBLIC_STORE_IV=change-this-iv-16
|
||||
|
||||
# 환경별 값 (.env.local / .env.development / .env.production)
|
||||
NEXT_PUBLIC_ENV=local
|
||||
ENV=local
|
||||
API_SERVER=http://localhost:8080
|
||||
3
templates/base/_env.local
Normal file
3
templates/base/_env.local
Normal file
@@ -0,0 +1,3 @@
|
||||
NEXT_PUBLIC_ENV=local
|
||||
ENV=local
|
||||
API_SERVER=http://localhost:8080
|
||||
3
templates/base/_env.production
Normal file
3
templates/base/_env.production
Normal file
@@ -0,0 +1,3 @@
|
||||
NEXT_PUBLIC_ENV=production
|
||||
ENV=production
|
||||
API_SERVER=https://api.example.com
|
||||
21
templates/base/_gitignore
Normal file
21
templates/base/_gitignore
Normal file
@@ -0,0 +1,21 @@
|
||||
/node_modules
|
||||
/.next
|
||||
/out
|
||||
/build
|
||||
/coverage
|
||||
/.pnp
|
||||
.pnp.*
|
||||
.vercel
|
||||
.DS_Store
|
||||
*.pem
|
||||
*.tsbuildinfo
|
||||
next-env.d.ts
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
.pnpm-debug.log*
|
||||
.env
|
||||
.env.local
|
||||
.env.*.local
|
||||
.idea/
|
||||
*.iml
|
||||
3
templates/base/_npmrc
Normal file
3
templates/base/_npmrc
Normal file
@@ -0,0 +1,3 @@
|
||||
registry=https://registry.npmjs.org/
|
||||
@kri:registry=https://gitea.kric.com/api/packages/KRi/npm/
|
||||
//gitea.kric.com/api/packages/KRi/npm/:_authToken=${GITEA_NPM_TOKEN}
|
||||
22
templates/base/components.json
Normal file
22
templates/base/components.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"$schema": "https://ui.shadcn.com/schema.json",
|
||||
"style": "new-york",
|
||||
"rsc": true,
|
||||
"tsx": true,
|
||||
"tailwind": {
|
||||
"config": "",
|
||||
"css": "src/app/globals.css",
|
||||
"baseColor": "neutral",
|
||||
"cssVariables": true,
|
||||
"prefix": ""
|
||||
},
|
||||
"iconLibrary": "lucide",
|
||||
"aliases": {
|
||||
"components": "@/components",
|
||||
"utils": "@/lib/utils",
|
||||
"ui": "@/components/ui",
|
||||
"lib": "@/lib",
|
||||
"hooks": "@/hooks"
|
||||
},
|
||||
"registries": {}
|
||||
}
|
||||
17
templates/base/eslint.config.mjs
Normal file
17
templates/base/eslint.config.mjs
Normal file
@@ -0,0 +1,17 @@
|
||||
import { defineConfig, globalIgnores } from "eslint/config";
|
||||
import nextVitals from "eslint-config-next/core-web-vitals";
|
||||
import nextTs from "eslint-config-next/typescript";
|
||||
|
||||
export default defineConfig([
|
||||
...nextVitals,
|
||||
...nextTs,
|
||||
globalIgnores([".next/**", "out/**", "build/**", "next-env.d.ts"]),
|
||||
{
|
||||
rules: {
|
||||
"@typescript-eslint/no-floating-promises": "off",
|
||||
"@typescript-eslint/no-explicit-any": "warn",
|
||||
"react-hooks/exhaustive-deps": "off",
|
||||
"react-hooks/set-state-in-effect": "off"
|
||||
}
|
||||
}
|
||||
]);
|
||||
6
templates/base/next.config.ts
Normal file
6
templates/base/next.config.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import type { NextConfig } from "next";
|
||||
import { createKriNextConfig } from "@kri/common/config";
|
||||
|
||||
const nextConfig = createKriNextConfig({}) satisfies NextConfig;
|
||||
|
||||
export default nextConfig;
|
||||
7
templates/base/postcss.config.mjs
Normal file
7
templates/base/postcss.config.mjs
Normal file
@@ -0,0 +1,7 @@
|
||||
const config = {
|
||||
plugins: {
|
||||
"@tailwindcss/postcss": {}
|
||||
}
|
||||
};
|
||||
|
||||
export default config;
|
||||
BIN
templates/base/public/favicon.ico
Normal file
BIN
templates/base/public/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
BIN
templates/base/public/logo.png
Normal file
BIN
templates/base/public/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
11
templates/base/src/app/(pages)/(main)/layout.tsx
Normal file
11
templates/base/src/app/(pages)/(main)/layout.tsx
Normal file
@@ -0,0 +1,11 @@
|
||||
import { cookies } from "next/headers";
|
||||
import { redirect } from "next/navigation";
|
||||
import { AppMainLayout } from "@/components/app-shell/AppMainLayout";
|
||||
import { CookieKeys } from "@/store/cookie/cookie-keys";
|
||||
|
||||
export default async function MainLayout({ children }: Readonly<{ children: React.ReactNode }>) {
|
||||
const cookieStore = await cookies();
|
||||
const accessToken = cookieStore.get(CookieKeys.AuthToken)?.value;
|
||||
if (!accessToken) redirect("/logout");
|
||||
return <AppMainLayout>{children}</AppMainLayout>;
|
||||
}
|
||||
13
templates/base/src/app/(pages)/(main)/page.tsx
Normal file
13
templates/base/src/app/(pages)/(main)/page.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import { AppPageTitle } from "@/components/app-shell/AppPageTitle";
|
||||
|
||||
export default function MainPage() {
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<AppPageTitle title="__DISPLAY_NAME__" description="프로젝트 기본 구성이 완료되었습니다." />
|
||||
<div className="rounded-lg border bg-card p-6 text-card-foreground shadow-sm">
|
||||
<p className="font-medium">다음 작업</p>
|
||||
<p className="mt-2 text-sm text-muted-foreground">메뉴와 API 경로를 프로젝트 업무에 맞게 확장하세요.</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
81
templates/base/src/app/(pages)/login/page.tsx
Normal file
81
templates/base/src/app/(pages)/login/page.tsx
Normal file
@@ -0,0 +1,81 @@
|
||||
"use client";
|
||||
|
||||
import Image from "next/image";
|
||||
import type React from "react";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { apiError, NONE_HTTP_ERROR } from "@kri/common/http";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardHeader } from "@/components/ui/card";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { useLoginMutation } from "@/query/auth";
|
||||
|
||||
export default function LoginPage() {
|
||||
const router = useRouter();
|
||||
const loginMutation = useLoginMutation();
|
||||
const passwordInputRef = useRef<HTMLInputElement | null>(null);
|
||||
const [userId, setUserId] = useState("");
|
||||
const [userPw, setUserPw] = useState("");
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
const tryLogin = async () => {
|
||||
if (!userId.trim()) return window.alert("아이디를 입력해 주세요.");
|
||||
if (!userPw) return window.alert("비밀번호를 입력해 주세요.");
|
||||
|
||||
setError(null);
|
||||
try {
|
||||
await loginMutation.mutateAsync({ userId: userId.trim(), userPw });
|
||||
} catch (cause: unknown) {
|
||||
const errorInfo = apiError(cause, { fallbackMessage: "로그인에 실패했습니다." });
|
||||
if (errorInfo.status === 401 || errorInfo.status === 403) setError("아이디 또는 비밀번호를 다시 확인해 주세요.");
|
||||
else if (errorInfo.code === NONE_HTTP_ERROR) setError("알 수 없는 오류가 발생했습니다. 잠시 후 다시 시도해 주세요.");
|
||||
else setError(`로그인에 실패했습니다. (${errorInfo.message})`);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (loginMutation.isSuccess) router.replace("/");
|
||||
}, [loginMutation.isSuccess, router]);
|
||||
|
||||
const handleIdKeyDown: React.KeyboardEventHandler<HTMLInputElement> = (event) => {
|
||||
if (event.key === "Enter") {
|
||||
event.preventDefault();
|
||||
passwordInputRef.current?.focus();
|
||||
}
|
||||
};
|
||||
|
||||
const handlePasswordKeyDown: React.KeyboardEventHandler<HTMLInputElement> = (event) => {
|
||||
if (event.key === "Enter") {
|
||||
event.preventDefault();
|
||||
void tryLogin();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<main className="flex min-h-screen items-center justify-center bg-muted/40 p-4">
|
||||
<Card className="w-full max-w-md shadow-xl">
|
||||
<CardHeader className="pb-8">
|
||||
<div className="flex justify-center">
|
||||
<Image src="/logo.png" alt="로고" width={240} height={120} className="h-24 w-auto object-contain" priority />
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="space-y-4">
|
||||
<div className="space-y-2">
|
||||
<label htmlFor="userId" className="text-sm font-medium">ID</label>
|
||||
<Input id="userId" autoComplete="username" placeholder="아이디를 입력하세요" value={userId} onChange={(event) => setUserId(event.currentTarget.value)} onKeyDown={handleIdKeyDown} />
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<label htmlFor="userPw" className="text-sm font-medium">Password</label>
|
||||
<Input ref={passwordInputRef} id="userPw" type="password" autoComplete="current-password" placeholder="비밀번호를 입력하세요" value={userPw} onChange={(event) => setUserPw(event.currentTarget.value)} onKeyDown={handlePasswordKeyDown} />
|
||||
</div>
|
||||
{error ? <p className="text-sm text-destructive">{error}</p> : null}
|
||||
<Button className="mt-6 h-11 w-full" disabled={loginMutation.isPending} onClick={() => void tryLogin()}>
|
||||
{loginMutation.isPending ? "로그인 중..." : "로그인"}
|
||||
</Button>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
20
templates/base/src/app/(pages)/logout/page.tsx
Normal file
20
templates/base/src/app/(pages)/logout/page.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useRef } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useLogoutMutation } from "@/query/auth";
|
||||
import { LoadingOverlayAdapter } from "@/components/app-shell/LoadingOverlayAdapter";
|
||||
|
||||
export default function LogoutPage() {
|
||||
const router = useRouter();
|
||||
const logoutMutation = useLogoutMutation();
|
||||
const started = useRef(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (started.current) return;
|
||||
started.current = true;
|
||||
void logoutMutation.mutateAsync().finally(() => router.replace("/login"));
|
||||
}, [logoutMutation, router]);
|
||||
|
||||
return <LoadingOverlayAdapter force label="로그아웃 중" />;
|
||||
}
|
||||
73
templates/base/src/app/api/example/[[...slug]]/route.ts
Normal file
73
templates/base/src/app/api/example/[[...slug]]/route.ts
Normal file
@@ -0,0 +1,73 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { errorToResponse } from "@kri/common/http";
|
||||
import { createServerApi } from "@/lib/http-server";
|
||||
import type { RouteContext } from "@/types/common";
|
||||
|
||||
const apiPath = (slug: string[]) => `/example${slug.length ? `/${slug.map(encodeURIComponent).join("/")}` : ""}`;
|
||||
const toResponse = (result: unknown) => result === undefined ? new NextResponse(null, { status: 204 }) : NextResponse.json(result);
|
||||
|
||||
export async function GET(request: NextRequest, context: RouteContext) {
|
||||
try {
|
||||
const { slug = [] } = await context.params;
|
||||
const query = Object.fromEntries(request.nextUrl.searchParams.entries());
|
||||
const serverApi = await createServerApi();
|
||||
return toResponse(await serverApi.get<unknown>(apiPath(slug), { query }));
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
}
|
||||
|
||||
export async function POST(request: NextRequest, context: RouteContext) {
|
||||
try {
|
||||
const { slug = [] } = await context.params;
|
||||
const serverApi = await createServerApi();
|
||||
const contentType = request.headers.get("content-type") ?? "";
|
||||
if (contentType.includes("multipart/form-data")) {
|
||||
return toResponse(await serverApi.postForm<unknown>(apiPath(slug), await request.formData()));
|
||||
}
|
||||
const body = await request.json().catch(() => undefined);
|
||||
return toResponse(await serverApi.post<unknown>(apiPath(slug), body));
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
}
|
||||
|
||||
export async function PUT(request: NextRequest, context: RouteContext) {
|
||||
try {
|
||||
const { slug = [] } = await context.params;
|
||||
const serverApi = await createServerApi();
|
||||
const contentType = request.headers.get("content-type") ?? "";
|
||||
if (contentType.includes("multipart/form-data")) {
|
||||
return toResponse(await serverApi.putForm<unknown>(apiPath(slug), await request.formData()));
|
||||
}
|
||||
const body = await request.json().catch(() => undefined);
|
||||
return toResponse(await serverApi.put<unknown>(apiPath(slug), body));
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
}
|
||||
|
||||
export async function PATCH(request: NextRequest, context: RouteContext) {
|
||||
try {
|
||||
const { slug = [] } = await context.params;
|
||||
const serverApi = await createServerApi();
|
||||
const body = await request.json().catch(() => undefined);
|
||||
return toResponse(await serverApi.patch<unknown>(apiPath(slug), body));
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
}
|
||||
|
||||
export async function DELETE(request: NextRequest, context: RouteContext) {
|
||||
try {
|
||||
const { slug = [] } = await context.params;
|
||||
const serverApi = await createServerApi();
|
||||
const body = await request.json().catch(() => undefined);
|
||||
return toResponse(await serverApi.del<unknown>(apiPath(slug), body === undefined ? undefined : { json: body }));
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
}
|
||||
|
||||
// createHttpClient의 FormData 전용 메서드는 postForm과 putForm입니다.
|
||||
// PATCH/DELETE multipart가 필요하면 공용 HTTP Client 정책을 확인한 뒤 별도 구현하세요.
|
||||
32
templates/base/src/app/api/login/[[...slug]]/route.ts
Normal file
32
templates/base/src/app/api/login/[[...slug]]/route.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import type { LoginRequest, LoginUser } from "@kri/common";
|
||||
import { errorToResponse } from "@kri/common/http";
|
||||
import { AUTH_COOKIE_MAX_AGE } from "@/const/common.const";
|
||||
import { serverEnv } from "@/lib/env.server";
|
||||
import { createServerApi } from "@/lib/http-server";
|
||||
import { CookieKeys } from "@/store/cookie/cookie-keys";
|
||||
import type { RouteContext } from "@/types/common";
|
||||
|
||||
type LoginResponse = { accessToken: string; user: LoginUser };
|
||||
|
||||
export async function POST(request: NextRequest, context: RouteContext) {
|
||||
try {
|
||||
const { slug = [] } = await context.params;
|
||||
const serverApi = await createServerApi();
|
||||
const body = (await request.json()) as LoginRequest;
|
||||
const suffix = slug.length ? `/${slug.map(encodeURIComponent).join("/")}` : "";
|
||||
const result = await serverApi.post<LoginResponse>(`/auth/login${suffix}`, body);
|
||||
|
||||
const response = NextResponse.json(result.user, { status: 200 });
|
||||
response.cookies.set(CookieKeys.AuthToken, result.accessToken, {
|
||||
httpOnly: true,
|
||||
secure: serverEnv.ENV === "prod",
|
||||
sameSite: "lax",
|
||||
path: "/",
|
||||
maxAge: AUTH_COOKIE_MAX_AGE,
|
||||
});
|
||||
return response;
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
}
|
||||
27
templates/base/src/app/api/logout/[[...slug]]/route.ts
Normal file
27
templates/base/src/app/api/logout/[[...slug]]/route.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { errorToResponse } from "@kri/common/http";
|
||||
import { serverEnv } from "@/lib/env.server";
|
||||
import { createServerApi } from "@/lib/http-server";
|
||||
import { CookieKeys } from "@/store/cookie/cookie-keys";
|
||||
import type { RouteContext } from "@/types/common";
|
||||
|
||||
export async function POST(_request: NextRequest, context: RouteContext) {
|
||||
try {
|
||||
const { slug = [] } = await context.params;
|
||||
const serverApi = await createServerApi();
|
||||
const suffix = slug.length ? `/${slug.map(encodeURIComponent).join("/")}` : "";
|
||||
await serverApi.post<boolean>(`/auth/logout${suffix}`);
|
||||
|
||||
const response = NextResponse.json({ ok: true });
|
||||
response.cookies.set(CookieKeys.AuthToken, "", {
|
||||
httpOnly: true,
|
||||
secure: serverEnv.ENV === "prod",
|
||||
sameSite: "lax",
|
||||
path: "/",
|
||||
maxAge: 0,
|
||||
});
|
||||
return response;
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
}
|
||||
87
templates/base/src/app/globals.css
Normal file
87
templates/base/src/app/globals.css
Normal file
@@ -0,0 +1,87 @@
|
||||
@import "tailwindcss";
|
||||
@import "tw-animate-css";
|
||||
|
||||
@custom-variant dark (&:is(.dark *));
|
||||
|
||||
@theme inline {
|
||||
--color-background: var(--background);
|
||||
--color-foreground: var(--foreground);
|
||||
--color-card: var(--card);
|
||||
--color-card-foreground: var(--card-foreground);
|
||||
--color-popover: var(--popover);
|
||||
--color-popover-foreground: var(--popover-foreground);
|
||||
--color-primary: var(--primary);
|
||||
--color-primary-foreground: var(--primary-foreground);
|
||||
--color-secondary: var(--secondary);
|
||||
--color-secondary-foreground: var(--secondary-foreground);
|
||||
--color-muted: var(--muted);
|
||||
--color-muted-foreground: var(--muted-foreground);
|
||||
--color-accent: var(--accent);
|
||||
--color-accent-foreground: var(--accent-foreground);
|
||||
--color-destructive: var(--destructive);
|
||||
--color-border: var(--border);
|
||||
--color-input: var(--input);
|
||||
--color-ring: var(--ring);
|
||||
--radius-sm: calc(var(--radius) - 4px);
|
||||
--radius-md: calc(var(--radius) - 2px);
|
||||
--radius-lg: var(--radius);
|
||||
--radius-xl: calc(var(--radius) + 4px);
|
||||
}
|
||||
|
||||
:root {
|
||||
--radius: 0.625rem;
|
||||
--background: oklch(1 0 0);
|
||||
--foreground: oklch(0.145 0 0);
|
||||
--card: oklch(1 0 0);
|
||||
--card-foreground: oklch(0.145 0 0);
|
||||
--popover: oklch(1 0 0);
|
||||
--popover-foreground: oklch(0.145 0 0);
|
||||
--primary: oklch(0.205 0 0);
|
||||
--primary-foreground: oklch(0.985 0 0);
|
||||
--secondary: oklch(0.97 0 0);
|
||||
--secondary-foreground: oklch(0.205 0 0);
|
||||
--muted: oklch(0.97 0 0);
|
||||
--muted-foreground: oklch(0.556 0 0);
|
||||
--accent: oklch(0.97 0 0);
|
||||
--accent-foreground: oklch(0.205 0 0);
|
||||
--destructive: oklch(0.577 0.245 27.325);
|
||||
--border: oklch(0.922 0 0);
|
||||
--input: oklch(0.922 0 0);
|
||||
--ring: oklch(0.708 0 0);
|
||||
}
|
||||
|
||||
.dark {
|
||||
--background: oklch(0.145 0 0);
|
||||
--foreground: oklch(0.985 0 0);
|
||||
--card: oklch(0.205 0 0);
|
||||
--card-foreground: oklch(0.985 0 0);
|
||||
--popover: oklch(0.205 0 0);
|
||||
--popover-foreground: oklch(0.985 0 0);
|
||||
--primary: oklch(0.922 0 0);
|
||||
--primary-foreground: oklch(0.205 0 0);
|
||||
--secondary: oklch(0.269 0 0);
|
||||
--secondary-foreground: oklch(0.985 0 0);
|
||||
--muted: oklch(0.269 0 0);
|
||||
--muted-foreground: oklch(0.708 0 0);
|
||||
--accent: oklch(0.269 0 0);
|
||||
--accent-foreground: oklch(0.985 0 0);
|
||||
--destructive: oklch(0.704 0.191 22.216);
|
||||
--border: oklch(1 0 0 / 10%);
|
||||
--input: oklch(1 0 0 / 15%);
|
||||
--ring: oklch(0.556 0 0);
|
||||
}
|
||||
|
||||
@layer base {
|
||||
* { @apply border-border outline-ring/50; }
|
||||
body { @apply bg-background text-foreground; }
|
||||
}
|
||||
|
||||
.ProseMirror img { cursor: pointer; }
|
||||
.ProseMirror .ProseMirror-selectednode img { outline: 5px solid #0ea5e9; outline-offset: -5px; }
|
||||
.ProseMirror [data-resize-container] { position: relative; display: inline-block; }
|
||||
.ProseMirror [data-resize-handle] { position: absolute; width: 10px; height: 10px; box-sizing: border-box; background: #fff; border: 1px solid #0ea5e9; z-index: 10; opacity: 0; pointer-events: none; transition: opacity .12s ease-out; }
|
||||
.ProseMirror [data-resize-container]:hover [data-resize-handle] { opacity: 1; pointer-events: auto; }
|
||||
.ProseMirror [data-resize-handle="bottom-right"] { right: -5px; bottom: -5px; cursor: se-resize !important; }
|
||||
.ProseMirror [data-resize-handle="bottom-left"] { left: -5px; bottom: -5px; cursor: sw-resize !important; }
|
||||
.ProseMirror [data-resize-handle="top-right"] { right: -5px; top: -5px; cursor: ne-resize !important; }
|
||||
.ProseMirror [data-resize-handle="top-left"] { left: -5px; top: -5px; cursor: nw-resize !important; }
|
||||
21
templates/base/src/app/layout.tsx
Normal file
21
templates/base/src/app/layout.tsx
Normal file
@@ -0,0 +1,21 @@
|
||||
import type { Metadata } from "next";
|
||||
import { Toaster } from "sonner";
|
||||
import { AppProvider } from "@/components/providers/AppProvider";
|
||||
import "./globals.css";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "__DISPLAY_NAME__",
|
||||
description: "__DESCRIPTION__",
|
||||
icons: { icon: "/favicon.ico" }
|
||||
};
|
||||
|
||||
export default function RootLayout({ children }: Readonly<{ children: React.ReactNode }>) {
|
||||
return (
|
||||
<html lang="ko">
|
||||
<body className="min-h-screen antialiased">
|
||||
<AppProvider>{children}</AppProvider>
|
||||
<Toaster />
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
11
templates/base/src/app/not-found.tsx
Normal file
11
templates/base/src/app/not-found.tsx
Normal file
@@ -0,0 +1,11 @@
|
||||
import Link from "next/link";
|
||||
|
||||
export default function NotFound() {
|
||||
return (
|
||||
<main className="flex min-h-screen flex-col items-center justify-center gap-4 p-6 text-center">
|
||||
<p className="text-sm text-muted-foreground">404</p>
|
||||
<h1 className="text-2xl font-bold">페이지를 찾을 수 없습니다.</h1>
|
||||
<Link href="/" className="text-sm underline underline-offset-4">홈으로 이동</Link>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
40
templates/base/src/components/app-shell/AppHeader.tsx
Normal file
40
templates/base/src/components/app-shell/AppHeader.tsx
Normal file
@@ -0,0 +1,40 @@
|
||||
"use client";
|
||||
|
||||
import Image from "next/image";
|
||||
import { LogOut } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { KriHeader } from "@/components/layout/KriHeader";
|
||||
import { topMenus } from "@/config/menu.data";
|
||||
import type { LoginUser } from "@kri/common";
|
||||
|
||||
interface AppHeaderProps {
|
||||
menuOpen: boolean;
|
||||
showMenuButton: boolean;
|
||||
activeMenuId?: string;
|
||||
user?: LoginUser | null;
|
||||
onToggleMenu: () => void;
|
||||
onNavigate: (path: string) => void;
|
||||
}
|
||||
|
||||
export function AppHeader({ menuOpen, showMenuButton, activeMenuId, user, onToggleMenu, onNavigate }: AppHeaderProps) {
|
||||
return (
|
||||
<KriHeader
|
||||
logo={<Image src="/logo.png" alt="로고" width={120} height={40} className="h-10 w-auto object-contain" priority />}
|
||||
menus={topMenus}
|
||||
activeMenuId={activeMenuId}
|
||||
menuOpen={menuOpen}
|
||||
showMenuButton={showMenuButton}
|
||||
onToggleMenu={onToggleMenu}
|
||||
onNavigate={onNavigate}
|
||||
right={
|
||||
<>
|
||||
<span className="hidden text-sm text-muted-foreground sm:inline">{user?.userName ?? ""}</span>
|
||||
<Button variant="ghost" size="sm" className="gap-2" onClick={() => onNavigate("/logout")}>
|
||||
<LogOut className="size-4" />
|
||||
<span className="hidden sm:inline">로그아웃</span>
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
44
templates/base/src/components/app-shell/AppMainLayout.tsx
Normal file
44
templates/base/src/components/app-shell/AppMainLayout.tsx
Normal file
@@ -0,0 +1,44 @@
|
||||
"use client";
|
||||
|
||||
import { useMemo, useState } from "react";
|
||||
import { usePathname, useRouter } from "next/navigation";
|
||||
import { KriMainLayout } from "@/components/layout/KriMainLayout";
|
||||
import { AppHeader } from "./AppHeader";
|
||||
import { AppSidebar } from "./AppSidebar";
|
||||
import { sideMenus, topMenus } from "@/config/menu.data";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
|
||||
export function AppMainLayout({ children }: { children: React.ReactNode }) {
|
||||
const pathname = usePathname();
|
||||
const router = useRouter();
|
||||
const { auth } = useAuth();
|
||||
const [menuOpen, setMenuOpen] = useState(true);
|
||||
|
||||
const activeMenuId = useMemo(
|
||||
() => topMenus.find((item) => item.path && (pathname === item.path || pathname.startsWith(`${item.path}/`)))?.id,
|
||||
[pathname],
|
||||
);
|
||||
|
||||
const navigate = (path: string) => router.push(path);
|
||||
const hasSidebar = sideMenus.length > 0;
|
||||
|
||||
return (
|
||||
<KriMainLayout
|
||||
sidebarOpen={hasSidebar && menuOpen}
|
||||
onSidebarOpenChange={setMenuOpen}
|
||||
header={
|
||||
<AppHeader
|
||||
menuOpen={menuOpen}
|
||||
showMenuButton={hasSidebar}
|
||||
activeMenuId={activeMenuId}
|
||||
user={auth.user}
|
||||
onToggleMenu={() => setMenuOpen((current) => !current)}
|
||||
onNavigate={navigate}
|
||||
/>
|
||||
}
|
||||
sidebar={hasSidebar ? <AppSidebar items={sideMenus} isOpen={menuOpen} pathname={pathname} onNavigate={navigate} /> : undefined}
|
||||
>
|
||||
{children}
|
||||
</KriMainLayout>
|
||||
);
|
||||
}
|
||||
10
templates/base/src/components/app-shell/AppPageTitle.tsx
Normal file
10
templates/base/src/components/app-shell/AppPageTitle.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import { KriPageTitle } from "@/components/layout/KriPageTitle";
|
||||
|
||||
export interface AppPageTitleProps {
|
||||
title: string;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
export function AppPageTitle({ title, description }: AppPageTitleProps) {
|
||||
return <KriPageTitle title={title} description={description} />;
|
||||
}
|
||||
15
templates/base/src/components/app-shell/AppSidebar.tsx
Normal file
15
templates/base/src/components/app-shell/AppSidebar.tsx
Normal file
@@ -0,0 +1,15 @@
|
||||
"use client";
|
||||
|
||||
import { KriSidebar } from "@/components/layout/KriSidebar";
|
||||
import type { SideMenuItem } from "@/config/menu.type";
|
||||
|
||||
interface AppSidebarProps {
|
||||
items: SideMenuItem[];
|
||||
isOpen: boolean;
|
||||
pathname: string;
|
||||
onNavigate: (path: string) => void;
|
||||
}
|
||||
|
||||
export function AppSidebar({ items, isOpen, pathname, onNavigate }: AppSidebarProps) {
|
||||
return <KriSidebar items={items} isOpen={isOpen} pathname={pathname} onNavigate={onNavigate} />;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
"use client";
|
||||
|
||||
import { useAtomValue } from "jotai";
|
||||
import { KriLoadingOverlay, type KriLoadingOverlayProps } from "@/components/common/KriLoadingOverlay";
|
||||
import { loadingAtom } from "@/store/jotai/loading";
|
||||
|
||||
export type LoadingOverlayAdapterProps = Omit<KriLoadingOverlayProps, "open"> & { force?: boolean };
|
||||
|
||||
export function LoadingOverlayAdapter({ force = false, ...props }: LoadingOverlayAdapterProps) {
|
||||
const open = useAtomValue(loadingAtom);
|
||||
return <KriLoadingOverlay open={force || open} {...props} />;
|
||||
}
|
||||
5
templates/base/src/components/app-shell/index.ts
Normal file
5
templates/base/src/components/app-shell/index.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export { AppHeader } from "./AppHeader";
|
||||
export { AppMainLayout } from "./AppMainLayout";
|
||||
export { AppPageTitle } from "./AppPageTitle";
|
||||
export { AppSidebar } from "./AppSidebar";
|
||||
export { LoadingOverlayAdapter } from "./LoadingOverlayAdapter";
|
||||
18
templates/base/src/components/providers/AppProvider.tsx
Normal file
18
templates/base/src/components/providers/AppProvider.tsx
Normal file
@@ -0,0 +1,18 @@
|
||||
"use client";
|
||||
|
||||
import { Provider as JotaiProvider } from "jotai";
|
||||
import { QueryProvider } from "@kri/common/query";
|
||||
import { LoadingOverlayAdapter } from "@/components/app-shell/LoadingOverlayAdapter";
|
||||
import { QueryLoadingSync } from "./QueryLoadingSync";
|
||||
|
||||
export function AppProvider({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<JotaiProvider>
|
||||
<QueryProvider>
|
||||
<QueryLoadingSync />
|
||||
<LoadingOverlayAdapter />
|
||||
{children}
|
||||
</QueryProvider>
|
||||
</JotaiProvider>
|
||||
);
|
||||
}
|
||||
10
templates/base/src/components/providers/QueryLoadingSync.tsx
Normal file
10
templates/base/src/components/providers/QueryLoadingSync.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
"use client";
|
||||
|
||||
import { QueryLoadingSync as CommonQueryLoadingSync } from "@kri/common/query";
|
||||
import { useSetAtom } from "jotai";
|
||||
import { queryLoadingAtom } from "@/store/jotai/loading";
|
||||
|
||||
export function QueryLoadingSync() {
|
||||
const setQueryLoading = useSetAtom(queryLoadingAtom);
|
||||
return <CommonQueryLoadingSync onLoadingChange={setQueryLoading} />;
|
||||
}
|
||||
7
templates/base/src/config/common.config.ts
Normal file
7
templates/base/src/config/common.config.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export const commonConfig = {
|
||||
appName: "__DISPLAY_NAME__",
|
||||
description: "__DESCRIPTION__",
|
||||
homePath: "/",
|
||||
loginPath: "/login",
|
||||
logoutPath: "/logout",
|
||||
} as const;
|
||||
7
templates/base/src/config/menu.data.ts
Normal file
7
templates/base/src/config/menu.data.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import type { SideMenuItem, TopMenuItem } from "./menu.type";
|
||||
|
||||
export const topMenus: TopMenuItem[] = [
|
||||
{ id: "home", label: "홈", path: "/" },
|
||||
];
|
||||
|
||||
export const sideMenus: SideMenuItem[] = [];
|
||||
4
templates/base/src/config/menu.type.ts
Normal file
4
templates/base/src/config/menu.type.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import type { KriNavigationItem } from "@/components/layout/types";
|
||||
|
||||
export type TopMenuItem = KriNavigationItem;
|
||||
export type SideMenuItem = KriNavigationItem;
|
||||
1
templates/base/src/const/common.const.ts
Normal file
1
templates/base/src/const/common.const.ts
Normal file
@@ -0,0 +1 @@
|
||||
export const AUTH_COOKIE_MAX_AGE = 24 * 60 * 60;
|
||||
38
templates/base/src/hooks/useAuth.ts
Normal file
38
templates/base/src/hooks/useAuth.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
"use client";
|
||||
|
||||
import { useCallback } from "react";
|
||||
import type { LoginUser } from "@kri/common";
|
||||
import { createAuthHook, type AuthState as CommonAuthState } from "@kri/common/hooks";
|
||||
import { getLocalStorage, removeLocalStorage, setLocalStorage } from "@/store/storage/secure-storage";
|
||||
import { StorageKeys } from "@/store/storage/storage-keys";
|
||||
|
||||
export type AuthState = CommonAuthState<LoginUser>;
|
||||
const initialAuthState: AuthState = { user: null };
|
||||
|
||||
const loadInitialAuthState = (): AuthState => {
|
||||
const stored = getLocalStorage(StorageKeys.AuthState);
|
||||
return stored && typeof stored === "object" && "user" in stored
|
||||
? { ...initialAuthState, ...(stored as Partial<AuthState>) }
|
||||
: initialAuthState;
|
||||
};
|
||||
|
||||
const { authAtom, useAuth: useCommonAuth } = createAuthHook<LoginUser>({ initialState: loadInitialAuthState() });
|
||||
export const authStateAtom = authAtom;
|
||||
|
||||
export function useAuth() {
|
||||
const { auth, setAuth: setCommonAuth } = useCommonAuth();
|
||||
|
||||
const setAuth = useCallback((next: AuthState | ((previous: AuthState) => AuthState)) => {
|
||||
setCommonAuth((previous) => {
|
||||
const resolved = typeof next === "function" ? next(previous) : next;
|
||||
if (resolved.user === null) removeLocalStorage(StorageKeys.AuthState);
|
||||
else setLocalStorage(StorageKeys.AuthState, resolved);
|
||||
return resolved;
|
||||
});
|
||||
}, [setCommonAuth]);
|
||||
|
||||
const setFromLoginResponse = useCallback((user: LoginUser) => setAuth({ user }), [setAuth]);
|
||||
const logout = useCallback(() => setAuth(initialAuthState), [setAuth]);
|
||||
|
||||
return { auth, setAuth, setFromLoginResponse, logout } as const;
|
||||
}
|
||||
23
templates/base/src/hooks/useDialog.ts
Normal file
23
templates/base/src/hooks/useDialog.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
"use client";
|
||||
|
||||
import { useCallback } from "react";
|
||||
import { createDialogHook } from "@kri/common/hooks";
|
||||
import type { DialogId } from "@/store/jotai/dialog";
|
||||
|
||||
const { openDialogIdsAtom, useDialog: useCommonDialog } = createDialogHook<DialogId>();
|
||||
export { openDialogIdsAtom };
|
||||
|
||||
export function useDialog() {
|
||||
const { openDialogIds, isDialogOpen, openDialog, closeDialog, closeAllDialogs } = useCommonDialog();
|
||||
const showDialog = useCallback((id: DialogId, onlyThis = true) => {
|
||||
if (onlyThis) closeAllDialogs();
|
||||
openDialog(id);
|
||||
}, [closeAllDialogs, openDialog]);
|
||||
return {
|
||||
openDialogIds,
|
||||
isDialogOpen,
|
||||
showDialog,
|
||||
hideDialog: closeDialog,
|
||||
hideAll: closeAllDialogs,
|
||||
} as const;
|
||||
}
|
||||
7
templates/base/src/hooks/useLoading.ts
Normal file
7
templates/base/src/hooks/useLoading.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { createLoadingHook } from "@kri/common/hooks";
|
||||
|
||||
const { loadingCountAtom, isLoadingAtom, useLoading } = createLoadingHook();
|
||||
export { loadingCountAtom, isLoadingAtom, useLoading };
|
||||
export const manualLoadingAtom = isLoadingAtom;
|
||||
17
templates/base/src/hooks/useStorage.ts
Normal file
17
templates/base/src/hooks/useStorage.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
"use client";
|
||||
|
||||
import { createStorageHook } from "@kri/common/hooks";
|
||||
import type { AuthState } from "@/hooks/useAuth";
|
||||
import { getLocalStorage, getSessionStorage, removeLocalStorage, removeSessionStorage, setLocalStorage, setSessionStorage } from "@/store/storage/secure-storage";
|
||||
import { StorageKeys, StorageType } from "@/store/storage/storage-keys";
|
||||
|
||||
type AppStorageSchema = { [StorageKeys.AuthState]: AuthState };
|
||||
type AppStorageKey = Extract<keyof AppStorageSchema, string>;
|
||||
|
||||
const useCommonStorage = createStorageHook<AppStorageSchema>({
|
||||
resolveStorageScope: (key) => StorageType[key],
|
||||
localStorageAdapter: { get: getLocalStorage, set: setLocalStorage, remove: removeLocalStorage },
|
||||
sessionStorageAdapter: { get: getSessionStorage, set: setSessionStorage, remove: removeSessionStorage },
|
||||
});
|
||||
|
||||
export const useStorage = <TKey extends AppStorageKey>(key: TKey) => useCommonStorage(key);
|
||||
8
templates/base/src/lib/env.client.ts
Normal file
8
templates/base/src/lib/env.client.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { createEnv, env } from "@kri/common/config";
|
||||
|
||||
export const clientEnv = createEnv({
|
||||
ENV: env.required("NEXT_PUBLIC_ENV", process.env.NEXT_PUBLIC_ENV),
|
||||
API_BASE: env.required("NEXT_PUBLIC_API_BASE", process.env.NEXT_PUBLIC_API_BASE),
|
||||
STORE_KEY: env.required("NEXT_PUBLIC_STORE_KEY", process.env.NEXT_PUBLIC_STORE_KEY),
|
||||
STORE_IV: env.required("NEXT_PUBLIC_STORE_IV", process.env.NEXT_PUBLIC_STORE_IV),
|
||||
});
|
||||
7
templates/base/src/lib/env.server.ts
Normal file
7
templates/base/src/lib/env.server.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import "server-only";
|
||||
import { createEnv, env } from "@kri/common/config";
|
||||
|
||||
export const serverEnv = createEnv({
|
||||
ENV: env.required("ENV", process.env.ENV),
|
||||
API_SERVER: env.required("API_SERVER", process.env.API_SERVER),
|
||||
});
|
||||
4
templates/base/src/lib/http-client.ts
Normal file
4
templates/base/src/lib/http-client.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import { createHttpClient } from "@kri/common/http";
|
||||
import { clientEnv } from "@/lib/env.client";
|
||||
|
||||
export const nextApi = createHttpClient(clientEnv.API_BASE);
|
||||
13
templates/base/src/lib/http-server.ts
Normal file
13
templates/base/src/lib/http-server.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { cookies } from "next/headers";
|
||||
import { createHttpClient } from "@kri/common/http";
|
||||
import { serverEnv } from "@/lib/env.server";
|
||||
import { CookieKeys } from "@/store/cookie/cookie-keys";
|
||||
|
||||
export async function createServerApi() {
|
||||
const cookieStore = await cookies();
|
||||
const accessToken = cookieStore.get(CookieKeys.AuthToken)?.value ?? null;
|
||||
return createHttpClient(serverEnv.API_SERVER, {
|
||||
getToken: () => accessToken,
|
||||
defaultHeaders: { "content-type": "application/json" },
|
||||
});
|
||||
}
|
||||
14
templates/base/src/lib/security.ts
Normal file
14
templates/base/src/lib/security.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { createSecurity } from "@kri/common/security";
|
||||
import { clientEnv } from "@/lib/env.client";
|
||||
|
||||
export const Security = createSecurity({
|
||||
key: clientEnv.STORE_KEY,
|
||||
iv: clientEnv.STORE_IV,
|
||||
onInvalidConfig: ({ message }) => {
|
||||
if (typeof window === "undefined" || clientEnv.ENV !== "local") return;
|
||||
const target = window as Window & { __kriCryptoConfigAlerted?: boolean };
|
||||
if (target.__kriCryptoConfigAlerted) return;
|
||||
target.__kriCryptoConfigAlerted = true;
|
||||
window.alert(message);
|
||||
},
|
||||
});
|
||||
1
templates/base/src/lib/utils.ts
Normal file
1
templates/base/src/lib/utils.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { cn } from "@kri/common/ui";
|
||||
10
templates/base/src/proxy.ts
Normal file
10
templates/base/src/proxy.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
|
||||
export const config = {
|
||||
matcher: ["/example/:path*"],
|
||||
};
|
||||
|
||||
export function proxy(_request: NextRequest) {
|
||||
// 인증, Header 추가, Redirect 같은 공통 처리를 구현할 수 있습니다.
|
||||
return NextResponse.next();
|
||||
}
|
||||
41
templates/base/src/query/auth.ts
Normal file
41
templates/base/src/query/auth.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
"use client";
|
||||
|
||||
import type { LoginRequest, LoginUser } from "@kri/common";
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
import { nextApi } from "@/lib/http-client";
|
||||
|
||||
export function useLoginMutation() {
|
||||
const { setFromLoginResponse } = useAuth();
|
||||
return useMutation({
|
||||
mutationFn: (request: LoginRequest) => nextApi.post<LoginUser>("/login", request, {
|
||||
skipUnauthorizedHandler: true,
|
||||
skipForbiddenHandler: true,
|
||||
skipResponseErrorHandler: true,
|
||||
}),
|
||||
onSuccess: setFromLoginResponse,
|
||||
});
|
||||
}
|
||||
|
||||
export function useLogoutMutation() {
|
||||
const queryClient = useQueryClient();
|
||||
const { auth, logout } = useAuth();
|
||||
return useMutation({
|
||||
mutationFn: async () => {
|
||||
const suffix = auth.user?.userId ? `/${encodeURIComponent(auth.user.userId)}` : "";
|
||||
try {
|
||||
await nextApi.post(`/logout${suffix}`, null, {
|
||||
skipUnauthorizedHandler: true,
|
||||
skipForbiddenHandler: true,
|
||||
skipResponseErrorHandler: true,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
},
|
||||
onSettled: () => {
|
||||
logout();
|
||||
queryClient.clear();
|
||||
},
|
||||
});
|
||||
}
|
||||
56
templates/base/src/query/example.ts
Normal file
56
templates/base/src/query/example.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
"use client";
|
||||
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { nextApi } from "@/lib/http-client";
|
||||
import { queryKeys } from "@/query/key/keys";
|
||||
import type { ExampleItem, ExampleRequest } from "@/types/common";
|
||||
|
||||
export const useExampleQuery = (id: string) => useQuery({
|
||||
queryKey: queryKeys.example.detail(id),
|
||||
queryFn: () => nextApi.get<ExampleItem>(`/example/${id}`),
|
||||
enabled: Boolean(id),
|
||||
});
|
||||
|
||||
export function useCreateExampleMutation() {
|
||||
const client = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (body: ExampleRequest) => nextApi.post<ExampleItem>("/example", body),
|
||||
onSuccess: () => client.invalidateQueries({ queryKey: queryKeys.example.all }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useUpdateExampleMutation(id: string) {
|
||||
const client = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (body: ExampleRequest) => nextApi.put<ExampleItem>(`/example/${id}`, body),
|
||||
onSuccess: () => client.invalidateQueries({ queryKey: queryKeys.example.all }),
|
||||
});
|
||||
}
|
||||
|
||||
export function usePatchExampleMutation(id: string) {
|
||||
const client = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (body: Partial<ExampleRequest>) => nextApi.patch<ExampleItem>(`/example/${id}`, body),
|
||||
onSuccess: () => client.invalidateQueries({ queryKey: queryKeys.example.all }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useDeleteExampleMutation() {
|
||||
const client = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (id: string) => nextApi.del<void>(`/example/${id}`),
|
||||
onSuccess: () => client.invalidateQueries({ queryKey: queryKeys.example.all }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useUploadExampleMutation(id: string) {
|
||||
return useMutation({
|
||||
mutationFn: (formData: FormData) => nextApi.postForm<ExampleItem>(`/example/${id}`, formData),
|
||||
});
|
||||
}
|
||||
|
||||
export function useReplaceExampleFileMutation(id: string) {
|
||||
return useMutation({
|
||||
mutationFn: (formData: FormData) => nextApi.putForm<ExampleItem>(`/example/${id}`, formData),
|
||||
});
|
||||
}
|
||||
6
templates/base/src/query/key/keys.ts
Normal file
6
templates/base/src/query/key/keys.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export const queryKeys = {
|
||||
example: {
|
||||
all: ["example"] as const,
|
||||
detail: (id: string) => ["example", id] as const,
|
||||
},
|
||||
} as const;
|
||||
9
templates/base/src/store/cookie/client-cookie.ts
Normal file
9
templates/base/src/store/cookie/client-cookie.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
"use client";
|
||||
|
||||
import { createCookieStore, type CookieSetOptions } from "@kri/common/browser";
|
||||
import type { CookieKey } from "./cookie-keys";
|
||||
|
||||
export type { CookieSetOptions };
|
||||
export const cookieStore = createCookieStore<CookieKey>({
|
||||
defaults: { days: 365, path: "/", secure: false, sameSite: "Lax" },
|
||||
});
|
||||
5
templates/base/src/store/cookie/cookie-keys.ts
Normal file
5
templates/base/src/store/cookie/cookie-keys.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export const CookieKeys = {
|
||||
AuthToken: "kri_authToken",
|
||||
} as const;
|
||||
|
||||
export type CookieKey = (typeof CookieKeys)[keyof typeof CookieKeys];
|
||||
2
templates/base/src/store/jotai/auth.ts
Normal file
2
templates/base/src/store/jotai/auth.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
"use client";
|
||||
export { authStateAtom, type AuthState } from "@/hooks/useAuth";
|
||||
1
templates/base/src/store/jotai/dialog.ts
Normal file
1
templates/base/src/store/jotai/dialog.ts
Normal file
@@ -0,0 +1 @@
|
||||
export type DialogId = "exampleDialog";
|
||||
8
templates/base/src/store/jotai/loading.ts
Normal file
8
templates/base/src/store/jotai/loading.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
"use client";
|
||||
|
||||
import { atom } from "jotai";
|
||||
import { isLoadingAtom } from "@/hooks/useLoading";
|
||||
|
||||
export const manualLoadingAtom = isLoadingAtom;
|
||||
export const queryLoadingAtom = atom(false);
|
||||
export const loadingAtom = atom((get) => get(isLoadingAtom) || get(queryLoadingAtom));
|
||||
27
templates/base/src/store/storage/secure-storage.ts
Normal file
27
templates/base/src/store/storage/secure-storage.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
"use client";
|
||||
|
||||
import { createJsonStorage, type JsonStorageTransform } from "@kri/common/browser";
|
||||
import { clientEnv } from "@/lib/env.client";
|
||||
import { Security } from "@/lib/security";
|
||||
|
||||
const securityTransform: JsonStorageTransform = {
|
||||
encode: (value) => Security.encryptBase64(value),
|
||||
decode: (value) => Security.decryptBase64(value),
|
||||
};
|
||||
|
||||
const options = (storage: "local" | "session") => ({
|
||||
storage,
|
||||
fallbackToPlainJson: true,
|
||||
...(clientEnv.ENV === "prod" ? { transform: securityTransform } : {}),
|
||||
} as const);
|
||||
|
||||
const local = createJsonStorage(options("local"));
|
||||
const session = createJsonStorage(options("session"));
|
||||
export const setLocalStorage = local.set;
|
||||
export const getLocalStorage = local.get;
|
||||
export const removeLocalStorage = local.remove;
|
||||
export const clearLocalStorage = local.clear;
|
||||
export const setSessionStorage = session.set;
|
||||
export const getSessionStorage = session.get;
|
||||
export const removeSessionStorage = session.remove;
|
||||
export const clearSessionStorage = session.clear;
|
||||
8
templates/base/src/store/storage/storage-keys.ts
Normal file
8
templates/base/src/store/storage/storage-keys.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
export const StorageKeys = {
|
||||
AuthState: "kri:authState",
|
||||
} as const;
|
||||
|
||||
export type StorageKey = (typeof StorageKeys)[keyof typeof StorageKeys];
|
||||
export const StorageType: Record<StorageKey, "local" | "session"> = {
|
||||
[StorageKeys.AuthState]: "local",
|
||||
};
|
||||
12
templates/base/src/types/common.ts
Normal file
12
templates/base/src/types/common.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
export type RouteContext = {
|
||||
params: Promise<{ slug?: string[] }>;
|
||||
};
|
||||
|
||||
export interface ExampleItem {
|
||||
id: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface ExampleRequest {
|
||||
name: string;
|
||||
}
|
||||
21
templates/base/tsconfig.json
Normal file
21
templates/base/tsconfig.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2017",
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"noEmit": true,
|
||||
"esModuleInterop": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "bundler",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"jsx": "react-jsx",
|
||||
"incremental": true,
|
||||
"plugins": [{ "name": "next" }],
|
||||
"paths": { "@/*": ["./src/*"] }
|
||||
},
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", ".next/dev/types/**/*.ts", "**/*.mts"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
24
tsconfig.json
Normal file
24
tsconfig.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"lib": [
|
||||
"ES2022"
|
||||
],
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"rootDir": "src",
|
||||
"outDir": "dist",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"declaration": true,
|
||||
"sourceMap": true,
|
||||
"types": [
|
||||
"node"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user