Viewing version 0.8.6. Open the latest package page.

grinder

0.8.6

Grinder is a task runner for Dart, helping to define and automate common project workflows.

Download archive

Readme

Grinder

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.

pub package Build Status Build status Coverage Status

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:

pub 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');
  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.

Changelog

grinder.dart changes

0.8.6

  • Declare a Null return type for fail() and GrinderContext.fail().

0.8.5

  • Broaden the cli_util dependency to be compatible with version 0.2.0.

0.8.4

  • Update the code to be package:pedantic v1.9.0 compliant.

0.8.3+1

  • Mark fail() and GrinderContext.fail() as @alwaysThrows.
  • Use package:pedantic to analyze the package.

0.8.3

  • Upgrade dependencies for Dart 2

0.8.2

  • Address some --preview-dart-2 runtime issues.

0.8.1

  • Added the ability to pass parameters to tasks from the command line (using a TaskArgs parameter on task functions)
  • Removed the older way to pass flags and options to tasks (via named and positional parameters on task functions)
  • Remove a dependency on a non-strong mode package (unscripted)

0.8.0+3

  • All APIs, including pub run grinder, always use the same Dart version as the user.

0.8.0+2

  • Added categories and extraArgs parameters to Dart2Js.compile() and Dart2Js.compileAsync()

0.8.0+1 (2015/11/12)

  • Fixed a bug with the DDC --html-report option

0.8.0 (2015/10/29)

  • Removed deprecated constants: BIN_DIR, BUILD_DIR, LIB_DIR, WEB_DIR
  • Removed the 120-col line wrapping on task output
  • Added a task for DDC (dev_compiler)
  • Fixed an issue where we were emitting overly verbose stack traces on failures
  • Fixed an issue where we would emit stdout after a failure, even when the stdout had been emitted as part of the task
  • Added outFile and enableExperimentalMirrors to the dart2js task
  • Some grinder output now written using ansi colors
  • Removed the deprecated defaultInit method.
  • Added a task for dartdoc
  • Added a new sdkBin() method

0.7.2 (2015/7/8)

  • Auto-expand directories passed to Analyzer.analyze() to a list of Dart source files using the added method findDartSourceFiles().
  • Add tests for Analyzer.analyze() task.
  • Add sourceDirs and existingSourceDirs to return the projects top-level directories usually containing Dart source files.
  • Deprecate the Tests class (in favor of TestRunner)
  • Add lineLength as an optional argument to DartFmt.format

0.7.1+3 (2015/5/24)

  • Fix bug with Dart.run/runAsync. Args were swapped.

0.7.1+2 (2015/5/24)

  • Add a Dart.runAsync static method.

0.7.1+1 (2015/5/19)

  • Add a files param to TestRunner.test.

0.7.1 (2015/5/19)

  • Added grind --completion install command to install tab-completion for task names and options in grind.
  • Improved grind -h (help) output.
  • Dart.run now takes an optional vmArgs, a list of arguments passed to the Dart VM.
  • Added downgrade method do Pub.
  • Introduce RunOptions to support all Process.run/Process.start parameters. The workingDirectory parameter is now deprecated in all methods, use RunOptions.workingDirectory instead.
  • Added PubApp.runAsync.
  • In Dart.run, deprecate the vmNewGenHeapMB and vmOldGenHeapMB options.
  • Added support for passing lists of files or directories to DartFmt.format().
  • Analyzer.analyzeFiles is deprecated in favor of Analyzer.analyze.
  • Added a Pub.global.list() method to list the installed applications.
  • added a TestRunner class - a wrapper around the new test package.

0.7.0 (2015/4/20)

  • Big changes! Task definitions are now primarily annotation based; see the readme for more information and an example
  • The GrinderContext arg is no longer expected in task functions. Instead, the context variable (and the log and fail functions) are available as global variables. They're injected into the zone running the current task.
  • pub [global] run grinder:grind no longer work, use pub [global] run grinder instead. Add :grinder if using pub run in Dart SDK < 1.10.
  • copyFile and copyDirectory and deprecated in favor of a new copy method
  • deleteEntity is deprecated in favor of a new delete method
  • Renamed runProcess/runProcessAsync/runDartScript to run/runAsync/Dart.run. Process result info (stdout, stderr, exitCode) is now exposed by these methods and some others which call them.
  • Added a wrapper class around pub global activate/run/pub run applications - PubApp
  • Grinder can now create a simple starter script for a project - run pub run grinder:init

