diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml index a330c5f..cde5dad 100644 --- a/.gitea/workflows/deploy.yaml +++ b/.gitea/workflows/deploy.yaml @@ -139,6 +139,7 @@ jobs: docker logs $container_id || true echo "::endgroup::" done + #- name: Wait for Live Server # run: | # attempts=0 @@ -184,18 +185,15 @@ jobs: - name: Lighthouse Analysis run: | yarn add lighthouse - npx lighthouse http://live-server:80 --output json --output-path /tmp/lighthouse-report.json --chrome-flags="--headless --no-sandbox --disable-dev-shm-usage" + npx lighthouse http://live-server:80 --output json --output-path /tmp/lighthouse-report.json --chrome-flags="--headless --no-sandbox --disable-dev-shm-usage" - # Notify-Lighthouse Step - - name: Notify Lighthouse + - name: upload-to-nextcloud run: | - docker run --rm \ - -e PLUGIN_FROM=noreply@gitbase.de \ - -e PLUGIN_HOST=smtp.basehosts.de \ - -e PLUGIN_RECIPIENT=binkrassdufass@gmail.com \ - -e PLUGIN_SUBJECT="Lighthouse Report" \ - -v ${{ github.workspace }}/tmp:/lighthouse-reports \ - drillster/drone-email /tmp/lighthouse-report.json + sudo apt-get update && sudo apt-get install -y curl bash findutils + export datetime=`date +%Y-%m-%d_%H-%M-%S` + mkdir -p /tmp/cloudsend/${GITHUB_REF_NAME}/$${datetime} + mv /tmp/lighthouse-report.json /tmp/cloudsend/${GITHUB_REF_NAME}/$${datetime}/ + ./scripts/cloudsend.sh /tmp/cloudsend/ https://www.basiswolke.de/index.php/s/xHGsypbqiifnGH5 deploy: name: deploy @@ -242,24 +240,6 @@ jobs: - name: setup node 18 uses: actions/setup-node@v3 - - name: container within a step - uses: docker://node:20-alpine3.19 - with: - entrypoint: echo - args: "dastest" - - name: check docker networking infos - run: | - echo "${{ toJson(job) }}" - echo "${{ github }}" - docker network ls - docker network inspect bridge - docker network inspect host - docker network inspect none - docker network inspect container:${{ job.services.tibi-server.id }} - docker network inspect container:${{ job.services.live-server.id }} - docker network inspect container:${{ job.services.mongo.id }} - docker network inspect container:${{ job.services.maildev.id }} - - name: install dependencies env: FORCE_COLOR: "true" @@ -310,58 +290,6 @@ jobs: run: | yarn build:legacy - - name: Wait for Live Server - run: | - attempts=0 - max_attempts=2 - while ! curl --output /dev/null --silent --head --fail http://live-server:8081; do - if [ $attempts -eq $max_attempts ]; then - echo "Live server not ready after $max_attempts attempts" - echo "${{ toJson(job) }}" - curl -v http://live-server:8081 - exit 1 - fi - attempts=$((attempts+1)) - echo "Waiting for live-server to be ready... attempt $attempts" - sleep 5 - done - - - name: Test HTTP Request - run: | - echo "Live server not ready after $max_attempts attempts" - echo "${{ toJson(job) }}" - echo "${{ job.services.live-server.id }}" - echo "${{ job.services.tibi-server.id }}" - echo "${{ job.services.mongo.id }}" - docker logs "${{ job.services.tibi-server.id }}" - docker logs "${{ job.services.live-server.id }}" - curl -v http://live-server:8081 - - - name: Install Chrome - run: | - wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add - - sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list' - - sudo apt-get update - sudo apt-get install -y google-chrome-stable - - # Lighthouse Analysis Step - - name: Lighthouse Analysis - run: | - yarn add lighthouse - npx lighthouse http://127.0.0.1:8081 --output json --output-path /tmp/lighthouse-report.json --chrome-flags="--headless --no-sandbox --disable-dev-shm-usage" - - # Notify-Lighthouse Step - - name: Notify Lighthouse - run: | - docker run --rm \ - -e PLUGIN_FROM=noreply@gitbase.de \ - -e PLUGIN_HOST=smtp.basehosts.de \ - -e PLUGIN_RECIPIENT=recipient@example.com \ - -e PLUGIN_SUBJECT="Lighthouse Report" \ - -v ${{ github.workspace }}/tmp:/lighthouse-reports \ - drillster/drone-email /tmp/lighthouse-report.json - - name: deploy if: github.ref == 'refs/heads/master' env: diff --git a/.yarn/cache/@puppeteer-browsers-npm-1.8.0-ac87d69e47-94bd9ba2c9.zip b/.yarn/cache/@puppeteer-browsers-npm-1.9.0-307336e7c9-9a1cad8b76.zip similarity index 58% rename from .yarn/cache/@puppeteer-browsers-npm-1.8.0-ac87d69e47-94bd9ba2c9.zip rename to .yarn/cache/@puppeteer-browsers-npm-1.9.0-307336e7c9-9a1cad8b76.zip index 169db53..f2fbb2d 100644 Binary files a/.yarn/cache/@puppeteer-browsers-npm-1.8.0-ac87d69e47-94bd9ba2c9.zip and b/.yarn/cache/@puppeteer-browsers-npm-1.9.0-307336e7c9-9a1cad8b76.zip differ diff --git a/.yarn/cache/chromium-bidi-npm-0.4.33-423dcfa06c-a7c8191a54.zip b/.yarn/cache/chromium-bidi-npm-0.4.33-423dcfa06c-a7c8191a54.zip deleted file mode 100644 index cd88956..0000000 Binary files a/.yarn/cache/chromium-bidi-npm-0.4.33-423dcfa06c-a7c8191a54.zip and /dev/null differ diff --git a/.yarn/cache/chromium-bidi-npm-0.5.1-8c30837a41-be7f695857.zip b/.yarn/cache/chromium-bidi-npm-0.5.1-8c30837a41-be7f695857.zip new file mode 100644 index 0000000..5854d35 Binary files /dev/null and b/.yarn/cache/chromium-bidi-npm-0.5.1-8c30837a41-be7f695857.zip differ diff --git a/.yarn/cache/lighthouse-npm-11.3.0-85461f7973-a6297c09e6.zip b/.yarn/cache/lighthouse-npm-11.4.0-0e1b6f54c4-403e9a9cd5.zip similarity index 51% rename from .yarn/cache/lighthouse-npm-11.3.0-85461f7973-a6297c09e6.zip rename to .yarn/cache/lighthouse-npm-11.4.0-0e1b6f54c4-403e9a9cd5.zip index 5b3d69c..ce1d8f4 100644 Binary files a/.yarn/cache/lighthouse-npm-11.3.0-85461f7973-a6297c09e6.zip and b/.yarn/cache/lighthouse-npm-11.4.0-0e1b6f54c4-403e9a9cd5.zip differ diff --git a/.yarn/cache/puppeteer-core-npm-21.5.2-477eb4a6be-62d3ef8e8a.zip b/.yarn/cache/puppeteer-core-npm-21.6.1-6600eb7f9b-954c5afd4d.zip similarity index 65% rename from .yarn/cache/puppeteer-core-npm-21.5.2-477eb4a6be-62d3ef8e8a.zip rename to .yarn/cache/puppeteer-core-npm-21.6.1-6600eb7f9b-954c5afd4d.zip index a3f869c..55fb419 100644 Binary files a/.yarn/cache/puppeteer-core-npm-21.5.2-477eb4a6be-62d3ef8e8a.zip and b/.yarn/cache/puppeteer-core-npm-21.6.1-6600eb7f9b-954c5afd4d.zip differ diff --git a/.yarn/cache/tldts-core-npm-6.1.1-dd6ce3d117-0ce2ec0d8e.zip b/.yarn/cache/tldts-core-npm-6.1.1-dd6ce3d117-0ce2ec0d8e.zip new file mode 100644 index 0000000..d0ec3e1 Binary files /dev/null and b/.yarn/cache/tldts-core-npm-6.1.1-dd6ce3d117-0ce2ec0d8e.zip differ diff --git a/.yarn/cache/tldts-icann-npm-6.1.1-97bf20a573-b5a123fef9.zip b/.yarn/cache/tldts-icann-npm-6.1.1-97bf20a573-b5a123fef9.zip new file mode 100644 index 0000000..3911b09 Binary files /dev/null and b/.yarn/cache/tldts-icann-npm-6.1.1-97bf20a573-b5a123fef9.zip differ diff --git a/.yarn/cache/ws-npm-8.14.2-b339ac47a2-3ca0dad26e.zip b/.yarn/cache/ws-npm-8.15.1-a30b5eeb2f-8c67365f6e.zip similarity index 53% rename from .yarn/cache/ws-npm-8.14.2-b339ac47a2-3ca0dad26e.zip rename to .yarn/cache/ws-npm-8.15.1-a30b5eeb2f-8c67365f6e.zip index 3b17534..ca1dca2 100644 Binary files a/.yarn/cache/ws-npm-8.14.2-b339ac47a2-3ca0dad26e.zip and b/.yarn/cache/ws-npm-8.15.1-a30b5eeb2f-8c67365f6e.zip differ diff --git a/api/collections/content.yml b/api/collections/content.yml index 1f55b0b..b78055e 100644 --- a/api/collections/content.yml +++ b/api/collections/content.yml @@ -46,6 +46,22 @@ meta: subFields: - source: aktiv - source: meta + subNavigation: + - name: modalForeign + defaultSort: + field: "path" + order: "ASC" + views: + - type: table + columns: + - path + defaultCallback: + eval: | + //js + (entry) => { + parent.selectEntry(entry) + } + //!js imageFilter: xs: diff --git a/api/collections/lighthouse-subpaths.yml b/api/collections/lighthouse-subpaths.yml new file mode 100644 index 0000000..d378cc6 --- /dev/null +++ b/api/collections/lighthouse-subpaths.yml @@ -0,0 +1,29 @@ +name: lighthouseSubpath + +meta: + label: Lighthouse Subpaths + muiIcon: web + views: + - type: table + columns: + - source: lighthouseSubpath + +permissions: + public: + methods: + get: false + post: false + put: false + delete: false + user: + methods: + get: true + post: true + put: true + delete: true + +fields: + - type: string + name: lighthouseSubpath + meta: + label: PagespeedPaths diff --git a/api/collections/lighthouse.yml b/api/collections/lighthouse.yml new file mode 100644 index 0000000..d76c5bd --- /dev/null +++ b/api/collections/lighthouse.yml @@ -0,0 +1,120 @@ +name: lighthouse + +meta: + label: Lighthouse + muiIcon: web + views: + - type: table + mediaQuery: "(min-width: 600px)" + columns: + - source: insertTime + filter: true + - source: perfomance + filter: true + - source: accessibility + filter: true + - source: bestPractices + filter: true + - source: seo + filter: true + - type: simpleList + mediaQuery: "(max-width: 599px)" + primaryText: insertTime + secondaryText: performance + tertiaryText: accessibility + +permissions: + public: + methods: + get: false + post: false + put: false + delete: false + user: + methods: + get: true + post: true + put: true + delete: true + +projections: + dashboard: + +hooks: + post: + create: + type: javascript + file: hooks/lighthouse/post_create.js + +fields: + - name: analyzedPaths + type: string[] + meta: + label: Analyzed Paths + - name: performance + type: number + meta: + label: Performance + - name: accessibility + type: number + meta: + label: Accessibility + - name: bestPractices + type: number + meta: + label: Best Practices + - name: seo + type: number + meta: + label: SEO + - name: lighthouseMetrics + + type: object + meta: + label: Lighthouse Metrics + subFields: + - name: FCPS + type: number + meta: + label: First Contentful Paint Score + - name: FCPV + type: number + meta: + label: First Contentful Paint Value + - name: FMPV + type: number + meta: + label: First Meaningful Paint Value + + - name: FMPS + type: number + meta: + label: First Meaningful Paint Score + + - name: SIS + type: number + meta: + label: Speed Index Score + + - name: SIV + type: number + meta: + label: Speed Index Value + - name: TTIS + type: number + meta: + label: Time to Interactive Score + + - name: TTIV + type: number + meta: + label: Time to Interactive Value + - name: FPIDS + type: number + meta: + label: First Potential Input Delay Score + + - name: FPIDV + type: number + meta: + label: First Potential Input Delay Value diff --git a/api/config.yml b/api/config.yml index ca04f9c..11b1112 100644 --- a/api/config.yml +++ b/api/config.yml @@ -5,15 +5,250 @@ meta: servers: - url: https://tibi-admin-server.code.testversion.online/api/v1/_/demo description: code-server + dashboard: majorItems: - - collection: banner # Sammlung, aus der die Daten für das nächste Element stammen - type: reference # Art des Elements, hier ein Referenz-Element - style: # Stil des Elements - upper: rgba(3, 50, 59, 0.7) # Farbe des oberen Teils - lower: rgba(3, 50, 59) # Farbe des unteren Teils + - type: "sectionTitle" + title: { de: "Website Perfomance", en: "Website Perfomance" } + appendix: + collection: lighthouse + eval: | + (function(){ + return " " + new Date($date).toLocaleDateString() + "" + })() + - type: graph + filter: false + graphType: radialBar + until: "lastYear" + value: total + containerProps: + #optional class prop + layout: + breakBefore: false + breakAfter: false + size: + default: "col-6" + small: "col-12" + large: "col-3" + options: + { + property: plotOptions, + value: + { + radialBar: + { + hollow: { margin: 0, size: "70%" }, + track: { dropShadow: { enabled: true, top: 2, left: 0, blur: 4, opacity: 0.15 } }, + dataLabels: + { + name: { offsetY: -10, color: "#000", fontSize: "13px" }, + value: { color: "#000", fontSize: "30px", show: true }, + }, + }, + }, + } + graphs: + - collection: lighthouse + field: performance + yAxis: latestValue + graphName: { de: "Perfomance Score", en: "Perfomance Score" } + dateTimeField: insertTime - - collection: content # Wiederholung der vorherigen Elemente + - type: graph + filter: false + graphType: radialBar + until: "lastYear" + value: total + containerProps: + #optional class prop + layout: + breakBefore: false + breakAfter: false + size: + default: "col-6" + small: "col-12" + large: "col-3" + options: + { + property: plotOptions, + value: + { + radialBar: + { + hollow: { margin: 0, size: "70%" }, + track: { dropShadow: { enabled: true, top: 2, left: 0, blur: 4, opacity: 0.15 } }, + dataLabels: + { + name: { offsetY: -10, color: "#000", fontSize: "13px" }, + value: { color: "#000", fontSize: "30px", show: true }, + }, + }, + }, + } + graphs: + - collection: lighthouse + field: accessibility + yAxis: latestValue + graphName: { de: "Accessibility Score", en: "Accessibility Score" } + dateTimeField: insertTime + + - type: graph + filter: false + graphType: radialBar + until: "lastYear" + value: total + containerProps: + #optional class prop + layout: + breakBefore: false + breakAfter: false + size: + default: "col-6" + small: "col-12" + large: "col-3" + options: + { + property: plotOptions, + value: + { + radialBar: + { + hollow: { margin: 0, size: "70%" }, + track: { dropShadow: { enabled: true, top: 2, left: 0, blur: 4, opacity: 0.15 } }, + dataLabels: + { + name: { offsetY: -10, color: "#000", fontSize: "13px" }, + value: { color: "#000", fontSize: "30px", show: true }, + }, + }, + }, + } + graphs: + - collection: lighthouse + field: bestPractices + yAxis: latestValue + graphName: { de: "Best Practices Score", en: "Best Practices Score" } + dateTimeField: insertTime + + - type: graph + filter: false + graphType: radialBar + until: "lastYear" + value: total + containerProps: + #optional class prop + layout: + breakBefore: false + breakAfter: false + size: + default: "col-6" + small: "col-12" + large: "col-3" + options: + { + property: plotOptions, + value: + { + radialBar: + { + hollow: { margin: 0, size: "70%" }, + track: { dropShadow: { enabled: true, top: 2, left: 0, blur: 4, opacity: 0.15 } }, + dataLabels: + { + name: { offsetY: -10, color: "#000", fontSize: "13px" }, + value: { color: "#000", fontSize: "30px", show: true }, + }, + }, + }, + } + graphs: + - collection: lighthouse + field: seo + yAxis: latestValue + graphName: { de: "SEO Score", en: "SEO Score" } + dateTimeField: insertTime + + - type: swiper # Art des Elements, hier ein Swiper + containerProps: + #optional class prop + layout: + breakBefore: false + breakAfter: false + size: + default: "col-12" + small: "col-12" + large: "col-6 row-2-4" + + elements: # Liste der Elemente in diesem Swiper + - type: graph + title: + value: { de: "Ladezeit (Score)", en: "Loadtime (Score)" } + xAxis: manual + until: "lastYear" + filter: false #deaktiviert die Filter möglichkeit für den Nutzer beim diagramm, normalerweise aktiviert. Hierbei sind alle kombinationen x >= until möglich + columns: + - name: { de: '["Erstes sichtbares", "Element"]', en: '["First Contentful", "Paint"]' } + field: lighthouseMetrics.FCPS + + - name: { de: '["Erstes bedeutsames", "Element"]', en: '["First Meaningful", "Paint"]' } + field: lighthouseMetrics.FMPS + + - name: + { + de: '["Maximale potenzielle", "erste", "ingabeverzögerung"]', + en: '["Max Potential", "First Input", "Delay"]', + } + field: lighthouseMetrics.FPIDS + + - name: { de: '["Zeit bis", "zur", "Interaktivität"]', en: '["Time to", "Interactive"]' } + field: lighthouseMetrics.TTIS + + - name: { de: '["Geschwindigkeitsindex"]', en: '["Speed Index"]' } + field: lighthouseMetrics.SIS + + graphType: "bar" + graphs: + - graphName: { de: "Lighthouse Metriken", en: "Lighthouse Metrics" } + yAxis: latestValue + collection: lighthouse + dateTimeField: insertTime + - type: graph + title: + value: { de: "Ladezeit (Sekunden)", en: "Loadtime (seconds)" } + xAxis: manual + until: "lastYear" + filter: false #deaktiviert die Filter möglichkeit für den Nutzer beim diagramm, normalerweise aktiviert. Hierbei sind alle kombinationen x >= until möglich + columns: + - name: { de: '["Erstes sichtbares", "Element"]', en: '["First Contentful", "Paint"]' } + field: lighthouseMetrics.FCPV + + - name: { de: '["Erstes bedeutsames", "Element"]', en: '["First Meaningful", "Paint"]' } + field: lighthouseMetrics.FMPV + + - name: + { + de: '["Maximale potenzielle", "erste", "ingabeverzögerung"]', + en: '["Max Potential", "First Input", "Delay"]', + } + field: lighthouseMetrics.FPIDV + + - name: { de: '["Zeit bis", "zur", "Interaktivität"]', en: '["Time to", "Interactive"]' } + field: lighthouseMetrics.TTIV + + - name: { de: '["Geschwindigkeitsindex"]', en: '["Speed Index"]' } + field: lighthouseMetrics.SIV + + graphType: "bar" + graphs: + - graphName: { de: "Lighthouse Metriken", en: "Lighthouse Metrics" } + yAxis: latestValue + collection: lighthouse + dateTimeField: insertTime + + - type: "sectionTitle" + title: { de: "Seiteninhalte", en: "Page content" } + + - collection: content type: reference style: upper: rgba(3, 50, 59, 0.7) @@ -30,6 +265,26 @@ meta: style: upper: rgba(3, 50, 59, 0.7) lower: rgba(3, 50, 59) + + - type: "sectionTitle" + title: { de: "Aktionen", en: "Actions" } + + - collection: lighthouse + type: action + action: "Lighthouse Durchlauf starten" + backgroundAction: true + modalText: + { + de: "Zur Analyse der Website werden einige Zeitintensive prozesse gestartet, daher wird dies im Hintergrund ausgeführt. Es kann einige Minuten dauern bis das Dashboard aktuallisiert wird, bitte haben Sie etwas Geduld.", + en: "To analyze the website, some time-intensive processes are started, so this is done in the background. It may take a few minutes for the dashboard to be updated, please be patient.", + } + properties: + url: https://allkids-erfurt.de + type: post + style: + upper: rgba(3, 50, 59, 0.7) + lower: rgba(3, 50, 59) + minorItems: [] collections: @@ -39,8 +294,10 @@ collections: - !include collections/forms.yml - !include collections/backups.yml - !include collections/ssr.yml + - !include collections/lighthouse.yml + - !include collections/lighthouse-subpaths.yml jobs: - - cron: "0 * * * *" + - cron: "* * * * " type: javascript - file: jobs/requestTemperature.js + file: jobs/lighthouse.js diff --git a/api/hooks/config.js b/api/hooks/config.js index f4e436a..41d98f8 100644 --- a/api/hooks/config.js +++ b/api/hooks/config.js @@ -29,4 +29,5 @@ module.exports = { return -1 }, ssrPublishCheckCollections: ["content"], + LIGHTHOUSE_TOKEN: "AIzaSyC0UxHp3-MpJiDL3ws7pEV6lj57bfIc7GQ", } diff --git a/api/hooks/lib/utils.js b/api/hooks/lib/utils.js index 922ef24..8af433a 100644 --- a/api/hooks/lib/utils.js +++ b/api/hooks/lib/utils.js @@ -37,6 +37,7 @@ function obj2str(obj) { if (obj) return obj } +var { LIGHTHOUSE_TOKEN } = require("../config") /** * clear SSR cache @@ -46,8 +47,103 @@ function clearSSRCache() { context.response.header("X-SSR-Cleared", info.removed) } +function calculateAverageDynamically(dbObjs) { + const sumObj = {} + let count = 0 + + dbObjs.forEach((obj) => { + accumulate(obj, sumObj) + count++ + }) + + function accumulate(sourceObj, targetObj) { + for (const key in sourceObj) { + if (typeof sourceObj[key] === "number") { + targetObj[key] = (targetObj[key] || 0) + sourceObj[key] + } else if (typeof sourceObj[key] === "object" && sourceObj[key] !== null) { + targetObj[key] = targetObj[key] || {} + accumulate(sourceObj[key], targetObj[key]) + } + } + } + + function average(targetObj) { + for (const key in targetObj) { + if (typeof targetObj[key] === "number") { + targetObj[key] = targetObj[key] / count + } else if (typeof targetObj[key] === "object") { + average(targetObj[key]) + } + } + } + + average(sumObj) + return sumObj +} + +function run(url) { + const response = context.http + .fetch(url, { + timeout: 300, + method: "GET", + headers: { + "Content-Type": "application/json", + }, + }) + .body.json() + // needs enough traffic to be collected + const cruxMetrics = { + "First Contentful Paint": response?.loadingExperience?.metrics?.FIRST_CONTENTFUL_PAINT_MS?.category, + "First Input Delay": response?.loadingExperience?.metrics?.FIRST_INPUT_DELAY_MS?.category, + } + const lighthouse = response.lighthouseResult + const lighthouseMetrics = { + FCPS: lighthouse.audits["first-contentful-paint"].score * 100, + FCPV: lighthouse.audits["first-contentful-paint"].numericValue / 1000, + FMPS: lighthouse.audits["first-meaningful-paint"].score * 100, + FMPV: lighthouse.audits["first-meaningful-paint"].numericValue / 1000, + + SIS: lighthouse.audits["speed-index"].score * 100, + SIV: lighthouse.audits["speed-index"].numericValue / 1000, + TTIS: lighthouse.audits["interactive"].score * 100, + TTIV: lighthouse.audits["interactive"].numericValue / 1000, + + FPIDS: lighthouse.audits["max-potential-fid"].score * 100, + FPIDV: lighthouse.audits["max-potential-fid"].numericValue / 1000, + } + + let dbObject = { + cruxMetrics, + lighthouseMetrics, + performance: lighthouse.categories.performance.score * 100, + accessibility: lighthouse.categories.accessibility.score * 100, + bestPractices: lighthouse.categories["best-practices"].score * 100, + seo: lighthouse.categories.seo.score * 100, + } + return dbObject +} +function setUpQuery(subPath = "/") { + const api = "https://www.googleapis.com/pagespeedonline/v5/runPagespeed" + let params = `category=performance&category=accessibility&category=best-practices&category=seo` + + const parameters = { + url: encodeURIComponent(`https://allkids-erfurt.de/${subPath}`), + key: LIGHTHOUSE_TOKEN, + } + + let query = `${api}?` + for (let key in parameters) { + query += `${key}=${parameters[key]}&` + } + query += params // Append other parameters without URL encoding + return query +} + module.exports = { log, clearSSRCache, obj2str, + run, + setUpQuery, + calculateAverageDynamically, } diff --git a/api/hooks/lighthouse/post_create.js b/api/hooks/lighthouse/post_create.js new file mode 100644 index 0000000..e3f1038 --- /dev/null +++ b/api/hooks/lighthouse/post_create.js @@ -0,0 +1,16 @@ +var { setUpQuery, calculateAverageDynamically, run } = require("../lib/utils") +;(function () { + let subPaths = context.db.find("lighthouseSubpath") + let urls = [] + for (let i = 0; i < subPaths.length; i++) { + urls.push(setUpQuery(subPaths[i].lighthouseSubpath)) + } + let dbObjs = [] + urls.forEach((url) => { + console.log("URL:", url) + dbObjs.push(run(url)) + }) + let dbObject = calculateAverageDynamically(dbObjs) + dbObject.analyzedPaths = [...subPaths].map((subPath) => subPath.lighthouseSubpath) + return { data: dbObject } +})() diff --git a/api/jobs/lighthouse.js b/api/jobs/lighthouse.js new file mode 100644 index 0000000..c13a13d --- /dev/null +++ b/api/jobs/lighthouse.js @@ -0,0 +1,17 @@ +var { setUpQuery, calculateAverageDynamically, run } = require("../hooks/lib/utils") +;(function () { + console.log("Running lighthouse job") + let subPaths = context.db.find("lighthouseSubpath") + let urls = [] + for (let i = 0; i < subPaths.length; i++) { + urls.push(setUpQuery(subPaths[i].lighthouseSubpath)) + } + let dbObjs = [] + urls.forEach((url) => { + console.log("URL:", url) + dbObjs.push(run(url)) + }) + let dbObject = calculateAverageDynamically(dbObjs) + dbObject.analyzedPaths = [...subPaths].map((subPath) => subPath.lighthouseSubpath) + context.db.create("lighthouse", dbObject) +})() diff --git a/api/jobs/requestTemperature.js b/api/jobs/requestTemperature.js deleted file mode 100644 index 9b00180..0000000 --- a/api/jobs/requestTemperature.js +++ /dev/null @@ -1,9 +0,0 @@ -function requestTemperature() { - let response = context.http.fetch( - "https://api.openweathermap.org/data/2.5/weather?lat=50.98&lon=11.03&appid=21fa3d5930956682000f7a2db5f357c0" - ) - let data = response.body.json() - let temperatureEntries = context.db.find("temperature") - context.db.update("temperature", temperatureEntries[0].id, { temperature: data.main.temp - 273.15 }) -} -requestTemperature() diff --git a/package.json b/package.json index cf1cee9..218139b 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,6 @@ "core-js": "3.32.2", "cssnano": "^6.0.1", "external-svg-loader": "^1.6.10", - "lighthouse": "^11.3.0", "live-server": "1.2.1", "postcss-import": "^15.1.0", "postcss-load-config": "^4.0.1", diff --git a/yarn.lock b/yarn.lock index d92c64a..280b0fb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2171,9 +2171,9 @@ __metadata: languageName: node linkType: hard -"@puppeteer/browsers@npm:1.8.0": - version: 1.8.0 - resolution: "@puppeteer/browsers@npm:1.8.0" +"@puppeteer/browsers@npm:1.9.0": + version: 1.9.0 + resolution: "@puppeteer/browsers@npm:1.9.0" dependencies: debug: 4.3.4 extract-zip: 2.0.1 @@ -2184,7 +2184,7 @@ __metadata: yargs: 17.7.2 bin: browsers: lib/cjs/main-cli.js - checksum: 94bd9ba2c9b33bf41a5d7ae7c4c7384afd09c54aa5356b6e2e2ed67d7f3f2d76941e3cb431f270baa9e572701f12289ae58bcb63a46b251deaff4030c64f2426 + checksum: 9a1cad8b760333a46f6ea69f07b1049b9b5da3aef3354da76089176998018aa10c4eeb5adb965405c9a899da81205cf60e845beca643bfe5a4a63410328fe131 languageName: node linkType: hard @@ -3221,15 +3221,15 @@ __metadata: languageName: node linkType: hard -"chromium-bidi@npm:0.4.33": - version: 0.4.33 - resolution: "chromium-bidi@npm:0.4.33" +"chromium-bidi@npm:0.5.1": + version: 0.5.1 + resolution: "chromium-bidi@npm:0.5.1" dependencies: mitt: 3.0.1 urlpattern-polyfill: 9.0.0 peerDependencies: devtools-protocol: "*" - checksum: a7c8191a541a97a01fb7781b4258a2cf6d046bfa572065db60c97d59510670a2b9b62cf6adb7f78de9b8ff5abbc5f8a9086adec9aee1da3994576e5cd92dd07d + checksum: be7f695857210869dbd1cfa869285367c7982ae9a0acda2cc5b20265eb83748d98a641477bf3405da72e62dc39dd71b18829cc09d04d9fb06c9cd1c971e30046 languageName: node linkType: hard @@ -5562,9 +5562,9 @@ __metadata: languageName: node linkType: hard -"lighthouse@npm:^11.3.0": - version: 11.3.0 - resolution: "lighthouse@npm:11.3.0" +"lighthouse@npm:^11.4.0": + version: 11.4.0 + resolution: "lighthouse@npm:11.4.0" dependencies: "@sentry/node": ^6.17.4 axe-core: ^4.8.1 @@ -5585,11 +5585,12 @@ __metadata: open: ^8.4.0 parse-cache-control: 1.0.1 ps-list: ^8.0.0 - puppeteer-core: ^21.5.0 + puppeteer-core: ^21.5.2 robots-parser: ^3.0.1 semver: ^5.3.0 speedline-core: ^1.4.3 - third-party-web: ^0.24.0 + third-party-web: ^0.24.1 + tldts-icann: ^6.1.0 ws: ^7.0.0 yargs: ^17.3.1 yargs-parser: ^21.0.0 @@ -5597,7 +5598,7 @@ __metadata: chrome-debug: core/scripts/manual-chrome-launcher.js lighthouse: cli/index.js smokehouse: cli/test/smokehouse/frontends/smokehouse-bin.js - checksum: a6297c09e66d57efa8bb85fcf4af007e04ce1922cb7e2e328ae04e93df82d03ec35cf43b9e87a504253cb1c80b1229f249a7f7f71ed40bd38b78ce91c24067af + checksum: 403e9a9cd572cbbb965f419474c13b22db1cdd03d1e297d5edd8cde4510ccd5c6de4dcb8fd2324924085599c17b9d380d9d2a8bd564748eb2b64f1e46589a4aa languageName: node linkType: hard @@ -7451,17 +7452,17 @@ __metadata: languageName: node linkType: hard -"puppeteer-core@npm:^21.5.0": - version: 21.5.2 - resolution: "puppeteer-core@npm:21.5.2" +"puppeteer-core@npm:^21.5.2": + version: 21.6.1 + resolution: "puppeteer-core@npm:21.6.1" dependencies: - "@puppeteer/browsers": 1.8.0 - chromium-bidi: 0.4.33 + "@puppeteer/browsers": 1.9.0 + chromium-bidi: 0.5.1 cross-fetch: 4.0.0 debug: 4.3.4 devtools-protocol: 0.0.1203626 - ws: 8.14.2 - checksum: 62d3ef8e8a04b027da298f480db8c42bbb5d2ab06fee864749b65da389ca3376bb65d1b87aed8cd1e49da2470c877c38620cad87f48bd7309122721f427689ae + ws: 8.15.1 + checksum: 954c5afd4daaea8333cc17ebfdea6fe898d1977b1e93e526ff80a1fe1c6ad970511ad90720c03de6198961906e4c2f7ba9b593f41a252504303eeaff3f883b4c languageName: node linkType: hard @@ -8627,7 +8628,7 @@ __metadata: languageName: node linkType: hard -"third-party-web@npm:^0.24.0": +"third-party-web@npm:^0.24.1": version: 0.24.1 resolution: "third-party-web@npm:0.24.1" checksum: 21363a1506c8c5186ef9ca81c32a25c20ab3b4976010ca6976066f05e6cd56c42bd121e385e071a18299a28032ad4f593ee367bf3a46c459424adbc0c3182b37 @@ -8656,6 +8657,7 @@ __metadata: autoprefixer: ^10.4.15 browser-sync: ^2.29.3 chokidar: ^3.5.3 + chrome-launcher: ^1.1.0 connect-history-api-fallback: ^2.0.0 core-js: 3.32.2 cssnano: ^6.0.1 @@ -8665,7 +8667,7 @@ __metadata: fluent-svelte: ^1.6.0 http-proxy-middleware: ^2.0.6 less: ^4.2.0 - lighthouse: ^11.3.0 + lighthouse: ^11.4.0 live-server: 1.2.1 morgan: ^1.10.0 node-fetch: ^3.3.2 @@ -8691,6 +8693,22 @@ __metadata: languageName: unknown linkType: soft +"tldts-core@npm:^6.1.1": + version: 6.1.1 + resolution: "tldts-core@npm:6.1.1" + checksum: 0ce2ec0d8ec30153d257cf885da68c0c2b2e29dacd23525b52a9f023ae02cb833d7602e5abe1a00427dc89cf4ba6cfb228acd269bc28b38a555c20b9cb3314e3 + languageName: node + linkType: hard + +"tldts-icann@npm:^6.1.0": + version: 6.1.1 + resolution: "tldts-icann@npm:6.1.1" + dependencies: + tldts-core: ^6.1.1 + checksum: b5a123fef9f207e82b9c2ffa02013318160ebb080e2b5a56deec6a4a6dd6538fb889c54e95de05061f2aae4e117c60fa9caba46586619daac25d6f214d0a93d0 + languageName: node + linkType: hard + "to-fast-properties@npm:^2.0.0": version: 2.0.0 resolution: "to-fast-properties@npm:2.0.0" @@ -9098,9 +9116,9 @@ __metadata: languageName: node linkType: hard -"ws@npm:8.14.2": - version: 8.14.2 - resolution: "ws@npm:8.14.2" +"ws@npm:8.15.1": + version: 8.15.1 + resolution: "ws@npm:8.15.1" peerDependencies: bufferutil: ^4.0.1 utf-8-validate: ">=5.0.2" @@ -9109,7 +9127,7 @@ __metadata: optional: true utf-8-validate: optional: true - checksum: 3ca0dad26e8cc6515ff392b622a1467430814c463b3368b0258e33696b1d4bed7510bc7030f7b72838b9fdeb8dbd8839cbf808367d6aae2e1d668ce741d4308b + checksum: 8c67365f6e6134278ad635d558bfce466d7ef7543a043baea333aaa430429f0af8a130c0c36e7dd78f918d68167a659ba9b5067330b77c4b279e91533395952b languageName: node linkType: hard