jcinfo-utils 1.0.35 → 1.0.36
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/.env +1 -1
- package/index.d.ts +2 -2
- package/index.js +6 -3
- package/package.json +1 -1
- package/src/updateDotEnv.js +4 -6
- package/test/testar.js +3 -5
- package/src/updateVersionDate.js +0 -29
package/.env
CHANGED
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -9,9 +9,12 @@ import {
|
|
|
9
9
|
getLastDay,
|
|
10
10
|
getMonthName,
|
|
11
11
|
} from './src/dates.js'
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
updateDotEnv,
|
|
14
|
+
updateDotEnvKey,
|
|
15
|
+
updateDotEnvKey as updateVersionDate,
|
|
16
|
+
} from './src/updateDotEnv.js'
|
|
13
17
|
import { formatFileSize } from './src/formatFileSize.js'
|
|
14
|
-
import { updateVersionDate } from './src/updateVersionDate.js'
|
|
15
18
|
import { retirarAcentuacao } from './src/retirarAcentuacao.js'
|
|
16
19
|
import { fileExists } from './src/utils.js'
|
|
17
20
|
|
|
@@ -219,8 +222,8 @@ export {
|
|
|
219
222
|
scrollToTop,
|
|
220
223
|
formatFileSize,
|
|
221
224
|
updateDotEnv,
|
|
222
|
-
updateVersionDate,
|
|
223
225
|
updateDotEnvKey,
|
|
226
|
+
updateVersionDate, //por questão de compatibilidade
|
|
224
227
|
retirarAcentuacao,
|
|
225
228
|
fileExists,
|
|
226
229
|
}
|
package/package.json
CHANGED
package/src/updateDotEnv.js
CHANGED
|
@@ -56,9 +56,7 @@ export function updateDotEnv(fs, incrementBuild = false, filename = '.env') {
|
|
|
56
56
|
}
|
|
57
57
|
version = `${version} (${finalBuild})`
|
|
58
58
|
line = `${key}=${version}`
|
|
59
|
-
console.log('')
|
|
60
|
-
console.log('Versão atualizada: ', version, 'no arquivo', filename)
|
|
61
|
-
console.log('')
|
|
59
|
+
console.log('* Versão atualizada: ', version, 'no arquivo', filename)
|
|
62
60
|
}
|
|
63
61
|
return line
|
|
64
62
|
})
|
|
@@ -70,9 +68,9 @@ const envKey = 'VITE_VERSION'
|
|
|
70
68
|
|
|
71
69
|
export function updateDotEnvKey(
|
|
72
70
|
fs,
|
|
73
|
-
filename = envProd,
|
|
74
|
-
key = envKey,
|
|
75
71
|
autoInc = false,
|
|
72
|
+
key = envKey,
|
|
73
|
+
filename = envProd,
|
|
76
74
|
updateWithDate = false,
|
|
77
75
|
) {
|
|
78
76
|
function generateValue(value) {
|
|
@@ -107,7 +105,7 @@ export function updateDotEnvKey(
|
|
|
107
105
|
if (vkey == key) {
|
|
108
106
|
let version = generateValue(vvalue)
|
|
109
107
|
line = `${key}=${version}`
|
|
110
|
-
console.log('Update KEY:', `${key} = ${version}`, '=>', filename)
|
|
108
|
+
console.log('* Update KEY:', `${key} = ${version}`, '=>', filename)
|
|
111
109
|
}
|
|
112
110
|
return line
|
|
113
111
|
})
|
package/test/testar.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as jc from '../index.js'
|
|
2
2
|
import fs from 'node:fs'
|
|
3
3
|
import { updateDotEnv, updateDotEnvKey } from '../src/updateDotEnv.js'
|
|
4
|
-
import { updateVersionDate } from '../src/updateVersionDate.js'
|
|
5
4
|
import { retirarAcentuacao } from '../src/retirarAcentuacao.js'
|
|
6
5
|
|
|
7
6
|
function testFormatFileSize() {
|
|
@@ -87,7 +86,6 @@ console.log('')
|
|
|
87
86
|
console.group('updateDotEnv, updateVersionDate, retirarAcentuação')
|
|
88
87
|
|
|
89
88
|
updateDotEnv(fs, true)
|
|
90
|
-
updateVersionDate(fs)
|
|
91
89
|
console.log('')
|
|
92
90
|
|
|
93
91
|
console.log(
|
|
@@ -103,9 +101,9 @@ arq = '.env.local'
|
|
|
103
101
|
console.log('Arquivo existe?', arq, jc.fileExists(arq))
|
|
104
102
|
|
|
105
103
|
console.log('')
|
|
106
|
-
updateDotEnvKey(fs)
|
|
107
|
-
updateDotEnvKey(fs,
|
|
108
|
-
updateDotEnvKey(fs,
|
|
104
|
+
updateDotEnvKey(fs, true)
|
|
105
|
+
updateDotEnvKey(fs, false, 'VITE_VERSION', '.env.local')
|
|
106
|
+
updateDotEnvKey(fs, true, 'VITE_VDATE', '.env.local', true)
|
|
109
107
|
|
|
110
108
|
console.log('')
|
|
111
109
|
console.groupEnd()
|
package/src/updateVersionDate.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs'
|
|
2
|
-
|
|
3
|
-
const cFileEncoded = 'utf-8'
|
|
4
|
-
const cFileEnvLocal = '.env.local'
|
|
5
|
-
const cKeyVersionDate = 'VITE_VDATE'
|
|
6
|
-
|
|
7
|
-
export function updateVersionDate(fs, filename = cFileEnvLocal) {
|
|
8
|
-
try {
|
|
9
|
-
let content = fs
|
|
10
|
-
.readFileSync(cFileEnvLocal, cFileEncoded)
|
|
11
|
-
.split('\r\n')
|
|
12
|
-
.map((line) => {
|
|
13
|
-
let [key, value] = line.split('=')
|
|
14
|
-
if (key == cKeyVersionDate) {
|
|
15
|
-
value = new Date().toLocaleString()
|
|
16
|
-
let [data, hora] = value.split(', ')
|
|
17
|
-
let [, mes, ano] = data.split('/')
|
|
18
|
-
let [hour, minut] = hora.split(':')
|
|
19
|
-
line = `${key}=${ano}.${mes} (${hour}.${minut})`
|
|
20
|
-
console.log('"Versão Data" atualizada:', line)
|
|
21
|
-
}
|
|
22
|
-
return line
|
|
23
|
-
})
|
|
24
|
-
.join('\r\n')
|
|
25
|
-
fs.writeFileSync(cFileEnvLocal, content, cFileEncoded)
|
|
26
|
-
} catch (error) {
|
|
27
|
-
console.log('updateVersionDate:', `Arquivo "${filename}" não existe!`)
|
|
28
|
-
}
|
|
29
|
-
}
|