spectrum-cli 1.0.6 → 1.1.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/CHANGELOG.md CHANGED
@@ -35,6 +35,34 @@ _Список правок для обеспечения безопасност
35
35
 
36
36
  _Список правок для обеспечения технической поддержки._
37
37
 
38
+ ## 🚀 [1.1.0] - 2025-09-30
39
+
40
+ ### 🆕 Added
41
+
42
+ - Добавлена команда `spectrum changelog append <message>` для умного добавления записей в CHANGELOG.md
43
+ - Автоматическое извлечение номера задачи из названия ветки (формат: [a-zA-Z]+-[0-9]+)
44
+ - Интерактивный запрос номера задачи при отсутствии в названии ветки
45
+ - Проверка Git config с предупреждениями и подсказками по настройке
46
+ - Умное определение раздела changelog по типу ветки (feature/bugfix/support)
47
+ - Интерактивный выбор раздела при неопределенности или множественных вариантах
48
+ - Автоматическое форматирование сообщений (добавление точки в конце)
49
+ - Контекстный вывод результата с цветовым выделением новой записи
50
+ - Автоматическое удаление дефолтного текста "_Список..._" при добавлении первой записи
51
+ - Установлен Jest для тестирования с полным покрытием utils функций
52
+ - Добавлены интеграционные тесты для проверки основной функциональности
53
+
54
+ ### 🛠 Changed
55
+
56
+ - Обновлена документация README.md с подробным описанием команды `changelog append`
57
+ - Улучшена структура экспорта функций в модуле `src/changelog.js`
58
+
59
+ ### 📦 Support
60
+
61
+ - Настроен Jest для модульного и интеграционного тестирования
62
+ - Добавлены npm scripts для запуска тестов (`test`, `test:watch`, `test:coverage`)
63
+ - Конфигурация Jest для Node.js окружения с покрытием кода
64
+ - Созданы базовые тесты для проверки стабильности функций
65
+
38
66
  ## 🚀 [1.0.1] - 2024-09-19
39
67
 
40
68
  ### 🆕 Added
@@ -64,9 +92,9 @@ _Список правок для обеспечения технической
64
92
  - Создан CLI интерфейс `spectrum` с командой `commander`
65
93
  - Добавлены основные команды:
66
94
  - `spectrum release start` - полный цикл релиза
67
- - `spectrum release close` - закрытие релиза
95
+ - `spectrum release close` - закрытие релиза
68
96
  - `spectrum release deploy` - деплой релиза
69
- - `spectrum up version major/minor/patch` - управление версиями
97
+ - `spectrum version up major/minor/patch` - управление версиями
70
98
  - Цветной вывод с эмодзи для лучшего UX
71
99
  - Автоматическое определение пакетного менеджера (npm/yarn/bun)
72
100
  - Обработка ошибок и fallback'ы
package/README.md CHANGED
@@ -35,14 +35,17 @@ npm install
35
35
  spectrum --help
36
36
 
37
37
  # 📦 Управление версиями
38
- spectrum up version major # Поднять major версию (1.0.0 → 2.0.0)
39
- spectrum up version minor # Поднять minor версию (1.0.0 → 1.1.0)
40
- spectrum up version patch # Поднять patch версию (1.0.0 → 1.0.1)
38
+ spectrum version up major # Поднять major версию (1.0.0 → 2.0.0)
39
+ spectrum version up minor # Поднять minor версию (1.0.0 → 1.1.0)
40
+ spectrum version up patch # Поднять patch версию (1.0.0 → 1.0.1)
41
41
 
42
42
  # 🚀 Управление релизами
43
43
  spectrum release start # Полный цикл релиза
44
44
  spectrum release close # Закрыть релиз и смержить в dev
45
45
  spectrum release deploy # Деплой релиза (создать тег)
