搜索插件、代码仓与 APP 分类

插件详情v0.0.2

sort_pubspec_dependencies

用于对 pubspec.yaml 中的依赖项和开发依赖项进行排序的 Flutter/Dart 包

AndroidiOSLinuxmacOSWindows
近 30 天下载
11.4万
喜欢数
6
Pub 分数
160

安装插件

flutter pub add sort_pubspec_dependencies

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个用于自动排序 pubspec.yaml 文件中依赖项和 dev_dependencies 的开发工具。该包确保依赖项的排序一致且整洁,提升 Flutter 项目的可读性和可维护性。它与 Flutter CLI 无缝集成,开发者只需一条命令即可排序依赖项。适用于强制执行代码风格标准的团队,或在依赖管理至关重要的大型应用中使用。

适合场景

  • 维护干净的 pubspec.yaml 文件
  • 在团队项目中强制执行一致的依赖项顺序
  • 在 CI/CD 中自动格式化依赖项
  • 提高依赖项列表的可读性
  • 简化合并冲突的解决

主要特点

  • 依赖项的自动排序
  • 简单的 CLI 集成
  • 同时支持 dependencies 和 dev_dependencies
  • 保留现有结构和注释
  • 与所有主要平台兼容

适合对象

  • Flutter 开发人员
  • 基于团队的项目维护者
  • CI/CD 流水线集成器
  • 代码质量倡导者
  • 频繁更新依赖项的项目

使用建议

  • 如果使用了自定义格式,则在排序后可能需要手动检查
  • 不适用于运行时使用
  • 不验证依赖项版本
  • 仅影响 pubspec.yaml 文件结构
  • 需要 Dart SDK 2.15 或更高版本

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Description

A Dart CLI tool for sorting dependencies in your pubspec.yaml file.

Keep your pubspec.yaml organized by alphabetically sorting dependencies: and dev_dependencies:. This tool ensures better readability and consistency across projects.

Features

  • Sorts dependencies and dev_dependencies alphabetically.
  • Maintains additional metadata for dependencies (e.g., paths, Git URLs and refs, version constraints).
  • CLI support for easy integration into development workflows.
  • The package is implemented exclusively using Dart tools, there are no transitive dependencies.
  • Lightweight and fast.

Installation

Add sort_pubspec_dependencies as a dev dependency in your project:

dev_dependencies:
  sort_pubspec_dependencies: <latest-version>

Usage

Run the tool locally

dart run sort_pubspec_dependencies

Options

You can create a sort_dependencies.yaml config in the root of your project for:

  • Your pubspec.yaml is located outside the main project directory, you can explicitly specify the path to it using the key: pubspecPath
  • If you want to run flutter pub get after sorting, set the value true to the key needRunPubGetAfterSorting

The sort_dependencies.yaml example:

pubspecPath: 'pubspec.yaml'
needRunPugGetAfterSorting: true

Also, you can run the tool via dart run sort_pubspec_dependencies --pubspec-path=<path>/p=<path> --with-run-pub-get to avoid creating a config and get the same effect

Conclution

Feel free to modify this template to suit your preferences or project needs

Also, you can open issues with a description of the problem if you find unexpected behavior

所属分类

源码仓库

使用此插件的项目

暂无相关数据。

所在榜单