flutter_workspaces_cli 1.1.1
flutter_workspaces_cli: ^1.1.1 copied to clipboard
A command-line tool for scaffolding and managing monorepo-style Flutter workspace structures.
Flutter Workspaces CLI #
A command-line tool for scaffolding and managing monorepo-style Flutter workspace structures. This CLI automates the creation of a complete Flutter workspace with a core shared package, main application, and proper dependency configuration.
Features #
- โ
Workspace Creation: Automatically creates a
<name>_workspacesfolder and sets up the workspace structure. - ๐ฆ Core Package Scaffolding: Creates a reusable
packages/corepackage for shared code. - ๐ฑ Flutter App Scaffolding: Generates a main Flutter application that imports and uses the core package.
- ๐ฏ Workspace Resolution: Configures
pubspec.yamlfiles with workspace resolution for monorepo support. - ๐ Environment Validation: Checks for Flutter and Dart SDK requirements (Dart 3.6.0+).
- ๐ Dependency Management: Automatically adds common Flutter dependencies (cupertino_icons, flutter_lints, custom_lint).
- ๐งน Error Handling: Reverts workspace creation on failure for clean error states.
Requirements #
- Dart SDK: 3.6.0 or higher
- Flutter SDK: Latest stable version (with Dart 3.6.0+)
- System: macOS, Linux, or Windows with shell support
Installation #
dart pub global activate flutter_workspaces_cli
Usage #
Run the CLI with the required --name argument to create a new workspace:
flutter_workspaces_cli.dart --name my_app
Or use the short flag:
flutter_workspaces_cli.dart -n my_app
What Gets Created #
After running the command, the following structure is created:
my_app_workspaces/
โโโ pubspec.yaml # Root workspace pubspec
โโโ my_app/ # Main Flutter application
โ โโโ lib/
โ โ โโโ main.dart # Main entry point (imports core)
โ โโโ pubspec.yaml
โ โโโ analysis_options.yaml
โโโ packages/
โโโ core/ # Shared core package
โโโ lib/
โ โโโ core.dart
โโโ pubspec.yaml
The root pubspec.yaml includes workspace configuration that allows both the app and core package to be developed together with shared dependency resolution.
Command-Line Arguments #
| Argument | Short | Required | Description |
|---|---|---|---|
--name |
-n |
Yes | The base name for your workspace and app (e.g., my_app) |
Example #
flutter_workspaces_cli.dart --name flutter_monorepo
This creates a workspace named flutter_monorepo_workspaces with all required structure and dependencies.
Exit Codes #
0: Success1: General error (execution failed)64: Missing or invalid arguments (e.g.,--namenot provided)
Error Handling #
If the CLI encounters an error during workspace creation:
- Missing
--nameargument: Prints usage help and exits with code 64 (no workspace created). - Other errors: Reverts the workspace if it was partially created and exits with code 1.
Development #
Running Tests #
Run the test suite to verify all functionality:
dart test
The test suite includes:
- Project name parsing and validation
- Dart version detection and validation
- Flutter installation checks
- Workspace and package file generation
- Pubspec configuration verification
Project Structure #
lib/
โโโ dart_process.dart # Dart SDK detection & validation
โโโ project_name_process.dart # CLI argument parsing
โโโ common_process.dart # Shared utilities
โโโ core_package_process.dart # Core package scaffolding
โโโ flutter_app_process.dart # Flutter app scaffolding
โโโ flutter_process.dart # Flutter SDK checks
โโโ workspace_process.dart # Workspace creation & config
bin/
โโโ flutter_workspaces_cli.dart # Main entry point
test/
โโโ flutter_workspaces_cli_test.dart # Test suite
Contributing #
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/your-feature) - Commit your changes (
git commit -am 'Add your feature') - Push to the branch (
git push origin feature/your-feature) - Open a Pull Request
License #
This project is provided as-is. See LICENSE for details.
Support #
For issues, questions, or suggestions, please open an issue on the GitHub repository.
Author #
Created by ThiagoEvoa
Enjoy building amazing Flutter workspaces! ๐