Skip to content

Commit

Permalink
Merge branch 'release/1.0' into fix/rnv_target
Browse files Browse the repository at this point in the history
* release/1.0:
  fix: cli target launch webos
  fix target list webos
  • Loading branch information
pavjacko committed Feb 12, 2024
2 parents b9485d8 + 174c8e7 commit 2aeba42
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 10 deletions.
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

0 comments on commit 2aeba42

Please sign in to comment.