mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-03-15 13:40:59 -05:00
Closes #785 Axios has a [known issue](https://github.com/axios/axios/issues/658) that causes requests to hang when accessing an HTTPS resource via a proxy served over HTTP. This changes out the axios dependency for the [request](https://github.com/request/request) library. In order to keep `async/await` conventions easy, I also dropped in the [request-promise-native](https://github.com/request/request-promise-native) dependency.
30 lines
971 B
JavaScript
30 lines
971 B
JavaScript
module.exports = async function getVersions () {
|
|
const current = require(`../../package.json`).version
|
|
let latest
|
|
if (process.env.VUE_CLI_LATEST_VERSION) {
|
|
// cached value
|
|
latest = process.env.VUE_CLI_LATEST_VERSION
|
|
} else if (process.env.VUE_CLI_TEST || process.env.VUE_CLI_DEBUG) {
|
|
// test/debug, use local version
|
|
latest = process.env.VUE_CLI_LATEST_VERSION = current
|
|
} else {
|
|
const request = require('./request')
|
|
const options = require('../options').loadOptions()
|
|
const registry = options.useTaobaoRegistry
|
|
? `https://registry.npm.taobao.org`
|
|
: `https://registry.npmjs.org`
|
|
|
|
const res = await request.get(`${registry}/vue-cli-version-marker/latest`)
|
|
if (res.statusCode === 200) {
|
|
latest = process.env.VUE_CLI_LATEST_VERSION = res.body.version
|
|
} else {
|
|
// fallback to local version
|
|
latest = process.env.VUE_CLI_LATEST_VERSION = current
|
|
}
|
|
}
|
|
return {
|
|
current,
|
|
latest
|
|
}
|
|
}
|