@vv0rkz/js-template 1.0.2 → 1.2.1

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
@@ -2,7 +2,7 @@
2
2
  import { fileURLToPath } from 'url'
3
3
  import { dirname, join } from 'path'
4
4
  import { spawnSync } from 'child_process'
5
- import { existsSync } from 'fs'
5
+ import { platform } from 'os'
6
6
 
7
7
  const __dirname = dirname(fileURLToPath(import.meta.url))
8
8
  const toolsDir = join(__dirname, '../tools-gh')
@@ -11,10 +11,10 @@ const args = process.argv.slice(2)
11
11
  const command = args[0]
12
12
  const commandArgs = args.slice(1)
13
13
 
14
- // Проверка наличия tools-gh в текущем проекте
15
- const projectToolsDir = join(process.cwd(), 'tools-gh')
16
- const useProjectTools = existsSync(projectToolsDir)
17
- const scriptsDir = useProjectTools ? projectToolsDir : toolsDir
14
+ // Для Windows npx должен быть npx.cmd без shell
15
+ const isWin = platform() === 'win32'
16
+ const npxCmd = isWin ? 'npx.cmd' : 'npx'
17
+ const ghCmd = isWin ? 'gh.exe' : 'gh'
18
18
 
19
19
  const commands = {
20
20
  init: () => {
@@ -22,65 +22,75 @@ const commands = {
22
22
  spawnSync('node', [initScript], { stdio: 'inherit' })
23
23
  },
24
24
 
25
+ 'init-readme': () => {
26
+ spawnSync('node', [join(toolsDir, 'init-readme.js')], { stdio: 'inherit' })
27
+ },
28
+
25
29
  changelog: () => {
26
- spawnSync('npx', ['changelogen', ...commandArgs], { stdio: 'inherit', shell: true })
30
+ // БЕЗ shell: true
31
+ spawnSync(npxCmd, ['changelogen', ...commandArgs], { stdio: 'inherit' })
27
32
  },
28
33
 
29
34
  release: () => {
30
35
  console.log('🚀 Запуск релиза...\n')
31
36
 
32
- const checkDemo = spawnSync('node', [join(scriptsDir, 'check-demo-for-release.js')], { stdio: 'inherit' })
37
+ const checkDemo = spawnSync('node', [join(toolsDir, 'check-demo-for-release.js')], { stdio: 'inherit' })
33
38
  if (checkDemo.status !== 0) {
34
39
  console.error('❌ Проверка демо не прошла')
35
40
  process.exit(1)
36
41
  }
37
42
 
38
- const changelog = spawnSync('npx', ['changelogen', '--release'], { stdio: 'inherit', shell: true })
43
+ const changelog = spawnSync(npxCmd, ['changelogen', '--release'], { stdio: 'inherit' })
39
44
  if (changelog.status !== 0) {
40
45
  console.error('❌ Ошибка создания changelog')
41
46
  process.exit(1)
42
47
  }
43
48
 
44
- spawnSync('node', [join(scriptsDir, 'update-readme.js')], { stdio: 'inherit' })
49
+ spawnSync('node', [join(toolsDir, 'update-readme.js')], { stdio: 'inherit' })
45
50
  console.log('\n✅ Релиз успешно создан!')
46
51
  },
47
52
 
48
53
  'update-readme': () => {
49
- spawnSync('node', [join(scriptsDir, 'update-readme.js')], { stdio: 'inherit' })
54
+ spawnSync('node', [join(toolsDir, 'update-readme.js')], { stdio: 'inherit' })
50
55
  },
51
56
 
52
57
  'push-release': () => {
53
- spawnSync('node', [join(scriptsDir, 'push-release-to-main.js')], { stdio: 'inherit' })
58
+ spawnSync('node', [join(toolsDir, 'push-release-to-main.js')], { stdio: 'inherit' })
54
59
  },
55
60
 
56
61
  bugs: () => {
57
- spawnSync('gh', ['issue', 'list', '--label', 'bug', '--state', 'open'], { stdio: 'inherit', shell: true })
62
+ // БЕЗ shell: true — убирает warning
63
+ spawnSync(ghCmd, ['issue', 'list', '--label', 'bug', '--state', 'open'], { stdio: 'inherit' })
58
64
  },
59
65
 
60
66
  'create-bug': () => {
61
67
  if (commandArgs.length === 0) {
62
- spawnSync('node', [join(scriptsDir, 'create-bug.js')], { stdio: 'inherit' })
68
+ spawnSync('node', [join(toolsDir, 'create-bug.js')], { stdio: 'inherit' })
63
69
  } else {
64
70
  const title = commandArgs.join(' ')
65
- spawnSync('gh', ['issue', 'create', '--label', 'bug', '--title', title], { stdio: 'inherit', shell: true })
71
+ // БЕЗ shell: true теперь пробелы работают!
72
+ spawnSync(ghCmd, ['issue', 'create', '--label', 'bug', '--title', title], { stdio: 'inherit' })
66
73
  }
67
74
  },
68
75
 
69
76
  tasks: () => {
70
- spawnSync('gh', ['issue', 'list', '--label', 'task', '--state', 'open'], { stdio: 'inherit', shell: true })
77
+ // БЕЗ shell: true
78
+ spawnSync(ghCmd, ['issue', 'list', '--label', 'task', '--state', 'open'], { stdio: 'inherit' })
71
79
  },
72
80
 
73
81
  'create-task': () => {
74
82
  if (commandArgs.length === 0) {
75
- spawnSync('node', [join(scriptsDir, 'create-task.js')], { stdio: 'inherit' })
83
+ spawnSync('node', [join(toolsDir, 'create-task.js')], { stdio: 'inherit' })
76
84
  } else {
77
85
  const title = commandArgs.join(' ')
78
- spawnSync('gh', ['issue', 'create', '--label', 'task', '--title', title], { stdio: 'inherit', shell: true })
86
+ // БЕЗ shell: true теперь пробелы работают!
87
+ spawnSync(ghCmd, ['issue', 'create', '--label', 'task', '--title', title], { stdio: 'inherit' })
79
88
  }
80
89
  },
81
90
 
82
91
  'all-issues': () => {
83
- spawnSync('gh', ['issue', 'list', '--state', 'open'], { stdio: 'inherit', shell: true })
92
+ // БЕЗ shell: true
93
+ spawnSync(ghCmd, ['issue', 'list', '--state', 'open'], { stdio: 'inherit' })
84
94
  },
85
95
  }
86
96
 
@@ -94,6 +104,7 @@ if (commands[command]) {
94
104
 
95
105
  📋 ПРОЕКТ:
96
106
  jst init Инициализация проекта
107
+ jst init-readme Создать стартовый README.md
97
108
 
98
109
  🔧 РАЗРАБОТКА:
99
110
  jst changelog Создать changelog
@@ -110,6 +121,7 @@ if (commands[command]) {
110
121
 
111
122
  📚 ПРИМЕРЫ:
112
123
  jst init
124
+ jst init-readme
113
125
  jst create-task "Добавить темную тему"
114
126
  jst release
115
127
  jst tasks
package/bin/init.js CHANGED
@@ -58,25 +58,9 @@ if (existsSync(huskyTemplateDir)) {
58
58
  console.log(' ✅ Хуки скопированы')
59
59
  }
60
60
 
61
- // 3. Копирование tools-gh
62
- console.log('\n🔧 Копирование GitHub скриптов...')
63
- const toolsDir = join(targetDir, 'tools-gh')
64
- if (!existsSync(toolsDir)) {
65
- mkdirSync(toolsDir, { recursive: true })
66
- }
67
-
68
- const toolsSourceDir = join(__dirname, '../tools-gh')
69
- if (existsSync(toolsSourceDir)) {
70
- const toolFiles = readdirSync(toolsSourceDir)
71
- toolFiles.forEach((file) => {
72
- const src = join(toolsSourceDir, file)
73
- const dest = join(toolsDir, file)
74
- if (statSync(src).isFile()) {
75
- copyFileSync(src, dest)
76
- console.log(` ✅ ${file}`)
77
- }
78
- })
79
- }
61
+ // 3. НЕ копируем tools-gh — они остаются в node_modules
62
+ console.log('\n🔧 GitHub скрипты...')
63
+ console.log(' ✅ Используются из @vv0rkz/js-template (не копируются)')
80
64
 
81
65
  // 4. Добавление скриптов в package.json
82
66
  console.log('\n📦 Обновление package.json...')
@@ -128,14 +112,16 @@ console.log(`
128
112
  🎉 JS Template успешно установлен!
129
113
 
130
114
  📖 БЫСТРЫЕ КОМАНДЫ:
131
- npm run jst changelog # или: npm run _ changelog
132
- npm run jst release # или: npm run _ release
133
- npm run jst tasks # или: npm run _ tasks
134
- npm run jst create-task # или: npm run _ create-task
115
+ npm run _ changelog # Создать changelog
116
+ npm run _ release # Полный релиз
117
+ npm run _ tasks # Список задач
118
+ npm run _ create-task # Создать задачу
135
119
 
136
120
  📚 ПОЛНЫЙ СПИСОК:
137
- npm run jst
121
+ npm run _
138
122
 
139
123
  🚀 Начни работу:
140
124
  npm run _ create-task "Моя первая задача"
125
+
126
+ 💡 ВАЖНО: tools-gh скрипты используются из node_modules, не копируются в проект
141
127
  `)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vv0rkz/js-template",
3
- "version": "1.0.2",
3
+ "version": "1.2.1",
4
4
  "description": "Reusable setup for JS projects with husky, changelog, gh tools",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env node
2
+ import { readFileSync, writeFileSync, existsSync } from 'fs'
3
+
4
+ console.log('📝 Генерация стартового README.md...')
5
+
6
+ // Читаем package.json
7
+ const packageJson = JSON.parse(readFileSync('package.json', 'utf8'))
8
+
9
+ const projectName = packageJson.name
10
+ const description = packageJson.description || 'Описание проекта'
11
+ const author = packageJson.author || 'vv0rkz'
12
+ const license = packageJson.license || 'MIT'
13
+ const repoUrl = packageJson.repository?.url?.replace('git+', '').replace('.git', '') || ''
14
+
15
+ // Минималистичный шаблон README
16
+ const readmeTemplate = `# ${projectName}
17
+
18
+ ${description}
19
+
20
+ ## 🚀 Быстрый старт
21
+
22
+ \`\`\`bash
23
+ # Установка зависимостей
24
+ npm install
25
+
26
+ # Запуск
27
+ npm run dev
28
+ \`\`\`
29
+
30
+ ## 📋 Команды
31
+
32
+ \`\`\`bash
33
+ npm run dev # Разработка
34
+ npm run _ tasks # Задачи
35
+ npm run _ release # Релиз
36
+ \`\`\`
37
+
38
+ > Проект использует [@vv0rkz/js-template](https://github.com/vv0rkz/js-template) для автоматизации workflow (husky hooks, changelog, GitHub tasks)
39
+
40
+ <!-- AUTOGENERATED_SECTION START -->
41
+ <!-- AUTOGENERATED_SECTION END -->
42
+
43
+ ## 📄 Лицензия
44
+
45
+ ${license} © ${author}
46
+ `
47
+
48
+ // Проверяем существование README
49
+ if (existsSync('README.md')) {
50
+ console.log('⚠️ README.md уже существует')
51
+ console.log('💡 Удали файл или переименуй, чтобы создать новый')
52
+ process.exit(1)
53
+ }
54
+
55
+ // Сохраняем README
56
+ writeFileSync('README.md', readmeTemplate)
57
+ console.log('✅ README.md создан!')
58
+ console.log('\n📝 Теперь:')
59
+ console.log(' 1. Отредактируй описание и добавь детали')
60
+ console.log(' 2. Добавь скриншоты/демо')
61
+ console.log(' 3. npm run _ update-readme — для обновления истории версий')