Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix webos launch target choice #1436

Merged
merged 4 commits into from
Mar 6, 2024
Merged
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
39 changes: 19 additions & 20 deletions packages/sdk-webos/src/deviceManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
logToSummary,
logDefault,
logInfo,
logTask,
logWarning,
isSystemWin,
RnvContext,
inquirerPrompt,
Expand All @@ -20,7 +22,6 @@ import {
isSystemMac,
logError,
logSuccess,
logWarning,
getConfigProp,
getAppFolder,
} from '@rnv/core';
Expand All @@ -36,38 +37,36 @@ import {
import semver from 'semver';
import { isUrlLocalhost } from '@rnv/sdk-utils';

export const launchWebOSimulator = async (c: RnvContext, target: string) => {
logDefault('launchWebOSimulator', `${target}`);

export const launchWebOSimulator = async (c: RnvContext, target: string | boolean) => {
logTask('launchWebOSimulator', `${target}`);
const webosSdkPath = getRealPath(c, c.buildConfig?.sdks?.WEBOS_SDK);
if (!webosSdkPath) {
return Promise.reject(`c.buildConfig.sdks.WEBOS_SDK undefined`);
}
let selectedOption = target;

const availableSimulatorVersions = getDirectories(path.join(webosSdkPath, 'Simulator'));
if (target && !availableSimulatorVersions.includes(selectedOption)) {

if (target === true) {
const { selectedSimulator } = await inquirerPrompt({
name: 'selectedSimulator',
type: 'list',
message: 'What simulator would you like to launch?',
choices: availableSimulatorVersions,
});

target = selectedSimulator;
} else if (typeof target === 'string' && !availableSimulatorVersions.includes(target)) {
logWarning(
`Target with name ${chalk().red(selectedOption)} does not exist. You can update it here: ${chalk().cyan(
`Target with name ${chalk().red(target)} does not exist. You can update it here: ${chalk().cyan(
c.paths.GLOBAL_RNV_CONFIG
)}`
);
await launchWebOSimulator(c, '');
await launchWebOSimulator(c, true);
return true;
}

if (!target) {
({ selectedOption } = await inquirerPrompt({
name: 'selectedOption',
type: 'list',
choices: availableSimulatorVersions,
message: `Select the simulator you want to launch`,
}));
}

const ePath = path.join(
webosSdkPath,
`Simulator/${selectedOption}/${selectedOption}${isSystemWin ? '.exe' : isSystemLinux ? '.appimage' : '.app'}`
`Simulator/${target}/${target}${isSystemWin ? '.exe' : isSystemLinux ? '.appimage' : '.app'}`
);

if (!fsExistsSync(ePath)) {
Expand All @@ -78,7 +77,7 @@ export const launchWebOSimulator = async (c: RnvContext, target: string) => {
}

await executeAsync(c, `${openCommand} ${ePath}`, { detached: true });
logSuccess(`Succesfully launched ${selectedOption}`);
logSuccess(`Succesfully launched ${target}`);
return true;
};

Expand Down
Loading