From 4a34e55847f3e9649d2860dbf53291b0f0a66cd0 Mon Sep 17 00:00:00 2001 From: Willy Woitas Date: Fri, 7 Jun 2024 00:57:29 +0200 Subject: [PATCH] Feature/cleanup deployment (#53) * maken going * add readme * cleanup deploy dir * change response loadinger --- README-ssh.md | 44 ++++++++++++++++++++++++ scripts/deploy.ts | 9 ++++- src/lib/components/a11y-inspector.svelte | 8 ++--- 3 files changed, 56 insertions(+), 5 deletions(-) diff --git a/README-ssh.md b/README-ssh.md index 8675774..d382005 100644 --- a/README-ssh.md +++ b/README-ssh.md @@ -19,3 +19,47 @@ nginx -t systemctl restart nginx systemctl reload nginx +## Nginx Config +cd etc/nginx/sites-available/ +nano default + +``` +map $query_string $proxy_host { +"~^url=(.*)" $1; +default $query_string; +} + +server { + + listen 443 ssl; + server_name a11y.neofonie.de; + + root /var/www/html; + index index.html; + + ssl_certificate /etc/ssl/neofonie/fullchain.pem; + ssl_certificate_key /etc/ssl/neofonie/privkey.pem; + + # a11y.neofonie.de/cors-hirse?url=google.com + + location /cors-ng { + rewrite ^/cors-ng(.*) /$1 break; + resolver 8.8.8.8 valid=1h; + proxy_pass https://$proxy_host; + } + + location /cors-js { + rewrite ^/cors-js(.*) /$1 break; + proxy_pass_request_headers on; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_pass http://a11y.neofonie.de:8443/https://$proxy_host; + } + + location /cors { + proxy_pass http://a11y.neofonie.de:1337; + } +} +``` diff --git a/scripts/deploy.ts b/scripts/deploy.ts index 6beb679..21b27aa 100644 --- a/scripts/deploy.ts +++ b/scripts/deploy.ts @@ -24,7 +24,14 @@ sftp passphrase: secrets.passphrase, privateKey: Buffer.from(secrets.privateKey.replace(/\|/g, "\n"), "utf-8"), }) - .then(() => sftp.uploadDir(src, secrets.destination)) + .then(() => { + // cleanup svelte dir + return sftp.rmdir(secrets.destination + "/_app", true); + }) + .then(() => { + // upload new vite + return sftp.uploadDir(src, secrets.destination); + }) .then((msg: string) => { console.log("Upload done", msg); return sftp.end(); diff --git a/src/lib/components/a11y-inspector.svelte b/src/lib/components/a11y-inspector.svelte index e069d8d..4ea7e54 100644 --- a/src/lib/components/a11y-inspector.svelte +++ b/src/lib/components/a11y-inspector.svelte @@ -31,13 +31,13 @@ function loadPagePerProxy() { if (src && elmIframe) { fetch(proxy + src) - .then((response) => response.text()) - .then((rawHTML) => { - elmIframe.src = `data:text/html;charset=utf-8,${escape(rawHTML)}`; + .then((response) => response.json()) + .then((json) => { + elmIframe.src = `data:text/html;charset=utf-8,${escape(json.html)}`; if (DOMParser) { const parser = new DOMParser(), - doc = parser.parseFromString(rawHTML, 'text/html'); + doc = parser.parseFromString(json.html, 'text/html'); watchedA11yContent(doc); testA11yRules();