gonuit / rps

Define and use scripts from your pubspec.yaml file.
MIT License
44 stars 8 forks source link

rps gen not working #12

Closed JGeek00 closed 1 year ago

JGeek00 commented 1 year ago

I'm trying to run rps gen as it's specified on the documentation but i'm receiving an error.

juan@juan-hp:~/adguard_home_manager$ rps gen
Error! Missing script for: "gen".

I tried running rps run <my command> and it worked so maybe rps gen was working but for some reason it throwed that error.

gonuit commented 1 year ago

Hi @JGeek00 👋🏻 ,

Do you have a gen script defined in your pubspec.yaml file?

For this to work, you must define the scripts of your choice yourself. As an example, your pubspec.yaml file might look as follows:

name: my_great_app
description: My great app!
publish_to: "none"

version: 1.0.0+1

scripts:
  run: "flutter run"
  gen: "flutter pub run build_runner build --delete-conflicting-outputs"
  watch: "flutter pub run build_runner watch --delete-conflicting-outputs"   

environment:
  sdk: ">=2.18.0 <3.0.0"

dependencies:
  json_annotation: 4.6.0

dev_dependencies:
  build_runner: ^2.2.1

flutter:
  uses-material-design: true

  assets:
    - assets/images/

Now you can use the rps, rps run, rps gen and rps watch commands 🕵🏻


It is also possible that you have nested the gen script under the run key. I do not recommend it, but it will work, and then calling rps gen is not possible, as it is nested under the run key.

If so, this is a change that should be made:

scripts:
-  run:
-    gen: "flutter pub run build_runner build --delete-conflicting-outputs"
+ gen: "flutter pub run build_runner build --delete-conflicting-outputs"

Let me know if this works for you 🤙🏻

JGeek00 commented 1 year ago

🤔 I think I misunderstood the instructions. I thought that after adding a custom script you had to run rps gen to "consolidate" the changes. I was running that command without having it declared on the pubspec.yaml. Now I have declared my custom script and everything works fine.