0.6.5 (2015/1/13)

  • added defaultInit() and defaultClean() methods, for common tasks
  • added methods for Pub.global.activate and Pub.global.run
  • added an optional workingDirectory argument to more methods
  • added a --version command line flag
  • have the version command check to see if there's a newer version of grinder available
  • the dart2js compile tasks now create the output directory if it doesn't exist

0.6.4 (2014/12/18)

  • clarify that users should put their build scripts in tools/grind.dart
  • add a getSdkDir method

0.6.2 (2014/11/13)

  • widen the version constraint on quiver

0.6.1 (2014/10/12)

  • widen the version constraint on args

0.6.0 (2014/09/22)

The convenience API is now more terse:

  • the defineTask() method has been renamed to task()
  • instead of named parameters, the task() function now uses optional positional parameters

Added two new entrypoint files in bin/: grind.dart and grinder.dart. These let you run grinder via:

pub run grinder test

They look for a corresponding grinder script in the tool directory (bin/grind.dart looks for tool/grind.dart and bin/grinder.dart looks for tool/grinder.dart). If they find a corresponding script they run it in a new Dart VM process. This means that projects will no longer have to have a grind.sh script in the root of each project.

PubTool's build methods now take an optional workingDirectory argument.

Removed runSdkBinary and runSdkBinaryAsync, and they are no longer needed. Use runProcess and runProcessAsync instead.

The methods on PubTools and Dart2jsTools are now static - you no longer need to create an instance to use them. Also, PubTools was renamed to Pub and Dart2jsTools was renamed to Dart2js. And a new utility class for dartanalyzer - Analyzer - was created.

0.5.7 (2014/07/28)

  • added runProcessAsync() and related async methods (such as PubTools.buildAsync(...))
  • removed duplicated stack traces when the build fails with exceptions
  • throw an exception when running SDK binaries, and we are not able to locate the Dart SDK

Installing

export PUB_HOSTED_URL=https://pub.mirror.p-hatan.ir
flutter pub add 'grinder:0.8.6'
pubspec.yaml
name: grinder
# This version must be updated in tandem with the lib/src/cli.dart version.
version: 0.8.6
description: Grinder is a task runner for Dart, helping to define and automate common project workflows.

homepage: https://github.com/google/grinder.dart

environment:
  sdk: '>=2.10.0 <3.0.0'

dependencies:
  cli_util: '>=0.1.2 <3.0.0'
  glob: ^1.0.0
  meta: ^1.1.7
  path: ^1.0.0

dev_dependencies:
  pedantic: ^1.9.0
  test: ^1.0.0

executables:
  grind: grinder

Version history

