Skip to content

Commit

Permalink
Merge pull request #1817 from flexn-io/fix/kaios_default_target
Browse files Browse the repository at this point in the history
[kaios] Fix default target
  • Loading branch information
Marius456 authored Dec 10, 2024
2 parents dcfe4a5 + 5b16083 commit 0f9d90d
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions packages/sdk-kaios/src/deviceManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ import {
logWarning,
chalk,
} from '@rnv/core';
import { updateDefaultTargets } from '@rnv/sdk-utils';
import path from 'path';

export const launchKaiOSSimulator = async (target: string | boolean) => {
const c = getContext();
logDefault(`launchKaiOSSimulator: ${target}`);

if (!c.platform) return;
const defaultTarget = c.buildConfig.defaultTargets?.[c.platform];
const kaiosSdkPath = getRealPath(c.buildConfig?.sdks?.KAIOS_SDK);

if (!kaiosSdkPath) {
Expand All @@ -27,19 +29,26 @@ export const launchKaiOSSimulator = async (target: string | boolean) => {
(directory) => directory.toLowerCase().indexOf('kaios') !== -1
);

if (target === true) {
if (typeof target === 'boolean') {
const { selectedSimulator } = await inquirerPrompt({
name: 'selectedSimulator',
type: 'list',
message: 'What simulator would you like to launch?',
choices: availableSimulatorVersions,
});
target = selectedSimulator;
if (!defaultTarget || defaultTarget !== selectedSimulator) {
await updateDefaultTargets(c, selectedSimulator);
}
} else if (typeof target === 'string' && !availableSimulatorVersions.includes(target)) {
logWarning(
`Target with name ${chalk().red(target)} does not exist. You can update it here: ${chalk().cyan(
c.paths.dotRnv.config
)}`
`${
defaultTarget && !c.program.opts().target
? `The default target specified in ${chalk().cyan(c.paths.dotRnv.config)} or ${chalk().cyan(
c.paths.project.configLocal
)}`
: 'Target'
} with name ${chalk().red(target)} does not exist.`
);
await launchKaiOSSimulator(true);
return true;
Expand Down

0 comments on commit 0f9d90d

Please sign in to comment.