herramientaenvioestupendo 1.0.53 → 1.0.55

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/README.md CHANGED
@@ -14,7 +14,7 @@ Para instalar el aplicativo CLI, deben realizar el siguiente procedimiento :
14
14
  ```npm i -g herramientaenvioestupendo```
15
15
 
16
16
  - Luego de esto deben validar la version de la herramienta :
17
- ```estupendo --version```, si esta indica que es la 1.0.53 es la correcta.
17
+ ```estupendo --version```, si esta indica que es la 1.0.55 es la correcta.
18
18
 
19
19
  - Para conocer que opciones tienen de comandos solo deben ingresar en su CMD :
20
20
  ```estupendo --help```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "herramientaenvioestupendo",
3
- "version": "1.0.53",
3
+ "version": "1.0.55",
4
4
  "private": false,
5
5
  "description": "Proyecto para envio documentos masivos",
6
6
  "keywords": [],
package/src/index.js CHANGED
@@ -3,7 +3,7 @@ import { program } from "commander"
3
3
  import { sendTxt, sendXml, sendAttached, sendJson, requestDocumentRace } from "./services.js"
4
4
 
5
5
 
6
- program.name("estupendo").version("1.0.53")
6
+ program.name("estupendo").version("1.0.55")
7
7
 
8
8
  program.command("send_xml")
9
9
  .requiredOption("-d, --directory <char>", "Directorio donde se encuentran los documentos XML")
@@ -35,8 +35,8 @@ const requestGet = async (url, body, token) => {
35
35
  });
36
36
  return response.data;
37
37
  } catch (err) {
38
- console.error(token);
39
38
  console.error(body);
39
+ console.error(token);
40
40
  console.error("Error en requestGet:", err.message);
41
41
  throw err;
42
42
  }
