nit-helper

nit-helper is a cross-platform Dart CLI tool designed to automate building Flutter and Serverpod projects, with support for monorepo structures.

The tool automatically detects the necessary directories (*_flutter, *_server) and executes the appropriate commands, with optional fvm support. Additionally, it can manage dependencies across multiple subprojects in large project hierarchies.


โœจ Features

  • ๐Ÿ“ฆ Automatic Flutter module building
  • ๐Ÿ›  Code generation and migrations for Serverpod
  • ๐Ÿ” Support for fvm (Flutter Version Management)
  • ๐Ÿง  Smart project structure navigation
  • ๐Ÿ”ง Commands unified in a single CLI: nit-helper
  • ๐Ÿ—‘๏ธ Unused files detection and cleanup
  • ๐Ÿ“š Get-All command for monorepo dependency management with tree-structured output

๐Ÿš€ Installation

dart pub global activate nit_helper

Ensure that the Dart global utilities path is added to PATH:

  • Linux/macOS:
    export PATH="$PATH:$HOME/.pub-cache/bin"
    
  • Windows: Open System Properties โ†’ Advanced โ†’ Environment Variables and add
    %APPDATA%\Pub\Cache\bin
    
    to the Path variable.

๐Ÿงช Usage

๐Ÿ”จ build

Builds the Flutter project (searches for a directory ending with _flutter, or works in the current directory if it matches).

nit-helper build

With fvm:

nit-helper build --fvm

Executes commands:

  • dart run build_runner build
  • fluttergen

๐Ÿ–ฅ build-server

Generates Serverpod code and applies migrations. Searches for a directory ending with _server.

nit-helper build-server

Force migration creation:

nit-helper build-server --force

With fvm:

nit-helper build-server --fvm

Executes commands:

  • serverpod generate
  • serverpod create-migration (or --force)
  • dart run bin/main.dart --role maintenance --apply-migrations

๐Ÿ” build-full

Combines build and build-server:

nit-helper build-full

With options:

nit-helper build-full --fvm --force

๐Ÿ” check

Analyzes the project for unused Dart files and provides cleanup options.

nit-helper check

With options:

# Scan specific project
nit-helper check --path ./my_project

# Exclude patterns and folders
nit-helper check --exclude-pattern "*.g.dart" --exclude-folder "generated"

# Interactive cleanup mode
nit-helper check --interactive

# Combine options
nit-helper check -p ./project -e "*.test.dart" -f "temp" -i

Features:

  • Smart dependency analysis via import/export parsing
  • Automatic exclusion of generated files (*.g.dart, *.freezed.dart, etc.)
  • Interactive cleanup with confirmation prompts
  • Cross-platform support
  • Detailed size reporting

๐Ÿ“š get-all

Recursively finds all subprojects with pubspec.yaml and runs dart pub get in each. Automatically excludes standard Flutter folders to avoid unnecessary scanning.

nit-helper get-all

With custom path:

nit-helper get-all --path ./my_monorepo

With fvm:

nit-helper get-all --path ./packages --fvm

Features:

  • Recursive Project Discovery: Automatically finds all Dart/Flutter projects at any depth
  • Beautiful Tree Output: Results displayed in a structured tree format with status indicators
  • Smart Folder Exclusion: Ignores build directories (build, ios, android, web, windows, macos, linux) and system folders (.git, .vscode, etc.)
  • Symlink Loop Detection: Prevents infinite loops from circular symlinks
  • Cross-Platform Support: Works on Windows, macOS, and Linux
  • Interactive Output: Preserves colored terminal output during dependency installation
  • Perfect for Monorepos: Handles complex project structures with nested dependencies

Example output:

๐Ÿ“ Found 4 projects:

๐Ÿ“Š GET ALL SUMMARY
โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
๐Ÿ“ฆ packages/
โ”œโ”€โ”€ โœ… shared_models
โ”œโ”€โ”€ โœ… ui_components
โ””โ”€โ”€ ๐Ÿ“ฆ utils/
    โ””โ”€โ”€ โœ… string_utils
โœ… my_app

Total projects: 4
Successful: 4
All projects processed successfully! ๐ŸŽ‰

๐Ÿงฐ Arguments

Argument Command Description
--fvm build, build-server, build-full, get-all Execute through fvm exec
--force build-server, build-full Force create migrations
--path, -p check, get-all Path to project directory
--exclude-pattern, -e check File patterns to exclude
--exclude-folder, -f check Folders to exclude
--interactive, -i check Enable interactive cleanup
--details, -d check Show detailed file list

๐Ÿ’ก Examples

# Build Flutter with fvm
nit-helper build --fvm

# Build Serverpod with forced migration
nit-helper build-server --force

# Full project build
nit-helper build-full --fvm --force

# Check for unused files
nit-helper check

# Interactive cleanup with exclusions  
nit-helper check --exclude-pattern "*.g.dart" --interactive

# Get dependencies for all subprojects in current directory
nit-helper get-all

# Get dependencies for specific monorepo path
nit-helper get-all --path ./packages

# Get dependencies with FVM
nit-helper get-all -p ./my_monorepo --fvm

๐Ÿ“‚ Project Structure

project_root/
โ”œโ”€โ”€ my_app_flutter/
โ”‚   โ”œโ”€โ”€ pubspec.yaml
โ”‚   โ””โ”€โ”€ main.dart
โ”œโ”€โ”€ my_app_server/
โ”‚   โ”œโ”€โ”€ pubspec.yaml
โ”‚   โ””โ”€โ”€ bin/main.dart
โ”œโ”€โ”€ packages/
โ”‚   โ”œโ”€โ”€ shared_models/
โ”‚   โ”‚   โ””โ”€โ”€ pubspec.yaml
โ”‚   โ””โ”€โ”€ ui_components/
โ”‚       โ””โ”€โ”€ pubspec.yaml

nit-helper will automatically detect where *_flutter and *_server are located and execute the appropriate commands. The get-all command is particularly useful in monorepo structures like the one above, scanning through all nested pubspec.yaml files and installing dependencies for each.


๐Ÿ™ Acknowledgments

Special thanks to Emad Beltaje for the original dart_unused_files package, which inspired and provided the foundation for the unused files detection functionality in the check command.


๐Ÿ“œ License

MIT License. ยฉ 2025 Maksim Levchenko


๐Ÿ“ซ Feedback

Report bugs or suggestions: GitHub Issues

Libraries

nit_helper