fluttercommunity / fluttercommunity/import_sorter
feat: Add automatic sorting for pubspec.yaml dependencies
- Dominant language
- Dart
- Stars
- 183
- Forks
- 42
- PR merge metrics
- No merged PRs in 30d
Description
## Description
This PR introduces a new feature to automatically sort dependencies within `pubspec.yaml` alphabetically. This helps keep the project configuration clean and organized, similar to how Dart imports are sorted.
## Key Changes
- **New Logic:** Added `lib/pubspec_sort.dart` which handles the parsing and sorting of the yaml file.
- **Dependency:** Added `yaml_edit` package to safely modify `pubspec.yaml` while preserving existing comments and whitespace.
- **Integration:** Updated `bin/import_sorter.dart` to execute the pubspec sorting after the import sorting process.
- **Scope:** The tool now sorts the following sections if they exist:
- `dependencies`
- `dev_dependencies`
- `dependency_overrides`
## Testing
- Added unit tests in `test/pubspec_test.dart` to verify that dependencies are correctly reordered alphabetically.
- Verified manually that the tool runs successfully via `dart run import_sorter`.
## Type of Change
- [x] New feature (non-breaking change which adds functionality)
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [x] This change requires a documentation update (README updated)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.