jcinfo-utils 1.0.38 → 1.0.40
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 +10 -2
- package/index.js +10 -5
- package/package.json +2 -2
- package/src/updateDotEnv.js +10 -3
- package/src/utils.js +1 -4
- package/test/testar.js +16 -7
package/.env
CHANGED
package/index.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
export type JcinfoUtils = {
|
|
2
|
+
showLogs: boolean
|
|
3
|
+
}
|
|
4
|
+
|
|
1
5
|
export function getDateStr(data: Date): string
|
|
2
6
|
|
|
3
7
|
export function getDateTimeStr(data?: Date): string
|
|
@@ -65,7 +69,7 @@ export function scrollToTop(smooth?: boolean): void
|
|
|
65
69
|
export function formatFileSize(bytes: number, decimalPoint: number): string
|
|
66
70
|
|
|
67
71
|
export function updateDotEnv(
|
|
68
|
-
fs:
|
|
72
|
+
fs: Object,
|
|
69
73
|
incrementBuild?: boolean,
|
|
70
74
|
filename?: string,
|
|
71
75
|
): void
|
|
@@ -80,4 +84,8 @@ export function updateDotEnvKey(
|
|
|
80
84
|
|
|
81
85
|
export function retirarAcentuacao(value: string): string
|
|
82
86
|
|
|
83
|
-
export function fileExists(filename: string): boolean
|
|
87
|
+
export function fileExists(fs: Object, filename: string): boolean
|
|
88
|
+
|
|
89
|
+
export function updateVersionDate(fs: Object): void
|
|
90
|
+
|
|
91
|
+
export function updateVersionBuild(fs: Object, autoInc?: boolean): void
|
package/index.js
CHANGED
|
@@ -12,7 +12,8 @@ import {
|
|
|
12
12
|
import {
|
|
13
13
|
updateDotEnv,
|
|
14
14
|
updateDotEnvKey,
|
|
15
|
-
|
|
15
|
+
updateVersionBuild,
|
|
16
|
+
updateVersionDate,
|
|
16
17
|
} from './src/updateDotEnv.js'
|
|
17
18
|
import { formatFileSize } from './src/formatFileSize.js'
|
|
18
19
|
import { retirarAcentuacao } from './src/retirarAcentuacao.js'
|
|
@@ -20,6 +21,9 @@ import { fileExists } from './src/utils.js'
|
|
|
20
21
|
|
|
21
22
|
// ===================================================== CONFIGURAÇÕES
|
|
22
23
|
|
|
24
|
+
/**
|
|
25
|
+
* @type {import { JcinfoUtils } from "index";}
|
|
26
|
+
*/
|
|
23
27
|
const jcinfoUtils = {
|
|
24
28
|
showLogs: false,
|
|
25
29
|
}
|
|
@@ -193,7 +197,7 @@ function scrollToTop(smooth = false) {
|
|
|
193
197
|
if (el) {
|
|
194
198
|
el.scrollTo({ top: 0, left: 0, behavior: smooth ? 'smooth' : 'auto' })
|
|
195
199
|
if (jcinfoUtils.showLogs) {
|
|
196
|
-
console.
|
|
200
|
+
console.info(`scrollToTop: ${isMain ? 'main' : 'body'}`)
|
|
197
201
|
}
|
|
198
202
|
}
|
|
199
203
|
} catch (error) {
|
|
@@ -223,9 +227,10 @@ export {
|
|
|
223
227
|
trunc,
|
|
224
228
|
scrollToTop,
|
|
225
229
|
formatFileSize,
|
|
226
|
-
updateDotEnv,
|
|
227
|
-
updateDotEnvKey,
|
|
228
|
-
updateVersionDate, //por questão de compatibilidade
|
|
229
230
|
retirarAcentuacao,
|
|
230
231
|
fileExists,
|
|
232
|
+
updateDotEnv,
|
|
233
|
+
updateDotEnvKey,
|
|
234
|
+
updateVersionDate,
|
|
235
|
+
updateVersionBuild,
|
|
231
236
|
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jcinfo-utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.40",
|
|
4
4
|
"description": "Pacote de funções utilitárias",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"dev": "nodemon test/testar.js",
|
|
9
9
|
"test": "nodemon test/testar.js",
|
|
10
|
-
"
|
|
10
|
+
"p": "yarn publish --patch"
|
|
11
11
|
},
|
|
12
12
|
"keywords": [],
|
|
13
13
|
"author": "JC",
|
package/src/updateDotEnv.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
//import fs from 'node:fs'
|
|
2
1
|
import { getDateTimeStr } from '../index.js'
|
|
3
|
-
import { fileExists } from '
|
|
2
|
+
import { fileExists } from '../index.js'
|
|
4
3
|
|
|
5
4
|
function getContentFileInArray(fs, filename) {
|
|
6
5
|
return fs.readFileSync(filename, 'utf8').split('\r\n')
|
|
@@ -96,7 +95,7 @@ export function updateDotEnvKey(
|
|
|
96
95
|
)
|
|
97
96
|
}
|
|
98
97
|
|
|
99
|
-
if (fileExists(filename)) {
|
|
98
|
+
if (fileExists(fs, filename)) {
|
|
100
99
|
let content = fs
|
|
101
100
|
.readFileSync(filename, 'utf-8')
|
|
102
101
|
.split('\r\n')
|
|
@@ -115,3 +114,11 @@ export function updateDotEnvKey(
|
|
|
115
114
|
console.error('updateDotEnvKey:', `Arquivo "${filename}" não encontrado!`)
|
|
116
115
|
}
|
|
117
116
|
}
|
|
117
|
+
|
|
118
|
+
export function updateVersionDate(fs) {
|
|
119
|
+
updateDotEnvKey(fs, false, 'VITE_VDATE', '.env.local', true)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function updateVersionBuild(fs, autoInc = false) {
|
|
123
|
+
updateDotEnvKey(fs, autoInc, envKey, envProd, false)
|
|
124
|
+
}
|
package/src/utils.js
CHANGED
package/test/testar.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import * as jc from '../index.js'
|
|
2
2
|
import fs from 'node:fs'
|
|
3
|
-
import
|
|
3
|
+
import * as update from '../src/updateDotEnv.js'
|
|
4
4
|
import { retirarAcentuacao } from '../src/retirarAcentuacao.js'
|
|
5
5
|
|
|
6
|
+
jc.jcinfoUtils.showLogs = true
|
|
7
|
+
|
|
6
8
|
function testFormatFileSize() {
|
|
7
9
|
let content = fs.readFileSync('c:\\jcinfo\\fb3\\databases.conf')
|
|
8
10
|
// let content = fs.readFileSync('testar.js', 'utf8')
|
|
@@ -85,7 +87,7 @@ console.groupEnd()
|
|
|
85
87
|
console.log('')
|
|
86
88
|
console.group('updateDotEnv, updateVersionDate, retirarAcentuação')
|
|
87
89
|
|
|
88
|
-
updateDotEnv(fs, true)
|
|
90
|
+
update.updateDotEnv(fs, true)
|
|
89
91
|
console.log('')
|
|
90
92
|
|
|
91
93
|
console.log(
|
|
@@ -95,15 +97,22 @@ console.log(
|
|
|
95
97
|
|
|
96
98
|
let arq = '.env.production.local'
|
|
97
99
|
console.log('')
|
|
98
|
-
console.log('Arquivo existe?', arq, jc.fileExists(arq))
|
|
100
|
+
console.log('Arquivo existe?', arq, jc.fileExists(fs, arq))
|
|
99
101
|
|
|
100
102
|
arq = '.env.local'
|
|
101
|
-
console.log('Arquivo existe?', arq, jc.fileExists(arq))
|
|
103
|
+
console.log('Arquivo existe?', arq, jc.fileExists(fs, arq))
|
|
104
|
+
|
|
105
|
+
console.log('')
|
|
106
|
+
update.updateDotEnvKey(fs, true)
|
|
102
107
|
|
|
103
108
|
console.log('')
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
109
|
+
update.updateVersionBuild(fs, true)
|
|
110
|
+
update.updateVersionDate(fs)
|
|
111
|
+
|
|
112
|
+
console.log('')
|
|
113
|
+
jc.scrollToTop()
|
|
114
|
+
|
|
115
|
+
console.log('jcinfoUtils.showLogs', jc.jcinfoUtils.showLogs)
|
|
107
116
|
|
|
108
117
|
console.log('')
|
|
109
118
|
console.groupEnd()
|