Skip to content

Commit

Permalink
check ruby before run bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
ngocle2497 committed Sep 14, 2023
1 parent 7075355 commit a7464fb
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 35 deletions.
26 changes: 16 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
## :star: Features

- Elegant usage directly within the RN-Boiler Cli
- Fastlane (App center included)
- Fastlane
- Lefthook
- Boot Splash
- Expo Image
Expand Down Expand Up @@ -43,16 +43,22 @@ npx rn-boiler MyApp

Args command:

- skip install deps:

```sh
--skipInstall
```

- skip init git:

```sh
--skipGit
Usage: rn-boiler <project-name> [options]
Arguments:
project-name Project name
Options:
-v, --version Output the current version
-pm, --package-manager <string> Use different package manager (choices:
"yarn", "bun", "npm", default: "bun")
--skip-install Skip install dependencies. Default: false.
(default: false)
--skip-git Skip git init. Default: false. (default:
false)
--verbose Default: false. (default: false)
-h, --help display help for command
```

<h3>Preview</h3>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "rn-boiler-template",
"private": false,
"version": "1.72.7",
"version": "1.72.10",
"description": "Clean and minimalist React Native template for a quick start with TypeScript and components",
"scripts": {
"test": "exit 0"
Expand Down
10 changes: 5 additions & 5 deletions template/GITLABRUNNER.MD
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ You can config gitlab CI runner to create build automatically.

- Create new repo for gitlab CI
- Create Runner for gitlab CI
- Move fastlane, build_script folder to new repo
- Add new files [README.MD](#readmemd), [.gitlab-ci.yml](#gitlab-ciyml), [pull_repo.sh](#pull_reposh), [release.sh](#releasesh) and [build_script](#build_script) folder to new repo
- Move fastlane, build-ci folder to new repo
- Add new files [README.MD](#readmemd), [.gitlab-ci.yml](#gitlab-ciyml), [pull_repo.sh](#pull_reposh), [release.sh](#releasesh) and [build-ci](#build-ci) folder to new repo

### README.MD

```md
## Requiement

- [rbenv](https://github.com/rbenv/rbenv)
- [rbenv](https://github.com/rbenv/rbenv)(version >= 2.7.6)
- [fnm](https://github.com/Schniz/fnm)
- [fastlane](https://fastlane.tools/)
- [Gitlab-Runner](https://docs.gitlab.com/runner/) for macos. executor should be shell
Expand Down Expand Up @@ -201,7 +201,7 @@ done

```

### build_script
### build-ci

#### build-android.ts

Expand Down Expand Up @@ -310,7 +310,7 @@ import { execSync } from 'child_process';
.
├── fastlane
├── build_script
├── build-ci
│ ├── build-android.ts
│ ├── deploy-android.ts
│ ├── build-ios.ts
Expand Down
5 changes: 3 additions & 2 deletions template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
# Setup

- Setup development environment [React Native CLI](https://reactnative.dev/docs/environment-setup)
- We recommended to use [yarn](https://classic.yarnpkg.com/en/docs/install/#mac-stable)
- Ruby version: 2.7.6 (recommended use [rbenv](https://github.com/rbenv/rbenv) to manage the Ruby programming language)
- Node version >= 18 (recommended use [fnm](https://github.com/Schniz/fnm))
- We recommended to use [yarn](https://classic.yarnpkg.com/en/docs/install/#mac-stable) or [bun](https://bun.sh/)
- Ruby version: 2.7.6 (recommended use [rbenv](https://github.com/rbenv/rbenv))

# Importance before commit

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class MainActivity extends ReactActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
RNBootSplash.init(this);
RNBootSplash.init(this, R.style.BootTheme);
super.onCreate(savedInstanceState);
}

Expand Down
4 changes: 2 additions & 2 deletions template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@
"eslint": "^8.19.0",
"eslint-plugin-import": "^2.27.5",
"jest": "^29.2.1",
"lefthook": "^1.4.5",
"lefthook": "^1.4.11",
"metro-react-native-babel-preset": "0.76.8",
"patch-package": "^6.4.7",
"patch-package": "^8.0.0",
"prettier": "^2.4.1",
"react-native-mmkv-flipper-plugin": "^1.0.0",
"react-test-renderer": "18.2.0",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 25 additions & 0 deletions template/scripts/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,28 @@ import Config from 'react-native-config';

return envJson;
};

export const getRubyVersion = () => {
try {
return Number(
execSync('ruby -e "puts RUBY_VERSION"')
.toString()
.trim()
.split('.')
.join(''),
);
} catch {
return 0;
}
};

export const getAndroidHome = () => {
try {
return (
execSync('echo $ANDROID_HOME').toString().trim() ||
execSync('echo $ANDROID_SDK_ROOT').toString().trim()
);
} catch {
return '';
}
};
48 changes: 34 additions & 14 deletions template/scripts/setup.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,49 @@
import { execSync } from 'child_process';

import { getAndroidHome, getRubyVersion } from './common';

(function () {
execSync('yarn patch-package', { stdio: 'inherit' });

if (getAndroidHome() !== '') {
execSync(`echo "sdk.dir=${getAndroidHome()}" > android/local.properties`, {
stdio: 'inherit',
});
}

if (process.platform === 'darwin') {
execSync('cd ios && touch tmp.xcconfig');

console.log(
' 🧐🧐🧐🧐🧐 Starting bundle install!! 🧐🧐🧐🧐🧐',
);
if (getRubyVersion() < 276) {
console.log(
' 🧐🧐🧐🧐🧐 Installing CocoaPods dependencies!! 🧐🧐🧐🧐🧐',
);

execSync('bundle install', {
stdio: 'inherit',
});
execSync('pod install --project-directory=ios', {
stdio: 'inherit',
});

console.log('bundle install Done!!✨✨✨✨✨');
console.log(' ✨✨✨✨✨ Pod done!!! ✨✨✨✨✨');
} else {
console.log(
' 🧐🧐🧐🧐🧐 Installing Bundle dependencies!! 🧐🧐🧐🧐🧐',
);

console.log(
' 🧐🧐🧐🧐🧐 Starting pod install!! 🧐🧐🧐🧐🧐',
);
execSync('bundle install', {
stdio: 'inherit',
});

execSync('bundle exec pod install --project-directory=ios', {
stdio: 'inherit',
});
console.log('bundle install Done!!✨✨✨✨✨');

console.log(
' 🧐🧐🧐🧐🧐 Installing CocoaPods dependencies!! 🧐🧐🧐🧐🧐',
);

execSync('bundle exec pod install --project-directory=ios', {
stdio: 'inherit',
});

console.log(' ✨✨✨✨✨ Pod done!!! ✨✨✨✨✨');
console.log(' ✨✨✨✨✨ Pod done!!! ✨✨✨✨✨');
}
}
})();

0 comments on commit a7464fb

Please sign in to comment.