jcinfo-utils 1.0.27 → 1.0.29
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 +5 -1
- package/package.json +1 -1
- package/src/updateDotEnv.js +12 -10
package/index.d.ts
CHANGED
|
@@ -64,4 +64,8 @@ export function scrollToTop(smooth?: boolean): void
|
|
|
64
64
|
|
|
65
65
|
export function formatFileSize(bytes: number, decimalPoint: number): string
|
|
66
66
|
|
|
67
|
-
export function updateDotEnv(
|
|
67
|
+
export function updateDotEnv(
|
|
68
|
+
fs: any,
|
|
69
|
+
incrementBuild?: boolean,
|
|
70
|
+
filename?: string,
|
|
71
|
+
): void
|
package/package.json
CHANGED
package/src/updateDotEnv.js
CHANGED
|
@@ -8,13 +8,13 @@ function generateBuildVersion() {
|
|
|
8
8
|
return mes + dia
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
function getContentFileInArray(fs) {
|
|
12
|
-
return fs.readFileSync(
|
|
11
|
+
function getContentFileInArray(fs, filename) {
|
|
12
|
+
return fs.readFileSync(filename, 'utf8').split('\r\n')
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
function saveContentArrayInFile(fs, arr) {
|
|
15
|
+
function saveContentArrayInFile(fs, arr, filename) {
|
|
16
16
|
arr = arr.join('\r\n')
|
|
17
|
-
fs.writeFileSync(
|
|
17
|
+
fs.writeFileSync(filename, arr, 'utf8')
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
function incrementBuildNumber(build, finalBuild) {
|
|
@@ -41,12 +41,12 @@ function incrementBuildNumber(build, finalBuild) {
|
|
|
41
41
|
return finalBuild
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
export function updateDotEnv(fs, incrementBuild = false) {
|
|
45
|
-
const
|
|
46
|
-
let content = getContentFileInArray(fs)
|
|
44
|
+
export function updateDotEnv(fs, incrementBuild = false, filename = '.env') {
|
|
45
|
+
const keys = ['VITE_VERSION', 'REACT_APP_VERSION']
|
|
46
|
+
let content = getContentFileInArray(fs, filename)
|
|
47
47
|
content = content.map((line) => {
|
|
48
48
|
let [key, value] = line.split('=')
|
|
49
|
-
if (
|
|
49
|
+
if (keys.includes(key) && value) {
|
|
50
50
|
let [version, build] = value.split(' ')
|
|
51
51
|
let finalBuild = generateBuildVersion()
|
|
52
52
|
if (incrementBuild) {
|
|
@@ -54,9 +54,11 @@ export function updateDotEnv(fs, incrementBuild = false) {
|
|
|
54
54
|
}
|
|
55
55
|
version = `${version} (${finalBuild})`
|
|
56
56
|
line = `${key}=${version}`
|
|
57
|
-
console.log('
|
|
57
|
+
console.log('')
|
|
58
|
+
console.log('Versão atualizada: ', version, 'no arquivo', filename)
|
|
59
|
+
console.log('')
|
|
58
60
|
}
|
|
59
61
|
return line
|
|
60
62
|
})
|
|
61
|
-
saveContentArrayInFile(fs, content)
|
|
63
|
+
saveContentArrayInFile(fs, content, filename)
|
|
62
64
|
}
|