jcinfo-utils 1.0.31 → 1.0.33

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 CHANGED
@@ -69,3 +69,7 @@ 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
package/index.js CHANGED
@@ -11,6 +11,8 @@ 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'
14
16
 
15
17
  // ===================================================== LOGS
16
18
 
@@ -175,10 +177,17 @@ function scrollToTop(smooth = false) {
175
177
  let el = document?.querySelector('main')
176
178
  if (!el) {
177
179
  el = document.body
180
+ if (process.env.NODE_ENV == 'development') {
181
+ console.log('scrollToTop: body')
182
+ }
178
183
  }
179
184
  if (el) {
185
+ if (process.env.NODE_ENV == 'development') {
186
+ console.log('scrollToTop: main')
187
+ }
180
188
  el.scrollTo({
181
189
  top: 0,
190
+ left: 0,
182
191
  behavior: smooth ? 'smooth' : 'auto',
183
192
  })
184
193
  }
@@ -207,6 +216,8 @@ export {
207
216
  random,
208
217
  trunc,
209
218
  scrollToTop,
210
- updateDotEnv,
211
219
  formatFileSize,
220
+ updateDotEnv,
221
+ updateVersionDate,
222
+ retirarAcentuacao,
212
223
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jcinfo-utils",
3
- "version": "1.0.31",
3
+ "version": "1.0.33",
4
4
  "description": "Pacote de funções utilitárias",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -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/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,14 @@ 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
+ console.groupEnd()