Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 61 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,94 +1,106 @@
## webtrit_phone_tools
# webtrit_phone_tools

WebTrit Phone CLI tools.

Generated by the [Very Good CLI][very_good_cli_link] 🤖
**WebTrit Phone CLI tools** — A comprehensive toolkit for automating the preparation, configuration,
and signing of WebTrit mobile applications.

---

## Getting Started 🚀
## Getting Started

If the CLI application is available on [pub](https://pub.dev), activate globally via:
Activate the CLI globally via **pub.dev**:

```sh
dart pub global activate webtrit_phone_tools

```

Or locally via:
Or install it locally from the source:

```sh
dart pub global activate --source=path <path to this package>
dart pub global activate --source=path <path_to_package>

```

---

## Usage

**Android Keystore Signing**
### Android Keystore Signing

Tools for managing signing keys and certificates.

```sh
# Keystore-generate command
$ webtrit_phone_tools keystore-generate --bundleId="com.webtrit.app" --appendDirectory ../webtrit_phone_keystores
# Keystore-commit command
$ webtrit_phone_tools keystore-commit --bundleId="com.webtrit.app" --appendDirectory ../webtrit_phone_keystores
# Keystore-verify command
$ webtrit_phone_tools keystore-verify ../webtrit_phone_keystores/com.webtrit.app
# Generate a new keystore
$ webtrit_phone_tools keystore-generate --bundleId="com.webtrit.app" --appendDirectory ../keystores

# Commit changes to the keystore repository
$ webtrit_phone_tools keystore-commit --bundleId="com.webtrit.app" --appendDirectory ../keystores

# Verify an existing keystore
$ webtrit_phone_tools keystore-verify ../keystores/com.webtrit.app

```

**Application Resource Configuration:**
### Resources & Configuration

Core commands for fetching assets, translations, and themes.

```sh
# Configure application resources (using configurator tool)
$ webtrit_phone_tools configure --applicationId=$(id) $(KEYSTORES_PATH) --$(BUILD_FLOW)
# Generate configuration files
# Fetch resources (assets, translations, themes)
$ webtrit_phone_tools resources-get --applicationId=<id> --token=<jwt> --keystores-path=<path>

# Generate local configuration files
$ webtrit_phone_tools configurator-generate

# Create demo classic configuration (using configurator tool)
$ webtrit_phone_tools create-demo-classic
# Create metadata (Assetlinks and Apple App Site Association)
$ webtrit_phone_tools assetlinks-generate --bundleId=<id> --appleTeamID=<id> --androidFingerprints=<sha256> --output=<path>

# Create assetlink and apple-app-site-association files
$ webtrit_phone_tools assetlinks-generate --bundleId=$(bundle_id) --appleTeamID=$(team_id) --androidFingerprints=$(SHA256_key) --output=$(out_path) $(metadata_path)
```

**Additional Commands:**
---

# Show CLI version
$ webtrit_phone_tools --version
## Architecture

# Show usage help
$ webtrit_phone_tools --help
```
Complex commands in this toolkit follow the **Orchestrator Pattern**. This design ensures a clean
separation of concerns, making the code easier to test, maintain, and scale.

---
### Layer Responsibilities

**Advanced Usage (Configurator Tool):**
| Layer | Entity | Responsibility |
|----------------|-----------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **Command** | `...Command` | **The Conductor.** Parses CLI arguments, initializes the `Context`, and dictates the execution flow. It contains no data processing logic. |
| **Context** | `...Context` | **The State.** An immutable object that holds all validated parameters (paths, IDs, tokens). It acts as the single source of truth passed between layers. |
| **Services** | `...Fetcher` / `...Service` | **External Data.** Handles interactions with APIs or external databases. Returns clean DTOs or models to the conductor. |
| **Processors** | `...Processor` | **Business Logic & I/O.** Manages data transformation, asset migration, and disk read/write operations. Each processor handles one logical domain. |
| **Util** | `...Util` | **The Toolbox. Stateless logic containing reusable helpers specific to the command’s domain. It handles repetitive tasks like string manipulation, path formatting, or data validation.. |
| **Runners** | `...Runner` | **Infrastructure.** Executes external system commands (`make`, `shell scripts`, etc.) and handles their `stdout` and `stderr` streams. |

These commands are for developers familiar with the `configurator` tool used internally.
### Execution Flow

* [`configurator-resources`](./lib/src/commands/configurator_get_resources_command.dart)
* [`configurator-generate`](./lib/src/commands/configurator_generate_command.dart)
1. **Parsing:** The `Command` extracts raw data from `argResults`.
2. **Contextualization:** A `Context` is built, normalizing paths and validating inputs.
3. **Fetching:** A `Service` retrieves necessary remote data.
4. **Processing:** One or more `Processors` perform file system manipulations or data transforms.
5. **Execution:** If required, a `Runner` triggers external processes to finalize the output.
6. **Exit:** The command returns a standard `ExitCode`.

---

## Providing Assets for Builds

In the Dart CLI, there isn't a mechanism like in Flutter where you can directly store files in executed builds. Instead,
we need to stringify assets before creating the build. This ensures that assets are properly embedded into the Dart
code.
Since Dart CLI tools do not have a native "assets" mechanism like Flutter, we use **stringification
** to embed resources directly into the CLI binary.

To stringify assets, use the `stringify_assets.sh` script. This script converts asset files into Dart code that can be
included in your build.

**Example Usage:**
Run this script before building the package:

```sh
./stringify_assets.sh assets lib/src/gen/stringify_assets.dart
```

This command takes all files in the `assets` directory and converts them into a Dart file located at
`lib/src/gen/stringify_assets.dart`.

Make sure to run this script before creating a build to ensure all assets are properly included.
```

## 📄 Related Documentation
---

See [Shared Makefile Reference](docs/shared_makefile_reference.md) for build flavor logic and usage via Makefile.
## Documentation

[very_good_cli_link]: https://github.com/VeryGoodOpenSource/very_good_cli
For build flavor logic and advanced usage via Makefile, see
the [Shared Makefile Reference](https://www.google.com/search?q=docs/shared_makefile_reference.md).
2 changes: 1 addition & 1 deletion lib/src/command_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class WebtritPhoneToolsCommandRunner extends CompletionCommandRunner<int> {
);

// Add sub commands
addCommand(ConfiguratorGetResourcesCommand(
addCommand(ResourcesGetCommand(
logger: _logger,
httpClient: _httpClient,
datasource: _datasource,
Expand Down
4 changes: 2 additions & 2 deletions lib/src/commands/commands.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export 'assetlinks_generate_command.dart';
export 'configurator_generate_command.dart';
export 'configurator_get_resources_command.dart';
export 'keystore_commit_command.dart';
export 'keystore_generate_command.dart';
export 'keystore_verify_command.dart';
export 'keystore_init_command.dart';
export 'keystore_verify_command.dart';
export 'resources/resources_get_command.dart';
export 'update_command.dart';
Loading
Loading