Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ As of the `0.8.0` release, example apps for testing are included when initializi
--author <author> ......... Author name and email (e.g. "Name <name@example.com>")
--license <id> ............ SPDX License ID (e.g. "MIT")
--description <text> ...... Short description of plugin features
--android-lang <text> ..... Language for Android plugin development (either "kotlin" or "java", default is "java")
--android-lang <text> ..... Language for Android plugin development (either "kotlin" or "java")
```
2 changes: 1 addition & 1 deletion src/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const help = `
--author <author> ......... Author name and email (e.g. "Name <name@example.com>")
--license <id> ............ SPDX License ID (e.g. "MIT")
--description <text> ...... Short description of plugin features
--android-lang ............ Language for Android plugin development (either "kotlin" or "java", default is "java")
--android-lang ............ Language for Android plugin development (either "kotlin" or "java")

-h, --help ................ Print help, then quit
--verbose ................. Print verbose output to stderr
Expand Down
16 changes: 2 additions & 14 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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|java)$/i.test(value))
typeof value === 'string' && value.trim().length > 0 && /^(kotlin|kt|java)$/i.test(value)
? true
: `Must be either "kotlin" or "java"`,
dir: (value) =>
Expand Down Expand Up @@ -99,24 +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') {
process.stderr.write(`ERR: Invalid --android-lang value "${value}": ${validatorResult}\n`);
process.exit(1);
}
}

opts[option] = validatorResult === true ? value : undefined;

return opts;
}, {} as Options);

const allOptions = { ...argValues, ...optionValues };

if (!allOptions['android-lang']) {
allOptions['android-lang'] = 'java';
}

return allOptions;
return { ...argValues, ...optionValues };
};
15 changes: 9 additions & 6 deletions src/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ export const gatherDetails = (initialOptions: Options): Promise<OptionValues> =>
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',
Expand All @@ -96,11 +105,5 @@ export const gatherDetails = (initialOptions: Options): Promise<OptionValues> =>
process.exit(1);
},
},
).then(
(result) =>
({
...result,
'android-lang': initialOptions['android-lang'],
}) as OptionValues,
);
};
Loading