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

xwzs

v1.1.2

Published

用于切换npm镜像源, 使用xw命令

Downloads

10

Readme

切换 git 仓库源

功能模仿参考 nrm xmzs

安装命令

npm i xwzs -g (建议全局安装 -g)

安装后,请使用命令 xw

命令支持

  • xw use 使用 name 源
  • xw use 选择源
  • xw list/ls 列出所有的仓库源
  • xw current 展示当前仓库源

  • xw add 添加自定义源
  • xw rename/rn 重命名自定义源
  • xw del/delete/rm 删除自定义源

  • xw ping 查看源响应时间

内置仓库源

  • npm ---------- https://registry.npmjs.org/
  • yarn --------- https://registry.yarnpkg.com/
  • tencent ------ https://mirrors.cloud.tencent.com/npm/
  • cnpm --------- https://r.cnpmjs.org/
  • taobao ------- https://registry.npmmirror.com/
  • npmMirror ---- https://skimdb.npmjs.com/registry/

实现过程

  1. index.js 添加注释 ,bin 2.commander +process.argv 读取并解析命令行参数
  2. child_process exec 执行命令设置 git 仓库源
  3. inquirer 获取用户选择的仓库源进行设置

用到的库:commander inquirer child_process node-http-ping chalk ora

总结:

  • 配置 bin 命令:js 首行加注释 ** !#/usr/env/bin node **; 当运行自定义 bin 命令 xw 时,系统隐式运行 node
  • commander 配合 process.argv 去解析出命令行参数,定义指令 use、ls、add、current 等
  • inquirer 带来命令行交互,选择源
  • child_process 从代码里运行 npm 命令:npm get registry/npm config set registry <npm 源地址>
  • node-http-ping 查看源的响应时间
  • chalk 命令行文字颜色
  • ora 添加 loading 加载