Skip to content

Commit 5c13149

Browse files
committed
Version 0.7.0-dev.1
1 parent 10dc5b3 commit 5c13149

File tree

7 files changed

+638
-243
lines changed

7 files changed

+638
-243
lines changed

CHANGELOG.md

Lines changed: 105 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,130 @@
1+
## 0.7.0-dev.1
2+
3+
### BREAKING CHANGES
4+
5+
- A special `$script` key has been introduced with a neat 💪 platform recognition feature.
6+
7+
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!
8+
9+
```yaml
10+
scripts:
11+
where-am-i:
12+
$script:
13+
$windows: echo "You are on Windows!"
14+
$linux: echo "You are on Linux!"
15+
$macos: echo "You are on MacOs!"
16+
$default: echo "You are on... something else?"
17+
```
18+
19+
```
20+
user@MacBook-Pro Desktop % rps where-am-i
21+
> where-am-i
22+
$ echo "You are on MacOs!"
23+
24+
You are on MacOs!
25+
26+
user@MacBook-Pro Desktop %
27+
```
28+
29+
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?
30+
31+
- Added support for script references. From now on it is possible to call another rps command directly from a defined script.
32+
33+
```yaml
34+
scripts:
35+
app:
36+
clean: flutter clean
37+
clean: $app clean
38+
c: $clean
39+
clear: $c
40+
delete: $clear
41+
```
42+
This is just a simple proxy example, but you can also use it in `$before` and `$after` hooks to chain multiple scripts together.
43+
44+
- ⚠️ The `before-` and `after-` hooks has been removed. Instead use the `$before` and `$after` keys. This will help keep hook scripts grouped in a project with multiple scripts defined.
45+
46+
```yaml
47+
scripts:
48+
hooks:
49+
$before: echo "before"
50+
$script: echo "script"
51+
$after: echo "after"
52+
```
53+
54+
Execute as always.
55+
56+
```
57+
user@MacBook-Pro Desktop % rps hooks
58+
> hooks $before
59+
$ echo "before"
60+
61+
before
62+
63+
> hooks
64+
$ echo "script"
65+
66+
script
67+
68+
> hooks $after
69+
$ echo "after"
70+
71+
after
72+
73+
user@MacBook-Pro Desktop %
74+
```
75+
76+
It is also possible to link multiple scripts together!
77+
78+
```yaml
79+
scripts:
80+
get: flutter pub get
81+
test:
82+
$before: $get
83+
$script: flutter test
84+
build:
85+
$before: $test
86+
$script: flutter build apk
87+
```
88+
89+
You don't have to worry about cyclic references, RPS will keep track of them and notify you in case of a problem.
90+
191
## 0.6.5
92+
293
- Update dependencies
3-
- Longer description in pubspec.yqml
94+
- Longer description in pubspec.yaml
495
- pedantic (deprecated) replaced by flutter_lints
96+
597
## 0.6.4
98+
699
- Fixed readme example
100+
7101
## 0.6.3
102+
8103
- Minor bug fixes and improvements. 🚧
104+
9105
## 0.6.2
106+
10107
- Exposed executables.
108+
11109
## 0.6.1
110+
12111
- Minor bug fixes and improvements. 🚧
13112
- Added colorful logs. 🎨
14113
- Shared with the world via Github and pub.dev! 🌎
114+
15115
## 0.6.0
116+
16117
- Added optional `before-` and `after-` hooks support.
118+
17119
## 0.5.1
18120

19121
- A `--version` flag has been added.
122+
20123
## 0.5.0
21124

22125
- Move towards native implementation.
23126
- Added native support for linux (x86_64).
127+
24128
## 0.4.0
25129

26130
- Move towards native implementation.

README.md

Lines changed: 151 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Run Pubspec Script (RPS)
22

33
Define and use scripts from your _pubspec.yaml_ file.
4-
54

65
## Getting started
76

@@ -18,23 +17,41 @@ Define and use scripts from your _pubspec.yaml_ file.
1817
version: 1.0.0
1918

2019
scripts:
21-
# run is a default script. To use it, simply type
22-
# in the command line: "rps" - that's all!
23-
run: "flutter run -t lib/main_development.dart --flavor development"
24-
# you can define more commands like this: "rps gen"
25-
gen: "flutter pub run build_runner watch --delete-conflicting-outputs"
26-
# and even nest them!
27-
build:
28-
android:
29-
# rps build android apk
30-
apk: "flutter build --release apk --flavor production"
31-
# rps build android appbundle
32-
appbundle: "flutter build --release appbundle --flavor production"
33-
# and so on...
20+
# run is a default script. To use it, simply type
21+
# in the command line: "rps" - that's all!
22+
run: "flutter run -t lib/main_development.dart --flavor development"
23+
# you can define more commands like this: "rps gen"
24+
gen: "flutter pub run build_runner watch --delete-conflicting-outputs"
25+
# and even nest them!
26+
build:
27+
# You can use hooks to! (and even nest them!)
28+
$before: flutter pub get
29+
$after: echo "Build done!"
30+
android:
31+
# rps build android apk
32+
apk: "flutter build --release apk --flavor production"
33+
# rps build android appbundle
34+
appbundle: "flutter build --release appbundle --flavor production"
35+
# and so on...
36+
# too long command? no problem! define alias using reference syntax!
37+
bab: $build android appbundle
38+
# as simple as typing "rps baa"
39+
baa: $build android apk
40+
# some commands may vary from platform to platform
41+
# but that's not a problem
42+
clear:
43+
# use the $script key to define platform specific scripts
44+
$script:
45+
# define the default script
46+
$default: rm -rf ./cache
47+
# And different script for the windows platform.
48+
$windows: rd /s /q ./cache
49+
# now "rps clear" will work on any platform!
50+
3451

