diff --git a/.dockerignore b/.dockerignore index dc157ff1..9926a60d 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,7 +1,11 @@ # Include any files or directories that you don't want to be copied to your + # container here (e.g., local build artifacts, temporary files, etc.). + # + # For more help, visit the .dockerignore file reference guide at + # https://docs.docker.com/go/build-context-dockerignore/ **/.classpath @@ -17,12 +21,12 @@ **/.next **/.cache **/*.*proj.user -**/*.dbmdl -**/*.jfm +**/_.dbmdl +\*\*/_.jfm **/charts **/docker-compose* -**/compose.y*ml -**/Dockerfile* +\*\*/compose.y*ml +**/Dockerfile\* **/node_modules **/npm-debug.log **/obj diff --git a/.github/workflows/automaticTesting.yml b/.github/workflows/automaticTesting.yml index 5e021449..0ae2b2ed 100644 --- a/.github/workflows/automaticTesting.yml +++ b/.github/workflows/automaticTesting.yml @@ -11,11 +11,7 @@ on: # - mizuho-githubaction # Run on pull request targeting `mizuho-githubaction` branch jobs: -<<<<<<< HEAD - jest_test: -======= unit_tests: ->>>>>>> origin/mizuho-integration if: github.event_name == 'push' || github.event_name == 'pull_request' runs-on: ubuntu-latest @@ -29,13 +25,8 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v4 with: -<<<<<<< HEAD - node-version: ">=18" + node-version: "20" cache: "npm" -======= - node-version: '20' - cache: 'npm' ->>>>>>> origin/mizuho-integration - name: Install required system dependencies run: | @@ -46,8 +37,6 @@ jobs: run: | npm cache clean --force npm ci -<<<<<<< HEAD -======= - name: Set config file run: cp config.example.ts config.ts @@ -87,8 +76,8 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v4 with: - node-version: '20' - cache: 'npm' + node-version: "20" + cache: "npm" - name: Install required system dependencies run: | @@ -107,13 +96,3 @@ jobs: run: npx jest -c jest.config.js --no-cache --testMatch="**/*integration*.test.ts" env: MONGODB_URI: mongodb://test:test@localhost:27017/sage_test?authSource=admin ->>>>>>> origin/mizuho-integration - - - name: Set config file - run: cp config.example.ts config.ts - - - name: Show Jest config - run: npx jest --showConfig | sed -n '1,120p' - - - name: Run Jest tests (no cache) - run: npx jest -c jest.config.js --no-cache diff --git a/.github/workflows/dockerimage.yaml b/.github/workflows/dockerimage.yaml index a3064267..d3d7ea10 100644 --- a/.github/workflows/dockerimage.yaml +++ b/.github/workflows/dockerimage.yaml @@ -1,13 +1,8 @@ name: dockerimage #name of the workflow on: -<<<<<<< HEAD workflow_call: secrets: -======= - workflow_call: - secrets: ->>>>>>> origin/mizuho-integration DOCKER_USER: required: true DOCKER_PASSWORD: @@ -17,7 +12,6 @@ on: jobs: build-and-push: -<<<<<<< HEAD # Build & push Docker image only on push events (not PRs) and after tests if: github.event_name == 'push' runs-on: ubuntu-latest @@ -48,6 +42,7 @@ jobs: tags: | type=raw,value=test-bot,enable=${{ github.ref == 'refs/heads/mizuho-githubaction' }} type=sha,enable=true,format=long + - name: Build and push Docker image uses: docker/build-push-action@v6 with: @@ -58,46 +53,3 @@ jobs: labels: ${{ steps.meta.outputs.labels }} cache-from: type=registry,ref=docker.io/kevlund/sage-repo:buildcache cache-to: type=registry,ref=docker.io/kevlund/sage-repo:buildcache,mode=max -======= - # Build & push Docker image only on push events (not PRs) and after tests - if: github.event_name == 'push' - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Log in to Docker Hub - uses: docker/login-action@v3 - with: - registry: docker.io - # Ensure these secrets are defined in repository settings - username: ${{ secrets.DOCKER_USER }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Extract Docker metadata - id: meta - uses: docker/metadata-action@v5 - with: - images: | - docker.io/kevlund/sage-repo - tags: | - type=raw,value=test-bot,enable=${{ github.ref == 'refs/heads/mizuho-githubaction' }} - type=sha,enable=true,format=long - - - name: Build and push Docker image - uses: docker/build-push-action@v6 - with: - context: . - file: ./Dockerfile - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=registry,ref=docker.io/kevlund/sage-repo:buildcache - cache-to: type=registry,ref=docker.io/kevlund/sage-repo:buildcache,mode=max ->>>>>>> origin/mizuho-integration diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 9850819e..83dcf180 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -1,11 +1,7 @@ name: documentation on: -<<<<<<< HEAD workflow_call: -======= - workflow_call: ->>>>>>> origin/mizuho-integration # push: # branches: [ "main", "Ava-branch-config", "mizuho-githubaction" ] @@ -14,11 +10,6 @@ jobs: runs-on: ubuntu-latest steps: -<<<<<<< HEAD - - name: autodoc - run: echo "Not completed yet" - # run: npm run autodoc -======= - name: Checkout repository uses: actions/checkout@v4 with: @@ -27,8 +18,8 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: '20' - cache: 'npm' + node-version: "20" + cache: "npm" - name: Install dependencies run: npm ci @@ -52,4 +43,3 @@ jobs: Commands.md Staff Commands.md retention-days: 30 ->>>>>>> origin/mizuho-integration diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3b31b17d..9b0a84cc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,15 +2,9 @@ name: Main Pipeline on: push: -<<<<<<< HEAD - branches: ["main"] + branches: ["mizuho-githubaction", "Ava-branch-config", "main"] pull_request: - branches: ["main"] -======= - branches: [ "mizuho-integration" ] - pull_request: - branches: [ "mizuho-integration" ] ->>>>>>> origin/mizuho-integration + branches: ["mizuho-githubaction", "Ava-branch-config", "main"] env: DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} @@ -22,14 +16,6 @@ permissions: security-events: write actions: read -<<<<<<< HEAD -======= -permissions: - contents: read - security-events: write - actions: read - ->>>>>>> origin/mizuho-integration jobs: node: uses: ./.github/workflows/node.js.yml @@ -41,8 +27,4 @@ jobs: DOCKER_USER: ${{ secrets.DOCKER_USER }} DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} automaticTesting: -<<<<<<< HEAD uses: ./.github/workflows/automaticTesting.yml -======= - uses: ./.github/workflows/automaticTesting.yml ->>>>>>> origin/mizuho-integration diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 89eb2e67..70bd789e 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -11,27 +11,16 @@ jobs: runs-on: ubuntu-latest steps: -<<<<<<< HEAD - uses: actions/checkout@v4 with: fetch-depth: 0 ref: ${{ github.sha }} + - name: Use Node.js uses: actions/setup-node@v4 with: - node-version: ">=18" + node-version: "20" cache: "npm" -======= - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ github.sha }} - - name: Use Node.js - uses: actions/setup-node@v4 - with: - node-version: '20' - cache: 'npm' ->>>>>>> origin/mizuho-integration - name: Install required system dependencies run: | @@ -41,23 +30,19 @@ jobs: - run: npm cache clean --force - run: npm ci - # Add this step to copy config.example.ts to config.ts - name: Set config file run: cp config.example.ts config.ts - name: build run: | - npm run build 2>&1 | tee build-output.log + npm run build 2>&1 | tee build-output.log || true if grep -q "node_modules/discord.js/typings/index.d.ts" build-output.log; then echo "Ignoring build errors from node_modules/discord.js/typings/index.d.ts" - -<<<<<<< HEAD - sed -i '/node_modules\/discord\.js\/typings\/index\.d\.ts/d' build-output.log fi - if grep -q "Error" build-output.log; then - echo "Other build errors found. Failing the workflow." + if grep -i "error" build-output.log | grep -v "node_modules/discord.js/typings/index.d.ts"; then + echo "Build failed with unignored errors" exit 1 fi @@ -68,15 +53,6 @@ jobs: - name: Run tests (no cache) run: npx jest -c jest.config.js --no-cache -======= - echo "No unignored build errors found. Workflow continues." - - - name: Show Jest config - run: npx jest --showConfig | sed -n '1,120p' - - - name: Run tests (no cache) - run: npx jest -c jest.config.js --no-cache ->>>>>>> origin/mizuho-integration - # - name: Start Development - # run: npm run dev + # - name: Start Development + # run: npm run dev diff --git a/README.Docker.md b/README.Docker.md index 5a7ae362..90f55176 100644 --- a/README.Docker.md +++ b/README.Docker.md @@ -7,16 +7,19 @@ Your application will be available at http://localhost:8080. ### Deploying your application to the cloud -First, build your image, e.g.: `docker build -t myapp .`. -If your cloud uses a different CPU architecture than your development -machine (e.g., you are on a Mac M1 and your cloud provider is amd64), -you'll want to build the image for that platform, e.g.: -`docker build --platform=linux/amd64 -t myapp .`. +First, build your image: `docker build -t myapp .` -Then, push it to your registry, e.g. `docker push myregistry.com/myapp`. +If your cloud uses a different CPU architecture than your development machine +(e.g., you are on a Mac M1 and your cloud provider is amd64),\ +you'll want to build the image for that platform: +`docker build --platform=linux/amd64 -t myapp .` + +Then, push it to your registry: +`docker push myregistry.com/myapp` Consult Docker's [getting started](https://docs.docker.com/go/get-started-sharing/) docs for more detail on building and pushing. ### References -* [Docker's Node.js guide](https://docs.docker.com/language/nodejs/) \ No newline at end of file + +- [Docker's Node.js guide](https://docs.docker.com/language/nodejs/) diff --git a/README.md b/README.md index 796261fe..b0ffd63f 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,20 @@ # Sage + ![GitHub package.json version](https://img.shields.io/github/package-json/v/ud-cis-discord/sagev2?color=000855) ![We use Typescript](https://img.shields.io/badge/written_in-typescript-000855?logo=typescript&logoColor=ddd) ![GitHub Workflow Status](https://img.shields.io/github/workflow/status/ud-cis-discord/sagev2/Lint?color=000855&logo=github) ![GitHub repo size](https://img.shields.io/github/repo-size/ud-cis-discord/sagev2?color=000855&logo=github) ![Lines of code](https://img.shields.io/tokei/lines/github/ud-cis-discord/sagev2?color=000855&logo=github) Sage is a purpose build Discord bot to manage the UD CIS Discord server. Sage features a number of systems to encourage engagement and help facilitate learning.
Some features of sage include: + - 🧙‍♂️ Self-assignable roles - 🎫 Question tagging so you can easily find questions others have asked - 🐱‍👤 Private and anonymous questions - 🔥 and many more! -Sage was originally created by: +Sage was originally created by: |

