Skip to content
Back to archipelago.banuacoder.com

DevTools

detect_new_library Pro ​

Tier
Proversion 1.0.6
Command
archipelago generate detect_new_library
Generates
  • devtools/scripts/detect_new_library
Depends on
monorepo_toolkitgenerate these first

Detects newly added direct dependencies in PR-changed pubspec.yaml files. Adds the detect-new-library command to the base monorepo_toolkit.

Variables ​

VariableTypeDefaultDescription
appNamestringMyAppThe name of your application
isForMonorepobooleantrueWhether this is being generated as part of a monorepo

Install ​

Interactive ​

bash
archipelago generate detect_new_library

Non-interactive (CI) ​

bash
archipelago generate detect_new_library --config my_config.json

Requires monorepo_toolkit already installed — post_gen adds this script as a path dependency of monorepo_toolkit's own pubspec.yaml and injects a DetectNewLibraryCommand() registration directly into command_runner.dart's // --- Pro Commands --- marker.

Config Template ​

json
{
  "@appName": "The name of your application",
  "appName": "MyApp",
  "@isForMonorepo": "Whether this is being generated as part of a monorepo",
  "isForMonorepo": true
}

Generated Structure ​

text
devtools/
└── scripts/
    └── detect_new_library/
        ├── lib/
        │   ├── detect_new_library.dart
        │   └── src/
        │       ├── commands/
        │       │   ├── check_command.dart
        │       │   └── detect_new_library_command.dart
        │       ├── models/
        │       │   └── new_library_config.dart
        │       └── services/
        │           └── detect_new_library_service.dart
        └── pubspec.yaml
.newlibrary.yaml

The post_gen hook registers the detect-new-library command in monorepo_toolkit's command runner and adds the .newlibrary.yaml config file at the workspace root with fail_on_new: false as the default.

Public API / Usage ​

bash
# Diff against auto-detected CI base branch, report only
dart run devtools/monorepo_toolkit/bin/monorepo_toolkit.dart detect-new-library check

# Diff against a specific base branch
dart run devtools/monorepo_toolkit/bin/monorepo_toolkit.dart detect-new-library check --base main

# Force a non-zero exit code when new dependencies are found (CI gate)
dart run devtools/monorepo_toolkit/bin/monorepo_toolkit.dart detect-new-library check --fail

check scans every pubspec.yaml changed relative to the base branch (auto-detected from CI env vars, or --base) for newly-added direct dependencies, prints each addition grouped by file, and exits 1 when either --fail is passed or .newlibrary.yaml's fail_on_new: true — otherwise it always exits 0, even when new libraries are found.

.newlibrary.yaml fields: base_branch (string, optional), fail_on_new (bool, default false), ignored_packages (list, default ['flutter', 'dart']).

DI & Wiring ​

Not applicable — pure Dart CLI command, no Flutter DI container involved.

Dependencies ​

detect_new_library script package: args ^2.7.0, path ^1.9.1, yaml ^3.1.3, plus shared_scripts (workspace path dependency, provides CliLogger/MonorepoFinder).

Platform Setup ​

None required — pure Dart CLI tool.

Limitations ​

  • check never fails the exit code unless explicitly told to (--fail or fail_on_new: true) — a CI pipeline that only runs detect-new-library check without either will never block a PR, by design (report-only default).
  • ignored_packages only filters by exact package name, not glob/regex patterns.

Changelog ​

Run archipelago brick info detect_new_library to see the latest published version. Enterprise customers can read the full CHANGELOG.md in the brick source repository.