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 Kaios template starter #1491

Merged
merged 5 commits into from Apr 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/engine-rn-web/src/index.ts
Expand Up @@ -51,7 +51,7 @@ const Engine = createRnvEngine({
kaios: {
defaultPort: 8093,
isWebHosted: true,
extensions: ['kaios.mobile', 'mobile', 'kaios', 'mobile.web', 'native'],
extensions: ['kaios', 'kaios.mobile', 'mobile', 'mobile.web', 'native', 'web'],
},
},
});
Expand Down
2 changes: 1 addition & 1 deletion packages/engine-rn-web/src/tasks/taskDebug.ts
Expand Up @@ -6,5 +6,5 @@ export default createTask({
return executeAsync('npx weinre --boundHost -all-');
},
task: RnvTaskName.debug,
platforms: ['web', 'webtv', 'tizen'],
platforms: ['web', 'webtv', 'tizen', 'kaios'],
});
5 changes: 4 additions & 1 deletion packages/engine-rn-web/src/tasks/taskRun.ts
Expand Up @@ -99,7 +99,10 @@ export default createTask({
}
return runWebOS(ctx);
case 'kaios':
return runKaiOSProject();
if (!ctx.program.opts().only) {
await _configureHostedIfRequired(ctx);
}
return runKaiOSProject(ctx);
case 'chromecast':
if (!ctx.program.opts().only) {
await _configureHostedIfRequired(ctx);
Expand Down
15 changes: 0 additions & 15 deletions packages/engine-rn-web/templates/platforms/kaios/manifest.webapp

This file was deleted.

@@ -0,0 +1,15 @@
{
"name": "{{APP_TITLE}}",
"description": "{{APP_DESCRIPTION}}",
"start_url": "/index.html",
"icons": {
"16": "/icons/icon16x16.png",
"48": "/icons/icon48x48.png",
"60": "/icons/icon60x60.png",
"128": "/icons/icon128x128.png"
},
"developer": {
"name": "{{AUTHOR_NAME}}",
"url": "{{AUTHOR_URL}}"
}
}
3 changes: 3 additions & 0 deletions packages/renative/src/api/platform/index.kaios.ts
@@ -0,0 +1,3 @@
import { Platform } from '../../constants';

export default Platform.kaios;
72 changes: 64 additions & 8 deletions packages/sdk-kaios/src/runner.ts
@@ -1,4 +1,4 @@
import { buildCoreWebpackProject, configureCoreWebProject } from '@rnv/sdk-webpack';
import { buildCoreWebpackProject, configureCoreWebProject, runWebpackServer } from '@rnv/sdk-webpack';
import path from 'path';
import {
getPlatformProjectDir,
Expand All @@ -9,10 +9,23 @@ import {
copyBuildsFolder,
copyAssetsFolder,
getContext,
getConfigProp,
chalk,
logError,
logInfo,
RnvContext,
} from '@rnv/core';
import { launchKaiOSSimulator } from './deviceManager';

import { getAppAuthor, getAppDescription, getAppTitle } from '@rnv/sdk-utils';
import {
REMOTE_DEBUGGER_ENABLED_PLATFORMS,
checkPortInUse,
confirmActiveBundler,
getAppAuthor,
getAppDescription,
getAppTitle,
waitForHost,
} from '@rnv/sdk-utils';

export const configureKaiOSProject = async () => {
const c = getContext();
Expand All @@ -34,8 +47,7 @@ const _configureProject = () =>
if (!isPlatformActive(resolve)) return;

const appFolder = getPlatformProjectDir();

const manifestFilePath = path.join(appFolder!, 'manifest.webapp');
const manifestFilePath = path.join(appFolder!, 'public/manifest.webapp');
const manifestFile = JSON.parse(fsReadFileSync(manifestFilePath).toString());

manifestFile.name = `${getAppTitle()}`;
Expand All @@ -47,12 +59,56 @@ const _configureProject = () =>
resolve();
});

export const runKaiOSProject = async () => {
export const runKaiOSProject = async (c: RnvContext) => {
logDefault('runKaiOSProject');
const { platform } = c;
const { hosted } = c.program.opts();

await buildCoreWebpackProject();
await launchKaiOSSimulator(true);
return true;
if (!platform) return;

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

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

if (bundleAssets) {
await buildCoreWebpackProject();
await launchKaiOSSimulator(true);
} else {
const isPortActive = await checkPortInUse(c.runtime.port);
const isWeinreEnabled = REMOTE_DEBUGGER_ENABLED_PLATFORMS.includes(platform) && !bundleAssets && !hosted;

if (!isPortActive) {
logInfo(
`Your ${chalk().bold(platform)} devServer at port ${chalk().bold(
c.runtime.port
)} is not running. Starting it up for you...`
);
waitForHost('')
.then(() => launchKaiOSSimulator(true))
.catch(logError);
await runWebpackServer(isWeinreEnabled);
} else {
const resetCompleted = await confirmActiveBundler();

if (resetCompleted) {
waitForHost('')
.then(() => launchKaiOSSimulator(true))
.catch(logError);
await runWebpackServer(isWeinreEnabled);
} else {
await launchKaiOSSimulator(true);
}
}
}
};

export const buildKaiOSProject = async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-utils/src/constants.ts
@@ -1,3 +1,3 @@
import { RnvPlatformKey } from '@rnv/core';

export const REMOTE_DEBUGGER_ENABLED_PLATFORMS: RnvPlatformKey[] = ['tizen', 'tizenmobile', 'tizenwatch'];
export const REMOTE_DEBUGGER_ENABLED_PLATFORMS: RnvPlatformKey[] = ['kaios', 'tizen', 'tizenmobile', 'tizenwatch'];