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
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bricks/** text eol=lf
lib/src/bundles/** text eol=lf
20 changes: 17 additions & 3 deletions .github/workflows/xdevs_cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
pull_request:
paths:
- ".github/workflows/xdevs_cli.yaml"
- ".gitattributes"
- "analysis_options.yaml"
- "bricks/**"
- "lib/**"
- "test/**"
- "pubspec.yaml"
Expand All @@ -12,6 +15,9 @@ on:
- main
paths:
- ".github/workflows/xdevs_cli.yaml"
- ".gitattributes"
- "analysis_options.yaml"
- "bricks/**"
- "lib/**"
- "test/**"
- "pubspec.yaml"
Expand All @@ -20,18 +26,26 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup Dart
uses: dart-lang/setup-dart@v1
with:
sdk: "3.11.0"
sdk: "3.14.0"

- name: Install Dependencies
run: dart pub get

- name: Verify Formatting
run: dart format --output=none --set-exit-if-changed .
run: dart format --output=none --set-exit-if-changed bin lib test

- name: Verify Bundles Are Up To Date
run: |
dart pub global activate mason_cli
dart pub global run mason_cli:mason bundle ./bricks/base_project -t dart -o ./lib/src/bundles
dart pub global run mason_cli:mason bundle ./bricks/feature_module -t dart -o ./lib/src/bundles
dart format lib/src/bundles
git diff --exit-code -- lib/src/bundles

- name: Analyze Project
run: dart analyze --fatal-infos
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 0.1.0

- Fixed generated projects so they compile and analyze cleanly with `material_ui`, `cupertino_ui`, Riverpod and `minimal_mvn`.
- Added selectable state management via `--state-management`, `-s` and `--sm`.
- Added selectable UI style via `--ui`, with `adaptive` as the default.
- Added `manifest` for agents and scripts, plus `--json` output on `create` and `feature`.
- Added `.xdevs_cli.json` so `feature` reuses the project configuration.
- Fixed Windows process arguments, feature dependencies, `build_runner`, exit codes and non-interactive `config`.
- Stopped overwriting `pubspec.yaml`, `.gitignore` and `README.md` created by Flutter.

## 0.0.1

- Initial version.
88 changes: 57 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,68 +2,94 @@

[![License: MIT][license_badge]][license_link]

A Flutter Command-Line Interface designed by [XitoDev](https://github.com/XitoDev) to quickly bootstrap scalable Flutter projects and feature modules based on Clean Architecture principles.
A Flutter CLI by [XitoDev](https://github.com/XitoDev) that scaffolds complete, compilable projects with Clean Architecture, GoRouter, adaptive UI and selectable state management.

---
### What is included

## What's included? 📦
- **UI**: `material_ui`, `cupertino_ui`, or `adaptive` (default) selected at creation time.
- **State management**: `riverpod` (default) or `minimal_mvn`.
- **Routing**: `go_router` with a working sample route.
- **Sample feature**: datasource, model, repository, entity, use case, state and screen.
- **Agent support**: `AGENTS.md` and `.xdevs_cli.json` in every generated project.
- **Code generation**: `build_runner` runs automatically for Riverpod.

When you generate a project with `xdevs_cli`, it comes pre-configured with:
`flutter create` owns `pubspec.yaml`, `.gitignore` and `README.md`; the brick only adds `lib/`, `test/` and the agent instructions.

- **State Management**: [Riverpod](https://pub.dev/packages/flutter_riverpod)
- **Routing**: [GoRouter](https://pub.dev/packages/go_router)
- **Code Generation & Data Models**: [Dart Mappable](https://pub.dev/packages/dart_mappable)
- **Linter**: Strictly follows Very Good Analysis rules.

## Getting Started 🚀

Activate globally via [pub.dev](https://pub.dev):
## Getting started

```sh
dart pub global activate xdevs_cli
```

## Usage
## For humans and agents

### Create a new project
Agents should not guess flags. Read the machine-readable manifest:

This command creates a complete Flutter app configured with Riverpod, GoRouter, and Dart Mappable.
```sh
xdevs_cli manifest
```

It returns a JSON document with commands, options, aliases, defaults, examples and exit codes. `create` and `feature` also accept `--json` and print exactly one JSON result line on stdout.

## Create a project

```sh
xdevs_cli create my_app
xdevs_cli create my_app -s minimal_mvn --ui adaptive
xdevs_cli create my_app --sm riverpod --ui cupertino --json
```

### Create new features
| Option | Values | Default |
| --- | --- | --- |
| `--state-management`, `-s`, `--sm` | `riverpod`, `minimal_mvn` | `riverpod` |
| `--ui` | `material`, `cupertino`, `adaptive` | `adaptive` |
| `--org`, `-o` | reverse-domain org | `com.example` |
| `--platforms`, `-p` | comma-separated platforms | all Flutter platforms |
| `--description`, `-d` | project description | generated description |
| `--directory` | existing base directory | current directory |
| `--json` | single JSON result on stdout | off |

Navigate to your project (or any folder inside it) and create one or multiple features at once. This scaffolds the Domain, Data, and Presentation layers for you.
The created project is ready to run:

```sh
# Enter the project
cd my_app
flutter run
```

# Create a single feature
xdevs_cli feature settings
## Create features

# Create multiple features at once (comma-separated)
Run this inside the project or pass `--directory`:

```sh
xdevs_cli feature auth
xdevs_cli feature auth,home,profile
xdevs_cli f orders --json
```

**Tip:** You can use the short alias `f` instead of `feature`:
Existing features are skipped. State management and UI style are read from `.xdevs_cli.json`, so features match the project.

## Configure defaults

```sh
xdevs_cli f orders
xdevs_cli config --state-management minimal_mvn --ui material
xdevs_cli config --org com.mycompany --platforms android,ios,web
```

## Running Tests 🧪
Without a terminal, at least one option is required.

To run all unit tests with coverage:
## Exit codes

`0` success, `64` usage error, `65` data error, `70` software error.

## Development

```sh
dart pub global activate coverage
dart test --coverage=coverage
dart pub global run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info
dart pub get
dart run build_runner build -d
dart format bin lib test
dart analyze --fatal-infos
dart test
```

---

[license_badge]: https://img.shields.io/badge/license-MIT-blue.svg
[license_link]: https://opensource.org/licenses/MIT
[license_link]: https://opensource.org/licenses/MIT
1 change: 1 addition & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ include: package:very_good_analysis/analysis_options.yaml
analyzer:
exclude:
- "bricks/**"
- "example/**"

linter:
rules:
Expand Down
7 changes: 0 additions & 7 deletions bricks/base_project/__brick__/.gitignore

This file was deleted.

24 changes: 24 additions & 0 deletions bricks/base_project/__brick__/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# {{project_name.snakeCase()}}

Generado con `xdevs_cli`. La configuración exacta está en `.xdevs_cli.json`.

## Comandos

```sh
flutter pub get
{{#is_riverpod}}
dart run build_runner build -d
{{/is_riverpod}}
flutter analyze
flutter test
xdevs_cli feature <feature_name>
xdevs_cli feature auth,home,profile
```

## Arquitectura

- `lib/features/<feature>/domain`: entidades, repositorios abstractos y casos de uso; sin dependencias de UI.
- `lib/features/<feature>/data`: datasources, modelos y repositorios concretos.
- `lib/features/<feature>/presentation`: estado, pantallas y widgets.

Al añadir una feature, usa `xdevs_cli feature <nombre>` en lugar de crear archivos a mano. Lee `.xdevs_cli.json` para saber qué manejo de estado y estilo UI usa este proyecto.
45 changes: 0 additions & 45 deletions bricks/base_project/__brick__/README.md

This file was deleted.

3 changes: 1 addition & 2 deletions bricks/base_project/__brick__/lib/core/themes/app_theme.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';

class AppTheme {
const AppTheme._();

static ThemeData get light {
return ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.teal),
useMaterial3: true,
);
}
}
36 changes: 34 additions & 2 deletions bricks/base_project/__brick__/lib/features/app/app.dart
Original file line number Diff line number Diff line change
@@ -1,17 +1,49 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
{{#ui_material}}
import 'package:material_ui/material_ui.dart' as material;
{{/ui_material}}
{{#ui_cupertino}}
import 'package:cupertino_ui/cupertino_ui.dart' as cupertino;
{{/ui_cupertino}}
{{#ui_adaptive}}
import 'package:flutter/foundation.dart'
show TargetPlatform, defaultTargetPlatform;
import 'package:material_ui/material_ui.dart' as material;
import 'package:cupertino_ui/cupertino_ui.dart' as cupertino;
{{/ui_adaptive}}

import 'app_router.dart';
{{^ui_cupertino}}
import '../../core/themes/app_theme.dart';
{{/ui_cupertino}}

class App extends StatelessWidget {
const App({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp.router(
{{#ui_adaptive}}
final isCupertino = defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform == TargetPlatform.macOS;
if (isCupertino) {
return cupertino.CupertinoApp.router(
debugShowCheckedModeBanner: false,
routerConfig: appRouter,
);
}
{{/ui_adaptive}}
{{#ui_cupertino}}
return cupertino.CupertinoApp.router(
debugShowCheckedModeBanner: false,
routerConfig: appRouter,
);
{{/ui_cupertino}}
{{^ui_cupertino}}
return material.MaterialApp.router(
debugShowCheckedModeBanner: false,
routerConfig: appRouter,
theme: AppTheme.light,
);
{{/ui_cupertino}}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import 'package:go_router/go_router.dart';

import 'package:{{project_name.snakeCase()}}/features/features_screens.dart';
import 'package:{{project_name.snakeCase()}}/features/sample/presentation/views/sample_screen.dart';

final appRouter = GoRouter(
routes: [GoRoute(path: '/', builder: (_, _) => const SampleScreen())],
routes: [
GoRoute(path: '/', builder: (_, _) => const SampleScreen()),
],
);
10 changes: 3 additions & 7 deletions bricks/base_project/__brick__/lib/features/sample/data/data.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/// Data layer for Sample feature.
///
/// Export all datasources, models, and repository implementations here.

// export 'datasources/sample_datasource.dart';
// export 'models/sample_model.dart';
// export 'repositories_impl/sample_repository_impl.dart';
export 'datasources/sample_datasource.dart';
export 'models/online_data.dart';
export 'repositories_impl/online_sample_data_repository.dart';
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import 'package:{{project_name.snakeCase()}}/features/sample/data/data.dart';
import '../models/online_data.dart';

class SampleDatasource {
// Simulate fetching data from an API or database
Future<OnlineData> fetchOnlineData() async {
await Future<void>.delayed(
const Duration(seconds: 2),
); // Simulate network delay
return OnlineData(data: 'Made with ❤️ by XitoDev');
await Future<void>.delayed(const Duration(milliseconds: 200));
return const OnlineData(data: 'Made with xdevs_cli');
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class OnlineData {
OnlineData({required this.data});
const OnlineData({required this.data});

final String data;
}
Loading
Loading