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

@danielhaim/analyzeredirects

v1.0.4

Published

A tool to analyze and resolve conflicting URL redirects.

Downloads

146

Readme

Analyze Redirects

npm version Downloads GitHub

Demo Image

Overview

AnalyzeRedirects is a tool for analyzing URL redirects, identifying duplicates and conflicts, and generating .htaccess or .nginx style redirect rules.

Installation

Install AnalyzeRedirects using NPM:

npm i @danielhaim/analyzeredirects
  1. Link the Package Locally If you're working on the project locally and want to test your changes in your environment, use npm link:
npm link
  1. Linking in another project If you want to link this package into another project for testing or development, you can use this command inside the target project:
npm link @danielhaim/analyzeredirects

API Documentation

Once installed, you can use the command-line interface (CLI) to analyze your redirects and generate .txt files with the rules. Here's how to use it:

# If you have linked the package locally:
analyze-redirects --file <path_to_your_json_file> [options]

# If you installed the package normally:
npx analyze-redirects --file <path_to_your_json_file> [options]

Options:

  • -f, --file <path>: Path to JSON file with Old_URL and New_URL.
  • -o, --output <path>: Path to output the generated redirects file (default: ./dist/redirects.txt).
  • -a, --analyze-only: Only analyze redirects without generating output file.
  • -s, --silent: Suppress console output.
  • -h, --help: Display this help message.

Examples:

To analyze redirects and see the output in the console:

analyze-redirects --file ./__test__/demo-urls.json

To generate a file with the redirects:

analyze-redirects -f ./__test__/demo-urls.json -o ./output-redirects.txt

To analyze without generating a file:

analyze-redirects --file ./__test__/demo-urls.json --analyze-only

Adding a New URL Set

To add a new set of redirects, create a urls.json file in the ./sets/ directory with the following structure:

[
    { "Old_URL": "/old-page", "New_URL": "https://example.com/new-page" },
    { "Old_URL": "/another-page", "New_URL": "https://example.com/another-page" }
]

Once your set is added, you can analyze it using the CLI by specifying the path to your urls.json file.

License

This software is released under the MIT License

Report Issues or Request a Feature

If you encounter any issues or have suggestions for improvements, please feel free to report them. Your feedback is invaluable in enhancing this software.

Folder Structure

Here's an overview of the project's folder structure:

.
├── LICENSE
├── README.md
├── __test__
│   ├── analyzeredirects.test.js
│   ├── demo-redirects.txt
│   ├── demo-urls.json
│   └── expected-demo-redirects.txt
├── babel.config.js
├── cli.js
├── index.js
├── jest.config.mjs
├── package-lock.json
├── package.json
├── sets
│   └── urls.json
└── src
    ├── index.js
    └── util.analyze.js
  • __test__: Contains test files and sample data.
  • cli.js: The CLI entry point.
  • sets/urls.json: Default set for analysis, you can add your own sets here.
  • src/: Source code for redirect analysis and utilities.