|
|
|
@ -4,10 +4,14 @@ import 'dart:io' show File; |
|
|
|
|
|
|
|
|
|
import 'package:yaml_edit/yaml_edit.dart'; |
|
|
|
|
|
|
|
|
|
// You must run this script in the root folder of the repo and not inside the scripts |
|
|
|
|
|
|
|
|
|
import '../version.dart'; |
|
|
|
|
|
|
|
|
|
/// The list of the packages that which will be used to update the `CHANGELOG.md` |
|
|
|
|
/// and the `README.md`, always make `'./'` at the top |
|
|
|
|
/// |
|
|
|
|
/// since we should not update the `CHANGELOG.md` of |
|
|
|
|
/// the `flutter_quill` since it used |
|
|
|
|
/// in all the packages |
|
|
|
|
final packages = [ |
|
|
|
|
'./', |
|
|
|
|
'./dart_quill_delta', |
|
|
|
@ -17,25 +21,36 @@ final packages = [ |
|
|
|
|
'./quill_pdf_converter', |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
/// A script that should run in the root folder of the repo and not inside |
|
|
|
|
/// the scripts folder |
|
|
|
|
/// |
|
|
|
|
/// it will update the versions and changelogs, the versions will be all the same |
|
|
|
|
/// from the `version.dart` and the changelogs will be use the same one from the |
|
|
|
|
/// root folder of `flutter_quill` |
|
|
|
|
Future<void> main(List<String> args) async { |
|
|
|
|
for (final element in packages) { |
|
|
|
|
await updatePubspecYamlFile('$element/pubspec.yaml'); |
|
|
|
|
if (element != packages.first) { |
|
|
|
|
updateChangelogMD(element); |
|
|
|
|
for (final packagePath in packages) { |
|
|
|
|
await updatePubspecYamlFile('$packagePath/pubspec.yaml'); |
|
|
|
|
if (packagePath != packages.first) { |
|
|
|
|
updateChangelogMD('$packagePath/CHANGELOG.md'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Future<void> updatePubspecYamlFile(String path) async { |
|
|
|
|
final file = File(path); |
|
|
|
|
/// Read the `version` variable from `version.dart` |
|
|
|
|
/// and update the package version |
|
|
|
|
/// in `pubspec.yaml` from the [pubspecYamlPath] |
|
|
|
|
Future<void> updatePubspecYamlFile(String pubspecYamlPath) async { |
|
|
|
|
final file = File(pubspecYamlPath); |
|
|
|
|
final yaml = await file.readAsString(); |
|
|
|
|
final yamlEditor = YamlEditor(yaml)..update(['version'], version); |
|
|
|
|
await file.writeAsString(yamlEditor.toString()); |
|
|
|
|
print(yamlEditor.toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Future<void> updateChangelogMD(String path) async { |
|
|
|
|
/// Copy the text from the root `CHANGELOG.md` and paste it to the one |
|
|
|
|
/// from the [changeLogPath] |
|
|
|
|
Future<void> updateChangelogMD(String changeLogPath) async { |
|
|
|
|
final changeLog = await File('./CHANGELOG.md').readAsString(); |
|
|
|
|
final currentFile = File('$path/CHANGELOG.md'); |
|
|
|
|
final currentFile = File(changeLogPath); |
|
|
|
|
await currentFile.writeAsString(changeLog); |
|
|
|
|
} |
|
|
|
|