Sergey Penkovsky 5220ebc4b9 feat(generator): complete code generation testing framework with 100% test coverage
BREAKING CHANGE: Updated file extensions and dependencies for better compatibility

## 🎯 Major Features Added:
-  Complete test suite for ModuleGenerator (66 integration tests)
-  Complete test suite for InjectGenerator (66 integration tests)
-  Comprehensive unit tests for BindSpec, MetadataUtils
-  195 total tests across all packages (100% passing)

## 🔧 Technical Improvements:
- feat(generator): add comprehensive integration tests for code generation
- feat(generator): implement BindSpec unit tests with full coverage
- feat(generator): add MetadataUtils unit tests for annotation processing
- fix(generator): update file extensions to avoid conflicts (.module.cherrypick.g.dart)
- fix(generator): correct part directive generation in templates
- fix(generator): resolve dart_style 3.x formatting compatibility

## 📦 Dependencies & Configuration:
- build(deps): upgrade analyzer to ^7.0.0 for Dart 3.5+ compatibility
- build(deps): upgrade dart_style to ^3.0.0 for modern formatting
- build(deps): upgrade source_gen to ^2.0.0 for latest features
- config(build): update build.yaml with new file extensions
- config(melos): optimize test commands for better performance

## 🐛 Bug Fixes:
- fix(examples): correct local package paths in client_app and postly
- fix(analysis): exclude generated files from static analysis
- fix(generator): remove unused imports and variables
- fix(tests): add missing part directives in test input files
- fix(tests): update expected outputs to match dart_style 3.x format

## 🚀 Performance & Quality:
- perf(tests): optimize test execution time (132 tests in ~1 second)
- quality: achieve 100% test coverage for code generation
- quality: eliminate all analyzer warnings and errors
- quality: ensure production-ready stability

## 📋 Test Coverage Summary:
- cherrypick: 61 tests 
- cherrypick_annotations: 1 test 
- cherrypick_generator: 132 tests 
- cherrypick_flutter: 1 test 
- Total: 195 tests (100% passing)

## 🔄 Compatibility:
-  Dart SDK 3.5.2+
-  Flutter 3.24+
-  melos + fvm workflow
-  build_runner integration
-  Modern analyzer and formatter

This commit establishes CherryPick as a production-ready dependency injection
framework with enterprise-grade testing and code generation capabilities.
2025-06-11 18:34:19 +03:00
2025-05-18 16:41:48 +03:00
2025-05-19 16:11:41 +03:00
2025-06-04 00:39:25 +03:00
2025-05-16 16:43:23 +03:00
2020-06-27 06:05:03 +03:00
2025-05-19 16:11:41 +03:00
2025-05-22 16:26:33 +03:00

CherryPick Workspace

CherryPick Workspace is a modular, open-source dependency injection ecosystem for Dart and Flutter, designed to offer lightweight, flexible, and scalable DI suitable for both backend and frontend (Flutter) development. This monorepo contains the main DI runtime library, annotation helpers, code generation for modular bindings, and seamless Flutter integration.


Packages Overview

  • cherrypick
    The core dependency injection library. Supports modular bindings, hierarchical scopes, named and singleton bindings, provider functions (sync/async), runtime parameters, and test-friendly composition.
    Intended for use in pure Dart and Flutter projects.

  • cherrypick_annotations
    A set of Dart annotations (@module, @singleton, @instance, @provide, @named, @params) enabling concise, declarative DI modules and providers, primarily for use with code generation tools.

  • cherrypick_generator
    A source_gen-based code generator that automatically converts your annotated modules and providers into ready-to-use boilerplate for registration and resolution within your app.
    Reduces manual wiring and errors; compatible with build_runner.

  • cherrypick_flutter
    Adds Flutter-native integration, exposing DI scopes and modules to the widget tree through CherryPickProvider and enabling dependency management throughout your Flutter app.


Why CherryPick?

  • Zero-overhead and intuitive API:
    Clean, minimal syntax, strong typing, powerful binding lifecycle control.
  • High testability:
    Supports overriding and hierarchical scope trees.
  • Both Sync & Async support:
    Register and resolve async providers, factories, and dependencies.
  • Seamless code generation:
    Effortless setup with annotations + generator—skip boilerplate!
  • Works with or without Flutter.
  • Production ready:
    Robust enough for apps, packages, and server-side Dart.
  • Extensible & Modular:
    Add bindings at runtime, use sub-modules, or integrate via codegen.

Get Started

1. Add dependencies

In your pubspec.yaml:

dependencies:
  cherrypick: ^<latest-version>
  cherrypick_annotations: ^<latest-version>

dev_dependencies:
  build_runner: ^<latest>
  cherrypick_generator: ^<latest-version>

For Flutter projects, add:

dependencies:
  cherrypick_flutter: ^<latest-version>

2. Write a DI Module (with annotations)

import 'package:cherrypick_annotations/cherrypick_annotations.dart';
import 'package:cherrypick/cherrypick.dart';

@module()
abstract class MyModule extends Module {
  @singleton()
  ApiClient apiClient() => ApiClient();

  @provide()
  DataRepository dataRepo(ApiClient client) => DataRepository(client);

  @provide()
  String greeting(@params() String name) => 'Hello, $name!';
}

3. Generate the bindings

dart run build_runner build
# or for Flutter:
flutter pub run build_runner build

The generator will create a $MyModule class with binding code.

4. Install and Resolve

final scope = CherryPick.openRootScope()
  ..installModules([$MyModule()]);

final repo = scope.resolve<DataRepository>();
final greeting = scope.resolveWithParams<String>('John'); // 'Hello, John!'

For Flutter, wrap your app with CherryPickProvider for DI scopes in the widget tree:

void main() {
  runApp(
    CherryPickProvider(child: MyApp()),
  );
}

Features at a Glance

  • Fast, lightweight DI for any Dart/Flutter project
  • 🧩 Modular & hierarchical scopes (root, subscopes)
  • 🔖 Named/bound/singleton instances out of the box
  • 🔄 Sync and async provider support
  • ✏️ Runtime parameters for dynamic factory methods
  • 🏷️ Code generator for annotation-based DI setup (cherrypick_generator)
  • 🕹️ Deep Flutter integration via CherryPickProvider

Example Usage

Please see:


Contribution & License

  • Contributions: PRs, issues, and feedback are welcome on GitHub.
  • License: Apache 2.0 for all packages in this workspace.

Happy Cherry Picking! 🍒

Description
CherryPick is a modular, open-source dependency injection ecosystem for Dart and Flutter
Readme Apache-2.0 2 MiB
Languages
Dart 96.2%
TypeScript 2.1%
Python 1.3%
CSS 0.4%