@vv0rkz/js-template 1.4.1 → 1.4.3

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/init.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { fileURLToPath } from 'url'
3
3
  import { dirname, join } from 'path'
4
- import { copyFileSync, mkdirSync, existsSync, readFileSync, writeFileSync, readdirSync, statSync } from 'fs'
4
+ import { copyFileSync, mkdirSync, existsSync, readFileSync, writeFileSync, readdirSync, statSync, unlinkSync } from 'fs'
5
5
  import { execSync, spawnSync } from 'child_process'
6
6
  import * as readline from 'readline'
7
7
 
@@ -53,30 +53,34 @@ if (!hasGit) {
53
53
 
54
54
  // 1. Копирование конфигов с интерактивной перезаписью
55
55
  console.log('\n📋 Копирование конфигов...')
56
- const filesToCopy = ['.gitignore', 'changelog.config.js', 'commitlint.config.js']
56
+ const filesToCopy = [
57
+ { src: 'gitignore', dest: '.gitignore' },
58
+ { src: 'changelog.config.js', dest: 'changelog.config.js' },
59
+ { src: 'commitlint.config.js', dest: 'commitlint.config.js' },
60
+ ]
57
61
 
58
62
  for (const file of filesToCopy) {
59
- const src = join(templateDir, file)
60
- const dest = join(targetDir, file)
63
+ const src = join(templateDir, file.src)
64
+ const dest = join(targetDir, file.dest)
61
65
 
62
66
  if (!existsSync(src)) {
63
- console.log(` ⚠️ ${file} не найден в template (пропускаем)`)
67
+ console.log(` ⚠️ ${file.dest} не найден в template (пропускаем)`)
64
68
  continue
65
69
  }
66
70
 
67
71
  if (existsSync(dest)) {
68
72
  // Файл существует - спрашиваем что делать
69
- const answer = await askQuestion(` ❓ ${file} уже существует. Перезаписать? (y/N): `)
73
+ const answer = await askQuestion(` ❓ ${file.dest} уже существует. Перезаписать? (y/N): `)
70
74
 
71
75
  if (answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes') {
72
76
  copyFileSync(src, dest)
73
- console.log(` ✅ ${file} (перезаписан)`)
77
+ console.log(` ✅ ${file.dest} (перезаписан)`)
74
78
  } else {
75
- console.log(` ⏭️ ${file} (пропущен)`)
79
+ console.log(` ⏭️ ${file.dest} (пропущен)`)
76
80
  }
77
81
  } else {
78
82
  copyFileSync(src, dest)
79
- console.log(` ✅ ${file}`)
83
+ console.log(` ✅ ${file.dest}`)
80
84
  }
81
85
  }
82
86
 
@@ -156,6 +160,14 @@ try {
156
160
  console.log('\n🔗 Активация husky...')
157
161
  try {
158
162
  execSync('npx husky init', { stdio: 'inherit', cwd: targetDir })
163
+
164
+ // Удаляем дефолтный pre-commit с npm test
165
+ const defaultPreCommit = join(targetDir, '.husky', 'pre-commit')
166
+ if (existsSync(defaultPreCommit)) {
167
+ unlinkSync(defaultPreCommit) // ← Теперь без await import
168
+ console.log(' 🧹 Удалён дефолтный pre-commit')
169
+ }
170
+
159
171
  console.log(' ✅ Husky активирован')
160
172
  } catch (error) {
161
173
  console.log(' ⚠️ Husky уже инициализирован')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vv0rkz/js-template",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
4
4
  "description": "Reusable setup for JS projects with husky, changelog, gh tools",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,38 @@
1
+ # dependencies
2
+ node_modules/
3
+ npm-debug.log*
4
+ yarn-debug.log*
5
+ yarn-error.log*
6
+
7
+ # production builds
8
+ dist/
9
+ build/
10
+
11
+ # environment variables
12
+ .env
13
+ .env.local
14
+ .env.development.local
15
+ .env.test.local
16
+ .env.production.local
17
+
18
+ # logs
19
+ *.log
20
+ logs/
21
+
22
+ # IDE
23
+ .vscode/
24
+ .idea/
25
+ *.swp
26
+ *.swo
27
+
28
+ # OS
29
+ .DS_Store
30
+ Thumbs.db
31
+
32
+ # Optional
33
+ .coverage/
34
+ .nyc_output/
35
+
36
+ .cache/
37
+ .webpack/
38
+ .eslintcache