Skip to content

Commit

Permalink
notes when update?
Browse files Browse the repository at this point in the history
  • Loading branch information
NSPC911 committed Dec 13, 2024
1 parent e80fdf8 commit f76f69f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
4 changes: 2 additions & 2 deletions archive_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
]

archive_specs = {
'bat.zip': [f for f in all_files if f not in ['.gitignore', 'search.sh', 'archive_creator.py', 'search.json']],
'bash.zip': [f for f in all_files if f not in ['.gitignore', 'search.bat', 'archive_creator.py', 'search.json']]
'bat.zip': [f for f in all_files if f not in ['.gitignore', 'search.sh', 'archive_creator.py', 'search.json', 'notes.json']],
'bash.zip': [f for f in all_files if f not in ['.gitignore', 'search.bat', 'archive_creator.py', 'search.json', 'notes.json']]
}

for archive_name, files_to_include in archive_specs.items():
Expand Down
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"default.show_current": true,
"updater.env.current_version": "1.0.4",
"updater.canary": false,
"updater.env.canary_version": "1.0.5.8",
"updater.env.canary_version": "1.0.5.9",
"updater.auto_update": false,
"config.env.colors": {
"comment": "These are the supported colors you can refer to",
Expand Down
3 changes: 3 additions & 0 deletions notes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"1.0.5": "Updating will not work as search.config.json was renamed to just config.json, so you will need to redownload the latest version"
}
17 changes: 15 additions & 2 deletions search.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,10 @@ def main(namespace_arguments):
if response.status_code == 200:
remote_config = response.json()
current_config = load_json(config_path)
version = {"canary": {"remote": remote_config["updater.env.canary_version"].split("."), "local": current_config["updater.env.canary_version"].split(".")}, "stable": {"remote": remote_config["updater.env.current_version"].split(), "local": current_config["updater.env.current_version"].split()}}
print(version)
# Update Checker
if current_config["updater.canary"] and ( remote_config["updater.env.canary_version"][0] > current_config["updater.env.canary_version"][0] or remote_config["updater.env.canary_version"][1] > current_config["updater.env.canary_version"][1] or remote_config["updater.env.canary_version"][2] > current_config["updater.env.canary_version"][2] or remote_config["updater.env.canary_version"][3] > current_config["updater.env.canary_version"][3]):
if current_config["updater.canary"] and ( version["canary"]["remote"][0] > version["canary"]["local"][0] or version["canary"]["remote"][1] > version["canary"]["local"][1] or version["canary"]["remote"][2] > version["canary"]["local"][2] or version["canary"]["remote"][3] > version["canary"]["local"][3]):
print(f"{Fore.GREEN}New canary version found!")
# Get latest commit details (my commits are terrible)
ghapi_response = requests.get("https://api.github.com/repos/NSPC911/search/commits")
Expand All @@ -129,7 +131,7 @@ def main(namespace_arguments):
print(f"Latest commit:\n{Fore.CYAN}{commit_details['message']}")
print(f"Commit Hash: {Fore.LIGHTMAGENTA_EX}{commit_details['tree']['sha']}")
canary_current = "canary"
elif ( remote_config["updater.env.current_version"][0] > current_config["updater.env.current_version"][0] or remote_config["updater.env.current_version"][1] > current_config["updater.env.current_version"][1] or remote_config["updater.env.current_version"][2] > current_config["updater.env.current_version"][2] ):
elif ( version["stable"]["remote"][0] > version["stable"]["local"][0] or version["stable"]["remote"][1] > version["stable"]["local"][1] or version["stable"]["remote"][2] > version["stable"]["local"][2] ):
print(f"{Fore.GREEN}New stable version found")
print(f"{Fore.YELLOW}Release notes: https://github.com/NSPC911/search/releases/tag/v{remote_config['updater.env.current_version']}")
canary_current = "current"
Expand All @@ -143,6 +145,17 @@ def main(namespace_arguments):
exit(0)
# Update Chooser
should_update = ""
notes_response = requests.get(remote_url + "notes.json")
if notes_response.status_code == 200:
notes = notes_response.json()
try:
print("Updater Notes:")
note = notes[remote_config["updater.env.current_version"]]
print('-' * (len(note) + 4))
print(f'| {note} |')
print('-' * (len(note) + 4))
except KeyError:
pass
if canary_current == "canary":
print(f"{Fore.YELLOW}Canary versions are bound to have errors. You will need to set {Fore.LIGHTBLUE_EX}`updater.env.current_version`{Fore.YELLOW} to an older version and disable {Fore.LIGHTBLUE_EX}`updater.canary`{Fore.YELLOW} to revert to the stable version.")
while not should_update.lower().startswith(("y", "n")):
Expand Down

0 comments on commit f76f69f

Please sign in to comment.