搜尋套件、儲存庫與 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

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。

所在榜單