Skip to content

Commit

Permalink
Various things (#5934)
Browse files Browse the repository at this point in the history
  • Loading branch information
gc authored Jul 2, 2024
1 parent 11d1487 commit e9fd7b7
Show file tree
Hide file tree
Showing 642 changed files with 3,417 additions and 5,072 deletions.
7 changes: 0 additions & 7 deletions .eslintignore

This file was deleted.

22 changes: 0 additions & 22 deletions .eslintrc.json

This file was deleted.

13 changes: 1 addition & 12 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,7 @@ jobs:
popd
- name: Copy env
run: cp .env.test .env
- name: Generate Prisma Client
run: yarn gen
- name: Run ESLint on changed files
uses: tj-actions/eslint-changed-files@v21
with:
skip_annotations: true
config_path: ".eslintrc.json"
ignore_path: ".eslintignore"
file_extensions: |
**/*.ts
**/*.tsx
- name: Build
run: yarn build
run: yarn build --clean
- name: Test
run: yarn test:unit
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ node_modules/
.eslintcache

/coverage
*.cpuprofile
*.cpuprofile

cache.json
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ To suggest a new feature, [click here](https://github.com/oldschoolgg/oldschoolb

Anyone is free to create PR's with improvements and additions to Old School Bot.

Please lint your code with the projects' [ESLint](https://eslint.org/) config.

Contributors are listed in this file, and given a Contributor role in the support server. If you have more questions, there are lots of helpful Contributors in the `#developers` channel on the Discord server.

### Setting up the bot to run locally for contributing
Expand Down Expand Up @@ -93,3 +91,13 @@ You can also ask Magna to invite your Bot with your invite link above if you so
## Self Hosting

Self hosting is not supported.

## Notes

### Profiling tests

- node --cpu-prof --cpu-prof-dir=./profiling ./node_modules/vitest/vitest.mjs run --coverage --config vitest.unit.config.mts parseStringBank

## Module graph

- yarn build && npx madge --image graph2.svg ./dist/index.js
57 changes: 57 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"organizeImports": {
"enabled": true
},
"files": {
"maxSize": 10000000,
"ignore": ["node_modules", "dist", "coverage", "profiling", "logs", "icon_cache"],
"include": ["**/*.ts", "**/*.mts", "**/*.json"]
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"a11y": {
"useAltText": "off",
"useKeyWithClickEvents": "off"
},
"suspicious": {
"noExplicitAny": "warn",
"noAssignInExpressions": "warn",
"noAsyncPromiseExecutor": "off"
},
"style": {
"noNonNullAssertion": "off",
"noParameterAssign": "off",
"useExponentiationOperator": "off",
"noUselessElse": "off"
},
"correctness": {
"useExhaustiveDependencies": "warn",
"noUnnecessaryContinue": "warn",
"noConstructorReturn": "off"
},
"complexity": {
"noExtraBooleanCast": "warn",
"noBannedTypes": "warn",
"noForEach": "warn"
}
}
},
"formatter": {
"enabled": true,
"formatWithErrors": true,
"indentStyle": "tab",
"indentWidth": 4,
"lineWidth": 120,
"lineEnding": "lf"
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"trailingCommas": "none",
"arrowParentheses": "asNeeded"
}
}
}
35 changes: 12 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
{
"scripts": {
"gen": "concurrently \"prisma generate --no-hints\" \"prisma generate --no-hints --schema prisma/robochimp.prisma\" && echo \"Generated Prisma Client\"",
"prettify": "prettier --use-tabs ./**/*.{js,md,json,yml} --write",
"lint": "concurrently \"yarn prettify\" \"eslint --quiet *.{ts,mts} \"{src,tests}/**/*.ts\" --fix\"",
"gen": "concurrently --raw \"prisma generate --no-hints\" \"prisma generate --no-hints --schema prisma/robochimp.prisma\" && echo \"Generated Prisma Client\"",
"prettify": "prettier --use-tabs ./**/*.{md,yml} --write",
"lint": "concurrently --timings --raw --kill-others-on-fail \"biome check --write --unsafe --diagnostic-level=error\" \"yarn prettify\"",
"build:tsc": "tsc -p src",
"build": "concurrently \"yarn wipedist\" \"yarn gen\" && yarn pre:build && yarn build:tsc && yarn post:build && echo \"Finished Building\"",
"build": "tsx ./src/scripts/build.ts",
"wipedist": "rimraf \"dist/\"",
"start": "yarn build && concurrently \"tsc -w -p src\" \"node --enable-source-maps dist/\"",
"test": "concurrently \"tsc -p src\" \"yarn test:lint\" \"yarn test:unit\"",
"test:lint": "eslint --quiet *.{mts,ts} \"{src,tests}/**/*.ts\"",
"test": "concurrently --timings --raw --kill-others-on-fail \"tsc -p src\" \"yarn test:lint\" \"yarn test:unit\"",
"test:lint": "biome check --diagnostic-level=error",
"test:unit": "vitest run --coverage --config vitest.unit.config.mts",
"dev": "yarn wipedist && tsc -w -p src",
"test:watch": "vitest --config vitest.unit.config.mts --coverage",
"test:integration": "tsx ./src/scripts/integration-tests.ts",
"pre:build": "tsx ./src/scripts/render-creatables-file.ts",
"post:build": "tsx ./src/scripts/postbuild.ts",
"build:esbuild": "esbuild --bundle src/index.ts --outdir=dist --platform=node --loader:.node=file --external:canvas",
"run:node": "node --enable-source-maps dist/index.js"
"build:esbuild": "esbuild --bundle src/index.ts --outdir=dist --platform=node --loader:.node=file --external:canvas"
},
"dependencies": {
"@fastify/cors": "^8.2.0",
Expand All @@ -36,6 +33,7 @@
"chart.js": "^3.7.0",
"chartjs-node-canvas": "github:gc/ChartjsNodeCanvas#a598b6dd27c44351f235bca07ca4ee660121f289",
"chartjs-plugin-datalabels": "^2.0.0",
"decimal.js": "^10.4.3",
"deepmerge": "^4.3.1",
"discord.js": "14.14.1",
"dotenv": "^16.4.5",
Expand All @@ -46,7 +44,6 @@
"lodash": "^4.17.21",
"lru-cache": "^10.3.0",
"mahoji": "^0.0.7",
"mathjs": "^13.0.0",
"murmurhash": "^2.0.1",
"node-cron": "^3.0.3",
"node-fetch": "^2.6.7",
Expand All @@ -60,31 +57,23 @@
"zod": "^3.23.8"
},
"devDependencies": {
"@oldschoolgg/eslint-config": "^2.0.13",
"@biomejs/biome": "^1.8.3",
"@oldschoolgg/ts-config": "^0.0.1",
"@types/jest-image-snapshot": "^6.1.0",
"@types/lodash": "^4.14.195",
"@types/madge": "^5.0.0",
"@types/mitm": "^1.3.8",
"@types/node": "^14.18.12",
"@types/node-cron": "^3.0.7",
"@types/node-fetch": "^2.6.1",
"@typescript-eslint/eslint-plugin": "^5.41.0",
"@typescript-eslint/parser": "^5.41.0",
"@vitest/coverage-v8": "^1.6.0",
"concurrently": "^8.2.2",
"dotenv-cli": "^7.4.2",
"dpdm": "^3.14.0",
"esbuild": "^0.22.0",
"eslint": "^8.36.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-simple-import-sort": "^8.0.0",
"eslint-plugin-unicorn": "^44.0.2",
"fast-glob": "^3.3.2",
"jest-image-snapshot": "^6.2.0",
"madge": "^7.0.0",
"mitm": "^1.7.2",
"prettier": "^2.7.1",
"prettier": "^3.3.2",
"prisma": "^5.13.0",
"rimraf": "^5.0.7",
"tsx": "^4.16.0",
Expand Down
10 changes: 5 additions & 5 deletions prisma/robochimp.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ model BlacklistedEntity {
}

model User {
id BigInt @id @unique
bits Int[]
github_id Int?
patreon_id String?
migrated_user_id BigInt?
id BigInt @id @unique
bits Int[]
github_id Int?
patreon_id String?
migrated_user_id BigInt?
leagues_completed_tasks_ids Int[]
leagues_points_balance_osb Int @default(0)
Expand Down
2 changes: 1 addition & 1 deletion src/config.example.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IDiscordSettings } from './lib/types';
import type { IDiscordSettings } from './lib/types';

export const botToken = '';
export const production = false;
Expand Down
11 changes: 6 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,25 @@ import './lib/data/trophies';
import './lib/itemMods';
import './lib/geImage';

import { join } from 'node:path';
import * as Sentry from '@sentry/node';
import { Chart } from 'chart.js';
import ChartDataLabels from 'chartjs-plugin-datalabels';
import { GatewayIntentBits, Options, Partials, TextChannel } from 'discord.js';
import type { TextChannel } from 'discord.js';
import { GatewayIntentBits, Options, Partials } from 'discord.js';
import { isObject } from 'e';
import { MahojiClient } from 'mahoji';
import { join } from 'path';

import { botToken, DEV_SERVER_ID, SENTRY_DSN, SupportServer } from './config';
import { DEV_SERVER_ID, SENTRY_DSN, SupportServer, botToken } from './config';
import { syncActivityCache } from './lib/Task';
import { BLACKLISTED_GUILDS, BLACKLISTED_USERS } from './lib/blacklists';
import { Channel, Events, globalConfig, META_CONSTANTS } from './lib/constants';
import { Channel, Events, META_CONSTANTS, globalConfig } from './lib/constants';
import { economyLog } from './lib/economyLogs';
import { onMessage } from './lib/events';
import { makeServer } from './lib/http';
import { modalInteractionHook } from './lib/modals';
import { runStartupScripts } from './lib/startupScripts';
import { OldSchoolBotClient } from './lib/structures/OldSchoolBotClient';
import { syncActivityCache } from './lib/Task';
import { assert, runTimedLoggedFn } from './lib/util';
import { CACHED_ACTIVE_USER_IDS, syncActiveUserIDs } from './lib/util/cachedUserIDs';
import { interactionHook } from './lib/util/globalInteractions';
Expand Down
7 changes: 3 additions & 4 deletions src/lib/DynamicButtons.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import {
import type {
BaseMessageOptions,
ButtonBuilder,
ButtonStyle,
DMChannel,
Message,
MessageComponentInteraction,
NewsChannel,
TextChannel,
ThreadChannel
} from 'discord.js';
import { noOp, Time } from 'e';
import { ButtonBuilder, ButtonStyle } from 'discord.js';
import { Time, noOp } from 'e';
import murmurhash from 'murmurhash';

import { BLACKLISTED_USERS } from './blacklists';
Expand Down
Loading

0 comments on commit e9fd7b7

Please sign in to comment.