搜尋套件、儲存庫與 APP 分類

套件詳情v1.5.0

derry

一個腳本管理員,可幫助您定義腳本捷徑並輕鬆、高效地使用它們。

AndroidiOSmacOSWindowsLinux
近 30 天下載
8380
喜歡數
232
Pub 分數
140

安裝套件

flutter pub add derry

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

Derry 是一個輕量級的腳本管理工具,專為 Flutter 開發者設計,能輕鬆且高效地定義與執行自訂腳本捷徑。它透過允許使用者建立可重複使用的指令,簡化重複性的開發任務,減少程式碼冗餘,並提升跨多個平台的工作流程效率。非常適合尋求在 Flutter 專案中獲得更快、更整齊腳本功能的團隊與個人開發者。

適用情境

  • 自動化建構流程
  • 執行測試套件
  • 管理部署腳本
  • 簡化 CI/CD 工作流程
  • 執行專案設定任務

主要特色

  • 腳本捷徑定義
  • 高效能執行
  • 跨平台支援
  • 簡單設定
  • 可擴展的命令系統

適合對象

  • Flutter 開發者
  • CI/CD 流水線整合者
  • 團隊開發環境
  • CLI 高級使用者
  • 專案自動化愛好者

使用建議

  • 需要手動腳本設定
  • 有限的圖形使用者介面
  • 依賴命令列使用
  • 不適用於執行時間應用邏輯
  • 最適合僅用於開發任務

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Derry

Derry is a script manager for Dart.

Overview

Derry helps you define shortcut scripts, and save you from having to type very long and forgettable long lines of scripts, again and again.

Instead of running this every time,

dart run build_runner build --delete-conflicting-outputs

Add this to pubspec.yaml,

scripts:
  build: dart run build_runner build --delete-conflicting-outputs

and run

derry build

Installation

Install derry as a global dependency from pub.dev like this.

dart pub global activate derry

Then use derry to run a command from the current dart/flutter project.

derry [script]

Usage

When called, derry will look for a pubspec.yaml file in the current directory, and will throw an error if it doesn't exist. The scripts can be declared within the scripts node of the pubspec.yaml file.

scripts:
  build: dart run build_runner build
derry build
# or even with additional arguments
derry build -- --delete-conflicting-outputs

API Documentation

Use definition file

Scripts can be configured just inside the pubspec.yaml file or within a separate file. When using a separate file to configure scripts, pass the file name as the value of the scripts node in the pubspec.yaml file.

# pubspec.yaml
scripts: derry.yaml
# derry.yaml
build: dart run build_runner build

Use scripts as List

A script can either be a single string or a list of strings. If it is a list, the strings inside of the list will be executed synchronously in the given order of the list.

build:
  - dart test
  - echo "test completed"
  - dart run build_runner build

Nested scripts

Scripts can be nested as the user needed. For example, you can use them to use different implementations of the build script based on operating system.

build:
  windows:
    - echo 0 # do something
  mac:
    - echo 1 # do something else

And you can use them by calling derry build windows on windows and derry build mac on macOS.

Pre and post scripts

With pre & post scripts, you can easily define a script to run before and after a specific script without hassling with references. Derry automatically understands them from the names.

prepublish:
  - cargo build && copy target blob
  - dart test
publish:
  - dart pub publish
postpublish:
  - rm -rf blob

Configure script descriptions

You can add a string to (description) option, which can be useful when viewing through a list of available via derry ls -d command. When you are using (description) field, you must use (script) field to define scripts.

build:
  (description): script to be called after every update to x.dart file
  (scripts):
    - cat generated.txt
    - dart run build_runner build

Configure multiline scripts

Note that in the list of scripts, executions will happen in separate processes. You can use && to execute multiple scripts in the same process.

# > or | can be used to define multiline strings, this is a standard YAML syntax
build: >
  cat generated.txt &&
  dart run build_runner build

# the second line won't be called if generated.txt does not exist

Use references

When defining scripts, you can reference to other scripts via $ syntax. These references to scripts won't be executed with a separate derry process. For example,

test:
  - dart run test
  - echo "test completed"
build:
  - $test # instead of using derry test
  - $test --ignored # even with arguments
  - flutter build
generate:
  env:
    - echo env
release:
  - $generate:env # use nested references via :
  - $build

derry test will spawn a new derry process to execute, while references won't, reducing the time took to run dart code, and spawn that process. But note that references will take a whole line of script. For example, you have to give a separate line for a subcommand, you can't use them together with other scripts or sandwiched in a string.

List available scripts

Use this command to see what scripts are available in the current configuration.

derry ls # --description or -d to output descriptions

Check the location of the derry scripts

Use this command to see the location (both absolute and relative) path of the derry script file. You can also use this to check if the scripts are correctly formatted or the location is correct.

derry source # --absolute or -a to show absolute path

Upgrade derry

dart pub global activate derry # or
derry upgrade # will run `dart pub global activate derry`

Why & How

Honestly, I needed it. It was easy to make, though I had a hard time implementing the script execution. Since Dart's Process isn't good at executing system commands, I used Rust with the help of Foreign Function Interfaces. For execution, currently cmd is used for Windows and bash is used for Linux and Mac.


Currently Supported Platforms

64bit Linux, Windows, and Mac are currently supported.

所屬分類

依賴

依賴清單 10 項

原始碼儲存庫

使用此套件的專案