Skip to content

Commit

Permalink
Merge pull request #20 from Alemapyapur/route
Browse files Browse the repository at this point in the history
Subiendo cambios finales
  • Loading branch information
Alemapyapur authored Sep 30, 2021
2 parents 6d0d87c + 00660a6 commit 169b272
Show file tree
Hide file tree
Showing 22 changed files with 479 additions and 727 deletions.
647 changes: 100 additions & 547 deletions README.md

Large diffs are not rendered by default.

86 changes: 86 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/usr/bin/env node
const { mdLinks } = require('./src/function-mdlinks.js');
const { uniqueLinks, brokenLinks, totalLinks } = require('./src/api.js')

// const arg = process.argv[2];
// Retorna un arr con los arg pasados a la terminal, 1 ejecutable node, 2 ruta del ejecutabl,3 args
const [, , ...argument] = process.argv;

// console.log(process.argv[0]); // node (length 1)
// console.log(process.argv[1]); // mdlinks (length 2)
// console.log(process.argv[2]); // path (length 3)
// console.log(process.argv[3]); // validate or stats (length 4)
// console.log(process.argv[4]); // stats or validate(length 5)
// console.log("*", process.argv.length); */

// * +----------------------------------------------------------------------------------------------------------------+
// * | OPTION STATS |
// * +----------------------------------------------------------------------------------------------------------------+

if (argument.length === 1) {
mdLinks(argument[0], { validate: false })
.then(resolve => {
resolve.map((objeto) => {
console.log(`${objeto.file} | ${objeto.text} | ${objeto.href}`);})
})
.catch(reject => console.log(reject));
}

if (argument.length === 2) {
switch (argument[1]) {
case '--validate':
mdLinks(argument[0], { validate: true })
// .then(resolve => {console.log(resolve)})
.then(resolve => {
resolve.map((objeto) => {
console.log(`
${objeto.file} | ${objeto.text} |
${objeto.href} | ${objeto.statusText} | ${objeto.message}`);
})
})
.catch(reject => console.log(reject));
break;

case '--stats':
mdLinks(argument[0], { validate: true })
.then(resolve => console.log(`${totalLinks(resolve)} \nUnique: ${uniqueLinks(resolve)}`))
.catch(reject => console.log(reject));
break;

case '--help':
console.log(`
+--------------------+--------------------------------------------------------+
| Comandos | Descripción |
+--------------------+--------------------------------------------------------+
| md-links ruta | Muestra la ruta, enlace y el texto |
+---------------------+-------------------------------------------------------+
| --stats | Muestra el los links totales y unicos |
+--------------------+--------------------------------------------------------+
| --validate | Muestra la ruta, el texto, enlace, status y el mensaje |
+--------------------+--------------------------------------------------------+
| --validate --stats | Muestra el total de enlaces unicos y rotos |
| --stats --validate | |
+---------------------+-------------------------------------------------------+
| --help | Muestra los comandos |
+--------------------+--------------------------------------------------------+
`)
break;

default: console.log('Comando no válido. Necesita ayuda ingrese --help');
break;
}
}


if (argument.length === 3) {
if (
(argument[1] === "--stats" && argument[2] === "--validate") ||
(argument[1] === "--validate" && argument[2] === "--stats")
) {
mdLinks(argument[0], { validate: true })
.then(resolve => console.log(`${totalLinks(resolve)} \nUnique: ${uniqueLinks(resolve)} ${brokenLinks(resolve)}`))
.catch(reject => console.log(reject));
} else {
console.log('Comando no válido. Necesita ayuda ingrese --help.');
}
}
1 change: 1 addition & 0 deletions not-found.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- [Google Broken](https://www.googlexx34.com)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "md-links-alemapyapur",
"version": "0.1.0",
"description": "- [1. Preámbulo](#1-preámbulo)\r - [2. Resumen del proyecto](#2-resumen-del-proyecto)\r - [3. Objetivos de aprendizaje](#3-objetivos-de-aprendizaje)\r - [4. Consideraciones generales](#4-consideraciones-generales)\r - [5. Criterios de aceptación mínimos del proyecto](#5-criterios-de-aceptación-mínimos-del-proyecto)\r - [6. Entregables](#6-entregables)\r - [7. Hacker edition](#7-hacker-edition)\r - [8. Pistas, tips y lecturas complementarias](#8-pistas-tips-y-lecturas-complementarias)\r - [9. Checklist](#9-checklist)\r - [10. Achicando el problema](#10-achicando-el-problema)",
"main": "index.js",
"main": "src/function-mdlinks.js",
"directories": {
"test": "test"
},
Expand Down
Loading

0 comments on commit 169b272

Please sign in to comment.