3552
# the rest of your pubspec file...
3653
dependencies:
37-
path: ^1.7.0
54+
path: ^1.7.0
3855
```
3956
4057
3. Use your custom command.
@@ -55,31 +72,135 @@ Define and use scripts from your _pubspec.yaml_ file.
5572

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

75+
## Nesting
76+
77+
Nest your commands to group them contextually and make them easier to understand 🧪
78+
79+
```yaml
80+
scripts:
81+
build:
82+
web: flutter build web --flavor production -t lib/main.dart
83+
android:
84+
apk: flutter build apk --flavor production -t lib/main.dart
85+
appbundle: flutter build appbundle --flavor production -t lib/main.dart
86+
ios:
87+
ipa: flutter build ipa --flavor production -t lib/main.dart
88+
ios: flutter build ios --flavor production -t lib/main.dart
89+
```
90+
91+
Use with ease 😏
92+
93+
```
94+
rps build android apk
95+
```
96+
97+
## References
98+
99+
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! ⛑
100+
101+
References are defined as a scripts that must begin with `$` sign.
102+
103+
```yaml
104+
scripts:
105+
generator:
106+
build: flutter pub run build_runner build --delete-conflicting-outputs
107+
watch: flutter pub run build_runner watch --delete-conflicting-outputs
108+
# short aliases:
109+
gb: $generator build # same as "rps run generator build"
110+
gw: $generator watch # same as "rps run generator watch"
111+
```
112+
113+
References can also be used with `$before` and `$after` hooks.
114+
58115
## Hooks
59-
You can use commands that will be executed **before** or **after** some command. Have a look at these scripts in the `pubspec.yaml` file.
116+
117+
To enable hooks define the `$before` and/or `$after` keys for your script command.
118+
60119
```yaml
61120
scripts:
121+
hooks:
122+
$before: echo "hello before" # executed before the $script
123+
$script: echo "hello script"
124+
$after: echo "hello after" # executed after $script
125+
```
126+
127+
Execute as always.
128+
129+
```
130+
user@MacBook-Pro Desktop % rps hooks
131+
> hooks $before
132+
$ echo "hello before"
133+
134+
hello before
135+
136+
> hooks
137+
$ echo "hello script"
138+
139+
hello script
140+
141+
> hooks $after
142+
$ echo "hello after"
143+
144+
hello after
145+
```
146+
147+
You can also combine multiple scripts using references!
148+
149+
```yaml
150+
scripts:
151+
get: flutter pub get
62152
test:
63-
before-echo: echo "before-test"
64-
echo: echo "test"
65-
after-echo: echo "after-test"
153+
# equivalent of "rps run get"
154+
$before: $get
155+
$script: flutter test
156+
build:
157+
# equivalent of "rps run test"
158+
$before: $test
159+
$script: flutter build apk
66160
```
67-
Running `rps test echo` command produces following output:
161+
162+
But wait a minute! The hooks can also be nested!
163+
164+
```yaml
165+
# Order when executing: "rps generator build"
166+
scripts:
167+
generator:
168+
$before: dart pub get # 1.
169+
$after: dart analyze # 5.
170+
build:
171+
$before: echo "Building JSON models..." # 2.
172+
$script: dart pub run build_runner build # 3.
173+
$after: echo "JSON models built successfully..." # 4.
68174
```
69-
> test before-echo
70-
$ echo "before-test"
71175
72-
before-test
73-
> test echo
74-
$ echo "test"
176+
You don't have to worry about cyclic references 🔄, RPS will keep track of them and notify you in case of a problem 😏.
177+
178+
## Platform specific scripts
179+
180+
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! 🛠
181+
182+
Just use one command on all supported platforms 💪.
183+
184+
```yaml
185+
scripts:
186+
where-am-i:
187+
$script:
188+
$windows: echo "You are on Windows!"
189+
$linux: echo "You are on Linux!"
190+
$macos: echo "You are on MacOs!"
191+
$default: echo "You are on... something else?"
192+
```
75193
76-
test
77-
> test after-echo
78-
$ echo "after-test"
194+
```
195+
user@MacBook-Pro Desktop % rps where-am-i
196+
> where-am-i
197+
$ echo "You are on MacOs!"
79198

80-
after-test
199+
You are on MacOs!
81200
```
82201

202+
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?
203+
83204
---
84205

85206
## Motivation
@@ -92,6 +213,6 @@ I got bored of typing the same long commands over and over again... I even got b
92213

93214
- Further hooks improvements.
94215

95-
___
216+
---
96217

97218
Hey you! This package is still in development (bugs may occur 🐛😏).

0 commit comments

Comments
 (0)