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 target list webos #1384

Merged
merged 3 commits into from
Feb 9, 2024
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 packages/engine-core/src/tasks/task.rnv.target.launch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const taskRnvTargetLaunch: RnvTaskFn = async (c, parentTask, originTask)
case TIZEN:
return launchTizenSimulator(c, target);
case WEBOS:
return launchWebOSimulator(c);
return launchWebOSimulator(c, target);
case KAIOS:
return launchKaiOSSimulator(c);
default:
Expand Down
46 changes: 37 additions & 9 deletions packages/sdk-webos/src/deviceManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import {
isSystemLinux,
isSystemMac,
logError,
logSuccess,
logWarning,
} from '@rnv/core';
import { WebosDevice } from './types';
import {
Expand All @@ -33,21 +35,38 @@ import {
} from './constants';
import semver from 'semver';

export const launchWebOSimulator = (c: RnvContext) => {
logTask('launchWebOSimulator');
export const launchWebOSimulator = async (c: RnvContext, target: string) => {
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)) {
logWarning(
`Target with name ${chalk().red(selectedOption)} does not exist. You can update it here: ${chalk().cyan(
c.paths.GLOBAL_RNV_CONFIG
)}`
);
await launchWebOSimulator(c, '');
return true;
}

const availableEmulatorVersions = getDirectories(path.join(webosSdkPath, 'Simulator'));
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/${availableEmulatorVersions?.[0]}/${availableEmulatorVersions?.[0]}${
isSystemWin ? '.exe' : isSystemLinux ? '.appimage' : '.app'
}`
`Simulator/${selectedOption}/${selectedOption}${isSystemWin ? '.exe' : isSystemLinux ? '.appimage' : '.app'}`
);

if (!fsExistsSync(ePath)) {
Expand All @@ -57,7 +76,9 @@ export const launchWebOSimulator = (c: RnvContext) => {
return executeAsync(c, ePath, { detached: true, stdio: 'ignore' });
}

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

const parseDevices = (c: RnvContext, devicesResponse: string): Promise<Array<WebosDevice>> => {
Expand Down Expand Up @@ -187,6 +208,15 @@ export const listWebOSTargets = async (c: RnvContext) => {

const deviceArray = devices.map((device, i) => ` [${i + 1}]> ${chalk().bold(device.name)} | ${device.device}`);

const webosSdkPath = getRealPath(c, c.buildConfig?.sdks?.WEBOS_SDK);
if (!webosSdkPath) {
return Promise.reject(`c.buildConfig.sdks.WEBOS_SDK undefined`);
}
const availableSimulatorVersions = getDirectories(path.join(webosSdkPath, 'Simulator'));
availableSimulatorVersions.map((a) => {
deviceArray.push(` [${deviceArray.length + 1}]> ${chalk().bold(a)} | simulator`);
});

logToSummary(`WebOS Targets:\n${deviceArray.join('\n')}`);

return true;
Expand All @@ -207,13 +237,11 @@ export const runWebosSimOrDevice = async (c: RnvContext) => {
const tOut = path.join(platDir, 'output');
const configFilePath = path.join(tDir, 'appinfo.json');

// logTask(`runWebOS:${target}:${isHosted}`, chalk().grey);
const cnfg = JSON.parse(fsReadFileSync(configFilePath).toString());
const tId = cnfg.id;
const appPath = path.join(tOut, `${tId}_${cnfg.version}_all.ipk`);

// Start the fun
// await buildWeb(c);
await execCLI(c, CLI_WEBOS_ARES_PACKAGE, `-o ${tOut} ${tDir} -n`);

// List all devices
Expand Down
Loading