Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/typescript-5.6.3
Browse files Browse the repository at this point in the history
  • Loading branch information
cobaltt7 authored Oct 26, 2024
2 parents 015db00 + 2d4df93 commit 937f1c5
Show file tree
Hide file tree
Showing 18 changed files with 89 additions and 308 deletions.
30 changes: 15 additions & 15 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@ appropriate issue number. That will cause GitHub to automatically close the issu
Please:

- Minimize the number of `@ts-` comments you use, and if you must use one, use `@ts-expect-error`.
- Format your code by using `npm run format` before pushing. If you don’t, it may be automatically run in the
- Format your code by using `node --run format` before pushing. If you don’t, it may be automatically run in the
workflow.
- Lint your code by using `npm run lint`. No lint errors may be present when your PR is merged. Warnings may be
allowed depending on the context. Some lint errors may be fixed automatically with `npm run lint -- --fix`, but it
is important to manually confirm it worked as intended. The workflow fails if any errors are present.
- Rerun the unit tests by using `npm run test`. Make sure the unit tests continue to succeed. No tests may fail when
your PR is merged. We would also very much appreciate any new tests you add if you could. We use the Node.js native
test runner for tests.

To test your code, it’s easiest to run `npm run serve & npm run dev` in my opinion. That runs both TypeScript and
nodemon on watch mode, to attempt to rebuild your code on every change, and to restart the bot on every successful
build. Using this setup, you hardly ever need to touch the terminal, and there's only one place you need to look for
error logs.

Before committing your code, it is necessary to run `npm run format`, then `npm run lint` and fix any lint errors,
finally `npm run test` and fix any failing tests, then repeat all three until no more lint errors are left.
- Lint your code by using `node --run lint`. No lint errors may be present when your PR is merged. Warnings may be
allowed depending on the context. Some lint errors may be fixed automatically with `node --run lint -- --fix`, but
it is important to manually confirm it worked as intended. The workflow fails if any errors are present.
- Rerun the unit tests by using `node --run test`. Make sure the unit tests continue to succeed. No tests may fail
when your PR is merged. We would also very much appreciate any new tests you add if you could. We use the Node.js
native test runner for tests.

To test your code, it’s easiest to run `node --run serve & node --run dev` in my opinion. That runs both TypeScript and
Node on watch mode, to attempt to rebuild your code on every change, and to restart the bot on every successful build.
Using this setup, you hardly ever need to touch the terminal, and there's only one place you need to look for error
logs.

Before committing your code, it is necessary to run `node --run format`, then `node --run lint` and fix any lint errors,
finally `node --run test` and fix any failing tests, then repeat all three until no more lint errors are left.
2 changes: 1 addition & 1 deletion .github/workflows/bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Setup Node.JS
uses: actions/[email protected]
with:
node-version: 20.6.0
node-version: 22.10.0
cache: npm

- name: Bump Twemoji
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup Node.JS
uses: actions/[email protected]
with:
node-version: 20.6.0
node-version: 22.10.0
cache: npm

- name: Download bad words
Expand Down Expand Up @@ -49,8 +49,8 @@ jobs:

- name: Deploy
run:
npx railway up --detach --service afdb8def-13c6-4650-af4e-ef60d2009b56
--environment production
npx railway up --ci --service afdb8def-13c6-4650-af4e-ef60d2009b56 --environment
production
env:
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}

