create-vite-react-boot 1.0.10 → 1.0.12
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/bin/cli.js +52 -21
- package/lib/apply.js +0 -12
- package/package.json +1 -1
package/bin/cli.js
CHANGED
@@ -3,16 +3,31 @@ import { fileURLToPath } from "url";
|
|
3
3
|
import path from "path";
|
4
4
|
import fs from "fs";
|
5
5
|
import prompts from "prompts";
|
6
|
-
import spawn from "cross-spawn"; //
|
6
|
+
import spawn from "cross-spawn"; // 크로스플랫폼 스폰
|
7
7
|
import { green, yellow, red, cyan, bold } from "kolorist";
|
8
8
|
import { applyScaffold } from "../lib/apply.js";
|
9
9
|
|
10
10
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
11
11
|
const cwd = process.cwd();
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
const child = spawn(cmd, args, {
|
13
|
+
/** 조용히 실행(로그 숨김) */
|
14
|
+
function runQuiet(cmd, args = [], options = {}) {
|
15
|
+
const child = spawn.sync(cmd, args, {
|
16
|
+
stdio: "pipe", // ← 출력 숨김
|
17
|
+
shell: false,
|
18
|
+
...options,
|
19
|
+
});
|
20
|
+
const code = child.status ?? 0;
|
21
|
+
if (code !== 0) process.exit(code);
|
22
|
+
}
|
23
|
+
|
24
|
+
/** 로그를 보여주며 실행(서브프로세스 출력 노출) */
|
25
|
+
function runPrint(cmd, args = [], options = {}) {
|
26
|
+
const child = spawn.sync(cmd, args, {
|
27
|
+
stdio: "inherit", // ← 출력 표시
|
28
|
+
shell: false,
|
29
|
+
...options,
|
30
|
+
});
|
16
31
|
const code = child.status ?? 0;
|
17
32
|
if (code !== 0) process.exit(code);
|
18
33
|
}
|
@@ -52,8 +67,8 @@ function isEmptyDir(dir) {
|
|
52
67
|
message: "프로젝트 이름?",
|
53
68
|
initial: "myapp",
|
54
69
|
validate: (v) =>
|
55
|
-
!v || /[\\/:*?"<>|]/.test(v) ? "유효한 폴더명을 입력하세요." : true
|
56
|
-
}
|
70
|
+
!v || /[\\/:*?"<>|]/.test(v) ? "유효한 폴더명을 입력하세요." : true,
|
71
|
+
},
|
57
72
|
],
|
58
73
|
{ onCancel: () => process.exit(1) }
|
59
74
|
);
|
@@ -66,7 +81,7 @@ function isEmptyDir(dir) {
|
|
66
81
|
|
67
82
|
const target = path.resolve(cwd, appName);
|
68
83
|
|
69
|
-
// 같은 폴더에서 다시 실행 방지: 이미
|
84
|
+
// 같은 폴더에서 다시 실행 방지: 이미 뭔가 있으면 중단
|
70
85
|
if (fs.existsSync(target) && !isEmptyDir(target)) {
|
71
86
|
console.log(red(`✖ 대상 폴더가 비어있지 않습니다: ${target}`));
|
72
87
|
process.exit(1);
|
@@ -89,13 +104,13 @@ function isEmptyDir(dir) {
|
|
89
104
|
scripts: {
|
90
105
|
dev: "vite",
|
91
106
|
build: "tsc -b && vite build",
|
92
|
-
preview: "vite preview"
|
107
|
+
preview: "vite preview",
|
93
108
|
},
|
94
109
|
dependencies: {
|
95
110
|
react: "^18.3.1",
|
96
111
|
"react-dom": "^18.3.1",
|
97
112
|
"react-router-dom": "^6.26.1",
|
98
|
-
axios: "^1.7.7"
|
113
|
+
axios: "^1.7.7",
|
99
114
|
},
|
100
115
|
devDependencies: {
|
101
116
|
typescript: "^5.5.4",
|
@@ -103,8 +118,8 @@ function isEmptyDir(dir) {
|
|
103
118
|
"@vitejs/plugin-react": "^4.3.1",
|
104
119
|
tailwindcss: "^3.4.10",
|
105
120
|
postcss: "^8.4.47",
|
106
|
-
autoprefixer: "^10.4.20"
|
107
|
-
}
|
121
|
+
autoprefixer: "^10.4.20",
|
122
|
+
},
|
108
123
|
};
|
109
124
|
writeJSON(path.join(target, "package.json"), pkgJson);
|
110
125
|
|
@@ -170,7 +185,7 @@ dist
|
|
170
185
|
<head>
|
171
186
|
<meta charset="UTF-8" />
|
172
187
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
173
|
-
<title
|
188
|
+
<title>react+boot</title>
|
174
189
|
</head>
|
175
190
|
<body>
|
176
191
|
<div id="root"></div>
|
@@ -260,20 +275,36 @@ export default function App(){
|
|
260
275
|
);
|
261
276
|
|
262
277
|
// ─────────────────────────────────────────────
|
263
|
-
// 2) 1회 설치 (
|
278
|
+
// 2) 1회 설치 (조용히 설치: fund/audit 등 장황 로그 숨김)
|
264
279
|
// ─────────────────────────────────────────────
|
265
|
-
console.log(yellow(`\n▶ 의존성 설치
|
266
|
-
|
280
|
+
console.log(yellow(`\n▶ 의존성 설치 중입니다. 잠시만 기다려주세요…\n`));
|
281
|
+
|
282
|
+
// 패키지 매니저별 silent 옵션
|
283
|
+
const silentFlag =
|
284
|
+
pm === "npm" ? "--silent" :
|
285
|
+
pm === "yarn" ? "--silent" :
|
286
|
+
pm === "pnpm" ? "--silent" :
|
287
|
+
"";
|
288
|
+
|
289
|
+
runQuiet(pm, ["install", ...(silentFlag ? [silentFlag] : [])], { cwd: target });
|
290
|
+
console.log(green(" → 의존성 설치 완료!\n"));
|
267
291
|
|
268
292
|
// ─────────────────────────────────────────────
|
269
293
|
// 3) 인증/라우팅/axios/Tailwind 추가 파일 (파일만 생성, 설치 없음)
|
270
294
|
// ─────────────────────────────────────────────
|
271
|
-
console.log(yellow("
|
295
|
+
console.log(yellow("▶ 인증/라우팅/Tailwind/axios 스캐폴딩 적용…"));
|
272
296
|
await applyScaffold({ root: target });
|
273
297
|
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
298
|
+
// ─────────────────────────────────────────────
|
299
|
+
// 4) 자동 cd + dev 서버 실행
|
300
|
+
// ─────────────────────────────────────────────
|
301
|
+
console.log(green("\n✅ 프로젝트 준비 완료!\n"));
|
302
|
+
console.log(cyan("▶ 개발 서버를 시작합니다…\n"));
|
303
|
+
|
304
|
+
// 작업 디렉토리 전환 후 dev 실행
|
305
|
+
process.chdir(target);
|
306
|
+
|
307
|
+
// npm / yarn / pnpm 공통: pm run dev
|
308
|
+
runPrint(pm, ["run", "dev"], { cwd: target });
|
279
309
|
})();
|
310
|
+
|
package/lib/apply.js
CHANGED
@@ -286,18 +286,6 @@ export function useAuth() {
|
|
286
286
|
if (!ctx) throw new Error('useAuth must be used within AuthProvider')
|
287
287
|
return ctx
|
288
288
|
}
|
289
|
-
|
290
|
-
`,
|
291
|
-
axiosClient: `import axios from 'axios'
|
292
|
-
export const api = axios.create({ baseURL: '/api', timeout: 8000 })
|
293
|
-
api.interceptors.request.use(cfg=>{
|
294
|
-
const raw = localStorage.getItem('session_v1')
|
295
|
-
if(raw){
|
296
|
-
const token = (JSON.parse(raw) as { id:string }).id
|
297
|
-
cfg.headers.Authorization = 'Bearer ' + token
|
298
|
-
}
|
299
|
-
return cfg
|
300
|
-
})
|
301
289
|
`,
|
302
290
|
axiosAuthApi: `import { api } from './client'
|
303
291
|
type Session = { id:string; email:string; name:string }
|