@vv0rkz/js-template 1.1.1 → 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,22 +2,33 @@
2
2
  import { fileURLToPath } from 'url'
3
3
  import { dirname, join } from 'path'
4
4
  import { spawnSync } from 'child_process'
5
+ import { platform } from 'os'
5
6
 
6
7
  const __dirname = dirname(fileURLToPath(import.meta.url))
7
- const toolsDir = join(__dirname, '../tools-gh') // ВСЕГДА из node_modules
8
+ const toolsDir = join(__dirname, '../tools-gh')
8
9
 
9
10
  const args = process.argv.slice(2)
10
11
  const command = args[0]
11
12
  const commandArgs = args.slice(1)
12
13
 
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
+
13
19
  const commands = {
14
20
  init: () => {
15
21
  const initScript = join(__dirname, 'init.js')
16
22
  spawnSync('node', [initScript], { stdio: 'inherit' })
17
23
  },
18
24
 
25
+ 'init-readme': () => {
26
+ spawnSync('node', [join(toolsDir, 'init-readme.js')], { stdio: 'inherit' })
27
+ },
28
+
19
29
  changelog: () => {
20
- spawnSync('npx', ['changelogen', ...commandArgs], { stdio: 'inherit', shell: true })
30
+ // БЕЗ shell: true
31
+ spawnSync(npxCmd, ['changelogen', ...commandArgs], { stdio: 'inherit' })
21
32
  },
22
33
 
23
34
  release: () => {
@@ -29,7 +40,7 @@ const commands = {
29
40
  process.exit(1)
30
41
  }
31
42
 
32
- const changelog = spawnSync('npx', ['changelogen', '--release'], { stdio: 'inherit', shell: true })
43
+ const changelog = spawnSync(npxCmd, ['changelogen', '--release'], { stdio: 'inherit' })
33
44
  if (changelog.status !== 0) {
34
45
  console.error('❌ Ошибка создания changelog')
35
46
  process.exit(1)
@@ -48,7 +59,8 @@ const commands = {
48
59
  },
49
60
 
50
61
  bugs: () => {
51
- 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' })
52
64
  },
53
65
 
54
66
  'create-bug': () => {
@@ -56,12 +68,14 @@ const commands = {
56
68
  spawnSync('node', [join(toolsDir, 'create-bug.js')], { stdio: 'inherit' })
57
69
  } else {
58
70
  const title = commandArgs.join(' ')
59
- 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' })
60
73
  }
61
74
  },
62
75
 
63
76
  tasks: () => {
64
- 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' })
65
79
  },
66
80
 
67
81
  'create-task': () => {
@@ -69,12 +83,14 @@ const commands = {
69
83
  spawnSync('node', [join(toolsDir, 'create-task.js')], { stdio: 'inherit' })
70
84
  } else {
71
85
  const title = commandArgs.join(' ')
72
- 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' })
73
88
  }
74
89
  },
75
90
 
76
91
  'all-issues': () => {
77
- spawnSync('gh', ['issue', 'list', '--state', 'open'], { stdio: 'inherit', shell: true })
92
+ // БЕЗ shell: true
93
+ spawnSync(ghCmd, ['issue', 'list', '--state', 'open'], { stdio: 'inherit' })
78
94
  },
79
95
  }
80
96
 
@@ -88,6 +104,7 @@ if (commands[command]) {
88
104
 
89
105
  📋 ПРОЕКТ:
90
106
  jst init Инициализация проекта
107
+ jst init-readme Создать стартовый README.md
91
108
 
92
109
  🔧 РАЗРАБОТКА:
93
110
  jst changelog Создать changelog
@@ -104,6 +121,7 @@ if (commands[command]) {
104
121
 
105
122
  📚 ПРИМЕРЫ:
106
123
  jst init
124
+ jst init-readme
107
125
  jst create-task "Добавить темную тему"
108
126
  jst release
109
127
  jst tasks
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vv0rkz/js-template",
3
- "version": "1.1.1",
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 — для обновления истории версий')