@ridiormf/version-control 1.1.1 → 1.1.3
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/README.es.md +396 -0
- package/README.fr.md +396 -0
- package/README.md +218 -536
- package/README.pt.md +508 -0
- package/bin/smart-commit.js +41 -9
- package/bin/version-control.js +6 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +46 -12
- package/dist/index.js.map +1 -1
- package/dist/readline.d.ts +14 -0
- package/dist/readline.d.ts.map +1 -1
- package/dist/readline.js +32 -0
- package/dist/readline.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/updateChecker.d.ts +5 -0
- package/dist/updateChecker.d.ts.map +1 -1
- package/dist/updateChecker.js +18 -2
- package/dist/updateChecker.js.map +1 -1
- package/package.json +12 -6
package/README.pt.md
ADDED
|
@@ -0,0 +1,508 @@
|
|
|
1
|
+
# Version Control
|
|
2
|
+
|
|
3
|
+
[](README.md)
|
|
4
|
+
[](README.pt.md)
|
|
5
|
+
[](README.es.md)
|
|
6
|
+
[](README.fr.md)
|
|
7
|
+
|
|
8
|
+
> Sistema inteligente de controle de versão que analisa commits do Git e automatiza o versionamento semântico (SemVer).
|
|
9
|
+
|
|
10
|
+
[](https://www.npmjs.com/package/@ridio/version-control)
|
|
11
|
+
[](https://opensource.org/licenses/MIT)
|
|
12
|
+
|
|
13
|
+
## 📋 Índice
|
|
14
|
+
|
|
15
|
+
- [Sobre](#sobre)
|
|
16
|
+
- [Instalação](#instalação)
|
|
17
|
+
- [Uso](#uso)
|
|
18
|
+
- [Como Funciona](#como-funciona)
|
|
19
|
+
- [Exemplos](#exemplos)
|
|
20
|
+
- [API](#api)
|
|
21
|
+
- [Contribuindo](#contribuindo)
|
|
22
|
+
- [Licença](#licença)
|
|
23
|
+
|
|
24
|
+
## 🎯 Sobre
|
|
25
|
+
|
|
26
|
+
O **Version Control** automatiza o versionamento semântico do seu projeto, eliminando a necessidade de decidir manualmente entre MAJOR, MINOR ou PATCH.
|
|
27
|
+
|
|
28
|
+
**Por que foi criado?**
|
|
29
|
+
|
|
30
|
+
Versionamento manual é propenso a erros e inconsistente entre equipes. Esta ferramenta resolve:
|
|
31
|
+
|
|
32
|
+
- ❌ Esquecimento de atualizar `package.json`, `CHANGELOG.md` ou tags
|
|
33
|
+
- ❌ Dúvidas sobre qual versão usar (MAJOR/MINOR/PATCH)
|
|
34
|
+
- ❌ CHANGELOGs incompletos ou desorganizados
|
|
35
|
+
- ❌ Mensagens de commit inconsistentes
|
|
36
|
+
|
|
37
|
+
**Solução:**
|
|
38
|
+
|
|
39
|
+
- ✅ Analisa commits automaticamente e sugere a versão correta
|
|
40
|
+
- ✅ Atualiza todos os arquivos de uma vez
|
|
41
|
+
- ✅ Gera CHANGELOGs organizados e completos
|
|
42
|
+
- ✅ Cria tags e faz push automaticamente
|
|
43
|
+
|
|
44
|
+
### ✨ Funcionalidades
|
|
45
|
+
|
|
46
|
+
- 🔍 **Análise Inteligente**: Analisa mensagens de commit e arquivos modificados
|
|
47
|
+
- 🎯 **Sugestão Automática**: Sugere MAJOR, MINOR ou PATCH baseado nas mudanças
|
|
48
|
+
- 📝 **Atualização Automática**: Atualiza `package.json`, `CHANGELOG.md` e arquivos de código
|
|
49
|
+
- 🏷️ **Git Tags**: Cria tags automaticamente e faz push para o repositório
|
|
50
|
+
- 🤖 **Smart Commit**: Gera mensagens de commit seguindo Conventional Commits
|
|
51
|
+
- 📋 **CHANGELOG Inteligente**: Agrupa commits por tipo e remove duplicatas
|
|
52
|
+
- 🧪 **Modo de Teste**: Permite rollback automático
|
|
53
|
+
- 🌍 **Internacionalização**: Suporte para EN, PT, ES, FR
|
|
54
|
+
|
|
55
|
+
## 📦 Instalação
|
|
56
|
+
|
|
57
|
+
### Global (Recomendado)
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
yarn global add @ridiormf/version-control
|
|
61
|
+
# ou
|
|
62
|
+
npm install -g @ridiormf/version-control
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Como dependência de desenvolvimento
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
yarn add -D @ridiormf/version-control
|
|
69
|
+
# ou
|
|
70
|
+
npm install -D @ridiormf/version-control
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Uso com npx (sem instalação)
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
npx @ridiormf/version-control
|
|
77
|
+
# ou
|
|
78
|
+
yarn dlx @ridiormf/version-control
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## 🚀 Uso
|
|
82
|
+
|
|
83
|
+
### CLI - Version Control
|
|
84
|
+
|
|
85
|
+
Após fazer suas alterações e commitar:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
version-control
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Ou com npx (sem instalar):
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
npx @ridiormf/version-control
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### CLI - Smart Commit
|
|
98
|
+
|
|
99
|
+
Commit inteligente com mensagem automática:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
git add .
|
|
103
|
+
smart-commit
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Exemplo:**
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
Staged files: 2
|
|
110
|
+
✨ src/newFeature.ts (+45/-0)
|
|
111
|
+
📝 src/index.ts (+5/-2)
|
|
112
|
+
|
|
113
|
+
Generated commit message:
|
|
114
|
+
feat(src): add newFeature
|
|
115
|
+
|
|
116
|
+
Options: [1] Commit [2] Edit [3] Cancel
|
|
117
|
+
Choice: 1
|
|
118
|
+
|
|
119
|
+
✓ Commit created successfully!
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Adicionando ao package.json
|
|
123
|
+
|
|
124
|
+
Adicione um script no seu `package.json`:
|
|
125
|
+
|
|
126
|
+
```json
|
|
127
|
+
{
|
|
128
|
+
"scripts": {
|
|
129
|
+
"version": "version-control",
|
|
130
|
+
"version:test": "version-control --test",
|
|
131
|
+
"commit": "smart-commit"
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
E execute:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
# Commit inteligente
|
|
140
|
+
yarn commit
|
|
141
|
+
|
|
142
|
+
# Versionamento normal
|
|
143
|
+
yarn version
|
|
144
|
+
|
|
145
|
+
# Versionamento com teste (permite desfazer)
|
|
146
|
+
yarn version:test
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Uso Programático
|
|
150
|
+
|
|
151
|
+
Use a biblioteca em seus scripts personalizados:
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
import {
|
|
155
|
+
analyzeChanges,
|
|
156
|
+
bumpVersion,
|
|
157
|
+
getCurrentVersion,
|
|
158
|
+
updatePackageJson,
|
|
159
|
+
updateChangelog,
|
|
160
|
+
executeGitCommands,
|
|
161
|
+
} from "@ridiormf/version-control";
|
|
162
|
+
|
|
163
|
+
// 1. Obter versão atual
|
|
164
|
+
const currentVersion = getCurrentVersion();
|
|
165
|
+
// Retorna: "1.2.3"
|
|
166
|
+
|
|
167
|
+
// 2. Analisar mudanças do último commit
|
|
168
|
+
const analysis = analyzeChanges();
|
|
169
|
+
// Retorna: { type: 'minor', reason: ['New feature added'], filesChanged: [...], commitMsg: '...' }
|
|
170
|
+
|
|
171
|
+
// 3. Calcular nova versão
|
|
172
|
+
const newVersion = bumpVersion(currentVersion, analysis.type);
|
|
173
|
+
// Retorna: "1.3.0"
|
|
174
|
+
|
|
175
|
+
// 4. Atualizar arquivos
|
|
176
|
+
updatePackageJson(newVersion);
|
|
177
|
+
updateChangelog(newVersion, analysis.type, analysis);
|
|
178
|
+
|
|
179
|
+
// 5. Commitar e criar tag
|
|
180
|
+
executeGitCommands(newVersion);
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## 🔧 Como Funciona
|
|
184
|
+
|
|
185
|
+
O sistema analisa as mudanças do último commit do Git e sugere a versão apropriada baseado em:
|
|
186
|
+
|
|
187
|
+
### � Conventional Commits
|
|
188
|
+
|
|
189
|
+
A ferramenta suporta o formato [Conventional Commits](https://www.conventionalcommits.org/), que estrutura as mensagens de commit de forma padronizada:
|
|
190
|
+
|
|
191
|
+
```
|
|
192
|
+
<tipo>(<escopo>): <descrição>
|
|
193
|
+
|
|
194
|
+
[corpo opcional]
|
|
195
|
+
|
|
196
|
+
[rodapé(s) opcional(is)]
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
**Exemplos:**
|
|
200
|
+
|
|
201
|
+
- `feat(auth): add login functionality`
|
|
202
|
+
- `fix: resolve memory leak in cache`
|
|
203
|
+
- `feat!: remove support for Node 12` (breaking change)
|
|
204
|
+
|
|
205
|
+
### 📋 CHANGELOG Inteligente
|
|
206
|
+
|
|
207
|
+
Todos os commits desde a última versão são **automaticamente incluídos** no CHANGELOG, agrupados por tipo:
|
|
208
|
+
|
|
209
|
+
- **✨ Added** - Novas funcionalidades (`feat:`, `add`, `new`)
|
|
210
|
+
- **🐛 Fixed** - Correções de bugs (`fix:`, `bug`)
|
|
211
|
+
- **🔄 Changed** - Mudanças em funcionalidades (`refactor:`, `perf:`)
|
|
212
|
+
- **⚠️ Breaking Changes** - Mudanças incompatíveis (`BREAKING CHANGE`, `!`)
|
|
213
|
+
- **🗑️ Removed** - Remoções (`remove`, `delete`)
|
|
214
|
+
- **🔒 Security** - Correções de segurança (`security`)
|
|
215
|
+
- **⚠️ Deprecated** - Funcionalidades obsoletas (`deprecat`)
|
|
216
|
+
|
|
217
|
+
A ferramenta **remove automaticamente** duplicatas e commits similares, mantendo apenas as entradas mais relevantes.
|
|
218
|
+
|
|
219
|
+
### 🤖 Smart Commit - Mensagens Automáticas
|
|
220
|
+
|
|
221
|
+
O **Smart Commit** analisa os arquivos staged e gera mensagens de commit automaticamente em inglês, seguindo o padrão Conventional Commits:
|
|
222
|
+
|
|
223
|
+
#### Como funciona:
|
|
224
|
+
|
|
225
|
+
1. **Analisa os arquivos**: Detecta arquivos adicionados, modificados ou deletados
|
|
226
|
+
2. **Identifica o tipo**: feat, fix, docs, test, refactor, style, chore
|
|
227
|
+
3. **Detecta o escopo**: Identifica automaticamente (src, api, ui, etc.)
|
|
228
|
+
4. **Gera a descrição**: Baseado nos nomes dos arquivos e padrões de mudança
|
|
229
|
+
|
|
230
|
+
#### Tipos detectados automaticamente:
|
|
231
|
+
|
|
232
|
+
- **feat**: Novos arquivos ou funcionalidades
|
|
233
|
+
- **fix**: Mais deleções que adições (correções)
|
|
234
|
+
- **docs**: Apenas arquivos de documentação (.md, .txt)
|
|
235
|
+
- **test**: Apenas arquivos de teste
|
|
236
|
+
- **style**: Mudanças pequenas em CSS/SCSS
|
|
237
|
+
- **refactor**: Modificações em código existente
|
|
238
|
+
- **chore**: Configurações e arquivos auxiliares
|
|
239
|
+
|
|
240
|
+
#### Exemplo:
|
|
241
|
+
|
|
242
|
+
```bash
|
|
243
|
+
# Adicionar novo arquivo
|
|
244
|
+
git add src/authentication.ts
|
|
245
|
+
yarn commit
|
|
246
|
+
# Gera: feat(src): add authentication
|
|
247
|
+
|
|
248
|
+
# Corrigir bug
|
|
249
|
+
git add src/bugFix.ts
|
|
250
|
+
yarn commit
|
|
251
|
+
# Gera: fix(src): resolve issue in bugFix
|
|
252
|
+
|
|
253
|
+
# Atualizar documentação
|
|
254
|
+
git add README.md
|
|
255
|
+
yarn commit
|
|
256
|
+
# Gera: docs: update README
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
#### 🎉 Versão Inicial (1.0.0)
|
|
260
|
+
|
|
261
|
+
Quando a ferramenta detecta que está gerando a versão **1.0.0** (primeira release), ela adiciona uma mensagem especial no CHANGELOG:
|
|
262
|
+
|
|
263
|
+
```markdown
|
|
264
|
+
## [1.0.0] - 2025-12-24
|
|
265
|
+
|
|
266
|
+
### 🎉 Initial Release
|
|
267
|
+
|
|
268
|
+
Primeira versão pública do projeto.
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
Esta é uma regra automática aplicada a **qualquer projeto** que usar a ferramenta pela primeira vez.
|
|
272
|
+
|
|
273
|
+
### �🔴 MAJOR (X.0.0) - Breaking Changes
|
|
274
|
+
|
|
275
|
+
Detectado quando a mensagem de commit contém palavras-chave como:
|
|
276
|
+
|
|
277
|
+
- `breaking`, `break`
|
|
278
|
+
- `incompatível`, `incompatible`
|
|
279
|
+
- `remove`, `delete`
|
|
280
|
+
- `refactor completo`, `rewrite`
|
|
281
|
+
|
|
282
|
+
**Exemplo:**
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
git commit -m "breaking: remove deprecated API methods"
|
|
286
|
+
# Sugere: 1.5.3 → 2.0.0
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### 🟡 MINOR (x.Y.0) - Novas Funcionalidades
|
|
290
|
+
|
|
291
|
+
Detectado quando:
|
|
292
|
+
|
|
293
|
+
- Mensagem contém: `add`, `new`, `feature`, `implement`, `create`
|
|
294
|
+
- Novos arquivos são adicionados ao projeto
|
|
295
|
+
- Arquivos de configuração são modificados
|
|
296
|
+
|
|
297
|
+
**Exemplo:**
|
|
298
|
+
|
|
299
|
+
```bash
|
|
300
|
+
git commit -m "feat: add user authentication module"
|
|
301
|
+
# Sugere: 1.5.3 → 1.6.0
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### 🟢 PATCH (x.y.Z) - Correções
|
|
305
|
+
|
|
306
|
+
Detectado quando a mensagem contém:
|
|
307
|
+
|
|
308
|
+
- `fix`, `bug`, `error`
|
|
309
|
+
- `correção`, `ajuste`
|
|
310
|
+
- Pequenas mudanças sem novos arquivos
|
|
311
|
+
|
|
312
|
+
**Exemplo:**
|
|
313
|
+
|
|
314
|
+
```bash
|
|
315
|
+
git commit -m "fix: resolve memory leak in cache"
|
|
316
|
+
# Sugere: 1.5.3 → 1.5.4
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
### 📊 Semantic Versioning
|
|
320
|
+
|
|
321
|
+
```
|
|
322
|
+
Quebra código existente?
|
|
323
|
+
├─ SIM → 🔴 MAJOR (X.0.0)
|
|
324
|
+
└─ NÃO → Adiciona funcionalidade?
|
|
325
|
+
├─ SIM → 🟡 MINOR (x.Y.0)
|
|
326
|
+
└─ NÃO → 🟢 PATCH (x.y.Z)
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
Veja mais em [semver.org](https://semver.org/)
|
|
330
|
+
|
|
331
|
+
## 📖 Exemplos
|
|
332
|
+
|
|
333
|
+
### Fluxo Típico
|
|
334
|
+
|
|
335
|
+
```bash
|
|
336
|
+
git commit -m "feat: add new export functionality"
|
|
337
|
+
version-control
|
|
338
|
+
|
|
339
|
+
# Versão atual: 1.2.3
|
|
340
|
+
# Tipo sugerido: MINOR
|
|
341
|
+
# Nova versão: 1.3.0
|
|
342
|
+
#
|
|
343
|
+
# Deseja atualizar? (s/n): s
|
|
344
|
+
#
|
|
345
|
+
# ✓ package.json atualizado
|
|
346
|
+
# ✓ CHANGELOG.md atualizado
|
|
347
|
+
# ✓ Tag v1.3.0 criada
|
|
348
|
+
# ✓ Versão 1.3.0 publicada!
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
## 📚 API
|
|
352
|
+
|
|
353
|
+
### Métodos Disponíveis
|
|
354
|
+
|
|
355
|
+
#### Análise e Versionamento
|
|
356
|
+
|
|
357
|
+
- `analyzeChanges()` - Analisa último commit e sugere tipo de versão
|
|
358
|
+
- `getCurrentVersion(projectRoot?)` - Retorna versão atual do package.json
|
|
359
|
+
- `bumpVersion(currentVersion, type)` - Calcula nova versão
|
|
360
|
+
|
|
361
|
+
#### Atualização de Arquivos
|
|
362
|
+
|
|
363
|
+
- `updatePackageJson(newVersion, projectRoot?)` - Atualiza package.json
|
|
364
|
+
- `updateIndexFile(newVersion, projectRoot?)` - Atualiza @version em arquivos de código
|
|
365
|
+
- `updateChangelog(version, type, analysis, projectRoot?)` - Atualiza CHANGELOG.md
|
|
366
|
+
|
|
367
|
+
#### Commit e Git
|
|
368
|
+
|
|
369
|
+
- `executeGitCommands(version)` - Cria commit, tag e faz push
|
|
370
|
+
- `getStagedChanges()` - Lista arquivos no stage
|
|
371
|
+
- `generateCommitMessage(changes)` - Gera mensagem de commit automática
|
|
372
|
+
|
|
373
|
+
#### Configuração
|
|
374
|
+
|
|
375
|
+
- `getConfiguredLanguage()` - Retorna idioma configurado
|
|
376
|
+
- `setLanguage(lang)` - Define idioma manualmente
|
|
377
|
+
- `clearConfig()` - Remove configuração
|
|
378
|
+
|
|
379
|
+
---
|
|
380
|
+
|
|
381
|
+
### Detalhamento
|
|
382
|
+
|
|
383
|
+
### `analyzeChanges(): ChangeAnalysis`
|
|
384
|
+
|
|
385
|
+
Analisa o último commit e retorna uma análise das mudanças.
|
|
386
|
+
|
|
387
|
+
**Retorno:**
|
|
388
|
+
|
|
389
|
+
```typescript
|
|
390
|
+
interface ChangeAnalysis {
|
|
391
|
+
type: "major" | "minor" | "patch";
|
|
392
|
+
reason: string[];
|
|
393
|
+
filesChanged: string[];
|
|
394
|
+
commitMsg: string;
|
|
395
|
+
}
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
### `getCurrentVersion(projectRoot?: string): string`
|
|
399
|
+
|
|
400
|
+
Retorna a versão atual do `package.json`.
|
|
401
|
+
|
|
402
|
+
**Parâmetros:**
|
|
403
|
+
|
|
404
|
+
- `projectRoot` (opcional): Caminho raiz do projeto (padrão: `process.cwd()`)
|
|
405
|
+
|
|
406
|
+
### `bumpVersion(currentVersion: string, type: VersionType): string`
|
|
407
|
+
|
|
408
|
+
Calcula a nova versão baseado no tipo de bump.
|
|
409
|
+
|
|
410
|
+
**Parâmetros:**
|
|
411
|
+
|
|
412
|
+
- `currentVersion`: Versão atual (ex: "1.2.3")
|
|
413
|
+
- `type`: Tipo de bump (`'major'`, `'minor'`, ou `'patch'`)
|
|
414
|
+
|
|
415
|
+
**Exemplo:**
|
|
416
|
+
|
|
417
|
+
```typescript
|
|
418
|
+
bumpVersion("1.2.3", "major"); // "2.0.0"
|
|
419
|
+
bumpVersion("1.2.3", "minor"); // "1.3.0"
|
|
420
|
+
bumpVersion("1.2.3", "patch"); // "1.2.4"
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
## � Internacionalização
|
|
424
|
+
|
|
425
|
+
A ferramenta detecta automaticamente o idioma do sistema e ajusta todas as mensagens de acordo.
|
|
426
|
+
|
|
427
|
+
### Idiomas Suportados
|
|
428
|
+
|
|
429
|
+
- 🇬🇧 **Inglês (EN)** - Default
|
|
430
|
+
- 🇧🇷 **Português (PT)** - pt_BR, pt_PT
|
|
431
|
+
- 🇪🇸 **Espanhol (ES)** - es_ES, es_MX, etc.
|
|
432
|
+
- 🇫🇷 **Francês (FR)** - fr_FR, fr_CA, etc.
|
|
433
|
+
|
|
434
|
+
### Configurar Idioma Manualmente
|
|
435
|
+
|
|
436
|
+
```bash
|
|
437
|
+
# Configurar para português
|
|
438
|
+
version-control config --lang pt
|
|
439
|
+
|
|
440
|
+
# Configurar para inglês
|
|
441
|
+
version-control config --lang en
|
|
442
|
+
|
|
443
|
+
# Configurar para espanhol
|
|
444
|
+
version-control config --lang es
|
|
445
|
+
|
|
446
|
+
# Configurar para francês
|
|
447
|
+
version-control config --lang fr
|
|
448
|
+
|
|
449
|
+
# Limpar configuração (volta a usar detecção automática)
|
|
450
|
+
version-control config --clear
|
|
451
|
+
|
|
452
|
+
# Ver configuração atual
|
|
453
|
+
version-control config
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
A configuração é salva globalmente em `~/.version-control-config.json` e será usada em todos os projetos.
|
|
457
|
+
|
|
458
|
+
### Como Funciona
|
|
459
|
+
|
|
460
|
+
1. **Configuração Manual**: Se você configurou um idioma com `version-control config --lang`, ele será usado
|
|
461
|
+
2. **Detecção Automática**: Se não houver configuração, detecta do sistema via `LANG`, `LANGUAGE`, `LC_ALL`
|
|
462
|
+
3. **Fallback**: Se o idioma não for suportado, usa inglês automaticamente
|
|
463
|
+
|
|
464
|
+
**Indicador de Idioma:**
|
|
465
|
+
|
|
466
|
+
Toda vez que você executar `version-control` ou `smart-commit`, verá uma linha informando:
|
|
467
|
+
|
|
468
|
+
```bash
|
|
469
|
+
ℹ Current language: PT (manually configured)
|
|
470
|
+
To change language: version-control config --lang <code>
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
ou
|
|
474
|
+
|
|
475
|
+
```bash
|
|
476
|
+
ℹ Idioma atual: PT (detectado do sistema)
|
|
477
|
+
Para mudar o idioma: version-control config --lang <code>
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
## 🎯 Palavras-chave
|
|
481
|
+
|
|
482
|
+
- **MAJOR**: `breaking`, `remove`, `delete`, `rewrite`
|
|
483
|
+
- **MINOR**: `add`, `new`, `feature`, `implement`
|
|
484
|
+
- **PATCH**: `fix`, `bug`, `error`
|
|
485
|
+
|
|
486
|
+
## 🤝 Contribuindo
|
|
487
|
+
|
|
488
|
+
Contribuições são bem-vindas! Sinta-se à vontade para:
|
|
489
|
+
|
|
490
|
+
1. Fazer fork do projeto
|
|
491
|
+
2. Criar uma branch para sua feature (`git checkout -b feature/AmazingFeature`)
|
|
492
|
+
3. Commit suas mudanças (`git commit -m 'feat: add some AmazingFeature'`)
|
|
493
|
+
4. Push para a branch (`git push origin feature/AmazingFeature`)
|
|
494
|
+
5. Abrir um Pull Request
|
|
495
|
+
|
|
496
|
+
## 📄 Licença
|
|
497
|
+
|
|
498
|
+
Este projeto está sob a licença MIT. Veja o arquivo [LICENSE](LICENSE) para mais detalhes.
|
|
499
|
+
|
|
500
|
+
## 👤 Autor
|
|
501
|
+
|
|
502
|
+
**Ridio Ricardo**
|
|
503
|
+
|
|
504
|
+
- GitHub: [@ridioricardo](https://github.com/ridioricardo)
|
|
505
|
+
|
|
506
|
+
---
|
|
507
|
+
|
|
508
|
+
Baseado nas especificações do [Semantic Versioning 2.0.0](https://semver.org/)
|
package/bin/smart-commit.js
CHANGED
|
@@ -12,7 +12,8 @@ const {
|
|
|
12
12
|
} = require("../dist/commitGenerator.js");
|
|
13
13
|
const {
|
|
14
14
|
createInterface,
|
|
15
|
-
|
|
15
|
+
askChoice,
|
|
16
|
+
askText,
|
|
16
17
|
closeInterface,
|
|
17
18
|
} = require("../dist/readline.js");
|
|
18
19
|
const { checkForUpdates } = require("../dist/updateChecker.js");
|
|
@@ -39,10 +40,16 @@ function showLanguageInfo() {
|
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
async function main() {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
});
|
|
43
|
+
console.log("");
|
|
44
|
+
|
|
45
|
+
// Check for updates to clear stdin buffer
|
|
46
|
+
await checkForUpdates().catch(() => {});
|
|
47
|
+
|
|
48
|
+
// Destroy HTTP agents immediately after
|
|
49
|
+
const http = require("http");
|
|
50
|
+
const https = require("https");
|
|
51
|
+
if (http.globalAgent) http.globalAgent.destroy();
|
|
52
|
+
if (https.globalAgent) https.globalAgent.destroy();
|
|
46
53
|
|
|
47
54
|
console.log("");
|
|
48
55
|
console.log(
|
|
@@ -56,6 +63,7 @@ async function main() {
|
|
|
56
63
|
console.log(
|
|
57
64
|
`${colors.bold}${colors.cyan}═══════════════════════════════════════════════════════════${colors.reset}`
|
|
58
65
|
);
|
|
66
|
+
console.log(`${colors.yellow}[LOCAL VERSION]${colors.reset}`);
|
|
59
67
|
console.log("");
|
|
60
68
|
|
|
61
69
|
// Show language info
|
|
@@ -136,7 +144,7 @@ async function main() {
|
|
|
136
144
|
|
|
137
145
|
let choice = "";
|
|
138
146
|
while (true) {
|
|
139
|
-
choice = await
|
|
147
|
+
choice = await askChoice(
|
|
140
148
|
rl,
|
|
141
149
|
`${colors.bold}${t("options")} [1] ${t("optionCommit")} [2] ${t(
|
|
142
150
|
"optionEdit"
|
|
@@ -161,7 +169,7 @@ async function main() {
|
|
|
161
169
|
|
|
162
170
|
if (choice === "2") {
|
|
163
171
|
console.log("");
|
|
164
|
-
finalMessage = await
|
|
172
|
+
finalMessage = await askText(
|
|
165
173
|
rl,
|
|
166
174
|
`${colors.bold}${t("enterCommitMessage")}${colors.reset} `
|
|
167
175
|
);
|
|
@@ -197,12 +205,36 @@ async function main() {
|
|
|
197
205
|
);
|
|
198
206
|
console.log("");
|
|
199
207
|
|
|
200
|
-
//
|
|
201
|
-
|
|
208
|
+
// Close everything
|
|
209
|
+
rl.close();
|
|
210
|
+
if (rl._ttyInput) rl._ttyInput.destroy();
|
|
211
|
+
if (rl._ttyOutput) rl._ttyOutput.destroy();
|
|
212
|
+
if (rl._ttyFd !== undefined) {
|
|
213
|
+
try {
|
|
214
|
+
require("fs").closeSync(rl._ttyFd);
|
|
215
|
+
} catch (e) {}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// Kill HTTP agents
|
|
219
|
+
const http = require("http");
|
|
220
|
+
const https = require("https");
|
|
221
|
+
if (http.globalAgent) http.globalAgent.destroy();
|
|
222
|
+
if (https.globalAgent) https.globalAgent.destroy();
|
|
223
|
+
|
|
224
|
+
// Force terminate with SIGKILL
|
|
225
|
+
process.kill(process.pid, "SIGTERM");
|
|
202
226
|
} catch (error) {
|
|
203
227
|
console.log("");
|
|
204
228
|
console.log(`${colors.red}✗ ${t("commitFailed")}${colors.reset}`);
|
|
205
229
|
console.log("");
|
|
230
|
+
rl.close();
|
|
231
|
+
if (rl._ttyInput) rl._ttyInput.destroy();
|
|
232
|
+
if (rl._ttyOutput) rl._ttyOutput.destroy();
|
|
233
|
+
if (rl._ttyFd !== undefined) {
|
|
234
|
+
try {
|
|
235
|
+
require("fs").closeSync(rl._ttyFd);
|
|
236
|
+
} catch (e) {}
|
|
237
|
+
}
|
|
206
238
|
process.exit(1);
|
|
207
239
|
}
|
|
208
240
|
}
|
package/bin/version-control.js
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;;GAMG;AAIH,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAuF5C;;GAEG;AACH,iBAAe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;;GAMG;AAIH,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAuF5C;;GAEG;AACH,iBAAe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAsPnC;AAGD,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,WAAW,EAAE,iBAAiB,EAAE,CAAC"}
|