• Stars
    star
    193
  • Rank 200,292 (Top 4 %)
  • Language
    Dart
  • License
    MIT License
  • Created over 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A script manager for Dart.

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.

More Repositories

1

vscode-notion

Browse Notion pages right inside Visual Studio Code.
TypeScript
323
star
2

envify

A better/safer way to handle environment variables in Flutter.
Dart
102
star
3

interact

A collection of interactive command-line components for Dart.
Dart
83
star
4

vercel-dart

A Dart Runtime for β–² Vercel.
TypeScript
61
star
5

vscode-vercel

WIP: Keep an eye on β–² Vercel deployments without ever leaving Visual Studio Code.
TypeScript
50
star
6

tint

Terminal string styling library for Dart.
Dart
27
star
7

fenceparser

A tiny, well-tested parser for parsing metadata out of fenced code blocks in Markdown
TypeScript
12
star
8

hls-downloader-flutter

HLS Downloader in Flutter.
Dart
5
star
9

minimalistic

Opinionated but sensible and minimal prettier config with plugins
JavaScript
5
star
10

dore

A web framework for Dart.
Dart
4
star
11

covid-nineteen

Statistics for COVID-19 written in Flutter for web (experiment)
JavaScript
4
star
12

burmese-random-words

Generate one or more random common Burmese words
TypeScript
3
star
13

frencojobs

α€™α€„α€Ία€Ήα€‚α€œα€¬α€•α€«
3
star
14

scrapbook

A client for HackClub's scrapbook written in Flutter.
Dart
3
star
15

ombud

A tiny decorator based abstraction layer for making HTTP proxy servers with fastify-http-proxy
TypeScript
3
star
16

vouchbyme

My submission for Amplify Hashnode Hackathon.
TypeScript
3
star
17

argparser

A tiny package to help you parse command-line arguments and flags easily.
Dart
2
star
18

frenco.dev

i made a website
TypeScript
2
star
19

tabrisjs-news-reader

Sample news reader app using tabris js.
JavaScript
1
star
20

dots

My configuration files
1
star
21

lib

My personal `tsdx` replacement
TypeScript
1
star
22

frontend

JavaScript
1
star
23

carify

Mobile app for easier event planning and discovery, for charities
Dart
1
star
24

typeweight

More readable font weights for Flutter.
C++
1
star
25

carify-v2

Carify app rewritten from scratch, with a new UI and better performance
Dart
1
star
26

configs

My personal configuration presets for tools like TypeScript, ESLint and Prettier
JavaScript
1
star