VersionPublishedArchiveSHA-256
0.0.4Cached · Upstream SHA-256 matchedDownload9de8fb40…df8a9a
0.0.5Cached · Upstream SHA-256 matchedDownload11a861da…414220
0.0.6Cached · Upstream SHA-256 matchedDownload026d1bda…dc1cf7
0.0.7Cached · Upstream SHA-256 matchedDownload9aeeb1a6…62e0c8
0.1.0Cached · Upstream SHA-256 matchedDownload8dcdf8a3…41c1b0
0.4.0Cached · Upstream SHA-256 matchedDownload0506fa5a…c1cac6
0.4.1Cached · Upstream SHA-256 matchedDownloaddec74951…bbd082
0.4.2Cached · Upstream SHA-256 matchedDownloade0c8fde4…87f92b
0.4.3Cached · Upstream SHA-256 matchedDownload2bd14dd8…9d849d
0.4.4Cached · Upstream SHA-256 matchedDownload977e9974…8e8cfb
0.4.5Cached · Upstream SHA-256 matchedDownloadfec4fa7a…2702a1
0.5.0Cached · Upstream SHA-256 matchedDownload4e9e52c6…c17619
0.5.1Cached · Upstream SHA-256 matchedDownloadfde18f3e…b872ce
0.5.2Cached · Upstream SHA-256 matchedDownload86b75995…9a215a
0.5.3Cached · Upstream SHA-256 matchedDownload8063a366…934348
0.5.4Cached · Upstream SHA-256 matchedDownload2a06c90a…bb06cc
0.5.6Cached · Upstream SHA-256 matchedDownload0409881b…3bf2e5
0.5.7Cached · Upstream SHA-256 matchedDownload297ac833…1b9fe9
0.6.0Cached · Upstream SHA-256 matchedDownload2f3b345b…01dc58
0.6.1Cached · Upstream SHA-256 matchedDownload8e7d702d…9ed5fa
0.6.2Cached · Upstream SHA-256 matchedDownload56df3170…94ce90
0.6.3Cached · Upstream SHA-256 matchedDownload10a4a0db…461924
0.6.4Cached · Upstream SHA-256 matchedDownloade1c3f8ee…293705
0.6.4+1Cached · Upstream SHA-256 matchedDownload80d71af0…e4af3d
0.6.5Cached · Upstream SHA-256 matchedDownloadd45160a8…9faba7
0.6.6Cached · Upstream SHA-256 matchedDownload94bcfcbe…d34385
0.6.6+1Cached · Upstream SHA-256 matchedDownload1408c2e0…d5dfc8
0.6.6+2Cached · Upstream SHA-256 matchedDownload40a33d3a…6a638e
0.6.6+3Cached · Upstream SHA-256 matchedDownload29081f9c…daf0bf
0.7.0-dev.1Cached · Upstream SHA-256 matchedDownload66e4961a…97767c
0.7.0-dev.2Cached · Upstream SHA-256 matchedDownloadd1ef1ac6…f588ac
0.7.0Cached · Upstream SHA-256 matchedDownload0ed2a625…8569f6
0.7.1Cached · Upstream SHA-256 matchedDownload517a659e…147a66
0.7.1+1Cached · Upstream SHA-256 matchedDownload2f2363a4…657a72
0.7.1+2Cached · Upstream SHA-256 matchedDownload48203ae8…d619bb
0.7.1+3Cached · Upstream SHA-256 matchedDownload35450802…4ba96c
0.7.2Cached · Upstream SHA-256 matchedDownload4fa504d5…66229e
0.8.0-dev.1Cached · Upstream SHA-256 matchedDownload704fe8b8…5db868
0.8.0-dev.2Cached · Upstream SHA-256 matchedDownload91bb8f19…9ad2fc
0.8.0Cached · Upstream SHA-256 matchedDownloadb12b054b…4a03e5
0.8.0+1Cached · Upstream SHA-256 matchedDownload7714a971…00fbfc
0.8.0+2Cached · Upstream SHA-256 matchedDownload9b65c1fd…ee9c0f
0.8.0+3Cached · Upstream SHA-256 matchedDownload5dc15642…95cadf
0.8.1Cached · Upstream SHA-256 matchedDownload5b0b4425…e84f1d
0.8.2Cached · Upstream SHA-256 matchedDownload6636532c…bf91f7
0.8.3Cached · Upstream SHA-256 matchedDownload8284e19b…b13f0d
0.8.3+1Cached · Upstream SHA-256 matchedDownload9653d450…29d19f
0.8.4Cached · Upstream SHA-256 matchedDownloadfdc35bbe…318f2a
0.8.5Cached · Upstream SHA-256 matchedDownload7fd2bed3…442c9b
0.8.6Cached · Upstream SHA-256 matchedDownload29e92765…cb37f1
0.9.0-nullsafety.0Cached · Upstream SHA-256 matchedDownloadd6ddb4d1…8c8bfa
0.9.0Cached · Upstream SHA-256 matchedDownload2961d5bf…cf0fb9
0.9.1Cached · Upstream SHA-256 matchedDownload2e8c0186…60fb19
0.9.2Cached · Upstream SHA-256 matchedDownloadb24948a4…787b04
0.9.3Cached · Upstream SHA-256 matchedDownload1dabcd70…7c8d00
0.9.4Cached · Upstream SHA-256 matchedDownload48495acd…568b56
0.9.5Cached · Upstream SHA-256 matchedDownloade1996e48…1f6188
0.10.0Cached · Upstream SHA-256 matchedDownload8c65fc6c…45093f
0.10.1Cached · Upstream SHA-256 matchedDownload7e0969c3…9dc8f3
0.10.2Cached · Upstream SHA-256 matchedDownloadf8cf4d64…6d644a

Dependencies

cli_util "\u003e=0.1.2 \u003c3.0.0"

glob "^1.0.0"

meta "^1.1.7"

path "^1.0.0"