@vv0rkz/js-template 1.1.1 → 1.3.0
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 +31 -8
- package/bin/init.js +12 -0
- package/package.json +1 -1
- package/tools-gh/init-readme.js +61 -0
- package/tools-gh/setup-labels.js +59 -0
package/bin/cli.js
CHANGED
|
@@ -2,22 +2,37 @@
|
|
|
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')
|
|
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
|
+
|
|
29
|
+
'setup-labels': () => {
|
|
30
|
+
spawnSync('node', [join(toolsDir, 'setup-labels.js')], { stdio: 'inherit' })
|
|
31
|
+
},
|
|
32
|
+
|
|
19
33
|
changelog: () => {
|
|
20
|
-
|
|
34
|
+
// БЕЗ shell: true
|
|
35
|
+
spawnSync(npxCmd, ['changelogen', ...commandArgs], { stdio: 'inherit' })
|
|
21
36
|
},
|
|
22
37
|
|
|
23
38
|
release: () => {
|
|
@@ -29,7 +44,7 @@ const commands = {
|
|
|
29
44
|
process.exit(1)
|
|
30
45
|
}
|
|
31
46
|
|
|
32
|
-
const changelog = spawnSync(
|
|
47
|
+
const changelog = spawnSync(npxCmd, ['changelogen', '--release'], { stdio: 'inherit' })
|
|
33
48
|
if (changelog.status !== 0) {
|
|
34
49
|
console.error('❌ Ошибка создания changelog')
|
|
35
50
|
process.exit(1)
|
|
@@ -48,7 +63,8 @@ const commands = {
|
|
|
48
63
|
},
|
|
49
64
|
|
|
50
65
|
bugs: () => {
|
|
51
|
-
|
|
66
|
+
// БЕЗ shell: true — убирает warning
|
|
67
|
+
spawnSync(ghCmd, ['issue', 'list', '--label', 'bug', '--state', 'open'], { stdio: 'inherit' })
|
|
52
68
|
},
|
|
53
69
|
|
|
54
70
|
'create-bug': () => {
|
|
@@ -56,12 +72,14 @@ const commands = {
|
|
|
56
72
|
spawnSync('node', [join(toolsDir, 'create-bug.js')], { stdio: 'inherit' })
|
|
57
73
|
} else {
|
|
58
74
|
const title = commandArgs.join(' ')
|
|
59
|
-
|
|
75
|
+
// БЕЗ shell: true — теперь пробелы работают!
|
|
76
|
+
spawnSync(ghCmd, ['issue', 'create', '--label', 'bug', '--title', title], { stdio: 'inherit' })
|
|
60
77
|
}
|
|
61
78
|
},
|
|
62
79
|
|
|
63
80
|
tasks: () => {
|
|
64
|
-
|
|
81
|
+
// БЕЗ shell: true
|
|
82
|
+
spawnSync(ghCmd, ['issue', 'list', '--label', 'task', '--state', 'open'], { stdio: 'inherit' })
|
|
65
83
|
},
|
|
66
84
|
|
|
67
85
|
'create-task': () => {
|
|
@@ -69,12 +87,14 @@ const commands = {
|
|
|
69
87
|
spawnSync('node', [join(toolsDir, 'create-task.js')], { stdio: 'inherit' })
|
|
70
88
|
} else {
|
|
71
89
|
const title = commandArgs.join(' ')
|
|
72
|
-
|
|
90
|
+
// БЕЗ shell: true — теперь пробелы работают!
|
|
91
|
+
spawnSync(ghCmd, ['issue', 'create', '--label', 'task', '--title', title], { stdio: 'inherit' })
|
|
73
92
|
}
|
|
74
93
|
},
|
|
75
94
|
|
|
76
95
|
'all-issues': () => {
|
|
77
|
-
|
|
96
|
+
// БЕЗ shell: true
|
|
97
|
+
spawnSync(ghCmd, ['issue', 'list', '--state', 'open'], { stdio: 'inherit' })
|
|
78
98
|
},
|
|
79
99
|
}
|
|
80
100
|
|
|
@@ -88,6 +108,8 @@ if (commands[command]) {
|
|
|
88
108
|
|
|
89
109
|
📋 ПРОЕКТ:
|
|
90
110
|
jst init Инициализация проекта
|
|
111
|
+
jst init-readme Создать стартовый README.md
|
|
112
|
+
jst setup-labels Настроить GitHub labels
|
|
91
113
|
|
|
92
114
|
🔧 РАЗРАБОТКА:
|
|
93
115
|
jst changelog Создать changelog
|
|
@@ -104,6 +126,7 @@ if (commands[command]) {
|
|
|
104
126
|
|
|
105
127
|
📚 ПРИМЕРЫ:
|
|
106
128
|
jst init
|
|
129
|
+
jst init-readme
|
|
107
130
|
jst create-task "Добавить темную тему"
|
|
108
131
|
jst release
|
|
109
132
|
jst tasks
|
package/bin/init.js
CHANGED
|
@@ -107,6 +107,18 @@ try {
|
|
|
107
107
|
} catch (error) {
|
|
108
108
|
console.log(' ⚠️ Husky уже инициализирован')
|
|
109
109
|
}
|
|
110
|
+
// 7. Настройка GitHub labels
|
|
111
|
+
console.log('\n🏷️ Настройка GitHub labels...')
|
|
112
|
+
try {
|
|
113
|
+
execSync('gh auth status', { stdio: 'ignore' })
|
|
114
|
+
const setupLabels = spawnSync('node', [join(toolsDir, 'setup-labels.js')], { stdio: 'inherit' })
|
|
115
|
+
if (setupLabels.status === 0) {
|
|
116
|
+
console.log(' ✅ Labels настроены')
|
|
117
|
+
}
|
|
118
|
+
} catch (error) {
|
|
119
|
+
console.log(' ⏭️ Пропущено (GitHub CLI не настроен)')
|
|
120
|
+
console.log(' Запусти позже: npm run _ setup-labels')
|
|
121
|
+
}
|
|
110
122
|
|
|
111
123
|
console.log(`
|
|
112
124
|
🎉 JS Template успешно установлен!
|
package/package.json
CHANGED
|
@@ -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 — для обновления истории версий')
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { execSync } from 'child_process'
|
|
3
|
+
|
|
4
|
+
console.log('🏷️ Настройка GitHub labels...\n')
|
|
5
|
+
|
|
6
|
+
const labels = [
|
|
7
|
+
{ name: 'task', color: '0E8A16', description: 'Задача для реализации' },
|
|
8
|
+
{ name: 'bug', color: 'D73A4A', description: 'Баг который нужно исправить' },
|
|
9
|
+
{ name: 'enhancement', color: 'A2EEEF', description: 'Улучшение функционала' },
|
|
10
|
+
{ name: 'documentation', color: '0075CA', description: 'Документация' },
|
|
11
|
+
{ name: 'question', color: 'D876E3', description: 'Вопрос' },
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
try {
|
|
15
|
+
// Проверяем что gh установлен и авторизован
|
|
16
|
+
execSync('gh auth status', { stdio: 'ignore' })
|
|
17
|
+
} catch (error) {
|
|
18
|
+
console.error('❌ GitHub CLI не установлен или не авторизован')
|
|
19
|
+
console.log('💡 Установи: https://cli.github.com/')
|
|
20
|
+
console.log(' И выполни: gh auth login')
|
|
21
|
+
process.exit(1)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Получаем существующие labels
|
|
25
|
+
let existingLabels = []
|
|
26
|
+
try {
|
|
27
|
+
const output = execSync('gh label list --json name', { encoding: 'utf8' })
|
|
28
|
+
existingLabels = JSON.parse(output).map((l) => l.name)
|
|
29
|
+
} catch (error) {
|
|
30
|
+
console.log('⚠️ Не удалось получить список labels (возможно репозиторий пустой)')
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Создаём недостающие labels
|
|
34
|
+
let created = 0
|
|
35
|
+
let skipped = 0
|
|
36
|
+
|
|
37
|
+
for (const label of labels) {
|
|
38
|
+
if (existingLabels.includes(label.name)) {
|
|
39
|
+
console.log(` ⏭️ ${label.name} (уже существует)`)
|
|
40
|
+
skipped++
|
|
41
|
+
continue
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
execSync(`gh label create "${label.name}" --color "${label.color}" --description "${label.description}"`, {
|
|
46
|
+
stdio: 'ignore',
|
|
47
|
+
})
|
|
48
|
+
console.log(` ✅ ${label.name}`)
|
|
49
|
+
created++
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.log(` ⚠️ ${label.name} (ошибка создания)`)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
console.log(`\n📊 Итого: создано ${created}, пропущено ${skipped}`)
|
|
56
|
+
|
|
57
|
+
if (created > 0) {
|
|
58
|
+
console.log('✅ Labels настроены!')
|
|
59
|
+
}
|