1.0.1 • Published 3 years ago

emae--md-links v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

Índice


1. 💡Preamble

Markdown is a very popular lightweight markup language among developers. It is used in many platforms that handle plain text (GitHub, forums, blogs, ...), and it is very common to find several files in that format in any type of repository (starting with the traditional README.md).

These Markdown files usually contain links that are often broken or no longer valid and that greatly damages the value of the information that you want to share.

2. ⬇️Install

npm install -g emae--md-links

3. 🔍Usage

After installing globally (or linking with npm link) you should have the md-links command available in your terminal

Usage: md-links <path-to-file> [options]

Commands:
  --v, --validate  Show validate links, makes an HTTP request to find out if the link works or not
  --s, --stats     Show basic statistics about links
  
Global options:
  -V, --version    output the version number
  -h, --help       display help for command

Examples

Input absolute or relative path to file or directory.Output: file, href, text

Choose a validate option. Output: file, href, status, message, text

Choose a stats option. Output: Total, Unique or stats and validate options Output: Total, Unique, Broken

4. ⚠️Considerations

This package does not consider the analysis of the node_modules directory, because a project can have several libraries installed, so only markdown files created by the user are considered.

If the entered path has blank spaces, place it in quotation marks to avoid being considered an error.

Example: Entering path D:\14-Java script\LIM013-fe-md-links

5. </>Pseudocode

API mdLinks(path, options)

Arguments
  • path: Absolute or relative path to the file or directory. If the past path is relative, should resolve to relative to the directory from which it is invoked node - current working directory).
  • options: An object with the following properties:
    • validate: Boolean that determines if you want to validate the links found.
Return value

The function must return a promise (Promise) that resolves to an array (Array) of objects (Object), where each object represents a link and contains the following properties:

  • href: URL found.
  • text: Text that appeared inside the link (<a>).
  • file: Path of the file where the link was found.
Inicio
-Ingresar path
-Leer path
-Si (path.isAbsolute) entonces retornar path
   funcion getMdFiles
   input: path absoluto
   lista[mdFiles] = [] vacia //Definimos el array para enlistar markdown files
   //recursion
    Si (es directorio && no es node_modules) entonces
     Leer directorio 
     paraCada file de directorio
      Retornar lista[mdFiles] = file + getMdFiles(path/file)
     fin paraCada
     
    //base case
    De lo contrario Si (es file) entonces 
      Si (extensión .md) entonces
       Añadir file a lista[mdFiles]
       Retornar lista[mdFiles]
      De lo contrario
       Escribir("No existen archivos markdown en este path")
      Fin Si
    
    Fin Si
    Fin funcion
   
-De lo contrario convertir path a absoluta (path.resolve)
-Fin Si

//Get links
funcion getLinks
 input: path absoluto
 lista[mdLinks] = [] vacia //Definimos el array para enlistar links of markdown files
 
 lista[mdFiles] = getMdFiles(path)
  paraCada markdown-file de lista[mdFiles]
    Leer file
    Convertir a HTML //marked module
    Seleccionar todos los anchor, propiedad href con protocolo 'http'
   -Si(existe anchor) entonces
     paraCada anchor
      Si(validate.option == false) entonces
        Añadir objeto:{href, text, file}
        retornar lista[mdLinks]
      De lo contrario
        Hacer petición HTTP // fetch module
        Añadir propiedades: {status, message}
        retornar lista[mdLinks]
      Fin Si
     fin paraCada
   -De lo contrario
     Escribir ("No existen links en los archivos markdown de este path")
   -Fin Si
  fin paraCada
Fin funcion

CLI

The executable of our application must be able to be executed as follows through the terminal:

md-links <path-to-file> [options]

Módulo md-links <path-to-file> [options]
Pedir path
 Mostrar file, href, text
 Si(--validate) entonces
  Mostrar file, href, text, status, message
 De lo contrario Si(--stats) entonces
  Mostrar total, unique
 De lo contrario Si (--validate --stats) entonces
  Mostrar total, unique, broken
 Fin Si
Fin módulo

6. 👥Contributing

If someone wants to add or improve something, I invite you to collaborate directly in this repository: md-links

7. 👁️‍🗨️License

md-links is released under the MIT License.

8. Pistas, tips y lecturas complementarias

FAQs

¿Cómo hago para que mi módulo sea instalable desde GitHub?

Para que el módulo sea instalable desde GitHub solo tiene que:

  • Estar en un repo público de GitHub
  • Contener un package.json válido

Con el comando npm install githubname/reponame podemos instalar directamente desde GitHub. Ver docs oficiales de npm install acá.

Por ejemplo, el course-parser que usamos para la currícula no está publicado en el registro público de NPM, así que lo instalamos directamente desde GitHub con el comando npm install Laboratoria/course-parser.

Tutoriales / NodeSchool workshoppers

Otros recursos

9. Objetivos de aprendizaje

Diseñar tu propia librería es una experiencia fundamental para cualquier desarrollador porque que te obliga a pensar en la interfaz (API) de tus módulos y cómo será usado por otros developers. Debes tener especial consideración en peculiaridades del lenguaje, convenciones y buenas prácticas.

A continuación puedes ver los objetivos de aprendizaje de este proyecto:

JavaScript

  • Uso de condicionales (if-else | switch | operador ternario)
  • Uso de funciones (parámetros | argumentos | valor de retorno)
  • Manipular arrays (filter | map | sort | reduce)
  • Manipular objects (key | value)
  • Uso ES modules (import | export)
  • Diferenciar entre expression y statements.
  • Diferenciar entre tipos de datos atómicos y estructurados.
  • Uso de callbacks.
  • Consumo de Promesas.
  • Creación de Promesas.

Node

Testing

Estructura del código y guía de estilo

  • Organizar y dividir el código en módulos (Modularización)
  • Uso de identificadores descriptivos (Nomenclatura | Semántica)
  • Uso de linter (ESLINT)

Git y GitHub

  • Uso de comandos de git (add | commit | pull | status | push)
  • Manejo de repositorios de GitHub (clone | fork | gh-pages)
  • Colaboración en Github (branches | pull requests | |tags)
  • Organización en Github (projects | issues | labels | milestones)

HTTP

Fundamentos de programación