web: add check compile test to prevent compile errors/warnings

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2023-01-01 23:32:05 +01:00
parent 93e20bce2e
commit 964fdf171b
No known key found for this signature in database
13 changed files with 52 additions and 4 deletions

View File

@ -27,6 +27,22 @@ jobs:
- name: Eslint - name: Eslint
working-directory: web/ working-directory: web/
run: npm run lint run: npm run lint
lint-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3.5.1
with:
node-version: '16'
cache: 'npm'
cache-dependency-path: web/package-lock.json
- working-directory: web/
run: npm ci
- name: Generate API
run: make gen-client-ts
- name: TSC
working-directory: web/
run: npm run tsc
lint-prettier: lint-prettier:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:

View File

@ -126,7 +126,7 @@ gen: gen-build gen-clean gen-client-ts
web-build: web-install web-build: web-install
cd web && npm run build cd web && npm run build
web: web-lint-fix web-lint web: web-lint-fix web-lint web-check-compile
web-install: web-install:
cd web && npm ci cd web && npm ci
@ -144,6 +144,9 @@ web-lint:
cd web && npm run lint cd web && npm run lint
cd web && npm run lit-analyse cd web && npm run lit-analyse
web-check-compile:
cd web && npm run tsc
web-extract: web-extract:
cd web && npm run extract cd web && npm run extract

View File

@ -12,6 +12,7 @@
"lit-analyse": "lit-analyzer src", "lit-analyse": "lit-analyzer src",
"prettier-check": "prettier --check .", "prettier-check": "prettier --check .",
"prettier": "prettier --write .", "prettier": "prettier --write .",
"tsc": "tsc --strict --noEmit",
"background-image": "npx @squoosh/cli -d src/assets/images --resize '{\"enabled\":true,\"width\":2560,\"method\":\"lanczos3\",\"fitMethod\":\"contain\",\"premultiply\":true,\"linearRGB\":true}' --mozjpeg '{\"quality\":75,\"baseline\":false,\"arithmetic\":false,\"progressive\":true,\"optimize_coding\":true,\"smoothing\":0,\"color_space\":3,\"quant_table\":3,\"trellis_multipass\":false,\"trellis_opt_zero\":false,\"trellis_opt_table\":false,\"trellis_loops\":1,\"auto_subsample\":true,\"chroma_subsample\":2,\"separate_chroma_quality\":false,\"chroma_quality\":75}' src/assets/images/flow_background.jpg" "background-image": "npx @squoosh/cli -d src/assets/images --resize '{\"enabled\":true,\"width\":2560,\"method\":\"lanczos3\",\"fitMethod\":\"contain\",\"premultiply\":true,\"linearRGB\":true}' --mozjpeg '{\"quality\":75,\"baseline\":false,\"arithmetic\":false,\"progressive\":true,\"optimize_coding\":true,\"smoothing\":0,\"color_space\":3,\"quant_table\":3,\"trellis_multipass\":false,\"trellis_opt_zero\":false,\"trellis_opt_table\":false,\"trellis_loops\":1,\"auto_subsample\":true,\"chroma_subsample\":2,\"separate_chroma_quality\":false,\"chroma_quality\":75}' src/assets/images/flow_background.jpg"
}, },
"lingui": { "lingui": {

View File

@ -18,6 +18,8 @@ export function DesignationToLabel(designation: FlowDesignationEnum): string {
return t`Stage Configuration`; return t`Stage Configuration`;
case FlowDesignationEnum.Unenrollment: case FlowDesignationEnum.Unenrollment:
return t`Unenrollment`; return t`Unenrollment`;
case FlowDesignationEnum.UnknownDefaultOpenApi:
return t`Unknown designation`;
} }
} }
@ -33,5 +35,7 @@ export function LayoutToLabel(layout: LayoutEnum): string {
return t`Sidebar left`; return t`Sidebar left`;
case LayoutEnum.SidebarRight: case LayoutEnum.SidebarRight:
return t`Sidebar right`; return t`Sidebar right`;
case LayoutEnum.UnknownDefaultOpenApi:
return t`Unknown layout`;
} }
} }

View File

@ -107,6 +107,10 @@ export class OutpostForm extends ModelForm<Outpost, string> {
</option>`; </option>`;
}); });
}); });
case OutpostTypeEnum.UnknownDefaultOpenApi:
return Promise.resolve([
html` <option value="">${t`Unknown outpost type`}</option>`,
]);
} }
} }

View File

@ -33,6 +33,8 @@ export function TypeToLabel(type?: OutpostTypeEnum): string {
return t`Proxy`; return t`Proxy`;
case OutpostTypeEnum.Ldap: case OutpostTypeEnum.Ldap:
return t`LDAP`; return t`LDAP`;
case OutpostTypeEnum.UnknownDefaultOpenApi:
return t`Unknown type`;
} }
} }

View File

