@vv0rkz/js-template 1.8.0 → 1.8.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/package.json CHANGED
@@ -1,41 +1,41 @@
1
- {
2
- "name": "@vv0rkz/js-template",
3
- "version": "1.8.0",
4
- "description": "Reusable setup for JS projects with husky, changelog, gh tools",
5
- "type": "module",
6
- "bin": {
7
- "jst": "./bin/cli.js",
8
- "js-template": "./bin/cli.js"
9
- },
10
- "files": [
11
- "bin/",
12
- "templates/",
13
- "tools-gh/"
14
- ],
15
- "scripts": {
16
- "test": "echo 'Tests not implemented yet' && exit 0"
17
- },
18
- "keywords": [
19
- "template",
20
- "husky",
21
- "changelog",
22
- "github",
23
- "workflow",
24
- "commitlint"
25
- ],
26
- "author": "vv0rkz",
27
- "license": "MIT",
28
- "repository": {
29
- "type": "git",
30
- "url": "https://github.com/vv0rkz/js-template.git"
31
- },
32
- "dependencies": {
33
- "@commitlint/cli": "^20.1.0",
34
- "@commitlint/config-conventional": "^20.0.0",
35
- "changelogen": "^0.6.2",
36
- "husky": "^9.1.7"
37
- },
38
- "devDependencies": {
39
- "browser-sync": "^3.0.4"
40
- }
41
- }
1
+ {
2
+ "name": "@vv0rkz/js-template",
3
+ "version": "1.8.2",
4
+ "description": "Reusable setup for JS projects with husky, changelog, gh tools",
5
+ "type": "module",
6
+ "bin": {
7
+ "jst": "./bin/cli.js",
8
+ "js-template": "./bin/cli.js"
9
+ },
10
+ "files": [
11
+ "bin/",
12
+ "templates/",
13
+ "tools-gh/"
14
+ ],
15
+ "scripts": {
16
+ "test": "echo 'Tests not implemented yet' && exit 0"
17
+ },
18
+ "keywords": [
19
+ "template",
20
+ "husky",
21
+ "changelog",
22
+ "github",
23
+ "workflow",
24
+ "commitlint"
25
+ ],
26
+ "author": "vv0rkz",
27
+ "license": "MIT",
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "https://github.com/vv0rkz/js-template.git"
31
+ },
32
+ "dependencies": {
33
+ "@commitlint/cli": "^20.1.0",
34
+ "@commitlint/config-conventional": "^20.0.0",
35
+ "changelogen": "^0.6.2",
36
+ "husky": "^9.1.7"
37
+ },
38
+ "devDependencies": {
39
+ "browser-sync": "^3.0.4"
40
+ }
41
+ }
@@ -117,9 +117,4 @@ export default {
117
117
  */
118
118
  depUpdater: false,
119
119
 
120
- /**
121
- * Репозиторий JST для команды `report-issue`
122
- * Формат: 'owner/repo'
123
- */
124
- jstRepo: 'vv0rkz/js-template',
125
120
  }
@@ -32,7 +32,6 @@ const DEFAULTS = {
32
32
  },
33
33
  },
34
34
  depUpdater: false,
35
- jstRepo: 'vv0rkz/js-template',
36
35
  }
37
36
 
38
37
  // --- Branch pattern template engine ---
@@ -15,6 +15,10 @@ console.log('🚀 Запуск релиза...\n')
15
15
 
16
16
  // 1. Current version
17
17
  const currentVersion = JSON.parse(readFileSync('package.json', 'utf8')).version
18
+ if (!currentVersion) {
19
+ console.log('❌ Нет поля version в package.json. Добавь: "version": "X.Y.Z"')
20
+ process.exit(1)
21
+ }
18
22
  console.log(`📦 Текущая версия: ${currentVersion}`)
19
23
 
20
24
  // 2. Demo check (configurable)
@@ -1,10 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import { spawnSync } from 'child_process'
3
3
  import { platform } from 'os'
4
- import { loadConfig } from './config.js'
5
4
 
6
- const config = await loadConfig()
7
- const jstRepo = config.jstRepo
5
+ const jstRepo = 'vv0rkz/js-template'
8
6
  const isWin = platform() === 'win32'
9
7
  const ghCmd = isWin ? 'gh.exe' : 'gh'
10
8
 
@@ -1,6 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import { execSync } from 'child_process'
2
+ import { execSync, spawnSync } from 'child_process'
3
3
  import { existsSync, readFileSync, writeFileSync } from 'fs'
