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
60 changes: 40 additions & 20 deletions apps/generator-cli/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,33 @@
import {Inject, Module, OnApplicationBootstrap} from '@nestjs/common';
import {HttpModule} from '@nestjs/axios';
import {Command} from 'commander';
import { Inject, Module, OnApplicationBootstrap } from '@nestjs/common';
import { HttpModule, HttpModuleOptions } from '@nestjs/axios';
import { Command } from 'commander';

import {COMMANDER_PROGRAM, LOGGER} from './constants';
import {VersionManagerController} from './controllers/version-manager.controller';
import {ConfigService, GeneratorService, PassThroughService, UIService, VersionManagerService} from './services';
import { COMMANDER_PROGRAM, LOGGER } from './constants';
import { VersionManagerController } from './controllers/version-manager.controller';
import {
ConfigService,
GeneratorService,
PassThroughService,
UIService,
VersionManagerService,
} from './services';
import { HttpsProxyAgent } from 'https-proxy-agent';

const proxyUrl = process.env.HTTP_PROXY || process.env.HTTPS_PROXY;
const httpModuleConfig: HttpModuleOptions = {};

if (proxyUrl) {
httpModuleConfig.proxy = false;
httpModuleConfig.httpsAgent = new HttpsProxyAgent(proxyUrl);
}

@Module({
imports: [HttpModule],
controllers: [
VersionManagerController
imports: [
HttpModule.register({
...httpModuleConfig,
}),
],
controllers: [VersionManagerController],
providers: [
UIService,
ConfigService,
Expand All @@ -19,34 +36,37 @@ import {ConfigService, GeneratorService, PassThroughService, UIService, VersionM
VersionManagerService,
{
provide: COMMANDER_PROGRAM,
useValue: new Command('openapi-generator-cli').helpOption(false).usage('<command> [<args>]').option( '--openapitools <openapitools.json>', 'Use the specified openapi-generator-cli configuration file')
useValue: new Command('openapi-generator-cli')
.helpOption(false)
.usage('<command> [<args>]')
.option(
'--openapitools <openapitools.json>',
'Use the specified openapi-generator-cli configuration file',
),
},
{provide: LOGGER, useValue: console}
]
{ provide: LOGGER, useValue: console },
],
})
export class AppModule implements OnApplicationBootstrap {

constructor(
@Inject(COMMANDER_PROGRAM) private readonly program: Command,
private readonly versionManager: VersionManagerService,
private readonly passThroughService: PassThroughService
) {
}
private readonly passThroughService: PassThroughService,
) {}

onApplicationBootstrap = async () => {

let selectedVersion = this.versionManager.getSelectedVersion();

if (!selectedVersion) {
const [{version}] = await this.versionManager.search(['latest']).toPromise();
const [{ version }] = await this.versionManager
.search(['latest'])
.toPromise();
await this.versionManager.setSelectedVersion(version);
selectedVersion = version;
}

await this.versionManager.downloadIfNeeded(selectedVersion);
await this.passThroughService.init();
this.program.parse(process.argv);

};

}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
"concurrently": "6.5.1",
"console.table": "0.10.0",
"fs-extra": "10.1.0",
"https-proxy-agent": "^7.0.4",
"inquirer": "8.2.6",
"jsonpath": "1.1.1",
"lodash": "4.17.21",
Expand Down
8 changes: 8 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5938,6 +5938,14 @@ https-proxy-agent@^7.0.0, https-proxy-agent@^7.0.1:
agent-base "^7.0.2"
debug "4"

https-proxy-agent@^7.0.4:
version "7.0.4"
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-7.0.4.tgz#8e97b841a029ad8ddc8731f26595bad868cb4168"
integrity sha512-wlwpilI7YdjSkWaQ/7omYBMTliDcmCN8OLihO6I9B86g06lMyAoqgoDpV0XqoaPOKj+0DIdAvnsWfyAAhmimcg==
dependencies:
agent-base "^7.0.2"
debug "4"

human-signals@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0"
Expand Down