Commit 9090093001caf769c311839b060e5dab72548cae

Authored by ly525
1 parent 141036f7

chore: download dependencies

add mirror.sh to config mirror for yarn add npm
zh: 添加 mirror.sh 来快速配置 npm 和 yarn 镜像
Showing 1 changed file with 143 additions and 0 deletions
deploy/mirror.sh 0 → 100644
  1 +#!/bin/bash
  2 +
  3 +###
  4 + # @Author: ly525
  5 + # @Date: 2019-11-23 22:56:04
  6 + # @LastEditors: ly525
  7 + # @LastEditTime: 2019-11-23 23:04:08
  8 + # @FilePath: /luban-h5/helpers/mirror.sh
  9 + # @Github: https://github.com/ly525/luban-h5
  10 + # @Description:
  11 + #!zh: 设置 npm 和 yarn 的镜像源为淘宝镜像源
  12 + #!en: set yarn and npm mirror for chinese users
  13 + # @Copyright 2018 - 2019 luban-h5. All Rights Reserved
  14 + ###
  15 +
  16 +# ==========================================================
  17 +# NPM
  18 +# ==========================================================
  19 +
  20 +npm set registry "https://registry.npm.taobao.org"
  21 +npm set disturl "https://npm.taobao.org/dist"
  22 +
  23 +npm set chromedriver-cdnurl "https://npm.taobao.org/mirrors/chromedriver"
  24 +npm set couchbase-binary-host-mirror "https://npm.taobao.org/mirrors/couchbase/v{version}"
  25 +npm set debug-binary-host-mirror "https://npm.taobao.org/mirrors/node-inspector"
  26 +npm set electron-mirror "https://npm.taobao.org/mirrors/electron/"
  27 +npm set flow-bin-binary-host-mirror "https://npm.taobao.org/mirrors/flow/v"
  28 +npm set fse-binary-host-mirror "https://npm.taobao.org/mirrors/fsevents"
  29 +npm set fuse-bindings-binary-host-mirror "https://npm.taobao.org/mirrors/fuse-bindings/v{version}"
  30 +npm set git4win-mirror "https://npm.taobao.org/mirrors/git-for-windows"
  31 +npm set gl-binary-host-mirror "https://npm.taobao.org/mirrors/gl/v{version}"
  32 +npm set grpc-node-binary-host-mirror "https://npm.taobao.org/mirrors"
  33 +npm set hackrf-binary-host-mirror "https://npm.taobao.org/mirrors/hackrf/v{version}"
  34 +npm set leveldown-binary-host-mirror "https://npm.taobao.org/mirrors/leveldown/v{version}"
  35 +npm set leveldown-hyper-binary-host-mirror "https://npm.taobao.org/mirrors/leveldown-hyper/v{version}"
  36 +npm set mknod-binary-host-mirror "https://npm.taobao.org/mirrors/mknod/v{version}"
  37 +npm set node-sqlite3-binary-host-mirror "https://npm.taobao.org/mirrors"
  38 +npm set node-tk5-binary-host-mirror "https://npm.taobao.org/mirrors/node-tk5/v{version}"
  39 +npm set nodegit-binary-host-mirror "https://npm.taobao.org/mirrors/nodegit/v{version}/"
  40 +npm set operadriver-cdnurl "https://npm.taobao.org/mirrors/operadriver"
  41 +npm set phantomjs-cdnurl "https://npm.taobao.org/mirrors/phantomjs"
  42 +npm set profiler-binary-host-mirror "https://npm.taobao.org/mirrors/node-inspector/"
  43 +npm set puppeteer-download-host "https://npm.taobao.org/mirrors"
  44 +npm set python-mirror "https://npm.taobao.org/mirrors/python"
  45 +npm set rabin-binary-host-mirror "https://npm.taobao.org/mirrors/rabin/v{version}"
  46 +npm set sass-binary-site "https://npm.taobao.org/mirrors/node-sass"
  47 +npm set sodium-prebuilt-binary-host-mirror "https://npm.taobao.org/mirrors/sodium-prebuilt/v{version}"
  48 +npm set sqlite3-binary-site "https://npm.taobao.org/mirrors/sqlite3"
  49 +npm set utf-8-validate-binary-host-mirror "https://npm.taobao.org/mirrors/utf-8-validate/v{version}"
  50 +npm set utp-native-binary-host-mirror "https://npm.taobao.org/mirrors/utp-native/v{version}"
  51 +npm set zmq-prebuilt-binary-host-mirror "https://npm.taobao.org/mirrors/zmq-prebuilt/v{version}"
  52 +
  53 +
  54 +npm cache clean --force # clean npm cache
  55 +
  56 +# ==========================================================
  57 +# YARN
  58 +# ==========================================================
  59 +
  60 +yarn set registry "https://registry.npm.taobao.org"
  61 +yarn set disturl "https://npm.taobao.org/dist"
  62 +yarn set chromedriver-cdnurl "https://npm.taobao.org/mirrors/chromedriver"
  63 +yarn set couchbase-binary-host-mirror "https://npm.taobao.org/mirrors/couchbase/v{version}"
  64 +yarn set debug-binary-host-mirror "https://npm.taobao.org/mirrors/node-inspector"
  65 +yarn set electron-mirror "https://npm.taobao.org/mirrors/electron/"
  66 +yarn set flow-bin-binary-host-mirror "https://npm.taobao.org/mirrors/flow/v"
  67 +yarn set fse-binary-host-mirror "https://npm.taobao.org/mirrors/fsevents"
  68 +yarn set fuse-bindings-binary-host-mirror "https://npm.taobao.org/mirrors/fuse-bindings/v{version}"
  69 +yarn set git4win-mirror "https://npm.taobao.org/mirrors/git-for-windows"
  70 +yarn set gl-binary-host-mirror "https://npm.taobao.org/mirrors/gl/v{version}"
  71 +yarn set grpc-node-binary-host-mirror "https://npm.taobao.org/mirrors"
  72 +yarn set hackrf-binary-host-mirror "https://npm.taobao.org/mirrors/hackrf/v{version}"
  73 +yarn set leveldown-binary-host-mirror "https://npm.taobao.org/mirrors/leveldown/v{version}"
  74 +yarn set leveldown-hyper-binary-host-mirror "https://npm.taobao.org/mirrors/leveldown-hyper/v{version}"
  75 +yarn set mknod-binary-host-mirror "https://npm.taobao.org/mirrors/mknod/v{version}"
  76 +yarn set node-sqlite3-binary-host-mirror "https://npm.taobao.org/mirrors"
  77 +yarn set node-tk5-binary-host-mirror "https://npm.taobao.org/mirrors/node-tk5/v{version}"
  78 +yarn set nodegit-binary-host-mirror "https://npm.taobao.org/mirrors/nodegit/v{version}/"
  79 +yarn set operadriver-cdnurl "https://npm.taobao.org/mirrors/operadriver"
  80 +yarn set phantomjs-cdnurl "https://npm.taobao.org/mirrors/phantomjs"
  81 +yarn set profiler-binary-host-mirror "https://npm.taobao.org/mirrors/node-inspector/"
  82 +yarn set puppeteer-download-host "https://npm.taobao.org/mirrors"
  83 +yarn set python-mirror "https://npm.taobao.org/mirrors/python"
  84 +yarn set rabin-binary-host-mirror "https://npm.taobao.org/mirrors/rabin/v{version}"
  85 +yarn set sass-binary-site "https://npm.taobao.org/mirrors/node-sass"
  86 +yarn set sodium-prebuilt-binary-host-mirror "https://npm.taobao.org/mirrors/sodium-prebuilt/v{version}"
  87 +yarn set sqlite3-binary-site "https://npm.taobao.org/mirrors/sqlite3"
  88 +yarn set utf-8-validate-binary-host-mirror "https://npm.taobao.org/mirrors/utf-8-validate/v{version}"
  89 +yarn set utp-native-binary-host-mirror "https://npm.taobao.org/mirrors/utp-native/v{version}"
  90 +yarn set zmq-prebuilt-binary-host-mirror "https://npm.taobao.org/mirrors/zmq-prebuilt/v{version}"
  91 +
  92 +yarn cache clean # clean yarn cache
  93 +
  94 +
  95 +# ==========================================================
  96 +# Binaries those not provide api to  override download url
  97 +# ==========================================================
  98 +
  99 +# 另外下载慢,还有可能是因为 有些包没有提供 更改其二进制包下载地址的 API
  100 +# 没有办法配置 mirror,在国内下载就很慢了
  101 +
  102 +# 比如下面的几个:
  103 +# pngquant-bin
  104 +# mozjpeg-bin
  105 +# cwebp-bin
  106 +# optipng-bin
  107 +
  108 +
  109 +# 因此大家在下载之前,最好先ping 下其对应二进制包存储网站,最好能在hosts中做一下映射
  110 +# 比如 raw.githubusercontent.com 是多解析,解析到日本IP,可能访问不了。说不定手动配置host 到美国,就可以完成下载
  111 +# http://tool.chinaz.com/speedworld/raw.githubusercontent.com 在这里可以查看 raw.githubusercontent.com 的 DNS 检测结果
  112 +# 类似下面这样:
  113 +
  114 +# 151.101.200.133 raw.githubusercontent.com
  115 +# 52.217.40.140 github-cloud.s3.amazonaws.com
  116 +# 216.105.38.13 sourceforge.net
  117 +
  118 +# 相关 issue 和 链接
  119 +# https://github.com/imagemin/cwebp-bin/issues/34
  120 +# https://github.com/mapbox/node-sqlite3/issues/734
  121 +# https://github.com/mapbox/node-sqlite3/issues/816
  122 +
  123 +#cwebp-bin
  124 +#https://raw.githubusercontent.com/imagemin/cwebp-bin/v${pkg.version}/vendor/`
  125 +
  126 +#pngquant-bin
  127 +#https://github.com/imagemin/pngquant-bin/blob/master/lib/index.js#L6
  128 +#https://raw.githubusercontent.com/imagemin/pngquant-bin/v${pkg.version}/vendor/
  129 +
  130 +
  131 +#optipng-bin
  132 +#https://github.com/imagemin/optipng-bin/blob/master/lib/install.js#L17
  133 +#https://sourceforge.net/projects/optipng/files/OptiPNG/
  134 +
  135 +
  136 +#mozjpeg-bin
  137 +#https://github.com/imagemin/mozjpeg-bin/blob/master/lib/index.js#L6
  138 +#https://raw.githubusercontent.com/imagemin/mozjpeg-bin/v${pkg.version}/vendor/`
  139 +
  140 +#gifsicle
  141 +#https://github.com/imagemin/gifsicle-bin/blob/master/lib/index.js#L6
  142 +#https://raw.githubusercontent.com/imagemin/gifsicle-bin/v${pkg.version}/vendor/
  143 +
... ...