feat: add support for uptime kuma 1.19.2

This commit is contained in:
lucasheld 2022-12-29 00:22:53 +01:00
parent 1e4be04ad7
commit d01ff6d80e
17 changed files with 1128 additions and 79 deletions

1
scripts/.gitignore vendored
View file

@ -1 +1,2 @@
uptime-kuma
uptime-kuma-old

View file

@ -4,6 +4,9 @@ import re
from utils import deduplicate_list, parse_vue_template
ROOT = "uptime-kuma"
def parse_model_keys(content, object_name):
match = re.findall(object_name + r"\.[0-9a-zA-Z_$]+", content)
keys = []
@ -15,13 +18,13 @@ def parse_model_keys(content, object_name):
def parse_proxy_keys():
content = parse_vue_template("uptime-kuma/src/components/ProxyDialog.vue")
content = parse_vue_template(f"{ROOT}/src/components/ProxyDialog.vue")
keys = parse_model_keys(content, "proxy")
return keys
def parse_notification_keys():
content = parse_vue_template("uptime-kuma/src/components/NotificationDialog.vue")
content = parse_vue_template(f"{ROOT}/src/components/NotificationDialog.vue")
keys = parse_model_keys(content, "notification")
return keys
@ -37,7 +40,7 @@ def parse_settings_keys():
def parse_monitor_keys():
content = parse_vue_template("uptime-kuma/src/pages/EditMonitor.vue")
content = parse_vue_template(f"{ROOT}/src/pages/EditMonitor.vue")
keys = parse_model_keys(content, "monitor")
return keys
@ -45,11 +48,11 @@ def parse_monitor_keys():
def parse_status_page_keys():
all_keys = ["id"]
content = parse_vue_template("uptime-kuma/src/pages/StatusPage.vue")
content = parse_vue_template(f"{ROOT}/src/pages/StatusPage.vue")
keys = parse_model_keys(content, "config")
all_keys.extend(keys)
content = parse_vue_template("uptime-kuma/src/pages/ManageStatusPage.vue")
content = parse_vue_template(f"{ROOT}/src/pages/ManageStatusPage.vue")
keys = parse_model_keys(content, "statusPage")
all_keys.extend(keys)
@ -57,6 +60,12 @@ def parse_status_page_keys():
return all_keys
def parse_maintenance_keys():
content = parse_vue_template(f"{ROOT}/src/pages/EditMaintenance.vue")
keys = parse_model_keys(content, "maintenance")
return keys
def main():
proxy_keys = parse_proxy_keys()
print("proxy:", proxy_keys)
@ -73,6 +82,9 @@ def main():
status_page_keys = parse_status_page_keys()
print("status_page:", status_page_keys)
maintenance_keys = parse_maintenance_keys()
print("maintenance:", maintenance_keys)
if __name__ == "__main__":
main()

View file

@ -6,9 +6,9 @@ from bs4 import BeautifulSoup
from utils import deduplicate_list, write_to_file
def build_notification_providers():
def build_notification_providers(root):
providers = []
for path in glob.glob('uptime-kuma/server/notification-providers/*'):
for path in glob.glob(f'{root}/server/notification-providers/*'):
with open(path) as f:
content = f.read()
match = re.search(r'class [^ ]+ extends NotificationProvider {', content)
@ -27,9 +27,9 @@ def build_notification_providers():
return providers
def build_notification_provider_conditions():
def build_notification_provider_conditions(root):
conditions = {}
for path in glob.glob('uptime-kuma/src/components/notifications/*'):
for path in glob.glob(f'{root}/src/components/notifications/*'):
if path.endswith("index.js"):
continue
with open(path) as f:
@ -54,11 +54,26 @@ def build_notification_provider_conditions():
return conditions
notification_providers = build_notification_providers()
notification_provider_conditions = build_notification_provider_conditions()
def diff(old, new):
for i in new:
if i not in old:
print("+", i)
for i in old:
if i not in new:
print("-", i)
print("")
write_to_file(
"notification_providers.py.j2", "./../uptime_kuma_api/notification_providers.py",
notification_providers=notification_providers,
notification_provider_conditions=notification_provider_conditions
)
# write_to_file(
# "notification_providers.py.j2", "./../uptime_kuma_api/notification_providers.py",
# notification_providers=notification_providers,
# notification_provider_conditions=notification_provider_conditions
# )
notification_providers_old = build_notification_providers("uptime-kuma-old")
notification_providers_new = build_notification_providers("uptime-kuma")
diff(notification_providers_old, notification_providers_new)
notification_provider_conditions_old = build_notification_provider_conditions("uptime-kuma-old")
notification_provider_conditions_new = build_notification_provider_conditions("uptime-kuma")
diff(notification_provider_conditions_old, notification_provider_conditions_new)