Skip to content

Commit

Permalink
Modify flow to install JDK to default path
Browse files Browse the repository at this point in the history
  • Loading branch information
joycetoh8 committed Sep 8, 2020
1 parent af8d130 commit c795e0e
Showing 1 changed file with 27 additions and 17 deletions.
44 changes: 27 additions & 17 deletions packages/cli/src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,34 +28,44 @@ export const DEFAULT_CONFIG_FILE_PATH = join(DEFAULT_CONFIG_FOLDER, DEFAULT_CONF
const LEGACY_CONFIG_FOLDER = join(homedir(), '.llama-pack');
const LEGACY_CONFIG_NAME = 'llama-pack-config.json';
const LEGACY_CONFIG_FILE_PATH = join(LEGACY_CONFIG_FOLDER, LEGACY_CONFIG_NAME);
const DEFAULT_JDK_FOLDER = join(DEFAULT_CONFIG_FOLDER, 'jdk');

async function createConfig(): Promise<Config> {
const result = await inquirer.prompt([
const installRequest = await inquirer.prompt([
{
type: 'confirm',
name: 'jdkExists',
message: 'Do you have JDK 8 installed?',
default: false,
name: 'jdk',
message: 'Do you want Bubblewrap to install JDK? (Enter "No" to use your JDK installation)',
default: true,
},
]);

let jdkPath;
if (!installRequest.jdk) {
const jdk = await inquirer.prompt([
{
name: 'path',
message: 'Path to your existing JDK:',
validate: existsSync,
},
]);
jdkPath = jdk.path;
} else {
await fsPromises.mkdir(DEFAULT_JDK_FOLDER);
console.log(`Downloading JDK 8 to ${DEFAULT_JDK_FOLDER}`);
const jdkInstaller = new JdkInstaller(process);
jdkPath = await jdkInstaller.install(DEFAULT_JDK_FOLDER);
}

const androidSdk = await inquirer.prompt([
{
name: 'jdkPath',
message: 'Path to the JDK. If not installed, enter the desired install location:',
validate: existsSync,
}, {
name: 'androidSdkPath',
name: 'path',
message: 'Path to the Android SDK:',
validate: existsSync,
},
]);

let jdkPath = result.jdkPath;
if (!result.jdkExists) {
console.log('Downloading JDK 8');
const jdkInstaller = new JdkInstaller(process);
jdkPath = await jdkInstaller.install(result.jdkPath);
}

return new Config(jdkPath, result.androidSdkPath);
return new Config(jdkPath, androidSdk.path);
}

async function renameConfigIfNeeded(log: Log): Promise<void> {
Expand Down

0 comments on commit c795e0e

Please sign in to comment.