From 4661171781cd88de74b3e65856e6dafe11f425e1 Mon Sep 17 00:00:00 2001 From: Ellet Date: Sun, 21 Jan 2024 18:52:24 +0300 Subject: [PATCH] docs: Update CHANGELOG.md and regenerate_versions.dart comments --- CHANGELOG.md | 2 +- scripts/regenerate_versions.dart | 35 +++++++++++++++++++++++--------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b93828d3..b1cb003e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/scripts/regenerate_versions.dart b/scripts/regenerate_versions.dart index 5832ef37..8b06a832 100644 --- a/scripts/regenerate_versions.dart +++ b/scripts/regenerate_versions.dart @@ -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 main(List 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 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 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 updateChangelogMD(String path) async { +/// Copy the text from the root `CHANGELOG.md` and paste it to the one +/// from the [changeLogPath] +Future 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); }