From 6b7eb02f3a822941185e8c74be71d677285c741e Mon Sep 17 00:00:00 2001 From: Momo Kornher Date: Mon, 3 Jul 2023 15:56:30 +0100 Subject: [PATCH] fix: export transliterateAssembly and fix bug with transliterate cli (backport) (#4166) Backport of https://github.com/aws/jsii-rosetta/pull/121 --- By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license]. [Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0 --- packages/jsii-rosetta/bin/jsii-rosetta.ts | 21 +++++++++++---------- packages/jsii-rosetta/lib/index.ts | 1 + 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/packages/jsii-rosetta/bin/jsii-rosetta.ts b/packages/jsii-rosetta/bin/jsii-rosetta.ts index cfc403fbb6..0c7c9f2b9d 100644 --- a/packages/jsii-rosetta/bin/jsii-rosetta.ts +++ b/packages/jsii-rosetta/bin/jsii-rosetta.ts @@ -288,7 +288,6 @@ function main() { describe: 'Assembly to transliterate', }) .option('language', { - alias: 'l', type: 'string', array: true, default: [], @@ -319,15 +318,17 @@ function main() { ); const languages = args.language.length > 0 - ? args.language.map((lang) => { - const target = Object.entries(TargetLanguage).find(([k]) => k === lang)?.[1]; - if (target == null) { - throw new Error( - `Unknown target language: ${lang}. Expected one of ${Object.keys(TargetLanguage).join(', ')}`, - ); - } - return target; - }) + ? args.language + .map((lang) => lang.toUpperCase()) + .map((lang) => { + const target = Object.entries(TargetLanguage).find(([k]) => k === lang)?.[1]; + if (target == null) { + throw new Error( + `Unknown target language: ${lang}. Expected one of ${Object.keys(TargetLanguage).join(', ')}`, + ); + } + return target; + }) : Object.values(TargetLanguage); return transliterateAssembly(assemblies, languages, args); }), diff --git a/packages/jsii-rosetta/lib/index.ts b/packages/jsii-rosetta/lib/index.ts index e9be061397..0bc4542bd8 100644 --- a/packages/jsii-rosetta/lib/index.ts +++ b/packages/jsii-rosetta/lib/index.ts @@ -12,4 +12,5 @@ export * from './rosetta-reader'; export * from './rosetta-translator'; export * from './snippet'; export * from './markdown'; +export * from './commands/transliterate'; export * from './strict';