flutter_workspaces_cli 1.1.1 copy "flutter_workspaces_cli: ^1.1.1" to clipboard
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>_workspaces folder and sets up the workspace structure.
  • ๐Ÿ“ฆ Core Package Scaffolding: Creates a reusable packages/core package for shared code.
  • ๐Ÿ“ฑ Flutter App Scaffolding: Generates a main Flutter application that imports and uses the core package.
  • ๐ŸŽฏ Workspace Resolution: Configures pubspec.yaml files 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: Success
  • 1: General error (execution failed)
  • 64: Missing or invalid arguments (e.g., --name not provided)

Error Handling #

If the CLI encounters an error during workspace creation:

  1. Missing --name argument: Prints usage help and exits with code 64 (no workspace created).
  2. 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:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/your-feature)
  3. Commit your changes (git commit -am 'Add your feature')
  4. Push to the branch (git push origin feature/your-feature)
  5. 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! ๐Ÿš€

1
likes
160
points
283
downloads

Publisher

verified publisherthiagoevoa.com

Weekly Downloads

A command-line tool for scaffolding and managing monorepo-style Flutter workspace structures.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

args, path

More

Packages that depend on flutter_workspaces_cli