From ef6355a3a73d069585eb82c236d99be907ceab09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halvard=20M=C3=B8rstad?= Date: Fri, 15 Sep 2023 12:08:00 +0000 Subject: [PATCH 1/3] Added environment variable override for storage dir --- apps/generator-cli/src/app/services/version-manager.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 d20635673..424a4d017 100644 --- a/apps/generator-cli/src/app/services/version-manager.service.ts +++ b/apps/generator-cli/src/app/services/version-manager.service.ts @@ -32,7 +32,7 @@ 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, From 22e441263f1c1f096e7b2f9e29e56b274178cfb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halvard=20M=C3=B8rstad?= Date: Fri, 15 Sep 2023 14:21:58 +0200 Subject: [PATCH 2/3] Added documentation --- apps/generator-cli/src/README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/generator-cli/src/README.md b/apps/generator-cli/src/README.md index a99441128..85592929d 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: From 14a30c50b428d1bf33c0386b80ced96b244b6584 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halvard=20M=C3=B8rstad?= Date: Fri, 22 Mar 2024 15:41:36 +0100 Subject: [PATCH 3/3] fix(storage): post main merge formatting --- .../src/app/services/version-manager.service.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) 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 213a64586..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,24 +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'); + 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 {