@omnisass/library 0.2.0 → 2026.1.0-alpha.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.
Files changed (101) hide show
  1. package/.editorconfig +13 -0
  2. package/.omnisass/scripts/bump-version.sh +288 -0
  3. package/.sassdoc.yaml +21 -0
  4. package/.vscode/settings.json +17 -0
  5. package/_configs.scss +10 -45
  6. package/index.scss +5 -91
  7. package/modules/utilities/converters/_convert-em2px.scss +3 -49
  8. package/modules/utilities/converters/_convert-hex2rgb.scss +2 -44
  9. package/modules/utilities/converters/_convert-hex2rgba.scss +2 -57
  10. package/modules/utilities/converters/_convert-px2em.scss +3 -62
  11. package/modules/utilities/converters/_convert-px2rem.scss +3 -62
  12. package/modules/utilities/converters/_convert-rem2px.scss +3 -62
  13. package/modules/utilities/converters/_index.scss +10 -0
  14. package/modules/utilities/getters/_index.scss +23 -0
  15. package/modules/utilities/getters/color/_get-color-brightness.scss +2 -48
  16. package/modules/utilities/getters/color/_get-color-darkest.scss +13 -68
  17. package/modules/utilities/getters/list/_get-list-item-end.scss +2 -29
  18. package/modules/utilities/getters/list/_get-list-item-start.scss +2 -29
  19. package/modules/utilities/getters/list/_get-list-item.scss +6 -82
  20. package/modules/utilities/getters/number/_get-number-from-percent.scss +2 -40
  21. package/modules/utilities/getters/number/_get-number-height-by-ratio.scss +3 -35
  22. package/modules/utilities/getters/number/_get-number-max-safe.scss +112 -0
  23. package/modules/utilities/getters/number/_get-number-max.scss +10 -88
  24. package/modules/utilities/getters/number/_get-number-min-safe.scss +114 -0
  25. package/modules/utilities/getters/number/_get-number-min.scss +9 -84
  26. package/modules/utilities/getters/number/_get-number-percentage-of.scss +2 -58
  27. package/modules/utilities/getters/number/_get-number-unit.scss +5 -46
  28. package/modules/utilities/getters/number/_get-number-width-by-ratio.scss +3 -56
  29. package/modules/utilities/helpers/_index.scss +44 -0
  30. package/modules/utilities/helpers/color/_color-blend-steps.scss +5 -89
  31. package/modules/utilities/helpers/color/_color-blend.scss +11 -85
  32. package/modules/utilities/helpers/color/_color-hue-shift.scss +7 -61
  33. package/modules/utilities/helpers/color/_color-scale.scss +7 -74
  34. package/modules/utilities/helpers/color/_color-shade.scss +2 -60
  35. package/modules/utilities/helpers/color/_color-tint.scss +2 -60
  36. package/modules/utilities/helpers/color/_color-triad.scss +9 -53
  37. package/modules/utilities/helpers/list/_list-dedupe.scss +9 -50
  38. package/modules/utilities/helpers/list/_list-insert-at.scss +16 -86
  39. package/modules/utilities/helpers/list/_list-merge.scss +1 -1
  40. package/modules/utilities/helpers/list/_list-remove-at.scss +9 -71
  41. package/modules/utilities/helpers/list/_list-sum-numbers-safe.scss +17 -81
  42. package/modules/utilities/helpers/list/_list-sum-numbers.scss +9 -57
  43. package/modules/utilities/helpers/number/_number-ceil-to.scss +1 -1
  44. package/modules/utilities/helpers/number/_number-clamp-max.scss +1 -1
  45. package/modules/utilities/helpers/number/_number-clamp-min.scss +1 -1
  46. package/modules/utilities/helpers/number/_number-clamp.scss +1 -1
  47. package/modules/utilities/helpers/number/_number-denormalize.scss +1 -1
  48. package/modules/utilities/helpers/number/_number-fibonacci.scss +2 -2
  49. package/modules/utilities/helpers/number/_number-floor-to.scss +1 -1
  50. package/modules/utilities/helpers/number/_number-format-with-separator.scss +4 -4
  51. package/modules/utilities/helpers/number/_number-normalize.scss +1 -1
  52. package/modules/utilities/helpers/number/_number-random-between-int.scss +1 -1
  53. package/modules/utilities/helpers/number/_number-random-between.scss +1 -1
  54. package/modules/utilities/helpers/number/_number-range.scss +7 -7
  55. package/modules/utilities/helpers/number/_number-round-to-nearest.scss +1 -1
  56. package/modules/utilities/helpers/number/_number-round-to.scss +1 -1
  57. package/modules/utilities/helpers/number/_number-strip-unit.scss +2 -14
  58. package/modules/utilities/helpers/string/_string-capitalize.scss +1 -1
  59. package/modules/utilities/helpers/string/_string-replace.scss +1 -1
  60. package/modules/utilities/helpers/string/_string-trim-end.scss +2 -2
  61. package/modules/utilities/helpers/string/_string-trim-start.scss +2 -2
  62. package/modules/utilities/helpers/string/_string-trim.scss +1 -1
  63. package/modules/utilities/loggers/_index.scss +6 -0
  64. package/modules/utilities/validators/_index.scss +38 -0
  65. package/modules/utilities/validators/{misc/_is-time.scss → _is-time.scss} +2 -2
  66. package/modules/utilities/validators/color/_is-color-light.scss +1 -1
  67. package/modules/utilities/validators/color/_is-color-list.scss +1 -1
  68. package/modules/utilities/validators/list/_is-list-contained.scss +1 -1
  69. package/modules/utilities/validators/number/_is-int-even.scss +1 -1
  70. package/modules/utilities/validators/number/_is-int-odd.scss +1 -1
  71. package/modules/utilities/validators/number/_is-int.scss +1 -1
  72. package/modules/utilities/validators/number/_is-number-has-unit.scss +1 -1
  73. package/modules/utilities/validators/number/_is-number-negative.scss +1 -1
  74. package/modules/utilities/validators/number/_is-number-positive.scss +1 -1
  75. package/modules/utilities/validators/number/_is-number-unitless.scss +1 -1
  76. package/modules/utilities/validators/number/_is-number-zero.scss +1 -1
  77. package/modules/utilities/validators/string/_is-string-contained.scss +25 -25
  78. package/modules/utilities/validators/string/_is-string-empty.scss +1 -1
  79. package/modules/utilities/validators/string/_is-string-ending-with.scss +1 -1
  80. package/modules/utilities/validators/string/_is-string-starting-with.scss +1 -1
  81. package/modules/utilities/validators/type-of/_is-boolean.scss +1 -1
  82. package/modules/utilities/validators/type-of/_is-color.scss +1 -1
  83. package/modules/utilities/validators/type-of/_is-list.scss +1 -1
  84. package/modules/utilities/validators/type-of/_is-map.scss +1 -1
  85. package/modules/utilities/validators/type-of/_is-number.scss +1 -1
  86. package/modules/utilities/validators/type-of/_is-string.scss +1 -1
  87. package/modules/utilities/validators/type-of/_is-type.scss +1 -1
  88. package/package.json +5 -6
  89. package/package.scss +3 -3
  90. package/playground/index.scss +8 -0
  91. package/modules/utilities/converters/_convert-camel2kebab.scss +0 -186
  92. package/modules/utilities/converters/_convert-kebab2camel.scss +0 -232
  93. package/modules/utilities/converters/_convert-kebab2snake.scss +0 -118
  94. package/modules/utilities/converters/_convert-snake2kebab.scss +0 -173
  95. package/modules/utilities/helpers/misc/_url-encode.configs.scss +0 -64
  96. package/modules/utilities/helpers/misc/_url-encode.scss +0 -148
  97. package/modules/utilities/loggers/_log-invalid-type.scss +0 -151
  98. package/modules/utilities/loggers/_log-invalid-value.scss +0 -151
  99. package/test.md +0 -168
  100. package/test.scss +0 -405
  101. package/test.sh +0 -149
