jcinfo-utils 1.0.32 → 1.0.34
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/index.d.ts +6 -0
- package/index.js +7 -1
- package/package.json +1 -1
- package/src/retirarAcentuacao.js +20 -0
- package/src/updateVersionDate.js +30 -0
- package/src/utils.js +12 -0
- package/test/testar.js +18 -6
package/index.d.ts
CHANGED
|
@@ -69,3 +69,9 @@ export function updateDotEnv(
|
|
|
69
69
|
incrementBuild?: boolean,
|
|
70
70
|
filename?: string,
|
|
71
71
|
): void
|
|
72
|
+
|
|
73
|
+
export function updateVersionDate(fs: any, filename?: string): void
|
|
74
|
+
|
|
75
|
+
export function retirarAcentuacao(value: string): string
|
|
76
|
+
|
|
77
|
+
export function fileExists(filename: string): boolean
|
package/index.js
CHANGED
|
@@ -11,6 +11,9 @@ import {
|
|
|
11
11
|
} from './src/dates.js'
|
|
12
12
|
import { updateDotEnv } from './src/updateDotEnv.js'
|
|
13
13
|
import { formatFileSize } from './src/formatFileSize.js'
|
|
14
|
+
import { updateVersionDate } from './src/updateVersionDate.js'
|
|
15
|
+
import { retirarAcentuacao } from './src/retirarAcentuacao.js'
|
|
16
|
+
import { fileExists } from './src/utils.js'
|
|
14
17
|
|
|
15
18
|
// ===================================================== LOGS
|
|
16
19
|
|
|
@@ -214,6 +217,9 @@ export {
|
|
|
214
217
|
random,
|
|
215
218
|
trunc,
|
|
216
219
|
scrollToTop,
|
|
217
|
-
updateDotEnv,
|
|
218
220
|
formatFileSize,
|
|
221
|
+
updateDotEnv,
|
|
222
|
+
updateVersionDate,
|
|
223
|
+
retirarAcentuacao,
|
|
224
|
+
fileExists,
|
|
219
225
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export function retirarAcentuacao(value) {
|
|
2
|
+
const cAcent = 'áéíóúÁÉÍÓÚãõÃÕàèìòùÀÈÌÒÙâêîôûÂÊÎÔÛäëïöüÄËÏÖܪº°çÇ&¹²³'
|
|
3
|
+
const sAcent = 'aeiouAEIOUaoAOaeiouAEIOUaeiouAEIOUaeiouAEIOUaoocCE123'
|
|
4
|
+
let result = ''
|
|
5
|
+
|
|
6
|
+
for (let i = 0; i < value.length; i++) {
|
|
7
|
+
let char = value.charAt(i)
|
|
8
|
+
let j = cAcent.indexOf(char)
|
|
9
|
+
|
|
10
|
+
if (j !== -1) {
|
|
11
|
+
result += sAcent.charAt(j)
|
|
12
|
+
} else if (char.charCodeAt(0) > 127) {
|
|
13
|
+
result += ' '
|
|
14
|
+
} else {
|
|
15
|
+
result += char
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return result
|
|
20
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const cFileEncoded = 'utf-8'
|
|
2
|
+
const cFileEnvLocal = '.env.local'
|
|
3
|
+
const cKeyVersionDate = 'VITE_VDATE'
|
|
4
|
+
|
|
5
|
+
export function updateVersionDate(fs, filename = cFileEnvLocal) {
|
|
6
|
+
try {
|
|
7
|
+
let content = fs
|
|
8
|
+
.readFileSync(cFileEnvLocal, cFileEncoded)
|
|
9
|
+
.split('\r\n')
|
|
10
|
+
.map((line) => {
|
|
11
|
+
let [key, value] = line.split('=')
|
|
12
|
+
if (key == cKeyVersionDate) {
|
|
13
|
+
value = new Date().toLocaleString()
|
|
14
|
+
let [data, hora] = value.split(', ')
|
|
15
|
+
let [, mes, ano] = data.split('/')
|
|
16
|
+
let [hour, minut] = hora.split(':')
|
|
17
|
+
line = `${key}=${ano}.${mes} (${hour}.${minut})`
|
|
18
|
+
console.log('"Versão Data" atualizada:', line)
|
|
19
|
+
}
|
|
20
|
+
return line
|
|
21
|
+
})
|
|
22
|
+
.join('\r\n')
|
|
23
|
+
fs.writeFileSync(cFileEnvLocal, content, cFileEncoded)
|
|
24
|
+
} catch (error) {
|
|
25
|
+
console.log(
|
|
26
|
+
'updateVersionDate:',
|
|
27
|
+
`Arquivo "${filename}" não existe ou está inacessível!`,
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
}
|
package/src/utils.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
|
|
3
|
+
export function fileExists(filename) {
|
|
4
|
+
try {
|
|
5
|
+
// Verifica se o arquivo existe usando fs.accessSync
|
|
6
|
+
fs.accessSync(filename, fs.constants.F_OK)
|
|
7
|
+
return true
|
|
8
|
+
} catch (err) {
|
|
9
|
+
// Se ocorrer um erro, o arquivo não existe ou não é acessível
|
|
10
|
+
return false
|
|
11
|
+
}
|
|
12
|
+
}
|
package/test/testar.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import * as jc from '../index.js'
|
|
2
2
|
import fs from 'node:fs'
|
|
3
|
+
import { updateDotEnv } from '../src/updateDotEnv.js'
|
|
4
|
+
import { updateVersionDate } from '../src/updateVersionDate.js'
|
|
5
|
+
import { retirarAcentuacao } from '../src/retirarAcentuacao.js'
|
|
3
6
|
|
|
4
7
|
function testFormatFileSize() {
|
|
5
8
|
let content = fs.readFileSync('c:\\jcinfo\\fb3\\databases.conf')
|
|
@@ -43,12 +46,6 @@ console.log(
|
|
|
43
46
|
|
|
44
47
|
console.groupEnd()
|
|
45
48
|
|
|
46
|
-
console.log('')
|
|
47
|
-
jc.updateDotEnv(fs, true)
|
|
48
|
-
console.log('')
|
|
49
|
-
|
|
50
|
-
console.groupEnd()
|
|
51
|
-
|
|
52
49
|
// ==================================================
|
|
53
50
|
console.group('Datas')
|
|
54
51
|
|
|
@@ -84,3 +81,18 @@ datas.forEach((data, i) => {
|
|
|
84
81
|
})
|
|
85
82
|
|
|
86
83
|
console.groupEnd()
|
|
84
|
+
console.groupEnd()
|
|
85
|
+
|
|
86
|
+
console.log('')
|
|
87
|
+
console.group('updateDotEnv, updateVersionDate, retirarAcentuação')
|
|
88
|
+
|
|
89
|
+
updateDotEnv(fs, true)
|
|
90
|
+
updateVersionDate(fs)
|
|
91
|
+
console.log('')
|
|
92
|
+
|
|
93
|
+
console.log(retirarAcentuacao('Criança, mãe, João, MÃE, anão, ANÃO'))
|
|
94
|
+
|
|
95
|
+
const arq = '.env'
|
|
96
|
+
console.log('Arquivo existe?', jc.fileExists(arq))
|
|
97
|
+
|
|
98
|
+
console.groupEnd()
|