@gilbert_oliveira/commit-wizard 2.0.2 → 2.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/README.md +13 -14
- package/dist/commit-wizard.d.ts +1 -0
- package/dist/commit-wizard.js +52 -110
- package/package.json +29 -26
- package/{bin → src/bin}/commit-wizard.ts +6 -5
- package/src/core/cache.ts +2 -2
- package/src/core/index.ts +15 -11
- package/src/core/openai.ts +30 -12
- package/src/core/smart-split.ts +72 -48
- package/src/git/index.ts +16 -4
- package/src/ui/index.ts +1 -1
- package/src/ui/smart-split.ts +1 -1
- package/src/utils/polyfill.ts +0 -82
package/src/utils/polyfill.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Polyfill para stripVTControlCharacters para compatibilidade com Bun/Node.js
|
|
3
|
-
*
|
|
4
|
-
* Este polyfill resolve problemas de compatibilidade onde o Bun não mapeia
|
|
5
|
-
* corretamente a função stripVTControlCharacters do módulo util do Node.js.
|
|
6
|
-
* A função foi adicionada ao Node.js v16.14.0+ mas pode não estar disponível
|
|
7
|
-
* em todos os ambientes ou ter problemas de mapping no Bun.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Remove caracteres de controle VT de uma string
|
|
12
|
-
* Implementação baseada na função nativa do Node.js
|
|
13
|
-
*
|
|
14
|
-
* @param str - String da qual remover os caracteres de controle
|
|
15
|
-
* @returns String limpa sem caracteres de controle VT/ANSI
|
|
16
|
-
*/
|
|
17
|
-
function stripVTControlCharacters(str: string): string {
|
|
18
|
-
if (typeof str !== 'string') {
|
|
19
|
-
throw new TypeError('The "str" argument must be of type string');
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// Regex para caracteres de controle ANSI/VT
|
|
23
|
-
// Baseada na implementação oficial do Node.js
|
|
24
|
-
const esc = String.fromCharCode(27); // ESC character (\u001B)
|
|
25
|
-
const csi = String.fromCharCode(155); // CSI character (\u009B)
|
|
26
|
-
const ansiRegex = new RegExp(`[${esc}${csi}][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]`, 'g');
|
|
27
|
-
|
|
28
|
-
return str.replace(ansiRegex, '');
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Interceptar require/import do módulo util antes de qualquer outra coisa
|
|
32
|
-
|
|
33
|
-
const Module = require('module');
|
|
34
|
-
const originalRequire = Module.prototype.require;
|
|
35
|
-
|
|
36
|
-
Module.prototype.require = function(id: string) {
|
|
37
|
-
const result = originalRequire.apply(this, arguments);
|
|
38
|
-
|
|
39
|
-
// Se estiver importando o módulo util e stripVTControlCharacters não existe, adicionar
|
|
40
|
-
if (id === 'util' && result && !result.stripVTControlCharacters) {
|
|
41
|
-
result.stripVTControlCharacters = stripVTControlCharacters;
|
|
42
|
-
// Tornar a propriedade não enumerável para não interferir em iterações
|
|
43
|
-
Object.defineProperty(result, 'stripVTControlCharacters', {
|
|
44
|
-
value: stripVTControlCharacters,
|
|
45
|
-
writable: false,
|
|
46
|
-
enumerable: true,
|
|
47
|
-
configurable: false,
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return result;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
declare global {
|
|
56
|
-
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
57
|
-
namespace NodeJS {
|
|
58
|
-
interface Global {
|
|
59
|
-
stripVTControlCharacters?: typeof stripVTControlCharacters;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Disponibilizar globalmente também como fallback
|
|
65
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
66
|
-
if (typeof globalThis !== 'undefined' && !(globalThis as any).stripVTControlCharacters) {
|
|
67
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
68
|
-
(globalThis as any).stripVTControlCharacters = stripVTControlCharacters;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Tentar aplicar diretamente ao módulo util se possível
|
|
72
|
-
try {
|
|
73
|
-
|
|
74
|
-
const util = require('util');
|
|
75
|
-
if (!util.stripVTControlCharacters) {
|
|
76
|
-
util.stripVTControlCharacters = stripVTControlCharacters;
|
|
77
|
-
}
|
|
78
|
-
} catch {
|
|
79
|
-
// Ignorar se não conseguir aplicar
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export { stripVTControlCharacters };
|