chore: switch to pnpm and remove DISCORD_APP

This commit is contained in:
Ryan Cao 2023-06-05 18:13:48 +08:00
parent 930d7bca12
commit cb16991417
No known key found for this signature in database
10 changed files with 1692 additions and 1657 deletions

View file

@ -1,2 +1,6 @@
node_modules/ node_modules/
.git .git/
.env
.env.*
!.env.example

View file

@ -1,4 +1,2 @@
DISCORD_TOKEN= DISCORD_TOKEN=
DISCORD_APP=
SAY_LOGS_CHANNEL= SAY_LOGS_CHANNEL=

View file

@ -1,11 +1,23 @@
name: Lint name: Lint
on: [push] on:
push:
pull_request:
jobs: jobs:
lint: lint:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - name: Checkout repository
- run: yarn install --frozen-lockfile uses: actions/checkout@v3
- run: yarn lint - name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 20
- name: Install pnpm
uses: pnpm/action-setup@v2
- name: Install dependencies
run: pnpm install
- name: Lint
run: pnpm run lint

9
.gitignore vendored
View file

@ -1,11 +1,10 @@
node_modules/ node_modules/
/index.js
dist
.env .env
.env.local .env.*
.direnv !.env.example
.direnv/
.pre-commit-config.yaml .pre-commit-config.yaml
eslint_report.json eslint_report.json

View file

@ -1,6 +1,11 @@
FROM docker.io/library/node:19-alpine FROM docker.io/library/node:20-alpine
RUN corepack enable
RUN corepack prepare pnpm@latest --activate
WORKDIR /app WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile COPY package.json pnpm-lock.yaml .
RUN pnpm install
COPY . . COPY . .
CMD [ "yarn", "start" ] CMD [ "pnpm", "run", "start" ]

View file

@ -28,5 +28,6 @@
"gray-matter": "4.0.3", "gray-matter": "4.0.3",
"prettier": "2.8.8", "prettier": "2.8.8",
"typescript": "5.1.3" "typescript": "5.1.3"
} },
"packageManager": "pnpm@8.6.0"
} }

1641
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,9 @@
import { SlashCommandBuilder, Routes, PermissionFlagsBits } from 'discord.js'; import {
SlashCommandBuilder,
Routes,
PermissionFlagsBits,
type RESTGetAPIOAuth2CurrentApplicationResult,
} from 'discord.js';
import { REST } from '@discordjs/rest'; import { REST } from '@discordjs/rest';
import { getTags } from './tags'; import { getTags } from './tags';
@ -62,7 +67,11 @@ export const reuploadCommands = async () => {
const rest = new REST({ version: '10' }).setToken(process.env.DISCORD_TOKEN!); const rest = new REST({ version: '10' }).setToken(process.env.DISCORD_TOKEN!);
await rest.put(Routes.applicationCommands(process.env.DISCORD_APP!), { const { id: appId } = (await rest.get(
Routes.oauth2CurrentApplication()
)) as RESTGetAPIOAuth2CurrentApplicationResult;
await rest.put(Routes.applicationCommands(appId), {
body: commands, body: commands,
}); });

View file

@ -1,13 +1,13 @@
{ {
"compilerOptions": { "compilerOptions": {
"strict": true, "strict": true,
"esModuleInterop": true,
"downlevelIteration": true, "downlevelIteration": true,
"module": "esnext", "module": "esnext",
"target": "ES2018", "target": "esnext",
"moduleResolution": "node", "moduleResolution": "node",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,
"rootDir": "src", "skipLibCheck": true,
"outDir": "dist" "noEmit": true
} }
} }

1634
yarn.lock

File diff suppressed because it is too large Load diff