Skip to content

feat: Add automatic sorting for pubspec.yaml dependencies#88

Open
Franklyn-R-Silva wants to merge 5 commits intofluttercommunity:masterfrom
Franklyn-R-Silva:feat/sort-pubspec
Open

feat: Add automatic sorting for pubspec.yaml dependencies#88
Franklyn-R-Silva wants to merge 5 commits intofluttercommunity:masterfrom
Franklyn-R-Silva:feat/sort-pubspec

Conversation

@Franklyn-R-Silva
Copy link
Copy Markdown

Description

This PR adds functionality to automatically sort dependencies in pubspec.yaml alphabetically.

It processes the following sections:

  • dependencies
  • dev_dependencies
  • dependency_overrides

Implementation Details

  • Used the yaml_edit package to safely modify the yaml file while preserving comments and structure.
  • Added a new logic file lib/pubspec_sort.dart.
  • Integrated the sorting step into the main execution flow in bin/import_sorter.dart.
  • Added unit tests in test/pubspec_test.dart to verify the sorting logic.

Type of Change

  • New feature (non-breaking change which adds functionality)

Copilot AI review requested due to automatic review settings December 11, 2025 12:27
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds functionality to automatically sort dependencies in pubspec.yaml files alphabetically, helping maintain cleaner and more consistent project configurations. When running the import_sorter tool, it now automatically processes and sorts the dependencies, dev_dependencies, and dependency_overrides sections.

Key Changes:

  • Created new lib/pubspec_sort.dart with sorting logic using the yaml_edit package
  • Integrated pubspec sorting into the main execution flow in bin/import_sorter.dart
  • Added unit tests in test/pubspec_test.dart to verify sorting behavior

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
lib/pubspec_sort.dart New file implementing the core sorting logic for pubspec.yaml dependencies using yaml_edit package
test/pubspec_test.dart New test file with unit tests covering dependencies, dev_dependencies sorting, and no-change scenarios
bin/import_sorter.dart Integrated pubspec sorting into main execution flow with console output
lib/sort.dart Improved comments and documentation for existing import sorting logic (cosmetic changes)
pubspec.yaml Added yaml_edit dependency required for the new functionality
README.md Added documentation section explaining the new pubspec sorting feature and updated pre-commit hook example
example/example_app/ios/Flutter/ephemeral/* Generated iOS Flutter files (no review needed)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Franklyn-R-Silva
Copy link
Copy Markdown
Author

@copilot open a new pull request to apply changes based on the comments in this thread

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Author

@Franklyn-R-Silva Franklyn-R-Silva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adjustment to organize dependencies in pubspec.yaml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants