Skip to content

Commit

Permalink
Merge pull request #1592 from flexn-io/fix/build-shouldnt-generate
Browse files Browse the repository at this point in the history
npx build for webos/tizen shouldn't build without an emulator downloaded
  • Loading branch information
pavjacko committed Jun 19, 2024
2 parents d50aaac + 2b0829b commit df820c7
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 14 deletions.
4 changes: 1 addition & 3 deletions packages/core/src/configs/buildConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
fsExistsSync,
formatBytes,
mkdirSync,
writeFileSync,
writeFileSync
} from '../system/fs';
import { chalk, logDefault, logWarning, logDebug } from '../logger';
import { getContext } from '../context/provider';
Expand Down Expand Up @@ -49,7 +49,6 @@ export const generateBuildConfig = () => {
logDebug('generateBuildConfig');

const c = getContext();

const extraPlugins = getEnginesPluginDelta();

const mergePathsPublic = [
Expand Down Expand Up @@ -109,7 +108,6 @@ export const generateBuildConfig = () => {

const _generateBuildConfig = (mergePaths: string[], mergeFiles: Array<object | undefined>) => {
const c = getContext();

const cleanPaths = mergePaths.filter((v) => v);
const existsPaths = cleanPaths.filter((v) => {
const exists = fsExistsSync(v);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/system/exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ const execCLI = (cli: string, command: string, opts: ExecOptions = {}) => {
c.buildConfig?.sdks
);
return Promise.reject(
`Location of your cli ${chalk().bold(p)} does not exists. check your ${chalk().bold(
`Location of your cli ${chalk().bold(p)} does not exist. check your ${chalk().bold(
c.paths.workspace.config
)} file if your ${chalk().bold('sdks')} paths are correct`
);
Expand Down
11 changes: 7 additions & 4 deletions packages/sdk-tizen/src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const _isSdkInstalled = (c: RnvContext) => {
return fsExistsSync(getRealPath(sdkPath));
};

const _attemptAutoFix = async (c: RnvContext) => {
const _attemptAutoFix = async (c: RnvContext, shouldThrow?: boolean) => {
logDefault('_attemptAutoFix');

if (!c.files.workspace.config) return;
Expand Down Expand Up @@ -98,15 +98,18 @@ const _attemptAutoFix = async (c: RnvContext) => {
}
}

logDefault(`_attemptAutoFix: no sdks found. searched at: ${getSdkLocations().join(', ')}`);

if (shouldThrow) {
throw new Error(`_attemptAutoFix: no sdks found. searched at: ${getSdkLocations().join(', ')}`);
} else logDefault(`_attemptAutoFix: no sdks found. searched at: ${getSdkLocations().join(', ')}`);

// const setupInstance = PlatformSetup(c);
// await setupInstance.askToInstallSDK(sdkPlatform);
generateBuildConfig();
return true;
};

export const checkTizenSdk = async () => {
export const checkTizenSdk = async (shouldThrow?: boolean) => {
const c = getContext();

logDefault('checkTizenSdk');
Expand All @@ -116,7 +119,7 @@ export const checkTizenSdk = async () => {
c.paths.workspace.config
)} does not exist: ${chalk().bold(_getCurrentSdkPath(c))}`
);
return _attemptAutoFix(c);
return _attemptAutoFix(c, shouldThrow);
}
return true;
};
2 changes: 1 addition & 1 deletion packages/sdk-tizen/src/tasks/taskSdkConfigure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default createTask({
isPrivate: true,
fn: async () => {
await checkAndConfigureTizenSdks();
await checkTizenSdk();
await checkTizenSdk(true);
},
task: RnvTaskName.sdkConfigure,
platforms: SdkPlatforms,
Expand Down
11 changes: 8 additions & 3 deletions packages/sdk-webos/src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const _isSdkInstalled = (c: RnvContext) => {
return fsExistsSync(getRealPath(sdkPath));
};

const _attemptAutoFix = async (c: RnvContext) => {
const _attemptAutoFix = async (c: RnvContext, shouldThrow?: boolean) => {
logDefault('_attemptAutoFix');

if (c.program.opts().hosted) {
Expand Down Expand Up @@ -104,6 +104,11 @@ const _attemptAutoFix = async (c: RnvContext) => {
}
}

if(shouldThrow) {
throw new Error(
`Your ${c.platform} SDK path is not configured. Please update your ${c.paths.workspace.config} file`
);
}
logError(`_attemptAutoFix: no sdks found. searched at: ${SDK_LOCATIONS.join(', ')}`);

// const setupInstance = PlatformSetup(c);
Expand All @@ -112,7 +117,7 @@ const _attemptAutoFix = async (c: RnvContext) => {
return true;
};

export const checkWebosSdk = async () => {
export const checkWebosSdk = async (shouldThrow?: boolean) => {
const c = getContext();

logDefault('checkWebosSdk');
Expand All @@ -122,7 +127,7 @@ export const checkWebosSdk = async () => {
c.paths.workspace.config
)} does not exist: ${chalk().bold(_getCurrentSdkPath(c))}`
);
return _attemptAutoFix(c);
return _attemptAutoFix(c, shouldThrow);
}
return true;
};
1 change: 0 additions & 1 deletion packages/sdk-webos/src/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ export const buildWebOSProject = async () => {
path.join(getPlatformProjectDir()!, 'splashBackground.png'),
path.join(tDir, 'splashBackground.png')
);

await execCLI(CLI_WEBOS_ARES_PACKAGE, `-o ${tOut} ${tDir} -n`);

logSuccess(`Your IPK package is located in ${chalk().cyan(tOut)} .`);
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-webos/src/tasks/taskSdkConfigure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default createTask({
isPrivate: true,
fn: async () => {
await checkAndConfigureWebosSdks();
await checkWebosSdk();
await checkWebosSdk(true);
},
task: RnvTaskName.sdkConfigure,
platforms: SdkPlatforms,
Expand Down

0 comments on commit df820c7

Please sign in to comment.