From 61fa5a118e70dea24fec4012bf598130e2cf6643 Mon Sep 17 00:00:00 2001 From: cguran-ionos Date: Fri, 10 Mar 2023 17:01:14 +0200 Subject: [PATCH] set artifactId and package using env variables (#13) --- CHANGELOG.md | 4 ++++ README.md | 8 ++++---- package-lock.json | 4 ++-- package.json | 2 +- src/commands/env.ts | 4 ++-- src/commands/generate.ts | 7 +++---- 6 files changed, 16 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 327eb0d..b342825 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.2.7 + +- allow setting `artifactId` and `packageName` from env variables `IONOSSDK_PACKAGE` and `IONOSSDK_ARTIFACTID` + ## 1.2.6 - add `artifactId` optional flag to env cmd also diff --git a/README.md b/README.md index a676695..7b8c4a9 100644 --- a/README.md +++ b/README.md @@ -62,8 +62,8 @@ OPTIONS -d, --debug show debug information -h, --help show CLI help -n, --name=name (required) sdk to build - -p, --package=packageName sdk package name - -i, --artifactId=artifactId artifact id + -p, --package=packageName sdk package name, can be set also from env var IONOSSDK_PACKAGE + -i, --artifactId=artifactId artifact id, can be set from also env var IONOSSDK_ARTIFACTID -o, --output-dir=output-dir output dir -s, --spec=spec [default: none.json] api spec -v, --version=version [default: 0.0.0] sdk version @@ -86,8 +86,8 @@ OPTIONS -d, --debug show debug information -h, --help show CLI help -n, --name=name (required) sdk to build - -p, --package=packageName sdk package name - -i, --artifactId=artifactId artifact id + -p, --package=packageName sdk package name, can be set also from env var IONOSSDK_PACKAGE + -i, --artifactId=artifactId artifact id, can be set also from env var IONOSSDK_ARTIFACTID -o, --output-dir=output-dir output dir -s, --spec=spec (required) api spec -v, --version=version (required) sdk version diff --git a/package-lock.json b/package-lock.json index d765342..85fadfa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@ionos-cloud/ionossdk", - "version": "1.2.6", + "version": "1.2.7", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@ionos-cloud/ionossdk", - "version": "1.2.6", + "version": "1.2.7", "license": "MIT", "dependencies": { "@oclif/command": "^1.8.0", diff --git a/package.json b/package.json index 31d2592..2b1eb85 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@ionos-cloud/ionossdk", "description": "Ionos Cloud SDK tool", - "version": "1.2.6", + "version": "1.2.7", "author": "Florin Mihalache", "bin": { "ionossdk": "./bin/run" diff --git a/src/commands/env.ts b/src/commands/env.ts index a54f665..b723138 100644 --- a/src/commands/env.ts +++ b/src/commands/env.ts @@ -13,8 +13,8 @@ export default class Env extends BaseCommand { spec: flags.string({char: 's', description: 'api spec', required: false, default: 'none.json'}), version: flags.string({char: 'v', description: 'sdk version', required: false, default: '0.0.0'}), name: flags.string({char: 'n', description: 'sdk to build', required: true}), - package: flags.string({char: 'p', description: 'sdk package name', required: false}), - artifactId: flags.string({char: 'i', description: 'artifact id', required: false}), + package: flags.string({char: 'p', description: 'sdk package name, can be set from env var IONOSSDK_PACKAGE', required: false, env: 'IONOSSDK_PACKAGE'}), + artifactId: flags.string({char: 'i', description: 'artifact id, can be set from env variable IONOSSDK_ARTIFACTID', required: false, env: 'IONOSSDK_ARTIFACTID'}), 'assets-dir': flags.string({char: 'a', description: 'sdk assets directory (templates, scripts etc)', required: true}), 'output-dir': flags.string({char: 'o', description: 'output dir', required: false, default: ''}), } diff --git a/src/commands/generate.ts b/src/commands/generate.ts index 9c509c3..c04341a 100644 --- a/src/commands/generate.ts +++ b/src/commands/generate.ts @@ -7,14 +7,15 @@ import {FileCache} from '../services/file-cache' export default class Generate extends BaseCommand { static description = 'Generates an Ionos Cloud SDK' + // static flags = { ...BaseCommand.flags, spec: flags.string({char: 's', description: 'api spec', required: true}), version: flags.string({char: 'v', description: 'sdk version', required: true}), name: flags.string({char: 'n', description: 'sdk to build', required: true}), - package: flags.string({char: 'p', description: 'sdk package name', required: false}), - artifactId: flags.string({char: 'i', description: 'artifact id', required: false}), + package: flags.string({char: 'p', description: 'sdk package name, can be set from env var IONOSSDK_PACKAGE', required: false, env: 'IONOSSDK_PACKAGE'}), + artifactId: flags.string({char: 'i', description: 'artifact id, can be set from env variable IONOSSDK_ARTIFACTID', required: false, env: 'IONOSSDK_ARTIFACTID'}), 'assets-dir': flags.string({char: 'a', description: 'sdk assets directory (templates, scripts etc)'}), 'output-dir': flags.string({char: 'o', description: 'output dir'}), build: flags.boolean({char: 'b', description: 'also build the sdk with the build.sh script', default: true}), @@ -24,9 +25,7 @@ export default class Generate extends BaseCommand { static args = [ ...BaseCommand.args ] async run() { - const genConfig = new GenConfig() - genConfig.version = this.flags.version genConfig.outputDir = this.flags['output-dir'] || '.' genConfig.assetsDir = this.flags['assets-dir'] || '.'