mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-09-04 13:46:34 +08:00
chore: remove gulp dependency (@NadAlaba) (#6889)
Co-authored-by: Miodec <jack@monkeytype.com>
This commit is contained in:
parent
f52f262f71
commit
a1293e79aa
9 changed files with 84 additions and 2285 deletions
2
.github/labeler.yml
vendored
2
.github/labeler.yml
vendored
|
@ -18,4 +18,4 @@ packages:
|
|||
- any: ["packages/**/*"]
|
||||
|
||||
local dev:
|
||||
- any: ["**/gulpfile.js", "**/tsconfig.json"]
|
||||
- any: ["**/turbo.json", "**/tsconfig.json", "**/knip.json", "**/.prettierrc", "**/.oxlintrc.json", "**/.eslintrc.cjs", "**/vite.config.dev.js"]
|
||||
|
|
35
.github/workflows/monkey-ci.yml
vendored
35
.github/workflows/monkey-ci.yml
vendored
|
@ -44,7 +44,7 @@ jobs:
|
|||
with:
|
||||
filters: |
|
||||
json:
|
||||
- 'frontend/**/*.json'
|
||||
- 'frontend/static/**/*'
|
||||
be-src:
|
||||
- 'backend/**/*.{ts,js,json,lua,css,html}'
|
||||
- 'backend/package.json'
|
||||
|
@ -238,16 +238,15 @@ jobs:
|
|||
id: filter
|
||||
with:
|
||||
filters: |
|
||||
language-json:
|
||||
languages:
|
||||
- 'frontend/static/languages/*.json'
|
||||
quotes-json:
|
||||
quotes:
|
||||
- 'frontend/static/quotes/*.json'
|
||||
other-json:
|
||||
- 'frontend/static/funbox/*.json'
|
||||
- 'frontend/static/fonts/*.json'
|
||||
- 'frontend/static/themes/*.json'
|
||||
- 'frontend/static/challenges/*.json'
|
||||
others:
|
||||
- 'frontend/static/layouts/*.json'
|
||||
- 'frontend/static/themes/**'
|
||||
- 'frontend/static/webfonts/**'
|
||||
- 'frontend/static/challenges/*.json'
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
|
@ -277,19 +276,19 @@ jobs:
|
|||
run: pnpm install
|
||||
|
||||
- name: Lint JSON
|
||||
run: npm run pr-check-lint-json
|
||||
run: npm run lint-json-assets
|
||||
|
||||
- name: Validate languages JSON
|
||||
if: steps.filter.outputs.language-json == 'true'
|
||||
run: npm run pr-check-language-json
|
||||
- name: Validate language assets
|
||||
if: steps.filter.outputs.languages == 'true'
|
||||
run: npm run check-language-assets
|
||||
|
||||
- name: Validate quotes JSON
|
||||
if: steps.filter.outputs.quotes-json == 'true'
|
||||
run: npm run pr-check-quote-json
|
||||
- name: Validate quote assets
|
||||
if: steps.filter.outputs.quotes == 'true'
|
||||
run: npm run check-quotes-assets
|
||||
|
||||
- name: Validate other JSON
|
||||
if: steps.filter.outputs.other-json == 'true'
|
||||
run: npm run pr-check-other-json
|
||||
- name: Validate other assets
|
||||
if: steps.filter.outputs.others == 'true'
|
||||
run: npm run check-other-assets
|
||||
|
||||
ci-pkg:
|
||||
name: ci-pkg
|
||||
|
|
|
@ -83,13 +83,13 @@ module.exports = {
|
|||
},
|
||||
build: {
|
||||
description:
|
||||
"Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)",
|
||||
"Changes that affect the build system or external dependencies (example scopes: vite, tsup-node, npm)",
|
||||
title: "Builds",
|
||||
emoji: "🛠",
|
||||
},
|
||||
ci: {
|
||||
description:
|
||||
"Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)",
|
||||
"Changes to our CI configuration files and scripts (example scopes: GitHub Workflows)",
|
||||
title: "Continuous Integrations",
|
||||
emoji: "⚙️",
|
||||
},
|
||||
|
|
|
@ -39,8 +39,8 @@ For types, we use the following:
|
|||
- `refactor`: A code change that neither fixes a bug nor adds a feature, but makes the code easier to read, understand, or improve
|
||||
- `perf`: A code change that improves performance
|
||||
- `test`: Adding missing tests or correcting existing tests
|
||||
- `build`: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
|
||||
- `ci`: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
|
||||
- `build`: Changes that affect the build system or external dependencies (example scopes: vite, tsup-node, npm)
|
||||
- `ci`: Changes to our CI configuration files and scripts (example scopes: GitHub Workflows)
|
||||
- `revert`: Reverts a previous commit
|
||||
- `chore`: Other changes that don't apply to any of the above
|
||||
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
/* eslint-disable import/no-unresolved */
|
||||
import eslint, { format, failAfterError } from "gulp-eslint-new";
|
||||
import gulp from "gulp";
|
||||
import {
|
||||
validateAll,
|
||||
validateQuotes,
|
||||
validateLanguages,
|
||||
validateOthers,
|
||||
} from "./scripts/json-validation.cjs";
|
||||
const eslintConfig = "../.eslintrc.json";
|
||||
|
||||
const { task, src, series } = gulp;
|
||||
|
||||
task("lint", function () {
|
||||
return src(["./src/ts/**/*.ts"])
|
||||
.pipe(eslint(eslintConfig))
|
||||
.pipe(format())
|
||||
.pipe(failAfterError());
|
||||
});
|
||||
|
||||
task("lint-json", function () {
|
||||
return src("./static/**/*.json")
|
||||
.pipe(eslint(eslintConfig))
|
||||
.pipe(format())
|
||||
.pipe(failAfterError());
|
||||
});
|
||||
|
||||
task("validate-json-schema", function () {
|
||||
return validateAll();
|
||||
});
|
||||
|
||||
//PR CHECK
|
||||
|
||||
task("pr-check-quote-json", function () {
|
||||
return validateQuotes();
|
||||
});
|
||||
task("pr-check-language-json", function () {
|
||||
return validateLanguages();
|
||||
});
|
||||
task("pr-check-other-json", function () {
|
||||
return validateOthers();
|
||||
});
|
||||
|
||||
task("pr-check-lint", series("lint"));
|
|
@ -7,7 +7,7 @@
|
|||
"eslint": "eslint \"./**/*.ts\"",
|
||||
"oxlint": "oxlint .",
|
||||
"lint": "npm run oxlint && npm run eslint",
|
||||
"validate-json": "npx gulp validate-json-schema",
|
||||
"validate-json": "node ./scripts/json-validation.cjs",
|
||||
"audit": "vite-bundle-visualizer",
|
||||
"dep-graph": "madge -c -i \"dep-graph.png\" ./src/ts",
|
||||
"ts-check": "tsc --noEmit",
|
||||
|
@ -55,8 +55,6 @@
|
|||
"eslint-plugin-compat": "6.0.2",
|
||||
"firebase-tools": "13.15.1",
|
||||
"fontawesome-subset": "4.4.0",
|
||||
"gulp": "4.0.2",
|
||||
"gulp-eslint-new": "1.9.1",
|
||||
"happy-dom": "15.10.2",
|
||||
"madge": "8.0.0",
|
||||
"magic-string": "0.30.17",
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
/**
|
||||
* Example usage in root or frontend:
|
||||
* pnpm validate-json (npm run validate-json)
|
||||
* pnpm vaildate-json quotes others(npm run vaildate-json quotes others)
|
||||
* pnpm validate-json challenges fonts -p (npm run validate-json challenges fonts -- -p)
|
||||
*/
|
||||
|
||||
// eslint-disable no-require-imports
|
||||
const fs = require("fs");
|
||||
const Ajv = require("ajv");
|
||||
|
@ -18,9 +25,8 @@ function findDuplicates(words) {
|
|||
return duplicates;
|
||||
}
|
||||
|
||||
function validateOthers() {
|
||||
function validateChallenges() {
|
||||
return new Promise((resolve, reject) => {
|
||||
//challenges
|
||||
const challengesSchema = {
|
||||
type: "array",
|
||||
items: {
|
||||
|
@ -105,7 +111,12 @@ function validateOthers() {
|
|||
console.log("Challenges list JSON schema is \u001b[31minvalid\u001b[0m");
|
||||
return reject(new Error(challengesValidator.errors[0].message));
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
|
||||
function validateLayouts() {
|
||||
return new Promise((resolve, reject) => {
|
||||
const charDefinitionSchema = {
|
||||
type: "array",
|
||||
minItems: 1,
|
||||
|
@ -118,7 +129,7 @@ function validateOthers() {
|
|||
maxItems: 2,
|
||||
items: { type: "string", minLength: 1, maxLength: 1 },
|
||||
};
|
||||
//layouts
|
||||
|
||||
const layoutsSchema = {
|
||||
ansi: {
|
||||
type: "object",
|
||||
|
@ -469,13 +480,47 @@ function validateLanguages() {
|
|||
});
|
||||
}
|
||||
|
||||
function validateAll() {
|
||||
return Promise.all([validateOthers(), validateLanguages(), validateQuotes()]);
|
||||
function main() {
|
||||
const args = process.argv.slice(2);
|
||||
|
||||
// oxlint-disable-next-line prefer-set-has this error doesnt make sense
|
||||
const flags = args.filter((arg) => arg.startsWith("-"));
|
||||
const keys = args.filter((arg) => !arg.startsWith("-"));
|
||||
|
||||
const mainValidators = {
|
||||
quotes: validateQuotes,
|
||||
languages: validateLanguages,
|
||||
layouts: validateLayouts,
|
||||
challenges: validateChallenges,
|
||||
};
|
||||
|
||||
const validatorsIndex = {
|
||||
...Object.fromEntries(
|
||||
Object.entries(mainValidators).map(([k, v]) => [k, [v]])
|
||||
),
|
||||
// add arbitrary keys and validator groupings down here
|
||||
others: [validateChallenges, validateLayouts],
|
||||
};
|
||||
|
||||
// flags
|
||||
const validateAll =
|
||||
keys.length < 1 || flags.includes("--all") || flags.includes("-a");
|
||||
const passWithNoValidators =
|
||||
flags.includes("--pass-with-no-validators") || flags.includes("-p");
|
||||
|
||||
const tasks = new Set(validateAll ? Object.values(mainValidators) : []);
|
||||
for (const key of keys) {
|
||||
if (!Object.keys(validatorsIndex).includes(key)) {
|
||||
console.error(`There is no validator for key '${key}'.`);
|
||||
if (!passWithNoValidators) process.exit(1);
|
||||
} else if (!validateAll) {
|
||||
validatorsIndex[key].forEach((validator) => tasks.add(validator));
|
||||
}
|
||||
}
|
||||
|
||||
if (tasks.size > 0) {
|
||||
return Promise.all([...tasks].map((validator) => validator()));
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
validateAll,
|
||||
validateOthers,
|
||||
validateLanguages,
|
||||
validateQuotes,
|
||||
};
|
||||
main();
|
||||
|
|
|
@ -53,10 +53,11 @@
|
|||
"pretty-fix-fe": "prettier --write ./frontend/src",
|
||||
"pretty-fix-assets": "prettier --write ./frontend/static",
|
||||
"pretty-fix-pkg": "prettier --write ./packages",
|
||||
"pr-check-lint-json": "cd frontend && eslint './static/**/*.json'",
|
||||
"pr-check-quote-json": "cd frontend && npx gulp pr-check-quote-json",
|
||||
"pr-check-language-json": "cd frontend && npx gulp pr-check-language-json && turbo test -- constants/languages",
|
||||
"pr-check-other-json": "cd frontend && npx gulp pr-check-other-json && turbo test -- constants/layouts constants/themes constants/fonts",
|
||||
"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 && turbo run test -- constants/languages",
|
||||
"check-other-assets": "cd frontend && npm run validate-json others && turbo run test -- constants/layouts constants/themes constants/fonts",
|
||||
"knip": "knip"
|
||||
},
|
||||
"engines": {
|
||||
|
|
2200
pnpm-lock.yaml
generated
2200
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue