Travis CI 在使用 DefinitelyTyped/tsd 时抛出状态码 403

Travis CI throws status code 403 when using DefinitelyTyped/tsd

当使用 Travis CI 构建项目时,我的安装命令之一(在 .travis.yml abort due to status code 403 中定义:

tsd reinstall
-> running reinstall
-> an error occured!
unexpected status code: 403 on: https://api.github.com/repos/borisyankov/DefinitelyTyped/branches/master
Error: unexpected status code: 403 on: https://api.github.com/repos/borisyankov/DefinitelyTyped/branches/master
    at Request.<anonymous> (/home/travis/.nvm/versions/node/v0.12.4/lib/node_modules/tsd/build/http/CacheStreamLoader.js:158:28)
    at Request.emit (events.js:107:17)
    at Request.onRequestResponse (/home/travis/.nvm/versions/node/v0.12.4/lib/node_modules/tsd/node_modules/request/request.js:1156:10)
    at ClientRequest.emit (events.js:107:17)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:426:21)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:111:23)
    at TLSSocket.socketOnData (_http_client.js:317:20)
    at TLSSocket.emit (events.js:107:17)
    at readableAddChunk (_stream_readable.js:163:16)
    at TLSSocket.Readable.push (_stream_readable.js:126:10)
[...]
The command "tsd reinstall" failed and exited with 1 during .

当从我的本地机器调用 github api url 时,我得到了正常响应。所以它必须介于 travis 和 github api.

之间

按照 Blake Embrey, whenever using tsd anywhere but your local machine, we should use a .tsdrc where we add a Github API token (or use an env var TSD_GITHUB_TOKEN which would be wiser for security reasons - on Travis you can encrypt 令牌的指示)。

关于如何创建令牌的说明也可以在 DefinitelyTyped 回购页面上找到,那里有所有解释。