Skip to content

Commit

Permalink
fix: upgrade proxy-agent to ^6.3.0 to remove vm2 deps (#13012)
Browse files Browse the repository at this point in the history
* ci: upgrade proxy-agent to ^6.3.0 to remove vm2 deps

* ci: unset IS_AMPLIFY_CI for verify api extract step, yarn lock update

* chore: comment
  • Loading branch information
awsluja authored Jul 27, 2023
1 parent 07af8e2 commit 989ec35
Show file tree
Hide file tree
Showing 11 changed files with 147 additions and 152 deletions.
2 changes: 1 addition & 1 deletion packages/amplify-category-notifications/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"lodash": "^4.17.21",
"ora": "^4.0.3",
"promise-sequential": "^1.1.1",
"proxy-agent": "^5.0.0"
"proxy-agent": "^6.3.0"
},
"jest": {
"testEnvironmentOptions": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
resolveRegion,
loadConfigurationForEnv,
} from '@aws-amplify/amplify-provider-awscloudformation';
import proxyAgent from 'proxy-agent';
import { ProxyAgent } from 'proxy-agent';
const spinner = ora('');
const defaultPinpointRegion = 'us-east-1';

Expand Down Expand Up @@ -544,10 +544,11 @@ export const getPinpointClient = async (
customUserAgent: formUserAgentParam(context, userAgentAction),
};

// HTTP_PROXY & HTTPS_PROXY env vars are read automatically by ProxyAgent, but we check to see if they are set before using the proxy
if (httpProxy) {
aws.config.update({
httpOptions: {
agent: proxyAgent(httpProxy),
agent: new ProxyAgent(),
},
});
}
Expand Down
2 changes: 1 addition & 1 deletion packages/amplify-cli-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"node-fetch": "^2.6.7",
"open": "^8.4.0",
"ora": "^4.0.3",
"proxy-agent": "^5.0.0",
"proxy-agent": "^6.3.0",
"semver": "^7.5.4",
"typescript-json-schema": "~0.52.0",
"which": "^2.0.2",
Expand Down
5 changes: 3 additions & 2 deletions packages/amplify-cli-core/src/banner-message/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fetch from 'node-fetch';
import semver from 'semver';
import ProxyAgent from 'proxy-agent';
import { ProxyAgent } from 'proxy-agent';
import { getLogger } from '../logger';

export type Message = {
Expand Down Expand Up @@ -43,7 +43,8 @@ export class BannerMessage {
try {
logger.info(`fetch banner messages from ${url}`);
const proxy = process.env.HTTP_PROXY || process.env.HTTPS_PROXY;
const fetchOptions = proxy ? { agent: new ProxyAgent(proxy) } : {};
// HTTP_PROXY & HTTPS_PROXY env vars are read automatically by ProxyAgent, but we check to see if they are set before using the proxy
const fetchOptions = proxy ? { agent: new ProxyAgent() } : {};
const result = await fetch(url, fetchOptions);
const body = await result.json();
if (!semver.satisfies(body.version, MAX_SUPPORTED_MESSAGE_CONFIG_VERSION)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/amplify-provider-awscloudformation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"node-fetch": "^2.6.7",
"ora": "^4.0.3",
"promise-sequential": "^1.1.1",
"proxy-agent": "^5.0.0",
"proxy-agent": "^6.3.0",
"rimraf": "^3.0.0",
"xstate": "^4.14.0"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const aws = require('aws-sdk');
const proxyAgent = require('proxy-agent');
const { ProxyAgent } = require('proxy-agent');
const configurationManager = require('../configuration-manager');
const { regions: amplifyServiceRegions } = require('../aws-regions');

Expand All @@ -24,7 +24,7 @@ async function getConfiguredAmplifyClient(context, options = {}) {
if (httpProxy) {
aws.config.update({
httpOptions: {
agent: proxyAgent(httpProxy),
agent: new ProxyAgent(),
},
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ try {
aws = require('aws-sdk');
}

const proxyAgent = require('proxy-agent');
const { ProxyAgent } = require('proxy-agent');
const configurationManager = require('../configuration-manager');

aws.configureWithCreds = async (context) => {
Expand All @@ -35,7 +35,7 @@ aws.configureWithCreds = async (context) => {
if (httpProxy) {
aws.config.update({
httpOptions: {
agent: proxyAgent(httpProxy),
agent: new ProxyAgent(httpProxy),
},
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import chalk from 'chalk';
import { prompt } from 'inquirer';
import _ from 'lodash';
import path from 'path';
import proxyAgent from 'proxy-agent';
import { ProxyAgent } from 'proxy-agent';
import { STS } from 'aws-sdk';
import awsRegions from './aws-regions';
import constants from './constants';
Expand Down Expand Up @@ -838,10 +838,11 @@ export async function getAwsConfig(context: $TSContext): Promise<AwsSdkConfig> {
}
}

// HTTP_PROXY & HTTPS_PROXY env vars are read automatically by ProxyAgent, but we check to see if they are set before using the proxy
if (httpProxy) {
resultAWSConfigInfo = {
...resultAWSConfigInfo,
httpOptions: { agent: proxyAgent(httpProxy) },
httpOptions: { agent: new ProxyAgent() },
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as fs from 'fs-extra';
import * as path from 'path';
import * as ini from 'ini';
import * as inquirer from 'inquirer';
import proxyAgent from 'proxy-agent';
import { ProxyAgent } from 'proxy-agent';
import * as constants from './constants';
import { fileLogger } from './utils/aws-logger';
import { AwsSdkConfig } from './utils/auth-types';
Expand Down Expand Up @@ -123,10 +123,11 @@ export const getProfiledAwsConfig = async (
});
}

// HTTP_PROXY & HTTPS_PROXY env vars are read automatically by ProxyAgent, but we check to see if they are set before using the proxy
if (httpProxy) {
awsConfigInfo = {
...awsConfigInfo,
httpOptions: { agent: proxyAgent(httpProxy) },
httpOptions: { agent: new ProxyAgent() },
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { stateManager, $TSContext, AmplifyError, AmplifyFault } from '@aws-ampli
import aws from 'aws-sdk';
import _ from 'lodash';
import fetch from 'node-fetch';
import proxyAgent from 'proxy-agent';
import { ProxyAgent } from 'proxy-agent';
import { adminLoginFlow } from '../admin-login';
import { AdminAuthConfig, AwsSdkConfig, CognitoAccessToken, CognitoIdToken } from './auth-types';
import { printer, prompter } from '@aws-amplify/amplify-prompts';
Expand Down Expand Up @@ -89,8 +89,9 @@ type AppStateResponse = {
async function getAdminAppState(appId: string, region: string): Promise<AppStateResponse> {
// environment variable AMPLIFY_CLI_APPSTATE_BASE_URL useful for development against beta/gamma appstate endpoints
const appStateBaseUrl = process.env.AMPLIFY_CLI_APPSTATE_BASE_URL ?? adminBackendMap[region].appStateUrl;
// HTTP_PROXY & HTTPS_PROXY env vars are read automatically by ProxyAgent, but we check to see if they are set before using the proxy
const httpProxy = process.env.HTTP_PROXY || process.env.HTTPS_PROXY;
const fetchOptions = httpProxy ? { agent: proxyAgent(httpProxy) } : {};
const fetchOptions = httpProxy ? { agent: new ProxyAgent() } : {};
const res = await fetch(`${appStateBaseUrl}/AppState/?appId=${appId}`, fetchOptions);
if (res.status >= 500) {
throw new AmplifyFault('ServiceCallFault', {
Expand Down
Loading

0 comments on commit 989ec35

Please sign in to comment.