Skip to content

Commit 28c5944

Browse files
authored
chore(scripts): migrate the scripts from sh to dart (#2036)
* chore(scripts): migrate the scripts from sh to dart, update GitHub PR template * fix(ci): fix GitHub workflows failure by run 'flutter pub get' before running local development script
1 parent af7e404 commit 28c5944

16 files changed

+155
-173
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ Thank you for contributing.
44
55
Provide a description of your changes below and a general summary in the title.
66
7+
Consider reading the Contributor Guide: https://github.com/singerdmx/flutter-quill/blob/master/CONTRIBUTING.md.
8+
9+
The changes of `CHANGELOG.md` and package version in `pubspec.yaml` are automated.
10+
711
-->
812

913
## Description
@@ -36,8 +40,9 @@ Put an x in all the boxes that apply:
3640
- [ ] 🛠️ **Bug fix:** Resolves an issue without altering current behavior.
3741
- [ ] 🧹 **Code refactor:** Code restructuring that does not affect behavior.
3842
- [ ]**Breaking change:** Alters existing functionality and requires updates.
43+
- [ ] 🧪 **Tests:** Adds new tests or modifies existing tests.
3944
- [ ] 📝 **Documentation:** Updates or additions to documentation.
40-
- [ ] 🗑️ **Chore:** Routine tasks, tests, or maintenance.
45+
- [ ] 🗑️ **Chore:** Routine tasks, or maintenance.
4146
- [ ]**Build configuration change:** Changes to build or deploy processes.
4247

4348
## Suggestions

.github/workflows/build.yml

Lines changed: 3 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ jobs:
2424
- name: 🔍 Verify Flutter installation
2525
run: flutter --version
2626

27-
- name: 🚧 Enable local development environment (use the local packages)
28-
run: ./scripts/enable_local_dev.sh
29-
3027
- name: 📥 Install Flutter dependencies
3128
run: flutter pub get
3229

30+
- name: 🚧 Enable local development environment (use the local packages)
31+
run: dart ./scripts/enable_local_dev.dart
32+
3333
- name: 🌐 Build Flutter Web Application
3434
run: flutter build web --release --verbose --dart-define=CI=true
3535
working-directory: ./example
@@ -47,56 +47,3 @@ jobs:
4747
- name: 🐧 Build Flutter Linux Desktop Application
4848
run: flutter build linux --release --verbose --dart-define=CI=true
4949
working-directory: ./example
50-
51-
# build_windows:
52-
# name: Build Windows App
53-
# runs-on: windows-latest
54-
55-
# steps:
56-
# - uses: actions/checkout@v4
57-
# - uses: subosito/flutter-action@v2
58-
# with:
59-
# channel: 'stable'
60-
# cache: true
61-
62-
# - name: Check flutter version
63-
# run: flutter --version
64-
65-
# # Sh scripts is not supported on windows
66-
# - name: Enable Local Dev
67-
# run: ./scripts/enable_local_dev.sh
68-
69-
# - name: Install dependencies
70-
# run: flutter pub get
71-
72-
# - name: Flutter build windows
73-
# run: flutter build windows --release --verbose --dart-define=CI=true
74-
# working-directory: ./example
75-
76-
# build_macOS:
77-
# name: Build macOS App
78-
# runs-on: macos-latest
79-
80-
# steps:
81-
# - uses: actions/checkout@v4
82-
# - uses: subosito/flutter-action@v2
83-
# with:
84-
# channel: 'stable'
85-
# cache: true
86-
87-
# - name: Check flutter version
88-
# run: flutter --version
89-
90-
# - name: Enable Local Dev
91-
# run: ./scripts/enable_local_dev.sh
92-
93-
# - name: Install dependencies
94-
# run: flutter pub get
95-
96-
# - name: Flutter build macOS
97-
# run: flutter build macos --release --verbose --dart-define=CI=true
98-
# working-directory: ./example
99-
100-
# - name: Flutter build iOS
101-
# run: flutter build ios --release --verbose --dart-define=CI=true
102-
# working-directory: ./example

.github/workflows/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ jobs:
2424
- name: 🔍 Verify Flutter installation
2525
run: flutter --version
2626

27-
- name: 🚧 Enable local development environment (use the local packages)
28-
run: ./scripts/enable_local_dev.sh
29-
3027
- name: 📥 Install Flutter dependencies
3128
run: flutter pub get
3229

30+
- name: 🚧 Enable local development environment (use the local packages)
31+
run: dart ./scripts/enable_local_dev.dart
32+
3333
- name: 📦 Install dart_quill_delta dependencies
3434
run: flutter pub get -C dart_quill_delta
3535

.github/workflows/publish.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ jobs:
3737

3838
- name: 🔍 Verify Flutter installation
3939
run: flutter --version
40-
41-
- name: 🚧 Enable local development environment (use the local packages)
42-
run: ./scripts/enable_local_dev.sh
4340

4441
- name: 📥 Install Flutter dependencies
4542
run: flutter pub get
43+
44+
- name: 🚧 Enable local development environment (use the local packages)
45+
run: dart ./scripts/enable_local_dev.dart
4646

4747
# This is needed in order for the authentication to success
4848
# dart pub token add https://pub.dev --env-var PUB_TOKEN

CONTRIBUTING.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,13 @@ You will need a GitHub account as well as Git installed and configured with your
5858
cp pubspec_overrides.yaml.disabled pubspec_overrides.yaml
5959
```
6060
or save some time with the following script:
61-
<!-- TODO: We should update this script to dart instead -->
6261
```
63-
./scripts/enable_local_dev.sh
62+
dart ./scripts/enable_local_dev.dart
6463
```
6564
8. Test them in the [example](./example) and add changes in there if necessary
6665
9. Run the following script if possible
67-
```
68-
./scripts/before_push.sh
66+
```shell
67+
dart ./scripts/before_push.dart
6968
```
7069
10. When you are done sending your pull request, run:
7170
```

scripts/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Scripts
2+
3+
All the scripts must be run from the root project folder and not inside the scripts folder
4+
5+
**Example:**
6+
7+
```shell
8+
dart ./scripts/pub_get.dart
9+
```

scripts/before_push.dart

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// ignore_for_file: avoid_print
2+
3+
import 'dart:io';
4+
5+
void main() async {
6+
await runCommand('flutter', ['analyze']);
7+
8+
await runCommand('flutter', ['test']);
9+
10+
await runCommand('flutter', ['pub', 'publish', '--dry-run']);
11+
12+
await runCommand('dart', ['fix', '--apply']);
13+
14+
await runCommand('dart', ['format', '.']);
15+
16+
await runCommand('dart', ['format', '--set-exit-if-changed', '.']);
17+
18+
await runCommand(
19+
'flutter',
20+
[
21+
'build',
22+
'web',
23+
'--release',
24+
'--dart-define=CI=true',
25+
],
26+
workingDirectory: 'example',
27+
);
28+
29+
print('');
30+
31+
await runCommand('dart', ['./scripts/ensure_translations_correct.dart']);
32+
33+
print('');
34+
35+
print('Checks completed.');
36+
}
37+
38+
Future<void> runCommand(
39+
String executable,
40+
List<String> arguments, {
41+
String? workingDirectory,
42+
}) async {
43+
print(
44+
"Running '$executable ${arguments.join(' ')}' in directory '${workingDirectory ?? 'root'}'...");
45+
final result = await Process.run(executable, arguments,
46+
workingDirectory: workingDirectory);
47+
print(result.stdout);
48+
print(result.stderr);
49+
}

scripts/before_push.sh

Lines changed: 0 additions & 43 deletions
This file was deleted.

scripts/disable_local_dev.dart

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// ignore_for_file: avoid_print
2+
3+
import 'dart:io' show File;
4+
5+
import 'package:path/path.dart' as path;
6+
7+
import './pub_get.dart' as pub_get show main;
8+
import 'packages.dart' show repoPackages;
9+
10+
Future<void> main(List<String> args) async {
11+
for (final package in repoPackages) {
12+
await disable(packageDirectoryPath: package);
13+
}
14+
await pub_get.main([]);
15+
print('Local development for all libraries has been disabled');
16+
}
17+
18+
Future<void> disable({required String packageDirectoryPath}) async {
19+
final pubspecOverridesFile =
20+
File(path.join(packageDirectoryPath, 'pubspec_overrides.yaml'));
21+
if (await pubspecOverridesFile.exists()) {
22+
await pubspecOverridesFile.delete();
23+
}
24+
}

scripts/disable_local_dev.sh

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)