Skip to content

Commit

Permalink
Merge pull request #1549 from flexn-io/fix/windows-runner
Browse files Browse the repository at this point in the history
Fix(Windows:Runner): Fix web and android path to respective node modules not found
  • Loading branch information
RicardasN authored May 13, 2024
2 parents a14b3f0 + ddbd660 commit 919735b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 11 deletions.
22 changes: 19 additions & 3 deletions packages/engine-rn-next/src/sdk/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,12 @@ export const buildWebNext = async () => {
const c = getContext();
logDefault('buildWebNext');

await executeAsync('npx next build', {

// On Windows npx does not always resolve correct path, hence we manually resolve it here
// https://github.com/flexn-io/renative/issues/1409#issuecomment-2095531486
const nextCmnd = `node ${path.join(path.dirname(require.resolve('next/package.json')), 'dist', 'bin', 'next')}`;
// const nextCmnd = 'npx next';
await executeAsync(`${nextCmnd} build`, {
env: {
...CoreEnvVars.BASE(),
...CoreEnvVars.RNV_EXTENSIONS(),
Expand All @@ -130,7 +135,13 @@ Dev server running at: ${url}
const opts = !c.program?.opts()?.json
? ExecOptionsPresets.INHERIT_OUTPUT_NO_SPINNER
: ExecOptionsPresets.SPINNER_FULL_ERROR_SUMMARY;
return executeAsync(`npx next ${bundleAssets ? 'start' : 'dev'} --port ${c.runtime.port}`, {

// On Windows npx does not always resolve correct path, hence we manually resolve it here
// https://github.com/flexn-io/renative/issues/1409#issuecomment-2095531486
const nextCmnd = `node ${path.join(path.dirname(require.resolve('next/package.json')), 'dist', 'bin', 'next')}`;
// const nextCmnd = 'npx next';

return executeAsync(`${nextCmnd} ${bundleAssets ? 'start' : 'dev'} --port ${c.runtime.port}`, {
env: {
...CoreEnvVars.BASE(),
...CoreEnvVars.RNV_EXTENSIONS(),
Expand All @@ -148,7 +159,12 @@ export const exportWebNext = async () => {

const exportDir = getExportDir(c);

await executeAsync(`npx next build`, {
// On Windows npx does not always resolve correct path, hence we manually resolve it here
// https://github.com/flexn-io/renative/issues/1409#issuecomment-2095531486
const nextCmnd = `node ${path.join(path.dirname(require.resolve('next/package.json')), 'dist', 'bin', 'next')}`;
// const nextCmnd = 'npx next';

await executeAsync(`${nextCmnd} build`, {
env: {
...CoreEnvVars.BASE(),
...CoreEnvVars.RNV_EXTENSIONS(),
Expand Down
18 changes: 12 additions & 6 deletions packages/sdk-react-native/src/androidRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,13 @@ export const runReactNativeAndroid = async (device: { udid?: string } | undefine
const appFolder = getAppFolder();

const udid = device?.udid;
// On Windows npx does not always resolve correct path, hence we manually resolve it here
// https://github.com/flexn-io/renative/issues/1409#issuecomment-2095531486
const reactNativeCmnd = `node ${path.join(path.dirname(require.resolve('react-native')), 'cli.js')}`;
// const reactNativeCmnd = 'npx react-native';

let command = `npx react-native run-android --mode=${signingConfig} --no-packager --main-activity=${
platform === 'androidwear' ? 'MainActivity' : 'SplashActivity'
}`;
let command = `${reactNativeCmnd} run-android --mode=${signingConfig} --no-packager --main-activity=${platform === 'androidwear' ? 'MainActivity' : 'SplashActivity'
}`;

if (udid) {
command += ` --deviceId=${udid}`;
Expand Down Expand Up @@ -126,10 +129,13 @@ export const buildReactNativeAndroid = async () => {
const signingConfig = getConfigProp('signingConfig') || DEFAULTS.signingConfig;
const outputAab = getConfigProp('aab');
const extraGradleParams = getConfigProp('extraGradleParams') || '';
// On Windows npx does not always resolve correct path, hence we manually resolve it here
// https://github.com/flexn-io/renative/issues/1409#issuecomment-2095531486
const reactNativeCmnd = `node ${path.join(path.dirname(require.resolve('react-native')), 'cli.js')}`;
// const reactNativeCmnd = 'npx react-native';

let command = `npx react-native build-android --mode=${signingConfig} --tasks ${
outputAab ? 'bundle' : 'assemble'
}${signingConfig}`;
let command = `${reactNativeCmnd} build-android --mode=${signingConfig} --tasks ${outputAab ? 'bundle' : 'assemble'
}${signingConfig}`;

if (extraGradleParams) {
command += ` --extra-params ${extraGradleParams}`;
Expand Down
3 changes: 2 additions & 1 deletion packages/template-starter/renative.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"tvos",
"webos",
"macos",
"windows",
"tizenwatch",
"kaios",
"chromecast",
Expand Down Expand Up @@ -134,4 +135,4 @@
}
}
}
}
}
2 changes: 1 addition & 1 deletion packages/template-starter/renative.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
{
"paths": ["webpack.config.js"],
"platforms": ["macos", "tizen", "webos", "tizenwatch", "tizenmobile"]
"platforms": ["windows", "macos", "tizen", "webos", "tizenwatch", "tizenmobile"]
}
],
"renative_json": {
Expand Down

0 comments on commit 919735b

Please sign in to comment.