Ben Segal
|

Josh Lyon
|

Ren Ross
|-|-|- Sage is currently maintained by: -|

Simon Brugel
|

Matt Nadar
|

Leo Chen
+|

Simon Brugel
|

Matt Nadar
|

Leo Chen
|-|-|- diff --git a/autodoc/writecommands.ts b/autodoc/writecommands.ts index 926b0934..ed803763 100644 --- a/autodoc/writecommands.ts +++ b/autodoc/writecommands.ts @@ -40,7 +40,7 @@ commands in staff-only channels. async function main() { const categories = new Map(); - const commandFiles = readdirRecursive(`${__dirname}/../src/commands`).filter(file => file.endsWith('.js')); + const commandFiles = readdirRecursive(`${__dirname}/../src/commands`).filter((file: string) => file.endsWith('.js')); for (const file of commandFiles) { const commandModule = await import(file); @@ -64,7 +64,7 @@ async function main() { if (!categories.has(command.category)) { const catWords = command.category.split(' '); - const formattedCat = catWords.map(word => word[0].toUpperCase() + word.substring(1)).join(' '); + const formattedCat = catWords.map((word: string) => word[0].toUpperCase() + word.substring(1)).join(' '); categories.set(command.category, `### ${formattedCat} Commands`); } @@ -74,11 +74,15 @@ async function main() { newCatText += command.extendedHelp ? `\n- More info: ${command.extendedHelp}\n` : ``; if (command.options) { newCatText += '\n- Parameters:\n'; - newCatText += command.options.map(param => + const formattedOptions = command.options.map((param) => { + const required = 'required' in param ? param.required : undefined; + const requiredText = required === undefined ? '' : ` (${required ? 'required' : 'optional'})`; // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore: see Note 1 comment block in help.ts - ` - ${param.name} (${param.required ? 'required' : 'optional'}): ${param.description}` - ).join('\n'); + const description = 'description' in param ? param.description : ''; + return ` - ${param.name}${requiredText}: ${description}`; + }); + newCatText += formattedOptions.join('\n'); } categories.set(command.category, newCatText); } diff --git a/k8s/sage-secret.yaml b/k8s/sage-secret.yaml index 0763bfe4..e67a0c3b 100644 --- a/k8s/sage-secret.yaml +++ b/k8s/sage-secret.yaml @@ -4,7 +4,6 @@ metadata: name: sage-secrets type: Opaque data: - API_KEY: TWl6dWhvMDQwMg== + API_KEY: TWl6dWhvMDQwMg== # change this value # echo -n "Mizuho0402" | base64 - diff --git a/onboard/nudge.ts b/onboard/nudge.ts index 04b2cb57..1b2ebe36 100644 --- a/onboard/nudge.ts +++ b/onboard/nudge.ts @@ -1,5 +1,5 @@ import 'module-alias/register'; -import { MongoClient, ObjectID } from 'mongodb'; +import { MongoClient, ObjectId } from 'mongodb'; import nodemailer from 'nodemailer'; import { SageUser } from '@lib/types/SageUser'; import { DB, BOT, EMAIL, GUILDS } from '@root/config'; @@ -94,7 +94,7 @@ function sleep(ms: number) { } interface DatabaseUser extends SageUser { - _id: ObjectID + _id: ObjectId } main(); diff --git a/package.json b/package.json index c5cab994..a98ef5f2 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "type": "git", "url": "git+https://github.com/ud-cis-discord/SageV2.git" }, - "author": "Matt Nadar, Leo Chen, Simon Brugel, Blade Tyrrell, Josh Lyon, Ren Ross, Ben Segal, Jared Miller, Marc Madlangbayan, Kevin Lundin, Caden Keen, Mizuho Okitani, Egor Prasolov, Ronald Kouloun, Wesley _", + "author": "Matt Nadar, Leo Chen, Simon Brugel, Blade Tyrrell, Josh Lyon, Ren Ross & Ben Segal", "license": "MIT", "bugs": { "url": "https://github.com/ud-cis-discord/SageV2/issues" diff --git a/tsconfig.json b/tsconfig.json index 12918463..0bd79405 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -17,7 +17,7 @@ "types": ["node", "discord.js", "jest"], "module": "commonjs" }, - "include": ["config.ts", "src/**/*"], + "include": ["config.ts", "src/**/*", "onboard/**/*", "autodoc/**/*"], "exclude": [ "**/node_modules", "**/node_modules/discord.js/typings/index.d.ts", // problematic in djs versions >13.1