Skip to content

Commit

Permalink
Upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Jul 5, 2022
1 parent 2300514 commit d4c2913
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 36 deletions.
33 changes: 17 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"funding": "https://github.com/sindresorhus/got?sponsor=1",
"type": "module",
"exports": "./dist/source/index.js",
"types": "./dist/source/index.d.ts",
"engines": {
"node": ">=14.16"
},
Expand Down Expand Up @@ -44,27 +45,27 @@
"ky"
],
"dependencies": {
"@sindresorhus/is": "^4.6.0",
"@sindresorhus/is": "^5.2.0",
"@szmarczak/http-timer": "^5.0.1",
"@types/cacheable-request": "^6.0.2",
"@types/responselike": "^1.0.0",
"cacheable-lookup": "^6.0.4",
"cacheable-request": "^7.0.2",
"decompress-response": "^6.0.0",
"form-data-encoder": "1.7.1",
"form-data-encoder": "^2.0.1",
"get-stream": "^6.0.1",
"http2-wrapper": "^2.1.10",
"lowercase-keys": "^3.0.0",
"p-cancelable": "^3.0.0",
"responselike": "^2.0.0"
},
"devDependencies": {
"@hapi/bourne": "^2.0.0",
"@hapi/bourne": "^3.0.0",
"@sindresorhus/tsconfig": "^2.0.0",
"@sinonjs/fake-timers": "^9.1.1",
"@types/benchmark": "^2.1.1",
"@types/express": "^4.17.13",
"@types/node": "^17.0.21",
"@types/node": "^18.0.1",
"@types/pem": "^1.9.6",
"@types/pify": "^5.0.1",
"@types/readable-stream": "^2.3.13",
Expand All @@ -73,7 +74,7 @@
"@types/sinonjs__fake-timers": "^8.1.1",
"@types/tough-cookie": "^4.0.1",
"ava": "^3.15.0",
"axios": "^0.26.1",
"axios": "^0.27.2",
"benchmark": "^2.1.4",
"bluebird": "^3.7.2",
"body-parser": "^1.19.2",
Expand All @@ -90,20 +91,19 @@
"nyc": "^15.1.0",
"p-event": "^5.0.1",
"pem": "^1.14.6",
"pify": "^5.0.0",
"readable-stream": "^3.6.0",
"pify": "^6.0.0",
"readable-stream": "^4.0.0",
"request": "^2.88.2",
"sinon": "^13.0.1",
"sinon": "^14.0.0",
"slow-stream": "0.0.4",
"tempy": "^2.0.0",
"tempy": "^3.0.0",
"then-busboy": "^5.1.1",
"to-readable-stream": "^3.0.0",
"tough-cookie": "^4.0.0",
"ts-node": "^10.7.0",
"typescript": "4.6.2",
"xo": "^0.48.0"
"ts-node": "^10.8.2",
"typescript": "^4.7.4",
"xo": "^0.50.0"
},
"types": "dist/source",
"sideEffects": false,
"ava": {
"files": [
Expand Down Expand Up @@ -140,9 +140,9 @@
],
"rules": {
"@typescript-eslint/no-empty-function": "off",
"node/no-deprecated-api": "off",
"node/prefer-global/url": "off",
"node/prefer-global/url-search-params": "off",
"n/no-deprecated-api": "off",
"n/prefer-global/url": "off",
"n/prefer-global/url-search-params": "off",
"@typescript-eslint/no-implicit-any-catch": "off",
"unicorn/prefer-node-protocol": "off",
"ava/assertion-arguments": "off",
Expand All @@ -151,6 +151,7 @@
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/await-thenable": "off",
"@typescript-eslint/no-redundant-type-constituents": "off",
"no-lone-blocks": "off",
"unicorn/no-await-expression-member": "off"
}
Expand Down
7 changes: 6 additions & 1 deletion source/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import CacheableRequest from 'cacheable-request';
import decompressResponse from 'decompress-response';
import is from '@sindresorhus/is';
import {buffer as getBuffer} from 'get-stream';
import {FormDataEncoder, isFormDataLike} from 'form-data-encoder';
import {FormDataEncoder, isFormData as isFormDataLike} from 'form-data-encoder';
import type {ClientRequestWithTimings, Timings, IncomingMessageWithTimings} from '@szmarczak/http-timer';
import type ResponseLike from 'responselike';
import getBodySize from './utils/get-body-size.js';
Expand Down Expand Up @@ -56,6 +56,8 @@ export type GotEventFunction<T> =
@example
```
import got from 'got';
got.stream('https://github.com')
.on('request', request => setTimeout(() => request.destroy(), 50));
```
Expand Down Expand Up @@ -88,6 +90,8 @@ export type GotEventFunction<T> =
@example
```
import got from 'got';
const response = await got('https://sindresorhus.com')
.on('downloadProgress', progress => {
// Report download progress
Expand Down Expand Up @@ -138,6 +142,7 @@ type OptionsType = ConstructorParameters<typeof Options>[1];
type DefaultsType = ConstructorParameters<typeof Options>[2];

export default class Request extends Duplex implements RequestEvents<Request> {
// @ts-expect-error - Ignoring for now.
override ['constructor']: typeof Request;

_noPipe?: boolean;
Expand Down
6 changes: 3 additions & 3 deletions source/core/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import is, {assert} from '@sindresorhus/is';
import lowercaseKeys from 'lowercase-keys';
import CacheableLookup from 'cacheable-lookup';
import http2wrapper, {ClientHttp2Session} from 'http2-wrapper';
import {isFormDataLike} from 'form-data-encoder';
import {isFormData} from 'form-data-encoder';
import type {FormDataLike} from 'form-data-encoder';
import type CacheableRequest from 'cacheable-request';
import type ResponseLike from 'responselike';
Expand All @@ -35,7 +35,7 @@ import type {Delays} from './timed-out.js';

type Promisable<T> = T | Promise<T>;

const [major, minor] = process.versions.node.split('.').map(v => Number(v)) as [number, number, number];
const [major, minor] = process.versions.node.split('.').map(Number) as [number, number, number];

export type DnsLookupIpVersion = undefined | 4 | 6;

Expand Down Expand Up @@ -1304,7 +1304,7 @@ export default class Options {
}

set body(value: string | Buffer | Readable | Generator | AsyncGenerator | FormDataLike | undefined) {
assert.any([is.string, is.buffer, is.nodeStream, is.generator, is.asyncGenerator, isFormDataLike, is.undefined], value);
assert.any([is.string, is.buffer, is.nodeStream, is.generator, is.asyncGenerator, isFormData, is.undefined], value);

if (is.nodeStream(value)) {
assert.truthy(value.readable);
Expand Down
2 changes: 1 addition & 1 deletion source/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export * from './core/response.js';
export type {default as Request} from './core/index.js';
export * from './core/index.js';
export * from './core/errors.js';
export {Delays} from './core/timed-out.js';
export type {Delays} from './core/timed-out.js';
export {default as calculateRetryDelay} from './core/calculate-retry-delay.js';
export * from './as-promise/types.js';
export * from './types.js';
Expand Down
8 changes: 8 additions & 0 deletions source/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ export interface GotPaginate {
@example
```
import got from 'got';
const countLimit = 10;
const pagination = got.paginate('https://api.github.com/repos/sindresorhus/got/commits', {
Expand All @@ -125,6 +127,8 @@ export interface GotPaginate {
@example
```
import got from 'got';
const countLimit = 10;
const results = await got.paginate.all('https://api.github.com/repos/sindresorhus/got/commits', {
Expand Down Expand Up @@ -219,6 +223,8 @@ export interface Got extends Record<HTTPAlias, GotRequestFunction>, GotRequestFu
@example
```
import got from 'got';
const countLimit = 10;
const pagination = got.paginate('https://api.github.com/repos/sindresorhus/got/commits', {
Expand Down Expand Up @@ -252,6 +258,8 @@ export interface Got extends Record<HTTPAlias, GotRequestFunction>, GotRequestFu
@example
```
import got from 'got';
const client = got.extend({
prefixUrl: 'https://example.com',
headers: {
Expand Down
3 changes: 2 additions & 1 deletion test/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ test('works', withServer, async (t, server) => {
response.end('not found');
});

t.is((await got.get(server.url)).body, 'ok');
const {body} = await got.get(server.url);
t.is(body, 'ok');

const error = await t.throwsAsync<HTTPError>(got.get(`${server.url}/404`), {instanceOf: HTTPError});
t.is(error.response.body, 'not found');
Expand Down
4 changes: 2 additions & 2 deletions test/helpers/with-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import http from 'http';
import {promisify} from 'util';
import {ExecutionContext, Macro} from 'ava'; // eslint-disable-line ava/use-test
import is from '@sindresorhus/is';
import tempy from 'tempy';
import {temporaryFile} from 'tempy';
import FakeTimers from '@sinonjs/fake-timers';
import got, {Got, ExtendOptions} from '../../source/index.js';
import createHttpsTestServer, {ExtendedHttpsTestServer, HttpsServerOptions} from './create-https-test-server.js';
Expand Down Expand Up @@ -108,7 +108,7 @@ export const withHttpsServer = generateHttpsHook;

// TODO: Remove this when `create-test-server` supports custom listen.
export const withSocketServer: Macro<[RunTestWithSocket]> = async (t, run) => {
const socketPath = tempy.file({extension: 'socket'});
const socketPath = temporaryFile({extension: 'socket'});

const server = http.createServer((request, response) => {
server.emit(request.url!, request, response);
Expand Down
2 changes: 1 addition & 1 deletion test/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ test('beforeRequest hook respect `url` option', withServer, async (t, server, go
hooks: {
beforeRequest: [
options => {
options.url = new URL(server.url + '/changed');
options.url = new URL(`${server.url}/changed`);
},
],
},
Expand Down
4 changes: 2 additions & 2 deletions test/parse-link-header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ test('works as expected', t => {
reference: '/TheBook/chapter2',
parameters: {
rel: '"previous"',
// eslint-disable-next-line @typescript-eslint/quotes
// eslint-disable-next-line @typescript-eslint/quotes, @typescript-eslint/naming-convention
'title*': `UTF-8'de'letztes%20Kapitel`,
},
},
{
reference: '/TheBook/chapter4',
parameters: {
rel: '"next"',
// eslint-disable-next-line @typescript-eslint/quotes
// eslint-disable-next-line @typescript-eslint/quotes, @typescript-eslint/naming-convention
'title*': `UTF-8'de'n%c3%a4chstes%20Kapitel`,
},
},
Expand Down
4 changes: 2 additions & 2 deletions test/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {pEvent} from 'p-event';
import {Handler} from 'express';
import {parse, Body, BodyEntryPath, BodyEntryRawValue, isBodyFile} from 'then-busboy';
import {FormData as FormDataNode, Blob, File} from 'formdata-node';
import {fileFromPath} from 'formdata-node/file-from-path';
import {fileFromPath} from 'formdata-node/file-from-path'; // eslint-disable-line n/file-extension-in-import
import getStream from 'get-stream';
import FormData from 'form-data';
import toReadableStream from 'to-readable-stream';
Expand Down Expand Up @@ -346,7 +346,7 @@ test('body - sends files with spec-compliant FormData', withServer, async (t, se
const fullPath = path.resolve('test/fixtures/ok');
const blobContent = 'Blob content';
const fileContent = 'File content';
const anotherFileContent = await fsPromises.readFile(fullPath, 'utf-8');
const anotherFileContent = await fsPromises.readFile(fullPath, 'utf8');
const expected = {
blob: blobContent,
file: fileContent,
Expand Down
4 changes: 2 additions & 2 deletions test/progress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import SlowStream from 'slow-stream';
import toReadableStream from 'to-readable-stream';
import getStream from 'get-stream';
import FormData from 'form-data';
import tempy from 'tempy';
import {temporaryFile} from 'tempy';
import is from '@sindresorhus/is';
import test, {ExecutionContext} from 'ava';
import {Handler} from 'express';
Expand Down Expand Up @@ -121,7 +121,7 @@ test('upload progress - file', withServer, async (t, server, got) => {
test('upload progress - file stream', withServer, async (t, server, got) => {
server.post('/', uploadEndpoint);

const path = tempy.file();
const path = temporaryFile();
fs.writeFileSync(path, file);

const {size} = await promisify(fs.stat)(path);
Expand Down
6 changes: 3 additions & 3 deletions test/redirects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ test('follows redirect', withServer, async (t, server, got) => {

const {body, redirectUrls} = await got('finite');
t.is(body, 'reached');
t.deepEqual(redirectUrls.map(x => String(x)), [`${server.url}/`]);
t.deepEqual(redirectUrls.map(String), [`${server.url}/`]);
});

test('follows 307, 308 redirect', withServer, async (t, server, got) => {
Expand Down Expand Up @@ -113,7 +113,7 @@ test('throws on endless redirects - default behavior', withServer, async (t, ser

const error = await t.throwsAsync<MaxRedirectsError>(got(''), {message: 'Redirected 10 times. Aborting.'});

t.deepEqual(error.response.redirectUrls.map(x => String(x)), Array.from({length: 10}).fill(`${server.url}/`));
t.deepEqual(error.response.redirectUrls.map(String), Array.from({length: 10}).fill(`${server.url}/`));
t.is(error.code, 'ERR_TOO_MANY_REDIRECTS');
});

Expand All @@ -127,7 +127,7 @@ test('custom `maxRedirects` option', withServer, async (t, server, got) => {

const error = await t.throwsAsync<MaxRedirectsError>(got('', {maxRedirects: 5}), {message: 'Redirected 5 times. Aborting.'});

t.deepEqual(error.response.redirectUrls.map(x => String(x)), Array.from({length: 5}).fill(`${server.url}/`));
t.deepEqual(error.response.redirectUrls.map(String), Array.from({length: 5}).fill(`${server.url}/`));
t.is(error.code, 'ERR_TOO_MANY_REDIRECTS');
});

Expand Down
10 changes: 8 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@
"es2020"
],
// TODO: Remove this at some point.
"noPropertyAccessFromIndexSignature": false
"noPropertyAccessFromIndexSignature": false,
"isolatedModules": true
},
"include": [
"source",
"test",
"benchmark"
]
],
"ts-node": {
"transpileOnly": true,
"files": true,
"experimentalResolver": true
}
}

0 comments on commit d4c2913

Please sign in to comment.