Skip to content

Commit 56b25f3

Browse files
authored
build: rename json-validation to check-assets, improve error messages (@fehmer) (monkeytypegame#6933)
- **improve error messages** - **rename json-validation to check-assets**
1 parent 661feaa commit 56b25f3

File tree

5 files changed

+19
-23
lines changed

5 files changed

+19
-23
lines changed

frontend/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
"eslint": "eslint \"./**/*.ts\"",
88
"oxlint": "oxlint .",
99
"lint": "npm run oxlint && npm run eslint",
10-
"validate-json": "tsx ./scripts/json-validation.ts",
10+
"check-assets": "tsx ./scripts/check-assets.ts",
1111
"audit": "vite-bundle-visualizer",
1212
"dep-graph": "madge -c -i \"dep-graph.png\" ./src/ts",
1313
"ts-check": "tsc --noEmit",
1414
"build": "npm run madge && vite build",
1515
"madge": " madge --circular --extensions ts ./src",
1616
"start": "vite preview --port 3000",
1717
"dev": "vite dev",
18-
"deploy-live": "npm run validate-json && npm run build && firebase deploy -P live --only hosting",
19-
"deploy-preview": "npm run validate-json && npm run build && firebase hosting:channel:deploy preview -P live --expires 2h",
18+
"deploy-live": "npm run check-assets && npm run build && firebase deploy -P live --only hosting",
19+
"deploy-preview": "npm run check-assets && npm run build && firebase hosting:channel:deploy preview -P live --expires 2h",
2020
"test": "vitest run",
2121
"test-coverage": "vitest run --coverage",
2222
"dev-test": "concurrently --kill-others \"vite dev\" \"vitest\"",
Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
22
* Example usage in root or frontend:
3-
* pnpm validate-json (npm run validate-json)
3+
* pnpm check-assets (npm run check-assets)
44
* pnpm vaildate-json quotes others(npm run vaildate-json quotes others)
5-
* pnpm validate-json challenges fonts -p (npm run validate-json challenges fonts -- -p)
5+
* pnpm check-assets challenges fonts -p (npm run check-assets challenges fonts -- -p)
66
*/
77

88
import * as fs from "fs";
@@ -106,7 +106,7 @@ async function validateChallenges(): Promise<void> {
106106
async function validateLayouts(): Promise<void> {
107107
const problems = new Problems<Layout, "_additional">("Layouts", {
108108
_additional:
109-
"Additional layout files not declared in frontend/src/ts/constants/layouts.ts",
109+
"Layout files present but missing in packages/schemas/src/layouts.ts",
110110
});
111111

112112
for (let layoutName of LayoutsList) {
@@ -138,8 +138,7 @@ async function validateLayouts(): Promise<void> {
138138
const additionalLayoutFiles = fs
139139
.readdirSync("./static/layouts")
140140
.map((it) => it.substring(0, it.length - 5))
141-
.filter((it) => !LayoutsList.some((layout) => layout === it))
142-
.map((it) => `frontend/static/layouts/${it}.json`);
141+
.filter((it) => !LayoutsList.some((layout) => layout === it));
143142
if (additionalLayoutFiles.length !== 0) {
144143
additionalLayoutFiles.forEach((it) => problems.add("_additional", it));
145144
}
@@ -239,9 +238,9 @@ async function validateLanguages(): Promise<void> {
239238
"Languages",
240239
{
241240
_additional:
242-
"Additional language files not declared in frontend/src/ts/constants/languages.ts",
241+
"Language files present but missing in packages/schemas/src/languages.ts",
243242
_groups:
244-
"Problems in LanguageGroups on frontend/src/ts/constants/languages.ts",
243+
"Problems in LanguageGroups in frontend/src/ts/constants/languages.ts",
245244
}
246245
);
247246

@@ -290,7 +289,6 @@ async function validateLanguages(): Promise<void> {
290289
fs.readdirSync("./static/languages")
291290
.map((it) => it.substring(0, it.length - 5))
292291
.filter((it) => !LanguageList.some((language) => language === it))
293-
.map((it) => `frontend/static/languages/${it}.json`)
294292
.forEach((it) => problems.add("_additional", it));
295293

296294
//check groups
@@ -334,7 +332,7 @@ async function validateLanguages(): Promise<void> {
334332
async function validateFonts(): Promise<void> {
335333
const problems = new Problems<KnownFontName, "_additional">("Fonts", {
336334
_additional:
337-
"Additional font files not declared in frontend/src/ts/constants/fonts.ts",
335+
"Font files present but missing in frontend/src/ts/constants/fonts.ts",
338336
});
339337

340338
//no missing files
@@ -367,7 +365,6 @@ async function validateFonts(): Promise<void> {
367365

368366
fontFiles
369367
.filter((name) => !expectedFontFiles.has(name))
370-
.map((name) => `frontend/static/webfonts/${name}`)
371368
.forEach((file) => problems.add("_additional", file));
372369

373370
console.log(problems.toString());
@@ -380,7 +377,7 @@ async function validateFonts(): Promise<void> {
380377
async function validateThemes(): Promise<void> {
381378
const problems = new Problems<ThemeName, "_additional">("Themes", {
382379
_additional:
383-
"Additional theme files not declared in frontend/src/ts/constants/themes.ts",
380+
"Theme files present but missing in frontend/src/ts/constants/themes.ts",
384381
});
385382

386383
//no missing files
@@ -396,7 +393,6 @@ async function validateThemes(): Promise<void> {
396393
//additional theme files
397394
themeFiles
398395
.filter((it) => !ThemesList.some((theme) => theme.name === it))
399-
.map((it) => `frontend/static/themes/${it}.css`)
400396
.forEach((it) => problems.add("_additional", it));
401397

402398
console.log(problems.toString());

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"type": "module",
66
"scripts": {
77
"preinstall": "npx only-allow pnpm",
8-
"full-check": "turbo lint ts-check build test integration-test validate-json --force",
8+
"full-check": "turbo lint ts-check build test integration-test check-assets --force",
99
"prepare": "husky install",
1010
"pre-commit": "lint-staged",
1111
"ts-check": "turbo run ts-check",
@@ -54,10 +54,10 @@
5454
"pretty-fix-assets": "prettier --write ./frontend/static",
5555
"pretty-fix-pkg": "prettier --write ./packages",
5656
"lint-json-assets": "cd frontend && eslint \"./static/**/*.json\"",
57-
"validate-json": "turbo validate-json --filter @monkeytype/frontend",
58-
"check-assets-quotes": "turbo validate-json --filter @monkeytype/frontend -- quotes",
59-
"check-assets-languages": "turbo validate-json --filter @monkeytype/frontend -- languages",
60-
"check-assets-others": "turbo validate-json --filter @monkeytype/frontend -- others",
57+
"check-assets": "turbo check-assets --filter @monkeytype/frontend",
58+
"check-assets-quotes": "turbo check-assets --filter @monkeytype/frontend -- quotes",
59+
"check-assets-languages": "turbo check-assets --filter @monkeytype/frontend -- languages",
60+
"check-assets-others": "turbo check-assets --filter @monkeytype/frontend -- others",
6161
"knip": "knip"
6262
},
6363
"engines": {

packages/release/src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,15 +179,15 @@ const buildProject = () => {
179179

180180
if (isFrontend && !isBackend) {
181181
runProjectRootCommand(
182-
"SENTRY=1 npx turbo lint test validate-json build --filter @monkeytype/frontend --force"
182+
"SENTRY=1 npx turbo lint test check-assets build --filter @monkeytype/frontend --force"
183183
);
184184
} else if (isBackend && !isFrontend) {
185185
runProjectRootCommand(
186186
"SENTRY=1 npx turbo lint test build --filter @monkeytype/backend --force"
187187
);
188188
} else {
189189
runProjectRootCommand(
190-
"SENTRY=1 npx turbo lint test validate-json build --force"
190+
"SENTRY=1 npx turbo lint test check-assets build --force"
191191
);
192192
}
193193
};

turbo.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"start": {
3232
"dependsOn": ["build"]
3333
},
34-
"@monkeytype/frontend#validate-json": {
34+
"@monkeytype/frontend#check-assets": {
3535
"dependsOn": ["^parallel", "@monkeytype/schemas#build"]
3636
},
3737
"@monkeytype/frontend#build": {

0 commit comments

Comments
 (0)