Add github hash to service worker to auto-update caches

This commit is contained in:
pietervdvn 2022-06-03 13:41:49 +02:00
parent bbe1d7c35e
commit 631108954e
3 changed files with 6 additions and 5 deletions

View file

@ -34,7 +34,7 @@
"generate:report": "cd Docs/Tools && ./compileStats.sh && git commit . -m 'New statistics ands graphs' && git push", "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: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: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'", "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", "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", "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",

View file

@ -10,8 +10,9 @@ npm run generate:translations
# Translation generation went fine - commit # Translation generation went fine - commit
git add langs/ git add langs/
git add assets/ git add assets/
git commit -m "Merge weblate trangsslations and regenerate translations" git commit -m "Merge weblate translations and regenerate translations"
git push
else else
echo "Generation of translations failed!" echo "Generation of translations failed!"
git checkout HEAD git merge --abort
fi fi

View file

@ -1,4 +1,4 @@
const version = "0.0.8" const version = "0.0.8-GITHUB-COMMIT"
interface ServiceWorkerFetchEvent extends Event { interface ServiceWorkerFetchEvent extends Event {
request: RequestInfo & {url: string}, request: RequestInfo & {url: string},