package/test.scss DELETED
@@ -1,405 +0,0 @@
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
- // ============================================================================
11
- // 7. ФУНКЦИИ ЭКРАНИРОВАНИЯ И КОДИРОВАНИЯ
12
- // ============================================================================
13
-
14
- // Простое URL-кодирование
15
-
16
-
17
- // Экранирование кавычек
18
- @function escape-quotes($string) {
19
- $string: string-replace($string, '"', '\"');
20
- $string: string-replace($string, "'", "\'");
21
- @return $string;
22
- }
23
-
24
- // Экранирование для использования в CSS-контенте
25
- @function escape-css-content($string) {
26
- $string: string-replace($string, "\\", "\\\\");
27
- $string: string-replace($string, '"', '\"');
28
- $string: string-replace($string, "'", "\'");
29
- $string: string-replace($string, "\n", "\\A ");
30
- @return $string;
31
- }
32
-
33
- // ============================================================================
34
- // 8. ФУНКЦИИ ДЛЯ РАБОТЫ С ПУТЯМИ И ФАЙЛАМИ
35
- // ============================================================================
36
-
37
- // Получение имени файла из пути
38
- @function get-filename($path) {
39
- $last-slash: string-index($path, "/");
40
- @if $last-slash {
41
- @return string.slice($path, $last-slash + 1);
42
- }
43
-
44
- $last-backslash: string-index($path, "\\");
45
- @if $last-backslash {
46
- @return string.slice($path, $last-backslash + 1);
47
- }
48
-
49
- @return $path;
50
- }
51
-
52
- // Получение расширения файла
53
- @function get-extension($filename) {
54
- $last-dot: string-index($filename, ".");
55
- @if $last-dot {
56
- @return string.slice($filename, $last-dot + 1);
57
- }
58
- @return "";
59
- }
60
-
61
- // Получение имени файла без расширения
62
- @function get-filename-without-extension($filename) {
63
- $extension: get-extension($filename);
64
- @if string-length($extension) > 0 {
65
- $extension-length: string-length($extension) + 1; // +1 для точки
66
- @return string.slice($filename, 1, -$extension-length - 1);
67
- }
68
- @return $filename;
69
- }
70
-
71
- // Получение директории из пути
72
- @function get-directory($path) {
73
- $last-slash: string-index($path, "/");
74
- @if $last-slash {
75
- @return string.slice($path, 1, $last-slash);
76
- }
77
-
78
- $last-backslash: string-index($path, "\\");
79
- @if $last-backslash {
80
- @return string.slice($path, 1, $last-backslash);
81
- }
82
-
83
- @return "./";
84
- }
85
-
86
- // ============================================================================
87
- // 9. ФУНКЦИИ ГЕНЕРАЦИИ И УНИКАЛЬНЫХ ИДЕНТИФИКАТОРОВ
88
- // ============================================================================
89
-
90
- // Генерация уникального идентификатора с префиксом
91
- @function unique-string-id($prefix: "id-") {
92
- $random: random(1000000);
93
- $timestamp: unique-id(); // Встроенная функция Sass
94
- @return $prefix + $random + "-" + $timestamp;
95
- }
96
-
97
- // Генерация хеша из строки (упрощенный вариант)
98
- @function string-hash($string) {
99
- $hash: 0;
100
- $length: string-length($string);
101
-
102
- @for $i from 1 through $length {
103
- $char: string.slice($string, $i, $i);
104
- $hash: (($hash * 31) + string-index("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", $char)) % 1000000;
105
- }
106
-
107
- @return $hash;
108
- }
109
-
110
- // ============================================================================
111
- // 10. ФУНКЦИИ ДЛЯ РАБОТЫ С КЛАССАМИ И СЕЛЕКТОРАМИ
112
- // ============================================================================
113
-
114
- // Генерация модификаторов для БЭМ
115
- @function generate-bem-modifiers($block, $modifiers...) {
116
- $result: ();
117
- @each $modifier in $modifiers {
118
- $result: append($result, $block + "--" + $modifier, comma);
119
- }
120
- @return $result;
121
- }
122
-
123
- // Генерация элементов для БЭМ
124
- @function generate-bem-elements($block, $elements...) {
125
- $result: ();
126
- @each $element in $elements {
127
- $result: append($result, $block + "__" + $element, comma);
128
- }
129
- @return $result;
130
- }
131
-
132
- // Создание селектора с состоянием
133
- @function with-state($selector, $state) {
134
- @return $selector + ":" + $state;
135
- }
136
-
137
- // Создание селектора с псевдоэлементом
138
- @function with-pseudo($selector, $pseudo) {
139
- @return $selector + "::" + $pseudo;
140
- }
141
-
142
- // ============================================================================
143
- // 11. ФУНКЦИИ ПАДИНГА И ВЫРАВНИВАНИЯ
144
- // ============================================================================
145
-
146
- // Дополнение строки слева
147
- @function string-pad-left($string, $length, $pad-char: " ") {
148
- @while string-length($string) < $length {
149
- $string: $pad-char + $string;
150
- }
151
- @return $string;
152
- }
153
-
154
- // Дополнение строки справа
155
- @function string-pad-right($string, $length, $pad-char: " ") {
156
- @while string-length($string) < $length {
157
- $string: $string + $pad-char;
158
- }
159
- @return $string;
160
- }
161
-
162
- // Дополнение строки с обеих сторон
163
- @function string-pad-both($string, $length, $pad-char: " ") {
164
- @while string-length($string) < $length {
165
- $string: $pad-char + $string + $pad-char;
166
- }
167
-
168
- // Если длина нечетная, удалить один символ справа
169
- @if string-length($string) > $length {
170
- $string: string.slice($string, 1, -2);
171
- }
172
-
173
- @return $string;
174
- }
175
-
176
- // Центрирование текста в указанной ширине
177
- @function string-center($string, $width, $pad-char: " ") {
178
- $string-length: string-length($string);
179
- @if $string-length >= $width {
180
- @return $string;
181
- }
182
-
183
- $padding: $width - $string-length;
184
- $left-padding: floor($padding / 2);
185
- $right-padding: $padding - $left-padding;
186
-
187
- $result: $string;
188
- @for $i from 1 through $left-padding {
189
- $result: $pad-char + $result;
190
- }
191
- @for $i from 1 through $right-padding {
192
- $result: $result + $pad-char;
193
- }
194
-
195
- @return $result;
196
- }
197
-
198
- // ============================================================================
199
- // 12. ФУНКЦИИ ПОВТОРЕНИЯ И ГЕНЕРАЦИИ
200
- // ============================================================================
201
-
202
- // Повторение строки указанное количество раз
203
- @function string-repeat($string, $times) {
204
- $result: "";
205
- @for $i from 1 through $times {
206
- $result: $result + $string;
207
- }
208
- @return $result;
209
- }
210
-
211
- // Генерация последовательности символов
212
- @function generate-sequence($start, $end) {
213
- $result: "";
214
- @for $i from $start through $end {
215
- $result: $result + string.slice("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", $i, $i);
216
- }
217
- @return $result;
218
- }
219
-
220
- // Генерация Lorem Ipsum текста
221
- @function lorem-ipsum($words: 10) {
222
- $lorem-words: "lorem" "ipsum" "dolor" "sit" "amet" "consectetur" "adipiscing" "elit" "sed" "do"
223
- "eiusmod" "tempor" "incididunt" "ut" "labore" "et" "dolore" "magna" "aliqua" "ut"
224
- "enim" "ad" "minim" "veniam" "quis" "nostrud" "exercitation" "ullamco" "laboris"
225
- "nisi" "ut" "aliquip" "ex" "ea" "commodo" "consequat";
226
-
227
- $result: "";
228
- @for $i from 1 through $words {
229
- $word-index: ($i - 1) % length($lorem-words) + 1;
230
- $word: nth($lorem-words, $word-index);
231
- $result: $result + $word;
232
- @if $i != $words {
233
- $result: $result + " ";
234
- }
235
- }
236
-
237
- @return capitalize($result) + ".";
238
- }
239
-
240
- // ============================================================================
241
- // 13. ВСПОМОГАТЕЛЬНЫЕ И КОМБИНИРОВАННЫЕ ФУНКЦИИ
242
- // ============================================================================
243
-
244
- // Обращение строки
245
- @function string-reverse($string) {
246
- $result: "";
247
- $length: string-length($string);
248
-
249
- @for $i from $length through 1 {
250
- $result: $result + string.slice($string, $i, $i);
251
- }
252
-
253
- @return $result;
254
- }
255
-
256
- // Подсчет вхождений подстроки
257
- @function string-count($string, $substring) {
258
- $count: 0;
259
- $index: string-index($string, $substring);
260
-
261
- @while $index != null {
262
- $count: $count + 1;
263
- $string: string.slice($string, $index + string-length($substring));
264
- $index: string-index($string, $substring);
265
- }
266
-
267
- @return $count;
268
- }
269
-
270
- // Удаление всех пробелов
271
- @function remove-spaces($string) {
272
- @return string-replace($string, " ", "");
273
- }
274
-
275
- // Удаление всех указанных символов
276
- @function remove-chars($string, $chars) {
277
- @each $char in $chars {
278
- $string: string-replace($string, $char, "");
279
- }
280
- @return $string;
281
- }
282
-
283
- // Получение уникальных символов из строки
284
- @function unique-chars($string) {
285
- $result: "";
286
- $length: string-length($string);
287
-
288
- @for $i from 1 through $length {
289
- $char: string.slice($string, $i, $i);
290
- @if not contains($result, $char) {
291
- $result: $result + $char;
292
- }
293
- }
294
-
295
- @return $result;
296
- }
297
-
298
- // ============================================================================
299
- // 14. ФУНКЦИИ ДЛЯ РАБОТЫ С ЦВЕТАМИ (Строковые представления)
300
- // ============================================================================
301
-
302
- // Извлечение hex значения из строки цвета
303
- @function extract-hex($color-string) {
304
- $color-string: to-lower-case($color-string);
305
- $hash-index: string-index($color-string, "#");
306
-
307
- @if $hash-index {
308
- $hex-start: $hash-index + 1;
309
- $hex: string.slice($color-string, $hex-start);
310
-
311
- // Убираем все не-hex символы
312
- $hex: remove-chars($hex, (" ", ";", ")", "(", ","));
313
-
314
- @return "#" + $hex;
315
- }
316
-
317
- @return null;
318
- }
319
-
320
- // Проверка, является ли строка hex-цветом
321
- @function is-hex-color($string) {
322
- $string: to-lower-case(string-trim($string));
323
- @if not string-starts-with($string, "#") {
324
- @return false;
325
- }
326
-
327
- $hex: string.slice($string, 2);
328
- $hex-length: string-length($hex);
329
-
330
- @if $hex-length != 3 and $hex-length != 6 and $hex-length != 8 {
331
- @return false;
332
- }
333
-
334
- $valid-chars: "0123456789abcdef";
335
-
336
- @for $i from 1 through $hex-length {
337
- $char: string.slice($hex, $i, $i);
338
- @if not contains($valid-chars, $char) {
339
- @return false;
340
- }
341
- }
342
-
343
- @return true;
344
- }
345
-
346
- // ============================================================================
347
- // 15. ФУНКЦИИ ДЛЯ РАБОТЫ С МЕДИА-ЗАПРОСАМИ
348
- // ============================================================================
349
-
350
- // Создание медиа-запроса с минимальной шириной
351
- @function min-width-query($width) {
352
- @return "(min-width: " + $width + ")";
353
- }
354
-
355
- // Создание медиа-запроса с максимальной шириной
356
- @function max-width-query($width) {
357
- @return "(max-width: " + $width + ")";
358
- }
359
-
360
- // Создание медиа-запроса для диапазона ширины
361
- @function width-range-query($min, $max) {
362
- @return "(min-width: " + $min + ") and (max-width: " + $max + ")";
363
- }
364
-
365
- // ============================================================================
366
- // ПРИМЕРЫ ИСПОЛЬЗОВАНИЯ
367
- // ============================================================================
368
-
369
- /*
370
- // Примеры использования функций:
371
-
372
- // 1. Базовые операции
373
- $test: "Hello World";
374
- $length: string-length($test); // 11
375
- $upper: to-upper-case($test); // "HELLO WORLD"
376
- $substr: string.slice($test, 7, 11); // "World"
377
-
378
- // 2. Проверки
379
- $has-world: contains($test, "World"); // true
380
- $starts-hello: string-starts-with($test, "Hello"); // true
381
- $ends-world: string-ends-with($test, "World"); // true
382
-
383
- // 3. Обрезка
384
- $trimmed: string-trim(" Hello "); // "Hello"
385
-
386
- // 4. Замена
387
- $replaced: string-replace($test, "World", "Sass"); // "Hello Sass"
388
-
389
- // 5. Преобразование регистра
390
- $kebab: camel-to-kebab("helloWorld"); // "hello-world"
391
- $camel: kebab-to-camel("hello-world"); // "helloWorld"
392
-
393
- // 6. Работа с CSS значениями
394
- $unit: get-unit("10px"); // "px"
395
- $number: get-number("10px"); // 10
396
- $no-unit: strip-unit("10px"); // 10
397
-
398
- // 7. Генерация классов
399
- $modifiers: generate-bem-modifiers("button", "primary", "large");
400
- // ".button--primary, .button--large"
401
- */
402
-
403
- // ============================================================================
404
- // КОНЕЦ БИБЛИОТЕКИ ФУНКЦИЙ ДЛЯ РАБОТЫ СО СТРОКАМИ
405
- // ============================================================================
package/test.sh DELETED
@@ -1,149 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- # Conventional Commit с использованием fzf
4
- # Убедитесь, что fzf установлен: brew install fzf, apt-get install fzf, или pacman -S fzf
5
-
6
- # Проверяем, есть ли изменения для коммита
7
- if [ -z "$(git status --porcelain)" ]; then
8
- echo "❌ Нет изменений для коммита"
9
- exit 1
10
- fi
11
-
12
- # Цвета для лучшего отображения
13
- RED='\033[0;31m'
14
- GREEN='\033[0;32m'
15
- YELLOW='\033[1;33m'
16
- BLUE='\033[0;34m'
17
- NC='\033[0m' # No Color
18
-
19
- # Функция для отображения заголовков
20
- header() {
21
- echo -e "${BLUE}=== $1 ===${NC}"
22
- }
23
-
24
- # Выбор типа коммита
25
- header "Тип коммита"
26
- TYPE=$(printf "feat: Новая функциональность
27
- fix: Исправление ошибки
28
- docs: Изменения в документации
29
- style: Форматирование, точки с запятой, пробелы
30
- refactor: Рефакторинг без изменения функциональности
31
- perf: Изменения для улучшения производительности
32
- test: Добавление или исправление тестов
33
- build: Изменения в системе сборки
34
- ci: Изменения в CI-конфигурации
35
- chore: Обновление зависимостей, рутинные задачи
36
- revert: Отмена предыдущего коммита" | fzf --height=50% --border=rounded \
37
- --header="Выберите тип коммита (↑↓ для навигации, Enter для выбора)" \
38
- --preview="echo -e '${GREEN}Пример:${NC}\n{1}: краткое описание\n\n${YELLOW}Сгенерирует:${NC}\n{1}: ваш текст'" | cut -d: -f1)
39
-
40
- if [ -z "$TYPE" ]; then
41
- echo "❌ Отменено пользователем"
42
- exit 0
43
- fi
44
-
45
- # Выбор области (scope)
46
- header "Область изменений"
47
- SCOPE=$(echo -e " \ngeneral\napi\nui\nauth\ndb\nconfig\ntests\ncli\ndocs\nbuild\ndeploy\nmobile\ndesktop\nserver\nclient\nfrontend\nbackend" | \
48
- fzf --height=40% --border=rounded --print-query \
49
- --header="Введите область или выберите из списка (Enter без ввода = без области)" | tail -1)
50
-
51
- SCOPE=$(echo "$SCOPE" | xargs) # Убираем лишние пробелы
52
-
53
- if [ -n "$SCOPE" ] && [ "$SCOPE" != " " ] && [ "$SCOPE" != "general" ]; then
54
- SCOPE="($SCOPE)"
55
- else
56
- SCOPE=""
57
- fi
58
-
59
- # Breaking change?
60
- header "Breaking Change"
61
- BREAKING=$(printf "Нет\nДа" | fzf --height=30% --border=rounded \
62
- --header="Это изменение ломает обратную совместимость?")
63
-
64
- if [ "$BREAKING" = "Да" ]; then
65
- BREAKING_CHAR="!"
66
-
67
- header "Описание Breaking Change"
68
- BREAKING_DESC=$(echo "" | fzf --height=10 --border=rounded --print-query \
69
- --header="Опишите что именно изменилось и как адаптировать код" | tail -1)
70
-
71
- if [ -z "$BREAKING_DESC" ] || [ "$BREAKING_DESC" = " " ]; then
72
- echo -e "${YELLOW}⚠️ Breaking change описан кратко${NC}"
73
- BREAKING_DESC="Изменен API/интерфейс, требуется обновление кода"
74
- fi
75
- else
76
- BREAKING_CHAR=""
77
- BREAKING_DESC=""
78
- fi
79
-
80
- # Краткое описание
81
- header "Краткое описание"
82
- DESCRIPTION=$(echo "" | fzf --height=10 --border=rounded --print-query \
83
- --header="Краткое описание (используйте повелительное наклонение, например: 'добавить', 'исправить', 'обновить')" | tail -1)
84
-
85
- # Проверка описания
86
- if [ -z "$DESCRIPTION" ] || [ "$DESCRIPTION" = " " ]; then
87
- echo -e "${RED}❌ Описание обязательно!${NC}"
88
- exit 1
89
- fi
90
-
91
- # Детальное описание (опционально)
92
- header "Детальное описание"
93
- echo -e "${YELLOW}Нажмите Ctrl+D для завершения ввода (или оставьте пустым)${NC}"
94
- echo "Введите детальное описание изменений:"
95
- BODY=""
96
- while IFS= read -r line; do
97
- if [ -z "$BODY" ]; then
98
- BODY="$line"
99
- else
100
- BODY="$BODY\n$line"
101
- fi
102
- done
103
-
104
- # Предпросмотр
105
- header "Предпросмотр коммита"
106
- FINAL_MESSAGE="$TYPE$SCOPE$BREAKING_CHAR: $DESCRIPTION"
107
-
108
- if [ -n "$BODY" ] && [ "$BODY" != " " ]; then
109
- FINAL_MESSAGE="$FINAL_MESSAGE\n\n$BODY"
110
- fi
111
-
112
- if [ -n "$BREAKING_DESC" ]; then
113
- if [ -n "$BODY" ] && [ "$BODY" != " " ]; then
114
- FINAL_MESSAGE="$FINAL_MESSAGE\n\n"
115
- else
116
- FINAL_MESSAGE="$FINAL_MESSAGE\n"
117
- fi
118
- FINAL_MESSAGE="$FINAL_MESSAGE\nBREAKING CHANGE: $BREAKING_DESC"
119
- fi
120
-
121
- echo -e "${GREEN}Сообщение коммита:${NC}"
122
- echo -e "------------------------------"
123
- echo -e "$FINAL_MESSAGE"
124
- echo -e "------------------------------"
125
-
126
- # Подтверждение
127
- header "Подтверждение"
128
- CONFIRM=$(printf "✅ Создать коммит\n❌ Отменить" | fzf --height=30% --border=rounded \
129
- --header="Все верно? (Enter для подтверждения)")
130
-
131
- if [[ "$CONFIRM" != "✅ Создать коммит" ]]; then
132
- echo -e "${YELLOW}❌ Отменено${NC}"
133
- exit 0
134
- fi
135
-
136
- # Создание коммита
137
- echo -e "$FINAL_MESSAGE" | git commit -F -
138
-
139
- # Проверка результата
140
- if [ $? -eq 0 ]; then
141
- echo -e "${GREEN}✅ Коммит успешно создан!${NC}"
142
-
143
- # Показываем последний коммит
144
- echo -e "\n${YELLOW}Последний коммит:${NC}"
145
- git log --oneline -1
146
- else
147
- echo -e "${RED}❌ Ошибка при создании коммита${NC}"
148
- exit 1
149
- fi