docs: Update CHANGELOG.md and regenerate_versions.dart comments

pull/1710/head
Ellet 1 year ago
parent 58f131decb
commit 4661171781
  1. 2
      CHANGELOG.md
  2. 35
      scripts/regenerate_versions.dart

@ -3,7 +3,7 @@
All notable changes to this project will be documented in this file.
## 9.2.9
* Placeholder
* Refactor the type of `Delta().toJson()` to be more clear type
## 9.2.8
* feat: Export Container node as QuillContainer

@ -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);
}

Loading…
Cancel
Save