Automate
The Automate Module is designed to simplify the process of creating and managing CLI automations in your Flood project. By utilizing your existing CorePondComponents, you can create automations that seamlessly integrate with your application's context. For example, the deploy
automation uses your Drop Repositories to generate Firebase Security Rules, ensuring a smooth deployment process.
AutomateCommand
At the core of the Automate Module is the AutomateCommand
class. It represents a CLI command that can be executed with specific arguments and options. To learn how to create a custom one for your project, refer to the AutomatePondContext page.
Usage
To use the Automate Module in your Flood project, register AutomatePondComponents
to your AutomatePondContext
, and then run Automate.automate(...)
from within the main
function in the tool/automate.dart
file. Automate.automate
will grab the args, find the corresponding AutomateCommand
to run, parse out the parameters, and run the command.
Here's an example of how to set up the AutomatePondContext
:
final automatePondContext = AutomatePondContext(
corePondContext: corePondContext,
);
await automatePondContext.register(GreetComponent());
await Automate.automate(
context: automatePondContext,
args: args,
appDirectoryGetter: (coreDirectory) => coreDirectory.parent / 'app',
);
In this example, we create an instance of AutomatePondContext
and pass in the corePondContext
. We then register a custom GreetComponent using the register
method.
Once the AutomatePondContext
is set up, you can run your automate commands using the following command:
dart tool/automate.dart greet John repeat:3
This will execute the GreetComponent
that you defined and registered.
If you run automate.dart
without any parameters, it will display a "usage" screen with information about each of the available commands.
dart tool/automate.dart
===[Automate Usage]===
greet: Greets the user.
Many of the Pre-Built Modules depend on
dcli (opens in a new tab), which depends on the "dart:cli
waitFor experiment". The Dart team is slowly phasing this
out (opens in a new tab), so you may need to run
dart --enable_deprecated_wait_for tool/automate.dart ...
to circumvent
this for now.
Pre-Built Modules
The Automate Module includes several pre-built modules that provide additional functionality and automation capabilities:
- Release: Manages the release process of your app to app stores and testing frameworks.
- Ops: Automates the deployment of backend resources for your application.
- Native Setup: Simplifies the process of creating app icons and splash screens for your Flutter app.