@@ -4,10 +4,14 @@ import 'dart:io' show File;
44
55import 'package:yaml_edit/yaml_edit.dart' ;
66
7- // You must run this script in the root folder of the repo and not inside the scripts
8-
97import '../version.dart' ;
108
9+ /// The list of the packages that which will be used to update the `CHANGELOG.md`
10+ /// and the `README.md` , always make `'./'` at the top
11+ ///
12+ /// since we should not update the `CHANGELOG.md` of
13+ /// the `flutter_quill` since it used
14+ /// in all the packages
1115final packages = [
1216 './' ,
1317 './dart_quill_delta' ,
@@ -17,25 +21,36 @@ final packages = [
1721 './quill_pdf_converter' ,
1822];
1923
24+ /// A script that should run in the root folder of the repo and not inside
25+ /// the scripts folder
26+ ///
27+ /// it will update the versions and changelogs, the versions will be all the same
28+ /// from the `version.dart` and the changelogs will be use the same one from the
29+ /// root folder of `flutter_quill`
2030Future <void > main (List <String > args) async {
21- for (final element in packages) {
22- await updatePubspecYamlFile ('$element /pubspec.yaml' );
23- if (element != packages.first) {
24- updateChangelogMD (element );
31+ for (final packagePath in packages) {
32+ await updatePubspecYamlFile ('$packagePath /pubspec.yaml' );
33+ if (packagePath != packages.first) {
34+ updateChangelogMD ('$ packagePath /CHANGELOG.md' );
2535 }
2636 }
2737}
2838
29- Future <void > updatePubspecYamlFile (String path) async {
30- final file = File (path);
39+ /// Read the `version` variable from `version.dart`
40+ /// and update the package version
41+ /// in `pubspec.yaml` from the [pubspecYamlPath]
42+ Future <void > updatePubspecYamlFile (String pubspecYamlPath) async {
43+ final file = File (pubspecYamlPath);
3144 final yaml = await file.readAsString ();
3245 final yamlEditor = YamlEditor (yaml)..update (['version' ], version);
3346 await file.writeAsString (yamlEditor.toString ());
3447 print (yamlEditor.toString ());
3548}
3649
37- Future <void > updateChangelogMD (String path) async {
50+ /// Copy the text from the root `CHANGELOG.md` and paste it to the one
51+ /// from the [changeLogPath]
52+ Future <void > updateChangelogMD (String changeLogPath) async {
3853 final changeLog = await File ('./CHANGELOG.md' ).readAsString ();
39- final currentFile = File ('$ path /CHANGELOG.md' );
54+ final currentFile = File (changeLogPath );
4055 await currentFile.writeAsString (changeLog);
4156}
0 commit comments