Skip to content

Commit

Permalink
open-source code
Browse files Browse the repository at this point in the history
  • Loading branch information
mlsmaycon committed Feb 28, 2024
0 parents commit 036d816
Show file tree
Hide file tree
Showing 321 changed files with 75,197 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
root: true,
extends: '@react-native-community',
};
69 changes: 69 additions & 0 deletions .github/workflows/build-debug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: build debug

on:
push:
branches:
- main
pull_request:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Java
uses: actions/setup-java@v3
with:
java-version: "11"
distribution: "adopt"
cache: "gradle"
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '19'
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: "1.21.x"
- name: Setup Android SDK
uses: android-actions/setup-android@v3
with:
cmdline-tools-version: 8512546
- name: NDK Cache
id: ndk-cache
uses: actions/cache@v3
with:
path: /usr/local/lib/android/sdk/ndk
key: ndk-cache-23.1.7779620
- name: Setup NDK
run: /usr/local/lib/android/sdk/cmdline-tools/7.0/bin/sdkmanager --install "ndk;23.1.7779620"
- name: Checkout netbird repository
uses: actions/checkout@v3
with:
repository: netbirdio/netbird
ref: main
path: netbird
- name: install gomobile
run: go install golang.org/x/mobile/cmd/[email protected]
- name: build android nebtird lib
run: PATH=$PATH:$(go env GOPATH)/bin bash -x build-android-lib.sh $GITHUB_WORKSPACE/netbird
env:
ANDROID_NDK_HOME: /usr/local/lib/android/sdk/ndk/23.1.7779620
- name: add react-native lib
run: yarn add file:./react/netbird-lib
- name: yarn install deps
run: yarn install
- name: npx reacti-native bundle
run: npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
- name: create empty local.properties
run: touch android/local.properties
- name: build debug apk
run: cd android && ./gradlew assembleDebug
- name: upload non tags for debug purposes
uses: actions/upload-artifact@v2
with:
name: debug-apk
path: android/app/build/outputs/apk/debug/app-debug.apk
retention-days: 1
45 changes: 45 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: test react-native

on:
push:
branches:
- main
pull_request:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Java
uses: actions/setup-java@v3
with:
java-version: "11"
distribution: "adopt"
cache: "gradle"
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '19'
cache: yarn
- name: Setup Android SDK
uses: android-actions/setup-android@v3
with:
cmdline-tools-version: 8512546
- name: install react-native lib dependencies
run: yarn install
working-directory: react/netbird-lib
- name: run npm prepack
run: npm run prepack
working-directory: react/netbird-lib
- name: add react-native lib
run: yarn add file:./react/netbird-lib
- name: yarn install deps
run: yarn install
- name: npx reacti-native bundle
run: npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
- name: create empty local.properties
run: touch android/local.properties
- name: run npm tests
run: npm test
81 changes: 81 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# OSX
#
.DS_Store

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
ios/.xcode.env.local

# Android/IntelliJ
#
build/
.idea
.gradle
local.properties
*.iml
*.hprof
.cxx/

# node.js
#
node_modules/
npm-debug.log
yarn-error.log

# jest
.jest/

# BUCK
buck-out/
\.buckd/
*.keystore
!debug.keystore

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/

**/fastlane/report.xml
**/fastlane/Preview.html
**/fastlane/screenshots
**/fastlane/test_output

# Bundle artifact
*.jsbundle

# Ruby / CocoaPods
/ios/Pods/
/vendor/bundle/

src/utils/graphql/*

android/netbird/*.aar
android/netbird/*.jar
android/netbird/build/
android/tool/*.aar
android/tool/*.jar
android/tool/build/
android/app/src/main/assets/index.android.bundle
android/app/src/main/res/drawable-*/src_*
android/app/src/main/res/drawable-*/node_modules_*
google-services.json
lefthook.yml
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18.12.1
7 changes: 7 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
arrowParens: 'avoid',
bracketSameLine: true,
bracketSpacing: false,
singleQuote: true,
trailingComma: 'all',
};
6 changes: 6 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source 'https://rubygems.org'

# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
ruby File.read(File.join(__dir__, '.ruby-version')).strip

