Skip to content

Commit

Permalink
feat: add scripts to build app in release mode
Browse files Browse the repository at this point in the history
  • Loading branch information
szymonrybczak committed Jun 10, 2024
1 parent 635320d commit 810d8a9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/TesterApp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"private": true,
"scripts": {
"android": "react-native run-android",
"android:release": "node ./scripts/release.js android",
"ios": "react-native run-ios",
"ios:release": "node ./scripts/release.js android",
"start": "react-native webpack-start",
"bundle:android": "react-native webpack-bundle --platform android --entry-file index.js --dev=false --bundle-output build/output/android/index.android.bundle --assets-dest build/output/android/res",
"bundle:ios": "react-native webpack-bundle --platform ios --entry-file index.js --dev=false --bundle-output build/output/ios/main.jsbundle --assets-dest build/output/ios",
Expand Down
35 changes: 35 additions & 0 deletions packages/TesterApp/scripts/release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// script.js
const { execSync } = require('child_process');

function runCommand(command) {
try {
execSync(command, { stdio: 'inherit' });
} catch (error) {
console.error(`Error executing command: ${command}`, error);
process.exit(1);
}
}

function buildIOS() {
runCommand('pnpm bundle:ios');
process.chdir('./ios');
runCommand('bundle exec pod install');
runCommand('npx react-native run-ios --mode "Release"');
}

function buildAndroid() {
console.log('Building Android...');
runCommand('pnpm bundle:android');
runCommand('npx react-native run-android --mode "Release"');
}

// Get argument
const platform = process.argv[2] || '';
if (platform === 'ios') {
buildIOS();
} else if (platform === 'android') {
buildAndroid();
} else {
console.error('Please specify either "ios" or "android" as an argument.');
process.exit(1);
}

0 comments on commit 810d8a9

Please sign in to comment.