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

hostify

v0.3.0-beta.1

Published

CLI tool and utils for hosts files: /etc/hosts and C:\Windows\System32\drivers\etc\hosts

Downloads

6

Readme

Build Status Coverage Status NPM version js-standard-style

Hostify

Icon

Hostify is a module that help us to work with the hosts file of our operating system.

It supports both a CLI tool and a module you can use in your own project.

NOTE: library in progress. Please use with caution and report any issue on here: https://github.com/eridem/hostify/issues

CLI tool operations

# Usage
hostify [COMMAND] [OPTIONS]

# For help
hostify --help
hostify [COMMAND] --help

| Command | Description | Example |:-- |:-- |:-- | | list | Show all entries in the host file | hostify list | | list --ipFilterExp "REGEXP" | Show entries which IPs match with RegExp | hostify list --ipFilterExp ".*\.255" | | list --hostFilterExp "REGEXP" | Show entries which Host match with RegExp | hostify list --hostFilterExp ".*tracking.*" | | list --ipFilterExp "REGEXP" --hostFilterExp "REGEXP" | Show entries which IP and Host match with both each RegExp | hostify list --ipFilterExp "0.0.0.0" --hostFilterExp ".*tracking.*" | | add --ip "IP" --host "HOST" [--comment "COMMENT"] | Add a single entry to the hosts file | hostify add --ip "0.0.0.0" --host "tracking.localhost" --comment "Tracking entry" | | delete --ipFilterExp "REGEXP" [--what-if] | Delete entries which IPs match with RegExp | hostify delete --ipFilterExp "127.0.0.\d+" | | delete --hostFilterExp "REGEXP" [--what-if] | Delete entries which Host match with RegExp | hostify delete --hostFilterExp ".*project\.local" |

Special options

| Option | Description | Example |:-- |:-- |:-- | | --path | Specify path of another hosts file | hostify list --path ./my-hosts.txt |

Module interface

Import module with:

const hostify = require('hostify').operations

List

hostify.list(options): <Array>{ ip: string, host: string }`

Show entries in the host file.

| Option | Model | Default | |:-- |:-- |:-- | | filterIpFn | filterIpFn: (val: string) => boolean | (v) => true | | filterHostFn | filterHostFn: (val: string) => boolean | (v) => true | | path | path: string | OS hosts path |

const options = {
  filterIpFn: (val) => val.endsWith('.255'),       // Filter IPs
  filterHostFn: (val) => val.contains('tracking')  // Filter Hosts
  // path: './my-hosts-file.txt'                   // Hosts file
}

const entries = hostify.list(options)

entries.forEach(entry => console.log(entry.ip, entry.host, entry.comment))

Add

hostify.add(options): <Array>{ ip: string, host: string }

Add entries in the host file.

| Option | Model | Default | |:-- |:-- |:-- | | entries | <Array>{ ip: string, host: string, comment: string } | null | | path | path: string | OS hosts path |

const options = {
  entries: [                                       // Entries to add
    { ip: '0.0.0.0', host: 'ad.localhost' },
    { ip: '0.0.0.0', host: 'tracking.localhost', comment: 'Track entry' }
  ],
  // path: './my-hosts-file.txt'                   // Hosts file
}

const entries = hostify.add(options)

entries.forEach(entry => console.log(entry.ip, entry.host, entry.comment))

Delete

hostify.delete(options): <Array>{ ip: string, host: string }

Delete entries in the host file.

| Option | Model | Default | |:-- |:-- |:-- | | filterIpFn | filterIpFn: (val: string) => boolean | (v) => true | | filterHostFn | filterHostFn: (val: string) => boolean | (v) => true | | whatIf | whatIf: boolean | false | | path | path: string | OS hosts path |

const options = {
  filterIpFn: (val) => val.endsWith('.255'),       // Filter IPs
  filterHostFn: (val) => val.contains('tracking'), // Filter Hosts
  whatIf: true                                     // Do not execute delete operation, only obtain results
  // path: './my-hosts-file.txt'                   // Hosts file
}

const entries = hostify.delete(options)

entries.forEach(entry => console.log(entry.ip, entry.host, entry.comment))