46
+
47
+ # 📝 Управление changelog
48
+ spectrum changelog append "Сообщение" # Добавить запись в CHANGELOG.md
46
49
  ```
47
50
 
48
51
  ### Справка по командам:
@@ -52,7 +55,10 @@ spectrum release deploy # Деплой релиза (создать тег)
52
55
  spectrum release --help
53
56
 
54
57
  # Справка по версиям
55
- spectrum up version --help
58
+ spectrum version up --help
59
+
60
+ # Справка по changelog
61
+ spectrum changelog --help
56
62
  ```
57
63
 
58
64
  ## ✨ Особенности
@@ -89,14 +95,15 @@ spectrum-cli/
89
95
 
90
96
  ### Команды:
91
97
 
92
- | Команда | Описание |
93
- | --------------------------- | ---------------------------- |
94
- | `spectrum up version major` | Увеличить major версию |
95
- | `spectrum up version minor` | Увеличить minor версию |
96
- | `spectrum up version patch` | Увеличить patch версию |
97
- | `spectrum release start` | Запустить полный цикл релиза |
98
- | `spectrum release close` | Закрыть релиз |
99
- | `spectrum release deploy` | Деплой релиза |
98
+ | Команда | Описание |
99
+ | ----------------------------- | ---------------------------- |
100
+ | `spectrum release start` | Запустить полный цикл релиза |
101
+ | `spectrum release deploy` | Деплой релиза |
102
+ | `spectrum release close` | Закрыть релиз |
103
+ | `spectrum version up major` | Увеличить major версию |
104
+ | `spectrum version up minor` | Увеличить minor версию |
105
+ | `spectrum version up patch` | Увеличить patch версию |
106
+ | `spectrum changelog append` | Добавить запись в changelog |
100
107
 
101
108
  ## 🔄 Workflow релиза
102
109
 
@@ -124,6 +131,35 @@ spectrum-cli/
124
131
  2. Создает тег с текущей версией
125
132
  3. Пушит тег в remote
126
133
 
134
+ ## 📝 Работа с Changelog
135
+
136
+ ### `spectrum changelog append "Сообщение"`
137
+
138
+ Умная команда для добавления записей в CHANGELOG.md с автоматическим определением контекста:
139
+
140
+ **✨ Основные возможности:**
141
+ - 🔍 **Автоматическое извлечение** номера задачи из названия ветки
142
+ - 🤔 **Интерактивный запрос** номера задачи если не найден
143
+ - 👤 **Проверка Git config** с подсказками по настройке
144
+ - 🎯 **Умное определение раздела** по типу ветки
145
+ - 🎨 **Контекстный вывод** с цветовым выделением
146
+ - 🧹 **Автоматическая очистка** дефолтного текста
147
+
148
+ **📋 Поддерживаемые типы веток:**
149
+ - `feature/` → выбор между Added, Changed, Deprecated, Removed
150
+ - `bugfix/`, `fix/` → автоматически Fixed
151
+ - `support/` → выбор между Support, Security
152
+ - другие → показ всех разделов
153
+
154
+ **📌 Пример использования:**
155
+ ```bash
156
+ # На ветке feature/ABC-123-new-component
157
+ spectrum changelog append "Добавлен новый компонент кнопки"
158
+
159
+ # Результат в CHANGELOG.md:
160
+ # - ABC-123 Добавлен новый компонент кнопки. [Ваше Имя](ваш@email.com)
161
+ ```
162
+
127
163
  ## 🎯 Философия
128
164
 
129
165
  - **Простота** - минимум команд, максимум функциональности
@@ -135,7 +171,6 @@ spectrum-cli/
135
171
 
136
172
  - 📋 **[Установка](./INSTALL.md)** - подробные инструкции по установке
137
173
  - 🚀 **[Релизы](./RELEASE.md)** - инструкции по выпуску новых версий
138
- - 📦 **[Дистрибьюция](./DISTRIBUTION.md)** - варианты распространения
139
174
 
140
175
  ## 🤝 Участие в разработке
141
176
 
package/index.js CHANGED
@@ -1,114 +1,132 @@
1
1
  #!/usr/bin/env node
2
- const { Command } = require('commander');
2
+ const { Command } = require("commander");
3
3
  const program = new Command();
4
4
 
