From 631108954edc2be5469951f4fa7b3282650c78bf Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Fri, 3 Jun 2022 13:41:49 +0200 Subject: [PATCH] Add github hash to service worker to auto-update caches --- package.json | 2 +- scripts/automerge-translations.sh | 7 ++++--- service-worker.ts | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 155a793b6..1fba93779 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "generate:report": "cd Docs/Tools && ./compileStats.sh && git commit . -m 'New statistics ands graphs' && git push", "generate:contributor-list": "ts-node scripts/generateContributors.ts", "generate:schemas": "ts2json-schema -p Models/ThemeConfig/Json/ -o Docs/Schemas/ -t tsconfig.json -R . -m \".*ConfigJson\" && ts-node scripts/fixSchemas.ts ", - "generate:service-worker": "tsc service-worker.ts", + "generate:service-worker": "tsc service-worker.ts && git_hash=$(git rev-parse HEAD) && sed -i \"s/GITHUB-COMMIT/$git_hash/\" service-worker.js", "optimize-images": "cd assets/generated/ && find -name '*.png' -exec optipng '{}' \\; && echo 'PNGs are optimized'", "reset:layeroverview": "echo {\\\"layers\\\":[], \\\"themes\\\":[]} > ./assets/generated/known_layers_and_themes.json && echo {\\\"layers\\\": []} > ./assets/generated/known_layers.json", "generate": "mkdir -p ./assets/generated && npm run reset:layeroverview && npm run generate:images && npm run generate:charging-stations && npm run generate:translations && npm run generate:licenses && npm run generate:layeroverview && npm run generate:service-worker", diff --git a/scripts/automerge-translations.sh b/scripts/automerge-translations.sh index 274b072e8..941fd4e9f 100755 --- a/scripts/automerge-translations.sh +++ b/scripts/automerge-translations.sh @@ -10,8 +10,9 @@ npm run generate:translations # Translation generation went fine - commit git add langs/ git add assets/ - git commit -m "Merge weblate trangsslations and regenerate translations" + git commit -m "Merge weblate translations and regenerate translations" + git push else echo "Generation of translations failed!" - git checkout HEAD - fi \ No newline at end of file + git merge --abort + fi diff --git a/service-worker.ts b/service-worker.ts index 686a048d2..29b69697e 100644 --- a/service-worker.ts +++ b/service-worker.ts @@ -1,4 +1,4 @@ -const version = "0.0.8" +const version = "0.0.8-GITHUB-COMMIT" interface ServiceWorkerFetchEvent extends Event { request: RequestInfo & {url: string},