npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

karlamac-md-links

v0.2.0

Published

Library to search for links, verify their validity and obtain statistics of .md files

Downloads

3

Readme

Markdown Links

Index


1. Introduction

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

These Markdown files often contain links that are sometimes broken or no longer valid, which greatly diminishes the value of the shared information.

Within an open-source community, we have been tasked with creating a tool using Node.js that reads and analyzes Markdown files, verifies the links they contain, and reports some statistics.

2. Project Summary

This project is a command-line tool (CLI) / JavaScript library that is executed using Node.js.

Node.js is a runtime environment for JavaScript built on the Chrome V8 JavaScript engine. It allows running JavaScript in the operating system environment, either on a machine or a server, opening the doors to interact with the system itself, files, networks, etc.

3. General Considerations

  • This project was completed individually.

  • The estimated time range to complete the project was 4 to 5 Sprints, and it was completed in 2.5 Sprints.

  • Compatibility was verified in the Linux, Mac and Windows execution environments.

  • The library and the executable script (command-line tool - CLI) are implemented in JavaScript to be run with Node.js. External libraries like path, FS, Axios, JSDOM, chalk, and marked were used.

  • The module is installable via npm install karlamacedo-md-links.

  • For this project, the use of async/await was not allowed.

  • The asynchronous version was used to read files.

  • ES Modules (import/export) were used with the help of babel.

  • To reduce the complexity of the recursive algorithm, the synchronous version of the function to read directories, readdirSync, was used.

4. Usage Instructions

Installation

To install the library, run the following command in the terminal:

npm install karlamacedo-md-links

Usage in the Terminal

To use the library through the terminal, use the following command:

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

Replace <path-to-file> with the path (absolute or relative) of the file or directory you want to process. Replace [options] with the action you want to perform:

Options

If no options are provided (npx karlamacedo-md-links <path-to-file>), it will return the .md files found and the links contained within each file. If no links or files are found, a notification will be displayed.

response

If only the --valid option is provided (npx karlamacedo-md-links <path-to-file> --valid), it will return the .md files found, the links contained within each file, and validate them through an HTTP request. It will also return their status codes, displaying an "OK ✔" notification for successful requests and a "Fail ✘" notification otherwise. If no links or files are found, a notification will be displayed.

response

If only the --stats option is provided (npx karlamacedo-md-links <path-to-file> --stats), it will return the .md files found and the links contained within each file. If no links or files are found, a notification will be displayed. Additionally, it will display a statistics section showing the total number of links found in the search and how many of them are unique.

response

If the --valid and --stats options are provided (npx karlamacedo-md-links <path-to-file> --valid --stats), it will return the .md files found, the links contained within each file, validate them through an HTTP request, and display their status codes with an "OK ✔" notification for successful requests and a "Fail ✘" notification otherwise. If no links or files are found, a notification will be displayed. Additionally, it will display a statistics section showing the total number of links found in the search, how many of them are unique, how many were successful in the HTTP request, and how many were not.

response

Usage as an API

To use the library as an API (Application Programming Interface), follow these steps:

  • Fork the GitHub repository.

  • Open your terminal and navigate to the location where you want to save the project using the cd command.

  • Run the following command:

git clone https://github.com/karlamacedoedo/DEV007-md-links.git
  • Open the project folder in your preferred code editor.

  • Open the terminal and execute the project using the following commands, depending on the desired action:

Opciones

If no options are provided (node cli.js <path-to-file>), it will return the .md files found and the links contained within each file. If no links or files are found, a notification will be displayed.

response

If only the --valid option is provided (node cli.js <path-to-file> --valid), it will return the .md files found, the links contained within each file, and validate them through an HTTP request. It will also return their status codes, displaying an "OK ✔" notification for successful requests and a "Fail ✘" notification otherwise. If no links or files are found, a notification will be displayed.

response

If only the --stats option is provided (node cli.js <path-to-file> --stats), it will return the .md files found and the links contained within each file. If no links or files are found, a notification will be displayed. Additionally, it will display a statistics section showing the total number of links found in the search and how many of them are unique.

response

If the --valid and --stats options are provided (node cli.js <path-to-file> --valid --stats), it will return the .md files found, the links contained within each file, validate them through an HTTP request, and display their status codes with an "OK ✔" notification for successful requests and a "Fail ✘" notification otherwise. If no links or files are found, a notification will be displayed. Additionally, it will display a statistics section showing the total number of links found in the search, how many of them are unique, how many had successful HTTP requests, and how many had failed requests.

response

5. Project Planning

This project was planned using GitHub Projects, creating issues, labels, and milestones.

planning

A flowchart was also previously created as a guide for the development of the logic of the project.

diagrama

6. Learning Objectives

JavaScript

  • [ ] Compatibility Testing in Multiple Execution Environments

  • [✓] Use of linter (ESLint)

  • [✓] Use of descriptive identifiers (Naming and Semantics)

Node.js

Version Control (Git y GitHub)

  • [✓] Git: Installation and Configuration

  • [✓] Git: Version Control with Git (init, clone, add, commit, status, push, pull, remote)

  • [✓] Git: Integration of Changes Between Branches (branch, checkout, fetch, merge, reset, rebase, tag)

  • [✓] GitHub: Account Creation and Repositories, SSH Key Configuration

  • [✓] GitHub: Collaboration on Github (branches | forks | pull requests | code review | tags)

  • [✓] GitHub: Organization on Github (projects | issues | labels | milestones | releases)

HTTP