πΊοΈ Next.js Route Visualizer
Next.js νλ‘μ νΈμ λΌμ°νΈ ꡬ쑰μ λ€λΉκ²μ΄μ
μ ν λμ μκ°νν΄λ³΄μΈμ!
ν λ²μ λͺ
λ Ήμ΄λ‘ λΌμ°νΈ κ·Έλν JSONκ³Ό μΈν°λν°λΈ HTML 리ν¬νΈλ₯Ό μμ±ν©λλ€.
β¨ νΉμ§
- π μν΄λ¦ μ€ν:
npx
λͺ
λ Ήμ΄ νλλ‘ μ¦μ μκ°ν
- π λΌμ°νΈ λΆμ: νμ΄μ§μ λ€μ΄λ΄λ―Ή λΌμ°νΈ κ΄κ³ μΆμ
- π― λμ ν¨μ λΆμ:
Router.push(getRoute())
μ κ°μ λμ ν¨μ νΈμΆ λ΄λΆ λΆμ
- π κ³ κΈ λ€λΉκ²μ΄μ
κ°μ§: Routes μμ, νμ΄ν ν¨μ, μ‘°κ±΄λΆ λ€λΉκ²μ΄μ
μ§μ
- π¨ λ κ°μ§ μκ°ν λͺ¨λ:
- π κ·Έλν λ€μ΄μ΄κ·Έλ¨: λλκ·Έ, μ€, νν°λ§ κ°λ₯ν λ
Έλ-λ§ν¬ μκ°ν
- π μΈν°λν°λΈ 리ν¬νΈ: νμ΄μ§ μ νν μ°κ²° νμ μΈν°νμ΄μ€
- πΎ JSON μΆλ ₯: λ€λ₯Έ λꡬμμλ νμ© κ°λ₯ν λ°μ΄ν°
- π μλ λΈλΌμ°μ : μμ± μ¦μ λΈλΌμ°μ μμ μ΄λ¦Ό
π λΉ λ₯Έ μμ
Next.js νλ‘μ νΈμμ λ°λ‘ μ€ν
npx @choi2021/next-route-visualizer
npx @choi2021/next-route-visualizer report
npx @choi2021/next-route-visualizer ./my-next-app
npx @choi2021/next-route-visualizer report ./my-next-app
λͺ
λ Ήμ΄ μ΅μ
npx @choi2021/next-route-visualizer map [project-path]
npx @choi2021/next-route-visualizer report [project-path] [-o output.html]
κ²°κ³Ό
κ·Έλν μκ°ν (map
λͺ
λ Ήμ΄):
route-graph.json
- λΌμ°νΈ λ°μ΄ν°
route-visualizer.html
- λ
Έλ-λ§ν¬ κ·Έλν μκ°ν
HTML 리ν¬νΈ (report
λͺ
λ Ήμ΄):
route-graph.json
- λΌμ°νΈ λ°μ΄ν°
route-report.html
- νμ΄μ§ μ νν μΈν°λν°λΈ 리ν¬νΈ
π μμ€ν
μꡬμ¬ν
- Node.js 14.0.0 μ΄μ
- Next.js νλ‘μ νΈ (pages/ λλ src/pages/ ꡬ쑰)
π‘ μ¬μ© μμ
$ npx @choi2021/next-route-visualizer report
π Next.js Route HTML Report Generator v1.0.0
π λΌμ°νΈ λΆμ μ€...
π HTML 리ν¬νΈ μμ± μ€...
β
HTML 리ν¬νΈκ° μμ±λμμ΅λλ€: route-report.html
π μ΄ 9κ° νμ΄μ§, 139κ° μ°κ²° λΆμ μλ£
π λΈλΌμ°μ μμ 리ν¬νΈλ₯Ό μ΄μμ΅λλ€!
π¨ μκ°ν λͺ¨λ
1. π κ·Έλν λ€μ΄μ΄κ·Έλ¨ (map
)
- μ»¬λ¬ μ½λ©: νμ΄μ§(νλμ), λ€μ΄λ΄λ―Ή λΌμ°νΈ(μ£Όν©μ)
- μΈν°λν°λΈ κ·Έλν: λ
Έλ λλκ·Έ, μ€ μΈ/μμ, ν¬
- μΈλΆ μ 보: νΈλ²μ νμΌ κ²½λ‘, μ½λ μ€λν«, λΌμΈ λ²νΈ νμ
- μ°κ²° μΆμ : νμ΄μ§κ° λ€λΉκ²μ΄μ
κ΄κ³ μκ°ν
2. π μΈν°λν°λΈ 리ν¬νΈ (report
)
- μ¬μ΄λλ°: μ°κ²° μ κΈ°μ€ μ λ ¬λ νμ΄μ§ λͺ©λ‘
- νμ΄μ§ μμΈ: μ νλ νμ΄μ§μ incoming/outgoing μ°κ²° νμ
- νλ‘μ νΈ ν΅κ³: μ 체 νμ΄μ§, μ°κ²° μ, νκ· μ°κ²° μ
- κ²μ κΈ°λ₯: νμ΄μ§ κ²½λ‘ μ€μκ° κ²μ
- ν΄λ¦ λ€λΉκ²μ΄μ
: μ°κ²°λ νμ΄μ§ κ° μ¬μ΄ μ΄λ
π μΆλ ₯ λ°μ΄ν° ꡬ쑰
route-graph.json
μ ꡬ쑰:
{
"nodes": [
{
"id": "/",
"path": "/",
"type": "page",
"filePath": "pages/index.tsx",
"fileSize": 2203,
"metadata": { "depth": 0, "segments": [""] }
}
],
"edges": [
{
"source": "/",
"target": "/about",
"method": "link",
"lineNumber": 25,
"codeSnippet": "<Link href='/about'>",
"fileName": "pages/index.tsx"
}
],
"summary": {
"totalPages": 9,
"totalConnections": 139,
"avgConnections": 15.4
}
}
π μ°κ²° λΆμ νμ
- link: Next.js Link μ»΄ν¬λνΈ
- router: router.push(), router.replace() λ±
- component: μ»΄ν¬λνΈλ₯Ό ν΅ν κ°μ λ€λΉκ²μ΄μ
π οΈ κ°λ° λ° λλ²κΉ
λ‘컬 κ°λ°
git clone https://github.com/your-username/next-route-map.git
cd next-route-map
npm install
npm run build
npm run test:example
npm run test:report
π€ κΈ°μ¬νκΈ°
λ²κ·Έ 리ν¬νΈμ κΈ°λ₯ μ μμ GitHub Issuesμμ νμν©λλ€.
π λΌμ΄μ μ€
MIT License
β νλ‘μ νΈκ° μ μ©νλ€λ©΄ GitHubμμ λ³νλ₯Ό λλ¬μ£ΌμΈμ!
π― κ³ κΈ λΆμ κΈ°λ₯ (v1.1.0)
λμ ν¨μ λΆμ
μ΄μ λ€μκ³Ό κ°μ 볡μ‘ν λ€λΉκ²μ΄μ
ν¨ν΄λ μ νν λΆμν©λλ€:
const getRoute = () => {
if (condition) {
return V2_Routes.ADMIN_PANEL();
} else {
return Routes.PROFILE();
}
};
const handleClick = () => {
Router.push(getRoute());
};
export const V2_Routes = {
ADMIN_PANEL: () => "/v2/admin/panel",
USER_PROFILE: (id) => `/v2/user/${id}`,
};
export async function getServerSideProps() {
if (!authenticated) {
return { redirect: { destination: "/login" } };
}
}
Router.push(Routes.HOME());
router.push(Routes.PROFILE());
μ§μνλ λ€λΉκ²μ΄μ
ν¨ν΄
- β
μ μ κ²½λ‘:
"/dashboard"
, '/profile'
- β
Routes μμ:
Routes.HOME
, ROUTES.DASHBOARD
- β
ν¨μν Routes:
Routes.PROFILE()
, V2_Routes.ADMIN()
- β
λμ ν¨μ νΈμΆ:
Router.push(getRoute())
- β
μ‘°κ±΄λΆ λ¦¬ν΄:
if/else
λΈλ‘ λ΄ λ€λΉκ²μ΄μ
- β
ν
νλ¦Ώ 리ν°λ΄:
`/dashboard?tab=${tab}`
- β
getServerSideProps 리λλ μ
- β
useEffect λ΄ λ€λΉκ²μ΄μ
- β
ν
κΈ°λ° λ€λΉκ²μ΄μ