gem 'cocoapods', '~> 1.11', '>= 1.11.3'
98 changes: 98 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (3.0.6)
rexml
activesupport (7.0.4.3)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
addressable (2.8.1)
public_suffix (>= 2.0.2, < 6.0)
algoliasearch (1.27.5)
httpclient (~> 2.8, >= 2.8.3)
json (>= 1.5.1)
atomos (0.1.3)
claide (1.1.0)
cocoapods (1.12.0)
addressable (~> 2.8)
claide (>= 1.0.2, < 2.0)
cocoapods-core (= 1.12.0)
cocoapods-deintegrate (>= 1.0.3, < 2.0)
cocoapods-downloader (>= 1.6.0, < 2.0)
cocoapods-plugins (>= 1.0.0, < 2.0)
cocoapods-search (>= 1.0.0, < 2.0)
cocoapods-trunk (>= 1.6.0, < 2.0)
cocoapods-try (>= 1.1.0, < 2.0)
colored2 (~> 3.1)
escape (~> 0.0.4)
fourflusher (>= 2.3.0, < 3.0)
gh_inspector (~> 1.0)
molinillo (~> 0.8.0)
nap (~> 1.0)
ruby-macho (>= 2.3.0, < 3.0)
xcodeproj (>= 1.21.0, < 2.0)
cocoapods-core (1.12.0)
activesupport (>= 5.0, < 8)
addressable (~> 2.8)
algoliasearch (~> 1.0)
concurrent-ruby (~> 1.1)
fuzzy_match (~> 2.0.4)
nap (~> 1.0)
netrc (~> 0.11)
public_suffix (~> 4.0)
typhoeus (~> 1.0)
cocoapods-deintegrate (1.0.5)
cocoapods-downloader (1.6.3)
cocoapods-plugins (1.0.0)
nap
cocoapods-search (1.0.1)
cocoapods-trunk (1.6.0)
nap (>= 0.8, < 2.0)
netrc (~> 0.11)
cocoapods-try (1.2.0)
colored2 (3.1.2)
concurrent-ruby (1.2.2)
escape (0.0.4)
ethon (0.16.0)
ffi (>= 1.15.0)
ffi (1.15.5)
fourflusher (2.3.1)
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
httpclient (2.8.3)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
json (2.6.3)
minitest (5.18.0)
molinillo (0.8.0)
nanaimo (0.3.0)
nap (1.1.0)
netrc (0.11.0)
public_suffix (4.0.7)
rexml (3.2.5)
ruby-macho (2.5.1)
typhoeus (1.4.0)
ethon (>= 0.9.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
xcodeproj (1.22.0)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.3.0)
rexml (~> 3.2.4)

PLATFORMS
ruby

DEPENDENCIES
cocoapods (~> 1.11, >= 1.11.3)

RUBY VERSION
ruby 2.7.6p219

BUNDLED WITH
2.1.4
69 changes: 69 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# NetBird android client
## Testing
### requirements
We need the following software:
* Java 1.11. Usually comes with android studio
* android studio initialized with jdk and emulator (not covered here, is a req from android-client and react-native-app projects)
* gradle (https://gradle.org/install/)
* npm 1.18, yarn and nvm:
```shell
# download and install nvm https://github.com/nvm-sh/nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
#
nvm install v19
nvm use v19
npm install -g yarn
npm install -g npx
```

### run locally
1. close all repositories:
> assuming you use a path like ~/projects locally
```shell
mkdir ~/projects
cd projects
# clone netbird repo
git clone [email protected]:netbirdio/netbird.git
# clone react native app repo
git clone [email protected]:netbirdio/react-native-app.git
```
2. Checkout the repositories to the branches you want to test. If you want the latest, check the status information on your IDE or on https://github.com and verify the branch list and commit history.
3. export JDK and Android home vars, on macOS they are: (please contribute with Linux equivalent)
```shell
# replace <USERNAME> with your name
export ANDROID_HOME=/Users/<USERNAME>/Library/Android/sdk
export JAVA_HOME=/Applications/Android Studio.app/Contents/jbr/Contents/Home
```
4. Install NDK and CMake
```shell
cd ~/projects/react-native-app
$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install "ndk;23.1.7779620"
```
5. Build the gomobile lib and the android client lib:
````shell
cd ~/projects/react-native-app
bash -x build-android-lib.sh ~/projects/netbird
````
6. Install the react native app dependencies
```shell
yarn install
yarn add file:./react/netbird-lib
```
7. Run the dev version
```shell
yarn start
```
8. select `a` to install it on your android phone or emulator

### generate debug bundle
Follow the steps to run locally until the step 5 then run the following steps:
1. run npx from react native app repo
```shell
cd ~/projects/react-native-app
npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
```
2. run gradlew
```shell
cd ~/projects/react-native-app/android
./gradlew bundleDebug
```
Loading

0 comments on commit 036d816

Please sign in to comment.