From 5e5b05786bbcf83d4d4fc59bde1560d7b36b2f2f Mon Sep 17 00:00:00 2001 From: OS-pedrogustavobilro Date: Mon, 23 Mar 2026 09:44:44 +0000 Subject: [PATCH 1/8] fix: Make --android-lang optional with java as default --- README.md | 2 +- src/help.ts | 2 +- src/options.ts | 13 ++++++++++--- src/prompt.ts | 14 ++++---------- src/template.ts | 4 ++-- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index dd029a1..148a2de 100644 --- a/README.md +++ b/README.md @@ -30,5 +30,5 @@ As of the `0.8.0` release, example apps for testing are included when initializi --author ......... Author name and email (e.g. "Name ") --license ............ SPDX License ID (e.g. "MIT") --description ...... Short description of plugin features ---android-lang ..... Language for Android plugin development (either "kotlin" or "java") +--android-lang ..... Language for Android plugin development (either "kotlin" or "java", default is "java") ``` diff --git a/src/help.ts b/src/help.ts index df38983..726ff7f 100644 --- a/src/help.ts +++ b/src/help.ts @@ -10,7 +10,7 @@ const help = ` --author ......... Author name and email (e.g. "Name ") --license ............ SPDX License ID (e.g. "MIT") --description ...... Short description of plugin features - --android-lang ............ Language for Android plugin development (either "kotlin" or "java") + --android-lang ............ Language for Android plugin development (either "kotlin" or "java", default is "java") -h, --help ................ Print help, then quit --verbose ................. Print verbose output to stderr diff --git a/src/options.ts b/src/options.ts index e15a25d..2ef66ac 100644 --- a/src/options.ts +++ b/src/options.ts @@ -17,7 +17,7 @@ export interface OptionValues { author: string; license: string; description: string; - 'android-lang': string; + 'android-lang'?: string; } export type Validators = { @@ -68,7 +68,7 @@ export const VALIDATORS: Validators = { description: (value) => typeof value !== 'string' || value.trim().length === 0 ? `Must provide a description` : true, 'android-lang': (value) => - typeof value === 'string' && value.trim().length > 0 && /^(kotlin|kt|java)$/i.test(value) + value === undefined || value === '' || (typeof value === 'string' && /^(kotlin|kt|java)$/i.test(value)) ? true : `Must be either "kotlin" or "java"`, dir: (value) => @@ -106,5 +106,12 @@ export const getOptions = (): Options => { return opts; }, {} as Options); - return { ...argValues, ...optionValues }; + const allOptions = { ...argValues, ...optionValues }; + + // Set default for android-lang if not provided + if (!allOptions['android-lang']) { + allOptions['android-lang'] = 'java'; + } + + return allOptions; }; diff --git a/src/prompt.ts b/src/prompt.ts index 76d601f..1125977 100644 --- a/src/prompt.ts +++ b/src/prompt.ts @@ -81,15 +81,6 @@ export const gatherDetails = (initialOptions: Options): Promise => message: `Enter a SPDX license identifier for your plugin.\n`, validate: VALIDATORS.license, }, - { - type: 'select', - name: 'android-lang', - message: `What language would you like to use for your Android plugin?\n`, - choices: [ - { title: 'Kotlin', value: 'kotlin' }, - { title: 'Java', value: 'java' }, - ], - }, { type: 'text', name: 'description', @@ -104,5 +95,8 @@ export const gatherDetails = (initialOptions: Options): Promise => process.exit(1); }, }, - ); + ).then(result => ({ + ...result, + 'android-lang': initialOptions['android-lang'], + } as OptionValues)); }; diff --git a/src/template.ts b/src/template.ts index 6446f8e..91bef8c 100644 --- a/src/template.ts +++ b/src/template.ts @@ -25,7 +25,7 @@ export const extractTemplate = async ( ): Promise => { const templateFiles: string[] = []; const templateFolders: string[] = []; - const androidLang = details['android-lang'].toLowerCase(); + const androidLang = (details['android-lang'] || 'java').toLowerCase(); await mkdir(dir, { recursive: true }); await extract({ file: type === 'PLUGIN_TEMPLATE' ? TEMPLATE_PATH : WWW_TEMPLATE_PATH, @@ -84,7 +84,7 @@ export const applyTemplate = async ( author, license, description, - 'android-lang': androidLang, + 'android-lang': androidLang = 'java', }: OptionValues, ): Promise => { const template = await readFile(p, { encoding: 'utf8' }); From 1b49928d3f266b060563beea5718548f02c9b3c3 Mon Sep 17 00:00:00 2001 From: OS-pedrogustavobilro Date: Mon, 23 Mar 2026 09:47:15 +0000 Subject: [PATCH 2/8] fix: fail when android-lang option is invalid --- src/options.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/options.ts b/src/options.ts index 2ef66ac..86b5064 100644 --- a/src/options.ts +++ b/src/options.ts @@ -99,6 +99,12 @@ export const getOptions = (): Options => { if (typeof validatorResult === 'string') { debug(`invalid option: --%s %O: %s`, option, value, validatorResult); + + // 'android-lang' is not prompted, so it should fail if invalid + if (option === 'android-lang' && value !== undefined && value !== '') { + process.stderr.write(`ERR: Invalid --android-lang value "${value}": ${validatorResult} (should be "kotlin" or "java")\n`); + process.exit(1); + } } opts[option] = validatorResult === true ? value : undefined; From 86a3a74e46906a73ab69880d3c966811de1e144a Mon Sep 17 00:00:00 2001 From: OS-pedrogustavobilro Date: Mon, 23 Mar 2026 09:55:23 +0000 Subject: [PATCH 3/8] fix: using 'kt' did not remove java folder --- src/options.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/options.ts b/src/options.ts index 86b5064..b32c196 100644 --- a/src/options.ts +++ b/src/options.ts @@ -114,8 +114,11 @@ export const getOptions = (): Options => { const allOptions = { ...argValues, ...optionValues }; - // Set default for android-lang if not provided - if (!allOptions['android-lang']) { + // Normalize and set default for android-lang + if (allOptions['android-lang']) { + const normalized = allOptions['android-lang'].toLowerCase(); + allOptions['android-lang'] = normalized === 'kt' ? 'kotlin' : normalized; + } else { allOptions['android-lang'] = 'java'; } From 1c2c3685a938655058e1c8f2a08cc185078d4175 Mon Sep 17 00:00:00 2001 From: OS-pedrogustavobilro Date: Mon, 23 Mar 2026 09:55:50 +0000 Subject: [PATCH 4/8] chore: fix lint issues --- src/options.ts | 4 +++- src/prompt.ts | 11 +++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/options.ts b/src/options.ts index b32c196..de918c8 100644 --- a/src/options.ts +++ b/src/options.ts @@ -102,7 +102,9 @@ export const getOptions = (): Options => { // 'android-lang' is not prompted, so it should fail if invalid if (option === 'android-lang' && value !== undefined && value !== '') { - process.stderr.write(`ERR: Invalid --android-lang value "${value}": ${validatorResult} (should be "kotlin" or "java")\n`); + process.stderr.write( + `ERR: Invalid --android-lang value "${value}": ${validatorResult} (should be "kotlin" or "java")\n`, + ); process.exit(1); } } diff --git a/src/prompt.ts b/src/prompt.ts index 1125977..f83f66d 100644 --- a/src/prompt.ts +++ b/src/prompt.ts @@ -95,8 +95,11 @@ export const gatherDetails = (initialOptions: Options): Promise => process.exit(1); }, }, - ).then(result => ({ - ...result, - 'android-lang': initialOptions['android-lang'], - } as OptionValues)); + ).then( + (result) => + ({ + ...result, + 'android-lang': initialOptions['android-lang'], + }) as OptionValues, + ); }; From 6425b380022df8f7e5c5a6eabbdea8bab536feb3 Mon Sep 17 00:00:00 2001 From: OS-pedrogustavobilro Date: Mon, 23 Mar 2026 15:54:38 +0000 Subject: [PATCH 5/8] chore: revert 86a3a74e46906a73ab69880d3c966811de1e144a Following PR discussion --- src/options.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/options.ts b/src/options.ts index de918c8..1c67c24 100644 --- a/src/options.ts +++ b/src/options.ts @@ -116,11 +116,7 @@ export const getOptions = (): Options => { const allOptions = { ...argValues, ...optionValues }; - // Normalize and set default for android-lang - if (allOptions['android-lang']) { - const normalized = allOptions['android-lang'].toLowerCase(); - allOptions['android-lang'] = normalized === 'kt' ? 'kotlin' : normalized; - } else { + if (!allOptions['android-lang']) { allOptions['android-lang'] = 'java'; } From 07bc7eddcbe10fe68e1447c92d0bd2c5660337d6 Mon Sep 17 00:00:00 2001 From: OS-pedrogustavobilro Date: Mon, 23 Mar 2026 16:01:44 +0000 Subject: [PATCH 6/8] chore: remove kt option --- src/options.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/options.ts b/src/options.ts index 1c67c24..46ed37c 100644 --- a/src/options.ts +++ b/src/options.ts @@ -68,7 +68,7 @@ export const VALIDATORS: Validators = { description: (value) => typeof value !== 'string' || value.trim().length === 0 ? `Must provide a description` : true, 'android-lang': (value) => - value === undefined || value === '' || (typeof value === 'string' && /^(kotlin|kt|java)$/i.test(value)) + value === undefined || value === '' || (typeof value === 'string' && /^(kotlin|java)$/i.test(value)) ? true : `Must be either "kotlin" or "java"`, dir: (value) => From ed1b1995af5873a89576539d319710ed8de85905 Mon Sep 17 00:00:00 2001 From: OS-pedrogustavobilro Date: Mon, 23 Mar 2026 17:46:29 +0000 Subject: [PATCH 7/8] chore: Improve error handling for android-lang --- src/options.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/options.ts b/src/options.ts index 46ed37c..7f296a0 100644 --- a/src/options.ts +++ b/src/options.ts @@ -17,7 +17,7 @@ export interface OptionValues { author: string; license: string; description: string; - 'android-lang'?: string; + 'android-lang': string; } export type Validators = { @@ -101,10 +101,8 @@ export const getOptions = (): Options => { debug(`invalid option: --%s %O: %s`, option, value, validatorResult); // 'android-lang' is not prompted, so it should fail if invalid - if (option === 'android-lang' && value !== undefined && value !== '') { - process.stderr.write( - `ERR: Invalid --android-lang value "${value}": ${validatorResult} (should be "kotlin" or "java")\n`, - ); + if (option === 'android-lang') { + process.stderr.write(`ERR: Invalid --android-lang value "${value}": ${validatorResult}\n`); process.exit(1); } } From dcc299622b5c863ffc4251f9c7f660f67a4bf3b1 Mon Sep 17 00:00:00 2001 From: OS-pedrogustavobilro Date: Mon, 23 Mar 2026 17:49:41 +0000 Subject: [PATCH 8/8] chore: update template since androidLang is not optional anymore --- src/template.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/template.ts b/src/template.ts index 91bef8c..6446f8e 100644 --- a/src/template.ts +++ b/src/template.ts @@ -25,7 +25,7 @@ export const extractTemplate = async ( ): Promise => { const templateFiles: string[] = []; const templateFolders: string[] = []; - const androidLang = (details['android-lang'] || 'java').toLowerCase(); + const androidLang = details['android-lang'].toLowerCase(); await mkdir(dir, { recursive: true }); await extract({ file: type === 'PLUGIN_TEMPLATE' ? TEMPLATE_PATH : WWW_TEMPLATE_PATH, @@ -84,7 +84,7 @@ export const applyTemplate = async ( author, license, description, - 'android-lang': androidLang = 'java', + 'android-lang': androidLang, }: OptionValues, ): Promise => { const template = await readFile(p, { encoding: 'utf8' });