DevTools
size_guard Pro
- Tier
- Proversion 1.0.8
- Command
archipelago generate size_guard- Generates
devtools/scripts/size_guard
- Depends on
- monorepo_toolkitgenerate these first
File size threshold enforcement for monorepo workspaces. Scans for oversized files (images, fonts, media, archives, etc.) so an accidentally-committed 20MB asset gets caught in CI instead of bloating the app bundle. Adds the
size-guardcommand to the basemonorepo_toolkit.
Requires the base monorepo_toolkit brick to already be generated.
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 |
Usage
Interactive
archipelago generate size_guardNon-interactive (CI)
archipelago generate size_guard --config my_config.jsonGenerated Structure
devtools/
└── scripts/
└── size_guard/
├── lib/
│ ├── size_guard.dart
│ └── src/
│ ├── commands/
│ │ ├── check_command.dart # `size-guard check`
│ │ └── size_guard_command.dart # parent `size-guard` command
│ ├── models/
│ │ └── size_guard_config.dart # SizeGuardConfig, SizeViolation, ScanStatistics
│ └── services/
│ └── size_guard_service.dart
└── pubspec.yaml
example/
└── size_guard.yaml # scaffolded example config — copy to the workspace root to activateCLI
dart run monorepo_toolkit size-guard check \
[--threshold 500KB] [--extension png] [--ignore some/path] \
[--config path/to.yaml] [--stats] [--changed-only] [--base main]--threshold(-t, default500KB) — acceptsB/KB/MB/GBsuffixes.--extension(-e, repeatable) — extra extensions to scan, merged with the built-in default set (images, fonts, audio/video, archives,json,db,sqlite).--ignore(-i, repeatable) — extra paths to ignore, merged with defaults (.git,.dart_tool,build,node_modules,ios/Pods,coverage, etc).--config(-c) — explicit YAML config path; otherwise falls back to<workspace root>/size_guard.yaml, then built-in defaults.--stats(-s) — print total files/bytes scanned even when nothing violates the threshold.--changed-only— scan only files changed vs. a base branch (viaGitChanges.getChangedFiles), for fast PR checks.--base(-b) — base branch for--changed-only; auto-detected from CI env if omitted.
Exit code is 1 if any file exceeds the threshold, 0 otherwise.
Config format
SizeGuardConfig.fromYamlFile reads <workspace root>/size_guard.yaml (or the --config path), expecting a top-level size_guard: map:
size_guard:
threshold: 500KB
extensions: [png, jpg, mp4]
ignore_paths: [some/generated/dir]
ignore_patterns: ["**/*.g.dart"]post_gen.dart scaffolds example/size_guard.yaml using this same schema. It is never read automatically from example/ — copy it to <workspace root>/size_guard.yaml, or pass --config example/size_guard.yaml, to activate it.
DI and wiring notes
post_gen.dart (when isForMonorepo: true) adds devtools/scripts/size_guard to the workspace, adds a path dependency to devtools/monorepo_toolkit/pubspec.yaml, and injects SizeGuardCommand into command_runner.dart at the // --- Pro Commands --- marker. This is CLI command registration, not app-runtime GetIt DI — there's no archipelago: di_modules block, since size_guard never runs inside the Flutter app itself.
Dependencies
- Hard prerequisite: base
monorepo_toolkitbrick must already be generated. No self-generation — the hook does nothing beyond the direct brick.yaml vars. - When
isForMonorepo: false,post_gen.dartskips workspace/command-runner wiring and scaffolds the package standalone.
Known Limitations
- The scaffolded
example/size_guard.yamlis inert until copied to the workspace root (or passed via--config). - No CI workflow wiring is generated; add
dart run monorepo_toolkit size-guard checkto your own CI steps.
Changelog
Run archipelago brick info size_guard to see the latest published version. Enterprise customers can read the full CHANGELOG.md in the brick source repository.