Skip to content

Commit

Permalink
Merge branch 'main' into refactor/deprecate-errors
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] committed Sep 17, 2023
2 parents 22f4900 + b6a2441 commit 185fa84
Show file tree
Hide file tree
Showing 358 changed files with 27,076 additions and 29,540 deletions.
1 change: 1 addition & 0 deletions .commitlintrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "https://json.schemastore.org/commitlintrc.json",
"extends": ["@commitlint/config-angular"],
"rules": {
"type-enum": [
Expand Down
11 changes: 0 additions & 11 deletions .eslintrc.json

This file was deleted.

21 changes: 10 additions & 11 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,36 @@ is a great boon to your development process.
To get ready to work on the codebase, please do the following:

1. Fork & clone the repository, and make sure you're on the **main** branch
2. Run `yarn --immutable` ([install](https://yarnpkg.com/getting-started/install))
3. Run `yarn build` to build local packages
2. Run `pnpm install --frozen-lockfile` ([install](https://pnpm.io/installation))
3. Run `pnpm run build` to build local packages
4. Code your heart out!
5. Run `yarn test` to run ESLint and ensure any JSDoc changes are valid
5. Run `pnpm run test` to run ESLint and ensure any JSDoc changes are valid
6. [Submit a pull request](https://github.com/discordjs/discord.js/compare) (Make sure you follow the [conventional commit format](https://github.com/discordjs/discord.js/blob/main/.github/COMMIT_CONVENTION.md))

## Testing changes locally

If you want to test changes you've made locally, you can do so by using `yarn link`. This will create a symlink to your local copy of the discord.js libraries.
If you want to test changes you've made locally, you can do so by using `pnpm link <package-you-want-to-link-to-your-current-package>`. This will create a symlink to your local copy of the discord.js libraries.

1. Create a new directory `mkdir discordjs-test` and move into it `cd discordjs-test`
2. Initialize a new yarn 3 project `yarn init -2`
3. Disable pnp `yarn config set nodeLinker node-modules`
4. Now link the local discord.js project you cloned earlier `yarn link -A {PATH_TO_DISCORDJS_REPO}`
5. Install packages you'd like to test locally `yarn add discord.js@latest`, `yarn add @discordjs/rest@latest`, etc. **Note: Make sure you use `latest` tag or else yarn will try to install the remote package from npm**
6. Import the package in your source code and test them out!
2. Initialize a new pnpm project `pnpm init`
3. Now link the local discord.js project you cloned earlier `pnpm link {PATH_TO_DISCORDJS_REPO}`
4. Install packages you'd like to test locally `pnpm add discord.js@latest`, `pnpm add @discordjs/rest@latest`, etc. **Note: Make sure you use `latest` tag or else pnpm will try to install the remote package from npm**
5. Import the package in your source code and test them out!

### Working with TypeScript packages

When testing local changes, you may notice you need to manually recompile TypeScript projects on every change in order to get the latest code changes to test locally.

To avoid this you can use the `--watch` parameter in the package build script to automatically recompile the project when changes are detected.

For example, to automatically recompile the `@discordjs/rest` project when changes are detected, run `yarn turbo run build --filter=@discordjs/rest -- --watch` in the root folder of where you cloned the discord.js repo.
For example, to automatically recompile the `@discordjs/rest` project when changes are detected, run `pnpm turbo run build --filter='@discordjs/rest' -- --watch` in the root folder of where you cloned the discord.js repo.

## Adding new packages

If you'd like to create another package under the `@discordjs` organization run the following command:

```sh
yarn create-package <package-name> [package-description]
pnpm run create-package <package-name> [package-description]
```

This will create new package directory under `packages/` with the required configuration files. You can
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/cleanup-cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#force-deleting-cache-entries
name: Cleanup caches
on:
pull_request:
types:
- closed
workflow_dispatch:
jobs:
cleanup:
name: Cleanup caches
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Cleanup caches
run: |
gh extension install actions/gh-actions-cache
REPO=${{ github.repository }}
BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"
echo "Fetching list of cache key"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 )
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7 changes: 4 additions & 3 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
- 'main'
paths:
- 'packages/*/src/**'
- '!packages/create-discord-bot/**'
tags:
- '**'
workflow_dispatch:
Expand Down Expand Up @@ -42,13 +43,13 @@ jobs:
node-version: 18

- name: Install dependencies
uses: ./packages/actions/src/yarnCache
uses: ./packages/actions/src/pnpmCache

- name: Build dependencies
run: yarn build
run: pnpm run build

- name: Build docs
run: yarn docs
run: pnpm run docs

- name: Checkout docs repository
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/issue-triage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
issue-triage:
runs-on: ubuntu-latest
steps:
- uses: github/issue-labeler@v3.1
- uses: github/issue-labeler@v3.2
with:
repo-token: '${{ secrets.GITHUB_TOKEN }}'
configuration-path: .github/issue-labeler.yml
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lighthouse-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:

- name: Audit production URLs with Lighthouse
id: lighthouse_audit
uses: treosh/lighthouse-ci-action@v9
uses: treosh/lighthouse-ci-action@v10
with:
urls: |
https://discordjs.dev
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lighthouse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- name: Audit preview URL with Lighthouse
if: ${{ steps.get_preview_url.outputs.vercel_preview_url != '' }}
id: lighthouse_audit
uses: treosh/lighthouse-ci-action@v9
uses: treosh/lighthouse-ci-action@v10
with:
urls: |
${{ steps.get_preview_url.outputs.vercel_preview_url }}
Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:
' ',
`*Lighthouse ran on [${Object.keys(links)[0]}](${Object.keys(links)[0]})*`
].join('\n')
core.setOutput("comment", comment);
core.setOutput("comment", comment);
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Add comment to PR
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/npm-auto-deprecate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
node-version: 18

- name: Install dependencies
uses: ./packages/actions/src/yarnCache
uses: ./packages/actions/src/pnpmCache

- name: Deprecate versions
run: 'yarn npm-deprecate --name "*dev*" --package @discordjs/brokers @discordjs/builders @discordjs/collection @discordjs/core @discordjs/formatters discord.js @discordjs/next @discordjs/proxy @discordjs/rest @discordjs/util @discordjs/voice @discordjs/ws'
run: 'pnpm exec npm-deprecate --name "*dev*" --package @discordjs/brokers @discordjs/builders @discordjs/collection @discordjs/core @discordjs/formatters discord.js @discordjs/next @discordjs/proxy @discordjs/rest @discordjs/util @discordjs/voice @discordjs/ws'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
7 changes: 2 additions & 5 deletions .github/workflows/publish-dev-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ jobs:
node-version: 18

- name: Install dependencies
uses: ./packages/actions/src/yarnCache

- name: Build dependencies
run: yarn build
uses: ./packages/actions/src/pnpmCache

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
Expand All @@ -30,4 +27,4 @@ jobs:
run: echo ${{ secrets.DOCKER_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin

- name: Build & push docker image
run: yarn docker build --buildkit @discordjs/proxy-container -t discordjs/proxy:latest --push
run: docker build -f packages/proxy-container/Dockerfile -t discordjs/proxy:latest --push .
10 changes: 5 additions & 5 deletions .github/workflows/publish-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ jobs:
registry-url: https://registry.npmjs.org/

- name: Install dependencies
uses: ./packages/actions/src/yarnCache
uses: ./packages/actions/src/pnpmCache

- name: Build dependencies
run: yarn build
run: pnpm run build

- name: Publish package
run: |
yarn workspace ${{ matrix.package }} release --preid "dev.$(date +%s)-$(git rev-parse --short HEAD)"
yarn workspace ${{ matrix.package }} npm publish --tag dev || true
pnpm --filter=${{ matrix.package }} run release --preid "dev.$(date +%s)-$(git rev-parse --short HEAD)"
pnpm --filter=${{ matrix.package }} publish --no-git-checks --tag dev || true
env:
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
7 changes: 2 additions & 5 deletions .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ jobs:
node-version: 18

- name: Install dependencies
uses: ./packages/actions/src/yarnCache

- name: Build dependencies
run: yarn build
uses: ./packages/actions/src/pnpmCache

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
Expand All @@ -27,4 +24,4 @@ jobs:
run: echo ${{ secrets.DOCKER_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin

- name: Build & push docker image
run: yarn docker build --buildkit @discordjs/proxy-container -t discordjs/proxy:$(cut -d '.' -f1 <<< $(jq --raw-output '.version' packages/proxy-container/package.json)) --push
run: docker build -f packages/proxy-container/Dockerfile -t discordjs/proxy:$(cut -d '.' -f1 <<< $(jq --raw-output '.version' packages/proxy-container/package.json)) --push .
8 changes: 4 additions & 4 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
registry-url: https://registry.npmjs.org/

- name: Install dependencies
uses: ./packages/actions/src/yarnCache
uses: ./packages/actions/src/pnpmCache

- name: Build dependencies
run: yarn build
run: pnpm run build

- name: Extract package and semver from tag
id: extract-tag
Expand All @@ -34,6 +34,6 @@ jobs:

- name: Publish package
run: |
yarn workspace ${{ steps.extract-tag.outputs.subpackage == 'true' && '@discordjs/' || '' }}${{ steps.extract-tag.outputs.package }} npm publish
pnpm --filter=${{ steps.extract-tag.outputs.subpackage == 'true' && '@discordjs/' || '' }}${{ steps.extract-tag.outputs.package }} publish
env:
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
NPM_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
18 changes: 9 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,39 +25,39 @@ jobs:
node-version: 18

- name: Install dependencies
uses: ./packages/actions/src/yarnCache
uses: ./packages/actions/src/pnpmCache

- name: Build dependencies (PR)
if: ${{ github.event_name != 'push' }}
run: yarn build --filter="...[origin/${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || 'main' }}]"
run: pnpm exec turbo run build --filter="...[origin/${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || 'main' }}]" --concurrency=4

- name: Build dependencies (Push)
if: ${{ github.event_name == 'push' }}
run: yarn build --filter="...[HEAD^1]"
run: pnpm exec turbo run build --filter="...[HEAD^1]" --concurrency=4

- name: ESLint (PR)
if: ${{ github.event_name != 'push' }}
run: yarn lint --filter="...[origin/${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || 'main' }}]" -- --format=compact
run: pnpm exec turbo run lint --filter="...[origin/${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || 'main' }}]" --concurrency=4 -- --format=compact

- name: ESLint (Push)
if: ${{ github.event_name == 'push' }}
run: yarn lint --filter="...[HEAD^1]" -- --format=compact
run: pnpm exec turbo run lint --filter="...[HEAD^1]" --concurrency=4 -- --format=compact

- name: Tests (PR)
if: ${{ github.event_name != 'push' }}
run: yarn test --filter="...[origin/${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || 'main' }}]"
run: pnpm exec turbo run test --filter="...[origin/${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || 'main' }}]" --concurrency=4

- name: Tests (Push)
if: ${{ github.event_name == 'push' }}
run: yarn test --filter="...[HEAD^1]"
run: pnpm exec turbo run test --filter="...[HEAD^1]" --concurrency=4

- name: Docs (PR)
if: ${{ github.event_name != 'push' }}
run: yarn docs --filter="...[origin/${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || 'main' }}]"
run: pnpm exec turbo run docs --filter="...[origin/${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || 'main' }}]" --concurrency=4

- name: Docs (Push)
if: ${{ github.event_name == 'push' }}
run: yarn docs --filter="...[HEAD^1]"
run: pnpm exec turbo run docs --filter="...[HEAD^1]" --concurrency=4

- name: Upload Coverage
if: github.repository_owner == 'discordjs'
Expand Down
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dist-docs

# Miscellaneous
.tmp
.vscode
.vscode/*
!.vscode/extensions.json
!.vscode/settings.json
.idea
Expand All @@ -29,6 +29,15 @@ dist-docs
tsconfig.tsbuildinfo
coverage
out
package.tgz
tsup.config.bundled*
vitest.config.ts.timestamp*

# Deno
deno.lock

# Bun
bun.lockb

# yarn
.pnp.*
Expand Down
2 changes: 1 addition & 1 deletion .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn commitlint --edit $1
pnpm exec commitlint --edit $1
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn build:affected && yarn lint-staged
pnpm run build:affected && pnpm exec lint-staged
3 changes: 2 additions & 1 deletion .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"$schema": "https://json.schemastore.org/lintstagedrc.schema.json",
"*": "prettier --ignore-unknown --write",
"{src/**,__tests__/**}.{mjs,js,cjs,ts,tsx}": "eslint --ext .mjs,.js,.cjs,.ts,.tsx --fix",
"{src/**,__tests__/**}.{mjs,js,cjs,ts,tsx}": "eslint --fix",
"src/**.ts": "vitest related --run --config ../../vitest.config.ts"
}
7 changes: 7 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
auto-install-peers=false
resolution-mode=highest
public-hoist-pattern[]=*eslint*
public-hoist-pattern[]=*prettier*
public-hoist-pattern[]=*@rushstack/node-core-library*
public-hoist-pattern[]=*@microsoft/api-extractor-model*
public-hoist-pattern[]=*jju*
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
CODEOWNERS
CHANGELOG.md
tsup.config.bundled*
vitest.config.ts.timestamp*
1 change: 1 addition & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "https://json.schemastore.org/prettierrc.json",
"printWidth": 120,
"useTabs": true,
"singleQuote": true,
Expand Down
Loading

0 comments on commit 185fa84

Please sign in to comment.