Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
feat: initial commit 🎉
Browse files Browse the repository at this point in the history
Signed-off-by: Glenn <[email protected]>
  • Loading branch information
promise committed Mar 31, 2024
0 parents commit 7073cbb
Show file tree
Hide file tree
Showing 53 changed files with 7,313 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/build
/database
/logs
/node_modules
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text eol=crlf
7 changes: 7 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": [
"github>promise/renovate-config",
"github>promise/renovate-config:force-node-version(18)",
"github>promise/renovate-config:force-mongo-version(4)"
]
}
24 changes: 24 additions & 0 deletions .github/workflows/docker-compose-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Docker Compose

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
name: Test Build
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4

- name: Touch .env file
run: touch ".env"

- name: Test docker compose build
run: docker compose build
27 changes: 27 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Docker Image

on:
push:
workflow_dispatch:

jobs:
ghcr:
name: ${{ github.ref == 'refs/heads/main' && 'Build and Push' || 'Test Build' }}
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4

- name: Login to ghcr.io
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: ${{ github.ref == 'refs/heads/main' && 'Build and Push' || 'Test Build' }}
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5
with:
push: ${{ github.ref == 'refs/heads/main' }}
tags: ghcr.io/project-blurple/april-fools-2024:latest
35 changes: 35 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Linting

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
eslint:
name: ESLint
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4

- name: Set up pnpm
uses: pnpm/action-setup@v2
with:
version: 8

- name: Set up node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4
with:
node-version-file: ".nvmrc"
cache: "pnpm"

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Run ESLint
run: pnpm lint
35 changes: 35 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Testing

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
jest:
name: Jest
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4

- name: Set up pnpm
uses: pnpm/action-setup@v2
with:
version: 8

- name: Set up node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4
with:
node-version-file: ".nvmrc"
cache: "pnpm"

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Run Jest
run: pnpm test
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/build
/database
/logs
/node_modules
/.env
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
auto-install-peers=true
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20.12.0
9 changes: 9 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"recommendations": [
"aaron-bond.better-comments",
"mikestead.dotenv",
"dbaeumer.vscode-eslint",
"christian-kohler.npm-intellisense",
"meganrogge.template-string-converter",
]
}
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true,
"eslint.format.enable": true,
"typescript.tsdk": "node_modules/typescript/lib"
}
40 changes: 40 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM node:20-alpine@sha256:ef3f47741e161900ddd07addcaca7e76534a9205e4cd73b2ed091ba339004a75 AS base
RUN apk --no-cache add g++ gcc make python3

WORKDIR /app
ENV IS_DOCKER=true


# install prod dependencies

FROM base AS deps
RUN npm install -g pnpm@8

COPY package.json ./
COPY pnpm-lock.yaml ./

RUN pnpm install --frozen-lockfile --prod


# install all dependencies and build typescript

FROM deps AS ts-builder
RUN pnpm install --frozen-lockfile

COPY tsconfig.json ./
COPY ./src ./src
RUN pnpm run build


# production image

FROM base

COPY .env* ./
COPY --from=deps /app/node_modules ./node_modules
COPY --from=ts-builder /app/build ./build
COPY package.json ./

ENV NODE_ENV=production
ENTRYPOINT [ "npm", "run" ]
CMD [ "start" ]
19 changes: 19 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: '3'

services:
bot:
build: .
restart: always
environment:
- DATABASE_URI=mongodb://db
ports:
- ${PORT}:${PORT}
volumes:
- ./logs:/app/logs
depends_on:
- db
db:
image: mongo:4@sha256:ce3d0eade688a2299e9e20454efc561a6fc8de1cbde5abb0f50feadfe758037b
restart: always
volumes:
- ./database:/data/db
11 changes: 11 additions & 0 deletions example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CLIENT_ID=
CLIENT_SECRET=
CLIENT_TOKEN=

OWNER_ID=
GUILD_ID=

THEME_COLOR=5865F2

PORT=
URL=
62 changes: 62 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"name": "april-fools-2024",
"main": "build",
"scripts": {
"build": "tsc",
"build:watch": "tsc -w",
"docker": "npm run docker:build && npm run docker:up",
"docker:build": "docker-compose --project-directory . build",
"docker:down": "docker-compose --project-directory . down",
"docker:logs": "docker-compose --project-directory . logs --tail=500 -f",
"docker:start": "npm run docker:up",
"docker:stop": "npm run docker:down",
"docker:up": "docker-compose --project-directory . up -d",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"start": "node .",
"test": "jest"
},
"dependencies": {
"@sapphire/type": "2.4.4",
"@typegoose/typegoose": "12.2.0",
"bufferutil": "4.0.8",
"dedent": "1.5.1",
"discord-oauth2": "2.12.1",
"discord.js": "14.14.1",
"dotenv": "16.4.5",
"erlpack": "github:discord/erlpack",
"express": "4.19.2",
"mongoose": "8.2.4",
"sentiment": "5.0.2",
"superagent": "8.1.2",
"utf-8-validate": "6.0.3",
"winston": "3.13.0",
"winston-daily-rotate-file": "5.0.0",
"zlib-sync": "0.1.9"
},
"devDependencies": {
"@tsconfig/node20": "20.1.4",
"@tsconfig/strictest": "2.0.5",
"@types/express": "4.17.21",
"@types/jest": "29.5.12",
"@types/node": "20.12.2",
"@types/sentiment": "5.0.4",
"@types/superagent": "8.1.6",
"eslint": "8.57.0",
"eslint-config-promise": "github:promise/eslint-config",
"jest": "29.7.0",
"ts-jest": "29.1.2",
"typescript": "5.4.3"
},
"eslintConfig": {
"extends": "promise"
},
"jest": {
"preset": "ts-jest",
"testEnvironment": "node",
"testPathIgnorePatterns": [
"<rootDir>/build/",
"<rootDir>/node_modules/"
]
}
}
Loading

0 comments on commit 7073cbb

Please sign in to comment.