Skip to content

Commit

Permalink
Merge pull request #1443 from flexn-io/fix/generateBuildConfig
Browse files Browse the repository at this point in the history
fix generateBuildConfig
  • Loading branch information
mihaiblaga89 authored Mar 6, 2024
2 parents 8124b40 + 1865438 commit a997f44
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
15 changes: 15 additions & 0 deletions packages/core/src/configs/buildConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,19 @@ export const generateBuildConfig = (_c?: RnvContext) => {
logWarning('Cannot save buildConfig as c.paths.project.builds.dir is not defined');
}
}

_checkBuildSchemeIfEngine(c);
};

const _checkBuildSchemeIfEngine = (c: RnvContext) => {
const { scheme } = c.program;
if (!c.platform || !scheme) return;

const platform = c.buildConfig?.platforms?.[c.platform];
if (!platform) return;

const definedEngine = platform.buildSchemes?.[scheme]?.engine;
if (definedEngine) {
platform.engine = definedEngine;
}
};
26 changes: 22 additions & 4 deletions packages/core/src/context/runtime.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import path from 'path';
import { getEngineRunnerByPlatform } from '../engines';
import { isSystemWin } from '../system/is';
import { getRealPath } from '../system/fs';
import { fsExistsSync, fsReadFileSync, getRealPath } from '../system/fs';
import { RnvContext, RnvContextPlatform } from './types';
import { generateRuntimePropInjects } from '../system/injectors';
import { getConfigProp } from './contextProps';
import { logDefault } from '../logger';
import { logDebug, logDefault } from '../logger';

export const configureRuntimeDefaults = async (c: RnvContext) => {
c.runtime.appId = c.files.project?.configLocal?._meta?.currentAppConfigId;

c.runtime.appId = c.files.project?.configLocal?._meta?.currentAppConfigId || _getAppId(c);
if (c.runtime.appId) {
c.runtime.appConfigDir = path.join(c.paths.project.appConfigsDir, c.runtime.appId);
}
logDefault('configureRuntimeDefaults', `appId:${c.runtime.appId}`);

// TODO:
Expand Down Expand Up @@ -77,3 +80,18 @@ export const configureRuntimeDefaults = async (c: RnvContext) => {
}
return true;
};

const _getAppId = (c: RnvContext) => {
logDebug(`_getAppId`);
const localConfigPath = path.join(c.paths.project.dir, 'renative.local.json');
if (!fsExistsSync(localConfigPath)) return undefined;
try {
const fileAsString = fsReadFileSync(localConfigPath).toString();
if (!fileAsString) return undefined;

const appId = JSON.parse(fileAsString)?._meta?.currentAppConfigId;
return appId;
} catch (error) {
return undefined;
}
};

0 comments on commit a997f44

Please sign in to comment.