Skip to content

Commit 6ecda39

Browse files
committed
chore(deps): update superagent to 5.x
1 parent 5a47874 commit 6ecda39

5 files changed

Lines changed: 15 additions & 5 deletions

File tree

packages/ionic/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"split2": "^3.0.0",
6262
"ssh-config": "^1.1.1",
6363
"stream-combiner2": "^1.1.1",
64-
"superagent": "^4.1.0",
64+
"superagent": "^5.2.1",
6565
"superagent-proxy": "^2.0.0",
6666
"tar": "^4.3.0",
6767
"through2": "^3.0.0",

packages/ionic/src/definitions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,7 @@ export interface SSLConfig {
432432
}
433433

434434
export interface CreateRequestOptions {
435+
userAgent: string;
435436
ssl?: SSLConfig;
436437
proxy?: string;
437438
}

packages/ionic/src/lib/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ export class Config extends BaseConfig<ConfigFile> implements IConfig {
107107
const { c } = this;
108108

109109
return {
110+
userAgent: `node/superagent/Ionic CLI ${c.version}`,
110111
ssl: {
111112
cafile: c['ssl.cafile'],
112113
certfile: c['ssl.certfile'],

packages/ionic/src/lib/utils/http.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function getGlobalProxy(): { envvar: string; envval: string; } | undefined {
2020
}
2121
}
2222

23-
export async function createRequest(method: HttpMethod, url: string, { proxy, ssl }: CreateRequestOptions): Promise<{ req: SuperAgentRequest; }> {
23+
export async function createRequest(method: HttpMethod, url: string, { userAgent, proxy, ssl }: CreateRequestOptions): Promise<{ req: SuperAgentRequest; }> {
2424
const superagent = await import('superagent');
2525

2626
if (!proxy) {
@@ -33,14 +33,16 @@ export async function createRequest(method: HttpMethod, url: string, { proxy, ss
3333

3434
const req = superagent(method, url);
3535

36-
req.redirects(25);
36+
req
37+
.set('User-Agent', userAgent)
38+
.redirects(25);
3739

3840
if (proxy) {
3941
const superagentProxy = await import('superagent-proxy');
4042
superagentProxy(superagent);
4143

42-
if ((req as any).proxy) { // TODO: create/use `@types/superagent-proxy`
43-
(req as any).proxy(proxy);
44+
if (req.proxy) {
45+
req.proxy(proxy);
4446
} else {
4547
debug(`Cannot install proxy--req.proxy not defined`);
4648
}

types/superagent-proxy.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
declare module "superagent-proxy" {
22
import * as superagent from 'superagent';
33

4+
module "superagent" {
5+
interface Request {
6+
proxy(url: string): this;
7+
}
8+
}
9+
410
function superagentProxy(s: typeof superagent): void;
511

612
export = superagentProxy;

0 commit comments

Comments
 (0)