create-express-esm 1.0.8 → 1.1.2

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 CHANGED
@@ -13,7 +13,7 @@ const __filename = fileURLToPath(import.meta.url);
13
13
  const __dirname = path.dirname(__filename);
14
14
 
15
15
  program
16
- .version('1.0.0')
16
+ .version('1.1.0') // 이슈 해결을 반영하여 버전 상향
17
17
  .description('Layered Architecture 기반의 Modern Express 프로젝트 생성기');
18
18
 
19
19
  program
@@ -34,56 +34,66 @@ program
34
34
  const targetPath = path.join(process.cwd(), projectName);
35
35
  const templatePath = path.join(__dirname, '../template');
36
36
 
37
- // 2. 템플릿 복사
38
- console.log(chalk.cyan(`\n📂 템플릿을 복사하는 중...`));
37
+ // 2. 템플릿 복사 및 환경 설정
39
38
  try {
40
39
  if (fs.existsSync(targetPath)) {
41
40
  console.error(chalk.red(`❌ 오류: '${projectName}' 폴더가 이미 존재합니다.`));
42
41
  process.exit(1);
43
42
  }
44
43
 
44
+ console.log(chalk.cyan(`\n📂 템플릿을 복사하는 중...`));
45
45
  await fs.copy(templatePath, targetPath);
46
46
 
47
- // [추가된 부분] 파일 이름 변경 로직 (gitignore -> .gitignore)
48
- // npm이 .gitignore를 멋대로 삭제하는 것을 방지하기 위함
49
- const gitignorePath = path.join(targetPath, 'gitignore');
50
- const dotGitignorePath = path.join(targetPath, '.gitignore');
51
-
52
- const envPath = path.join(targetPath, '_env'); // 만약 _env로 바꿨다면
53
- const dotEnvPath = path.join(targetPath, '.env');
47
+ /**
48
+ * [이슈 #1 해결] 도트 파일(Dotfiles) 이름 변경 로직
49
+ * NPM 배포 시 무시되는 .gitignore와 .env를 처리합니다.
50
+ */
51
+ const renameMap = {
52
+ 'gitignore': '.gitignore', // 기존 사용 방식 대응
53
+ '_gitignore': '.gitignore', // 신규 권장 방식 대응
54
+ '_env': '.env' // .env 대응
55
+ };
54
56
 
55
- // 파일이 실제로 존재하는지 확인 이름 변경
56
- if (await fs.pathExists(gitignorePath)) {
57
- await fs.move(gitignorePath, dotGitignorePath);
58
- }
59
-
60
- if (await fs.pathExists(envPath)) {
61
- await fs.move(envPath, dotEnvPath);
57
+ for (const [oldName, newName] of Object.entries(renameMap)) {
58
+ const oldFilePath = path.join(targetPath, oldName);
59
+ const newFilePath = path.join(targetPath, newName);
60
+
61
+ if (await fs.pathExists(oldFilePath)) {
62
+ await fs.move(oldFilePath, newFilePath, { overwrite: true });
63
+
64
+ // .env가 생성될 때 .env.example도 함께 생성 (DX 개선)
65
+ if (newName === '.env') {
66
+ const exampleEnvPath = path.join(targetPath, '.env.example');
67
+ await fs.copy(newFilePath, exampleEnvPath);
68
+ }
69
+ }
62
70
  }
63
71
 
64
- // package.json 이름 수정
72
+ // 3. package.json 프로젝트 이름 수정
65
73
  const pkgPath = path.join(targetPath, 'package.json');
66
- const pkg = await fs.readJson(pkgPath);
67
- pkg.name = projectName;
68
- await fs.writeJson(pkgPath, pkg, { spaces: 2 });
74
+ if (await fs.pathExists(pkgPath)) {
75
+ const pkg = await fs.readJson(pkgPath);
76
+ pkg.name = projectName;
77
+ await fs.writeJson(pkgPath, pkg, { spaces: 2 });
78
+ }
69
79
 
70
- console.log(chalk.green(`✅ 복사 완료!`));
80
+ console.log(chalk.green(`✅ 템플릿 구성 및 환경 설정 완료!`));
71
81
 
72
- // 3. 자동 설치 (핵심 기능!)
82
+ // 4. 패키지 자동 설치
73
83
  console.log(chalk.yellow(`\n📦 패키지 자동 설치를 진행합니다... (npm install)`));
74
84
 
75
85
  execSync('npm install', {
76
86
  cwd: targetPath,
77
- stdio: 'inherit' // 설치 로그를 터미널에 보여줌
87
+ stdio: 'inherit'
78
88
  });
79
89
 
80
90
  console.log(chalk.green(`\n✨ 모든 설치가 완료되었습니다!`));
81
91
  console.log(chalk.white(`\n다음 명령어로 시작하세요:\n`));
82
- console.log(chalk.cyan(` cd ${projectName}`));
83
- console.log(chalk.cyan(` npm run dev`));
92
+ console.log(chalk.cyan(` cd ${projectName}`));
93
+ console.log(chalk.cyan(` npm run dev\n`));
84
94
 
85
95
  } catch (error) {
86
- console.error(chalk.red('오류 발생:'), error);
96
+ console.error(chalk.red('\n❌ 프로젝트 생성 중 오류 발생:'), error);
87
97
  }
88
98
  });
89
99
 
package/package.json CHANGED
@@ -1,27 +1,27 @@
1
- {
2
- "name": "create-express-esm",
3
- "version": "1.0.8",
4
- "description": "A modern CLI tool to bootstrap Express.js applications with ES Modules and Layered Architecture.",
5
- "main": "index.js",
6
- "bin": {
7
- "create-express-esm": "./bin/cli.js"
8
- },
9
- "scripts": {
10
- "test": "echo \"Error: no test specified\" && exit 1",
11
- "deploy": "npm version patch && git push origin main --tags && npm publish"
12
- },
13
- "keywords": [],
14
- "author": "",
15
- "license": "ISC",
16
- "type": "module",
17
- "dependencies": {
18
- "chalk": "^5.6.2",
19
- "commander": "^14.0.2",
20
- "fs-extra": "^11.3.2",
21
- "inquirer": "^13.0.1"
22
- },
23
- "files": [
24
- "bin",
25
- "template"
26
- ]
27
- }
1
+ {
2
+ "name": "create-express-esm",
3
+ "version": "1.1.2",
4
+ "description": "A modern CLI tool to bootstrap Express.js applications with ES Modules and Layered Architecture.",
5
+ "main": "index.js",
6
+ "bin": {
7
+ "create-express-esm": "./bin/cli.js"
8
+ },
9
+ "scripts": {
10
+ "test": "echo \"Error: no test specified\" && exit 1",
11
+ "deploy": "npm version patch && git push origin main --tags && npm publish"
12
+ },
13
+ "keywords": [],
14
+ "author": "",
15
+ "license": "ISC",
16
+ "type": "module",
17
+ "dependencies": {
18
+ "chalk": "^5.6.2",
19
+ "commander": "^14.0.2",
20
+ "fs-extra": "^11.3.2",
21
+ "inquirer": "^13.0.1"
22
+ },
23
+ "files": [
24
+ "bin",
25
+ "template"
26
+ ]
27
+ }
File without changes