Skip to content

Commit e96a8a9

Browse files
authored
build: pnpm (#9806)
1 parent 8325fa6 commit e96a8a9

File tree

82 files changed

+24444
-28614
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+24444
-28614
lines changed

.github/CONTRIBUTING.md

+10-11
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,36 @@ is a great boon to your development process.
1111
To get ready to work on the codebase, please do the following:
1212

1313
1. Fork & clone the repository, and make sure you're on the **main** branch
14-
2. Run `yarn --immutable` ([install](https://yarnpkg.com/getting-started/install))
15-
3. Run `yarn build` to build local packages
14+
2. Run `pnpm install --frozen-lockfile` ([install](https://pnpm.io/installation))
15+
3. Run `pnpm run build` to build local packages
1616
4. Code your heart out!
17-
5. Run `yarn test` to run ESLint and ensure any JSDoc changes are valid
17+
5. Run `pnpm run test` to run ESLint and ensure any JSDoc changes are valid
1818
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))
1919

2020
## Testing changes locally
2121

22-
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.
22+
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.
2323

2424
1. Create a new directory `mkdir discordjs-test` and move into it `cd discordjs-test`
25-
2. Initialize a new yarn 3 project `yarn init -2`
26-
3. Disable pnp `yarn config set nodeLinker node-modules`
27-
4. Now link the local discord.js project you cloned earlier `yarn link -A {PATH_TO_DISCORDJS_REPO}`
28-
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**
29-
6. Import the package in your source code and test them out!
25+
2. Initialize a new pnpm project `pnpm init`
26+
3. Now link the local discord.js project you cloned earlier `pnpm link {PATH_TO_DISCORDJS_REPO}`
27+
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**
28+
5. Import the package in your source code and test them out!
3029

3130
### Working with TypeScript packages
3231

3332
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.
3433

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

37-
For example, to automatically recompile the `@discordjs/rest` project when changes are detected, run `yarn turbo run build --filter=@discordjs/rest --concurrency=3 -- --watch` in the root folder of where you cloned the discord.js repo.
36+
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.
3837

3938
## Adding new packages
4039

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

4342
```sh
44-
yarn create-package <package-name> [package-description]
43+
pnpm run create-package <package-name> [package-description]
4544
```
4645

4746
This will create new package directory under `packages/` with the required configuration files. You can

.github/workflows/cleanup-cache.yml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
pull_request:
55
types:
66
- closed
7+
workflow_dispatch:
78
jobs:
89
cleanup:
910
name: Cleanup caches

.github/workflows/documentation.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ jobs:
4242
node-version: 18
4343

4444
- name: Install dependencies
45-
uses: ./packages/actions/src/yarnCache
45+
uses: ./packages/actions/src/pnpmCache
4646

4747
- name: Build dependencies
48-
run: yarn build
48+
run: pnpm run build
4949

5050
- name: Build docs
51-
run: yarn docs
51+
run: pnpm run docs
5252

5353
- name: Checkout docs repository
5454
uses: actions/checkout@v3

.github/workflows/npm-auto-deprecate.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ jobs:
1818
node-version: 18
1919

2020
- name: Install dependencies
21-
uses: ./packages/actions/src/yarnCache
21+
uses: ./packages/actions/src/pnpmCache
2222

2323
- name: Deprecate versions
24-
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'
24+
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'
2525
env:
2626
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

.github/workflows/publish-dev-docker.yml

+2-5
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ jobs:
1818
node-version: 18
1919

2020
- name: Install dependencies
21-
uses: ./packages/actions/src/yarnCache
22-
23-
- name: Build dependencies
24-
run: yarn build
21+
uses: ./packages/actions/src/pnpmCache
2522

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

3229
- name: Build & push docker image
33-
run: yarn docker build --buildkit @discordjs/proxy-container -t discordjs/proxy:latest --push
30+
run: docker build -f packages/proxy-container/Dockerfile -t discordjs/proxy:latest --push .

.github/workflows/publish-dev.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ jobs:
5252
registry-url: https://registry.npmjs.org/
5353

5454
- name: Install dependencies
55-
uses: ./packages/actions/src/yarnCache
55+
uses: ./packages/actions/src/pnpmCache
5656

5757
- name: Build dependencies
58-
run: yarn build
58+
run: pnpm run build
5959

6060
- name: Publish package
6161
run: |
62-
yarn workspace ${{ matrix.package }} release --preid "dev.$(date +%s)-$(git rev-parse --short HEAD)"
63-
yarn workspace ${{ matrix.package }} npm publish --tag dev || true
62+
pnpm --filter=${{ matrix.package }} run release --preid "dev.$(date +%s)-$(git rev-parse --short HEAD)"
63+
pnpm --filter=${{ matrix.package }} publish --tag dev || true
6464
env:
65-
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
65+
NPM_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

.github/workflows/publish-docker.yml

+2-5
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@ jobs:
1515
node-version: 18
1616

1717
- name: Install dependencies
18-
uses: ./packages/actions/src/yarnCache
19-
20-
- name: Build dependencies
21-
run: yarn build
18+
uses: ./packages/actions/src/pnpmCache
2219

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

2926
- name: Build & push docker image
30-
run: yarn docker build --buildkit @discordjs/proxy-container -t discordjs/proxy:$(cut -d '.' -f1 <<< $(jq --raw-output '.version' packages/proxy-container/package.json)) --push
27+
run: docker build -f packages/proxy-container/Dockerfile -t discordjs/proxy:$(cut -d '.' -f1 <<< $(jq --raw-output '.version' packages/proxy-container/package.json)) --push .

.github/workflows/publish-release.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ jobs:
2121
registry-url: https://registry.npmjs.org/
2222

2323
- name: Install dependencies
24-
uses: ./packages/actions/src/yarnCache
24+
uses: ./packages/actions/src/pnpmCache
2525

2626
- name: Build dependencies
27-
run: yarn build
27+
run: pnpm run build
2828

2929
- name: Extract package and semver from tag
3030
id: extract-tag
@@ -34,6 +34,6 @@ jobs:
3434

3535
- name: Publish package
3636
run: |
37-
yarn workspace ${{ steps.extract-tag.outputs.subpackage == 'true' && '@discordjs/' || '' }}${{ steps.extract-tag.outputs.package }} npm publish
37+
pnpm --filter=${{ steps.extract-tag.outputs.subpackage == 'true' && '@discordjs/' || '' }}${{ steps.extract-tag.outputs.package }} publish
3838
env:
39-
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
39+
NPM_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

.github/workflows/tests.yml

+9-9
Original file line numberDiff line numberDiff line change
@@ -25,39 +25,39 @@ jobs:
2525
node-version: 18
2626

2727
- name: Install dependencies
28-
uses: ./packages/actions/src/yarnCache
28+
uses: ./packages/actions/src/pnpmCache
2929

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

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

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

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

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

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

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

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

6262
- name: Upload Coverage
6363
if: github.repository_owner == 'discordjs'

.husky/commit-msg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
22
. "$(dirname "$0")/_/husky.sh"
33

4-
yarn commitlint --edit $1
4+
pnpm exec commitlint --edit $1

.husky/pre-commit

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
22
. "$(dirname "$0")/_/husky.sh"
33

4-
yarn build:affected && yarn lint-staged
4+
pnpm run build:affected && pnpm exec lint-staged

.npmrc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
auto-install-peers=false
2+
resolution-mode=highest
3+
public-hoist-pattern[]=*eslint*
4+
public-hoist-pattern[]=*prettier*
5+
public-hoist-pattern[]=*@rushstack/node-core-library*
6+
public-hoist-pattern[]=*@microsoft/api-extractor-model*
7+
public-hoist-pattern[]=*jju*

.vscode/settings.json

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"],
33
"eslint.useESLintClass": true,
44
"eslint.experimental.useFlatConfig": true,
5-
"eslint.workingDirectories": [{ "mode": "auto" }],
5+
"eslint.workingDirectories": [
6+
{ "directory": "${workspaceFolder}" },
7+
{ "pattern": "./apps/*/" },
8+
{ "pattern": "./packages/*/" }
9+
],
610
"editor.defaultFormatter": "esbenp.prettier-vscode",
711
"editor.formatOnSave": true,
812
"editor.codeActionsOnSave": {
@@ -16,7 +20,7 @@
1620
},
1721
"files.insertFinalNewline": true,
1822
"files.eol": "\n",
19-
"npm.packageManager": "yarn",
23+
"npm.packageManager": "pnpm",
2024
"typescript.tsdk": "node_modules/typescript/lib",
2125
"deno.enablePaths": ["./packages/create-discord-bot/template/Deno"],
2226
"deno.lint": true,

.yarn/patches/yaml-npm-2.2.2-6e3cddb343.patch

-18
This file was deleted.

0 commit comments

Comments
 (0)