#!/bin/bash

NPM=/usr/bin/npm

case "$1" in
  i|install|show|view|up|update|outdated|init|create)
    $NPM --registry=https://registry.npmmirror.com "$@"
    ;;

  sync)
    curl -I "https://registry-direct.npmmirror.com/$2/sync?sync_upstream=true"   -X 'PUT'   -H 'authority: registry-direct.npmmirror.com'   -H 'accept: application/json, text/javascript, */*; q=0.01'   -H 'accept-language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7'   -H 'content-length: 0'   -H 'origin: https://npmmirror.com'   -H 'referer: https://npmmirror.com/'  -H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36'   --compressed
    echo "同步 $2 成功~~"
    echo ""
    ;;
  origin)
    $NPM search $2
    ;;
  *)
    $NPM "$@"
    ;;
esac