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 Tizen #1453

Merged
3 commits merged into from Mar 15, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 5 additions & 26 deletions packages/sdk-tizen/src/deviceManager.ts
Expand Up @@ -289,30 +289,12 @@ const _composeDevicesString = (devices: Array<Pick<TizenDevice, 'id' | 'name'>>)
// }
// };

export const runTizenSimOrDevice = async (
c: RnvContext,
buildCoreWebpackProject?: (c: RnvContext) => Promise<void>
) => {
const { hosted } = c.program;
const { target, engine } = c.runtime;
export const runTizenSimOrDevice = async (c: RnvContext) => {
const { target } = c.runtime;
const { platform } = c;

if (!platform) return;

// const platformConfig = c.buildConfig.platforms?.[platform];
const bundleAssets = getConfigProp(c, platform, 'bundleAssets');
const isHosted = hosted ?? !bundleAssets;
const isLightningEngine = engine?.config.id === 'engine-lightning';
if (!bundleAssets && !hosted) {
// console.log('RUN WEINRE');
}

// if (!platformConfig) {
// throw new Error(
// `runTizen: ${chalk().grey(platform)} not defined in your ${chalk().bold(c.paths.appConfig.config)}`
// );
// }

const appName = getConfigProp(c, platform, 'appName');

if (!appName) {
Expand All @@ -323,6 +305,7 @@ export const runTizenSimOrDevice = async (

const tDir = getPlatformProjectDir(c)!;
const tBuild = path.join(tDir, 'build');
const intermediate = path.join(tDir, 'intermediate');
const tOut = path.join(tDir, 'output');
const tId = getConfigProp(c, platform, 'id');
const certProfile = getConfigProp(c, platform, 'certificateProfile') || DEFAULTS.certificateProfile;
Expand Down Expand Up @@ -375,12 +358,8 @@ Please create one and then edit the default target from ${c.paths.workspace.dir}
const continueLaunching = async () => {
let hasDevice = false;

if (!isLightningEngine && buildCoreWebpackProject) {
// lightning engine handles the build and packaging
!isHosted && (await buildCoreWebpackProject(c));
await execCLI(c, CLI_TIZEN, `build-web -- ${tDir} -out ${tBuild}`);
await execCLI(c, CLI_TIZEN, `package -- ${tBuild} -s ${certProfile} -t wgt -o ${tOut}`);
}
await execCLI(c, CLI_TIZEN, `build-web -- ${tBuild} -out ${intermediate}`);
await execCLI(c, CLI_TIZEN, `package -- ${intermediate} -s ${certProfile} -t wgt -o ${tOut}`);

try {
const packageID = platform === 'tizenwatch' || platform === 'tizenmobile' ? tId.split('.')[0] : tId;
Expand Down
46 changes: 21 additions & 25 deletions packages/sdk-tizen/src/runner.ts
Expand Up @@ -94,14 +94,16 @@ export const configureTizenGlobal = (c: RnvContext) =>
// }
});

const _runTizenSimOrDevice = async (c: RnvContext) => {
try {
await runTizenSimOrDevice(c, buildCoreWebpackProject);
} catch (e) {
// TODO: Capture different errors and react accordingly
return Promise.reject(e);
}
return true;
const _copyRequiredFiles = (c: RnvContext) => {
const tDir = getPlatformProjectDir(c)!;
const tBuild = path.join(tDir, 'build');

const requiredFiles = ['.project', '.tproject', 'config.xml', 'icon.png'];

requiredFiles.map((requiredFile) => {
const requiredFilePath = path.join(tDir, requiredFile);
copyFileSync(requiredFilePath, path.join(tBuild, requiredFile));
});
};

export const runTizen = async (c: RnvContext, target?: string) => {
Expand All @@ -111,24 +113,23 @@ export const runTizen = async (c: RnvContext, target?: string) => {

if (!platform) return;

const isHosted = hosted && !getConfigProp(c, platform, 'bundleAssets');
const bundleAssets = getConfigProp(c, platform, 'bundleAssets') === true;
const isHosted = hosted && !bundleAssets;

if (isHosted) {
const isPortActive = await checkPortInUse(c, platform, c.runtime.port);
if (isPortActive) {
const resetCompleted = await confirmActiveBundler(c);
c.runtime.skipActiveServerCheck = !resetCompleted;
}
logDefault('runTizen', `target:${target} hosted:${!!isHosted}`);
return;
}

logDefault('runTizen', `target:${target} hosted:${!!isHosted}`);
if (isHosted) return;

const bundleAssets = getConfigProp(c, platform, 'bundleAssets') === true;

if (bundleAssets) {
await buildCoreWebpackProject(c);
await _runTizenSimOrDevice(c);
_copyRequiredFiles(c);
await runTizenSimOrDevice(c);
} else {
const isPortActive = await checkPortInUse(c, platform, c.runtime.port);
const isWeinreEnabled = REMOTE_DEBUGGER_ENABLED_PLATFORMS.includes(platform) && !bundleAssets && !hosted;
Expand All @@ -140,19 +141,19 @@ export const runTizen = async (c: RnvContext, target?: string) => {
)} is not running. Starting it up for you...`
);
waitForHost(c, '')
.then(() => _runTizenSimOrDevice(c))
.then(() => runTizenSimOrDevice(c))
.catch(logError);
await runWebpackServer(c, isWeinreEnabled);
} else {
const resetCompleted = await confirmActiveBundler(c);

if (resetCompleted) {
waitForHost(c, '')
.then(() => _runTizenSimOrDevice(c))
.then(() => runTizenSimOrDevice(c))
.catch(logError);
await runWebpackServer(c, isWeinreEnabled);
} else {
await _runTizenSimOrDevice(c);
await runTizenSimOrDevice(c);
}
}
}
Expand All @@ -169,18 +170,13 @@ export const buildTizenProject = async (c: RnvContext) => {
const tDir = getPlatformProjectDir(c)!;

await buildCoreWebpackProject(c);

if (!c.program.hosted) {
_copyRequiredFiles(c);
const tOut = path.join(tDir, 'output');
const tIntermediate = path.join(tDir, 'intermediate');
const tBuild = path.join(tDir, 'build');

const requiredFiles = ['.project', '.tproject', 'config.xml', 'icon.png'];

requiredFiles.map((requiredFile) => {
const requiredFilePath = path.join(tDir, requiredFile);
copyFileSync(requiredFilePath, path.join(tBuild, requiredFile));
});

await execCLI(c, CLI_TIZEN, `build-web -- ${tBuild} -out ${tIntermediate}`);
await execCLI(c, CLI_TIZEN, `package -- ${tIntermediate} -s ${certProfile} -t wgt -o ${tOut}`);

Expand Down
7 changes: 4 additions & 3 deletions packages/sdk-webos/src/runner.ts
Expand Up @@ -40,7 +40,10 @@ export const runWebOS = async (c: RnvContext) => {
const { target } = c.runtime;
const { platform } = c;

const isHosted = hosted && !getConfigProp(c, platform, 'bundleAssets');
if (!platform) return;

const bundleAssets = getConfigProp(c, platform, 'bundleAssets') === true;
const isHosted = hosted && !bundleAssets;

if (isHosted) {
const isPortActive = await checkPortInUse(c, platform, c.runtime.port);
Expand All @@ -52,8 +55,6 @@ export const runWebOS = async (c: RnvContext) => {
return;
}

const bundleAssets = getConfigProp(c, platform, 'bundleAssets') === true;

const env = getConfigProp(c, platform, 'environment');
if (env !== 'production') {
process.env.RNV_INJECTED_WEBPACK_SCRIPTS = `${
Expand Down