Skip to content

Commit a1293e7

Browse files
nadalabaMiodec
andauthored
chore: remove gulp dependency (@nadalaba) (monkeytypegame#6889)
Co-authored-by: Miodec <[email protected]>
1 parent f52f262 commit a1293e7

File tree

9 files changed

+86
-2287
lines changed

9 files changed

+86
-2287
lines changed

.github/labeler.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ packages:
1818
- any: ["packages/**/*"]
1919

2020
local dev:
21-
- any: ["**/gulpfile.js", "**/tsconfig.json"]
21+
- any: ["**/turbo.json", "**/tsconfig.json", "**/knip.json", "**/.prettierrc", "**/.oxlintrc.json", "**/.eslintrc.cjs", "**/vite.config.dev.js"]

.github/workflows/monkey-ci.yml

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
with:
4545
filters: |
4646
json:
47-
- 'frontend/**/*.json'
47+
- 'frontend/static/**/*'
4848
be-src:
4949
- 'backend/**/*.{ts,js,json,lua,css,html}'
5050
- 'backend/package.json'
@@ -238,16 +238,15 @@ jobs:
238238
id: filter
239239
with:
240240
filters: |
241-
language-json:
241+
languages:
242242
- 'frontend/static/languages/*.json'
243-
quotes-json:
243+
quotes:
244244
- 'frontend/static/quotes/*.json'
245-
other-json:
246-
- 'frontend/static/funbox/*.json'
247-
- 'frontend/static/fonts/*.json'
248-
- 'frontend/static/themes/*.json'
249-
- 'frontend/static/challenges/*.json'
245+
others:
250246
- 'frontend/static/layouts/*.json'
247+
- 'frontend/static/themes/**'
248+
- 'frontend/static/webfonts/**'
249+
- 'frontend/static/challenges/*.json'
251250
252251
- name: Set up Node.js
253252
uses: actions/setup-node@v4
@@ -277,19 +276,19 @@ jobs:
277276
run: pnpm install
278277

279278
- name: Lint JSON
280-
run: npm run pr-check-lint-json
279+
run: npm run lint-json-assets
281280

282-
- name: Validate languages JSON
283-
if: steps.filter.outputs.language-json == 'true'
284-
run: npm run pr-check-language-json
281+
- name: Validate language assets
282+
if: steps.filter.outputs.languages == 'true'
283+
run: npm run check-language-assets
285284

286-
- name: Validate quotes JSON
287-
if: steps.filter.outputs.quotes-json == 'true'
288-
run: npm run pr-check-quote-json
285+
- name: Validate quote assets
286+
if: steps.filter.outputs.quotes == 'true'
287+
run: npm run check-quotes-assets
289288

290-
- name: Validate other JSON
291-
if: steps.filter.outputs.other-json == 'true'
292-
run: npm run pr-check-other-json
289+
- name: Validate other assets
290+
if: steps.filter.outputs.others == 'true'
291+
run: npm run check-other-assets
293292

294293
ci-pkg:
295294
name: ci-pkg

commitlint.config.cjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ module.exports = {
8383
},
8484
build: {
8585
description:
86-
"Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)",
86+
"Changes that affect the build system or external dependencies (example scopes: vite, tsup-node, npm)",
8787
title: "Builds",
8888
emoji: "🛠",
8989
},
9090
ci: {
9191
description:
92-
"Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)",
92+
"Changes to our CI configuration files and scripts (example scopes: GitHub Workflows)",
9393
title: "Continuous Integrations",
9494
emoji: "⚙️",
9595
},

docs/CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ For types, we use the following:
3939
- `refactor`: A code change that neither fixes a bug nor adds a feature, but makes the code easier to read, understand, or improve
4040
- `perf`: A code change that improves performance
4141
- `test`: Adding missing tests or correcting existing tests
42-
- `build`: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
43-
- `ci`: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
42+
- `build`: Changes that affect the build system or external dependencies (example scopes: vite, tsup-node, npm)
43+
- `ci`: Changes to our CI configuration files and scripts (example scopes: GitHub Workflows)
4444
- `revert`: Reverts a previous commit
4545
- `chore`: Other changes that don't apply to any of the above
4646

frontend/gulpfile.js

Lines changed: 0 additions & 44 deletions
This file was deleted.

frontend/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"eslint": "eslint \"./**/*.ts\"",
88
"oxlint": "oxlint .",
99
"lint": "npm run oxlint && npm run eslint",
10-
"validate-json": "npx gulp validate-json-schema",
10+
"validate-json": "node ./scripts/json-validation.cjs",
1111
"audit": "vite-bundle-visualizer",
1212
"dep-graph": "madge -c -i \"dep-graph.png\" ./src/ts",
1313
"ts-check": "tsc --noEmit",
@@ -55,8 +55,6 @@
5555
"eslint-plugin-compat": "6.0.2",
5656
"firebase-tools": "13.15.1",
5757
"fontawesome-subset": "4.4.0",
58-
"gulp": "4.0.2",
59-
"gulp-eslint-new": "1.9.1",
6058
"happy-dom": "15.10.2",
6159
"madge": "8.0.0",
6260
"magic-string": "0.30.17",

frontend/scripts/json-validation.cjs

Lines changed: 56 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
/**
2+
* Example usage in root or frontend:
3+
* pnpm validate-json (npm run validate-json)
4+
* 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)
6+
*/
7+
18
// eslint-disable no-require-imports
29
const fs = require("fs");
310
const Ajv = require("ajv");
@@ -18,9 +25,8 @@ function findDuplicates(words) {
1825
return duplicates;
1926
}
2027

21-
function validateOthers() {
28+
function validateChallenges() {
2229
return new Promise((resolve, reject) => {
23-
//challenges
2430
const challengesSchema = {
2531
type: "array",
2632
items: {
@@ -105,7 +111,12 @@ function validateOthers() {
105111
console.log("Challenges list JSON schema is \u001b[31minvalid\u001b[0m");
106112
return reject(new Error(challengesValidator.errors[0].message));
107113
}
114+
resolve();
115+
});
116+
}
108117

118+
function validateLayouts() {
119+
return new Promise((resolve, reject) => {
109120
const charDefinitionSchema = {
110121
type: "array",
111122
minItems: 1,
@@ -118,7 +129,7 @@ function validateOthers() {
118129
maxItems: 2,
119130
items: { type: "string", minLength: 1, maxLength: 1 },
120131
};
121-
//layouts
132+
122133
const layoutsSchema = {
123134
ansi: {
124135
type: "object",
@@ -469,13 +480,47 @@ function validateLanguages() {
469480
});
470481
}
471482

472-
function validateAll() {
473-
return Promise.all([validateOthers(), validateLanguages(), validateQuotes()]);
483+
function main() {
484+
const args = process.argv.slice(2);
485+
486+
// oxlint-disable-next-line prefer-set-has this error doesnt make sense
487+
const flags = args.filter((arg) => arg.startsWith("-"));
488+
const keys = args.filter((arg) => !arg.startsWith("-"));
489+
490+
const mainValidators = {
491+
quotes: validateQuotes,
492+
languages: validateLanguages,
493+
layouts: validateLayouts,
494+
challenges: validateChallenges,
495+
};
496+
497+
const validatorsIndex = {
498+
...Object.fromEntries(
499+
Object.entries(mainValidators).map(([k, v]) => [k, [v]])
500+
),
501+
// add arbitrary keys and validator groupings down here
502+
others: [validateChallenges, validateLayouts],
503+
};
504+
505+
// flags
506+
const validateAll =
507+
keys.length < 1 || flags.includes("--all") || flags.includes("-a");
508+
const passWithNoValidators =
509+
flags.includes("--pass-with-no-validators") || flags.includes("-p");
510+
511+
const tasks = new Set(validateAll ? Object.values(mainValidators) : []);
512+
for (const key of keys) {
513+
if (!Object.keys(validatorsIndex).includes(key)) {
514+
console.error(`There is no validator for key '${key}'.`);
515+
if (!passWithNoValidators) process.exit(1);
516+
} else if (!validateAll) {
517+
validatorsIndex[key].forEach((validator) => tasks.add(validator));
518+
}
519+
}
520+
521+
if (tasks.size > 0) {
522+
return Promise.all([...tasks].map((validator) => validator()));
523+
}
474524
}
475525

476-
module.exports = {
477-
validateAll,
478-
validateOthers,
479-
validateLanguages,
480-
validateQuotes,
481-
};
526+
main();

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@
5353
"pretty-fix-fe": "prettier --write ./frontend/src",
5454
"pretty-fix-assets": "prettier --write ./frontend/static",
5555
"pretty-fix-pkg": "prettier --write ./packages",
56-
"pr-check-lint-json": "cd frontend && eslint './static/**/*.json'",
57-
"pr-check-quote-json": "cd frontend && npx gulp pr-check-quote-json",
58-
"pr-check-language-json": "cd frontend && npx gulp pr-check-language-json && turbo test -- constants/languages",
59-
"pr-check-other-json": "cd frontend && npx gulp pr-check-other-json && turbo test -- constants/layouts constants/themes constants/fonts",
56+
"lint-json-assets": "cd frontend && eslint \"./static/**/*.json\"",
57+
"validate-json": "cd frontend && pnpm validate-json",
58+
"check-quote-assets": "cd frontend && npm run validate-json quotes",
59+
"check-language-assets": "cd frontend && npm run validate-json languages && turbo run test -- constants/languages",
60+
"check-other-assets": "cd frontend && npm run validate-json others && turbo run test -- constants/layouts constants/themes constants/fonts",
6061
"knip": "knip"
6162
},
6263
"engines": {

0 commit comments

Comments
 (0)