Expand Down
13 changes: 7 additions & 6 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,21 @@ jobs:
- name: Checkout
uses: actions/[email protected]
with:
token: ${{ secrets.TOKEN }}
ref: ${{ github.head_ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}

- name: Setup Node.JS
uses: actions/[email protected]
with:
node-version: 20.6.0
node-version: 22.10.0
cache: npm

- name: Install
run: npm ci

- name: Format
run: npm run format
run: node --run format

- name: Assert clean
if: startsWith(github.ref_name, 'dependabot/') == true
Expand Down Expand Up @@ -74,14 +75,14 @@ jobs:
- name: Setup Node.JS
uses: actions/[email protected]
with:
node-version: 20.6.0
node-version: 22.10.0
cache: npm

- name: Install
run: npm ci

- name: Build & Test
run: npm run test
run: node --run test

lint:
name: Lint
Expand All @@ -97,11 +98,11 @@ jobs:
- name: Setup Node.JS
uses: actions/[email protected]
with:
node-version: 20.6.0
node-version: 22.10.0
cache: npm

- name: Install
run: npm ci

- name: Lint
run: npm run lint
run: node --run lint
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Pull requests are welcome if you would like to help contribute. Please read thro

### Set up the repository locally

1. Download [git](https://git-scm.com) and [Node.js](https://nodejs.org) if you haven’t already.
1. Download [git](https://git-scm.com) and [Node.js](https://nodejs.org) (v22.10+) if you haven’t already.
2. Clone the repository using the `git clone` command.
3. Install dependencies with `npm install`.
4. Set up the .env file as described in
Expand All @@ -69,10 +69,10 @@ to this bot but could be useful in other apps as well.

Scradd has a couple of dev commands to streamline your coding.

- `npm run build`: One-time build with TypeScript
- `npm run start`: Run the bot
- `npm run dev`: Rebuild with TypeScript on each code change
- `npm run serve`: Run the bot and restart with nodemon on each successful build
- `npm run format`: Format code with Prettier
- `npm run lint`: Lint code with ESLint
- `npm run test`: Run unit tests with the Node.js native test runner
- `node --run build`: One-time build with TypeScript
- `node --run start`: Run the bot
- `node --run dev`: Rebuild with TypeScript on each code change
- `node --run serve`: Run the bot and restart on each successful build
- `node --run format`: Format code with Prettier
- `node --run lint`: Lint code with ESLint
- `node --run test`: Run unit tests with the Node.js native test runner
2 changes: 1 addition & 1 deletion common/constants.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import addons from "@sa-community/addons-data" assert { type: "json" };
import addons from "@sa-community/addons-data" with { type: "json" };
import { matchSorter } from "match-sorter";
import { strictEqual } from "node:assert";
import { describe, it } from "node:test";
Expand Down
2 changes: 1 addition & 1 deletion common/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import addons from "@sa-community/addons-data" assert { type: "json" };
import addons from "@sa-community/addons-data" with { type: "json" };

const domains = {
npm: "https://npmjs.com/package",
Expand Down
2 changes: 1 addition & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import dns from "node:dns";
import { fileURLToPath } from "node:url";
import { client, login } from "strife.js";
import constants from "./common/constants.js";
import pkg from "./package.json" assert { type: "json" };
import pkg from "./package.json" with { type: "json" };
import features from "./common/features.js";

dns.setDefaultResultOrder("ipv4first");
Expand Down
4 changes: 2 additions & 2 deletions modules/addon.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import addons from "@sa-community/addons-data" assert { type: "json" };
import scratchAddons from "@sa-community/addons-data/manifest.json" assert { type: "json" };
import addons from "@sa-community/addons-data" with { type: "json" };
import scratchAddons from "@sa-community/addons-data/manifest.json" with { type: "json" };
import {
ApplicationCommandOptionType,
ButtonStyle,
Expand Down
2 changes: 1 addition & 1 deletion modules/bot/credits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
import { client } from "strife.js";
import config from "../../common/config.js";
import constants from "../../common/constants.js";
import pkg from "../../package.json" assert { type: "json" };
import pkg from "../../package.json" with { type: "json" };
import { columnize } from "../../util/discord.js";
import { joinWithAnd } from "../../util/text.js";
import { mentionUser } from "../settings.js";
Expand Down
2 changes: 1 addition & 1 deletion modules/bot/status.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TimestampStyles, time, type ChatInputCommandInteraction } from "discord.js";
import { client } from "strife.js";
import constants from "../../common/constants.js";
import pkg from "../../package.json" assert { type: "json" };
import pkg from "../../package.json" with { type: "json" };

export default async function status(interaction: ChatInputCommandInteraction): Promise<void> {
const message = await interaction.deferReply({ fetchReply: true });
Expand Down
2 changes: 1 addition & 1 deletion modules/forms/appeals/show-appeal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import type { IncomingMessage, ServerResponse } from "node:http";
import { client } from "strife.js";
import config from "../../../common/config.js";
import constants from "../../../common/constants.js";
import pkg from "../../../package.json" assert { type: "json" };
import pkg from "../../../package.json" with { type: "json" };
import { stripMarkdown } from "../../../util/markdown.js";
import { getRequestUrl } from "../../../util/text.js";
import { strikeDatabase } from "../../punishments/util.js";
Expand Down
4 changes: 2 additions & 2 deletions modules/games/addon-questions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import addons from "@sa-community/addons-data" assert { type: "json" };
import scratchAddons from "@sa-community/addons-data/manifest.json" assert { type: "json" };
import addons from "@sa-community/addons-data" with { type: "json" };
import scratchAddons from "@sa-community/addons-data/manifest.json" with { type: "json" };
import constants from "../../common/constants.js";
import { escapeMessage } from "../../util/markdown.js";
import { trimPatchVersion } from "../../util/text.js";
Expand Down
4 changes: 2 additions & 2 deletions modules/games/guess-addon.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import addons from "@sa-community/addons-data" assert { type: "json" };
import scratchAddons from "@sa-community/addons-data/manifest.json" assert { type: "json" };
import addons from "@sa-community/addons-data" with { type: "json" };
import scratchAddons from "@sa-community/addons-data/manifest.json" with { type: "json" };
import {
ButtonStyle,
ComponentType,
Expand Down
2 changes: 1 addition & 1 deletion modules/punishments/ban.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import { client } from "strife.js";
import config from "../../common/config.js";
import constants from "../../common/constants.js";
import pkg from "../../package.json" assert { type: "json" };
import pkg from "../../package.json" with { type: "json" };
import { disableComponents } from "../../util/discord.js";
import { escapeMessage } from "../../util/markdown.js";
import { parseTime } from "../../util/numbers.js";
Expand Down
Loading

0 comments on commit 937f1c5

Please sign in to comment.