Skip to content

Commit

Permalink
add scripts, refactor README
Browse files Browse the repository at this point in the history
  • Loading branch information
letwebdev committed Sep 28, 2023
1 parent d8fbb0a commit 40d9227
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 13 deletions.
56 changes: 47 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## known bugs

## Customize configuration
## Customize vite configuration

See [Vite Configuration Reference](https://vitejs.dev/config/).

Expand Down Expand Up @@ -34,34 +34,72 @@ npm run lint

### Recuirements

- Android Studio

- Capacitor
- either of
- Android Studio
- For more details, see [Add Capacitor to your web app](https://capacitorjs.com/docs/getting-started#add-capacitor-to-your-web-app).
- basic Android command-line tools

#### Install basic Android command line tools

1. Download the command line tools zip from [Download Android Studio & App Tools - Android Developers](https://developer.android.com/studio) > Command line tools only

2. Unzip it to `"${ANDROID_HOME}/cmdline-tools/latest"`

3. Add these tools to PATH

For more details, see [Add Capacitor to your web app](https://capacitorjs.com/docs/getting-started#add-capacitor-to-your-web-app)
```sh
export PATH="${ANDROID_HOME}/cmdline-tools/latest/bin:${PATH}" >> "${HOME}/.profile"
source "${HOME}/.profile"
```

4. Accept the licenses

```sh
yes | sdkmanager --licenses
```

### Install extra dependencies
### Install Capacitor

```sh
npm install
```

### Create a Android project
### Create an Android project

```sh
npx cap add android
```

### Build and sync the web code to the native project
### Build

#### With Android Studio

##### Build and Sync the web code to the native project

```sh
npm run sync
```

### Open the project in Android Studio
##### Open Android Studio

```sh
npx cap open android
```

In "app/assets/public/index.html", replace all "/hackernews" with "."
Build -> Build bundle(s) / APK(s) -> Build APK(s)
Build > Build bundle(s) / APK(s) > Build APK(s)

#### With command line tools

##### Set environment variables

- [ANDROID_HOME](https://developer.android.com/tools/variables#android_home)
- [GRADLE_USER_HOME](https://docs.gradle.org/current/userguide/directory_layout.html#dir:gradle_user_home)(optional, defaults to `"${HOME}/.gradle"`)

##### Build and Sync the web code to, then Build the native project

```sh
# The built apk is located at "android/app/build/outputs/apk/debug/app-debug.apk"
npm run build-apk
```
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
"scripts": {
"dev": "vite",
"build": "run-p type-check build-only",
"sync": "npm run build && npm run sync-only",
"preview": "vite preview",
"test:unit": "vitest",
"build-only": "vite build",
"sync-only": "cap sync",
"type-check": "vue-tsc --noEmit -p tsconfig.vitest.json --composite false",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
"format": "prettier --write src/"
"format": "prettier --write src/",
"build-apk": "npm run sync && npm run build-apk-only",
"fix-path-apk": "sed --in-place 's|/hackernews|.|g' 'android/app/src/main/assets/public/index.html'",
"sync": "npm run build && npm run sync-only",
"build-apk-only": "(cd android && bash ./gradlew assembleDebug)",
"sync-only": "cap sync && npm run fix-path-apk"
},
"dependencies": {
"@vueuse/core": "^10.4.1",
Expand Down

0 comments on commit 40d9227

Please sign in to comment.