diff --git a/main.py b/main.py
index 0e66aac..2b3af1f 100644
--- a/main.py
+++ b/main.py
@@ -11,7 +11,7 @@ from src.downloader.download import Downloader
from src.exceptions import AppNotFoundError, BuilderError, PatchesJsonLoadError, PatchingFailedError
from src.parser import Parser
from src.patches import Patches
-from src.utils import check_java, delete_old_changelog, save_patch_info
+from src.utils import check_java, delete_old_changelog, save_patch_info, write_changelog_to_file
def get_app(config: RevancedConfig, app_name: str) -> APP:
@@ -52,6 +52,7 @@ def main() -> None:
logger.exception(e)
except BuilderError as e:
logger.exception(f"Failed to build {possible_app} because of {e}")
+ write_changelog_to_file()
if __name__ == "__main__":
diff --git a/src/utils.py b/src/utils.py
index ade9548..6a02f04 100644
--- a/src/utils.py
+++ b/src/utils.py
@@ -34,6 +34,7 @@ request_timeout = 60
session = Session()
session.headers["User-Agent"] = request_header["User-Agent"]
updates_file = "updates.json"
+changelogs: dict[str, dict[str, str]] = {}
def update_changelog(name: str, response: dict[str, str]) -> None:
@@ -48,12 +49,11 @@ def update_changelog(name: str, response: dict[str, str]) -> None:
in the dictionary represent the type of change (e.g., "bug fix", "feature", "documentation"), and
the values represent the specific changes made for each type.
"""
- parent_repo = get_parent_repo()
- change_log = format_changelog(name, response, parent_repo)
- write_to_file(change_log)
+ app_change_log = format_changelog(name, response)
+ changelogs[name] = app_change_log
-def format_changelog(name: str, response: dict[str, str], parent_repo: str) -> str:
+def format_changelog(name: str, response: dict[str, str]) -> dict[str, str]:
"""The `format_changelog` returns formatted changelog string.
Parameters
@@ -64,34 +64,39 @@ def format_changelog(name: str, response: dict[str, str], parent_repo: str) -> s
response : Dict[str, str]
The `response` parameter is a dictionary that contains information about a release. It has the
following keys:
- parent_repo : str
- The `parent_repo` parameter is a string that represents the URL or name of the parent repository.
- It is used to generate a footer in the formatted changelog, indicating that the changelogs were
- generated by a specific tool or script.
Returns
-------
- a formatted changelog as a string.
+ a formatted changelog as a dict.
"""
- collapse_start = f"\n 👀 {name}
\n\n"
- release_version = f"**Release Version** - [{response['tag_name']}]({response['html_url']})
"
- change_log = f"**Changelog** -
{response['body']}"
- publish_time = f"**Published at** -
{response['published_at']}"
- footer = f"
Change logs generated by [Docker Py Revanced]({parent_repo})\n"
- collapse_end = " "
- return f"{collapse_start}{release_version}{change_log}{publish_time}{footer}{collapse_end}"
+ final_name = f"[{name}]({response['html_url']})"
+ return {
+ "Name": final_name,
+ "Version": response["tag_name"],
+ "Changelog": response["body"],
+ "Published at": response["published_at"],
+ }
-def write_to_file(change_log: str) -> None:
- """The function `write_to_file` writes a given changelog string to a file.
+def write_changelog_to_file() -> None:
+ """The function `write_changelog_to_file` writes a given changelog json to a file."""
+ markdown_table = (
+ "| AppName | Version | Changelog | Published At |\n" + "|---------|---------|-----------|--------------|\n"
+ )
+ for app_data in changelogs.values():
+ name_link = app_data["Name"]
+ version = app_data["Version"]
+ changelog = app_data["Changelog"]
+ published_at = app_data["Published at"]
- Parameters
- ----------
- change_log : str
- A string representing the changelog that you want to write to the file.
- """
- with Path(changelog_file).open("a", encoding="utf_8") as file1:
- file1.write(change_log)
+ # Clean up changelog for markdown
+ changelog = changelog.replace("\r\n", "
")
+ changelog = changelog.replace("\n", "
")
+
+ # Add row to the Markdown table string
+ markdown_table += f"| {name_link} | {version} | {changelog} | {published_at} |\n"
+ with Path(changelog_file).open("w", encoding="utf_8") as file1:
+ file1.write(markdown_table)
def get_parent_repo() -> str: