Merge branch 'drone-ci'
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Tobias Berger 2021-10-14 13:33:54 +02:00
commit 61b9c8d66d
8 changed files with 98 additions and 21 deletions

81
.drone.yml Normal file
View file

@ -0,0 +1,81 @@
kind: pipeline
type: docker
workspace:
path: /drone/svelte-sharg
# Check if the game builds
# If yes, test if everything is nice
# If yes, deploy to vercel
steps:
- name: install
image: node
commands:
- yarn
- name: build-game
image: node
commands:
- yarn build:game
depends_on:
- install
- name: build-pwa
image: node
commands:
- yarn build:pwa
depends_on:
- install
- name: prettier
image: node
commands:
- yarn lint:prettier:all
depends_on:
- build-game
- build-pwa
- name: eslint
image: node
commands:
- yarn lint:eslint --max-warnings=0
depends_on:
- build-game
- build-pwa
- name: type-check
image: node
commands:
- yarn type-check
depends_on:
- build-game
- build-pwa
- name: deploy (production)
image: dockette/vercel
environment:
VERCEL_TOKEN:
from_secret: VERCEL_TOKEN
VERCEL_SCOPE:
from_secret: VERCEL_SCOPE
commands:
- vercel -t $VERCEL_TOKEN --scope $VERCEL_SCOPE -c
when:
branch:
- main
depends_on:
- prettier
- eslint
- type-check
- name: deploy (preview)
image: dockette/vercel
environment:
VERCEL_TOKEN:
from_secret: VERCEL_TOKEN
VERCEL_SCOPE:
from_secret: VERCEL_SCOPE
commands:
- vercel -t $VERCEL_TOKEN --scope $VERCEL_SCOPE -c
when:
branch:
exclude:
- main
depends_on:
- prettier
- eslint
- type-check

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
/node_modules/
/public/build/
/public/service-worker.js
.vercel

View file

@ -13,9 +13,9 @@
"dev:pwa": "yarn build:pwa -w",
"start": "sirv public --no-clear",
"preview": "yarn build && yarn start",
"check": "yarn check:game && yarn check:pwa",
"check:game": "svelte-check --tsconfig ./tsconfig.json",
"check:pwa": "svelte-check --tsconfig ./src/pwa/tsconfig.json",
"type-check": "yarn type-check:game && yarn type-check:pwa",
"type-check:game": "svelte-check --tsconfig ./tsconfig.json",
"type-check:pwa": "svelte-check --tsconfig ./src/pwa/tsconfig.json",
"lint": "yarn lint:prettier && yarn lint:eslint",
"lint:prettier": "pretty-quick --ignore-path .gitignore --check --plugin-search-dir=. .",
"lint:prettier:all": "prettier --ignore-path .gitignore --check --plugin-search-dir=. .",
@ -24,7 +24,7 @@
"fix:prettier": "pretty-quick --ignore-path .gitignore --write --plugin-search-dir=. .",
"fix:prettier:all": "prettier --ignore-path .gitignore --write --plugin-search-dir=. .",
"fix:eslint": "eslint --fix --ignore-path .gitignore ./src/",
"test": "yarn lint:prettier:all && yarn lint:eslint --max-warnings=0 && yarn check"
"test": "yarn lint:prettier:all && yarn lint:eslint --max-warnings=0 && yarn type-check"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^13.0.5",

View file

@ -10,10 +10,7 @@ export default {
preferConst: true,
strict: true,
},
plugins: [
typescript({ sourceMap: false, include: "**/service-worker.ts", lib: ["WebWorker"] }),
production && terser({ output: { comments: false } }),
],
plugins: [typescript({ tsconfig: "src/pwa/tsconfig.json" }), production && terser({ output: { comments: false } })],
watch: {
clearScreen: false,
},

View file

@ -1,8 +1,6 @@
<svelte:options immutable />
<script lang="ts">
import { fade } from "svelte/transition";
import type { Resource } from "../../shark/data/Resources";
export let categoryName: string;

View file

@ -5,7 +5,7 @@ const STATIC_CACHE_NAME = CACHE_NAME + "-" + CACHE_VERSION;
const INITIAL_FILES_TO_CACHE = ["/", "/index.html", "/build/bundle.js", "/build/bundle.css", "/favicon.png"];
const CACHE_DENYLIST = ["/manifest.json", "/service-worker.js", "livereload.js"];
const globalScope = self as WorkerGlobalScope as ServiceWorkerGlobalScope;
const globalScope = self as unknown /* as WorkerGlobalScope */ as ServiceWorkerGlobalScope;
globalScope.addEventListener("install", (event) => {
console.debug("[ServiceWorker] Install");
@ -41,13 +41,12 @@ globalScope.addEventListener("fetch", (event) => {
const path = new URL(event.request.url).pathname;
console.debug("[ServiceWorker] Fetch", event.request.url, "==", path);
function getFromFetch(cache: Cache) {
return fetch(event.request).then((response) => {
async function getFromFetch(cache: Cache) {
const response = await fetch(event.request);
if (!CACHE_DENYLIST.includes(path)) {
cache.put(path, response.clone());
}
return response;
});
}
async function getFromCache() {

View file

@ -2,9 +2,10 @@
"extends": "@tsconfig/svelte/tsconfig.json",
"target": "es2021",
"include": ["src/**/*"],
"exclude": ["src/service-worker.ts"],
"exclude": ["src/pwa/**"],
"compilerOptions": {
"strict": true,
"isolatedModules": false
"isolatedModules": false,
"useDefineForClassFields": true
}
}