Skip to content

Commit 5dc4e19

Browse files
authored
Revert "fix: make 'android-lang' optional, with java as default (#149)" (#150)
This reverts commit c2274d0.
1 parent c2274d0 commit 5dc4e19

4 files changed

Lines changed: 13 additions & 22 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ As of the `0.8.0` release, example apps for testing are included when initializi
3030
--author <author> ......... Author name and email (e.g. "Name <name@example.com>")
3131
--license <id> ............ SPDX License ID (e.g. "MIT")
3232
--description <text> ...... Short description of plugin features
33-
--android-lang <text> ..... Language for Android plugin development (either "kotlin" or "java", default is "java")
33+
--android-lang <text> ..... Language for Android plugin development (either "kotlin" or "java")
3434
```

src/help.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const help = `
1010
--author <author> ......... Author name and email (e.g. "Name <name@example.com>")
1111
--license <id> ............ SPDX License ID (e.g. "MIT")
1212
--description <text> ...... Short description of plugin features
13-
--android-lang ............ Language for Android plugin development (either "kotlin" or "java", default is "java")
13+
--android-lang ............ Language for Android plugin development (either "kotlin" or "java")
1414
1515
-h, --help ................ Print help, then quit
1616
--verbose ................. Print verbose output to stderr

src/options.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export const VALIDATORS: Validators = {
6868
description: (value) =>
6969
typeof value !== 'string' || value.trim().length === 0 ? `Must provide a description` : true,
7070
'android-lang': (value) =>
71-
value === undefined || value === '' || (typeof value === 'string' && /^(kotlin|java)$/i.test(value))
71+
typeof value === 'string' && value.trim().length > 0 && /^(kotlin|kt|java)$/i.test(value)
7272
? true
7373
: `Must be either "kotlin" or "java"`,
7474
dir: (value) =>
@@ -99,24 +99,12 @@ export const getOptions = (): Options => {
9999

100100
if (typeof validatorResult === 'string') {
101101
debug(`invalid option: --%s %O: %s`, option, value, validatorResult);
102-
103-
// 'android-lang' is not prompted, so it should fail if invalid
104-
if (option === 'android-lang') {
105-
process.stderr.write(`ERR: Invalid --android-lang value "${value}": ${validatorResult}\n`);
106-
process.exit(1);
107-
}
108102
}
109103

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

112106
return opts;
113107
}, {} as Options);
114108

115-
const allOptions = { ...argValues, ...optionValues };
116-
117-
if (!allOptions['android-lang']) {
118-
allOptions['android-lang'] = 'java';
119-
}
120-
121-
return allOptions;
109+
return { ...argValues, ...optionValues };
122110
};

src/prompt.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,15 @@ export const gatherDetails = (initialOptions: Options): Promise<OptionValues> =>
8282
message: `Enter a SPDX license identifier for your plugin.\n`,
8383
validate: VALIDATORS.license,
8484
},
85+
{
86+
type: 'select',
87+
name: 'android-lang',
88+
message: `What language would you like to use for your Android plugin?\n`,
89+
choices: [
90+
{ title: 'Kotlin', value: 'kotlin' },
91+
{ title: 'Java', value: 'java' },
92+
],
93+
},
8594
{
8695
type: 'text',
8796
name: 'description',
@@ -96,11 +105,5 @@ export const gatherDetails = (initialOptions: Options): Promise<OptionValues> =>
96105
process.exit(1);
97106
},
98107
},
99-
).then(
100-
(result) =>
101-
({
102-
...result,
103-
'android-lang': initialOptions['android-lang'],
104-
}) as OptionValues,
105108
);
106109
};

0 commit comments

Comments
 (0)