5
- const git = require('./src/git');
6
- const version = require('./src/version');
7
- const release = require('./src/release');
5
+ const git = require("./src/git");
6
+ const version = require("./src/version");
7
+ const release = require("./src/release");
8
+ const changelog = require("./src/changelog");
8
9
 
9
10
  program
10
- .name('spectrum')
11
- .description('🚀 Spectrum CLI for development workflow')
12
- .version('1.0.6');
11
+ .name("spectrum")
12
+ .description("🚀 Spectrum CLI for development workflow")
13
+ .version("1.0.7");
13
14
 
14
15
  // Release commands
15
16
  const releaseCmd = program
16
- .command('release')
17
- .description('Release management commands');
17
+ .command("release")
18
+ .description("Release management commands");
18
19
 
19
20
  releaseCmd
20
- .command('start')
21
- .description('Start full release process')
22
- .action(() => release.releaseStart());
21
+ .command("start")
22
+ .description("Start full release process")
23
+ .action(() => release.releaseStart());
23
24
 
24
25
  releaseCmd
25
- .command('close')
26
- .description('Close release and merge to dev')
27
- .action(() => release.releaseClose());
26
+ .command("close")
27
+ .description("Close release and merge to dev")
28
+ .action(() => release.releaseClose());
28
29
 
29
30
  releaseCmd
30
- .command('deploy')
31
- .description('Deploy release (create and push tag)')
32
- .action(() => git.gitCreateTagAndPush());
33
-
34
- // Up version commands
35
- const upCmd = program
36
- .command('up')
37
- .description('Version management commands');
38
-
39
- const versionCmd = upCmd
40
- .command('version')
41
- .description('Update version using semantic versioning');
42
-
43
- versionCmd
44
- .command('major')
45
- .description('Bump major version (x.0.0)')
46
- .action(() => version.setVersionTypescript('major'));
47
-
48
- versionCmd
49
- .command('minor')
50
- .description('Bump minor version (x.y.0)')
51
- .action(() => version.setVersionTypescript('minor'));
52
-
53
- versionCmd
54
- .command('patch')
55
- .description('Bump patch version (x.y.z)')
56
- .action(() => version.setVersionTypescript('patch'));
31
+ .command("deploy")
32
+ .description("Deploy release (create and push tag)")
33
+ .action(() => git.gitCreateTagAndPush());
34
+
35
+ // Version up commands
36
+ const versionCmd = program
37
+ .command("version")
38
+ .description("Update version using semantic versioning");
39
+
40
+ const upCmd = versionCmd
41
+ .command("up")
42
+ .description("Update version using semantic versioning");
43
+
44
+ upCmd
45
+ .command("major")
46
+ .description("Bump major version (x.0.0)")
47
+ .action(() => version.setVersionTypescript("major"));
48
+
49
+ upCmd
50
+ .command("minor")
51
+ .description("Bump minor version (x.y.0)")
52
+ .action(() => version.setVersionTypescript("minor"));
53
+
54
+ upCmd
55
+ .command("patch")
56
+ .description("Bump patch version (x.y.z)")
57
+ .action(() => version.setVersionTypescript("patch"));
58
+
59
+ // Changelog commands
60
+ const changelogCmd = program
61
+ .command("changelog")
62
+ .description("Changelog management commands");
63
+
64
+ changelogCmd
65
+ .command("append <message>")
66
+ .description("Append entry to changelog with task number from branch")
67
+ .action(async (message) => {
68
+ try {
69
+ await changelog.changelogAppend(message);
70
+ } catch (error) {
71
+ console.error(`❌ Error: ${error.message}`);
72
+ process.exit(1);
73
+ }
74
+ });
57
75
 
58
76
  // Override help to show custom format with aliases
