diff --git a/apps/generator-cli/src/README.md b/apps/generator-cli/src/README.md index 5c0d3f9cf..a430f70c4 100644 --- a/apps/generator-cli/src/README.md +++ b/apps/generator-cli/src/README.md @@ -134,7 +134,7 @@ Further it is also possible to configure generators, for example: "spaces": 2, "generator-cli": { "version": "4.3.1", - "storageDir": "~/my/custom/storage/dir", // optional + "storageDir": "~/my/custom/storage/dir", // optional, where the JAR file will be located/downloaded "generators": { // optional "v2.0": { // any name you like (just printed to the console log or reference it using --generator-key) "generatorName": "typescript-angular", @@ -176,6 +176,12 @@ is automatically used to generate your code. 🎉 | relPath | file name and extension of file relative to the glob provided | docs/auth.yaml | | ext | just file extension | yaml | +### Environment variables + +The following environment variables can be provided to override the config file: + +- `OPENAPI_GENERATOR_STORAGE_DIR`: Overrides the storageDir property. + ### Using custom / private maven registry If you're using a private maven registry you can configure the `downloadUrl` and `queryUrl` like this: diff --git a/apps/generator-cli/src/app/services/version-manager.service.ts b/apps/generator-cli/src/app/services/version-manager.service.ts index 53300c0aa..8a955fcfb 100644 --- a/apps/generator-cli/src/app/services/version-manager.service.ts +++ b/apps/generator-cli/src/app/services/version-manager.service.ts @@ -31,21 +31,21 @@ const mvn = { @Injectable() export class VersionManagerService { - private customStorageDir = this.configService.get( - 'generator-cli.storageDir' - ); + private customStorageDir = + process.env.OPENAPI_GENERATOR_STORAGE_DIR || + this.configService.get('generator-cli.storageDir'); public readonly storage = this.customStorageDir ? path.resolve( this.configService.cwd, - this.customStorageDir.replace('~', os.homedir()) + this.customStorageDir.replace('~', os.homedir()), ) : path.resolve(__dirname, './versions'); constructor( @Inject(LOGGER) private readonly logger: LOGGER, private httpService: HttpService, - private configService: ConfigService + private configService: ConfigService, ) {} getAll(): Observable {