craft_runner 0.1.0 copy "craft_runner: ^0.1.0" to clipboard
craft_runner: ^0.1.0 copied to clipboard

Code generation runner for riverpod_craft. Watch mode, single file generation, and cleanup.

riverpod_craft_cli #

Code generation CLI for riverpod_craft. Parses Dart source files with @provider, @command, and @settable annotations and generates type-safe provider boilerplate.

Installation #

The CLI is included in the riverpod_craft_cli package. Add it as a dev dependency or run directly:

dev_dependencies:
  riverpod_craft_cli:
    path: ../riverpod_craft_cli

Commands #

watch (default) #

Monitors the lib/ directory and regenerates .craft.dart files on save.

dart run riverpod_craft_cli
# or explicitly:
dart run riverpod_craft_cli watch

On startup, watch mode:

  1. Cleans up orphaned .craft.dart files (where the source file no longer has annotations)
  2. Processes all existing annotated files
  3. Watches for file changes

generate <file_path> #

Generates the .craft.dart file for a single source file.

dart run riverpod_craft_cli generate lib/providers/my_provider.dart

clean #

Removes all generated .craft.dart files from the project.

dart run riverpod_craft_cli clean

init #

Sets up the project — installs Dart dependencies and VS Code extension.

dart run riverpod_craft_cli init

help #

Shows available commands.

dart run riverpod_craft_cli help

Generated Files #

  • Source: my_provider.dart
  • Output: my_provider.craft.dart
  • Connected via part 'my_provider.craft.dart'; (added automatically to source)

If you remove all annotations from a source file, the CLI automatically deletes the corresponding .craft.dart file and removes the part directive.

What Gets Generated #

For each annotated provider, the CLI generates:

Source Generated
@provider class with Future<T> create() DataNotifier base class, provider declaration, Ref/WidgetRef facades, extensions
@provider class with T create() StateDataNotifier base class, provider declaration, facades with setState()
@provider function Notifier class, provider declaration, facades, extensions
@command methods CommandNotifier subclass, command facades with run()/reset()/retry()
Family parameters Callable facade classes, invalidateFamily()

How It Works #

  1. Parse — Uses the Dart analyzer package to parse source files into AST
  2. Collect — Walks the AST to find annotated classes/functions and extract metadata (types, parameters, annotations)
  3. Generate — Builds provider code from the collected metadata
  4. Write — Outputs the .craft.dart file and ensures the part directive exists in the source

Requirements #

  • Dart SDK: ^3.8.1
0
likes
120
points
26
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Code generation runner for riverpod_craft. Watch mode, single file generation, and cleanup.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

analyzer, crypto, dart_style, path, pub_semver, riverpod_craft_plugin, yaml

More

Packages that depend on craft_runner