derry 0.1.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 79

Derry #

Pub Version

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,

pub run build_runner build --delete-conflicting-outputs

Add this to pubspec.yaml,

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

and run

derry run build
# or by alias
derry build

Installation #

Install derry as a global dependency from Pub as follows.

pub global activate derry

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

derry run [script]

Usage #

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

scripts:
  build: pub run build_runner build
derry build
# or use `silent` option to hide outputs
derry build --silent
# 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: pub 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:
  - pub run test
  - echo "test completed"
  - pub run build_runner build

Use aliases

Most used scripts are defined as aliases that you can use with a shorter derry command. Options available with derry run command will also be available with these aliases. No other functionalities are added to these aliases, they are just extensions of derry run command.

derry build # instead of derry run build
derry test # instead of derry run test

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.

# derry.yaml
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.

Configure execution type

Note that in the list of scripts, executions will happen in separate processes, use && to execute multiple scripts in the same process. Alternatively, you can also configure the execution value. To separate the configuration values from nested scripts, wrap the keys of the configurations with parenthesis as in (execution).

build:
  (execution): once # multiple by default
  (scripts):
    - cat generated.txt
    - pub run build_runner build # won't be called if generated.txt does not exist

This will be the same as using && but it saved the user from having very long lines of scripts.

Use subcommands

When defining scripts, the user can also define subcommands. Subcommands are references to commands/scripts that won't be executed with a separate derry process. For example,

test:
  - pub run test
  - echo "test completed"
build:
  - $test # instead of using derry test
  - $test --ignored # even with arguments
  - flutter build

derry test will spawn a new derry process to execute, while subcommands are not, reducing the time took to run dart code, and spawn that process. But note that subcommands 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.

List available scripts

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

derry ls

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

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. I know that's not optimal and I'm still looking for a way to allow users to use the current shell for executions.


Currently Supported Platforms #

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


License #

MIT © Frenco Jobs

0.1.1 #

  • Refactored ffi directory to bindings directory
  • Refactored usage lines to be all lowercase and with no period
  • Added derry --version option

0.1.0 #

  • Added support for derry source command

0.0.9 #

  • Added support for using subcommands with options/arguments/parameters

0.0.8+1 #

  • Fixed #20 MultipleHandlers Error caused by #12 fix

0.0.8 #

  • Fixed #12 Ctrl-C Error
  • Added -s as abbrreviation for --silent

0.0.7+1 #

  • Fixed #14 error on not being able to use options caused by previous changes

0.0.7 #

  • Added support for nested scripts
  • Modified Did you mean this? check and ls commands to work well with nested scripts
  • Breaking changes on Advanced Configuration API for compatibility with nested scripts

0.0.6 #

  • Added Did you mean this? check by using string-similarity package
  • Fixed null infoLine error
  • Fixed command not found unhandled exceptions

0.0.5 #

  • Added derry ls command
  • Updated documentation

0.0.4 #

  • Added support for test and build aliases
  • Better and consistent error messages with an API

0.0.3+1 #

  • Modified README to work correctly on pub.dev

0.0.3 #

  • Added support for --silent
  • Refactored Rust source code
  • Started using derry for build
  • Modified documentation

0.0.2 #

  • Added support for subcommands

0.0.1 #

  • Initial version, scaffolded by Stagehand
  • Added support for list definitions
  • Added support for configurable execution type
  • Added support for win64, linux64, and (mac64)
  • Added tests for helpers

example/main.dart

// Check the repository for [derry.yaml] file and more informative example
// [derry.yaml] will probably look like this
//
// version: dart --version # example that stderr is also shown
// ping: ping google.com && echo ok # example that stdout is served with stream
// # example for list commands
// list:
//   - echo test
//   - echo done
// # example for advanved configurations
// run_once:
//   (execution): once
//   (scripts):
//     - echo test
//     - exit
//     - echo "this wont be called"
// # example for subcommands
// prep:
//   - echo step 1
//   - echo step 2
// test: # call with derry test
//   - $prep
//   - echo pub run test
// build: # call with derry build
//   - \$prep # should not work
//   - echo flutter build
// nested: # example for nested scripts
//   foo:
//     - echo bar

void main() {
  print('Derry.');
}

Use this package as an executable

1. Install it

You can install the package from the command line:


$ pub global activate derry

2. Use it

The package has the following executables:


$ derry

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  derry: ^0.1.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:derry/derry.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
57
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
79
Learn more about scoring.

We analyzed this package on Jul 14, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.15

Analysis suggestions

Package not compatible with SDK flutter

Because it is not compatible with any of the supported runtimes: flutter-native, flutter-web

Package not compatible with runtime flutter-native on Android

Because:

  • package:derry/derry.dart that imports:
  • dart:cli

Package not compatible with runtime flutter-native on Linux

Because:

  • package:derry/derry.dart that imports:
  • dart:cli

Package not compatible with runtime flutter-native on Windows

Because:

  • package:derry/derry.dart that imports:
  • dart:cli

Package not compatible with runtime flutter-native on iOS

Because:

  • package:derry/derry.dart that imports:
  • dart:cli

Package not compatible with runtime flutter-native on macOS

Because:

  • package:derry/derry.dart that imports:
  • dart:cli

Package not compatible with runtime flutter-web on Web

Because:

  • package:derry/derry.dart that imports:
  • package:console/console.dart that imports:
  • dart:io

Package not compatible with runtime js

Because:

  • package:derry/derry.dart that imports:
  • package:console/console.dart that imports:
  • dart:io

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.8.1 <3.0.0
args ^1.6.0 1.6.0
console ^3.1.0 3.1.0
equatable ^1.2.0 1.2.2
ffi ^0.1.3 0.1.3
string_similarity ^1.0.1 1.0.1
yaml ^2.2.1 2.2.1
Transitive dependencies
charcode 1.1.3
collection 1.14.13 1.15.0-nullsafety
meta 1.2.2 1.3.0-nullsafety
path 1.7.0
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
build_runner ^1.10.0
build_version ^2.0.1
pedantic ^1.8.0
test ^1.6.0