4
+ import { loadConfig } from './config.js'
5
+
6
+ const config = await loadConfig()
7
+ const demoDir = config.release.demoDir
4
8
 
5
9
  console.log('🎨 Обновляю README релизами с демо...')
6
10
 
@@ -30,21 +34,49 @@ try {
30
34
  console.log('⚠️ Не удалось определить URL репозитория')
31
35
  }
32
36
 
37
+ /**
38
+ * Пытается извлечь первый кадр GIF в PNG через ffmpeg.
39
+ * Возвращает true если PNG был создан, false если ffmpeg недоступен или ошибка.
40
+ */
41
+ function tryGeneratePng(gifPath, pngPath) {
42
+ const result = spawnSync('ffmpeg', ['-i', gifPath, '-frames:v', '1', pngPath, '-y'], {
43
+ encoding: 'utf8',
44
+ })
45
+ if (result.status === 0 && existsSync(pngPath)) {
46
+ console.log(`🖼️ PNG превью создан: ${pngPath}`)
47
+ return true
48
+ }
49
+ return false
50
+ }
51
+
33
52
  // Парсим changelog - ТОЛЬКО версии с демо
34
53
  const versionBlocks = changelog.split('## v').slice(1)
35
54
  let prettyChangelog = '## 📋 История версий\n\n'
36
55
  const processedVersions = new Set()
37
56
 
38
57
  versionBlocks.forEach((versionBlock) => {
39
- const versionMatch = versionBlock.match(/^(\d+\.\d+\.\d+)/)
58
+ // Поддержка заголовков вида "v1.4.0...v2.0.0" (changelogen диапазон) и обычных "v2.0.0"
59
+ const rangeMatch = versionBlock.match(/^\d+\.\d+\.\d+\.\.\.v(\d+\.\d+\.\d+)/)
60
+ const simpleMatch = versionBlock.match(/^(\d+\.\d+\.\d+)/)
61
+ const versionMatch = rangeMatch || simpleMatch
40
62
  if (!versionMatch) return
41
63
 
42
64
  const version = `v${versionMatch[1]}`
43
65
  if (processedVersions.has(version)) return
44
66
  processedVersions.add(version)
45
67
 
46
- // ПРОВЕРЯЕМ ДЕМО - если нет демо, пропускаем
47
- const hasDemo = existsSync(`docs/${version}.gif`) || existsSync(`docs/${version}.png`)
68
+ const gifPath = `${demoDir}/${version}.gif`
69
+ const pngPath = `${demoDir}/${version}.png`
70
+
71
+ const hasGif = existsSync(gifPath)
72
+ let hasPng = existsSync(pngPath)
73
+
74
+ // Если есть GIF но нет PNG — пытаемся сгенерировать PNG через ffmpeg
75
+ if (hasGif && !hasPng) {
76
+ hasPng = tryGeneratePng(gifPath, pngPath)
77
+ }
78
+
79
+ const hasDemo = hasGif || hasPng
48
80
  if (!hasDemo) {
49
81
  console.log(`⏭️ Пропускаем ${version} - нет демо`)
50
82
  return
@@ -94,11 +126,16 @@ versionBlocks.forEach((versionBlock) => {
94
126
  // Форматируем версию
95
127
  prettyChangelog += `### 🟢 ${version}\n\n`
96
128
 
97
- // Добавляем демо (гарантированно есть)
98
- if (existsSync(`docs/${version}.gif`)) {
99
- prettyChangelog += `**Демо работы** \n<img src="docs/${version}.gif" width="400" />\n\n`
129
+ // Добавляем демо
130
+ // Если есть GIF + PNG → кликабельный превью (быстрая загрузка + анимация по клику)
131
+ // Если только PNG обычный img
132
+ // Если только GIF → обычный img с GIF
133
+ if (hasGif && hasPng) {
134
+ prettyChangelog += `**Демо работы** \n<a href="${gifPath}" title="Нажми чтобы увидеть анимацию"><img src="${pngPath}" width="400" /></a>\n\n`
135
+ } else if (hasPng) {
136
+ prettyChangelog += `**Демо работы** \n<img src="${pngPath}" width="400" />\n\n`
100
137
  } else {
101
- prettyChangelog += `**Демо работы** \n<img src="docs/${version}.png" width="400" />\n\n`
138
+ prettyChangelog += `**Демо работы** \n<img src="${gifPath}" width="400" />\n\n`
102
139
  }
103
140
 
104
141
  // Добавляем функционал