jcinfo-utils 1.0.21 → 1.0.22
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/formatFileSize.js +8 -0
- package/index.d.ts +8 -4
- package/index.js +5 -0
- package/package.json +1 -1
- package/testar.js +9 -0
- package/updateDotEnv.js +23 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function formatFileSize(bytes, decimalPoint) {
|
|
2
|
+
if (bytes == 0) return '0 Bytes'
|
|
3
|
+
var k = 1000,
|
|
4
|
+
dm = decimalPoint || 2,
|
|
5
|
+
sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
|
|
6
|
+
i = Math.floor(Math.log(bytes) / Math.log(k))
|
|
7
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]
|
|
8
|
+
}
|
package/index.d.ts
CHANGED
|
@@ -10,10 +10,14 @@ export function isDarkMode(): boolean
|
|
|
10
10
|
|
|
11
11
|
export function colorGain(hex: string, gain: number): string
|
|
12
12
|
|
|
13
|
-
export function trunc(valor
|
|
13
|
+
export function trunc(valor?: number, decimais?: number): number
|
|
14
14
|
|
|
15
|
-
export function random(max
|
|
15
|
+
export function random(max?: number): number
|
|
16
16
|
|
|
17
|
-
export function getHash(value
|
|
17
|
+
export function getHash(value?: string): string
|
|
18
18
|
|
|
19
|
-
export function scrollToTop(smooth
|
|
19
|
+
export function scrollToTop(smooth?: boolean): void
|
|
20
|
+
|
|
21
|
+
export function formatFileSize(bytes: number, decimalPoint: number): string
|
|
22
|
+
|
|
23
|
+
export function updateDotEnv(): void
|
package/index.js
CHANGED
|
@@ -10,6 +10,9 @@ import {
|
|
|
10
10
|
getMonthName,
|
|
11
11
|
} from './dates.js'
|
|
12
12
|
|
|
13
|
+
import { updateDotEnv } from './updateDotEnv.js'
|
|
14
|
+
import { formatFileSize } from './formatFileSize.js'
|
|
15
|
+
|
|
13
16
|
// ===================================================== LOGS
|
|
14
17
|
|
|
15
18
|
function addLog({ ...args }) {
|
|
@@ -189,4 +192,6 @@ export {
|
|
|
189
192
|
random,
|
|
190
193
|
trunc,
|
|
191
194
|
scrollToTop,
|
|
195
|
+
updateDotEnv,
|
|
196
|
+
formatFileSize,
|
|
192
197
|
}
|
package/package.json
CHANGED
package/testar.js
CHANGED
package/updateDotEnv.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
|
|
3
|
+
export function updateDotEnv() {
|
|
4
|
+
const keys = ['VITE_VERSION', 'REACT_APP_VERSION']
|
|
5
|
+
let content = fs.readFileSync('.env', 'utf8')
|
|
6
|
+
content = content
|
|
7
|
+
.split('\r\n')
|
|
8
|
+
.map((line) => {
|
|
9
|
+
let [key, value] = line.split('=')
|
|
10
|
+
if (keys.includes(key) && value) {
|
|
11
|
+
let version = value.split(' ')
|
|
12
|
+
let date = new Date()
|
|
13
|
+
let mes = String(date.getMonth() + 1)
|
|
14
|
+
let dia = String(date.getDate()).padStart(2, '0')
|
|
15
|
+
version = version[0] + ` (${mes}${dia})`
|
|
16
|
+
line = key + '=' + version
|
|
17
|
+
console.log('Versão atualizada para:', version)
|
|
18
|
+
}
|
|
19
|
+
return line
|
|
20
|
+
})
|
|
21
|
+
.join('\r\n')
|
|
22
|
+
fs.writeFileSync('.env', content, 'utf8')
|
|
23
|
+
}
|