Skip to content

Detect New Library Pro

The detect-new-library command scans pubspec.yaml files changed in a pull request and reports any newly added direct dependencies. It is warn-only by default — the intent is visibility, not blocking. Teams can opt into blocking mode once they have established a review culture around new dependency additions.

Usage

bash
# Report-only (default, always exits 0)
dart run monorepo_toolkit detect-new-library check

# Check against a specific base branch
dart run monorepo_toolkit detect-new-library check --base develop

# Blocking mode (exits 1 if new libraries found)
dart run monorepo_toolkit detect-new-library check --fail

Flags

FlagAbbrDefaultDescription
--base-bmainBase branch to diff against
--failfalseExit 1 if new direct dependencies are detected
--config-c.newlibrary.yamlPath to YAML config file

Configuration

Create a .newlibrary.yaml at the workspace root:

yaml
new_library:
  fail_on_new: false

  ignored_packages:
    - flutter
    - dart
    - flutter_test
    - integration_test

Set fail_on_new: true in the config file to permanently enable blocking mode without requiring the --fail flag on every invocation.

Why warn-only by default

New dependencies are not inherently bad — they are often the right choice. The goal of this tool is to make new additions visible in PR reviews so teams can ask the right questions: Is this library maintained? Does an equivalent already exist in the workspace? What is its transitive dependency footprint?

Once a team has established that culture, enabling fail_on_new: true shifts the gate to a mandatory approval step.

CI integration

yaml
# Warn-only — always passes, surfaces in CI logs
steps:
  - name: Detect new dependencies
    run: dart run monorepo_toolkit detect-new-library check --base ${{ github.base_ref }}

# Blocking mode
steps:
  - name: Detect new dependencies (blocking)
    run: dart run monorepo_toolkit detect-new-library check --base ${{ github.base_ref }} --fail

Built by Banua Coder