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

插件详情v0.10.2

grinder

Grinder 是 Dart 的任务运行器,可帮助定义和自动化常见项目工作流。

macOSWindowsLinux
近 30 天下载
12.2万
喜欢数
116
Pub 分数
160

安装插件

flutter pub add grinder

插件介绍

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

Grinder 是 Dart 的任务运行器,可简化常见项目工作流程的自动化,例如测试、构建和代码生成。它允许开发者在 Dart 脚本中定义可重用的任务,从而轻松实现团队间开发流程的标准化和优化。Grinder 支持在 macOS、Windows 和 Linux 上跨平台执行,可无缝集成到 Dart 和 Flutter 项目中。其简洁的语法和可扩展的设计使其非常适合以最小开销管理复杂的构建流水线。

适合场景

  • 自动化构建流程
  • 运行测试和代码检查
  • 管理发布工作流
  • 生成样板代码
  • 简化 CI/CD 流水线

主要特点

  • 基于 Dart 的任务定义
  • 跨平台兼容性
  • 可扩展的任务系统
  • 与 Flutter 和 Dart 项目集成
  • 支持命令行执行

适合对象

  • Dart 和 Flutter 开发者
  • 需要一致工作流程的团队
  • CI/CD流水线设置
  • 项目维护者

使用建议

  • 需要理解 Dart 脚本
  • 有限的图形用户界面
  • 最适合命令行环境
  • 可能需要为复杂工作流进行额外配置

原始 README

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

Dart pub package

Dart workflows, automated.

Grinder consists of a library to define project tasks (e.g. test, build, doc) and a command-line tool to run them.

Getting Started

To start using grinder, add it to your dev_dependencies.

Defining Tasks

Tasks are defined entirely by Dart code allowing you to take advantage of the whole Dart ecosystem to write and debug them. Task definitions reside in a tool/grind.dart script. To create a simple grinder script, run:

dart run grinder:init

In general, grinder scripts look something like this:

import 'package:grinder/grinder.dart';

main(args) => grind(args);

@DefaultTask('Build the project.')
build() {
  log("Building...");
}

@Task('Test stuff.')
@Depends(build)
test() {
  new PubApp.local('test').run([]);
}

@Task('Generate docs.')
doc() {
  log("Generating docs...");
}

@Task('Deploy built app.')
@Depends(build, test, doc)
deploy() {
  ...
}

Any task dependencies (see @Depends above), are run before the dependent task.

Grinder contains a variety of convenience APIs for common task definitions, such as PubApp referenced above. See the API Documentation for full details.

Running Tasks

First install the grind executable:

pub global activate grinder

then use it to run desired tasks:

grind test
grind build doc

or to run a default task (see @DefaultTask above):

grind

or to display a list of available tasks and their dependencies:

grind -h

You can also bypass installing grind and instead use pub run grinder.

Passing parameters to tasks

In order to pass parameters to tasks from the command-line, you query the TaskArgs instance for your task invocation. For example:

grind build --release --mode=topaz

and:

@Task()
build() {
  TaskArgs args = context.invocation.arguments;
  bool isRelease = args.getFlag('release'); // will be set to true
  String mode = args.getOption('mode'); // will be set to topaz
  
  ...
}

would pass the flag release and the option mode to the build task.

You can pass flags and options to multiple tasks. The following command-line would pass separate flags and options to two different tasks:

grind build --release generate-docs --header=small

Disclaimer

This is not an official Google product.

Publishing automation

For information about our publishing automation and release process, see https://github.com/dart-lang/ecosystem/wiki/Publishing-automation.

所属分类

依赖

依赖清单 5 项

源码仓库

使用此插件的项目