Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,14 @@ jobs:
(npm run oa version-manager set 4.3.1 && npm run oa version | grep -q '4.3.1') || exit 1
test -f ~/my/storage/4.3.1.jar || exit 1
npm run oa:generate && mkdir ./foo && cd ./foo && npm run oa:generate

# release:
#- name: Test with HTTP proxy
# run: |
# cd ./examples
# yarn global add json && export PATH="$(yarn global bin):$PATH"
# yarn cache clean && yarn add $GITHUB_WORKSPACE/package.tgz
# export HTTP_PROXY=http://proxy_ip:proxy_port
# npm run oa generate -- -g ruby -i https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml -o $GITHUB_WORKSPACE/tmp/ruby-client
# rel#ease:
# if: github.event.pull_request.merged == 'true'
# name: Release (Dry)
# # needs: e2e # DONT FORGET TO ENABLE ME !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Expand Down
7 changes: 5 additions & 2 deletions apps/generator-cli/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ export default {
preset: '../../jest.preset.js',
testEnvironment: 'node',
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
'^.+\\.[cm]?[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
moduleFileExtensions: ['ts', 'js', 'html'],
transformIgnorePatterns: [
'node_modules/(?!(proxy-agent|agent-base|http-proxy-agent|https-proxy-agent|pac-proxy-agent|socks-proxy-agent|proxy-from-env)/)',
],
moduleFileExtensions: ['ts', 'js', 'mjs', 'cjs', 'html'],
coverageDirectory: '../../coverage/apps/generator-cli',
// snapshotFormat: { escapeString: true, printBasicPrototype: true },
};
10 changes: 4 additions & 6 deletions apps/generator-cli/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Inject, Module, OnApplicationBootstrap } from '@nestjs/common';
import { HttpModule, HttpModuleOptions } from '@nestjs/axios';
import { Command } from 'commander';
import { ProxyAgent } from 'proxy-agent';

import { COMMANDER_PROGRAM, LOGGER } from './constants';
import { VersionManagerController } from './controllers/version-manager.controller';
Expand All @@ -15,19 +16,16 @@ import {
const hasHttpProxyEnvs = process.env.HTTP_PROXY || process.env.http_proxy;
const hasHttpsProxyEnvs = process.env.HTTPS_PROXY || process.env.https_proxy;
const httpModuleConfig: HttpModuleOptions = {};
const proxyAgent = new ProxyAgent();

if (hasHttpProxyEnvs) {
httpModuleConfig.proxy = false;
// eslint-disable-next-line @typescript-eslint/no-var-requires
const ProxyAgent = require('proxy-agent').default ?? require('proxy-agent');
httpModuleConfig.httpAgent = new ProxyAgent();
httpModuleConfig.httpAgent = proxyAgent;
}

if (hasHttpsProxyEnvs) {
httpModuleConfig.proxy = false;
// eslint-disable-next-line @typescript-eslint/no-var-requires
const ProxyAgent = require('proxy-agent').default ?? require('proxy-agent');
httpModuleConfig.httpsAgent = new ProxyAgent();
httpModuleConfig.httpsAgent = proxyAgent;
}

@Module({
Expand Down
6 changes: 6 additions & 0 deletions apps/generator-cli/src/proxy-agent.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
declare module 'proxy-agent' {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const ProxyAgent: new (...args: any[]) => any;
export default ProxyAgent;
export { ProxyAgent };
}