@ -279,6 +279,8 @@ export class ProxyProviderFormPage extends ModelForm<ProxyProvider, number> {
${t`Set this to the domain you wish the authentication to be valid for. Must be a parent domain of the URL above. If you're running applications as app1.domain.tld, app2.domain.tld, set this to 'domain.tld'.`} ${t`Set this to the domain you wish the authentication to be valid for. Must be a parent domain of the URL above. If you're running applications as app1.domain.tld, app2.domain.tld, set this to 'domain.tld'.`}
</p> </p>
</ak-form-element-horizontal>`; </ak-form-element-horizontal>`;
case ProxyMode.UnknownDefaultOpenApi:
return html`<p>${t`Unknown proxy mode`}</p>`;
} }
} }

View File

@ -47,6 +47,8 @@ export function ModeToLabel(action?: ProxyMode): string {
return t`Forward auth (single application)`; return t`Forward auth (single application)`;
case ProxyMode.ForwardDomain: case ProxyMode.ForwardDomain:
return t`Forward auth (domain-level)`; return t`Forward auth (domain-level)`;
case ProxyMode.UnknownDefaultOpenApi:
return t`Unknown proxy mode`;
} }
} }
@ -57,6 +59,8 @@ export function isForward(mode: ProxyMode): boolean {
case ProxyMode.ForwardSingle: case ProxyMode.ForwardSingle:
case ProxyMode.ForwardDomain: case ProxyMode.ForwardDomain:
return true; return true;
case ProxyMode.UnknownDefaultOpenApi:
return false;
} }
} }

View File

@ -27,8 +27,9 @@ import PFBase from "@patternfly/patternfly/patternfly-base.css";
import { OAuthSource, ProviderTypeEnum, SourcesApi } from "@goauthentik/api"; import { OAuthSource, ProviderTypeEnum, SourcesApi } from "@goauthentik/api";
export function ProviderToLabel(provider?: ProviderTypeEnum): string { export function ProviderToLabel(provider?: ProviderTypeEnum): string {
if (!provider) return "";
switch (provider) { switch (provider) {
case undefined:
return "";
case ProviderTypeEnum.Apple: case ProviderTypeEnum.Apple:
return "Apple"; return "Apple";
case ProviderTypeEnum.Azuread: case ProviderTypeEnum.Azuread:
@ -51,6 +52,10 @@ export function ProviderToLabel(provider?: ProviderTypeEnum): string {
return "Reddit"; return "Reddit";
case ProviderTypeEnum.Twitter: case ProviderTypeEnum.Twitter:
return "Twitter"; return "Twitter";
case ProviderTypeEnum.Twitch:
return "Twitch";
case ProviderTypeEnum.UnknownDefaultOpenApi:
return t`Unknown provider type`;
} }
} }

View File

@ -15,5 +15,7 @@ export function UserMatchingModeToLabel(mode?: UserMatchingModeEnum): string {
return t`Link to a user with identical username. Can have security implications when a username is used with another source`; return t`Link to a user with identical username. Can have security implications when a username is used with another source`;
case UserMatchingModeEnum.UsernameDeny: case UserMatchingModeEnum.UsernameDeny:
return t`Use the user's username, but deny enrollment when the username already exists`; return t`Use the user's username, but deny enrollment when the username already exists`;
case UserMatchingModeEnum.UnknownDefaultOpenApi:
return t`Unknown user matching mode`;
} }
} }

View File

@ -27,6 +27,8 @@ export function IntentToLabel(intent: IntentEnum): string {
return t`Recovery`; return t`Recovery`;
case IntentEnum.Verification: case IntentEnum.Verification:
return t`Verification`; return t`Verification`;
case IntentEnum.UnknownDefaultOpenApi:
return t`Unknown intent`;
} }
} }

View File

@ -35,7 +35,10 @@ export class Diagram extends AKElement {
const matcher = window.matchMedia("(prefers-color-scheme: light)"); const matcher = window.matchMedia("(prefers-color-scheme: light)");
const handler = (ev?: MediaQueryListEvent) => { const handler = (ev?: MediaQueryListEvent) => {
mermaid.initialize({ mermaid.initialize({
logLevel: "fatal", // The type definition for this says number
// but the example use strings
// and numbers don't work
logLevel: "fatal" as unknown as number,
startOnLoad: false, startOnLoad: false,
theme: ev?.matches || matcher.matches ? "default" : "dark", theme: ev?.matches || matcher.matches ? "default" : "dark",
flowchart: { flowchart: {

View File

@ -202,7 +202,7 @@ export abstract class Table<T> extends AKElement {
let comp = (item: T) => { let comp = (item: T) => {
return JSON.stringify(item) === jsonRes; return JSON.stringify(item) === jsonRes;
}; };
if ("pk" in res) { if (Object.hasOwn(res as object, "pk")) {
comp = (item: T) => { comp = (item: T) => {
return ( return (
(item as unknown as { pk: string | number }).pk === (item as unknown as { pk: string | number }).pk ===