From 0052587184e56d3992b3c9a2bdf6d78756064bea Mon Sep 17 00:00:00 2001 From: Justinas Date: Wed, 11 Sep 2024 09:27:57 +0300 Subject: [PATCH 1/7] listTizenTargets fix --- packages/sdk-tizen/src/deviceManager.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/sdk-tizen/src/deviceManager.ts b/packages/sdk-tizen/src/deviceManager.ts index 7c879e382..3e6bd9fcd 100644 --- a/packages/sdk-tizen/src/deviceManager.ts +++ b/packages/sdk-tizen/src/deviceManager.ts @@ -81,6 +81,7 @@ export const launchTizenEmulator = async (name: string | true): Promise const devices_lines = devices.split('\n'); const allDownloadedEmulators = emulators.split('\n'); // all tizen, tizenwatch and tizenmobile emulators + console.log(allDownloadedEmulators); const specificEmulators = await getSubplatformDevices(allDownloadedEmulators, c.platform as string); const lines = specificEmulators.concat(devices_lines.slice(1)); @@ -163,7 +164,12 @@ const getSubplatformDevices = async (allTizenEmulators: string[], neededPlatform export const listTizenTargets = async (platform: string) => { const emulatorsString = await execCLI(CLI_TIZEN_EMULATOR, 'list-vm'); const devicesString = await execCLI(CLI_SDB_TIZEN, 'devices'); - const devicesArr = devicesString.split('\n').slice(1); + const devicesArr = devicesString + .split('\n') + .slice(1) + .map((line: string) => line.split(' ')[0]); + console.log(devicesArr); + // turns devices string: ' List of devices attached \n192.168.0.105:26101 device UE43NU7192' to only the '192.168.0.105:26101' const allDownloadedEmulators = emulatorsString.split('\n'); // all tizen, tizenwatch and tizenmobile emulators const specificPlatformEmulators = await getSubplatformDevices(allDownloadedEmulators.concat(devicesArr), platform); // tizen, tizenwatch, tizenmobile - only 1 of them let targetStr = ''; From 20bf53a0c1505f394dbc9575e4fe7f7b7218f232 Mon Sep 17 00:00:00 2001 From: Justinas Date: Thu, 12 Sep 2024 11:32:15 +0300 Subject: [PATCH 2/7] target launch -p tizen command fixing so it works with real devices --- packages/sdk-tizen/src/deviceManager.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/sdk-tizen/src/deviceManager.ts b/packages/sdk-tizen/src/deviceManager.ts index 3e6bd9fcd..a39578f78 100644 --- a/packages/sdk-tizen/src/deviceManager.ts +++ b/packages/sdk-tizen/src/deviceManager.ts @@ -81,12 +81,14 @@ export const launchTizenEmulator = async (name: string | true): Promise const devices_lines = devices.split('\n'); const allDownloadedEmulators = emulators.split('\n'); // all tizen, tizenwatch and tizenmobile emulators - console.log(allDownloadedEmulators); + const specificEmulators = await getSubplatformDevices(allDownloadedEmulators, c.platform as string); + const devicesArr = devices_lines.slice(1).map((line: string) => line.split(' ')[0]); // devices array with only their ip - const lines = specificEmulators.concat(devices_lines.slice(1)); + const lines = specificEmulators.concat(devicesArr); const targetsArray = lines.map((line) => ({ id: line, name: line })); + const choices = _composeDevicesString(targetsArray); const { chosenEmulator } = await inquirerPrompt({ @@ -100,6 +102,11 @@ export const launchTizenEmulator = async (name: string | true): Promise } if (name) { + const ipRegex = /^(?:\d{1,3}\.){3}\d{1,3}:\d{1,5}$/; + if (name === true || ipRegex.test(name)) { + logInfo('Connecting to device'); // don't continue with further code - launching on device works diffirently than on emulator + return true; + } try { await executeAsync( `${c.cli[CLI_TIZEN_EMULATOR]} launch --name ${name}`, @@ -168,8 +175,8 @@ export const listTizenTargets = async (platform: string) => { .split('\n') .slice(1) .map((line: string) => line.split(' ')[0]); - console.log(devicesArr); // turns devices string: ' List of devices attached \n192.168.0.105:26101 device UE43NU7192' to only the '192.168.0.105:26101' + const allDownloadedEmulators = emulatorsString.split('\n'); // all tizen, tizenwatch and tizenmobile emulators const specificPlatformEmulators = await getSubplatformDevices(allDownloadedEmulators.concat(devicesArr), platform); // tizen, tizenwatch, tizenmobile - only 1 of them let targetStr = ''; From 89a1eb6ac5a0d1358ae8296019c4967dec6208e5 Mon Sep 17 00:00:00 2001 From: Justinas Date: Fri, 13 Sep 2024 10:51:31 +0300 Subject: [PATCH 3/7] npx rnv run -p tizen now lets you run on devices --- packages/sdk-tizen/src/deviceManager.ts | 7 +++++-- packages/template-starter/package.json | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/sdk-tizen/src/deviceManager.ts b/packages/sdk-tizen/src/deviceManager.ts index 2e3e81796..f79f08837 100644 --- a/packages/sdk-tizen/src/deviceManager.ts +++ b/packages/sdk-tizen/src/deviceManager.ts @@ -103,8 +103,11 @@ export const launchTizenEmulator = async (name: string | true): Promise if (name) { const ipRegex = /^(?:\d{1,3}\.){3}\d{1,3}:\d{1,5}$/; - if (name === true || ipRegex.test(name)) { - logInfo('Connecting to device'); // don't continue with further code - launching on device works diffirently than on emulator + if (name !== true && ipRegex.test(name)) { + // if ip is chosen, real device boot should start + logInfo('Connecting to device'); + c.runtime.target = name.split(':')[0]; + await runTizenSimOrDevice(); return true; } try { diff --git a/packages/template-starter/package.json b/packages/template-starter/package.json index 855f2ca46..f2b197219 100644 --- a/packages/template-starter/package.json +++ b/packages/template-starter/package.json @@ -132,5 +132,9 @@ "browserslist": [ ">0.2%", "op_mini all" - ] + ], + "dependencies": { + "dotenv": "16.4.5", + "raf": "3.4.1" + } } From 869cd11fcc1dc20d33489e5f0aff7305339b02ed Mon Sep 17 00:00:00 2001 From: Justinas Date: Tue, 17 Sep 2024 08:43:40 +0300 Subject: [PATCH 4/7] fixed a hanging, uninformative log --- packages/sdk-tizen/src/deviceManager.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/sdk-tizen/src/deviceManager.ts b/packages/sdk-tizen/src/deviceManager.ts index f79f08837..65222df4f 100644 --- a/packages/sdk-tizen/src/deviceManager.ts +++ b/packages/sdk-tizen/src/deviceManager.ts @@ -100,15 +100,14 @@ export const launchTizenEmulator = async (name: string | true): Promise name = chosenEmulator; } - - if (name) { + if (name && typeof name === 'string') { const ipRegex = /^(?:\d{1,3}\.){3}\d{1,3}:\d{1,5}$/; - if (name !== true && ipRegex.test(name)) { + if (ipRegex.test(name)) { // if ip is chosen, real device boot should start logInfo('Connecting to device'); c.runtime.target = name.split(':')[0]; await runTizenSimOrDevice(); - return true; + return new Promise(() => logInfo('Device is launched.')); } try { await executeAsync( @@ -430,8 +429,7 @@ Please create one and then edit the default target from ${c.paths.workspace.dir} await execCLI(CLI_TIZEN, `package -- "${intermediate}" -s ${certProfile} -t wgt -o "${tOut}"`); try { - // const packageID = platform === 'tizenwatch' || platform === 'tizenmobile' ? tId.split('.')[0] : tId; - const packageID = tId; + const packageID = platform === 'tizenwatch' || platform === 'tizenmobile' ? tId.split('.')[0] : tId; await execCLI(CLI_TIZEN, `uninstall -p ${packageID} -t ${deviceID}`, { ignoreErrors: true, }); From 1f73719f2704265e10988973ab1ca335df3f62cc Mon Sep 17 00:00:00 2001 From: Justinas Date: Wed, 18 Sep 2024 14:08:09 +0300 Subject: [PATCH 5/7] target launch, rnv run for tizen fixes --- packages/sdk-tizen/src/deviceManager.ts | 21 +++++++++++++------ .../sdk-tizen/src/tasks/taskTargetLaunch.ts | 2 +- packages/template-starter/package.json | 6 +----- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/packages/sdk-tizen/src/deviceManager.ts b/packages/sdk-tizen/src/deviceManager.ts index 3673c66c0..49af1717b 100644 --- a/packages/sdk-tizen/src/deviceManager.ts +++ b/packages/sdk-tizen/src/deviceManager.ts @@ -71,10 +71,9 @@ const formatXMLObject = ( return {}; }; -export const launchTizenEmulator = async (name: string | true): Promise => { +export const launchTizenEmulator = async (name: string | true, hideDevices?: boolean): Promise => { const c = getContext(); logDefault(`launchTizenEmulator:${name}`); - if (name === true) { const emulators = await execCLI(CLI_TIZEN_EMULATOR, 'list-vm'); const devices = await execCLI(CLI_SDB_TIZEN, 'devices'); @@ -86,7 +85,9 @@ export const launchTizenEmulator = async (name: string | true): Promise const lines = specificEmulators.concat(devicesArr); - const targetsArray = lines.map((line) => ({ id: line, name: line })); + const targetsArray = hideDevices + ? specificEmulators.map((line) => ({ id: line, name: line })) + : lines.map((line) => ({ id: line, name: line })); const choices = _composeDevicesString(targetsArray); @@ -105,7 +106,7 @@ export const launchTizenEmulator = async (name: string | true): Promise // if ip is chosen, real device boot should start logInfo('Connecting to device'); c.runtime.target = name.split(':')[0]; - await runTizenSimOrDevice(); + await runTizenSimOrDevice(true); return new Promise(() => logInfo('Device is launched.')); } try { @@ -348,7 +349,7 @@ const _composeDevicesString = (devices: Array>) // } // }; -export const runTizenSimOrDevice = async () => { +export const runTizenSimOrDevice = async (onlyRun?: true | null) => { const c = getContext(); const { target } = c.runtime; const { platform } = c; @@ -382,8 +383,11 @@ export const runTizenSimOrDevice = async () => { let deviceID: string; if (!tId) return Promise.reject(`Tizen platform requires "id" filed in platforms.tizen`); - const askForEmulator = async () => { + if (!target) { + launchTizenEmulator(true); + return; + } const { startEmulator } = await inquirerPrompt({ name: 'startEmulator', type: 'confirm', @@ -424,6 +428,11 @@ Please create one and then edit the default target from ${c.paths.workspace.dir} const continueLaunching = async () => { let hasDevice = false; + // if (onlyRun) { + // await execCLI(CLI_TIZEN, `run -p ${tId} -t ${deviceID}`); + // return true; + // } + await execCLI(CLI_TIZEN, `build-web -- "${tBuild}" -out "${intermediate}"`); await execCLI(CLI_TIZEN, `package -- "${intermediate}" -s ${certProfile} -t wgt -o "${tOut}"`); diff --git a/packages/sdk-tizen/src/tasks/taskTargetLaunch.ts b/packages/sdk-tizen/src/tasks/taskTargetLaunch.ts index f77079b92..1e630d2b2 100644 --- a/packages/sdk-tizen/src/tasks/taskTargetLaunch.ts +++ b/packages/sdk-tizen/src/tasks/taskTargetLaunch.ts @@ -11,7 +11,7 @@ export default createTask({ await checkAndConfigureTizenSdks(); const target = await getTargetWithOptionalPrompt(); await checkTizenSdk(); - return launchTizenEmulator(target); + return launchTizenEmulator(target, true); }, task: RnvTaskName.targetLaunch, options: [RnvTaskOptions.target], diff --git a/packages/template-starter/package.json b/packages/template-starter/package.json index 8900b6b22..11ae291f1 100644 --- a/packages/template-starter/package.json +++ b/packages/template-starter/package.json @@ -133,9 +133,5 @@ "browserslist": [ ">0.2%", "op_mini all" - ], - "dependencies": { - "dotenv": "16.4.5", - "raf": "3.4.1" - } + ] } From 42d1849f3bde83f21fef723caaa65d3009b5fafc Mon Sep 17 00:00:00 2001 From: Justinas Date: Thu, 19 Sep 2024 08:53:00 +0300 Subject: [PATCH 6/7] more edge case fixes --- .../src/__tests__/deviceManager.test.ts | 50 +++++++++++++++++-- packages/sdk-tizen/src/deviceManager.ts | 23 ++++----- 2 files changed, 57 insertions(+), 16 deletions(-) diff --git a/packages/sdk-tizen/src/__tests__/deviceManager.test.ts b/packages/sdk-tizen/src/__tests__/deviceManager.test.ts index 3669e5f3d..afd46f927 100644 --- a/packages/sdk-tizen/src/__tests__/deviceManager.test.ts +++ b/packages/sdk-tizen/src/__tests__/deviceManager.test.ts @@ -115,7 +115,7 @@ describe('launchTizenEmulator', () => { expect(inquirerPrompt).toHaveBeenCalledWith({ name: 'chosenEmulator', type: 'list', - message: 'What emulator would you like to launch?', + message: 'which emulator or device would you like to launch?', choices: expect.any(Array), }); expect(executeAsync).toHaveBeenCalledWith( @@ -124,6 +124,48 @@ describe('launchTizenEmulator', () => { ); expect(result).toBe(true); }); + it('should hide real devices from prompt, if true is passed', async () => { + const mockContext = { cli: { [CLI_TIZEN_EMULATOR]: 'tizen-emulator' }, platform: 'tizen' }; + const ctx = { ...getContext(), ...mockContext }; + createRnvContext(ctx); + + (execCLI as jest.Mock) + .mockResolvedValueOnce('emulator1\nemulator2') + .mockResolvedValueOnce( + 'firstTrashLineThatTizenDeviceCmdReturns\n111.111.0.111:26101 device UE43NU7192' + ); + (inquirerPrompt as jest.Mock).mockResolvedValue({ chosenEmulator: 'emulator1' }); + (executeAsync as jest.Mock).mockResolvedValue(true); + const result = await launchTizenEmulator(true, true); + expect(inquirerPrompt).toHaveBeenCalledWith({ + name: 'chosenEmulator', + type: 'list', + message: 'which emulator or device would you like to launch?', + choices: [], // not correct, because emulators are not mocked, but doesn't matter here, since its testing devices + }); + expect(result).toBe(true); + }); + it('should show real devices(same conditions as test above, just not passing 2nd param true to launchTizenEmulator) ', async () => { + const mockContext = { cli: { [CLI_TIZEN_EMULATOR]: 'tizen-emulator' }, platform: 'tizen' }; + const ctx = { ...getContext(), ...mockContext }; + createRnvContext(ctx); + + (execCLI as jest.Mock) + .mockResolvedValueOnce('emulator1\nemulator2') + .mockResolvedValueOnce( + 'firstTrashLineThatTizenDeviceCmdReturns\n111.111.0.111:26101 device UE43NU7192' + ); + (inquirerPrompt as jest.Mock).mockResolvedValue({ chosenEmulator: 'emulator1' }); + (executeAsync as jest.Mock).mockResolvedValue(true); + const result = await launchTizenEmulator(true); + expect(inquirerPrompt).toHaveBeenCalledWith({ + name: 'chosenEmulator', + type: 'list', + message: 'which emulator or device would you like to launch?', + choices: [{ key: '111.111.0.111:26101', name: '111.111.0.111:26101', value: '111.111.0.111:26101' }], + }); + expect(result).toBe(true); + }); it('should handle unknown VM error and retry with prompt', async () => { const mockContext = { cli: { [CLI_TIZEN_EMULATOR]: 'tizen-emulator' }, platform: 'tizen' }; const ctx = { ...getContext(), ...mockContext }; @@ -134,13 +176,13 @@ describe('launchTizenEmulator', () => { (inquirerPrompt as jest.Mock).mockResolvedValue({ chosenEmulator: 'emulator1' }); (executeAsync as jest.Mock).mockResolvedValue(true); const result = await launchTizenEmulator('unknownEmulator'); - expect(logError).toHaveBeenCalledWith('The VM "unknownEmulator" does not exist.'); + expect(logError).toHaveBeenCalledWith('The VM/device "unknownEmulator" does not exist.'); expect(execCLI).toHaveBeenCalledWith(CLI_TIZEN_EMULATOR, 'list-vm'); expect(execCLI).toHaveBeenCalledWith(CLI_SDB_TIZEN, 'devices'); expect(inquirerPrompt).toHaveBeenCalledWith({ name: 'chosenEmulator', type: 'list', - message: 'What emulator would you like to launch?', + message: 'which emulator or device would you like to launch?', choices: expect.any(Array), }); expect(executeAsync).toHaveBeenCalledWith( @@ -156,7 +198,7 @@ describe('launchTizenEmulator', () => { (executeAsync as jest.Mock).mockRejectedValueOnce(ERROR_MSG.ALREADY_RUNNING); const result = await launchTizenEmulator('runningEmulator'); - expect(logError).toHaveBeenCalledWith('The VM "runningEmulator" is already running.'); + expect(logError).toHaveBeenCalledWith('The VM/device "runningEmulator" is already running.'); expect(result).toBe(true); }); it('should reject if no name is specified', async () => { diff --git a/packages/sdk-tizen/src/deviceManager.ts b/packages/sdk-tizen/src/deviceManager.ts index 49af1717b..f1842bea8 100644 --- a/packages/sdk-tizen/src/deviceManager.ts +++ b/packages/sdk-tizen/src/deviceManager.ts @@ -34,6 +34,7 @@ export const DEFAULT_CERTIFICATE_NAME = 'tizen_author'; const ERROR_MSG = { UNKNOWN_VM: 'does not match any VM', ALREADY_RUNNING: 'is running now', + NO_SUPPORT: 'Your system cannot support HW virtualization', }; type PlatKeyObj = { @@ -94,7 +95,7 @@ export const launchTizenEmulator = async (name: string | true, hideDevices?: boo const { chosenEmulator } = await inquirerPrompt({ name: 'chosenEmulator', type: 'list', - message: 'What emulator would you like to launch?', + message: 'which emulator or device would you like to launch?', choices, }); @@ -106,7 +107,7 @@ export const launchTizenEmulator = async (name: string | true, hideDevices?: boo // if ip is chosen, real device boot should start logInfo('Connecting to device'); c.runtime.target = name.split(':')[0]; - await runTizenSimOrDevice(true); + await runTizenSimOrDevice(); return new Promise(() => logInfo('Device is launched.')); } try { @@ -118,12 +119,15 @@ export const launchTizenEmulator = async (name: string | true, hideDevices?: boo } catch (e) { if (typeof e === 'string') { if (e.includes(ERROR_MSG.UNKNOWN_VM)) { - logError(`The VM "${name}" does not exist.`); - return launchTizenEmulator(true); + logError(`The VM/device "${name}" does not exist.`); + return launchTizenEmulator(true, hideDevices); } - if (e.includes(ERROR_MSG.ALREADY_RUNNING)) { - logError(`The VM "${name}" is already running.`); + logError(`The VM/device "${name}" is already running.`); + return true; + } + if (e.includes(ERROR_MSG.NO_SUPPORT)) { + logError(`Your system cannot support HW virtualization.`); return true; } } @@ -349,7 +353,7 @@ const _composeDevicesString = (devices: Array>) // } // }; -export const runTizenSimOrDevice = async (onlyRun?: true | null) => { +export const runTizenSimOrDevice = async () => { const c = getContext(); const { target } = c.runtime; const { platform } = c; @@ -428,11 +432,6 @@ Please create one and then edit the default target from ${c.paths.workspace.dir} const continueLaunching = async () => { let hasDevice = false; - // if (onlyRun) { - // await execCLI(CLI_TIZEN, `run -p ${tId} -t ${deviceID}`); - // return true; - // } - await execCLI(CLI_TIZEN, `build-web -- "${tBuild}" -out "${intermediate}"`); await execCLI(CLI_TIZEN, `package -- "${intermediate}" -s ${certProfile} -t wgt -o "${tOut}"`); From faf061caaef7fa83717cc1cc49278f1893e774a3 Mon Sep 17 00:00:00 2001 From: Justinas Date: Fri, 20 Sep 2024 10:07:26 +0300 Subject: [PATCH 7/7] changed name of a fuction --- .../src/__tests__/deviceManager.test.ts | 22 +++++++++---------- packages/sdk-tizen/src/deviceManager.ts | 18 +++++++-------- .../sdk-tizen/src/tasks/taskTargetLaunch.ts | 4 ++-- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/packages/sdk-tizen/src/__tests__/deviceManager.test.ts b/packages/sdk-tizen/src/__tests__/deviceManager.test.ts index afd46f927..5ad469dfc 100644 --- a/packages/sdk-tizen/src/__tests__/deviceManager.test.ts +++ b/packages/sdk-tizen/src/__tests__/deviceManager.test.ts @@ -10,7 +10,7 @@ import { inquirerPrompt, ExecOptionsPresets, } from '@rnv/core'; -import { listTizenTargets, launchTizenEmulator } from '../deviceManager'; +import { listTizenTargets, launchTizenTarget } from '../deviceManager'; import { CLI_TIZEN_EMULATOR, CLI_SDB_TIZEN } from '../constants'; const ERROR_MSG = { @@ -84,7 +84,7 @@ describe('listTizenTargets', () => { }); }); -describe('launchTizenEmulator', () => { +describe('launchTizenTarget', () => { it('should launch the specified emulator by name', async () => { const mockContext = { cli: { [CLI_TIZEN_EMULATOR]: 'tizen-emulator' }, platform: 'tizen' }; const ctx = { ...getContext(), ...mockContext }; @@ -92,9 +92,9 @@ describe('launchTizenEmulator', () => { (executeAsync as jest.Mock).mockResolvedValue(true); - const result = await launchTizenEmulator('emulatorName'); + const result = await launchTizenTarget('emulatorName'); - expect(logDefault).toHaveBeenCalledWith('launchTizenEmulator:emulatorName'); + expect(logDefault).toHaveBeenCalledWith('launchTizenTarget:emulatorName'); expect(executeAsync).toHaveBeenCalledWith( 'tizen-emulator launch --name emulatorName', ExecOptionsPresets.SPINNER_FULL_ERROR_SUMMARY @@ -109,7 +109,7 @@ describe('launchTizenEmulator', () => { (execCLI as jest.Mock).mockResolvedValueOnce('emulator1\nemulator2').mockResolvedValueOnce('device1\ndevice2'); (inquirerPrompt as jest.Mock).mockResolvedValue({ chosenEmulator: 'emulator1' }); (executeAsync as jest.Mock).mockResolvedValue(true); - const result = await launchTizenEmulator(true); + const result = await launchTizenTarget(true); expect(execCLI).toHaveBeenCalledWith(CLI_TIZEN_EMULATOR, 'list-vm'); expect(execCLI).toHaveBeenCalledWith(CLI_SDB_TIZEN, 'devices'); expect(inquirerPrompt).toHaveBeenCalledWith({ @@ -136,7 +136,7 @@ describe('launchTizenEmulator', () => { ); (inquirerPrompt as jest.Mock).mockResolvedValue({ chosenEmulator: 'emulator1' }); (executeAsync as jest.Mock).mockResolvedValue(true); - const result = await launchTizenEmulator(true, true); + const result = await launchTizenTarget(true, true); expect(inquirerPrompt).toHaveBeenCalledWith({ name: 'chosenEmulator', type: 'list', @@ -145,7 +145,7 @@ describe('launchTizenEmulator', () => { }); expect(result).toBe(true); }); - it('should show real devices(same conditions as test above, just not passing 2nd param true to launchTizenEmulator) ', async () => { + it('should show real devices(same conditions as test above, just not passing 2nd param true to launchTizenTarget) ', async () => { const mockContext = { cli: { [CLI_TIZEN_EMULATOR]: 'tizen-emulator' }, platform: 'tizen' }; const ctx = { ...getContext(), ...mockContext }; createRnvContext(ctx); @@ -157,7 +157,7 @@ describe('launchTizenEmulator', () => { ); (inquirerPrompt as jest.Mock).mockResolvedValue({ chosenEmulator: 'emulator1' }); (executeAsync as jest.Mock).mockResolvedValue(true); - const result = await launchTizenEmulator(true); + const result = await launchTizenTarget(true); expect(inquirerPrompt).toHaveBeenCalledWith({ name: 'chosenEmulator', type: 'list', @@ -175,7 +175,7 @@ describe('launchTizenEmulator', () => { (execCLI as jest.Mock).mockResolvedValueOnce('emulator1\nemulator2').mockResolvedValueOnce('device1\ndevice2'); (inquirerPrompt as jest.Mock).mockResolvedValue({ chosenEmulator: 'emulator1' }); (executeAsync as jest.Mock).mockResolvedValue(true); - const result = await launchTizenEmulator('unknownEmulator'); + const result = await launchTizenTarget('unknownEmulator'); expect(logError).toHaveBeenCalledWith('The VM/device "unknownEmulator" does not exist.'); expect(execCLI).toHaveBeenCalledWith(CLI_TIZEN_EMULATOR, 'list-vm'); expect(execCLI).toHaveBeenCalledWith(CLI_SDB_TIZEN, 'devices'); @@ -197,11 +197,11 @@ describe('launchTizenEmulator', () => { createRnvContext(ctx); (executeAsync as jest.Mock).mockRejectedValueOnce(ERROR_MSG.ALREADY_RUNNING); - const result = await launchTizenEmulator('runningEmulator'); + const result = await launchTizenTarget('runningEmulator'); expect(logError).toHaveBeenCalledWith('The VM/device "runningEmulator" is already running.'); expect(result).toBe(true); }); it('should reject if no name is specified', async () => { - await expect(launchTizenEmulator('')).rejects.toEqual('No emulator -t target name specified!'); + await expect(launchTizenTarget('')).rejects.toEqual('No emulator -t target name specified!'); }); }); diff --git a/packages/sdk-tizen/src/deviceManager.ts b/packages/sdk-tizen/src/deviceManager.ts index f1842bea8..aab807ae6 100644 --- a/packages/sdk-tizen/src/deviceManager.ts +++ b/packages/sdk-tizen/src/deviceManager.ts @@ -72,9 +72,9 @@ const formatXMLObject = ( return {}; }; -export const launchTizenEmulator = async (name: string | true, hideDevices?: boolean): Promise => { +export const launchTizenTarget = async (name: string | true, hideDevices?: boolean): Promise => { const c = getContext(); - logDefault(`launchTizenEmulator:${name}`); + logDefault(`launchTizenTarget:${name}`); if (name === true) { const emulators = await execCLI(CLI_TIZEN_EMULATOR, 'list-vm'); const devices = await execCLI(CLI_SDB_TIZEN, 'devices'); @@ -120,7 +120,7 @@ export const launchTizenEmulator = async (name: string | true, hideDevices?: boo if (typeof e === 'string') { if (e.includes(ERROR_MSG.UNKNOWN_VM)) { logError(`The VM/device "${name}" does not exist.`); - return launchTizenEmulator(true, hideDevices); + return launchTizenTarget(true, hideDevices); } if (e.includes(ERROR_MSG.ALREADY_RUNNING)) { logError(`The VM/device "${name}" is already running.`); @@ -389,7 +389,7 @@ export const runTizenSimOrDevice = async () => { if (!tId) return Promise.reject(`Tizen platform requires "id" filed in platforms.tizen`); const askForEmulator = async () => { if (!target) { - launchTizenEmulator(true); + launchTizenTarget(true); return; } const { startEmulator } = await inquirerPrompt({ @@ -406,7 +406,7 @@ export const runTizenSimOrDevice = async () => { return; } try { - await launchTizenEmulator(defaultTarget); + await launchTizenTarget(defaultTarget); deviceID = defaultTarget; await _waitForEmulatorToBeReady(defaultTarget); return continueLaunching(); @@ -414,7 +414,7 @@ export const runTizenSimOrDevice = async () => { logDebug(`askForEmulator:ERRROR: ${e}`); try { await execCLI(CLI_TIZEN_EMULATOR, `create -n ${defaultTarget} -p tv-samsung-5.0-x86`); - await launchTizenEmulator(defaultTarget); + await launchTizenTarget(defaultTarget); deviceID = defaultTarget; await _waitForEmulatorToBeReady(defaultTarget); return continueLaunching(); @@ -445,7 +445,7 @@ Please create one and then edit the default target from ${c.paths.workspace.dir} if (typeof e === 'string' && e.includes('No device matching')) { if (target) { isRunningEmulator = true; - await launchTizenEmulator(target); + await launchTizenTarget(target); hasDevice = await _waitForEmulatorToBeReady(target); } else { return Promise.reject('Not target specified. (-t)'); @@ -475,7 +475,7 @@ Please create one and then edit the default target from ${c.paths.workspace.dir} if (target) { isRunningEmulator = true; - await launchTizenEmulator(target); + await launchTizenTarget(target); hasDevice = await _waitForEmulatorToBeReady(target); } else { return Promise.reject('Not target specified. (-t)'); @@ -522,7 +522,7 @@ Please create one and then edit the default target from ${c.paths.workspace.dir} try { // try to launch it, see if it's a emulator that's not started yet isRunningEmulator = true; - await launchTizenEmulator(target); + await launchTizenTarget(target); await _waitForEmulatorToBeReady(target); deviceID = target; return continueLaunching(); diff --git a/packages/sdk-tizen/src/tasks/taskTargetLaunch.ts b/packages/sdk-tizen/src/tasks/taskTargetLaunch.ts index 1e630d2b2..95b68af65 100644 --- a/packages/sdk-tizen/src/tasks/taskTargetLaunch.ts +++ b/packages/sdk-tizen/src/tasks/taskTargetLaunch.ts @@ -1,7 +1,7 @@ import { createTask, RnvTaskName, RnvTaskOptions } from '@rnv/core'; import { getTargetWithOptionalPrompt } from '@rnv/sdk-utils'; import { checkAndConfigureTizenSdks, checkTizenSdk } from '../installer'; -import { launchTizenEmulator } from '../deviceManager'; +import { launchTizenTarget } from '../deviceManager'; import { SdkPlatforms } from '../constants'; export default createTask({ @@ -11,7 +11,7 @@ export default createTask({ await checkAndConfigureTizenSdks(); const target = await getTargetWithOptionalPrompt(); await checkTizenSdk(); - return launchTizenEmulator(target, true); + return launchTizenTarget(target, true); }, task: RnvTaskName.targetLaunch, options: [RnvTaskOptions.target],