package/src/services.js CHANGED
@@ -26,11 +26,13 @@ const sendXml = async (options) => {
26
26
  const pdfDir = path.join(process.cwd(), "pdfs");
27
27
  const xmlDir = path.join(process.cwd(), "xmls");
28
28
  const procesadosDir = path.join(process.cwd(), "procesados");
29
+ const logsDir = path.join(process.cwd(), "logs");
29
30
 
30
31
  // Crear carpetas si no existen
31
32
  if (!fs.existsSync(pdfDir)) fs.mkdirSync(pdfDir);
32
33
  if (!fs.existsSync(xmlDir)) fs.mkdirSync(xmlDir);
33
34
  if (!fs.existsSync(procesadosDir)) fs.mkdirSync(procesadosDir);
35
+ if (!fs.existsSync(logsDir)) fs.mkdirSync(logsDir);
34
36
  console.log("Procesando...")
35
37
  for (let archivo of txts) {
36
38
  const name = path.join(options.directory, archivo)
@@ -83,11 +85,18 @@ const sendXml = async (options) => {
83
85
 
84
86
 
85
87
  }
86
- const now = new Date();
87
- const fecha = now.toISOString().slice(0, 19).replace("T", "_").replace(/:/g, "-");
88
- const filenameDate = `Output_txt_${fecha}.json`;
89
- const ruta = path.join(process.cwd(), filenameDate)
90
- fs.appendFile(ruta, JSON.stringify(output, null, 4), () => { })
88
+ if (output.length > 0) {
89
+ const now = new Date();
90
+ const fecha = now.toISOString().slice(0, 19).replace("T", "_").replace(/:/g, "-");
91
+ const filenameDate = `Output_txt_${fecha}.json`;
92
+ const ruta = path.join(logsDir, filenameDate);
93
+
94
+ fs.appendFile(ruta, JSON.stringify(output, null, 4), () => {
95
+ console.log(`Log guardado en: ${ruta}`);
96
+ });
97
+ } else {
98
+ console.log("No hay datos para guardar en el log.");
99
+ }
91
100
  }
92
101
 
93
102
  // envios automaticos TXT
@@ -109,11 +118,13 @@ const sendTxt = async (options) => {
109
118
  const pdfDir = path.join(process.cwd(), "pdfs");
110
119
  const xmlDir = path.join(process.cwd(), "xmls");
111
120
  const procesadosDir = path.join(process.cwd(), "procesados");
121
+ const logsDir = path.join(process.cwd(), "logs");
112
122
 
113
123
  // Crear carpetas si no existen
114
124
  if (!fs.existsSync(pdfDir)) fs.mkdirSync(pdfDir);
115
125
  if (!fs.existsSync(xmlDir)) fs.mkdirSync(xmlDir);
116
126
  if (!fs.existsSync(procesadosDir)) fs.mkdirSync(procesadosDir);
127
+ if (!fs.existsSync(logsDir)) fs.mkdirSync(logsDir);
117
128
  console.log("Procesando...")
118
129
  for (let archivo of txts) {
119
130
  const name = path.join(options.directory, archivo)
@@ -166,11 +177,18 @@ const sendTxt = async (options) => {
166
177
 
167
178
 
168
179
  }
169
- const now = new Date();
170
- const fecha = now.toISOString().slice(0, 19).replace("T", "_").replace(/:/g, "-");
171
- const filenameDate = `Output_txt_${fecha}.json`;
172
- const ruta = path.join(process.cwd(), filenameDate)
173
- fs.appendFile(ruta, JSON.stringify(output, null, 4), () => { })
180
+ if (output.length > 0) {
181
+ const now = new Date();
182
+ const fecha = now.toISOString().slice(0, 19).replace("T", "_").replace(/:/g, "-");
183
+ const filenameDate = `Output_txt_${fecha}.json`;
184
+ const ruta = path.join(logsDir, filenameDate);
185
+
186
+ fs.appendFile(ruta, JSON.stringify(output, null, 4), () => {
187
+ console.log(`Log guardado en: ${ruta}`);
188
+ });
189
+ } else {
190
+ console.log("No hay datos para guardar en el log.");
191
+ }
174
192
 
175
193
  }
176
194
 
@@ -235,11 +253,13 @@ const sendJson = async (options) => {
235
253
  const pdfDir = path.join(process.cwd(), "pdfs");
236
254
  const xmlDir = path.join(process.cwd(), "xmls");
237
255
  const procesadosDir = path.join(process.cwd(), "procesados");
256
+ const logsDir = path.join(process.cwd(), "logs");
238
257
 
239
258
  // Crear carpetas si no existen
240
259
  if (!fs.existsSync(pdfDir)) fs.mkdirSync(pdfDir);
241
260
  if (!fs.existsSync(xmlDir)) fs.mkdirSync(xmlDir);
242
261
  if (!fs.existsSync(procesadosDir)) fs.mkdirSync(procesadosDir);
262
+ if (!fs.existsSync(logsDir)) fs.mkdirSync(logsDir);
243
263
  console.log("Procesando...")
244
264
  for (let archivo of txts) {
245
265
  const name = path.join(options.directory, archivo)
@@ -293,11 +313,18 @@ const sendJson = async (options) => {
293
313
 
294
314
 
295
315
  }
296
- const now = new Date();
297
- const fecha = now.toISOString().slice(0, 19).replace("T", "_").replace(/:/g, "-");
298
- const filenameDate = `Output_txt_${fecha}.json`;
299
- const ruta = path.join(process.cwd(), filenameDate)
300
- fs.appendFile(ruta, JSON.stringify(output, null, 4), () => { })
316
+ if (output.length > 0) {
317
+ const now = new Date();
318
+ const fecha = now.toISOString().slice(0, 19).replace("T", "_").replace(/:/g, "-");
319
+ const filenameDate = `Output_txt_${fecha}.json`;
320
+ const ruta = path.join(logsDir, filenameDate);
321
+
322
+ fs.appendFile(ruta, JSON.stringify(output, null, 4), () => {
323
+ console.log(`Log guardado en: ${ruta}`);
324
+ });
325
+ } else {
326
+ console.log("No hay datos para guardar en el log.");
327
+ }
301
328
  }
302
329
  //envio requestDocumentRace
303
330
  const requestDocumentRace = async (options) => {
@@ -324,10 +351,12 @@ const requestDocumentRace = async (options) => {
324
351
  const output = [];
325
352
  const pdfDir = path.join(process.cwd(), "pdfs");
326
353
  const xmlDir = path.join(process.cwd(), "xmls");
354
+ const logsDir = path.join(process.cwd(), "logs");
327
355
 
328
356
  // Crear carpetas si no existen
329
357
  if (!fs.existsSync(pdfDir)) fs.mkdirSync(pdfDir);
330
358
  if (!fs.existsSync(xmlDir)) fs.mkdirSync(xmlDir);
359
+ if (!fs.existsSync(logsDir)) fs.mkdirSync(logsDir);
331
360
 
332
361
  console.log("Procesando...")
333
362
 
@@ -396,11 +425,18 @@ const requestDocumentRace = async (options) => {
396
425
 
397
426
 
398
427
 
399
- const now = new Date();
400
- const fecha = now.toISOString().slice(0, 19).replace("T", "_").replace(/:/g, "-");
401
- const filenameDate = `Output_txt_${fecha}.json`;
402
- const ruta = path.join(process.cwd(), filenameDate)
403
- fs.appendFile(ruta, JSON.stringify(output, null, 4), () => { })
428
+ if (output.length > 0) {
429
+ const now = new Date();
430
+ const fecha = now.toISOString().slice(0, 19).replace("T", "_").replace(/:/g, "-");
431
+ const filenameDate = `Output_txt_${fecha}.json`;
432
+ const ruta = path.join(logsDir, filenameDate);
433
+
434
+ fs.appendFile(ruta, JSON.stringify(output, null, 4), () => {
435
+ console.log(`Log guardado en: ${ruta}`);
436
+ });
437
+ } else {
438
+ console.log("No hay datos para guardar en el log.");
439
+ }
404
440
  }
405
441
 
406
442
  export { sendTxt, sendXml, sendAttached, sendJson, requestDocumentRace }