From 7639164eaa6b8ce193f8f82fa7e4b96521ed20f1 Mon Sep 17 00:00:00 2001 From: nodeexx <156369338+nodeexx@users.noreply.github.com> Date: 2024年3月17日 17:11:07 +0100 Subject: [PATCH 01/29] Add comments to client logging utils --- src/lib/client/logging/utils/index.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lib/client/logging/utils/index.ts b/src/lib/client/logging/utils/index.ts index e053e0b..b2fb904 100644 --- a/src/lib/client/logging/utils/index.ts +++ b/src/lib/client/logging/utils/index.ts @@ -11,6 +11,9 @@ export const logLevels = { error: 50, } as const; +/* + * Colors copied from https://github.com/gajus/roarr-browser-log-writer + */ export const logLevelColors = { debug: { backgroundColor: '#666', @@ -36,6 +39,9 @@ export const logLevelColors = { [key in LogLevelName]: { backgroundColor: string; color: string }; }; +/* + * Colors copied from https://github.com/gajus/roarr-browser-log-writer + */ export const logTimestampColors = { debug: { color: '#999', From 57ceb5ddcf0b6474238a4c5ef83af854ff6776a7 Mon Sep 17 00:00:00 2001 From: nodeexx <156369338+nodeexx@users.noreply.github.com> Date: 2024年3月17日 17:11:26 +0100 Subject: [PATCH 02/29] Change first client log --- src/hooks.client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hooks.client.ts b/src/hooks.client.ts index 7c49cda..c29e6cf 100644 --- a/src/hooks.client.ts +++ b/src/hooks.client.ts @@ -24,7 +24,7 @@ setupSentryClient({ }); setClientPosthogSessionId(); -logger.debug('Client app started'); +logger.info('Starting the app client...'); export const handleError = handleErrorWithSentry((async ({ error }) => { const message = 'Internal Client Error'; From d7a3051296b3ca490bd848f4b7b91f779ee874ac Mon Sep 17 00:00:00 2001 From: nodeexx <156369338+nodeexx@users.noreply.github.com> Date: 2024年3月18日 10:34:22 +0100 Subject: [PATCH 03/29] Don's show HTTP access logs on local --- .env.local.secret | Bin 1386 -> 1388 bytes .gitsecret/paths/mapping.cfg | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.local.secret b/.env.local.secret index 631a10d7e9ec74ce8b93751b6994436a69871a17..539e79842abb26501d5e874ad83ae9373142edcb 100644 GIT binary patch literal 1388 zcmV-y1(W)P0t^G}FzJ0|wuwUl5B@Zb4`!aGyK}*SA11rAPUo{L7ドルh1>Sy&aPPy2Cf zKM%@e>0sBg81Je;as)d&0~K4+7V!tbEut(|k#g*0+rUvTS(8N{$W(WJvafoqmuE52 zz6^BaVUF0KYr*l#S*^&*NDgr*skjF(D&;oAj9E>7Y1r291vza;?AGB|F9vef@e1xU zpO6c36U{p!YCy*P@uQA$?&JN!FFLaF;iUG7dY9$Gy-lE|Jt3rPtTt0d=8xsKLO1+f zn$`iIu-&`E(}z_O56j$jtvdnp%V7eoj6s4II3S-Q1#=S4_iqzEfE6|DC!dOPZ0d}d zWFHLgjhoS~J@3GG0uWThz@X!0wvnxhlyuB1t)m+rn1qAO56z*$D|R~wEYvnZUl!ov z)2Av(0kU%xVI`3#G8n~56^HjVSJJsB*G)P9f_L!jGflb-mf)U+|3*W!8eACIlVzis=0&d&CWJ1QG&7(hSv?&qIhlJNbj&YmKhJxUGkKv?6K7K`#yfpfDXD18%mG z=QT^?HYHNfe-d;PD)aX2MWoJ*2ZI;|l^>>d;X~4H(4=5T6Qi#hsp{lve;u5t#P}j}>#&9%aw2kYx-3 z-0uoUa8<7svcxz(yjb7b=o|9#h0ubjwgrgyz{y(1czc^b_d@pqbd;qvj53#*moj_e zU>%uZ2Ev}kQ#_e#PWUt_>?nL8q_tjQwz{IvPa9S?Y`lO=RO|&G5Wc>`GS+hp&ulHw z!FE(3d<1y9z&mu&fjfs16*p!_jJp|_f9c**P@8f7kNUAwc_DI?H+JmMw73DZ`za zlup{!d3%^mCk%^Y+HZm1MRMtHttA;S%yR&{pHa4Ygdz(MfG*#OoV8NN+}^55)k!+0 z4MtK3?_`h43N?rCUDj3oBfk26-syr6#P;XaM~!rfF}j!OW%Of2Zl^mToS;_96Es6j zS=;mhlxwn&z?iz6{byHi8j4yKKqw>JhG?%3E;^oR2FO0i(Zh^<_wvx;*qqqza58*+ zNEOChnoH=*z?rP?&&8YBNN}*rIheUb^k<;&&e}s#oa^m9;3e-`^uumpuft4y`_6xi zjTnB6B;d*Z6^u!m2j&dH#vguHK6U0-XcQUJ*iihUiV(}#%&^Hp`QvliaWZEM8G8j~ z>N1x87)O$`N=2pq{)2FH0r%7q>(7Fly(7=z%|OaahZ_KdFc<*nkw^bkntt4h;&vbr z*Fz9WnM*Nc7|m7!x~urZjgu15o_mYY1E8Or_?=5%1Y`2mF=e*|ilcfNo87`^jaB*^O;$Q z>ya>}0#+^9u2xSQny<4wom)*6rv^m$o5de-}5ib^djymbq;vgxusq-wm&0 uH7>~Zw)q|m3H%gjH?zA0BIa_;Gn~1&h@krG4`gjt)h9x7iyLh4Q0ue{h^NB< literal 1386 zcmV-w1(o`R0t^G}FzJ0|wuwUl5CEeObGet>e!oKyShV@a=vp{n;?lC=j!&_RuH3lt zboQlDj`5x7k(@F$Uu(|`)aOf9?LVq}{2pR%>I*#>R>lgdXzR;?JwjdRA1+eOei9<- zPZ}rR)JE*uxWC=Z_HS%Mi$ZCRnco?xk`W}&I4>(-FiVsX2P~boVg0eNCpsS&XPe#e z1tckvygTQ*o{M+tZI(wkBja#$A&RWzw?59aIt2_-ykZsF2XqSans8WoFZSH{wHdet z8S10`#h!&P$xyKVyQXa2ZL4|~m5ドル**H(KU!BvGbnsoB5yM_S7t;(=E>eIcY=YAWX6 z<1?du8baaek!2;g3cw`ky>|tmSx!~~d++r8BfA)ZCOtQzB?>qo+)vi2F@SoZ{!5KG zbStZnam{3toH_zgSLS$SZ&+-Eno|W-HOsI*fRFi34hvFo*kgGEu|=X48<=jnmse@x z9cA#R?(afnD?pK=Du@jlMlB3L+e4(8&VmDVV-`?uSg)5wF)2}Dp4hubyowxxIr0IU zjVG`Bj&h_yKgez2-R<Cz`aag(l;kfjOpb|Irj;rqRn?lgUV_L-~=F14T~ z!INnnMO(_xo()o8f6j=?l}Ub8b6J;)D~cH*p7o8PMbhoY%XMY!>}1v;VBN1xZC9Sl zjMg8ドル`|26ZNma@C&rDU1Emz5&}X$f%^qKFbIILMdL zikOLC_yqm9hh6tg8pVhKIBp0|jio2LiD?ia$G|#?0J3%-!{?*-K`@z?D;+wIV(EPfvG{CA)}iSsq6=H zuKu||BXKE)z#^0~#|!b3IR7HA*CPGHWPx#h`Va|-<}0yygtc)uqbd!7`fsae+cju_ zF41*Ja|39wsRuCY{;cBR%tNy~a^)XB5tlh2tHQ&9`tmTA-Zx$v)CDud<0d&+*jmyc<1@e;s%vcxad^l5?bvw0us+okh;j8n z6qw}pZ0>IBGrfOh1WAGkW^1(QTDt5Ggq2Kr1X>~OOhNfJPuEsv;5SqZXXe=NEMeW+ zvO@o-_Cf|5+}vmrAo6)mT>UkrPW%AtjqN3>SIjaZ?cqsawES7$a`pfee=u`@?%2vk zYG%qO2zjLi_)hh&5?tzXMAS57Q7#MrRyJ4PKLkk=iz5SX&(lRjCLKW9)=2ALZzHq? sX(XB*ZafKu9q$UK(WP}8*Stk61?0S$VR&>O&eB`LE^q?t)V+~^vw8cd{r~^~ diff --git a/.gitsecret/paths/mapping.cfg b/.gitsecret/paths/mapping.cfg index 2fc52c3..97147e5 100644 --- a/.gitsecret/paths/mapping.cfg +++ b/.gitsecret/paths/mapping.cfg @@ -1,2 +1,2 @@ -.env.local:ae055e688bd77cea8f52cea6ab36a0038b6374d2425526996d398c797f703d14 +.env.local:102adc6306f87e5f75303283aaefcd3da969f605b77df8a33c6c5842ea6c133f .env.playwright:ae1afa4ec916e6c9ce9476856be19236d9f664512aba3d24e2df0ea14e210cbd From 18f92f9a85bb8c0600a2259e25dd00e822de9073 Mon Sep 17 00:00:00 2001 From: nodeexx <156369338+nodeexx@users.noreply.github.com> Date: 2024年3月18日 14:32:05 +0100 Subject: [PATCH 04/29] Add renovate.json --- renovate.json | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 renovate.json diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..2984d1d --- /dev/null +++ b/renovate.json @@ -0,0 +1,17 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": ["config:recommended"], + "schedule": ["before 5am on the first day of the month"], + "packageRules": [ + { + "matchUpdateTypes": ["minor", "patch"], + "groupName": "dependencies (minor, patch)", + "groupSlug": "minor-patch-dependency-updates" + }, + { + "matchUpdateTypes": ["major"], + "groupName": "dependencies", + "groupSlug": "dependency-upgrades" + } + ] +} From 19e2a47fa34b3ab9f8b3e3206975362c8d4481ff Mon Sep 17 00:00:00 2001 From: nodeexx <156369338+nodeexx@users.noreply.github.com> Date: 2024年3月18日 17:39:58 +0100 Subject: [PATCH 05/29] Remove renovate.json to nuke its current configuration --- renovate.json | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 renovate.json diff --git a/renovate.json b/renovate.json deleted file mode 100644 index 2984d1d..0000000 --- a/renovate.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": ["config:recommended"], - "schedule": ["before 5am on the first day of the month"], - "packageRules": [ - { - "matchUpdateTypes": ["minor", "patch"], - "groupName": "dependencies (minor, patch)", - "groupSlug": "minor-patch-dependency-updates" - }, - { - "matchUpdateTypes": ["major"], - "groupName": "dependencies", - "groupSlug": "dependency-upgrades" - } - ] -} From 9c8f274fd906f0ee82dfb4cd5ceb674e4d66b40f Mon Sep 17 00:00:00 2001 From: nodeexx <156369338+nodeexx@users.noreply.github.com> Date: 2024年3月18日 17:51:47 +0100 Subject: [PATCH 06/29] Add renovate.json --- renovate.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 renovate.json diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..477f004 --- /dev/null +++ b/renovate.json @@ -0,0 +1,14 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": ["config:recommended"], + "schedule": ["before 5am on the first day of the month"], + "prConcurrentLimit": 1, + "separateMajorMinor": false, + "packageRules": [ + { + "matchUpdateTypes": ["major", "minor", "patch"], + "groupName": "all dependencies", + "groupSlug": "update-all-dependencies" + } + ] +} From 5c74ac5d77367c032413d72fb617595c6ffac7e5 Mon Sep 17 00:00:00 2001 From: nodeexx <156369338+nodeexx@users.noreply.github.com> Date: 2024年3月18日 18:24:10 +0100 Subject: [PATCH 07/29] Add minimumReleaseAge option to renovate.json --- renovate.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/renovate.json b/renovate.json index 477f004..ee97425 100644 --- a/renovate.json +++ b/renovate.json @@ -4,6 +4,8 @@ "schedule": ["before 5am on the first day of the month"], "prConcurrentLimit": 1, "separateMajorMinor": false, + "internalChecksFilter": "strict", + "minimumReleaseAge": "3", "packageRules": [ { "matchUpdateTypes": ["major", "minor", "patch"], From dc25147dea7b26ed0d20e54b674f772dea70a103 Mon Sep 17 00:00:00 2001 From: nodeexx <156369338+nodeexx@users.noreply.github.com> Date: 2024年3月19日 08:49:28 +0100 Subject: [PATCH 08/29] Setup Sentry performance monitoring for DB queries --- src/lib/server/sentry/utils/index.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/lib/server/sentry/utils/index.ts b/src/lib/server/sentry/utils/index.ts index 395430c..063ac8c 100644 --- a/src/lib/server/sentry/utils/index.ts +++ b/src/lib/server/sentry/utils/index.ts @@ -1,12 +1,20 @@ import { posthog, PostHogSentryIntegration } from '$lib/server/posthog'; import type { Integration } from '@sentry/types'; +import * as Sentry from '@sentry/sveltekit'; +import { prisma } from '$lib/server/prisma'; export function getServerSentryIntegrations( organization: string | undefined, ): Integration[] { + const integrations: Integration[] = [ + new Sentry.Integrations.Prisma({ client: prisma }), + ]; + if (posthog && organization) { - return [new PostHogSentryIntegration(posthog, undefined, organization)]; + integrations.unshift( + new PostHogSentryIntegration(posthog, undefined, organization), + ); } - return []; + return integrations; } From 8460d8749fb37271ef7ffbf0d82a2c49f42583c8 Mon Sep 17 00:00:00 2001 From: nodeexx <156369338+nodeexx@users.noreply.github.com> Date: 2024年3月22日 21:55:07 +0100 Subject: [PATCH 09/29] Create a k6 load test --- .eslintrc.cjs | 2 +- scripts/testing/load/commands/run-sh.sh | 14 +++++ scripts/testing/load/commands/run.sh | 14 +++++ scripts/testing/load/tests/_template.test.js | 63 ++++++++++++++++++++ scripts/testing/load/tests/load-1.test.js | 47 +++++++++++++++ tsconfig.json | 2 +- 6 files changed, 140 insertions(+), 2 deletions(-) create mode 100755 scripts/testing/load/commands/run-sh.sh create mode 100755 scripts/testing/load/commands/run.sh create mode 100644 scripts/testing/load/tests/_template.test.js create mode 100644 scripts/testing/load/tests/load-1.test.js diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 82dfe40..3460308 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -62,7 +62,7 @@ module.exports = { rules: {}, }, { - files: ['**/*.cjs'], + files: ['**/*.cjs', '**/*.js'], rules: { '@typescript-eslint/no-var-requires': 'off', }, diff --git a/scripts/testing/load/commands/run-sh.sh b/scripts/testing/load/commands/run-sh.sh new file mode 100755 index 0000000..3de0ce8 --- /dev/null +++ b/scripts/testing/load/commands/run-sh.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +set -eu + +docker container run \ + --name "graphana-k6" \ + --interactive \ + --tty \ + --rm \ + --user "k6" \ + --workdir "/home/k6" \ + --volume "${PWD}:/home/k6" \ + --entrypoint "/bin/sh" \ + "grafana/k6:0.49.0" diff --git a/scripts/testing/load/commands/run.sh b/scripts/testing/load/commands/run.sh new file mode 100755 index 0000000..2596284 --- /dev/null +++ b/scripts/testing/load/commands/run.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +set -eu + +docker container run \ + --name "graphana-k6" \ + --interactive \ + --tty \ + --rm \ + --user "root" \ + --workdir "/home/k6" \ + --volume "${PWD}:/home/k6" \ + "grafana/k6:0.49.0" \ + $@ diff --git a/scripts/testing/load/tests/_template.test.js b/scripts/testing/load/tests/_template.test.js new file mode 100644 index 0000000..ff06193 --- /dev/null +++ b/scripts/testing/load/tests/_template.test.js @@ -0,0 +1,63 @@ +// @ts-expect-error +import http from 'k6/http'; +// @ts-expect-error +import { sleep } from 'k6'; + +export const options = { + // A number specifying the number of VUs to run concurrently. + vus: 10, + // A string specifying the total duration of the test run. + duration: '30s', + + // The following section contains configuration options for execution of this + // test script in Grafana Cloud. + // + // See https://grafana.com/docs/grafana-cloud/k6/get-started/run-cloud-tests-from-the-cli/ + // to learn about authoring and running k6 test scripts in Grafana k6 Cloud. + // + // ext: { + // loadimpact: { + // // The ID of the project to which the test is assigned in the k6 Cloud UI. + // // By default tests are executed in default project. + // projectID: "", + // // The name of the test in the k6 Cloud UI. + // // Test runs with the same name will be grouped. + // name: "script.js" + // } + // }, + + // Uncomment this section to enable the use of Browser API in your tests. + // + // See https://grafana.com/docs/k6/latest/using-k6-browser/running-browser-tests/ to learn more + // about using Browser API in your test scripts. + // + // scenarios: { + // // The scenario name appears in the result summary, tags, and so on. + // // You can give the scenario any name, as long as each name in the script is unique. + // ui: { + // // Executor is a mandatory parameter for browser-based tests. + // // Shared iterations in this case tells k6 to reuse VUs to execute iterations. + // // + // // See https://grafana.com/docs/k6/latest/using-k6/scenarios/executors/ for other executor types. + // executor: 'shared-iterations', + // options: { + // browser: { + // // This is a mandatory parameter that instructs k6 to launch and + // // connect to a chromium-based browser, and use it to run UI-based + // // tests. + // type: 'chromium', + // }, + // }, + // }, + // } +}; + +// The function that defines VU logic. +// +// See https://grafana.com/docs/k6/latest/examples/get-started-with-k6/ to learn more +// about authoring k6 scripts. +// +export default function () { + http.get('https://test.k6.io'); + sleep(1); +} diff --git a/scripts/testing/load/tests/load-1.test.js b/scripts/testing/load/tests/load-1.test.js new file mode 100644 index 0000000..f5451ee --- /dev/null +++ b/scripts/testing/load/tests/load-1.test.js @@ -0,0 +1,47 @@ +// @ts-expect-error +import http from 'k6/http'; +// @ts-expect-error +import { check, sleep } from 'k6'; +// @ts-expect-error +import { Rate } from 'k6/metrics'; +// @ts-expect-error +import { htmlReport } from 'https://raw.githubusercontent.com/benc-uk/k6-reporter/main/dist/bundle.js'; + +// Define the failure rate +let failureRate = new Rate('failed_requests'); + +export let options = { + stages: [ + { duration: '10s', target: 10 }, // ramp up to 5 requests per second over 10 seconds + { duration: '10s', target: 10 }, // stay at 5 requests per second for 10 seconds + { duration: '10s', target: 1 }, // ramp down to 1 request per second over 10 seconds + ], + thresholds: { + 'http_req_duration{scenario:default}': ['p(95)<5000'], // Test fails if 95th percentile of request durations is higher than 5 seconds + failed_requests: ['rate<0.01'], // Fail if more than 1% of requests fail + }, +}; + +export default function () { + let response = http.get('http://staging-code-snippet-sharing.nodeexx.com'); + + // Check each response for a 200 status code + const checkRes = check(response, { + // @ts-expect-error + 'status is 200': (r) => r.status === 200, + }); + + // Track the failed requests + failureRate.add(!checkRes); + + // Since the test doesn't precisely control the request rate to exactly match the target, + // sleeping for a short duration helps to regulate the execution pace. + sleep(1); +} + +// @ts-expect-error +export function handleSummary(data) { + return { + 'summary.html': htmlReport(data), + }; +} diff --git a/tsconfig.json b/tsconfig.json index d070d7b..38e69da 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -26,7 +26,7 @@ "./.*.ts", "./scripts/app/**/*.js", "./scripts/stack/**/*.js", - "./scripts/ci/**/*.js" + "./scripts/testing/**/*.js" ], "compilerOptions": { "useDefineForClassFields": true, From c608193a508354993e05598817c834f53cc7774a Mon Sep 17 00:00:00 2001 From: nodeexx <156369338+nodeexx@users.noreply.github.com> Date: 2024年3月22日 22:06:59 +0100 Subject: [PATCH 10/29] Modify used version of ianlewis/todos to fix failing forbidden-comments-linting CI step --- .github/workflows/ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a565cfb..39f5f2b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -190,13 +190,13 @@ jobs: ref: ${{ github.head_ref }} - name: Setup todos CLI command run: | - curl -sSLo slsa-verifier https://github.com/slsa-framework/slsa-verifier/releases/download/v2.3.0/slsa-verifier-linux-amd64 \ - && echo "ea687149d658efecda64d69da999efb84bb695a3212f29548d4897994027172d slsa-verifier" | sha256sum -c - \ + curl -sSLo slsa-verifier https://github.com/slsa-framework/slsa-verifier/releases/download/v2.4.1/slsa-verifier-linux-amd64 \ + && echo "e81900c9f11a44276e1552afb7c1f6ea7b13ad9c6efdb920d97f23a76659e25f slsa-verifier" | sha256sum -c - \ && chmod +x slsa-verifier - curl -sSLo todos https://github.com/ianlewis/todos/releases/download/v0.5.0/todos-linux-amd64 \ - && curl -sSLo todos.intoto.jsonl https://github.com/ianlewis/todos/releases/download/v0.5.0/todos-linux-amd64.intoto.jsonl \ - && ./slsa-verifier verify-artifact todos --provenance-path todos.intoto.jsonl --source-uri github.com/ianlewis/todos --source-tag v0.5.0 \ + curl -sSLo todos https://github.com/ianlewis/todos/releases/download/v0.8.0/todos-linux-amd64 \ + && curl -sSLo todos.intoto.jsonl https://github.com/ianlewis/todos/releases/download/v0.8.0/todos-linux-amd64.intoto.jsonl \ + && ./slsa-verifier verify-artifact todos --provenance-path todos.intoto.jsonl --source-uri github.com/ianlewis/todos --source-tag v0.8.0 \ && chmod +x todos \ && sudo cp todos /usr/local/bin - name: Run todos CLI command From 076c615c5182486bd8a3b6a3ac640b4eae19c206 Mon Sep 17 00:00:00 2001 From: nodeexx <156369338+nodeexx@users.noreply.github.com> Date: 2024年3月23日 00:13:46 +0100 Subject: [PATCH 11/29] Remove development-only Vite variables --- .env.local.secret | Bin 1388 -> 1362 bytes .env.playwright.secret | Bin 1135 -> 1108 bytes .env.template | 4 ---- .gitsecret/paths/mapping.cfg | 4 ++-- scripts/stack/_lib/actions.js | 6 ++---- scripts/stack/local/infra/_lib/constants.js | 1 - vite.config.ts | 6 +++--- 7 files changed, 7 insertions(+), 14 deletions(-) diff --git a/.env.local.secret b/.env.local.secret index 539e79842abb26501d5e874ad83ae9373142edcb..382c1fb5185618c81b7058d271157c2197b7fa6e 100644 GIT binary patch literal 1362 zcmV-Y1+Dsp0t^G}FzJ0|wuwUl5BmqcZ2}2-Oh4u=?Dwdq9k z*4uSd}^wFEqa>(m93h)p+jS85kC=Wq%&*O zFsH!RP-|8ViRZl80n)55Z_-c!e3dfOMzX9$u_&_1aKO|riur7G$%GL2o85ドルNMHdE<&nduckj9oidql@geomavo|37@^dao#;nmr<*$v=ub^gx0iw z&rG*n&ku&#!G)B=)$%_ha~ol4bKsXvuC z5S4^4zQyrN4n@W)_&w6;0U5J$MR_ zeF6UdA=3VLw~xaf@Ph~U2gr}e2~NfW@*xNYL`bk0pdzvNVSHJ|8o(XV2upQc&6NY(;-7E4OzC z89lm}-V S4WN)S;|%Q3^>h$R{6sbjZQYvzq7}|xZZJo;PR_xo>$|`HOjlJ0 zxA1FStmMl6{Tvlx^k%quEx2W&k#Q4=6lNh+yyEOt8J==Ibwt+E>x4iI41{A94zgbl zo~(}M#t7RTykl=kQsA~V%i!IN{RfecR(8_afGuLe8YFZL*b2giMt)FeQM&=md8Dxa U^xkoy!{AhM>bLS%)kHjtz|Vi7ZvX%Q literal 1388 zcmV-y1(W)P0t^G}FzJ0|wuwUl5B@Zb4`!aGyK}*SA11rAPUo{L7ドルh1>Sy&aPPy2Cf zKM%@e>0sBg81Je;as)d&0~K4+7V!tbEut(|k#g*0+rUvTS(8N{$W(WJvafoqmuE52 zz6^BaVUF0KYr*l#S*^&*NDgr*skjF(D&;oAj9E>7Y1r291vza;?AGB|F9vef@e1xU zpO6c36U{p!YCy*P@uQA$?&JN!FFLaF;iUG7dY9$Gy-lE|Jt3rPtTt0d=8xsKLO1+f zn$`iIu-&`E(}z_O56j$jtvdnp%V7eoj6s4II3S-Q1#=S4_iqzEfE6|DC!dOPZ0d}d zWFHLgjhoS~J@3GG0uWThz@X!0wvnxhlyuB1t)m+rn1qAO56z*$D|R~wEYvnZUl!ov z)2Av(0kU%xVI`3#G8n~56^HjVSJJsB*G)P9f_L!jGflb-mf)U+|3*W!8eACIlVzis=0&d&CWJ1QG&7(hSv?&qIhlJNbj&YmKhJxUGkKv?6K7K`#yfpfDXD18%mG z=QT^?HYHNfe-d;PD)aX2MWoJ*2ZI;|l^>>d;X~4H(4=5T6Qi#hsp{lve;u5t#P}j}>#&9%aw2kYx-3 z-0uoUa8<7svcxz(yjb7b=o|9#h0ubjwgrgyz{y(1czc^b_d@pqbd;qvj53#*moj_e zU>%uZ2Ev}kQ#_e#PWUt_>?nL8q_tjQwz{IvPa9S?Y`lO=RO|&G5Wc>`GS+hp&ulHw z!FE(3d<1y9z&mu&fjfs16*p!_jJp|_f9c**P@8f7kNUAwc_DI?H+JmMw73DZ`za zlup{!d3%^mCk%^Y+HZm1MRMtHttA;S%yR&{pHa4Ygdz(MfG*#OoV8NN+}^55)k!+0 z4MtK3?_`h43N?rCUDj3oBfk26-syr6#P;XaM~!rfF}j!OW%Of2Zl^mToS;_96Es6j zS=;mhlxwn&z?iz6{byHi8j4yKKqw>JhG?%3E;^oR2FO0i(Zh^<_wvx;*qqqza58*+ zNEOChnoH=*z?rP?&&8YBNN}*rIheUb^k<;&&e}s#oa^m9;3e-`^uumpuft4y`_6xi zjTnB6B;d*Z6^u!m2j&dH#vguHK6U0-XcQUJ*iihUiV(}#%&^Hp`QvliaWZEM8G8j~ z>N1x87)O$`N=2pq{)2FH0r%7q>(7Fly(7=z%|OaahZ_KdFc<*nkw^bkntt4h;&vbr z*Fz9WnM*Nc7|m7!x~urZjgu15o_mYY1E8Or_?=5%1Y`2mF=e*|ilcfNo87`^jaB*^O;$Q z>ya>}0#+^9u2xSQny<4wom)*6rv^m$o5de-}5ib^djymbq;vgxusq-wm&0 uH7>~Zw)q|m3H%gjH?zA0BIa_;Gn~1&h@krG4`gjt)h9x7iyLh4Q0ue{h^NB< diff --git a/.env.playwright.secret b/.env.playwright.secret index c1fb9d34d49562678459a73592b8ccce1142cdb5..1a7f5456bba0331edbe6767c724d82f7ac34760d 100644 GIT binary patch literal 1108 zcmV-a1gran0t^G}FzJ0|wuwUl5C2#T+&8x|G*BUbDvpy3=#pU5tb&C9_KW=7>ea7a#_$;yyhUC;xsfyjl; z|6?+}m=Ut-$B0Ud6IHc_MAJ?@YPEO}<%)e!uylr&(ftk&ska}kwxn0hv1p}2#iga< zoHDJs#1~1@aAuvB(sNx;f=kOD!@u>hi*Lh(z zkun)~=8<8#4%i1wmet6oty^l*x)lxinwp&76o0n}y_~vvi)iqal*yanf#t7h8<*`7 zjp4(yz<$py#*%d;dOZVm5wjoUM^I?4WH;O1jk2-P9`Tilm~(ZQ=ib!3m>~CD~br zQlq2tszvENdMqX%O3SQPrsBD6G|=+echZ1kpV1Cp)}4;94vx2D>nL{|FrxvJ2H; z=4TR!05Qcp@eI7M_s%h0NMH7`zHImG(@CBD6HyLqpUIf;0|bx1*Lt1u z>fwIBO|A4GVM=Guw6+^}aDt-MKwy9t4^4NTUOJ;+rhQ}aSf})((Ks2Y9Nil z-9bd;n%!0L2S|F$^UwTYz9F_NXHmt;pOLmJf4=Li6NNjMK766$fCa^4YtAx8l{`dAtii)Ub(HM zwv-un>`;s^Dc4S!l@`NFEV6imX&Yp)w7D*pUujvM@1;QUtmC6mB2c(h3F|iCzW(5O zGD834ccHqul#v#8N**}ZVsl~I=L)IdVh-qdR(#^*=zL&0?^}@?m?vz$((WTF?(P%E z(h#OYmSX5KXfOoh@bo{Dt^P`RU-VpqwHdqmwBZl29X}6`=D@?!^wbXSQOq|)ET971 zww$E@A!`vRLhroTVl$Z8`32-by{AgDV=2=eKF9REy9^YIc)^({A?a75@B{oxnrxL( a*Y1YQ=pl7Gv$Tz3G@=5zf`py4-eQIgfJt5e literal 1135 zcmV-#1d#iM0t^G}FzJ0|wuwUl5CER#qBZAH4v1h;jR+F-*Idy&ok?m$?J4ld5yRX= z3%Riuv>V$K2zDx#QSOz}Uqf;DBne%yI&mce64u?zIz`ebyfYOZ%q!h$jdwhItR|2fmUs;C0|+16eu zq)9Hvx0s#^%kMPzUenKVt{WXmX8iTS1dP97pHz{?SPe!7O15woF+jf+XP z%3KW=vddrOV6|7QYZi#<(g1qm5b}z8ysq4dlg*;us_u;#} z^dEx`nwB3c!MA6h2^9p8KFj8uK|CGW8j16O0ドル}2ZX$M-sfS-_;w59RxSoP4Us685) zx>E8yhIdn*&38ws@?75!MLfGu*jfT6PWV=U3{EmSvZ0r-`pfH%lwmhr(w%HkP{>;4 z>ol0PpXCJE$Gj5f2sgULP`{Q}HWb|aEd-UESglO*V>Z_%%-(AbLH1q*Ceb%5vuP#q z)QgEcWMgO@n^>?$m5DnfrUIfSsh`^h$C~gEDX?VQ24 zUk$}~nnA+|@fx>6+> zhllqG#;f-_%0|Nv=aS5ADu`xm|H5jx3h7l*43EI3HUuBHoV*=cijp?Sn0QxUH zx9Y@^p%l1R_;>?C6iw_pWfgfz#IzspdwgINvsk_bFCYH~O>a|!XA_&jNLn5O2%(qUx--C{JJn~IEMignnz-OP;U^k|E znqfJ(Hv#FLU6c0Ec-S}wJb8p$$SoS?3q)^;YXZ;DT=0M+Q5BCCF+ZIqTqUn;+H@+% zC@*l&hK!cmFx=?{osSNEB~2k8wdUglEP~r!1+9|(px2gklAxYEETq)GEuUt$emV BFE9WA diff --git a/.env.template b/.env.template index c51a544..21ea857 100644 --- a/.env.template +++ b/.env.template @@ -16,10 +16,6 @@ PUBLIC_SENTRY_PROJECT_ID= PROJECT_NAME=code-snippet-sharing -VITE_DEV_HOST=localhost -VITE_DEV_PORT=3000 -VITE_PREVIEW_PORT=3000 - POSTGRES_DATA_VOLUME_NAME=postgres-data-development ## Development and production diff --git a/.gitsecret/paths/mapping.cfg b/.gitsecret/paths/mapping.cfg index 97147e5..f2c5f45 100644 --- a/.gitsecret/paths/mapping.cfg +++ b/.gitsecret/paths/mapping.cfg @@ -1,2 +1,2 @@ -.env.local:102adc6306f87e5f75303283aaefcd3da969f605b77df8a33c6c5842ea6c133f -.env.playwright:ae1afa4ec916e6c9ce9476856be19236d9f664512aba3d24e2df0ea14e210cbd +.env.local:abbe9da718d9249cfa0b265678517b558b7fbe9f67c38ad714e2f0d9da51c63e +.env.playwright:cc88f3266a590b9cd526fc40bb2dfd415fa65fc19ebaa7396a342dd10a137567 diff --git a/scripts/stack/_lib/actions.js b/scripts/stack/_lib/actions.js index bd27945..eb20907 100644 --- a/scripts/stack/_lib/actions.js +++ b/scripts/stack/_lib/actions.js @@ -136,9 +136,7 @@ export async function startLocalApp() { await sleep(5000); try { - await waitUntilServiceIsAvailable( - `http://localhost:${process.env['VITE_DEV_PORT']}`, - ); + await waitUntilServiceIsAvailable('http://localhost:3000'); } catch (error) { console.error(error); console.error(`app (local): failed`); @@ -332,7 +330,7 @@ export function stopLocalApp() { try { console.log('app (local): stopping'); const appPid = execSync( - `ss -lnp | grep :${process.env['VITE_DEV_PORT']} | sed 's/.*pid=\\(.*\\),.*/\1円/g'`, + `ss -lnp | grep :3000 | sed 's/.*pid=\\(.*\\),.*/\1円/g'`, { env: process.env }, ) .toString() diff --git a/scripts/stack/local/infra/_lib/constants.js b/scripts/stack/local/infra/_lib/constants.js index 1926469..20ed754 100644 --- a/scripts/stack/local/infra/_lib/constants.js +++ b/scripts/stack/local/infra/_lib/constants.js @@ -2,6 +2,5 @@ export const MANDATORY_ENV_VARS = [ 'PROJECT_NAME', 'POSTGRES_DATA_VOLUME_NAME', 'DATABASE_URL', - 'VITE_DEV_PORT', ]; export const DOCKER_COMPOSE_FILES = ['docker-compose.local.infra-only.yml']; diff --git a/vite.config.ts b/vite.config.ts index 8af009b..43507d5 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -17,12 +17,12 @@ export default defineConfig(({ mode }) => { minify: 'esbuild', }, server: { - host: env['VITE_DEV_HOST'] ?? 'localhost', - port: parseInt(env['VITE_DEV_PORT'] ?? '') || 5173, + host: 'localhost', + port: 3000, strictPort: true, }, preview: { - port: parseInt(env['VITE_PREVIEW_PORT'] ?? '') || 4173, + port: 3000, }, plugins: [ ...getWrappedSentrySvelteKitPlugin(mode, env), From 9f9da6750beb533c339f1f1388d343f810298bec Mon Sep 17 00:00:00 2001 From: nodeexx <156369338+nodeexx@users.noreply.github.com> Date: 2024年3月23日 00:24:57 +0100 Subject: [PATCH 12/29] Remove browser and learning tests --- package.json | 1 - src/index.browser-test.ts | 7 ----- tests/learning/browser/index.browser-test.ts | 7 ----- tests/learning/browser/lodash.browser-test.ts | 18 ------------ vitest.browser.learning.config.ts | 29 ------------------- 5 files changed, 62 deletions(-) delete mode 100644 src/index.browser-test.ts delete mode 100644 tests/learning/browser/index.browser-test.ts delete mode 100644 tests/learning/browser/lodash.browser-test.ts delete mode 100644 vitest.browser.learning.config.ts diff --git a/package.json b/package.json index f6e8406..b7763fe 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,6 @@ "test:unit:dom:coverage": "npm run test:unit:dom -- --coverage", "test:unit:dom:debug": "npm run test:unit:dom -- --single-thread", "test:unit:browser": "vitest run --config vitest.browser.config.ts", - "test:unit:browser:learning": "vitest run --config vitest.browser.learning.config.ts", "test:api:only": "playwright test --config playwright.api.config.ts", "test:api:ui:only": "npm run test:api:only -- --ui", "test:e2e:only": "playwright test --config playwright.e2e.config.ts", diff --git a/src/index.browser-test.ts b/src/index.browser-test.ts deleted file mode 100644 index 964d287..0000000 --- a/src/index.browser-test.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { describe, it, expect } from 'vitest'; - -describe('sum test', () => { - it('adds 1 + 2 to equal 3', () => { - expect(1 + 2).toBe(3); - }); -}); diff --git a/tests/learning/browser/index.browser-test.ts b/tests/learning/browser/index.browser-test.ts deleted file mode 100644 index 964d287..0000000 --- a/tests/learning/browser/index.browser-test.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { describe, it, expect } from 'vitest'; - -describe('sum test', () => { - it('adds 1 + 2 to equal 3', () => { - expect(1 + 2).toBe(3); - }); -}); diff --git a/tests/learning/browser/lodash.browser-test.ts b/tests/learning/browser/lodash.browser-test.ts deleted file mode 100644 index 314e25b..0000000 --- a/tests/learning/browser/lodash.browser-test.ts +++ /dev/null @@ -1,18 +0,0 @@ -import partition from 'lodash/partition'; -import { describe, it, expect } from 'vitest'; - -/** - * Currently fails because of the following error: - * "TypeError: __vi_esm_0__.default is not a function or its return value is not iterable" - * https://github.com/vitest-dev/vitest/issues/4097 - */ -describe('lodash', () => { - describe('partition', () => { - it('should partition array', () => { - const [odd, even] = partition([1, 2, 3, 4], (n) => n % 2); - - expect(odd).toEqual([1, 3]); - expect(even).toEqual([2, 4]); - }); - }); -}); diff --git a/vitest.browser.learning.config.ts b/vitest.browser.learning.config.ts deleted file mode 100644 index 03bde3b..0000000 --- a/vitest.browser.learning.config.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Used for running learning browser tests. - */ - -import { defineConfig, mergeConfig, type UserConfig } from 'vitest/config'; -import browserConfig from './vitest.browser.config'; - -const mergedConfig = defineConfig((configEnv) => - mergeConfig( - browserConfig(configEnv), - defineConfig({ - test: { - coverage: { - reportsDirectory: './reports/vitest/coverage/learning/browser', - }, - }, - }) as UserConfig, - ), -); - -const config = defineConfig((configEnv) => ({ - ...mergedConfig(configEnv), - test: { - ...mergedConfig(configEnv).test, - include: ['tests/learning/browser/**/*.browser-test.{js,ts}'], - }, -})); - -export default config; From 927d3c0e076f48b749fe1a77d258e0f06a13902f Mon Sep 17 00:00:00 2001 From: nodeexx <156369338+nodeexx@users.noreply.github.com> Date: 2024年3月23日 00:25:50 +0100 Subject: [PATCH 13/29] Remove sample node and dom unit tests --- src/index.dom-test.ts | 7 ------- src/index.node-test.ts | 7 ------- 2 files changed, 14 deletions(-) delete mode 100644 src/index.dom-test.ts delete mode 100644 src/index.node-test.ts diff --git a/src/index.dom-test.ts b/src/index.dom-test.ts deleted file mode 100644 index 964d287..0000000 --- a/src/index.dom-test.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { describe, it, expect } from 'vitest'; - -describe('sum test', () => { - it('adds 1 + 2 to equal 3', () => { - expect(1 + 2).toBe(3); - }); -}); diff --git a/src/index.node-test.ts b/src/index.node-test.ts deleted file mode 100644 index 964d287..0000000 --- a/src/index.node-test.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { describe, it, expect } from 'vitest'; - -describe('sum test', () => { - it('adds 1 + 2 to equal 3', () => { - expect(1 + 2).toBe(3); - }); -}); From d35ea57c37e2ab93227092854b96be85f5302277 Mon Sep 17 00:00:00 2001 From: nodeexx <156369338+nodeexx@users.noreply.github.com> Date: 2024年3月23日 00:29:07 +0100 Subject: [PATCH 14/29] Remove unused nodemon package and config --- nodemon.json | 15 ------ package-lock.json | 116 ---------------------------------------------- package.json | 1 - 3 files changed, 132 deletions(-) delete mode 100644 nodemon.json diff --git a/nodemon.json b/nodemon.json deleted file mode 100644 index f2c1559..0000000 --- a/nodemon.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "verbose": true, - "ignore": [ - "node_modules", - "dist", - "build", - ".stryker-tmp", - ".nyc_output", - "coverage", - "target", - "reports", - ".svelte-kit" - ], - "ext": "json,js,cjs,mjs,ts,svelte" -} diff --git a/package-lock.json b/package-lock.json index c286930..5657f82 100644 --- a/package-lock.json +++ b/package-lock.json @@ -66,7 +66,6 @@ "eslint-plugin-testing-library": "6.1.0", "ignore": "5.3.0", "jsdom": "23.0.1", - "nodemon": "3.0.1", "npm-check-updates": "16.14.6", "playwright": "1.39.0", "postcss": "8.4.31", @@ -8731,12 +8730,6 @@ "node": ">= 4" } }, - "node_modules/ignore-by-default": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", - "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==", - "dev": true - }, "node_modules/ignore-walk": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-6.0.3.tgz", @@ -11137,79 +11130,6 @@ "integrity": "sha512-uYr7J37ae/ORWdZeQ1xxMJe3NtdmqMC/JZK+geofDrkLUApKRHPd18/TxtBOJ4A0/+uUIliorNrfYV6s1b02eQ==", "dev": true }, - "node_modules/nodemon": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.0.1.tgz", - "integrity": "sha512-g9AZ7HmkhQkqXkRc20w+ZfQ73cHLbE8hnPbtaFbFtCumZsjyMhKk9LajQ07U5Ux28lvFjZ5X7HvWR1xzU8jHVw==", - "dev": true, - "dependencies": { - "chokidar": "^3.5.2", - "debug": "^3.2.7", - "ignore-by-default": "^1.0.1", - "minimatch": "^3.1.2", - "pstree.remy": "^1.1.8", - "semver": "^7.5.3", - "simple-update-notifier": "^2.0.0", - "supports-color": "^5.5.0", - "touch": "^3.1.0", - "undefsafe": "^2.0.5" - }, - "bin": { - "nodemon": "bin/nodemon.js" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/nodemon" - } - }, - "node_modules/nodemon/node_modules/debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "dev": true, - "dependencies": { - "ms": "^2.1.1" - } - }, - "node_modules/nodemon/node_modules/has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/nodemon/node_modules/supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "dependencies": { - "has-flag": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/nopt": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", - "integrity": "sha512-NWmpvLSqUrgrAC9HCuxEvb+PSloHpqVu+FqcO4eeF2h5qYRhA7ev6KvelyQAKtegUbC6RypJnlEOhd8vloNKYg==", - "dev": true, - "dependencies": { - "abbrev": "1" - }, - "bin": { - "nopt": "bin/nopt.js" - }, - "engines": { - "node": "*" - } - }, "node_modules/normalize-package-data": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-3.0.3.tgz", @@ -13366,12 +13286,6 @@ "integrity": "sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==", "dev": true }, - "node_modules/pstree.remy": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", - "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==", - "dev": true - }, "node_modules/pump": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", @@ -14676,18 +14590,6 @@ "node": "^14.17.0 || ^16.13.0 ||>=18.0.0" } }, - "node_modules/simple-update-notifier": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", - "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", - "dev": true, - "dependencies": { - "semver": "^7.5.3" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/sirv": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/sirv/-/sirv-2.0.3.tgz", @@ -15940,18 +15842,6 @@ "node": ">=6" } }, - "node_modules/touch": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz", - "integrity": "sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==", - "dev": true, - "dependencies": { - "nopt": "~1.0.10" - }, - "bin": { - "nodetouch": "bin/nodetouch.js" - } - }, "node_modules/tough-cookie": { "version": "4.1.3", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.3.tgz", @@ -16239,12 +16129,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/undefsafe": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", - "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==", - "dev": true - }, "node_modules/undici": { "version": "5.26.5", "resolved": "https://registry.npmjs.org/undici/-/undici-5.26.5.tgz", diff --git a/package.json b/package.json index b7763fe..868df49 100644 --- a/package.json +++ b/package.json @@ -113,7 +113,6 @@ "eslint-plugin-testing-library": "6.1.0", "ignore": "5.3.0", "jsdom": "23.0.1", - "nodemon": "3.0.1", "npm-check-updates": "16.14.6", "playwright": "1.39.0", "postcss": "8.4.31", From 25428d1a39e24ef565af59e63e0f7103f9a0b568 Mon Sep 17 00:00:00 2001 From: nodeexx <156369338+nodeexx@users.noreply.github.com> Date: 2024年3月23日 00:44:56 +0100 Subject: [PATCH 15/29] Remove doesRequireAuth from auth guard --- src/app.d.ts | 1 - src/lib/server/lucia/guards/auth-user.guard.node-test.ts | 1 - src/lib/server/lucia/guards/auth-user.guard.ts | 1 - .../code-snippets/[id]/edit/page.server.node-test.ts | 1 - 4 files changed, 4 deletions(-) diff --git a/src/app.d.ts b/src/app.d.ts index 5969186..7a91139 100644 --- a/src/app.d.ts +++ b/src/app.d.ts @@ -27,7 +27,6 @@ declare global { interface PageData { flash?: GlobalMessage; authUser: import('$lib/shared/lucia/types').AuthUser | null; - doesRequireAuth?: boolean; } // interface Platform {} diff --git a/src/lib/server/lucia/guards/auth-user.guard.node-test.ts b/src/lib/server/lucia/guards/auth-user.guard.node-test.ts index 1fcaa74..78cbcc8 100644 --- a/src/lib/server/lucia/guards/auth-user.guard.node-test.ts +++ b/src/lib/server/lucia/guards/auth-user.guard.node-test.ts @@ -32,7 +32,6 @@ describe(guardAuthUser.name, () => { expect(result).toEqual({ authUser: locals.authUser, - doesRequireAuth: true, }); expect(redirectSpy).toHaveBeenCalledTimes(0); }); diff --git a/src/lib/server/lucia/guards/auth-user.guard.ts b/src/lib/server/lucia/guards/auth-user.guard.ts index bc5ff93..ec2c570 100644 --- a/src/lib/server/lucia/guards/auth-user.guard.ts +++ b/src/lib/server/lucia/guards/auth-user.guard.ts @@ -8,7 +8,6 @@ export function guardAuthUser(locals: App.Locals, url: URL): App.PageData { if (locals.authUser) { return { authUser: locals.authUser, - doesRequireAuth: true, }; } diff --git a/src/routes/(app)/(card-layout)/code-snippets/[id]/edit/page.server.node-test.ts b/src/routes/(app)/(card-layout)/code-snippets/[id]/edit/page.server.node-test.ts index aaedd10..a15a6e2 100644 --- a/src/routes/(app)/(card-layout)/code-snippets/[id]/edit/page.server.node-test.ts +++ b/src/routes/(app)/(card-layout)/code-snippets/[id]/edit/page.server.node-test.ts @@ -62,7 +62,6 @@ describe(load.name, () => { } as CodeSnippet); vi.spyOn(libServerLuciaGuardsModule, 'guardAuthUser').mockReturnValue({ authUser: mockAuthUser, - doesRequireAuth: true, }); vi.spyOn( libServerCodeSnippetsModule, From 8aca3f6b7eddbfe6525f529b9339eaa23d0966aa Mon Sep 17 00:00:00 2001 From: nodeexx <156369338+nodeexx@users.noreply.github.com> Date: 2024年3月23日 10:09:02 +0100 Subject: [PATCH 16/29] Rename load tests --- .../load/tests/{_template.test.js => _template.load-test.js} | 0 .../testing/load/tests/{load-1.test.js => load-1.load-test.js} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename scripts/testing/load/tests/{_template.test.js => _template.load-test.js} (100%) rename scripts/testing/load/tests/{load-1.test.js => load-1.load-test.js} (100%) diff --git a/scripts/testing/load/tests/_template.test.js b/scripts/testing/load/tests/_template.load-test.js similarity index 100% rename from scripts/testing/load/tests/_template.test.js rename to scripts/testing/load/tests/_template.load-test.js diff --git a/scripts/testing/load/tests/load-1.test.js b/scripts/testing/load/tests/load-1.load-test.js similarity index 100% rename from scripts/testing/load/tests/load-1.test.js rename to scripts/testing/load/tests/load-1.load-test.js From eb60b13e6c8f670a27b2d1502cc050faa5ab80df Mon Sep 17 00:00:00 2001 From: nodeexx <156369338+nodeexx@users.noreply.github.com> Date: 2024年3月23日 10:09:20 +0100 Subject: [PATCH 17/29] Add new Vitest extension to recommended --- .vscode/extensions.template.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.vscode/extensions.template.json b/.vscode/extensions.template.json index dddae26..27f94b9 100644 --- a/.vscode/extensions.template.json +++ b/.vscode/extensions.template.json @@ -24,6 +24,7 @@ "stordahl.sveltekit-snippets", "proverbialninja.svelte-extractor", "vunguyentuan.vscode-postcss", - "wix.vscode-import-cost" + "wix.vscode-import-cost", + "vitest.explorer" ] } From 0ab1598b7e187d7b5e1a8b478178e5a4394ff3f8 Mon Sep 17 00:00:00 2001 From: nodeexx <156369338+nodeexx@users.noreply.github.com> Date: 2024年3月23日 10:16:54 +0100 Subject: [PATCH 18/29] Update VSCode settings --- .vscode/settings.template.json | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/.vscode/settings.template.json b/.vscode/settings.template.json index dcf174a..d6cc4c8 100644 --- a/.vscode/settings.template.json +++ b/.vscode/settings.template.json @@ -1,5 +1,8 @@ { "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.fixAll": "explicit" + }, "files.watcherExclude": { "**/.git/objects/**": true, "**/.git/subtree-cache/**": true, @@ -50,9 +53,21 @@ "editor.defaultFormatter": "redhat.vscode-yaml" // Identation settings -> .editorconfig }, + "[markdown]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + // Identation settings -> .editorconfig + }, /* TypeScript */ "typescript.tsdk": "./node_modules/typescript/lib", "typescript.preferences.importModuleSpecifier": "shortest", + "typescript.inlayHints.parameterNames.enabled": "all", + // "typescript.inlayHints.variableTypes.enabled": true, + // "typescript.inlayHints.propertyDeclarationTypes.enabled": true, + "typescript.inlayHints.functionLikeReturnTypes.enabled": true, + // "typescript.inlayHints.parameterTypes.enabled": true, + "typescript.inlayHints.enumMemberValues.enabled": true, + "typescript.referencesCodeLens.enabled": true, + "typescript.implementationsCodeLens.enabled": true, /* GitHub Copilot */ "github.copilot.enable": { "*": true, @@ -75,11 +90,11 @@ /* Wallaby.js */ "wallaby.startAutomatically": false, /* ESLint */ - // "eslint.enable": true, - // "eslint.format.enable": true, + "eslint.enable": true, + "eslint.format.enable": true, "eslint.validate": ["javascript", "typescript", "svelte"], /* Prettier */ - // "prettier.enable": true, + "prettier.enable": true, /* Stylelint */ "stylelint.validate": ["postcss", "svelte"], /* cSpell */ From 0bbd4b383f7b22b39ff929f487d900c3f113acff Mon Sep 17 00:00:00 2001 From: nodeexx <156369338+nodeexx@users.noreply.github.com> Date: 2024年3月24日 12:48:37 +0100 Subject: [PATCH 19/29] Modify ESLint setup --- .eslintrc.cjs | 60 ++++++-- package-lock.json | 380 +++------------------------------------------- package.json | 3 +- 3 files changed, 71 insertions(+), 372 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 3460308..46b8549 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -3,25 +3,28 @@ module.exports = { parser: '@typescript-eslint/parser', parserOptions: { sourceType: 'module', - ecmaVersion: 2020, + ecmaVersion: 'latest', project: './tsconfig.json', extraFileExtensions: ['.svelte'], }, + env: { + browser: true, + es2017: true, + node: true, + }, plugins: [ - '@typescript-eslint', + 'import', 'import-no-duplicates-prefix-resolved-path', - 'prettier', + 'simple-import-sort', + '@typescript-eslint', ], extends: [ 'eslint:recommended', 'plugin:@typescript-eslint/recommended', - 'plugin:prettier/recommended', + 'plugin:@typescript-eslint/strict-type-checked', + 'plugin:@typescript-eslint/stylistic-type-checked', + 'prettier', ], - env: { - browser: true, - es2017: true, - node: true, - }, settings: { 'import/parsers': { '@typescript-eslint/parser': ['.cjs', '.js', '.ts'], @@ -33,10 +36,20 @@ module.exports = { }, }, rules: { - 'prettier/prettier': 'error', 'no-unused-vars': 'off', // Useful for triggering Svelte reactivity 'no-self-assign': 'off', + 'simple-import-sort/imports': 'error', + 'simple-import-sort/exports': 'error', + 'import/first': 'error', + 'import/newline-after-import': 'error', + 'import/no-duplicates': 'off', + 'import-no-duplicates-prefix-resolved-path/no-duplicates': [ + 'error', + { + prefixResolvedPathWithImportName: true, + }, + ], '@typescript-eslint/no-unused-vars': [ 'error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }, @@ -50,6 +63,18 @@ module.exports = { '@typescript-eslint/explicit-function-return-type': 'off', '@typescript-eslint/explicit-module-boundary-types': 'off', '@typescript-eslint/no-namespace': 'off', + '@typescript-eslint/consistent-indexed-object-style': 'off', + '@typescript-eslint/prefer-nullish-coalescing': 'off', + '@typescript-eslint/no-unsafe-member-access': 'off', + '@typescript-eslint/no-unsafe-argument': 'off', + '@typescript-eslint/no-unsafe-assignment': 'off', + '@typescript-eslint/no-throw-literal': 'off', + '@typescript-eslint/unbound-method': 'off', + '@typescript-eslint/no-unnecessary-type-arguments': 'off', + '@typescript-eslint/prefer-reduce-type-parameter': 'off', + '@typescript-eslint/no-confusing-void-expression': 'off', + '@typescript-eslint/no-unnecessary-condition': 'off', + '@typescript-eslint/no-extraneous-class': 'off', }, overrides: [ { @@ -61,12 +86,27 @@ module.exports = { extends: ['plugin:svelte/recommended', 'plugin:svelte/prettier'], rules: {}, }, + { + files: ['./scripts/testing/load/tests/**/*.js'], + rules: { + 'import/no-unresolved': 'off', + '@typescript-eslint/no-unsafe-assignment': 'off', + '@typescript-eslint/no-unsafe-call': 'off', + '@typescript-eslint/no-unsafe-member-access': 'off', + }, + }, { files: ['**/*.cjs', '**/*.js'], rules: { '@typescript-eslint/no-var-requires': 'off', }, }, + { + files: ['src/**/*.{node-test,dom-test}.ts'], + rules: { + '@typescript-eslint/require-await': 'off', + }, + }, { // No `.spec.{js,ts}` files, because those are for server unit tests files: ['src/**/*.{test,browser-test}.{js,ts}'], diff --git a/package-lock.json b/package-lock.json index 5657f82..511a18d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -57,11 +57,12 @@ "dotenv": "16.3.1", "eslint": "8.53.0", "eslint-config-prettier": "9.0.0", + "eslint-import-resolver-alias": "1.1.2", "eslint-import-resolver-typescript": "3.6.1", "eslint-plugin-import": "2.29.0", "eslint-plugin-import-no-duplicates-prefix-resolved-path": "2.0.0", "eslint-plugin-jest-dom": "5.1.0", - "eslint-plugin-prettier": "5.0.1", + "eslint-plugin-simple-import-sort": "12.0.0", "eslint-plugin-svelte": "2.34.1", "eslint-plugin-testing-library": "6.1.0", "ignore": "5.3.0", @@ -2455,56 +2456,6 @@ "node": ">=14" } }, - "node_modules/@pkgr/utils": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/@pkgr/utils/-/utils-2.4.2.tgz", - "integrity": "sha512-POgTXhjrTfbTV63DiFXav4lBHiICLKKwDeaKn9Nphwj7WH6m0hMMCaJkMyRWjgtPFyRKRVoMXXjczsTQRDEhYw==", - "dev": true, - "dependencies": { - "cross-spawn": "^7.0.3", - "fast-glob": "^3.3.0", - "is-glob": "^4.0.3", - "open": "^9.1.0", - "picocolors": "^1.0.0", - "tslib": "^2.6.0" - }, - "engines": { - "node": "^12.20.0 || ^14.18.0 ||>=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/unts" - } - }, - "node_modules/@pkgr/utils/node_modules/define-lazy-prop": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-3.0.0.tgz", - "integrity": "sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg==", - "dev": true, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/@pkgr/utils/node_modules/open": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/open/-/open-9.1.0.tgz", - "integrity": "sha512-OS+QTnw1/4vrf+9hh1jc1jnYjzSG4ttTBB8UxOwAnInG3Uo4ssetzC1ihqaIHjLJnA5GGlRl6QlZXOTQhRBUvg==", - "dev": true, - "dependencies": { - "default-browser": "^4.0.0", - "define-lazy-prop": "^3.0.0", - "is-inside-container": "^1.0.0", - "is-wsl": "^2.2.0" - }, - "engines": { - "node": ">=14.16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/@playwright/test": { "version": "1.39.0", "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.39.0.tgz", @@ -5029,15 +4980,6 @@ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" }, - "node_modules/big-integer": { - "version": "1.6.51", - "resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.51.tgz", - "integrity": "sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg==", - "dev": true, - "engines": { - "node": ">=0.6" - } - }, "node_modules/binary-extensions": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", @@ -5188,18 +5130,6 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, - "node_modules/bplist-parser": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.2.0.tgz", - "integrity": "sha512-z0M+byMThzQmD9NILRniCUXYsYpjwnlO8N5uCFaCqIOpqRsJCrQL9NK3JsD67CN5a08nF5oIL2bD6loTdHOuKw==", - "dev": true, - "dependencies": { - "big-integer": "^1.6.44" - }, - "engines": { - "node": ">= 5.10.0" - } - }, "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -5300,21 +5230,6 @@ "semver": "^7.0.0" } }, - "node_modules/bundle-name": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/bundle-name/-/bundle-name-3.0.0.tgz", - "integrity": "sha512-PKA4BeSvBpQKQ8iPOGCSiell+N8P+Tf1DlwqmYhpe2gAhKPHn8EYOxVT+ShuGmhg8lN8XiSlS80yiExKXrURlw==", - "dev": true, - "dependencies": { - "run-applescript": "^5.0.0" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/cac": { "version": "6.7.14", "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", @@ -6317,40 +6232,6 @@ "node": ">=0.10.0" } }, - "node_modules/default-browser": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/default-browser/-/default-browser-4.0.0.tgz", - "integrity": "sha512-wX5pXO1+BrhMkSbROFsyxUm0i/cJEScyNhA4PPxc41ICuv05ZZB/MX28s8aZx6xjmatvebIapF6hLEKEcpneUA==", - "dev": true, - "dependencies": { - "bundle-name": "^3.0.0", - "default-browser-id": "^3.0.0", - "execa": "^7.1.1", - "titleize": "^3.0.0" - }, - "engines": { - "node": ">=14.16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/default-browser-id": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/default-browser-id/-/default-browser-id-3.0.0.tgz", - "integrity": "sha512-OZ1y3y0SqSICtE8DE4S8YOE9UZOJ8wO16fKWVP5J1Qz42kV9jcnMVFrEE/noXb/ss3Q4pZIH79kxofzyNNtUNA==", - "dev": true, - "dependencies": { - "bplist-parser": "^0.2.0", - "untildify": "^4.0.0" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/defaults": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.4.tgz", @@ -7274,6 +7155,18 @@ "eslint": ">=7.0.0" } }, + "node_modules/eslint-import-resolver-alias": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-alias/-/eslint-import-resolver-alias-1.1.2.tgz", + "integrity": "sha512-WdviM1Eu834zsfjHtcGHtGfcu+F30Od3V7I9Fi57uhBEwPkjDcii7/yW8jAT+gOhn4P/vOxxNAXbFAKsrrc15w==", + "dev": true, + "engines": { + "node": ">= 4" + }, + "peerDependencies": { + "eslint-plugin-import": ">=1.4.0" + } + }, "node_modules/eslint-import-resolver-node": { "version": "0.3.9", "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.9.tgz", @@ -7439,33 +7332,13 @@ } } }, - "node_modules/eslint-plugin-prettier": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.0.1.tgz", - "integrity": "sha512-m3u5RnR56asrwV/lDC4GHorlW75DsFfmUcjfCYylTUs85dBRnB7VM6xG8eCMJdeDRnppzmxZVf1GEPJvl1JmNg==", + "node_modules/eslint-plugin-simple-import-sort": { + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-simple-import-sort/-/eslint-plugin-simple-import-sort-12.0.0.tgz", + "integrity": "sha512-8o0dVEdAkYap0Cn5kNeklaKcT1nUsa3LITWEuFk3nJifOoD+5JQGoyDUW2W/iPWwBsNBJpyJS9y4je/BgxLcyQ==", "dev": true, - "dependencies": { - "prettier-linter-helpers": "^1.0.0", - "synckit": "^0.8.5" - }, - "engines": { - "node": "^14.18.0 ||>=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/prettier" - }, "peerDependencies": { - "@types/eslint": ">=8.0.0", - "eslint": ">=8.0.0", - "prettier": ">=3.0.0" - }, - "peerDependenciesMeta": { - "@types/eslint": { - "optional": true - }, - "eslint-config-prettier": { - "optional": true - } + "eslint": ">=5.0.0" } }, "node_modules/eslint-plugin-svelte": { @@ -7728,29 +7601,6 @@ "node": ">=6" } }, - "node_modules/execa": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/execa/-/execa-7.2.0.tgz", - "integrity": "sha512-UduyVP7TLB5IcAQl+OzLyLcS/l32W/GLg+AhHJ+ow40FOk2U3SAllPwR44v4vmdFwIWqpdwxxpQbF1n5ta9seA==", - "dev": true, - "dependencies": { - "cross-spawn": "^7.0.3", - "get-stream": "^6.0.1", - "human-signals": "^4.3.0", - "is-stream": "^3.0.0", - "merge-stream": "^2.0.0", - "npm-run-path": "^5.1.0", - "onetime": "^6.0.0", - "signal-exit": "^3.0.7", - "strip-final-newline": "^3.0.0" - }, - "engines": { - "node": "^14.18.0 || ^16.14.0 ||>=18.0.0" - }, - "funding": { - "url": "https://github.com/sindresorhus/execa?sponsor=1" - } - }, "node_modules/exponential-backoff": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/exponential-backoff/-/exponential-backoff-3.1.1.tgz", @@ -7789,12 +7639,6 @@ "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", "dev": true }, - "node_modules/fast-diff": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz", - "integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==", - "dev": true - }, "node_modules/fast-glob": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", @@ -8691,15 +8535,6 @@ "node": ">= 6" } }, - "node_modules/human-signals": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-4.3.1.tgz", - "integrity": "sha512-nZXjEF2nbo7lIw3mgYjItAfgQXog3OjJogSbKa2CQIIvSGWcKgeJnQlNXip6NglNzYH45nSRiEVimMvYL8DDqQ==", - "dev": true, - "engines": { - "node": ">=14.18.0" - } - }, "node_modules/humanize-ms": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz", @@ -9365,39 +9200,6 @@ "node": ">=0.10.0" } }, - "node_modules/is-inside-container": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-inside-container/-/is-inside-container-1.0.0.tgz", - "integrity": "sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA==", - "dev": true, - "dependencies": { - "is-docker": "^3.0.0" - }, - "bin": { - "is-inside-container": "cli.js" - }, - "engines": { - "node": ">=14.16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/is-inside-container/node_modules/is-docker": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-3.0.0.tgz", - "integrity": "sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ==", - "dev": true, - "bin": { - "is-docker": "cli.js" - }, - "engines": { - "node": "^12.20.0 || ^14.13.1 ||>=16.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/is-installed-globally": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/is-installed-globally/-/is-installed-globally-0.4.0.tgz", @@ -13056,18 +12858,6 @@ "url": "https://github.com/prettier/prettier?sponsor=1" } }, - "node_modules/prettier-linter-helpers": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", - "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", - "dev": true, - "dependencies": { - "fast-diff": "^1.1.2" - }, - "engines": { - "node": ">=6.0.0" - } - }, "node_modules/prettier-plugin-svelte": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/prettier-plugin-svelte/-/prettier-plugin-svelte-3.0.3.tgz", @@ -14033,110 +13823,6 @@ "integrity": "sha512-APM0Gt1KoXBz0iIkkdB/kfvGOwC4UuJFeG/c+yV7wSc7q96cG/kJ0HiYCnzivD9SB53cLV1MlHFNfOuPaadYSw==", "dev": true }, - "node_modules/run-applescript": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/run-applescript/-/run-applescript-5.0.0.tgz", - "integrity": "sha512-XcT5rBksx1QdIhlFOCtgZkB99ZEouFZ1E2Kc2LHqNW13U3/74YGdkQRmThTwxy4QIyookibDKYZOPqX//6BlAg==", - "dev": true, - "dependencies": { - "execa": "^5.0.0" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/run-applescript/node_modules/execa": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", - "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", - "dev": true, - "dependencies": { - "cross-spawn": "^7.0.3", - "get-stream": "^6.0.0", - "human-signals": "^2.1.0", - "is-stream": "^2.0.0", - "merge-stream": "^2.0.0", - "npm-run-path": "^4.0.1", - "onetime": "^5.1.2", - "signal-exit": "^3.0.3", - "strip-final-newline": "^2.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sindresorhus/execa?sponsor=1" - } - }, - "node_modules/run-applescript/node_modules/human-signals": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", - "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", - "dev": true, - "engines": { - "node": ">=10.17.0" - } - }, - "node_modules/run-applescript/node_modules/is-stream": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", - "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", - "dev": true, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/run-applescript/node_modules/mimic-fn": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", - "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/run-applescript/node_modules/npm-run-path": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", - "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", - "dev": true, - "dependencies": { - "path-key": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/run-applescript/node_modules/onetime": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", - "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", - "dev": true, - "dependencies": { - "mimic-fn": "^2.1.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/run-applescript/node_modules/strip-final-newline": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", - "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", - "dev": true, - "engines": { - "node": ">=6" - } - }, "node_modules/run-async": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz", @@ -15525,22 +15211,6 @@ "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==", "dev": true }, - "node_modules/synckit": { - "version": "0.8.5", - "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.8.5.tgz", - "integrity": "sha512-L1dapNV6vu2s/4Sputv8xGsCdAVlb5nRDMFU/E27D44l5U6cw1g0dGd45uLc+OXjNMmF4ntiMdCimzcjFKQI8Q==", - "dev": true, - "dependencies": { - "@pkgr/utils": "^2.3.1", - "tslib": "^2.5.0" - }, - "engines": { - "node": "^14.18.0 ||>=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/unts" - } - }, "node_modules/table": { "version": "6.8.1", "resolved": "https://registry.npmjs.org/table/-/table-6.8.1.tgz", @@ -15791,18 +15461,6 @@ "node": ">=14.0.0" } }, - "node_modules/titleize": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/titleize/-/titleize-3.0.0.tgz", - "integrity": "sha512-KxVu8EYHDPBdUYdKZdKtU2aj2XfEx9AfjXxE/Aj0vT06w2icA09Vus1rh6eSu1y01akYg6BjIK/hxyLJINoMLQ==", - "dev": true, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/tmp": { "version": "0.0.33", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", diff --git a/package.json b/package.json index 868df49..219ff0f 100644 --- a/package.json +++ b/package.json @@ -104,11 +104,12 @@ "dotenv": "16.3.1", "eslint": "8.53.0", "eslint-config-prettier": "9.0.0", + "eslint-import-resolver-alias": "1.1.2", "eslint-import-resolver-typescript": "3.6.1", "eslint-plugin-import": "2.29.0", "eslint-plugin-import-no-duplicates-prefix-resolved-path": "2.0.0", "eslint-plugin-jest-dom": "5.1.0", - "eslint-plugin-prettier": "5.0.1", + "eslint-plugin-simple-import-sort": "12.0.0", "eslint-plugin-svelte": "2.34.1", "eslint-plugin-testing-library": "6.1.0", "ignore": "5.3.0", From 8c65c8819fd5ec0e0e96f2e41e9f9e13185f42db Mon Sep 17 00:00:00 2001 From: nodeexx <156369338+nodeexx@users.noreply.github.com> Date: 2024年3月24日 13:35:16 +0100 Subject: [PATCH 20/29] Lint and fix import order --- playwright.api.config.ts | 5 +-- playwright.e2e.config.ts | 3 +- scripts/app/lib/lucia/client.js | 4 ++- .../app/seeds/enumeration/seedCodeSnippets.js | 3 +- scripts/app/seeds/groups/development.js | 3 +- scripts/app/seeds/groups/playwright.js | 3 +- scripts/stack/_lib/actions.js | 1 + scripts/stack/_lib/utils/docker.js | 1 + scripts/stack/local/all/api/down.js | 5 +-- scripts/stack/local/all/api/headless.js | 5 +-- scripts/stack/local/all/e2e/down.js | 5 +-- scripts/stack/local/all/e2e/headless.js | 5 +-- .../infra-app/playwright/api/headless.js | 9 ++--- .../local/infra-app/playwright/api/ui.js | 9 ++--- .../stack/local/infra-app/playwright/down.js | 5 +-- .../local/infra-app/playwright/e2e/codegen.js | 9 ++--- .../local/infra-app/playwright/e2e/headed.js | 9 ++--- .../infra-app/playwright/e2e/headless.js | 9 ++--- .../local/infra-app/playwright/e2e/ui.js | 9 ++--- .../stack/local/infra-app/stack-only/down.js | 5 +-- .../infra-app/stack-only/infra-app-seed.js | 7 ++-- .../local/infra-app/stack-only/infra-app.js | 5 +-- .../local/infra/playwright/api/headless.js | 9 ++--- .../stack/local/infra/playwright/api/ui.js | 9 ++--- scripts/stack/local/infra/playwright/down.js | 5 +-- .../local/infra/playwright/e2e/codegen.js | 9 ++--- .../local/infra/playwright/e2e/headed.js | 9 ++--- .../local/infra/playwright/e2e/headless.js | 9 ++--- .../stack/local/infra/playwright/e2e/ui.js | 9 ++--- .../stack/local/infra/playwright/infra-app.js | 7 ++-- scripts/stack/local/infra/stack-only/app.js | 5 +-- scripts/stack/local/infra/stack-only/down.js | 5 +-- .../stack/local/infra/stack-only/infra-app.js | 9 ++--- .../local/infra/stack-only/infra-migrate.js | 7 ++-- scripts/stack/local/infra/stack-only/infra.js | 5 +-- .../stack/local/infra/stack-only/migrate.js | 5 +-- scripts/stack/local/infra/stack-only/seed.js | 5 +-- .../testing/load/tests/_template.load-test.js | 4 +-- .../testing/load/tests/load-1.load-test.js | 6 ++-- src/hooks.client.ts | 7 ++-- src/hooks.server.ts | 17 ++++----- .../client/components/app-shell/AppBar.svelte | 1 + .../app-shell/AppBar.svelte.dom-test.ts | 5 +-- .../components/app-shell/AppMenuButton.svelte | 2 +- .../AppMenuButton.svelte.dom-test.ts | 18 +++++----- .../components/app-shell/AppShell.svelte | 1 + .../app-shell/AppShell.svelte.dom-test.ts | 7 ++-- .../client/components/app-shell/Error.svelte | 3 +- .../app-shell/Error.svelte.dom-test.ts | 14 ++++---- .../components/app-shell/PageMessage.svelte | 3 +- .../app-shell/PageMessage.svelte.dom-test.ts | 5 +-- .../code-snippets/CodeSnippetCard.svelte | 9 ++--- .../CodeSnippetCard.svelte.dom-test.ts | 16 +++++---- .../CodeSnippetCreateEditForm.svelte | 7 ++-- ...deSnippetCreateEditForm.svelte.dom-test.ts | 14 ++++---- .../code-snippets/CodeSnippetFindForm.svelte | 5 +-- .../CodeSnippetFindForm.svelte.dom-test.ts | 8 +++-- .../client/components/code-snippets/index.ts | 2 +- src/lib/client/components/common/Alert.svelte | 5 +-- .../common/Alert.svelte.dom-test.ts | 5 +-- .../components/common/Card.svelte.dom-test.ts | 9 ++--- .../common/SimplePaginator.svelte.dom-test.ts | 5 +-- ...SingleCardPageContainer.svelte.dom-test.ts | 7 ++-- src/lib/client/components/common/index.ts | 2 +- src/lib/client/core/config/index.ts | 4 +-- .../previous-app-page.store.dom-test.ts | 14 ++++---- .../core/stores/previous-app-page.store.ts | 9 ++--- src/lib/client/core/utils/index.ts | 2 +- .../core/utils/navigation.utils.dom-test.ts | 18 +++++----- src/lib/client/core/utils/navigation.utils.ts | 4 ++- .../global-messages/utils/index.dom-test.ts | 12 ++++--- src/lib/client/global-messages/utils/index.ts | 1 + src/lib/client/logging/client.ts | 1 + src/lib/client/logging/utils/index.ts | 1 + src/lib/client/posthog/client.ts | 3 +- ...ge-events-capture.configurator.dom-test.ts | 26 +++++++------- ...efault-page-events-capture.configurator.ts | 6 ++-- ...hog-user-identity.configurator.dom-test.ts | 24 +++++++------ .../posthog-user-identity.configurator.ts | 10 +++--- ...try-user-identity.configurator.dom-test.ts | 22 ++++++------ .../sentry-user-identity.configurator.ts | 7 ++-- src/lib/client/sentry/utils/index.ts | 3 +- src/lib/client/skeleton/utils/setup.utils.ts | 12 +++---- .../code-snippets.form-actions.node-test.ts | 24 +++++++------ .../code-snippets.form-actions.ts | 14 ++++---- .../code-snippets.service.node-test.ts | 10 +++--- .../services/code-snippets.service.ts | 3 +- .../code-snippets/utils/errors.node-test.ts | 5 +-- src/lib/server/core/config/index.ts | 5 +-- ...atory-private-env-vars.handle.node-test.ts | 3 +- ...check-mandatory-private-env-vars.handle.ts | 3 +- .../maintenance-mode.handle.node-test.ts | 6 ++-- .../core/hooks/maintenance-mode.handle.ts | 5 +-- .../server/core/utils/env.utils.node-test.ts | 12 ++++--- .../server/core/utils/url.utils.node-test.ts | 3 +- src/lib/server/lucia/client.ts | 8 +++-- .../lucia/guards/auth-user.guard.node-test.ts | 12 ++++--- .../server/lucia/guards/auth-user.guard.ts | 5 +-- ...add-auth-data-to-local.handle.node-test.ts | 3 +- .../hooks/add-auth-data-to-local.handle.ts | 1 + src/lib/server/lucia/oauth/google/provider.ts | 4 ++- .../google/utils/sign-in.utils.node-test.ts | 28 ++++++++------- .../lucia/oauth/google/utils/sign-in.utils.ts | 13 +++---- src/lib/server/lucia/utils/index.node-test.ts | 10 +++--- src/lib/server/lucia/utils/index.ts | 1 + .../pagination/utils/index.node-test.ts | 3 +- src/lib/server/pagination/utils/index.ts | 1 + src/lib/server/posthog/client.ts | 1 + src/lib/server/roarr/client.ts | 18 +++++----- src/lib/server/roarr/hooks/http-log.handle.ts | 3 +- src/lib/server/roarr/types/index.ts | 3 +- src/lib/server/roarr/utils/index.ts | 4 ++- ...t-sentry-user-identity.handle.node-test.ts | 18 +++++----- .../hooks/set-sentry-user-identity.handle.ts | 3 +- src/lib/server/sentry/utils/index.ts | 5 +-- .../create-edit-code-snippet.dto.node-test.ts | 6 ++-- .../dtos/create-edit-code-snippet.dto.ts | 3 +- .../dtos/delete-code-snippet.dto.node-test.ts | 6 ++-- .../dtos/delete-code-snippet.dto.ts | 3 +- .../dtos/find-code-snippets.dto.node-test.ts | 6 ++-- src/lib/shared/code-snippets/testing/index.ts | 1 + .../core/utils/datetime.utils.node-test.ts | 3 +- src/lib/shared/core/utils/index.ts | 2 +- .../core/utils/parsing.utils.node-test.ts | 3 +- .../shared/core/utils/url.utils.node-test.ts | 5 +-- src/lib/shared/logging/utils/index.ts | 4 ++- src/lib/shared/lucia/testing/index.ts | 3 +- .../shared/posthog/utils/index.node-test.ts | 9 ++--- src/lib/shared/sentry/client.node-test.ts | 17 ++++----- src/lib/shared/sentry/client.ts | 3 +- src/lib/shared/sentry/utils/index.ts | 3 +- .../shared/sveltekit/testing/test-helpers.ts | 5 +-- src/lib/shared/zod/utils/errors.node-test.ts | 3 +- src/lib/shared/zod/utils/extract.node-test.ts | 3 +- .../code-snippets/[id]/+page.server.ts | 12 ++++--- .../code-snippets/[id]/+page.svelte | 7 ++-- .../code-snippets/[id]/edit/+page.server.ts | 14 ++++---- .../code-snippets/[id]/edit/+page.svelte | 7 ++-- .../[id]/edit/page.server.node-test.ts | 36 ++++++++++--------- .../[id]/edit/page.svelte.dom-test.ts | 14 ++++---- .../[id]/page.server.node-test.ts | 32 +++++++++-------- .../[id]/page.svelte.dom-test.ts | 16 +++++---- .../code-snippets/create/+page.server.ts | 12 ++++--- .../code-snippets/create/+page.svelte | 2 +- .../create/page.server.node-test.ts | 24 +++++++------ .../create/page.svelte.dom-test.ts | 14 ++++---- .../(card-layout)/layout.svelte.dom-test.ts | 8 +++-- .../(card-layout)/profile/+page.server.ts | 16 +++++---- .../(app)/(card-layout)/profile/+page.svelte | 5 +-- .../profile/page.server.node-test.ts | 26 +++++++------- .../profile/page.svelte.dom-test.ts | 16 +++++---- src/routes/(app)/+page.server.ts | 10 +++--- src/routes/(app)/+page.svelte | 7 ++-- src/routes/(app)/layout.svelte.dom-test.ts | 8 +++-- .../(app)/page.CodeSnippetCard.mock.svelte | 5 +-- .../(app)/page.server.module.node-test.ts | 4 ++- src/routes/(app)/page.server.node-test.ts | 24 +++++++------ src/routes/(app)/page.svelte.dom-test.ts | 18 +++++----- src/routes/+layout.svelte | 14 ++++---- src/routes/api/healthcheck/+server.ts | 4 ++- .../api/healthcheck/server.node-test.ts | 4 ++- src/routes/error.svelte.dom-test.ts | 12 ++++--- src/routes/layout.server.node-test.ts | 8 +++-- src/routes/layout.svelte.dom-test.ts | 24 +++++++------ src/routes/maintenance/+page.server.ts | 2 ++ .../maintenance/page.server.node-test.ts | 8 +++-- src/routes/sign-in/+page.server.ts | 32 +++++++++-------- src/routes/sign-in/+page.svelte | 9 ++--- src/routes/sign-in/page.server.node-test.ts | 24 +++++++------ src/routes/sign-in/page.svelte.dom-test.ts | 16 +++++---- tailwind.config.ts | 4 +-- tests/playwright/api/tests/index.api-setup.ts | 5 +-- .../sign-out.api-test.ts | 5 +-- .../code-snippets/create.api-test.ts | 5 +-- .../code-snippets/delete.api-test.ts | 5 +-- .../code-snippets/edit.api-test.ts | 5 +-- .../api/tests/visitor/sign-in.api-test.ts | 2 +- tests/playwright/common/lib/setup.ts | 5 +-- .../e2e/page-objects/pages/home.page.ts | 1 + tests/playwright/e2e/tests/index.e2e-setup.ts | 7 ++-- .../sign-out.e2e-test.ts | 3 +- .../code-snippets/create.e2e-test.ts | 5 +-- .../code-snippets/delete.e2e-test.ts | 5 +-- .../code-snippets/edit.e2e-test.ts | 5 +-- .../code-snippets/view-details.e2e-test.ts | 3 +- .../code-snippets/view.e2e-test.ts | 1 + .../code-snippets/view-details.e2e-test.ts | 3 +- .../visitor/code-snippets/view.e2e-test.ts | 1 + .../e2e/tests/visitor/sign-in.e2e-test.ts | 3 +- vite.config.ts | 10 +++--- vitest.browser.config.ts | 1 + vitest.common.config.ts | 1 + vitest.dom.config.ts | 1 + vitest.node.config.ts | 1 + 194 files changed, 870 insertions(+), 628 deletions(-) diff --git a/playwright.api.config.ts b/playwright.api.config.ts index 4268629..4e90df3 100644 --- a/playwright.api.config.ts +++ b/playwright.api.config.ts @@ -1,10 +1,11 @@ import { defineConfig, devices } from '@playwright/test'; -import commonConfig from './playwright.common.config.ts'; import path from 'path'; + +import commonConfig from './playwright.common.config.ts'; import { - COMMON_SAVED_STATES_FOLDER, API_REPORTS_FOLDER, API_TESTS_FOLDER, + COMMON_SAVED_STATES_FOLDER, } from './tests/playwright/common/lib/constants.ts'; /** diff --git a/playwright.e2e.config.ts b/playwright.e2e.config.ts index 5f9f204..fdc6444 100644 --- a/playwright.e2e.config.ts +++ b/playwright.e2e.config.ts @@ -1,6 +1,7 @@ import { defineConfig, devices } from '@playwright/test'; -import commonConfig from './playwright.common.config.ts'; import path from 'path'; + +import commonConfig from './playwright.common.config.ts'; import { COMMON_SAVED_STATES_FOLDER, E2E_REPORTS_FOLDER, diff --git a/scripts/app/lib/lucia/client.js b/scripts/app/lib/lucia/client.js index ab1fbcf..55fc85f 100644 --- a/scripts/app/lib/lucia/client.js +++ b/scripts/app/lib/lucia/client.js @@ -1,8 +1,10 @@ // Polyfill the Web Crypto API, required only for Node.js runtime <= version 18 import 'lucia/polyfill/node'; + +import { prisma as prismaAdapter } from '@lucia-auth/adapter-prisma'; import { lucia } from 'lucia'; import { node as nodeMiddleware } from 'lucia/middleware'; -import { prisma as prismaAdapter } from '@lucia-auth/adapter-prisma'; + import { prisma as prismaClient } from '../prisma/client.js'; export const auth = lucia({ diff --git a/scripts/app/seeds/enumeration/seedCodeSnippets.js b/scripts/app/seeds/enumeration/seedCodeSnippets.js index 682e122..2ca1cee 100644 --- a/scripts/app/seeds/enumeration/seedCodeSnippets.js +++ b/scripts/app/seeds/enumeration/seedCodeSnippets.js @@ -1,6 +1,7 @@ -import { prisma } from '../../lib/prisma/client.js'; import { faker } from '@faker-js/faker'; +import { prisma } from '../../lib/prisma/client.js'; + const POSTGRES_CODE_SNIPPETS_SEQUENCE_NAME = 'code_snippets_id_seq'; const SEEDED_USER_ID = 'uop6wpmo6m20i6p'; const OTHER_SEEDED_USER_ID = 'zop6wpmo6m20i6p'; diff --git a/scripts/app/seeds/groups/development.js b/scripts/app/seeds/groups/development.js index d5adea9..143c6af 100644 --- a/scripts/app/seeds/groups/development.js +++ b/scripts/app/seeds/groups/development.js @@ -1,7 +1,8 @@ import { fileURLToPath } from 'url'; -import { seedUsersAndSessions } from '../enumeration/seedUsersAndSessions.js'; + import { logAndIgnoreError } from '../../lib/utils/errors.js'; import { seedCodeSnippets } from '../enumeration/seedCodeSnippets.js'; +import { seedUsersAndSessions } from '../enumeration/seedUsersAndSessions.js'; const filepath = fileURLToPath(import.meta.url); const filename = filepath.split('/').pop()?.split('.')[0]; diff --git a/scripts/app/seeds/groups/playwright.js b/scripts/app/seeds/groups/playwright.js index 6b91fcf..1169209 100644 --- a/scripts/app/seeds/groups/playwright.js +++ b/scripts/app/seeds/groups/playwright.js @@ -1,7 +1,8 @@ import { fileURLToPath } from 'url'; -import { seedUsersAndSessions } from '../enumeration/seedUsersAndSessions.js'; + import { deleteAll } from '../enumeration/deleteAll.js'; import { seedCodeSnippets } from '../enumeration/seedCodeSnippets.js'; +import { seedUsersAndSessions } from '../enumeration/seedUsersAndSessions.js'; const filepath = fileURLToPath(import.meta.url); const filename = filepath.split('/').pop()?.split('.')[0]; diff --git a/scripts/stack/_lib/actions.js b/scripts/stack/_lib/actions.js index eb20907..784ffc7 100644 --- a/scripts/stack/_lib/actions.js +++ b/scripts/stack/_lib/actions.js @@ -1,4 +1,5 @@ import { execSync, spawn } from 'child_process'; + import { displayDockerContainerLogs, startDockerizedStack, diff --git a/scripts/stack/_lib/utils/docker.js b/scripts/stack/_lib/utils/docker.js index 40f0db0..a0bf38e 100644 --- a/scripts/stack/_lib/utils/docker.js +++ b/scripts/stack/_lib/utils/docker.js @@ -1,4 +1,5 @@ import { execSync } from 'child_process'; + import { sleep } from './misc.js'; /** diff --git a/scripts/stack/local/all/api/down.js b/scripts/stack/local/all/api/down.js index e213c4d..59a76ca 100755 --- a/scripts/stack/local/all/api/down.js +++ b/scripts/stack/local/all/api/down.js @@ -1,11 +1,12 @@ #!/usr/bin/env node import { program } from 'commander'; + +import { stopDockerizedApi } from '../../../_lib/actions.js'; import { loadAndCheckEnvVars } from '../../../_lib/utils/env.js'; import { getPaths } from '../../../_lib/utils/paths.js'; -import { stopDockerizedApi } from '../../../_lib/actions.js'; -import { DOCKER_COMPOSE_FILES, ENV_FILE } from './_lib/constants.js'; import { MANDATORY_ENV_VARS } from '../_lib/constants.js'; +import { DOCKER_COMPOSE_FILES, ENV_FILE } from './_lib/constants.js'; main().catch((e) => { console.error(e); diff --git a/scripts/stack/local/all/api/headless.js b/scripts/stack/local/all/api/headless.js index ef43c1d..ee24780 100755 --- a/scripts/stack/local/all/api/headless.js +++ b/scripts/stack/local/all/api/headless.js @@ -1,11 +1,12 @@ #!/usr/bin/env node +import { execSync } from 'child_process'; import { program } from 'commander'; + +import { startDockerizedApi } from '../../../_lib/actions.js'; import { loadAndCheckEnvVars } from '../../../_lib/utils/env.js'; import { getPaths } from '../../../_lib/utils/paths.js'; -import { startDockerizedApi } from '../../../_lib/actions.js'; import { MANDATORY_ENV_VARS } from '../_lib/constants.js'; -import { execSync } from 'child_process'; import { DOCKER_COMPOSE_FILES, ENV_FILE } from './_lib/constants.js'; main().catch((e) => { diff --git a/scripts/stack/local/all/e2e/down.js b/scripts/stack/local/all/e2e/down.js index 87f6ff3..4a497ef 100755 --- a/scripts/stack/local/all/e2e/down.js +++ b/scripts/stack/local/all/e2e/down.js @@ -1,11 +1,12 @@ #!/usr/bin/env node import { program } from 'commander'; + +import { stopDockerizedE2E } from '../../../_lib/actions.js'; import { loadAndCheckEnvVars } from '../../../_lib/utils/env.js'; import { getPaths } from '../../../_lib/utils/paths.js'; -import { stopDockerizedE2E } from '../../../_lib/actions.js'; -import { DOCKER_COMPOSE_FILES, ENV_FILE } from './_lib/constants.js'; import { MANDATORY_ENV_VARS } from '../_lib/constants.js'; +import { DOCKER_COMPOSE_FILES, ENV_FILE } from './_lib/constants.js'; main().catch((e) => { console.error(e); diff --git a/scripts/stack/local/all/e2e/headless.js b/scripts/stack/local/all/e2e/headless.js index 9dde0db..ec26b08 100755 --- a/scripts/stack/local/all/e2e/headless.js +++ b/scripts/stack/local/all/e2e/headless.js @@ -1,11 +1,12 @@ #!/usr/bin/env node +import { execSync } from 'child_process'; import { program } from 'commander'; + +import { startDockerizedE2E } from '../../../_lib/actions.js'; import { loadAndCheckEnvVars } from '../../../_lib/utils/env.js'; import { getPaths } from '../../../_lib/utils/paths.js'; -import { startDockerizedE2E } from '../../../_lib/actions.js'; import { MANDATORY_ENV_VARS } from '../_lib/constants.js'; -import { execSync } from 'child_process'; import { DOCKER_COMPOSE_FILES, ENV_FILE } from './_lib/constants.js'; main().catch((e) => { diff --git a/scripts/stack/local/infra-app/playwright/api/headless.js b/scripts/stack/local/infra-app/playwright/api/headless.js index 7172323..be35f9d 100755 --- a/scripts/stack/local/infra-app/playwright/api/headless.js +++ b/scripts/stack/local/infra-app/playwright/api/headless.js @@ -1,15 +1,16 @@ #!/usr/bin/env node +import { execSync } from 'child_process'; import { program } from 'commander'; -import { loadAndCheckEnvVars } from '../../../../_lib/utils/env.js'; -import { getPaths } from '../../../../_lib/utils/paths.js'; + import { runLocalHeadlessApi, startDockerizedInfraApp, } from '../../../../_lib/actions.js'; -import { ENV_FILE, DOCKER_COMPOSE_FILES } from '../_lib/constants.js'; -import { execSync } from 'child_process'; +import { loadAndCheckEnvVars } from '../../../../_lib/utils/env.js'; +import { getPaths } from '../../../../_lib/utils/paths.js'; import { MANDATORY_ENV_VARS } from '../../_lib/constants.js'; +import { DOCKER_COMPOSE_FILES, ENV_FILE } from '../_lib/constants.js'; main().catch((e) => { console.error(e); diff --git a/scripts/stack/local/infra-app/playwright/api/ui.js b/scripts/stack/local/infra-app/playwright/api/ui.js index da78c59..3e43b7b 100755 --- a/scripts/stack/local/infra-app/playwright/api/ui.js +++ b/scripts/stack/local/infra-app/playwright/api/ui.js @@ -1,15 +1,16 @@ #!/usr/bin/env node +import { execSync } from 'child_process'; import { program } from 'commander'; -import { loadAndCheckEnvVars } from '../../../../_lib/utils/env.js'; -import { getPaths } from '../../../../_lib/utils/paths.js'; + import { runLocalUiApi, startDockerizedInfraApp, } from '../../../../_lib/actions.js'; -import { ENV_FILE, DOCKER_COMPOSE_FILES } from '../_lib/constants.js'; -import { execSync } from 'child_process'; +import { loadAndCheckEnvVars } from '../../../../_lib/utils/env.js'; +import { getPaths } from '../../../../_lib/utils/paths.js'; import { MANDATORY_ENV_VARS } from '../../_lib/constants.js'; +import { DOCKER_COMPOSE_FILES, ENV_FILE } from '../_lib/constants.js'; main().catch((e) => { console.error(e); diff --git a/scripts/stack/local/infra-app/playwright/down.js b/scripts/stack/local/infra-app/playwright/down.js index 92b0a0d..6685c1e 100755 --- a/scripts/stack/local/infra-app/playwright/down.js +++ b/scripts/stack/local/infra-app/playwright/down.js @@ -1,11 +1,12 @@ #!/usr/bin/env node import { program } from 'commander'; + +import { stopDockerizedInfraApp } from '../../../_lib/actions.js'; import { loadAndCheckEnvVars } from '../../../_lib/utils/env.js'; import { getPaths } from '../../../_lib/utils/paths.js'; -import { stopDockerizedInfraApp } from '../../../_lib/actions.js'; -import { ENV_FILE, DOCKER_COMPOSE_FILES } from './_lib/constants.js'; import { MANDATORY_ENV_VARS } from '../_lib/constants.js'; +import { DOCKER_COMPOSE_FILES, ENV_FILE } from './_lib/constants.js'; main().catch((e) => { console.error(e); diff --git a/scripts/stack/local/infra-app/playwright/e2e/codegen.js b/scripts/stack/local/infra-app/playwright/e2e/codegen.js index a5949d9..581fed8 100755 --- a/scripts/stack/local/infra-app/playwright/e2e/codegen.js +++ b/scripts/stack/local/infra-app/playwright/e2e/codegen.js @@ -1,15 +1,16 @@ #!/usr/bin/env node +import { execSync } from 'child_process'; import { program } from 'commander'; -import { loadAndCheckEnvVars } from '../../../../_lib/utils/env.js'; -import { getPaths } from '../../../../_lib/utils/paths.js'; + import { runLocalCodegenE2E, startDockerizedInfraApp, } from '../../../../_lib/actions.js'; -import { ENV_FILE, DOCKER_COMPOSE_FILES } from '../_lib/constants.js'; -import { execSync } from 'child_process'; +import { loadAndCheckEnvVars } from '../../../../_lib/utils/env.js'; +import { getPaths } from '../../../../_lib/utils/paths.js'; import { MANDATORY_ENV_VARS } from '../../_lib/constants.js'; +import { DOCKER_COMPOSE_FILES, ENV_FILE } from '../_lib/constants.js'; main().catch((e) => { console.error(e); diff --git a/scripts/stack/local/infra-app/playwright/e2e/headed.js b/scripts/stack/local/infra-app/playwright/e2e/headed.js index 3233dbf..628a639 100755 --- a/scripts/stack/local/infra-app/playwright/e2e/headed.js +++ b/scripts/stack/local/infra-app/playwright/e2e/headed.js @@ -1,15 +1,16 @@ #!/usr/bin/env node +import { execSync } from 'child_process'; import { program } from 'commander'; -import { loadAndCheckEnvVars } from '../../../../_lib/utils/env.js'; -import { getPaths } from '../../../../_lib/utils/paths.js'; + import { runLocalHeadedE2E, startDockerizedInfraApp, } from '../../../../_lib/actions.js'; -import { ENV_FILE, DOCKER_COMPOSE_FILES } from '../_lib/constants.js'; -import { execSync } from 'child_process'; +import { loadAndCheckEnvVars } from '../../../../_lib/utils/env.js'; +import { getPaths } from '../../../../_lib/utils/paths.js'; import { MANDATORY_ENV_VARS } from '../../_lib/constants.js'; +import { DOCKER_COMPOSE_FILES, ENV_FILE } from '../_lib/constants.js'; main().catch((e) => { console.error(e); diff --git a/scripts/stack/local/infra-app/playwright/e2e/headless.js b/scripts/stack/local/infra-app/playwright/e2e/headless.js index d4a2582..532cbc3 100755 --- a/scripts/stack/local/infra-app/playwright/e2e/headless.js +++ b/scripts/stack/local/infra-app/playwright/e2e/headless.js @@ -1,15 +1,16 @@ #!/usr/bin/env node +import { execSync } from 'child_process'; import { program } from 'commander'; -import { loadAndCheckEnvVars } from '../../../../_lib/utils/env.js'; -import { getPaths } from '../../../../_lib/utils/paths.js'; + import { runLocalHeadlessE2E, startDockerizedInfraApp, } from '../../../../_lib/actions.js'; -import { ENV_FILE, DOCKER_COMPOSE_FILES } from '../_lib/constants.js'; -import { execSync } from 'child_process'; +import { loadAndCheckEnvVars } from '../../../../_lib/utils/env.js'; +import { getPaths } from '../../../../_lib/utils/paths.js'; import { MANDATORY_ENV_VARS } from '../../_lib/constants.js'; +import { DOCKER_COMPOSE_FILES, ENV_FILE } from '../_lib/constants.js'; main().catch((e) => { console.error(e); diff --git a/scripts/stack/local/infra-app/playwright/e2e/ui.js b/scripts/stack/local/infra-app/playwright/e2e/ui.js index e6bc5d4..b25dcce 100755 --- a/scripts/stack/local/infra-app/playwright/e2e/ui.js +++ b/scripts/stack/local/infra-app/playwright/e2e/ui.js @@ -1,15 +1,16 @@ #!/usr/bin/env node +import { execSync } from 'child_process'; import { program } from 'commander'; -import { loadAndCheckEnvVars } from '../../../../_lib/utils/env.js'; -import { getPaths } from '../../../../_lib/utils/paths.js'; + import { runLocalUiE2E, startDockerizedInfraApp, } from '../../../../_lib/actions.js'; -import { ENV_FILE, DOCKER_COMPOSE_FILES } from '../_lib/constants.js'; -import { execSync } from 'child_process'; +import { loadAndCheckEnvVars } from '../../../../_lib/utils/env.js'; +import { getPaths } from '../../../../_lib/utils/paths.js'; import { MANDATORY_ENV_VARS } from '../../_lib/constants.js'; +import { DOCKER_COMPOSE_FILES, ENV_FILE } from '../_lib/constants.js'; main().catch((e) => { console.error(e); diff --git a/scripts/stack/local/infra-app/stack-only/down.js b/scripts/stack/local/infra-app/stack-only/down.js index 30c5bdb..40f14cc 100755 --- a/scripts/stack/local/infra-app/stack-only/down.js +++ b/scripts/stack/local/infra-app/stack-only/down.js @@ -1,11 +1,12 @@ #!/usr/bin/env node import { program } from 'commander'; + +import { stopDockerizedInfraApp } from '../../../_lib/actions.js'; import { loadAndCheckEnvVars } from '../../../_lib/utils/env.js'; import { getPaths } from '../../../_lib/utils/paths.js'; -import { stopDockerizedInfraApp } from '../../../_lib/actions.js'; -import { ENV_FILE, DOCKER_COMPOSE_FILES } from './_lib/constants.js'; import { MANDATORY_ENV_VARS } from '../_lib/constants.js'; +import { DOCKER_COMPOSE_FILES, ENV_FILE } from './_lib/constants.js'; main().catch((e) => { console.error(e); diff --git a/scripts/stack/local/infra-app/stack-only/infra-app-seed.js b/scripts/stack/local/infra-app/stack-only/infra-app-seed.js index eacf24a..55fa52e 100755 --- a/scripts/stack/local/infra-app/stack-only/infra-app-seed.js +++ b/scripts/stack/local/infra-app/stack-only/infra-app-seed.js @@ -1,14 +1,15 @@ #!/usr/bin/env node import { program } from 'commander'; -import { loadAndCheckEnvVars } from '../../../_lib/utils/env.js'; -import { getPaths } from '../../../_lib/utils/paths.js'; + import { performLocalSeeding, startDockerizedInfraApp, } from '../../../_lib/actions.js'; -import { ENV_FILE, DOCKER_COMPOSE_FILES } from './_lib/constants.js'; +import { loadAndCheckEnvVars } from '../../../_lib/utils/env.js'; +import { getPaths } from '../../../_lib/utils/paths.js'; import { MANDATORY_ENV_VARS } from '../_lib/constants.js'; +import { DOCKER_COMPOSE_FILES, ENV_FILE } from './_lib/constants.js'; main().catch((e) => { console.error(e); diff --git a/scripts/stack/local/infra-app/stack-only/infra-app.js b/scripts/stack/local/infra-app/stack-only/infra-app.js index 0b5302f..eb16c92 100755 --- a/scripts/stack/local/infra-app/stack-only/infra-app.js +++ b/scripts/stack/local/infra-app/stack-only/infra-app.js @@ -1,11 +1,12 @@ #!/usr/bin/env node import { program } from 'commander'; + +import { startDockerizedInfraApp } from '../../../_lib/actions.js'; import { loadAndCheckEnvVars } from '../../../_lib/utils/env.js'; import { getPaths } from '../../../_lib/utils/paths.js'; -import { startDockerizedInfraApp } from '../../../_lib/actions.js'; -import { ENV_FILE, DOCKER_COMPOSE_FILES } from './_lib/constants.js'; import { MANDATORY_ENV_VARS } from '../_lib/constants.js'; +import { DOCKER_COMPOSE_FILES, ENV_FILE } from './_lib/constants.js'; main().catch((e) => { console.error(e); diff --git a/scripts/stack/local/infra/playwright/api/headless.js b/scripts/stack/local/infra/playwright/api/headless.js index a100a87..80df916 100755 --- a/scripts/stack/local/infra/playwright/api/headless.js +++ b/scripts/stack/local/infra/playwright/api/headless.js @@ -1,20 +1,21 @@ #!/usr/bin/env node +import { execSync } from 'child_process'; import { program } from 'commander'; -import { loadAndCheckEnvVars } from '../../../../_lib/utils/env.js'; -import { getPaths } from '../../../../_lib/utils/paths.js'; + import { performLocalMigration, runLocalHeadlessApi, startDockerizedInfra, startLocalApp, } from '../../../../_lib/actions.js'; -import { ENV_FILE } from '../_lib/constants.js'; -import { execSync } from 'child_process'; +import { loadAndCheckEnvVars } from '../../../../_lib/utils/env.js'; +import { getPaths } from '../../../../_lib/utils/paths.js'; import { DOCKER_COMPOSE_FILES, MANDATORY_ENV_VARS, } from '../../_lib/constants.js'; +import { ENV_FILE } from '../_lib/constants.js'; main().catch((e) => { console.error(e); diff --git a/scripts/stack/local/infra/playwright/api/ui.js b/scripts/stack/local/infra/playwright/api/ui.js index 29793e1..3f2fc70 100755 --- a/scripts/stack/local/infra/playwright/api/ui.js +++ b/scripts/stack/local/infra/playwright/api/ui.js @@ -1,20 +1,21 @@ #!/usr/bin/env node +import { execSync } from 'child_process'; import { program } from 'commander'; -import { loadAndCheckEnvVars } from '../../../../_lib/utils/env.js'; -import { getPaths } from '../../../../_lib/utils/paths.js'; + import { performLocalMigration, runLocalUiApi, startDockerizedInfra, startLocalApp, } from '../../../../_lib/actions.js'; -import { ENV_FILE } from '../_lib/constants.js'; -import { execSync } from 'child_process'; +import { loadAndCheckEnvVars } from '../../../../_lib/utils/env.js'; +import { getPaths } from '../../../../_lib/utils/paths.js'; import { DOCKER_COMPOSE_FILES, MANDATORY_ENV_VARS, } from '../../_lib/constants.js'; +import { ENV_FILE } from '../_lib/constants.js'; main().catch((e) => { console.error(e); diff --git a/scripts/stack/local/infra/playwright/down.js b/scripts/stack/local/infra/playwright/down.js index 0160922..0c87246 100755 --- a/scripts/stack/local/infra/playwright/down.js +++ b/scripts/stack/local/infra/playwright/down.js @@ -1,11 +1,12 @@ #!/usr/bin/env node import { program } from 'commander'; + +import { stopDockerizedInfra, stopLocalApp } from '../../../_lib/actions.js'; import { loadAndCheckEnvVars } from '../../../_lib/utils/env.js'; import { getPaths } from '../../../_lib/utils/paths.js'; -import { stopDockerizedInfra, stopLocalApp } from '../../../_lib/actions.js'; -import { ENV_FILE } from './_lib/constants.js'; import { DOCKER_COMPOSE_FILES, MANDATORY_ENV_VARS } from '../_lib/constants.js'; +import { ENV_FILE } from './_lib/constants.js'; main().catch((e) => { console.error(e); diff --git a/scripts/stack/local/infra/playwright/e2e/codegen.js b/scripts/stack/local/infra/playwright/e2e/codegen.js index a21f7e3..ef69457 100755 --- a/scripts/stack/local/infra/playwright/e2e/codegen.js +++ b/scripts/stack/local/infra/playwright/e2e/codegen.js @@ -1,20 +1,21 @@ #!/usr/bin/env node +import { execSync } from 'child_process'; import { program } from 'commander'; -import { loadAndCheckEnvVars } from '../../../../_lib/utils/env.js'; -import { getPaths } from '../../../../_lib/utils/paths.js'; + import { performLocalMigration, runLocalCodegenE2E, startDockerizedInfra, startLocalApp, } from '../../../../_lib/actions.js'; -import { ENV_FILE } from '../_lib/constants.js'; -import { execSync } from 'child_process'; +import { loadAndCheckEnvVars } from '../../../../_lib/utils/env.js'; +import { getPaths } from '../../../../_lib/utils/paths.js'; import { DOCKER_COMPOSE_FILES, MANDATORY_ENV_VARS, } from '../../_lib/constants.js'; +import { ENV_FILE } from '../_lib/constants.js'; main().catch((e) => { console.error(e); diff --git a/scripts/stack/local/infra/playwright/e2e/headed.js b/scripts/stack/local/infra/playwright/e2e/headed.js index ca15ebe..ba99819 100755 --- a/scripts/stack/local/infra/playwright/e2e/headed.js +++ b/scripts/stack/local/infra/playwright/e2e/headed.js @@ -1,20 +1,21 @@ #!/usr/bin/env node +import { execSync } from 'child_process'; import { program } from 'commander'; -import { loadAndCheckEnvVars } from '../../../../_lib/utils/env.js'; -import { getPaths } from '../../../../_lib/utils/paths.js'; + import { performLocalMigration, runLocalHeadedE2E, startDockerizedInfra, startLocalApp, } from '../../../../_lib/actions.js'; -import { ENV_FILE } from '../_lib/constants.js'; -import { execSync } from 'child_process'; +import { loadAndCheckEnvVars } from '../../../../_lib/utils/env.js'; +import { getPaths } from '../../../../_lib/utils/paths.js'; import { DOCKER_COMPOSE_FILES, MANDATORY_ENV_VARS, } from '../../_lib/constants.js'; +import { ENV_FILE } from '../_lib/constants.js'; main().catch((e) => { console.error(e); diff --git a/scripts/stack/local/infra/playwright/e2e/headless.js b/scripts/stack/local/infra/playwright/e2e/headless.js index b5b2fe2..5b0969d 100755 --- a/scripts/stack/local/infra/playwright/e2e/headless.js +++ b/scripts/stack/local/infra/playwright/e2e/headless.js @@ -1,20 +1,21 @@ #!/usr/bin/env node +import { execSync } from 'child_process'; import { program } from 'commander'; -import { loadAndCheckEnvVars } from '../../../../_lib/utils/env.js'; -import { getPaths } from '../../../../_lib/utils/paths.js'; + import { performLocalMigration, runLocalHeadlessE2E, startDockerizedInfra, startLocalApp, } from '../../../../_lib/actions.js'; -import { ENV_FILE } from '../_lib/constants.js'; -import { execSync } from 'child_process'; +import { loadAndCheckEnvVars } from '../../../../_lib/utils/env.js'; +import { getPaths } from '../../../../_lib/utils/paths.js'; import { DOCKER_COMPOSE_FILES, MANDATORY_ENV_VARS, } from '../../_lib/constants.js'; +import { ENV_FILE } from '../_lib/constants.js'; main().catch((e) => { console.error(e); diff --git a/scripts/stack/local/infra/playwright/e2e/ui.js b/scripts/stack/local/infra/playwright/e2e/ui.js index f7feba8..a0419e8 100755 --- a/scripts/stack/local/infra/playwright/e2e/ui.js +++ b/scripts/stack/local/infra/playwright/e2e/ui.js @@ -1,20 +1,21 @@ #!/usr/bin/env node +import { execSync } from 'child_process'; import { program } from 'commander'; -import { loadAndCheckEnvVars } from '../../../../_lib/utils/env.js'; -import { getPaths } from '../../../../_lib/utils/paths.js'; + import { performLocalMigration, runLocalUiE2E, startDockerizedInfra, startLocalApp, } from '../../../../_lib/actions.js'; -import { ENV_FILE } from '../_lib/constants.js'; -import { execSync } from 'child_process'; +import { loadAndCheckEnvVars } from '../../../../_lib/utils/env.js'; +import { getPaths } from '../../../../_lib/utils/paths.js'; import { DOCKER_COMPOSE_FILES, MANDATORY_ENV_VARS, } from '../../_lib/constants.js'; +import { ENV_FILE } from '../_lib/constants.js'; main().catch((e) => { console.error(e); diff --git a/scripts/stack/local/infra/playwright/infra-app.js b/scripts/stack/local/infra/playwright/infra-app.js index 057a0e9..a36166d 100755 --- a/scripts/stack/local/infra/playwright/infra-app.js +++ b/scripts/stack/local/infra/playwright/infra-app.js @@ -1,15 +1,16 @@ #!/usr/bin/env node import { program } from 'commander'; -import { loadAndCheckEnvVars } from '../../../_lib/utils/env.js'; -import { getPaths } from '../../../_lib/utils/paths.js'; + import { performLocalMigration, startDockerizedInfra, startLocalApp, } from '../../../_lib/actions.js'; -import { ENV_FILE } from './_lib/constants.js'; +import { loadAndCheckEnvVars } from '../../../_lib/utils/env.js'; +import { getPaths } from '../../../_lib/utils/paths.js'; import { DOCKER_COMPOSE_FILES, MANDATORY_ENV_VARS } from '../_lib/constants.js'; +import { ENV_FILE } from './_lib/constants.js'; main().catch((e) => { console.error(e); diff --git a/scripts/stack/local/infra/stack-only/app.js b/scripts/stack/local/infra/stack-only/app.js index 3622bd4..a489be1 100755 --- a/scripts/stack/local/infra/stack-only/app.js +++ b/scripts/stack/local/infra/stack-only/app.js @@ -1,11 +1,12 @@ #!/usr/bin/env node import { program } from 'commander'; + +import { runLocalApp } from '../../../_lib/actions.js'; import { loadAndCheckEnvVars } from '../../../_lib/utils/env.js'; import { getPaths } from '../../../_lib/utils/paths.js'; -import { runLocalApp } from '../../../_lib/actions.js'; -import { ENV_FILE } from './_lib/constants.js'; import { MANDATORY_ENV_VARS } from '../_lib/constants.js'; +import { ENV_FILE } from './_lib/constants.js'; main().catch((e) => { console.error(e); diff --git a/scripts/stack/local/infra/stack-only/down.js b/scripts/stack/local/infra/stack-only/down.js index 826b61a..955469b 100755 --- a/scripts/stack/local/infra/stack-only/down.js +++ b/scripts/stack/local/infra/stack-only/down.js @@ -1,11 +1,12 @@ #!/usr/bin/env node import { program } from 'commander'; + +import { stopDockerizedInfra, stopLocalApp } from '../../../_lib/actions.js'; import { loadAndCheckEnvVars } from '../../../_lib/utils/env.js'; import { getPaths } from '../../../_lib/utils/paths.js'; -import { stopDockerizedInfra, stopLocalApp } from '../../../_lib/actions.js'; -import { ENV_FILE } from './_lib/constants.js'; import { DOCKER_COMPOSE_FILES, MANDATORY_ENV_VARS } from '../_lib/constants.js'; +import { ENV_FILE } from './_lib/constants.js'; main().catch((e) => { console.error(e); diff --git a/scripts/stack/local/infra/stack-only/infra-app.js b/scripts/stack/local/infra/stack-only/infra-app.js index 531ff88..fedb610 100755 --- a/scripts/stack/local/infra/stack-only/infra-app.js +++ b/scripts/stack/local/infra/stack-only/infra-app.js @@ -1,16 +1,17 @@ #!/usr/bin/env node +import { execSync } from 'child_process'; import { program } from 'commander'; -import { loadAndCheckEnvVars } from '../../../_lib/utils/env.js'; -import { getPaths } from '../../../_lib/utils/paths.js'; + import { performLocalMigration, runLocalApp, startDockerizedInfra, } from '../../../_lib/actions.js'; -import { ENV_FILE } from './_lib/constants.js'; +import { loadAndCheckEnvVars } from '../../../_lib/utils/env.js'; +import { getPaths } from '../../../_lib/utils/paths.js'; import { DOCKER_COMPOSE_FILES, MANDATORY_ENV_VARS } from '../_lib/constants.js'; -import { execSync } from 'child_process'; +import { ENV_FILE } from './_lib/constants.js'; main().catch((e) => { console.error(e); diff --git a/scripts/stack/local/infra/stack-only/infra-migrate.js b/scripts/stack/local/infra/stack-only/infra-migrate.js index 23705c5..05c633b 100755 --- a/scripts/stack/local/infra/stack-only/infra-migrate.js +++ b/scripts/stack/local/infra/stack-only/infra-migrate.js @@ -1,14 +1,15 @@ #!/usr/bin/env node import { program } from 'commander'; -import { loadAndCheckEnvVars } from '../../../_lib/utils/env.js'; -import { getPaths } from '../../../_lib/utils/paths.js'; + import { performLocalMigration, startDockerizedInfra, } from '../../../_lib/actions.js'; -import { ENV_FILE } from './_lib/constants.js'; +import { loadAndCheckEnvVars } from '../../../_lib/utils/env.js'; +import { getPaths } from '../../../_lib/utils/paths.js'; import { DOCKER_COMPOSE_FILES, MANDATORY_ENV_VARS } from '../_lib/constants.js'; +import { ENV_FILE } from './_lib/constants.js'; main().catch((e) => { console.error(e); diff --git a/scripts/stack/local/infra/stack-only/infra.js b/scripts/stack/local/infra/stack-only/infra.js index 8ec598a..549f24b 100755 --- a/scripts/stack/local/infra/stack-only/infra.js +++ b/scripts/stack/local/infra/stack-only/infra.js @@ -1,11 +1,12 @@ #!/usr/bin/env node import { program } from 'commander'; + +import { startDockerizedInfra } from '../../../_lib/actions.js'; import { loadAndCheckEnvVars } from '../../../_lib/utils/env.js'; import { getPaths } from '../../../_lib/utils/paths.js'; -import { startDockerizedInfra } from '../../../_lib/actions.js'; -import { ENV_FILE } from './_lib/constants.js'; import { DOCKER_COMPOSE_FILES, MANDATORY_ENV_VARS } from '../_lib/constants.js'; +import { ENV_FILE } from './_lib/constants.js'; main().catch((e) => { console.error(e); diff --git a/scripts/stack/local/infra/stack-only/migrate.js b/scripts/stack/local/infra/stack-only/migrate.js index 0111d17..a6a05c6 100755 --- a/scripts/stack/local/infra/stack-only/migrate.js +++ b/scripts/stack/local/infra/stack-only/migrate.js @@ -1,11 +1,12 @@ #!/usr/bin/env node import { program } from 'commander'; + +import { performLocalMigration } from '../../../_lib/actions.js'; import { loadAndCheckEnvVars } from '../../../_lib/utils/env.js'; import { getPaths } from '../../../_lib/utils/paths.js'; -import { performLocalMigration } from '../../../_lib/actions.js'; -import { ENV_FILE } from './_lib/constants.js'; import { MANDATORY_ENV_VARS } from '../_lib/constants.js'; +import { ENV_FILE } from './_lib/constants.js'; main().catch((e) => { console.error(e); diff --git a/scripts/stack/local/infra/stack-only/seed.js b/scripts/stack/local/infra/stack-only/seed.js index 7fa6d76..dba659e 100755 --- a/scripts/stack/local/infra/stack-only/seed.js +++ b/scripts/stack/local/infra/stack-only/seed.js @@ -1,11 +1,12 @@ #!/usr/bin/env node import { program } from 'commander'; + +import { performLocalSeeding } from '../../../_lib/actions.js'; import { loadAndCheckEnvVars } from '../../../_lib/utils/env.js'; import { getPaths } from '../../../_lib/utils/paths.js'; -import { performLocalSeeding } from '../../../_lib/actions.js'; -import { ENV_FILE } from './_lib/constants.js'; import { MANDATORY_ENV_VARS } from '../_lib/constants.js'; +import { ENV_FILE } from './_lib/constants.js'; main().catch((e) => { console.error(e); diff --git a/scripts/testing/load/tests/_template.load-test.js b/scripts/testing/load/tests/_template.load-test.js index ff06193..251bc28 100644 --- a/scripts/testing/load/tests/_template.load-test.js +++ b/scripts/testing/load/tests/_template.load-test.js @@ -1,7 +1,7 @@ // @ts-expect-error -import http from 'k6/http'; -// @ts-expect-error import { sleep } from 'k6'; +// @ts-expect-error +import http from 'k6/http'; export const options = { // A number specifying the number of VUs to run concurrently. diff --git a/scripts/testing/load/tests/load-1.load-test.js b/scripts/testing/load/tests/load-1.load-test.js index f5451ee..40470b0 100644 --- a/scripts/testing/load/tests/load-1.load-test.js +++ b/scripts/testing/load/tests/load-1.load-test.js @@ -1,11 +1,11 @@ // @ts-expect-error -import http from 'k6/http'; +import { htmlReport } from 'https://raw.githubusercontent.com/benc-uk/k6-reporter/main/dist/bundle.js'; // @ts-expect-error import { check, sleep } from 'k6'; // @ts-expect-error -import { Rate } from 'k6/metrics'; +import http from 'k6/http'; // @ts-expect-error -import { htmlReport } from 'https://raw.githubusercontent.com/benc-uk/k6-reporter/main/dist/bundle.js'; +import { Rate } from 'k6/metrics'; // Define the failure rate let failureRate = new Rate('failed_requests'); diff --git a/src/hooks.client.ts b/src/hooks.client.ts index c29e6cf..e271ca3 100644 --- a/src/hooks.client.ts +++ b/src/hooks.client.ts @@ -1,13 +1,14 @@ -import { dev } from '$app/environment'; import type { HandleClientError } from '@sveltejs/kit'; + +import { dev } from '$app/environment'; import { config } from '$lib/client/core/config'; -import { handleErrorWithSentry, setupSentryClient } from '$lib/shared/sentry'; +import { logger } from '$lib/client/logging'; import { setupBrowserPosthogClient } from '$lib/client/posthog'; import { getClientSentryIntegrations, setClientPosthogSessionId, } from '$lib/client/sentry/utils'; -import { logger } from '$lib/client/logging'; +import { handleErrorWithSentry, setupSentryClient } from '$lib/shared/sentry'; setupBrowserPosthogClient(config.posthog.projectApiKey, config.posthog.apiHost); setupSentryClient({ diff --git a/src/hooks.server.ts b/src/hooks.server.ts index a38e44a..20f8b5b 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -1,21 +1,22 @@ +import type { Handle, HandleServerError } from '@sveltejs/kit'; +import { sequence } from '@sveltejs/kit/hooks'; + +import { config } from '$lib/server/core/config'; import { checkMandatoryPrivateEnvVarsHandle, maintenanceModeHandle, } from '$lib/server/core/hooks'; import { addAuthDataToLocalHandle } from '$lib/server/lucia/hooks'; -import { sequence } from '@sveltejs/kit/hooks'; -import { config } from '$lib/server/core/config'; -import type { Handle, HandleServerError } from '@sveltejs/kit'; +import { posthog, setupNodePosthogClient } from '$lib/server/posthog'; +import { roarr } from '$lib/server/roarr'; +import { httpLogHandle } from '$lib/server/roarr/hooks'; +import { setSentryUserIdentity } from '$lib/server/sentry/hooks'; +import { getServerSentryIntegrations } from '$lib/server/sentry/utils'; import { handleErrorWithSentry, sentry, setupSentryClient, } from '$lib/shared/sentry'; -import { setSentryUserIdentity } from '$lib/server/sentry/hooks'; -import { posthog, setupNodePosthogClient } from '$lib/server/posthog'; -import { getServerSentryIntegrations } from '$lib/server/sentry/utils'; -import { roarr } from '$lib/server/roarr'; -import { httpLogHandle } from '$lib/server/roarr/hooks'; setupNodePosthogClient(config.posthog.projectApiKey, config.posthog.apiHost); setupSentryClient({ diff --git a/src/lib/client/components/app-shell/AppBar.svelte b/src/lib/client/components/app-shell/AppBar.svelte index 4fab452..f58fb9d 100644 --- a/src/lib/client/components/app-shell/AppBar.svelte +++ b/src/lib/client/components/app-shell/AppBar.svelte @@ -1,5 +1,6 @@ diff --git a/src/lib/client/components/app-shell/AppBar.svelte.dom-test.ts b/src/lib/client/components/app-shell/AppBar.svelte.dom-test.ts index 2c0d8c3..d7e7454 100644 --- a/src/lib/client/components/app-shell/AppBar.svelte.dom-test.ts +++ b/src/lib/client/components/app-shell/AppBar.svelte.dom-test.ts @@ -1,5 +1,6 @@ -import { describe, it, expect, afterEach } from 'vitest'; -import { render, cleanup } from '@testing-library/svelte'; +import { cleanup, render } from '@testing-library/svelte'; +import { afterEach, describe, expect, it } from 'vitest'; + import Component from './AppBar.svelte'; describe(Component.name, () => { diff --git a/src/lib/client/components/app-shell/AppMenuButton.svelte b/src/lib/client/components/app-shell/AppMenuButton.svelte index e12233b..766a930 100644 --- a/src/lib/client/components/app-shell/AppMenuButton.svelte +++ b/src/lib/client/components/app-shell/AppMenuButton.svelte @@ -2,8 +2,8 @@ import IconUser from '~icons/fa6-solid/user'; import { page } from '$app/stores'; import { - ORIGINAL_PATH_URL_QUERY_PARAM_NAME, encodeOriginalPath, + ORIGINAL_PATH_URL_QUERY_PARAM_NAME, } from '$lib/shared/core/utils'; $: signInPath = getSignInPath($page.url); diff --git a/src/lib/client/components/app-shell/AppMenuButton.svelte.dom-test.ts b/src/lib/client/components/app-shell/AppMenuButton.svelte.dom-test.ts index 16d4471..67326f1 100644 --- a/src/lib/client/components/app-shell/AppMenuButton.svelte.dom-test.ts +++ b/src/lib/client/components/app-shell/AppMenuButton.svelte.dom-test.ts @@ -1,14 +1,16 @@ -import { describe, it, expect, vi, afterEach } from 'vitest'; -import { render, cleanup } from '@testing-library/svelte'; -import Component from './AppMenuButton.svelte'; +import type { Page } from '@sveltejs/kit'; +import { cleanup, render } from '@testing-library/svelte'; +import { readable } from 'svelte/store'; +import { afterEach, describe, expect, it, vi } from 'vitest'; + +import * as appStores from '$app/stores'; +import type { AuthUser } from '$lib/shared/lucia/types'; import { - SveltekitDefaultMocks, defaultMockAppStoresPageValue, + SveltekitDefaultMocks, } from '$lib/shared/sveltekit/testing'; -import type { AuthUser } from '$lib/shared/lucia/types'; -import * as appStores from '$app/stores'; -import { readable } from 'svelte/store'; -import type { Page } from '@sveltejs/kit'; + +import Component from './AppMenuButton.svelte'; describe(Component.name, () => { afterEach(() => { diff --git a/src/lib/client/components/app-shell/AppShell.svelte b/src/lib/client/components/app-shell/AppShell.svelte index 19f59de..2702f85 100644 --- a/src/lib/client/components/app-shell/AppShell.svelte +++ b/src/lib/client/components/app-shell/AppShell.svelte @@ -1,5 +1,6 @@ diff --git a/src/lib/client/logging/client.ts b/src/lib/client/logging/client.ts index 362e12f..abaeef6 100644 --- a/src/lib/client/logging/client.ts +++ b/src/lib/client/logging/client.ts @@ -18,7 +18,7 @@ export const logger = (function () { return ( message: string, context: LoggerContext = {}, - stackLevel: number = 3, + stackLevel = 3, ) => { if (!shouldBeLogged(methodName)) { return; diff --git a/src/lib/client/sentry/utils/index.ts b/src/lib/client/sentry/utils/index.ts index 638dd81..274588f 100644 --- a/src/lib/client/sentry/utils/index.ts +++ b/src/lib/client/sentry/utils/index.ts @@ -19,6 +19,6 @@ export function getClientSentryIntegrations( export function setClientPosthogSessionId(): void { if (posthog) { - sentry?.setTag(POSTHOG_SESSION_ID_TAG, getSessionId() as string); + sentry?.setTag(POSTHOG_SESSION_ID_TAG, getSessionId()!); } } diff --git a/src/lib/server/lucia/oauth/google/constants.ts b/src/lib/server/lucia/oauth/google/constants.ts index 29309ba..7921643 100644 --- a/src/lib/server/lucia/oauth/google/constants.ts +++ b/src/lib/server/lucia/oauth/google/constants.ts @@ -1,7 +1,7 @@ // See `state` parameter: // https://developers.google.com/identity/protocols/oauth2/javascript-implicit-flow#redirecting -export const GOOGLE_OAUTH_STATE_COOKIE_NAME: string = 'google_oauth_state'; -export const GOOGLE_OAUTH_STATE_SEPARATOR: string = '-----'; -export const GOOGLE_OAUTH_STATE_QUERY_PARAM_NAME: string = 'state'; -export const GOOGLE_OAUTH_CODE_QUERY_PARAM_NAME: string = 'code'; -export const GOOGLE_OAUTH_TYPE_QUERY_PARAM_VALUE: string = 'google'; +export const GOOGLE_OAUTH_STATE_COOKIE_NAME = 'google_oauth_state'; +export const GOOGLE_OAUTH_STATE_SEPARATOR = '-----'; +export const GOOGLE_OAUTH_STATE_QUERY_PARAM_NAME = 'state'; +export const GOOGLE_OAUTH_CODE_QUERY_PARAM_NAME = 'code'; +export const GOOGLE_OAUTH_TYPE_QUERY_PARAM_VALUE = 'google'; diff --git a/src/lib/server/roarr/client.ts b/src/lib/server/roarr/client.ts index fd29b1b..489b00a 100644 --- a/src/lib/server/roarr/client.ts +++ b/src/lib/server/roarr/client.ts @@ -20,7 +20,7 @@ export const roarr = (function () { return ( message: string, context: ServerLoggerContextWithError = {}, - stackLevel: number = 3, + stackLevel = 3, ) => { if (!shouldBeLogged(methodName)) { return; diff --git a/src/lib/server/roarr/types/index.ts b/src/lib/server/roarr/types/index.ts index 1f097ca..2075d57 100644 --- a/src/lib/server/roarr/types/index.ts +++ b/src/lib/server/roarr/types/index.ts @@ -11,9 +11,9 @@ export type ServerLoggerLoggingMethodName = | ServerLoggerLoggingMethodNameNoOnce | ServerLoggerLoggingMethodNameOnce; -export type JsonObject = { +export interface JsonObject { [k: string]: JsonValue; -}; +} export type JsonValue = | JsonObject | JsonValue[] diff --git a/src/lib/shared/logging/utils/index.ts b/src/lib/shared/logging/utils/index.ts index 8d8e6fa..657b843 100644 --- a/src/lib/shared/logging/utils/index.ts +++ b/src/lib/shared/logging/utils/index.ts @@ -26,7 +26,7 @@ export function enrichLoggerContextWithSentryTraceId( export function enrichContextWithDebugInfo( context: LoggerContext = {}, rootFolder = '', - stackLevel: number = 3, + stackLevel = 3, ): LoggerContext { return { ...context, @@ -35,7 +35,7 @@ export function enrichContextWithDebugInfo( }; } -function getCallName(stackLevel: number = 3): string { +function getCallName(stackLevel = 3): string { const typeName = callsites()[stackLevel]?.getTypeName() ?? ''; const functionName = callsites()[3]?.getFunctionName() ?? @@ -49,7 +49,7 @@ function getCallName(stackLevel: number = 3): string { return functionName; } -function getFileName(rootFolder = '', stackLevel: number = 3): string { +function getFileName(rootFolder = '', stackLevel = 3): string { const fileName = callsites()[stackLevel]?.getFileName() ?? callsites()[stackLevel]?.getEvalOrigin() ?? diff --git a/src/routes/(app)/page.server.module.ts b/src/routes/(app)/page.server.module.ts index 7fe6f90..89caf61 100644 --- a/src/routes/(app)/page.server.module.ts +++ b/src/routes/(app)/page.server.module.ts @@ -67,23 +67,23 @@ export function cleanSearchParamsAndGenerateQuery( const path = String(errorPath[0]); if (['page', 'count'].includes(path)) { - delete findCodeSnippetsQuery['page']; + delete findCodeSnippetsQuery.page; cleanedSearchParams.delete('page'); - findCodeSnippetsQuery['count'] = DEFAULT_CODE_SNIPPET_COUNT; + findCodeSnippetsQuery.count = DEFAULT_CODE_SNIPPET_COUNT; cleanedSearchParams.delete('count'); } if (['filterBy'].includes(path)) { - delete findCodeSnippetsQuery['filterBy']; + delete findCodeSnippetsQuery.filterBy; cleanedSearchParams.delete('filterBy'); - delete findCodeSnippetsQuery['filterValue']; + delete findCodeSnippetsQuery.filterValue; cleanedSearchParams.delete('filterValue'); } if (['sortOrder'].includes(path)) { - findCodeSnippetsQuery['sortOrder'] = 'asc'; + findCodeSnippetsQuery.sortOrder = 'asc'; cleanedSearchParams.delete('sortOrder'); } }); From 5a0b5f99783fa81021665b871944364e804205f4 Mon Sep 17 00:00:00 2001 From: nodeexx <156369338+nodeexx@users.noreply.github.com> Date: 2024年3月25日 11:21:51 +0100 Subject: [PATCH 24/29] Fix ESLint linting errors related to plugin:@typescript-eslint/strict-type-checked --- scripts/stack/_lib/utils/docker.js | 3 ++- scripts/stack/local/all/api/down.js | 8 +++++--- scripts/stack/local/all/e2e/down.js | 8 +++++--- scripts/stack/local/infra-app/playwright/down.js | 8 +++++--- scripts/stack/local/infra-app/stack-only/down.js | 8 +++++--- scripts/stack/local/infra/playwright/down.js | 8 +++++--- scripts/stack/local/infra/stack-only/app.js | 8 +++++--- scripts/stack/local/infra/stack-only/down.js | 8 +++++--- scripts/stack/local/infra/stack-only/migrate.js | 8 +++++--- scripts/stack/local/infra/stack-only/seed.js | 8 +++++--- src/hooks.client.ts | 2 +- src/hooks.server.ts | 4 +++- ...sthog-default-page-events-capture.configurator.ts | 2 +- src/lib/client/sentry/utils/index.ts | 2 +- src/lib/client/skeleton/utils/setup.utils.ts | 2 +- .../code-snippets/services/code-snippets.service.ts | 12 ++++++------ .../hooks/add-auth-data-to-local.handle.node-test.ts | 2 ++ .../server/lucia/oauth/google/utils/sign-in.utils.ts | 2 +- src/lib/server/posthog/client.ts | 4 ++-- src/lib/server/superforms/testing/index.ts | 2 +- src/lib/shared/sentry/client.node-test.ts | 10 +++++----- src/lib/shared/sveltekit/testing/test-helpers.ts | 4 ++-- .../(card-layout)/code-snippets/[id]/+page.server.ts | 3 ++- src/routes/(app)/+page.server.ts | 3 ++- src/routes/(app)/page.server.module.ts | 4 ++-- src/routes/+layout.server.ts | 2 +- src/routes/api/healthcheck/+server.ts | 2 +- src/routes/api/healthcheck/server.node-test.ts | 4 ++-- src/routes/maintenance/+page.server.ts | 2 +- tailwind.config.ts | 2 +- tests/playwright/api/tests/index.api-teardown.ts | 2 +- tests/playwright/e2e/tests/index.e2e-teardown.ts | 2 +- 32 files changed, 87 insertions(+), 62 deletions(-) diff --git a/scripts/stack/_lib/utils/docker.js b/scripts/stack/_lib/utils/docker.js index a0bf38e..79b2e31 100644 --- a/scripts/stack/_lib/utils/docker.js +++ b/scripts/stack/_lib/utils/docker.js @@ -40,8 +40,9 @@ export function getDockerContainerHealthStatus(containerName) { .trim() ); } catch (e) { + const error = /** @type {Error} */ (e); throw new Error( - `Failed to get health status of ${containerName} container: ${e}`, + `Failed to get health status of ${containerName} container: ${error.message}`, ); } diff --git a/scripts/stack/local/all/api/down.js b/scripts/stack/local/all/api/down.js index 59a76ca..8222733 100755 --- a/scripts/stack/local/all/api/down.js +++ b/scripts/stack/local/all/api/down.js @@ -8,12 +8,14 @@ import { getPaths } from '../../../_lib/utils/paths.js'; import { MANDATORY_ENV_VARS } from '../_lib/constants.js'; import { DOCKER_COMPOSE_FILES, ENV_FILE } from './_lib/constants.js'; -main().catch((e) => { +try { + main(); +} catch (e) { console.error(e); process.exit(1); -}); +} -async function main() { +function main() { const scriptPath = /** @type {string} */ (process.argv[1]); const paths = getPaths(scriptPath, ENV_FILE); diff --git a/scripts/stack/local/all/e2e/down.js b/scripts/stack/local/all/e2e/down.js index 4a497ef..b64b028 100755 --- a/scripts/stack/local/all/e2e/down.js +++ b/scripts/stack/local/all/e2e/down.js @@ -8,12 +8,14 @@ import { getPaths } from '../../../_lib/utils/paths.js'; import { MANDATORY_ENV_VARS } from '../_lib/constants.js'; import { DOCKER_COMPOSE_FILES, ENV_FILE } from './_lib/constants.js'; -main().catch((e) => { +try { + main(); +} catch (e) { console.error(e); process.exit(1); -}); +} -async function main() { +function main() { const scriptPath = /** @type {string} */ (process.argv[1]); const paths = getPaths(scriptPath, ENV_FILE); diff --git a/scripts/stack/local/infra-app/playwright/down.js b/scripts/stack/local/infra-app/playwright/down.js index 6685c1e..3714683 100755 --- a/scripts/stack/local/infra-app/playwright/down.js +++ b/scripts/stack/local/infra-app/playwright/down.js @@ -8,12 +8,14 @@ import { getPaths } from '../../../_lib/utils/paths.js'; import { MANDATORY_ENV_VARS } from '../_lib/constants.js'; import { DOCKER_COMPOSE_FILES, ENV_FILE } from './_lib/constants.js'; -main().catch((e) => { +try { + main(); +} catch (e) { console.error(e); process.exit(1); -}); +} -async function main() { +function main() { const scriptPath = /** @type {string} */ (process.argv[1]); const paths = getPaths(scriptPath, ENV_FILE); diff --git a/scripts/stack/local/infra-app/stack-only/down.js b/scripts/stack/local/infra-app/stack-only/down.js index 40f14cc..65cedb9 100755 --- a/scripts/stack/local/infra-app/stack-only/down.js +++ b/scripts/stack/local/infra-app/stack-only/down.js @@ -8,12 +8,14 @@ import { getPaths } from '../../../_lib/utils/paths.js'; import { MANDATORY_ENV_VARS } from '../_lib/constants.js'; import { DOCKER_COMPOSE_FILES, ENV_FILE } from './_lib/constants.js'; -main().catch((e) => { +try { + main(); +} catch (e) { console.error(e); process.exit(1); -}); +} -async function main() { +function main() { const scriptPath = /** @type {string} */ (process.argv[1]); const paths = getPaths(scriptPath, ENV_FILE); diff --git a/scripts/stack/local/infra/playwright/down.js b/scripts/stack/local/infra/playwright/down.js index 0c87246..6816485 100755 --- a/scripts/stack/local/infra/playwright/down.js +++ b/scripts/stack/local/infra/playwright/down.js @@ -8,12 +8,14 @@ import { getPaths } from '../../../_lib/utils/paths.js'; import { DOCKER_COMPOSE_FILES, MANDATORY_ENV_VARS } from '../_lib/constants.js'; import { ENV_FILE } from './_lib/constants.js'; -main().catch((e) => { +try { + main(); +} catch (e) { console.error(e); process.exit(1); -}); +} -async function main() { +function main() { const scriptPath = /** @type {string} */ (process.argv[1]); const paths = getPaths(scriptPath, ENV_FILE); diff --git a/scripts/stack/local/infra/stack-only/app.js b/scripts/stack/local/infra/stack-only/app.js index a489be1..9b1eccc 100755 --- a/scripts/stack/local/infra/stack-only/app.js +++ b/scripts/stack/local/infra/stack-only/app.js @@ -8,12 +8,14 @@ import { getPaths } from '../../../_lib/utils/paths.js'; import { MANDATORY_ENV_VARS } from '../_lib/constants.js'; import { ENV_FILE } from './_lib/constants.js'; -main().catch((e) => { +try { + main(); +} catch (e) { console.error(e); process.exit(1); -}); +} -async function main() { +function main() { const scriptPath = /** @type {string} */ (process.argv[1]); const paths = getPaths(scriptPath, ENV_FILE); diff --git a/scripts/stack/local/infra/stack-only/down.js b/scripts/stack/local/infra/stack-only/down.js index 955469b..b7b8404 100755 --- a/scripts/stack/local/infra/stack-only/down.js +++ b/scripts/stack/local/infra/stack-only/down.js @@ -8,12 +8,14 @@ import { getPaths } from '../../../_lib/utils/paths.js'; import { DOCKER_COMPOSE_FILES, MANDATORY_ENV_VARS } from '../_lib/constants.js'; import { ENV_FILE } from './_lib/constants.js'; -main().catch((e) => { +try { + main(); +} catch (e) { console.error(e); process.exit(1); -}); +} -async function main() { +function main() { const scriptPath = /** @type {string} */ (process.argv[1]); const paths = getPaths(scriptPath, ENV_FILE); diff --git a/scripts/stack/local/infra/stack-only/migrate.js b/scripts/stack/local/infra/stack-only/migrate.js index a6a05c6..2a86d6e 100755 --- a/scripts/stack/local/infra/stack-only/migrate.js +++ b/scripts/stack/local/infra/stack-only/migrate.js @@ -8,12 +8,14 @@ import { getPaths } from '../../../_lib/utils/paths.js'; import { MANDATORY_ENV_VARS } from '../_lib/constants.js'; import { ENV_FILE } from './_lib/constants.js'; -main().catch((e) => { +try { + main(); +} catch (e) { console.error(e); process.exit(1); -}); +} -async function main() { +function main() { const scriptPath = /** @type {string} */ (process.argv[1]); const paths = getPaths(scriptPath, ENV_FILE); diff --git a/scripts/stack/local/infra/stack-only/seed.js b/scripts/stack/local/infra/stack-only/seed.js index dba659e..7a0c904 100755 --- a/scripts/stack/local/infra/stack-only/seed.js +++ b/scripts/stack/local/infra/stack-only/seed.js @@ -8,12 +8,14 @@ import { getPaths } from '../../../_lib/utils/paths.js'; import { MANDATORY_ENV_VARS } from '../_lib/constants.js'; import { ENV_FILE } from './_lib/constants.js'; -main().catch((e) => { +try { + main(); +} catch (e) { console.error(e); process.exit(1); -}); +} -async function main() { +function main() { const scriptPath = /** @type {string} */ (process.argv[1]); const paths = getPaths(scriptPath, ENV_FILE); diff --git a/src/hooks.client.ts b/src/hooks.client.ts index e271ca3..078c120 100644 --- a/src/hooks.client.ts +++ b/src/hooks.client.ts @@ -27,7 +27,7 @@ setClientPosthogSessionId(); logger.info('Starting the app client...'); -export const handleError = handleErrorWithSentry((async ({ error }) => { +export const handleError = handleErrorWithSentry((({ error }) => { const message = 'Internal Client Error'; if (dev) { console.error(message, error); diff --git a/src/hooks.server.ts b/src/hooks.server.ts index 20f8b5b..8d298c7 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -54,7 +54,7 @@ export const handle = (async (input) => { return sequence(...nonMaintenanceModeHandles)(input); }) satisfies Handle; -export const handleError = handleErrorWithSentry((async ({ error }) => { +export const handleError = handleErrorWithSentry((({ error }) => { const message = 'Internal Server Error'; console.error(message, error); @@ -64,6 +64,7 @@ export const handleError = handleErrorWithSentry((async ({ error }) => { }; }) satisfies HandleServerError); +// eslint-disable-next-line @typescript-eslint/no-misused-promises process.on('SIGINT', async () => { console.info( 'Got SIGINT (e.g. `Ctrl+C`). Graceful shutdown ', @@ -71,6 +72,7 @@ process.on('SIGINT', async () => { ); await shutdownGracefully(); }); +// eslint-disable-next-line @typescript-eslint/no-misused-promises process.on('SIGTERM', async () => { console.info( 'Got SIGTERM (e.g. `docker container stop`). Graceful shutdown ', diff --git a/src/lib/client/posthog/posthog-default-page-events-capture.configurator.ts b/src/lib/client/posthog/posthog-default-page-events-capture.configurator.ts index 8068400..e0bce87 100644 --- a/src/lib/client/posthog/posthog-default-page-events-capture.configurator.ts +++ b/src/lib/client/posthog/posthog-default-page-events-capture.configurator.ts @@ -80,7 +80,7 @@ export class _PosthogDefaultPageEventsCaptureConfigurator { // WARN: Navigation after `popstate` event happens before this runs, so // page leave event is captured for the destination page, not the source // one. No solution for now (`beforeNavigate` also did not help). - if ($navigating && $navigating.willUnload === false) { + if ($navigating && !$navigating.willUnload) { this.capturePageLeaveEvent(_PageEventTrigger.BEFORE_NAVIGATE); return; } diff --git a/src/lib/client/sentry/utils/index.ts b/src/lib/client/sentry/utils/index.ts index 274588f..f9b5f20 100644 --- a/src/lib/client/sentry/utils/index.ts +++ b/src/lib/client/sentry/utils/index.ts @@ -19,6 +19,6 @@ export function getClientSentryIntegrations( export function setClientPosthogSessionId(): void { if (posthog) { - sentry?.setTag(POSTHOG_SESSION_ID_TAG, getSessionId()!); + sentry?.setTag(POSTHOG_SESSION_ID_TAG, getSessionId()); } } diff --git a/src/lib/client/skeleton/utils/setup.utils.ts b/src/lib/client/skeleton/utils/setup.utils.ts index 51271e0..6af9a30 100644 --- a/src/lib/client/skeleton/utils/setup.utils.ts +++ b/src/lib/client/skeleton/utils/setup.utils.ts @@ -23,7 +23,7 @@ export function setupSkeletonPopup() { computePosition, autoUpdate, offset, - // @ts-ignore + // @ts-expect-error shift, flip, arrow, diff --git a/src/lib/server/code-snippets/services/code-snippets.service.ts b/src/lib/server/code-snippets/services/code-snippets.service.ts index 56c64b4..9369540 100644 --- a/src/lib/server/code-snippets/services/code-snippets.service.ts +++ b/src/lib/server/code-snippets/services/code-snippets.service.ts @@ -32,7 +32,7 @@ export class CodeSnippetsService { where: { is_deleted: false, ...(query?.filterBy === 'author' && - query?.filterValue && { user_id: query?.filterValue }), + query.filterValue && { user_id: query.filterValue }), }, }); @@ -44,7 +44,7 @@ export class CodeSnippetsService { ): Promise { const itemCount = await this.getTotalItemCountByQuery(query); let pageCount = 1; - if (query?.count != null && query?.count> 0) { + if (query?.count != null && query.count> 0) { pageCount = Math.ceil(itemCount / query.count); } @@ -53,26 +53,26 @@ export class CodeSnippetsService { async findManyByQuery(query?: FindCodeSnippetsQuery): Promise { let skip: number | undefined; - if (query?.page != null && query?.page> 1 && query?.count != null) { + if (query?.page != null && query.page> 1 && query.count != null) { skip = (query.page - 1) * query.count; } let take: number | undefined; if (query?.count != null) { - take = query?.count; + take = query.count; } const codeSnippets = await prisma.codeSnippet.findMany({ where: { is_deleted: false, ...(query?.filterBy === 'author' && - query?.filterValue && { user_id: query?.filterValue }), + query.filterValue && { user_id: query.filterValue }), }, ...(skip && { skip }), ...(take && { take }), ...(query?.sortBy && { orderBy: { - [query?.sortBy]: query?.sortOrder || 'asc', + [query.sortBy]: query.sortOrder || 'asc', }, }), }); diff --git a/src/lib/server/lucia/hooks/add-auth-data-to-local.handle.node-test.ts b/src/lib/server/lucia/hooks/add-auth-data-to-local.handle.node-test.ts index 231c400..5f9e4fd 100644 --- a/src/lib/server/lucia/hooks/add-auth-data-to-local.handle.node-test.ts +++ b/src/lib/server/lucia/hooks/add-auth-data-to-local.handle.node-test.ts @@ -5,6 +5,7 @@ import type * as utilsModule from '../utils'; import { addAuthDataToLocalHandle } from './add-auth-data-to-local.handle'; vi.mock('../client', async () => { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion const actual = (await vi.importActual('../client')) as typeof clientModule; return { ...actual, @@ -15,6 +16,7 @@ vi.mock('../client', async () => { }); vi.mock('../utils', async () => { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion const actual = (await vi.importActual('../utils')) as typeof utilsModule; return { ...actual, diff --git a/src/lib/server/lucia/oauth/google/utils/sign-in.utils.ts b/src/lib/server/lucia/oauth/google/utils/sign-in.utils.ts index a45e892..1aaebfb 100644 --- a/src/lib/server/lucia/oauth/google/utils/sign-in.utils.ts +++ b/src/lib/server/lucia/oauth/google/utils/sign-in.utils.ts @@ -190,7 +190,7 @@ async function performOAuthAccountLinking( } async function verifyEmail(databaseUser: PrismaUser): Promise { - if (databaseUser.email_verified === true) { + if (databaseUser.email_verified) { return; } diff --git a/src/lib/server/posthog/client.ts b/src/lib/server/posthog/client.ts index ac545f7..92c4f5a 100644 --- a/src/lib/server/posthog/client.ts +++ b/src/lib/server/posthog/client.ts @@ -21,7 +21,7 @@ export function setupNodePosthogClient( } function getNodePosthogClient(projectApiKey: string, apiHost: string): PostHog { - return new PostHog(projectApiKey!, { - host: apiHost!, + return new PostHog(projectApiKey, { + host: apiHost, }); } diff --git a/src/lib/server/superforms/testing/index.ts b/src/lib/server/superforms/testing/index.ts index a2620c9..67c7c81 100644 --- a/src/lib/server/superforms/testing/index.ts +++ b/src/lib/server/superforms/testing/index.ts @@ -6,7 +6,7 @@ export function getMockFormData( Object.entries(data).forEach(([key, value]) => { formData.append(key, value); }); - const formDataFn = async () => formData; + const formDataFn = () => Promise.resolve(formData); return formDataFn; } diff --git a/src/lib/shared/sentry/client.node-test.ts b/src/lib/shared/sentry/client.node-test.ts index 0b72eb1..499983a 100644 --- a/src/lib/shared/sentry/client.node-test.ts +++ b/src/lib/shared/sentry/client.node-test.ts @@ -37,7 +37,7 @@ describe(setupSentryClient.name, () => { }); it('should configure the client', async () => { - await setupSentryClient({ + setupSentryClient({ dsn: 'mock-dsn', environment: 'localhost', origin: 'http://localhost:3000', @@ -54,7 +54,7 @@ describe(setupSentryClient.name, () => { }); it('should not configure the client if its already configured', async () => { - await setupSentryClient({ + setupSentryClient({ dsn: 'mock-dsn', environment: 'localhost', origin: 'http://localhost:3000', @@ -62,7 +62,7 @@ describe(setupSentryClient.name, () => { // Reset the spy to check if it's called again vi.clearAllMocks(); - await setupSentryClient({ + setupSentryClient({ dsn: 'mock-dsn', environment: 'localhost', origin: 'http://localhost:3000', @@ -72,7 +72,7 @@ describe(setupSentryClient.name, () => { }); it('should fail configuration of the client if configuration inputs are invalid', async () => { - await setupSentryClient({ + setupSentryClient({ dsn: undefined, environment: undefined, origin: 'http://localhost:3000', @@ -90,7 +90,7 @@ describe(checkIfSentryClientConfigured.name, () => { }); it('should not throw an error if client is configured', async () => { - await setupSentryClient({ + setupSentryClient({ dsn: 'mock-dsn', environment: 'localhost', origin: 'http://localhost:3000', diff --git a/src/lib/shared/sveltekit/testing/test-helpers.ts b/src/lib/shared/sveltekit/testing/test-helpers.ts index 12d0da5..9720440 100644 --- a/src/lib/shared/sveltekit/testing/test-helpers.ts +++ b/src/lib/shared/sveltekit/testing/test-helpers.ts @@ -101,7 +101,7 @@ export class SveltekitDefaultMocks { const updated = { subscribe: readable(false).subscribe, - check: async () => false, + check: () => Promise.resolve(false), }; return { navigating, page, updated }; @@ -123,7 +123,7 @@ export class SveltekitDefaultMocks { subscribe(fn) { return getStores().updated.subscribe(fn); }, - check: async () => false, + check: () => Promise.resolve(false), }; return { diff --git a/src/routes/(app)/(card-layout)/code-snippets/[id]/+page.server.ts b/src/routes/(app)/(card-layout)/code-snippets/[id]/+page.server.ts index 050c2c5..4c47927 100644 --- a/src/routes/(app)/(card-layout)/code-snippets/[id]/+page.server.ts +++ b/src/routes/(app)/(card-layout)/code-snippets/[id]/+page.server.ts @@ -53,7 +53,8 @@ export const actions = { authUser, form, ); - if ((result as unknown as ActionFailure)?.status>= 400) { + const possibleActionFailure = result as unknown as ActionFailure; + if (possibleActionFailure.status && possibleActionFailure.status>= 400) { return result; } diff --git a/src/routes/(app)/+page.server.ts b/src/routes/(app)/+page.server.ts index 3822b66..7b25f34 100644 --- a/src/routes/(app)/+page.server.ts +++ b/src/routes/(app)/+page.server.ts @@ -54,7 +54,8 @@ export const actions = { authUser, form, ); - if ((result as unknown as ActionFailure)?.status>= 400) { + const possibleActionFailure = result as unknown as ActionFailure; + if (possibleActionFailure.status && possibleActionFailure.status>= 400) { return result; } diff --git a/src/routes/(app)/page.server.module.ts b/src/routes/(app)/page.server.module.ts index 89caf61..a856651 100644 --- a/src/routes/(app)/page.server.module.ts +++ b/src/routes/(app)/page.server.module.ts @@ -46,7 +46,7 @@ export function cleanSearchParamsAndGenerateQuery( const sortOrder = (searchParams.get('sortOrder') as | FindCodeSnippetsQuery['sortOrder'] - | null) || 'asc'; + | null) ?? 'asc'; // Set query const findCodeSnippetsQuery = { @@ -55,7 +55,7 @@ export function cleanSearchParamsAndGenerateQuery( ...(filterBy != null && { filterBy }), ...(filterValue != null && { filterValue }), sortBy, - ...(sortOrder != null && { sortOrder }), + sortOrder, }; // Validate query diff --git a/src/routes/+layout.server.ts b/src/routes/+layout.server.ts index e4aca68..29e898f 100644 --- a/src/routes/+layout.server.ts +++ b/src/routes/+layout.server.ts @@ -1,6 +1,6 @@ import { loadFlash } from 'sveltekit-flash-message/server'; -export const load = loadFlash(async ({ locals }) => { +export const load = loadFlash(({ locals }) => { // NOTE: Used only for the sibling `+error.svelte` that calls // `invalidateAll`. ALWAYS add this auth block to each nested page that // is accessible to unauthenticated users, but may conditionally display diff --git a/src/routes/api/healthcheck/+server.ts b/src/routes/api/healthcheck/+server.ts index a9c716c..051c4ad 100644 --- a/src/routes/api/healthcheck/+server.ts +++ b/src/routes/api/healthcheck/+server.ts @@ -4,7 +4,7 @@ import { config } from '$lib/server/core/config'; import type { RequestHandler } from './$types'; -export const GET = (async () => { +export const GET = (() => { let status = 'OK'; if (config.isMaintenanceMode) { status = 'maintenance'; diff --git a/src/routes/api/healthcheck/server.node-test.ts b/src/routes/api/healthcheck/server.node-test.ts index 97b8a57..f906341 100644 --- a/src/routes/api/healthcheck/server.node-test.ts +++ b/src/routes/api/healthcheck/server.node-test.ts @@ -16,7 +16,7 @@ describe(GET.name, () => { typeof libServerCoreConfigModule.config > as typeof libServerCoreConfigModule.config); - const response = await GET(); + const response = GET(); expect(await response.json()).toEqual({ status: 'OK', @@ -30,7 +30,7 @@ describe(GET.name, () => { typeof libServerCoreConfigModule.config > as typeof libServerCoreConfigModule.config); - const response = await GET(); + const response = GET(); expect(await response.json()).toEqual({ status: 'maintenance', diff --git a/src/routes/maintenance/+page.server.ts b/src/routes/maintenance/+page.server.ts index 88f8e7c..0e61fcf 100644 --- a/src/routes/maintenance/+page.server.ts +++ b/src/routes/maintenance/+page.server.ts @@ -5,7 +5,7 @@ import { decodeOriginalPath } from '$lib/shared/core/utils'; import type { PageServerLoad } from './$types'; -export const load = (async ({ url, setHeaders }) => { +export const load = (({ url, setHeaders }) => { if (config.isMaintenanceMode) { setHeaders({ 'Retry-After': '600', diff --git a/tailwind.config.ts b/tailwind.config.ts index cfd28e8..3be1342 100644 --- a/tailwind.config.ts +++ b/tailwind.config.ts @@ -17,7 +17,7 @@ const config = { plugins: [ forms, typography, - // @ts-ignore + // @ts-expect-error skeleton({ themes: { preset: [{ name: 'wintry', enhancements: true }] }, }), diff --git a/tests/playwright/api/tests/index.api-teardown.ts b/tests/playwright/api/tests/index.api-teardown.ts index c2c0821..4c0415e 100644 --- a/tests/playwright/api/tests/index.api-teardown.ts +++ b/tests/playwright/api/tests/index.api-teardown.ts @@ -1,5 +1,5 @@ import { test as teardown } from '@playwright/test'; -teardown('teardown API', async () => { +teardown('teardown API', () => { console.log('API teardown complete'); }); diff --git a/tests/playwright/e2e/tests/index.e2e-teardown.ts b/tests/playwright/e2e/tests/index.e2e-teardown.ts index 5567fa6..9f3b11a 100644 --- a/tests/playwright/e2e/tests/index.e2e-teardown.ts +++ b/tests/playwright/e2e/tests/index.e2e-teardown.ts @@ -1,5 +1,5 @@ import { test as teardown } from '@playwright/test'; -teardown('teardown E2E', async () => { +teardown('teardown E2E', () => { console.log('E2E teardown complete'); }); From ce5a6e89762ed54c3215c54565a676eac7cc966b Mon Sep 17 00:00:00 2001 From: nodeexx <156369338+nodeexx@users.noreply.github.com> Date: 2024年3月25日 11:38:14 +0100 Subject: [PATCH 25/29] Fix tests and last minor linting errors --- src/lib/client/logging/client.ts | 6 +----- src/routes/maintenance/page.server.node-test.ts | 6 +++--- src/routes/sign-in/page.server.node-test.ts | 4 ++-- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/lib/client/logging/client.ts b/src/lib/client/logging/client.ts index abaeef6..beb1be4 100644 --- a/src/lib/client/logging/client.ts +++ b/src/lib/client/logging/client.ts @@ -15,11 +15,7 @@ import { export const logger = (function () { const createLogger = (methodName: LogLevelName) => { - return ( - message: string, - context: LoggerContext = {}, - stackLevel = 3, - ) => { + return (message: string, context: LoggerContext = {}, stackLevel = 3) => { if (!shouldBeLogged(methodName)) { return; } diff --git a/src/routes/maintenance/page.server.node-test.ts b/src/routes/maintenance/page.server.node-test.ts index 1691410..aeca3c0 100644 --- a/src/routes/maintenance/page.server.node-test.ts +++ b/src/routes/maintenance/page.server.node-test.ts @@ -23,7 +23,7 @@ describe(load.name, () => { url: new URL('http://localhost/maintenance'), setHeaders, } as Partial as PageServerLoadEvent; - await expect(load(event)).rejects.toThrow(); + expect(() => load(event)).toThrow(); expect(setHeaders).toHaveBeenCalledTimes(1); expect(setHeaders).toHaveBeenCalledWith({ @@ -46,7 +46,7 @@ describe(load.name, () => { ), setHeaders, } as Partial as PageServerLoadEvent; - await expect(load(event)).rejects.toThrow(); + expect(() => load(event)).toThrow(); expect(redirectSpy).toHaveBeenCalledTimes(1); expect(redirectSpy).toHaveBeenCalledWith(307, '/auth'); @@ -63,7 +63,7 @@ describe(load.name, () => { url: new URL('http://localhost/maintenance'), setHeaders, } as Partial as PageServerLoadEvent; - await expect(load(event)).rejects.toThrow(); + expect(() => load(event)).toThrow(); expect(redirectSpy).toHaveBeenCalledTimes(1); expect(redirectSpy).toHaveBeenCalledWith(307, '/'); diff --git a/src/routes/sign-in/page.server.node-test.ts b/src/routes/sign-in/page.server.node-test.ts index 68e874a..acaece6 100644 --- a/src/routes/sign-in/page.server.node-test.ts +++ b/src/routes/sign-in/page.server.node-test.ts @@ -264,7 +264,7 @@ describe('actions', () => { libServerLuciaOauthGoogleModule, 'GOOGLE_OAUTH_STATE_COOKIE_NAME', 'get', - ).mockReturnValue('mock-state-cookie-name'); + ).mockReturnValue('mock-state-cookie-name' as any); const redirectSpy = vi.spyOn(sveltejsKitModule, 'redirect'); await expect(actions['google-auth'](mockEvent)).rejects.toThrow(); @@ -313,7 +313,7 @@ describe('actions', () => { libServerLuciaOauthGoogleModule, 'GOOGLE_OAUTH_STATE_COOKIE_NAME', 'get', - ).mockReturnValue('mock-state-cookie-name'); + ).mockReturnValue('mock-state-cookie-name' as any); const redirectSpy = vi.spyOn(sveltejsKitModule, 'redirect'); await expect(actions['google-auth'](mockEvent)).rejects.toThrow(); From f267ecf2e13a9a4d43d533aef9a5122e762b949b Mon Sep 17 00:00:00 2001 From: nodeexx <156369338+nodeexx@users.noreply.github.com> Date: 2024年3月25日 11:48:47 +0100 Subject: [PATCH 26/29] Make minor ESLint config improvements --- .eslintrc.cjs | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 8a217f6..486a137 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -24,33 +24,35 @@ module.exports = { 'no-unused-vars': 'off', // Useful for triggering Svelte reactivity 'no-self-assign': 'off', + /* eslint-plugin-simple-import-sort */ 'simple-import-sort/imports': 'error', 'simple-import-sort/exports': 'error', - '@typescript-eslint/no-unused-vars': [ - 'error', - { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }, - ], - '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/no-non-null-assertion': 'off', - '@typescript-eslint/no-empty-function': 'off', - '@typescript-eslint/no-floating-promises': 'error', + /* @typescript-eslint/eslint-plugin */ '@typescript-eslint/ban-ts-comment': 'off', - '@typescript-eslint/interface-name-prefix': 'off', + '@typescript-eslint/consistent-indexed-object-style': 'off', '@typescript-eslint/explicit-function-return-type': 'off', '@typescript-eslint/explicit-module-boundary-types': 'off', + '@typescript-eslint/interface-name-prefix': 'off', + '@typescript-eslint/no-confusing-void-expression': 'off', + '@typescript-eslint/no-empty-function': 'off', + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/no-extraneous-class': 'off', + '@typescript-eslint/no-floating-promises': 'error', '@typescript-eslint/no-namespace': 'off', - '@typescript-eslint/consistent-indexed-object-style': 'off', - '@typescript-eslint/prefer-nullish-coalescing': 'off', - '@typescript-eslint/no-unsafe-member-access': 'off', - '@typescript-eslint/no-unsafe-argument': 'off', - '@typescript-eslint/no-unsafe-assignment': 'off', + '@typescript-eslint/no-non-null-assertion': 'off', '@typescript-eslint/no-throw-literal': 'off', - '@typescript-eslint/unbound-method': 'off', + '@typescript-eslint/no-unnecessary-condition': 'off', '@typescript-eslint/no-unnecessary-type-arguments': 'off', + '@typescript-eslint/no-unsafe-argument': 'off', + '@typescript-eslint/no-unsafe-assignment': 'off', + '@typescript-eslint/no-unsafe-member-access': 'off', + '@typescript-eslint/no-unused-vars': [ + 'error', + { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }, + ], + '@typescript-eslint/prefer-nullish-coalescing': 'off', '@typescript-eslint/prefer-reduce-type-parameter': 'off', - '@typescript-eslint/no-confusing-void-expression': 'off', - '@typescript-eslint/no-unnecessary-condition': 'off', - '@typescript-eslint/no-extraneous-class': 'off', + '@typescript-eslint/unbound-method': 'off', }, overrides: [ { From d828c973a198bde0056aebcf6ddf43ec4ea2d919 Mon Sep 17 00:00:00 2001 From: nodeexx <156369338+nodeexx@users.noreply.github.com> Date: 2024年3月25日 12:04:10 +0100 Subject: [PATCH 27/29] Fix unit test linting --- .eslintrc.cjs | 11 +++++++++-- .../CodeSnippetCreateEditForm.svelte.dom-test.ts | 4 ++-- .../(app)/(card-layout)/layout.svelte.dom-test.ts | 2 +- src/routes/(app)/layout.svelte.dom-test.ts | 2 +- src/routes/layout.svelte.dom-test.ts | 2 +- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 486a137..c3ec036 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -85,12 +85,19 @@ module.exports = { }, }, { - // No `.spec.{js,ts}` files, because those are for server unit tests - files: ['src/**/*.{test,browser-test}.{js,ts}'], + files: ['src/**/*.node-test.{js,ts}'], + extends: ['plugin:jest-dom/recommended'], + rules: { + 'jest-dom/prefer-in-document': 'off', + }, + }, + { + files: ['src/**/*.dom-test.{js,ts}'], plugins: ['testing-library'], extends: ['plugin:testing-library/dom', 'plugin:jest-dom/recommended'], rules: { 'jest-dom/prefer-in-document': 'off', + 'testing-library/prefer-presence-queries': 'off', 'testing-library/prefer-screen-queries': 'off', }, }, diff --git a/src/lib/client/components/code-snippets/CodeSnippetCreateEditForm.svelte.dom-test.ts b/src/lib/client/components/code-snippets/CodeSnippetCreateEditForm.svelte.dom-test.ts index c4c6f4c..6f190bd 100644 --- a/src/lib/client/components/code-snippets/CodeSnippetCreateEditForm.svelte.dom-test.ts +++ b/src/lib/client/components/code-snippets/CodeSnippetCreateEditForm.svelte.dom-test.ts @@ -59,11 +59,11 @@ describe(Component.name, () => { }); expect(renderResult.getByTestId('name-error-message')).toBeVisible(); - expect(renderResult.getByTestId('name-error-message').textContent).toEqual( + expect(renderResult.getByTestId('name-error-message')).toHaveTextContent( 'Name is required', ); expect(renderResult.getByTestId('code-error-message')).toBeVisible(); - expect(renderResult.getByTestId('code-error-message').textContent).toEqual( + expect(renderResult.getByTestId('code-error-message')).toHaveTextContent( 'Code is required', ); }); diff --git a/src/routes/(app)/(card-layout)/layout.svelte.dom-test.ts b/src/routes/(app)/(card-layout)/layout.svelte.dom-test.ts index 972e5e3..780fab6 100644 --- a/src/routes/(app)/(card-layout)/layout.svelte.dom-test.ts +++ b/src/routes/(app)/(card-layout)/layout.svelte.dom-test.ts @@ -19,7 +19,7 @@ describe(Component.name, () => { it('should render slot content', () => { const renderResult = render(SlotTest, { props: { component: Component } }); - expect(renderResult.getByTestId('slot-content').textContent).toBe( + expect(renderResult.getByTestId('slot-content')).toHaveTextContent( 'mock-slot-text', ); }); diff --git a/src/routes/(app)/layout.svelte.dom-test.ts b/src/routes/(app)/layout.svelte.dom-test.ts index 972e5e3..780fab6 100644 --- a/src/routes/(app)/layout.svelte.dom-test.ts +++ b/src/routes/(app)/layout.svelte.dom-test.ts @@ -19,7 +19,7 @@ describe(Component.name, () => { it('should render slot content', () => { const renderResult = render(SlotTest, { props: { component: Component } }); - expect(renderResult.getByTestId('slot-content').textContent).toBe( + expect(renderResult.getByTestId('slot-content')).toHaveTextContent( 'mock-slot-text', ); }); diff --git a/src/routes/layout.svelte.dom-test.ts b/src/routes/layout.svelte.dom-test.ts index 684b045..3eb0302 100644 --- a/src/routes/layout.svelte.dom-test.ts +++ b/src/routes/layout.svelte.dom-test.ts @@ -45,7 +45,7 @@ describe(Component.name, () => { it('should render slot content', () => { const renderResult = render(SlotTest, { props: { component: Component } }); - expect(renderResult.getByTestId('slot-content').textContent).toBe( + expect(renderResult.getByTestId('slot-content')).toHaveTextContent( 'mock-slot-text', ); }); From 8094646fe0f81496197afce7bb7c3ddb9a35c063 Mon Sep 17 00:00:00 2001 From: nodeexx <156369338+nodeexx@users.noreply.github.com> Date: 2024年3月25日 12:19:27 +0100 Subject: [PATCH 28/29] Setup ESLint rules for Playwright tests and fix related issues --- .eslintrc.cjs | 7 ++++++ package-lock.json | 22 +++++++++++++++++++ package.json | 1 + tests/playwright/api/tests/index.api-setup.ts | 4 ++++ .../sign-out.api-test.ts | 12 ++-------- .../code-snippets/create.api-test.ts | 6 +---- .../code-snippets/delete.api-test.ts | 6 +---- .../code-snippets/edit.api-test.ts | 6 +---- .../api/tests/visitor/sign-in.api-test.ts | 6 +---- .../sign-out.e2e-test.ts | 4 ++-- .../e2e/tests/visitor/sign-in.e2e-test.ts | 2 +- 11 files changed, 43 insertions(+), 33 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index c3ec036..01f0886 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -101,5 +101,12 @@ module.exports = { 'testing-library/prefer-screen-queries': 'off', }, }, + { + files: ['tests/playwright/**/*.{api-test,e2e-test}.{js,ts}'], + extends: ['plugin:playwright/recommended'], + rules: { + 'playwright/expect-expect': 'off', + }, + }, ], }; diff --git a/package-lock.json b/package-lock.json index 43dea08..093fcac 100644 --- a/package-lock.json +++ b/package-lock.json @@ -58,6 +58,7 @@ "eslint": "8.53.0", "eslint-config-prettier": "9.0.0", "eslint-plugin-jest-dom": "5.1.0", + "eslint-plugin-playwright": "1.5.4", "eslint-plugin-simple-import-sort": "12.0.0", "eslint-plugin-svelte": "2.34.1", "eslint-plugin-testing-library": "6.1.0", @@ -6969,6 +6970,27 @@ } } }, + "node_modules/eslint-plugin-playwright": { + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/eslint-plugin-playwright/-/eslint-plugin-playwright-1.5.4.tgz", + "integrity": "sha512-J38Wy3Vc2f9y73J+KRmgXgbYI8TZ3zbz6qBbTj3PhpFndUS572jZ7kqQ3rJ9si5BaMHT7lmZzraO+3UjwIDV4Q==", + "dev": true, + "dependencies": { + "globals": "^13.23.0" + }, + "engines": { + "node": ">=16.6.0" + }, + "peerDependencies": { + "eslint": ">=8.40.0", + "eslint-plugin-jest": ">=25" + }, + "peerDependenciesMeta": { + "eslint-plugin-jest": { + "optional": true + } + } + }, "node_modules/eslint-plugin-simple-import-sort": { "version": "12.0.0", "resolved": "https://registry.npmjs.org/eslint-plugin-simple-import-sort/-/eslint-plugin-simple-import-sort-12.0.0.tgz", diff --git a/package.json b/package.json index 738bcf2..16f501e 100644 --- a/package.json +++ b/package.json @@ -105,6 +105,7 @@ "eslint": "8.53.0", "eslint-config-prettier": "9.0.0", "eslint-plugin-jest-dom": "5.1.0", + "eslint-plugin-playwright": "1.5.4", "eslint-plugin-simple-import-sort": "12.0.0", "eslint-plugin-svelte": "2.34.1", "eslint-plugin-testing-library": "6.1.0", diff --git a/tests/playwright/api/tests/index.api-setup.ts b/tests/playwright/api/tests/index.api-setup.ts index 6a4f0d9..a96aa2a 100644 --- a/tests/playwright/api/tests/index.api-setup.ts +++ b/tests/playwright/api/tests/index.api-setup.ts @@ -10,6 +10,10 @@ import { } from '../../common/lib/setup'; setup('setup API', async ({ page, baseURL }) => { + if (!baseURL) { + throw new Error('Base URL is not set'); + } + seedDb(); await saveVisitorRoleState(page); diff --git a/tests/playwright/api/tests/signed-in-user--before-sign-out/sign-out.api-test.ts b/tests/playwright/api/tests/signed-in-user--before-sign-out/sign-out.api-test.ts index ff81e84..b334a05 100644 --- a/tests/playwright/api/tests/signed-in-user--before-sign-out/sign-out.api-test.ts +++ b/tests/playwright/api/tests/signed-in-user--before-sign-out/sign-out.api-test.ts @@ -8,10 +8,6 @@ test.describe('POST /profile?/sign-out', () => { page, baseURL, }) => { - if (!baseURL) { - throw new Error('Base URL is not set'); - } - const homePage = new HomePage(page); await homePage.doNavigateTo(); @@ -20,7 +16,7 @@ test.describe('POST /profile?/sign-out', () => { const response = await page.request.post('/profile?/sign-out', { headers: { // Needed to pass CSRF check - origin: baseURL, + origin: baseURL!, }, form: {}, }); @@ -35,15 +31,11 @@ test.describe('POST /profile?/sign-out', () => { }); test('returns 401 if user is not logged in', async ({ page, baseURL }) => { - if (!baseURL) { - throw new Error('Base URL is not set'); - } - await page.context().clearCookies(); const response = await page.request.post('/profile?/sign-out', { headers: { // Needed to pass CSRF check - origin: baseURL, + origin: baseURL!, }, form: {}, }); diff --git a/tests/playwright/api/tests/signed-in-user/code-snippets/create.api-test.ts b/tests/playwright/api/tests/signed-in-user/code-snippets/create.api-test.ts index cb7672d..5826f0c 100644 --- a/tests/playwright/api/tests/signed-in-user/code-snippets/create.api-test.ts +++ b/tests/playwright/api/tests/signed-in-user/code-snippets/create.api-test.ts @@ -10,17 +10,13 @@ test.describe('POST /code-snippets/create?/create', () => { page, baseURL, }) => { - if (!baseURL) { - throw new Error('Base URL is not set'); - } - const homePage = new HomePage(page); await homePage.doNavigateTo(); const response = await page.request.post('/code-snippets/create?/create', { headers: { // Needed to pass CSRF check - origin: baseURL, + origin: baseURL!, }, multipart: { name: CODE_SNIPPET.name, diff --git a/tests/playwright/api/tests/signed-in-user/code-snippets/delete.api-test.ts b/tests/playwright/api/tests/signed-in-user/code-snippets/delete.api-test.ts index cbc7817..81f1993 100644 --- a/tests/playwright/api/tests/signed-in-user/code-snippets/delete.api-test.ts +++ b/tests/playwright/api/tests/signed-in-user/code-snippets/delete.api-test.ts @@ -10,10 +10,6 @@ test.describe('POST /code-snippets/:id?/delete', () => { page, baseURL, }) => { - if (!baseURL) { - throw new Error('Base URL is not set'); - } - const homePage = new HomePage(page); await homePage.doNavigateTo(); @@ -22,7 +18,7 @@ test.describe('POST /code-snippets/:id?/delete', () => { { headers: { // Needed to pass CSRF check - origin: baseURL, + origin: baseURL!, }, multipart: {}, }, diff --git a/tests/playwright/api/tests/signed-in-user/code-snippets/edit.api-test.ts b/tests/playwright/api/tests/signed-in-user/code-snippets/edit.api-test.ts index 503e053..ce24d2e 100644 --- a/tests/playwright/api/tests/signed-in-user/code-snippets/edit.api-test.ts +++ b/tests/playwright/api/tests/signed-in-user/code-snippets/edit.api-test.ts @@ -10,10 +10,6 @@ test.describe('POST /code-snippets/:id/edit?/edit', () => { page, baseURL, }) => { - if (!baseURL) { - throw new Error('Base URL is not set'); - } - const homePage = new HomePage(page); await homePage.doNavigateTo(); @@ -22,7 +18,7 @@ test.describe('POST /code-snippets/:id/edit?/edit', () => { { headers: { // Needed to pass CSRF check - origin: baseURL, + origin: baseURL!, }, multipart: { name: CODE_SNIPPET.newName, diff --git a/tests/playwright/api/tests/visitor/sign-in.api-test.ts b/tests/playwright/api/tests/visitor/sign-in.api-test.ts index 5f6040b..d43f0c7 100644 --- a/tests/playwright/api/tests/visitor/sign-in.api-test.ts +++ b/tests/playwright/api/tests/visitor/sign-in.api-test.ts @@ -5,14 +5,10 @@ test.describe('POST /sign-in?/google-auth', () => { request, baseURL, }, testInfo) => { - if (!baseURL) { - throw new Error('Base URL is not set'); - } - const response = await request.post('/sign-in?/google-auth', { headers: { // Needed to pass CSRF check - origin: baseURL, + origin: baseURL!, }, form: {}, }); diff --git a/tests/playwright/e2e/tests/signed-in-user--before-sign-out/sign-out.e2e-test.ts b/tests/playwright/e2e/tests/signed-in-user--before-sign-out/sign-out.e2e-test.ts index dcd11ea..befb2d0 100644 --- a/tests/playwright/e2e/tests/signed-in-user--before-sign-out/sign-out.e2e-test.ts +++ b/tests/playwright/e2e/tests/signed-in-user--before-sign-out/sign-out.e2e-test.ts @@ -12,7 +12,7 @@ test.describe('Feature: Sign out', () => { await expect( homePage.componentNavigationBar.getSignInButton(), - ).not.toBeVisible(); + ).toBeHidden(); await expect( homePage.componentNavigationBar.getProfileButton(), ).toBeVisible(); @@ -29,6 +29,6 @@ test.describe('Feature: Sign out', () => { ).toBeVisible(); await expect( homePage.componentNavigationBar.getProfileButton(), - ).not.toBeVisible(); + ).toBeHidden(); }); }); diff --git a/tests/playwright/e2e/tests/visitor/sign-in.e2e-test.ts b/tests/playwright/e2e/tests/visitor/sign-in.e2e-test.ts index 03ac735..89c738c 100644 --- a/tests/playwright/e2e/tests/visitor/sign-in.e2e-test.ts +++ b/tests/playwright/e2e/tests/visitor/sign-in.e2e-test.ts @@ -14,7 +14,7 @@ test.describe('Feature: Sign in/Sign up via Google', () => { ).toBeVisible(); await expect( homePage.componentNavigationBar.getProfileButton(), - ).not.toBeVisible(); + ).toBeHidden(); await homePage.componentNavigationBar.doClickSignInButton(); From a7d68b01540e2a0f90f68c9c82bcf363a2506381 Mon Sep 17 00:00:00 2001 From: nodeexx <156369338+nodeexx@users.noreply.github.com> Date: 2024年3月25日 12:34:30 +0100 Subject: [PATCH 29/29] Set automatic import update when moving JS/TS files --- .vscode/settings.template.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.vscode/settings.template.json b/.vscode/settings.template.json index d6cc4c8..6449ff3 100644 --- a/.vscode/settings.template.json +++ b/.vscode/settings.template.json @@ -21,6 +21,8 @@ "debug.javascript.terminalOptions": { "skipFiles": ["/**"] }, + "javascript.updateImportsOnFileMove.enabled": "always", + "typescript.updateImportsOnFileMove.enabled": "always", "[javascript]": { "editor.defaultFormatter": "esbenp.prettier-vscode" // Identation settings -> .editorconfig

AltStyle によって変換されたページ (->オリジナル) /