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
| Variable | Type | Default | Description |
|---|---|---|---|
| appName | string | MyApp | The name of your application |
| isForMonorepo | boolean | true | Whether this is being generated as part of a monorepo |
Install
Interactive
archipelago generate detect_new_libraryNon-interactive (CI)
archipelago generate detect_new_library --config my_config.jsonRequires 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
{
"@appName": "The name of your application",
"appName": "MyApp",
"@isForMonorepo": "Whether this is being generated as part of a monorepo",
"isForMonorepo": true
}Generated Structure
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.yamlThe 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
# 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 --failcheck 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
checknever fails the exit code unless explicitly told to (--failorfail_on_new: true) — a CI pipeline that only runsdetect-new-library checkwithout either will never block a PR, by design (report-only default).ignored_packagesonly 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.