rps 0.7.0-dev.5 copy "rps: ^0.7.0-dev.5" to clipboard
rps: ^0.7.0-dev.5 copied to clipboard

rps (Run Pubspec Script) allows you to define and run scripts from pubspec.yaml.

Run Pubspec Script (RPS) #

RPS is a dart script manager that allows you to define and use scripts from the pubspec.yaml file.

Features #

Quick start 🚀 #

  1. Install this package.

    dart pub global activate rps --version 0.7.0-dev.5
    
  2. Define scripts inside the pubspec.yaml

    scripts:
      gen: flutter pub run build_runner build --delete-conflicting-outputs
    
  3. Use your custom command.

    rps gen
    # you can also provide additional arguments
    rps gen --verbose
    
  4. Safe a time and become a power user! 😈

    Less time typing long commands more time watching funny cats. 🐈

Features #

🪆 Nesting #

Nest your commands to group them contextually and make them easier to understand.

scripts:
  build:
    web: flutter build web --flavor production -t lib/main.dart
    android:
      apk: flutter build apk --flavor production -t lib/main.dart
      appbundle: flutter build appbundle --flavor production -t lib/main.dart
    ios:
      ipa: flutter build ipa --flavor production -t lib/main.dart
      ios: flutter build ios --flavor production -t lib/main.dart

Use with ease 😏

rps build android apk

🔗 References #

Sometimes you may want to create a command alias (e.g. a shorter version of it) or simply pass the execution of a hook to another command. This is where references come to the rescue! ⛑

References are defined as a scripts that must begin with $ sign.

scripts:
  generator:
    build: flutter pub run build_runner build --delete-conflicting-outputs
    watch: flutter pub run build_runner watch --delete-conflicting-outputs
  # short aliases:
  gb: $generator build # same as "rps run generator build"
  gw: $generator watch # same as "rps run generator watch"

References can also be used with $before and $after hooks.

🪝 Hooks #

To enable hooks define the $before and/or $after keys for your script command.

scripts:
  hello:
    $before: echo "hello before" # executed before the $script
    $script: echo "hello script"
    $after: echo "hello after" # executed after $script

All hooks will be executed in the specified order when calling the rps hello command.

You can also combine multiple scripts using references!

scripts:
  get: flutter pub get
  test:
    # equivalent of "rps run get"
    $before: $get
    $script: flutter test
  build:
    # equivalent of "rps run test"
    $before: $test
    $script: flutter build apk

You can also nest hooks to provide an easy-to-read workflow for all grouped commands!

# Order when executing: "rps generator build"
scripts:
  generator:
    $before: dart pub get # 1.
    $after: dart analyze # 5.
    build:
      $before: echo "Building JSON models..." # 2.
      $script: dart pub run build_runner build # 3.
      $after: echo "JSON models built successfully..." # 4.

You don't have to worry about cyclic references 🔄, RPS will keep track of them and notify you in case of a problem 😏.

💻 Platform specific scripts #

Do you work on multiple platforms? Need to use many different commands and always forget which one to use? This is what you've been waiting for! 🛠

Just use one command on all supported platforms 💪.

scripts:
  where-am-i:
    $script:
      $windows: echo "You are on Windows!"
      $linux: echo "You are on Linux!"
      $macos: echo "You are on MacOs!"
      $default: echo "You are on... something else?"
user@MacBook-Pro Desktop % rps where-am-i
> where-am-i
$ echo "You are on MacOs!"

You are on MacOs!

This can be useful for commands like rm -rf, which in Windows.... rd /s /q, you know what I mean, it can be helpful, right?

Overview example #

name: my_great_app
version: 1.0.0

scripts:
  # run is a default script. To use it, simply type
  # in the command line: "rps" - that's all!
  run: "flutter run -t lib/main_development.dart --flavor development"
  # you can define more commands like this: "rps gen"
  gen: "flutter pub run build_runner watch --delete-conflicting-outputs"
  # and even nest them!
  build:
    # You can use hooks to! (and even nest them!)
    $before: flutter pub get
    $after: echo "Build done!"
    android:
      # rps build android apk
      apk: 
        $before: echo "Building android apk..."
        $script: "flutter build --release apk --flavor production"
      # rps build android appbundle
      appbundle: "flutter build --release appbundle --flavor production"
      # and so on...
  # too long command? no problem! define alias using reference syntax!
  bab: $build android appbundle
  # as simple as typing "rps baa"
  baa: $build android apk
  # some commands may vary from platform to platform
  # but that's not a problem
  clear:
    # use the $script key to define platform specific scripts
    $script:
      # define the default script
      $default: rm -rf ./app/cache
      # And different script for the windows platform.
      $windows: rd /s /q app\cache
      # now "rps clear" will work on any platform!

  # the rest of your pubspec file...
dependencies:
  path: ^1.7.0

Motivation #

I got bored of typing the same long commands over and over again... I even got bored of pressing that boring (and even small on a MacBook) up arrow key to find my previous command in history. So, as befits a programmer, to save time, I spent more time writing this library than searching/writing commands for the last year...

stonks


Hey you! This package is still in development (errors and API changes can still occur 🐛😏).

83
likes
0
pub points
88%
popularity

Publisher

verified publisherklyta.it

rps (Run Pubspec Script) allows you to define and run scripts from pubspec.yaml.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

ffi, path, yaml

More

Packages that depend on rps