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 CHANGED
@@ -1,4 +1,4 @@
1
1
  # apenas para testar a função updateDotEnv() & updateDotEnvKey()
2
2
  # REACT_APP_VERSION=1.0 (1116.1)
3
- VITE_VERSION= (1116.13)
3
+ VITE_VERSION= (1116.25)
4
4
  VITE_VDATE=
package/index.d.ts CHANGED
@@ -72,9 +72,9 @@ export function updateDotEnv(
72
72
 
73
73
  export function updateDotEnvKey(
74
74
  fs: Object,
75
- filename?: string,
76
- key?: string,
77
75
  autoInc?: boolean,
76
+ key?: string,
77
+ filename?: string,
78
78
  updateWithDate?: boolean,
79
79
  ): void
80
80
 
package/index.js CHANGED
@@ -9,9 +9,12 @@ import {
9
9
  getLastDay,
10
10
  getMonthName,
11
11
  } from './src/dates.js'
12
- import { updateDotEnv, updateDotEnvKey } from './src/updateDotEnv.js'
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jcinfo-utils",
3
- "version": "1.0.35",
3
+ "version": "1.0.36",
4
4
  "description": "Pacote de funções utilitárias",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -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, '.env.local', 'VITE_VERSION', true)
108
- updateDotEnvKey(fs, '.env.local', 'VITE_VDATE', true, true)
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()
@@ -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
- }