59
77
  program.configureHelp({
60
- formatHelp: (cmd, helper) => {
61
- const termWidth = helper.padWidth(cmd, helper);
62
- const helpWidth = helper.helpWidth || 80;
63
- const itemIndentWidth = 2;
64
- const itemSeparatorWidth = 2;
65
- const cmdUsage = helper.commandUsage(cmd);
66
- const cmdDescription = helper.commandDescription(cmd);
67
- const options = helper.visibleOptions(cmd);
68
- const commands = helper.visibleCommands(cmd);
69
-
70
- let output = '';
71
-
72
- // Usage
73
- if (cmdUsage) {
74
- output += `Usage: ${cmdUsage}\n\n`;
75
- }
76
-
77
- // Description
78
- if (cmdDescription) {
79
- output += `${cmdDescription}\n\n`;
80
- }
81
-
82
- // Commands with aliases
83
- if (commands.length > 0) {
84
- output += 'Commands:\n';
85
- commands.forEach(cmd => {
86
- const nameAndArgs = cmd.name() + cmd.usage().replace(/^[^\s]+\s*/, ' ');
87
- const aliases = cmd.aliases();
88
- const description = cmd.description();
89
-
90
- let cmdLine = ` ${nameAndArgs}`;
91
- if (aliases.length > 0) {
92
- cmdLine = cmdLine.padEnd(25) + `[${aliases.join(', ')}]`;
93
- }
94
- cmdLine = cmdLine.padEnd(40) + description;
95
- output += cmdLine + '\n';
96
- });
97
- output += '\n';
98
- }
99
-
100
- // Options
101
- if (options.length > 0) {
102
- output += 'Options:\n';
103
- options.forEach(option => {
104
- const flags = helper.optionTerm(option);
105
- const description = helper.optionDescription(option);
106
- output += ` ${flags.padEnd(25)} ${description}\n`;
107
- });
78
+ formatHelp: (cmd, helper) => {
79
+ const termWidth = helper.padWidth(cmd, helper);
80
+ const helpWidth = helper.helpWidth || 80;
81
+ const itemIndentWidth = 2;
82
+ const itemSeparatorWidth = 2;
83
+ const cmdUsage = helper.commandUsage(cmd);
84
+ const cmdDescription = helper.commandDescription(cmd);
85
+ const options = helper.visibleOptions(cmd);
86
+ const commands = helper.visibleCommands(cmd);
87
+
88
+ let output = "";
89
+
90
+ // Usage
91
+ if (cmdUsage) {
92
+ output += `Usage: ${cmdUsage}\n\n`;
93
+ }
94
+
95
+ // Description
96
+ if (cmdDescription) {
97
+ output += `${cmdDescription}\n\n`;
98
+ }
99
+
100
+ // Commands with aliases
101
+ if (commands.length > 0) {
102
+ output += "Commands:\n";
103
+ commands.forEach((cmd) => {
104
+ const nameAndArgs = cmd.name() + cmd.usage().replace(/^[^\s]+\s*/, " ");
105
+ const aliases = cmd.aliases();
106
+ const description = cmd.description();
107
+
108
+ let cmdLine = ` ${nameAndArgs}`;
109
+ if (aliases.length > 0) {
110
+ cmdLine = cmdLine.padEnd(25) + `[${aliases.join(", ")}]`;
108
111
  }
109
-
110
- return output;
112
+ cmdLine = cmdLine.padEnd(40) + description;
113
+ output += cmdLine + "\n";
114
+ });
115
+ output += "\n";
111
116
  }
117
+
118
+ // Options
119
+ if (options.length > 0) {
120
+ output += "Options:\n";
121
+ options.forEach((option) => {
122
+ const flags = helper.optionTerm(option);
123
+ const description = helper.optionDescription(option);
124
+ output += ` ${flags.padEnd(25)} ${description}\n`;
125
+ });
126
+ }
127
+
128
+ return output;
129
+ },
112
130
  });
113
131
 
114
- program.parse();
132
+ program.parse();
package/package.json CHANGED
@@ -1,13 +1,15 @@
1
1
  {
2
2
  "name": "spectrum-cli",
3
- "version": "1.0.6",
3
+ "version": "1.1.0",
4
4
  "description": "🚀 Modern CLI for development workflow automation - release management, versioning, and changelog generation",
5
5
  "main": "index.js",
6
6
  "bin": {
7
7
  "spectrum": "./index.js"
8
8
  },
9
9
  "scripts": {
10
- "test": "echo \"Error: no test specified\" && exit 1",
10
+ "test": "jest",
11
+ "test:watch": "jest --watch",
12
+ "test:coverage": "jest --coverage",
11
13
  "prepublishOnly": "echo \"Publishing spectrum-cli v$(node -p 'require(\"./package.json\").version')\"",
12
14
  "postpack": "echo \"Packed successfully\""
13
15
  },
@@ -61,5 +63,19 @@
61
63
  "preferGlobal": true,
62
64
  "publishConfig": {
63
65
  "access": "public"
66
+ },
67
+ "devDependencies": {
68
+ "jest": "^30.2.0"
69
+ },
70
+ "jest": {
71
+ "testEnvironment": "node",
72
+ "collectCoverageFrom": [
73
+ "src/**/*.js",
74
+ "index.js"
75
+ ],
76
+ "testMatch": [
77
+ "**/__tests__/**/*.js",
78
+ "**/*.test.js"
79
+ ]
64
80
  }
65
81
  }
package/src/UNRELEASED.md CHANGED
@@ -27,4 +27,3 @@ _Список правок для обеспечения безопасност
27
27
  ### 📦 Support
28
28
 
29
29
  _Список правок для обеспечения технической поддержки._
30
-
package/src/changelog.js CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  const fs = require('fs');
3
3
  const path = require('path');
4
- const { logSuccess, execCommand, getVersion, colors } = require('./utils');
4
+ const readline = require('readline');
5
+ const { logSuccess, logError, execCommand, execSilent, getVersion, getCurrentBranch, colors } = require('./utils');
5
6
 
6
7
  function changelogChangeHeader() {
7
8
  try {
@@ -71,10 +72,234 @@ function changelogCommit() {
71
72
  return false;
72
73
  }
73
74
 
75
+ function createReadlineInterface() {
76
+ return readline.createInterface({
77
+ input: process.stdin,
78
+ output: process.stdout
79
+ });
80
+ }
81
+
82
+ function askQuestion(question) {
83
+ return new Promise((resolve) => {
84
+ const rl = createReadlineInterface();
85
+ rl.question(question, (answer) => {
86
+ rl.close();
87
+ resolve(answer.trim());
88
+ });
89
+ });
90
+ }
91
+
92
+ async function extractTaskFromBranch() {
93
+ const currentBranch = getCurrentBranch();
94
+ if (!currentBranch) {
95
+ logError('❌', 'Cannot get current branch name.');
96
+ return null;
97
+ }
98
+
99
+ const taskMatch = currentBranch.match(/([a-zA-Z]+-[0-9]+)/);
100
+ if (!taskMatch) {
101
+ console.log(`⚠️ ${colors.yellow}Branch name "${currentBranch}" does not contain task number in format [a-zA-Z]+-[0-9]+.${colors.reset}`);
102
+ const task = await askQuestion('📝 Please enter task number (e.g. SPEC-123): ');
103
+ if (!task || !task.match(/^[a-zA-Z]+-[0-9]+$/)) {
104
+ logError('❌', 'Invalid task format. Expected format: [a-zA-Z]+-[0-9]+');
105
+ return null;
106
+ }
107
+ return task;
108
+ }
109
+
110
+ return taskMatch[1];
111
+ }
112
+
113
+ async function getGitUser() {
114
+ let name = execSilent('git config user.name');
115
+ let email = execSilent('git config user.email');
116
+
117
+ if (!name || !email) {
118
+ console.log(`⚠️ ${colors.yellow}Git user name and email are not configured.${colors.reset}`);
119
+ console.log(`💡 You can configure them using:`);
120
+ console.log(` git config user.name "Your Name"`);
121
+ console.log(` git config user.email "your.email@domain.com"`);
122
+ console.log('');
123
+
124
+ if (!name) {
125
+ name = await askQuestion('👤 Please enter your name: ');
126
+ if (!name) {
127
+ logError('❌', 'Name is required.');
128
+ return null;
129
+ }
130
+ }
131
+
132
+ if (!email) {
133
+ email = await askQuestion('📧 Please enter your email: ');
134
+ if (!email || !email.includes('@')) {
135
+ logError('❌', 'Valid email is required.');
136
+ return null;
137
+ }
138
+ }
139
+ }
140
+
141
+ return `[${name}](${email})`;
142
+ }
143
+
144
+ function formatMessage(message) {
145
+ if (!message.endsWith('.')) {
146
+ return message + '.';
147
+ }
148
+ return message;
149
+ }
150
+
151
+ function detectSectionFromBranch() {
152
+ const currentBranch = getCurrentBranch();
153
+ if (!currentBranch) return [];
154
+
155
+ const branchLower = currentBranch.toLowerCase();
156
+ const sections = {
157
+ support: ['### 📦 Support', '### 🔐 Security'],
158
+ bugfix: ['### 🪲 Fixed'],
159
+ feature: ['### 🆕 Added', '### 🛠 Changed', '### 📜 Deprecated', '### 🗑 Removed']
160
+ };
161
+
162
+ if (branchLower.includes('support')) {
163
+ return sections.support;
164
+ } else if (branchLower.includes('bugfix') || branchLower.includes('fix')) {
165
+ return sections.bugfix;
166
+ } else if (branchLower.includes('feature') || branchLower.includes('feat')) {
167
+ return sections.feature;
168
+ }
169
+
170
+ return [];
171
+ }
172
+
173
+ async function selectSection(availableSections) {
174
+ if (availableSections.length === 0) {
175
+ availableSections = [
176
+ '### 🆕 Added',
177
+ '### 🛠 Changed',
178
+ '### 📜 Deprecated',
179
+ '### 🗑 Removed',
180
+ '### 🪲 Fixed',
181
+ '### 🔐 Security',
182
+ '### 📦 Support'
183
+ ];
184
+ }
185
+
186
+ if (availableSections.length === 1) {
187
+ return availableSections[0];
188
+ }
189
+
190
+ console.log(`\n📋 Please select a section:`);
191
+ availableSections.forEach((section, index) => {
192
+ console.log(` ${index + 1}. ${section}`);
193
+ });
194
+
195
+ const choice = await askQuestion('\n🔢 Enter section number: ');
196
+ const choiceNum = parseInt(choice);
197
+
198
+ if (isNaN(choiceNum) || choiceNum < 1 || choiceNum > availableSections.length) {
199
+ logError('❌', 'Invalid choice.');
200
+ return null;
201
+ }
202
+
203
+ return availableSections[choiceNum - 1];
204
+ }
205
+
206
+ function displayContext(lines, insertIndex, entry) {
207
+ console.log('\n📝 Changelog updated:');
208
+
209
+ if (insertIndex > 0) {
210
+ console.log(` ${colors.reset}${lines[insertIndex - 1]}${colors.reset}`);
211
+ }
212
+
213
+ console.log(` ${colors.green}${entry}${colors.reset}`);
214
+
215
+ if (insertIndex < lines.length - 1) {
216
+ console.log(` ${colors.reset}${lines[insertIndex]}${colors.reset}`);
217
+ }
218
+ console.log('');
219
+ }
220
+
221
+ async function changelogAppend(message) {
222
+ try {
223
+ const task = await extractTaskFromBranch();
224
+ if (!task) return false;
225
+
226
+ const user = await getGitUser();
227
+ if (!user) return false;
228
+
229
+ const formattedMessage = formatMessage(message);
230
+ const entry = `- ${task} ${formattedMessage} ${user}`;
231
+
232
+ const availableSections = detectSectionFromBranch();
233
+ const selectedSection = await selectSection(availableSections);
234
+ if (!selectedSection) return false;
235
+
236
+ const changelog = fs.readFileSync('CHANGELOG.md', 'utf8');
237
+ const lines = changelog.split('\n');
238
+
239
+ let sectionIndex = -1;
240
+ for (let i = 0; i < lines.length; i++) {
241
+ if (lines[i] === selectedSection) {
242
+ sectionIndex = i;
243
+ break;
244
+ }
245
+ }
246
+
247
+ if (sectionIndex === -1) {
248
+ logError('❌', `Cannot find "${selectedSection}" section in CHANGELOG.md.`);
249
+ return false;
250
+ }
251
+
252
+ let insertIndex = sectionIndex + 2;
253
+ let defaultTextLines = 0;
254
+
255
+ // Count and remember default text lines to remove them
256
+ while (insertIndex + defaultTextLines < lines.length &&
257
+ lines[insertIndex + defaultTextLines].startsWith('_')) {
258
+ defaultTextLines++;
259
+ }
260
+
261
+ // Insert the new entry
262
+ lines.splice(insertIndex, 0, entry);
263
+
264
+ // Remove default text lines if this is the first real entry in the section
265
+ if (defaultTextLines > 0) {
266
+ // Check if there are any non-default entries after our insertion
267
+ let hasOtherEntries = false;
268
+ for (let i = insertIndex + 1; i < insertIndex + 1 + defaultTextLines; i++) {
269
+ if (lines[i] && lines[i].startsWith('- ')) {
270
+ hasOtherEntries = true;
271
+ break;
272
+ }
273
+ }
274
+
275
+ // If no other entries, remove default text
276
+ if (!hasOtherEntries) {
277
+ lines.splice(insertIndex + 1, defaultTextLines);
278
+ }
279
+ }
280
+
281
+ const updatedChangelog = lines.join('\n');
282
+ fs.writeFileSync('CHANGELOG.md', updatedChangelog);
283
+
284
+ displayContext(lines, insertIndex, entry);
285
+ logSuccess('✅', `Entry added to ${selectedSection}`);
286
+ return true;
287
+ } catch (error) {
288
+ logError('❌', `Error adding changelog entry: ${error.message}`);
289
+ return false;
290
+ }
291
+ }
292
+
74
293
 
75
294
  module.exports = {
76
295
  changelogChangeHeader,
77
296
  changelogRemoveEmptyChapters,
78
297
  changelogAddUnreleasedBlock,
79
- changelogCommit
298
+ changelogCommit,
299
+ changelogAppend,
300
+ extractTaskFromBranch,
301
+ getGitUser,
302
+ formatMessage,
303
+ detectSectionFromBranch,
304
+ selectSection
80
305
  };
package/src/git.js CHANGED
@@ -87,7 +87,7 @@ function gitCreateTagAndPush() {
87
87
  }
88
88
 
89
89
  if (execCommand(`git tag v${currentVersion}`, null, null)) {
90
- logSuccess('🏷️', `Create tag v${currentVersion}.`);
90
+ logSuccess('🔖', `Create tag v${currentVersion}.`);
91
91
 
92
92
  if (execCommand(`git push origin v${currentVersion}`, null, null)) {
93
93
  logSuccess('🚀', `Push tag v${currentVersion}.`);
package/src/utils.js CHANGED
@@ -47,7 +47,11 @@ function getCurrentBranch() {
47
47
  }
48
48
 
49
49
  function getMainBranch() {
50
- return execSilent('git symbolic-ref refs/remotes/origin/HEAD | sed "s@^refs/remotes/origin/@@"') || 'main';
50
+ const branches = execSilent('git branch -r');
51
+ if (branches && branches.includes('origin/master')) {
52
+ return 'master';
53
+ }
54
+ return 'main';
51
55
  }
52
56
 
53
57
  function getDevelopBranch() {
package/src/version.js CHANGED
@@ -34,7 +34,7 @@ function setVersionTypescript(versionType) {
34
34
  packageJson.version = newVersion;
35
35
  fs.writeFileSync('package.json', JSON.stringify(packageJson, null, 2) + '\n');
36
36
 
37
- logSuccess('🏷️', `Current version ${oldVersion} up to ${colors.green}${newVersion}${colors.reset}.`);
37
+ logSuccess('🔖', `Current version ${oldVersion} up to ${colors.green}${newVersion}${colors.reset}.`);
38
38
  return true;
39
39
  } catch (error) {
40
40
  logError('❌', 'Error updating version in package.json');