Skip to content

Commit

Permalink
docs: CLI - portals serve android (#268)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlpoole committed Mar 13, 2024
1 parent 3c7ea0b commit e303eb8
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 5 deletions.
88 changes: 88 additions & 0 deletions website/docs/cli/commands/serve-android.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
title: CLI Command - serve android
sidebar_label: serve android
---

The `portals serve android` command is a tool for web developers to debug and test their
web code in different Portal configurations on an emulator or a device without having
to go through the build process of a native application or even have access to its
source code. The command allows web developers to run their web code from their local
dev server and see the changes on the fly.

:::note

The serve command requires Ionic Portals 0.9.0 or higher and requires that the portal
has [`devMode`](https://ionic.io/docs/portals-android-api-ref/-ionic-portals/io.ionic.portals/-portal/index.html#-813353364%2FProperties%2F-149544105) set to `true`.

:::

### Requirements

The following environment variables must be set in order for the `portals serve android` command to function correctly:

- Set the `$ANDROID_HOME` variable to the path of the Android SDK installation directory.
- Set the `$JAVA_HOME` variable to the path of the Java SDK installation directory.

### Usage
```bash
portals serve android \
--application /path/to/your/android-app.apk \
--dev-server http://10.0.2.2:8100
```
This command will present an interactive list of eligible destinations since no specific device details were provided. When selected, the command will launch the Android app to the selected device and will override all portals with the content served from the development server URL by default. If a capacitor.config.{json, ts, js} file is located in the current working directory, it will use that, otherwise it will fallback to any configuration potentially shipped in the application.

:::note

If the local dev server is set to `localhost` the CLI will attempt to help you by correcting this host to `10.0.2.2` for running in an emulator. Android emulators are unable to reach the host machine through `localhost` as this is reserved as the loopback address for reaching the emulator itself. Make sure to set the dev server address correctly if you need to reach it via your local network from a real Android device.

:::

### Examples

#### Specify capacitor configuration file

```bash
portals serve android \
--application /path/to/your/android-app.apk \
--dev-server http://10.0.2.2:8100 \
--capacitor-config /path/to/your/capacitor.config.ts
```

#### Specify device details

If you know the specific device ID of the emulator or device you want to target, you can use the `--device-id` flag:

```bash
portals serve android \
--application /path/to/your/android-app.apk \
--dev-server http://10.0.2.2:8100 \
--device-id "emulator-5554"
```

:::note

The ID of the emulator or device is the ID shown when running [`adb devices`](https://developer.android.com/tools/adb#devicestatus).

:::

#### Specify portal name

If you want to override only portals with a specific name, use the `--portal-name` flag:

```bash
portals serve android \
--application /path/to/your/android-app.apk \
--dev-server http://10.0.2.2:8100 \
--portal-name "profile"
```
### Flags:
- `--device-id` **(string)** The ID of the target device.
- `-h, --help` help for android

### Global Flags:
- `--application` **(string)** Path to the native application. (required)
- `--dev-server` **(string)** URL of the development server. (required)
- `--capacitor-config` **(string)** Path to the capacitor configuration file.
- `--portal-name` **(string)** The name of the target Portal. (default "PORTAL")
- `--config` **(string)** config file (default $PWD/.portals.yaml)

2 changes: 1 addition & 1 deletion website/docs/cli/commands/serve-ios.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ portals serve ios [simulator | device] \
--application /path/to/your/ios.app \
--dev-server http://localhost:8100
```
This command will present an interactive list of eligible destination since no specific device details were provided. When selected, the command will launch the iOS app to the selected device and will override all portals with the content served from the development server URL by default. If a capacitor.config.{json, ts, js} file is located in the current working directory, it will use that, otherwise it will fallback to any configuration potentially shipped in the application.
This command will present an interactive list of eligible destinations since no specific device details were provided. When selected, the command will launch the iOS app to the selected device and will override all portals with the content served from the development server URL by default. If a capacitor.config.{json, ts, js} file is located in the current working directory, it will use that, otherwise it will fallback to any configuration potentially shipped in the application.

### Examples

Expand Down
6 changes: 3 additions & 3 deletions website/docs/cli/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ curl -sL https://raw.githubusercontent.com/ionic-team/portals-cli-releases/main/

For Windows users, manual installation is currently required. You can download the appropriate zip file for your architecture (arm64, i386, or x86_64) from the list provided and extract it to a directory on your system's `PATH` for convenient access.

- [arm64](https://github.com/ionic-team/portals-cli-releases/releases/latest/downloads/portals_Windows_arm64.zip)
- [i386](https://github.com/ionic-team/portals-cli-releases/releases/latest/downloads/portals_Windows_i386.zip)
- [x86_64](https://github.com/ionic-team/portals-cli-releases/releases/latest/downloads/portals_Windows_x86_64.zip)
- [arm64](https://github.com/ionic-team/portals-cli-releases/releases/latest/download/portals_Windows_arm64.zip)
- [i386](https://github.com/ionic-team/portals-cli-releases/releases/latest/download/portals_Windows_i386.zip)
- [x86_64](https://github.com/ionic-team/portals-cli-releases/releases/latest/download/portals_Windows_x86_64.zip)

### Linux Binaries

Expand Down
2 changes: 1 addition & 1 deletion website/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ module.exports = {
type: "category",
label: "Command Reference",
collapsed: true,
items: ["cli/commands/poc", "cli/commands/sync", "cli/commands/serve-ios"],
items: ["cli/commands/poc", "cli/commands/sync", "cli/commands/serve-ios", "cli/commands/serve-android"],
},
],
},
Expand Down

0 comments on commit e303eb8

Please sign in to comment.