Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: Switching from Request package to Got #5849

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,17 @@
"execa": "^1.0.0",
"geckodriver": "^1.20.0",
"globby": "^9.2.0",
"got": "^11.6.2",
"graphql": "^14.6.0",
"http-server": "^0.12.3",
"inquirer": "^7.1.0",
"jest": "^24.9.0",
"lerna": "^3.22.0",
"lerna-changelog": "^0.8.3",
"lerna-changelog": "^1.0.1",
"lint-staged": "^9.5.0",
"memfs": "^3.2.0",
"minimist": "^1.2.5",
"prettier": ">= 1.13.0",
"request": "^2.88.2",
"request-promise-native": "^1.0.8",
"rimraf": "^3.0.2",
"semver": "^6.1.0",
"typescript": "~3.9.3",
Expand Down
17 changes: 5 additions & 12 deletions packages/@vue/cli-service/__tests__/proxy.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
jest.setTimeout(30000)

const request = require('request-promise-native')
const got = require('got')
const { defaultPreset } = require('@vue/cli/lib/options')
const create = require('@vue/cli-test-utils/createTestProject')
const serve = require('@vue/cli-test-utils/serveWithPuppeteer')
Expand Down Expand Up @@ -30,29 +30,22 @@ afterAll(() => {

let newId = 1
async function assertProxy (url, title) {
const res = await request({
url: `${url}posts/1`,
json: true
})
const res = await got(`${url}posts/1`).json()
expect(res.title).toBe(title)

// POST
newId++
await request({
await got({
url: `${url}posts`,
json: true,
method: 'POST',
body: {
json: {
id: newId,
title: 'new',
author: 'test'
}
})

const newPost = await request({
url: `${url}posts/${newId}`,
json: true
})
const newPost = await got(`${url}posts/${newId}`).json()
expect(newPost.title).toBe('new')
}

Expand Down
11 changes: 5 additions & 6 deletions packages/@vue/cli-shared-utils/lib/request.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
exports.request = {
get (uri, opts) {
get (url, opts) {
// lazy require
const request = require('util').promisify(require('request'))
const got = require('got')
const reqOpts = {
method: 'GET',
timeout: 30000,
resolveWithFullResponse: true,
json: true,
uri,
responseType: 'json',
url,
...opts
}

return request(reqOpts)
return got(reqOpts)
}
}
2 changes: 1 addition & 1 deletion packages/@vue/cli-shared-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
"@hapi/joi": "^15.0.1",
"chalk": "^2.4.2",
"execa": "^1.0.0",
"got": "^11.6.2",
"launch-editor": "^2.2.1",
"lru-cache": "^5.1.1",
"node-ipc": "^9.1.1",
"open": "^6.3.0",
"ora": "^3.4.0",
"read-pkg": "^5.1.1",
"request": "^2.88.2",
"semver": "^6.1.0",
"strip-ansi": "^6.0.0"
},
Expand Down
7 changes: 3 additions & 4 deletions scripts/checkLinks.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
require('events').defaultMaxListeners = 0
const path = require('path')
const fs = require('fs')
const request = require('request-promise-native')
const got = require('got')

const promises = []

async function checkLink (file, link, n) {
try {
const result = await request({
const result = await got({
method: 'HEAD',
uri: link,
resolveWithFullResponse: true
url: link
})
if (result.statusCode !== 200) {
throw new Error('error')
Expand Down
4 changes: 2 additions & 2 deletions scripts/syncDeps.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
const fs = require('fs')
const path = require('path')
const chalk = require('chalk')
const request = require('request-promise-native')
const got = require('got')
const semver = require('semver')
const globby = require('globby')
const { execSync } = require('child_process')
Expand All @@ -26,7 +26,7 @@ const getRemoteVersion = async (pkg) => {
}
let res
try {
res = await request(`http://registry.npmjs.org/${pkg}/latest`, { json: true })
res = await got(`http://registry.npmjs.org/${pkg}/latest`).json()
} catch (e) {
return
}
Expand Down