ci(assets): Refactor json-validator (@fehmer) (#6901)

This commit is contained in:
Christian Fehmer 2025-08-22 13:37:56 +02:00 committed by GitHub
parent d2c627fcc8
commit 5937f49246
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 508 additions and 628 deletions

View file

@ -1,39 +0,0 @@
import { describe, it, expect } from "vitest";
import { readdirSync } from "fs";
import { ThemesList } from "../../src/ts/constants/themes";
describe("themes", () => {
it("should not have duplicates", () => {
const duplicates = ThemesList.filter(
(item, index) => ThemesList.indexOf(item) !== index
);
expect(duplicates).toEqual([]);
});
it("should have all related css files", () => {
const themeFiles = listThemeFiles();
const missingThemeFiles = ThemesList.filter(
(it) => !themeFiles.includes(it.name)
).map((it) => `fontend/static/themes/${it}.css`);
expect(missingThemeFiles, "missing theme css files").toEqual([]);
});
it("should not have additional css files", () => {
const themeFiles = listThemeFiles();
const additionalThemeFiles = themeFiles
.filter((it) => !ThemesList.some((theme) => theme.name === it))
.map((it) => `fontend/static/themes/${it}.css`);
expect(
additionalThemeFiles,
"additional theme css files not declared in frontend/src/ts/constants/themes.ts"
).toEqual([]);
});
});
function listThemeFiles() {
return readdirSync(import.meta.dirname + "/../../static/themes").map((it) =>
it.substring(0, it.length - 4)
);
}

File diff suppressed because it is too large Load diff

View file

@ -54,10 +54,10 @@
"pretty-fix-assets": "prettier --write ./frontend/static",
"pretty-fix-pkg": "prettier --write ./packages",
"lint-json-assets": "cd frontend && eslint \"./static/**/*.json\"",
"validate-json": "cd frontend && pnpm validate-json",
"check-quote-assets": "cd frontend && npm run validate-json quotes",
"check-language-assets": "cd frontend && npm run validate-json languages",
"check-other-assets": "cd frontend && npm run validate-json others",
"validate-json": "turbo validate-json --filter @monkeytype/frontend",
"check-quote-assets": "turbo validate-json --filter @monkeytype/frontend -- quotes",
"check-language-assets": "turbo validate-json --filter @monkeytype/frontend -- languages",
"check-other-assets": "turbo validate-json --filter @monkeytype/frontend -- others",
"knip": "knip"
},
"engines": {

View file

@ -32,7 +32,7 @@
"dependsOn": ["build"]
},
"@monkeytype/frontend#validate-json": {
"dependsOn": ["^parallel"]
"dependsOn": ["^parallel", "@monkeytype/schemas#build"]
},
"@monkeytype/frontend#build": {
"dependsOn": ["^build"],