Skip to content

Commit cb73d67

Browse files
authored
chore: npm -> pnpm VSCODE-714 (#1191)
1 parent f45a4c7 commit cb73d67

22 files changed

+17897
-28966
lines changed

.depcheckrc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ ignores:
1212
- "vscode"
1313
- "webpack-cli"
1414
- "@mongodb-js/oidc-plugin"
15-
- node-loader
16-
- ts-loader
17-
- mongodb-runner
18-
- tabbable # Mocha register testing workaround stub.
19-
- focus-trap # Mocha register testing workaround stub.
20-
- ejson-shell-parser # Used by the connection-form.
15+
- "node-loader"
16+
- "ts-loader"
17+
- "mongodb-runner"
18+
- "tabbable" # Mocha register testing workaround stub.
19+
- "focus-trap" # Mocha register testing workaround stub.
20+
- "ejson-shell-parser" # Used by the connection-form.
21+
- "rimraf" # Used in 'clean' script to remove previous build artifacts
22+
- "snyk" # Used in 'snyk-test' script to create sbom

.eslintrc.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ module.exports = {
6969
allowHigherOrderFunctions: true,
7070
},
7171
],
72+
'@typescript-eslint/ban-ts-comment': [
73+
'error',
74+
{
75+
'ts-ignore': 'allow-with-description',
76+
},
77+
],
7278
},
7379
parserOptions: {
7480
project: ['./tsconfig.json'], // Specify it only for TypeScript files.

.github/workflows/actions/test-and-build/action.yaml

Lines changed: 43 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ runs:
5757
- name: Install Dependencies
5858
shell: bash
5959
run: |
60-
npm ci --omit=optional
60+
pnpm install --frozen-lockfile
6161
6262
- name: Run Checks
63-
run: npm run check
63+
run: pnpm run check
6464
# the glob here just fails
6565
if: ${{ runner.os != 'Windows' }}
6666
shell: bash
@@ -70,19 +70,19 @@ runs:
7070
NODE_OPTIONS: "--max_old_space_size=4096"
7171
MDB_IS_TEST: "true"
7272
run: |
73-
npm run test
73+
pnpm run test
7474
shell: bash
7575

7676
- name: Build .vsix
7777
env:
7878
NODE_OPTIONS: "--require ./scripts/no-npm-list-fail.js --max_old_space_size=4096"
7979
# NOTE: --githubBranch is "The GitHub branch used to infer relative links in README.md."
8080
run: |
81-
npx vsce package --githubBranch main
81+
pnpm exec vsce package --githubBranch main
8282
shell: bash
8383

8484
- name: Check .vsix filesize
85-
run: npm run check-vsix-size
85+
run: pnpm run check-vsix-size
8686
shell: bash
8787

8888
- name: Sign .vsix
@@ -117,33 +117,41 @@ runs:
117117
env:
118118
SNYK_TOKEN: ${{ inputs.SNYK_TOKEN }}
119119
run: |
120-
npm run snyk-test > /dev/null 2>&1
121-
122-
# TODO(VSCODE-706): Fix Snyk vuln ticket generation
123-
# - name: Create Jira Tickets
124-
# if: >
125-
# runner.os == 'Linux' &&
126-
# (
127-
# github.event_name == 'push' && github.ref == 'refs/heads/main' ||
128-
# github.event_name == 'workflow_dispatch' ||
129-
# github.event_name == 'schedule'
130-
# )
131-
# shell: bash
132-
# env:
133-
# JIRA_API_TOKEN: ${{ inputs.JIRA_API_TOKEN }}
134-
# JIRA_BASE_URL: "https://jira.mongodb.org"
135-
# JIRA_PROJECT: "VSCODE"
136-
# JIRA_VULNERABILITY_BUILD_INFO: "- [GitHub Run|https://github.com/mongodb-js/vscode/actions/runs/${{github.run_id}}/jobs/${{github.job}}]"
137-
# run: |
138-
# npm run create-vulnerability-tickets > /dev/null
139-
140-
# - name: Generate Vulnerability Report (Fail on >= High)
141-
# if: runner.os == 'Linux'
142-
# continue-on-error: ${{ github.event_name == 'pull_request' }}
143-
# shell: bash
144-
# run: |
145-
# # The standard output is suppressed since Github Actions logs are
146-
# # available for everyone with read access to the repo, which is everyone that is
147-
# # logged in for public repos.
148-
# # This command is only here to fail on failures for `main` and tags.
149-
# npm run generate-vulnerability-report > /dev/null
120+
pnpm run snyk-test > /dev/null 2>&1
121+
122+
- name: Upload Snyk Report
123+
if: runner.os == 'Linux'
124+
uses: actions/upload-artifact@v4
125+
with:
126+
name: Snyk Report - ${{ github.run_id }}
127+
path: |
128+
.sbom/snyk-test-result.html
129+
.sbom/snyk-test-result.json
130+
131+
- name: Create Jira Tickets
132+
if: >
133+
runner.os == 'Linux' &&
134+
(
135+
github.event_name == 'push' && github.ref == 'refs/heads/main' ||
136+
github.event_name == 'workflow_dispatch' ||
137+
github.event_name == 'schedule'
138+
)
139+
shell: bash
140+
env:
141+
JIRA_API_TOKEN: ${{ inputs.JIRA_API_TOKEN }}
142+
JIRA_BASE_URL: "https://jira.mongodb.org"
143+
JIRA_PROJECT: "VSCODE"
144+
JIRA_VULNERABILITY_BUILD_INFO: "- [GitHub Run|https://github.com/mongodb-js/vscode/actions/runs/${{github.run_id}}/jobs/${{github.job}}]"
145+
run: |
146+
pnpm run create-vulnerability-tickets > /dev/null
147+
148+
- name: Generate Vulnerability Report (Fail on >= High)
149+
if: runner.os == 'Linux'
150+
continue-on-error: ${{ github.event_name == 'pull_request' }}
151+
shell: bash
152+
run: |
153+
# The standard output is suppressed since Github Actions logs are
154+
# available for everyone with read access to the repo, which is everyone that is
155+
# logged in for public repos.
156+
# This command is only here to fail on failures for `main` and tags.
157+
pnpm run generate-vulnerability-report > /dev/null

.github/workflows/draft-release.yaml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ on:
44
workflow_dispatch:
55
inputs:
66
versionBump:
7-
description: 'Version bump'
7+
description: Version bump
88
type: choice
99
required: true
10-
default: 'patch'
10+
default: patch
1111
options:
12-
- patch
13-
- minor
14-
- major
15-
- exact-version
12+
- patch
13+
- minor
14+
- major
15+
- exact-version
1616

1717
exactVersion:
1818
description: 'Exact version: (Only effective selecting "exact-version" as version bump)'
@@ -37,11 +37,14 @@ jobs:
3737
# and check if tags are already present
3838
fetch-depth: 0
3939

40+
- name: Setup pnpm
41+
uses: pnpm/action-setup@v4
42+
4043
- name: Setup Node.js Environment
4144
uses: actions/setup-node@v4
4245
with:
4346
node-version: 22.15.1
44-
cache: npm
47+
cache: pnpm
4548

4649
- name: Determine Next Version
4750
shell: bash
@@ -54,9 +57,9 @@ jobs:
5457
5558
if [[ "$VERSION_BUMP" == "major" || "$VERSION_BUMP" == "minor" || "$VERSION_BUMP" == "patch" ]]; then
5659
PREV_VERSION_TAG=$(gh api repos/:owner/:repo/releases --jq '. | map(select(.draft == false)) | .[0] | .tag_name')
57-
PREV_VERSION=$(npx semver --coerce ${PREV_VERSION_TAG})
60+
PREV_VERSION=$(pnpm exec semver --coerce ${PREV_VERSION_TAG})
5861
59-
NEXT_VERSION=$(npx semver -i $VERSION_BUMP $PREV_VERSION)
62+
NEXT_VERSION=$(pnpm exec semver -i $VERSION_BUMP $PREV_VERSION)
6063
else
6164
NEXT_VERSION=${{ github.event.inputs.exactVersion }}
6265
fi
@@ -65,9 +68,9 @@ jobs:
6568
NEXT_VERSION="${NEXT_VERSION#v}"
6669
6770
# Validates the version before using it
68-
npx semver v"${NEXT_VERSION}"
71+
pnpm exec semver v"${NEXT_VERSION}"
6972
70-
npm version "${NEXT_VERSION}" --no-git-tag-version
73+
pnpm version "${NEXT_VERSION}" --no-git-tag-version
7174
echo "RELEASE_TAG=v${NEXT_VERSION}" >> "$GITHUB_ENV"
7275
7376
- name: Validate release tag
@@ -115,4 +118,3 @@ jobs:
115118
shell: bash
116119
env:
117120
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
118-

.github/workflows/publish-release.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,21 @@ jobs:
1212
name: Publish Release
1313
runs-on: ubuntu-latest
1414
steps:
15+
- name: Setup pnpm
16+
uses: pnpm/action-setup@v4
17+
1518
- name: Setup Node.js Environment
1619
uses: actions/setup-node@v4
1720
with:
1821
node-version: 22.15.1
22+
cache: pnpm
1923

2024
- name: Run node-gyp bug workaround script
2125
run: |
2226
curl -sSfLO https://raw.githubusercontent.com/mongodb-js/compass/42e6142ae08be6fec944b80ff6289e6bcd11badf/.evergreen/node-gyp-bug-workaround.sh && bash node-gyp-bug-workaround.sh
2327
2428
- name: Install VSCode publishing dependencies
25-
run: npm install -g vsce
29+
run: pnpm add -g vsce
2630

2731
- name: Download release assets
2832
run: |
@@ -43,6 +47,6 @@ jobs:
4347
- name: Publish to marketplace
4448
run: |
4549
echo "Publishing ${VSIX_PATH} to marketplace"
46-
npx vsce publish --packagePath "${VSIX_PATH}" --githubBranch main
50+
pnpm exec vsce publish --packagePath "${VSIX_PATH}" --githubBranch main
4751
env:
4852
VSCE_PAT: ${{ secrets.VSCE_PAT }}

.github/workflows/test-and-build-from-fork.yaml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,26 @@ jobs:
2222
- name: Checkout
2323
uses: actions/checkout@v4
2424

25+
- name: Setup pnpm
26+
uses: pnpm/action-setup@v4
27+
2528
- name: Setup Node.js Environment
2629
uses: actions/setup-node@v4
2730
with:
2831
node-version: 22.15.1
29-
cache: npm
32+
cache: pnpm
3033

3134
- name: Install Dependencies
32-
run: npm ci --omit=optional
35+
run: pnpm install --frozen-lockfile
3336

3437
- name: Run Checks
35-
run: npm run check
38+
run: pnpm run check
3639
# the glob here just fails
3740
if: ${{ runner.os != 'Windows' }}
3841

3942
- name: Run Tests
4043
env:
4144
NODE_OPTIONS: "--max_old_space_size=4096"
42-
SEGMENT_KEY: "test-segment-key"
45+
SEGMENT_KEY: ${{ secrets.SEGMENT_KEY_DEV }}
4346
MDB_IS_TEST: "true"
44-
run: npm run test
47+
run: pnpm run test

.github/workflows/test-and-build.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,14 @@ jobs:
3131
with:
3232
fetch-depth: 0
3333

34+
- name: Setup pnpm
35+
uses: pnpm/action-setup@v4
36+
3437
- name: Setup Node.js Environment
3538
uses: actions/setup-node@v4
3639
with:
3740
node-version: 22.15.1
38-
cache: npm
41+
cache: pnpm
3942

4043
- name: Run tests and build
4144
uses: ./.github/workflows/actions/test-and-build

.npmrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Hoist peer dependencies to reduce nested installations
2+
# This makes pnpm behave more like npm/yarn in terms of hoisting
3+
public-hoist-pattern[]=*@cfworker/json-schema*
4+
public-hoist-pattern[]=*mongodb-client-encryption*
5+
public-hoist-pattern[]=*socks*
6+
7+

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ CHANGELOG.md
1414
README.md
1515
constants.json
1616
.sbom
17+
pnpm-lock.yaml

CONTRIBUTING.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ MongoDB welcomes community contributions! If you’re interested in making a con
99
1. Create a branch with a name that briefly describes your feature
1010
1. Implement your feature or bug fix
1111
1. Add new cases to `./src/test` that verify your bug fix or make sure no one
12-
unintentionally breaks your feature in the future and run them with `npm test`
12+
unintentionally breaks your feature in the future and run them with `pnpm test`
1313
1. Add comments around your new code that explain what's happening
1414
1. Commit and push your changes to your branch then submit a pull request
1515

@@ -24,13 +24,13 @@ Please include as much information as possible about your environment.
2424
We recommend familiarizing yourself with the VSCode extension documentation:
2525
[code.visualstudio.com/api](https://code.visualstudio.com/api).
2626

27-
Running the MongoDB VSCode plugin requires [Node.js](https://nodejs.org) and npm.
27+
Running the MongoDB VSCode plugin requires [Node.js](https://nodejs.org) and pnpm.
2828

2929
1. Clone this project, navigate to the folder, then run:
3030

3131
```shell
32-
npm install
33-
npm run watch
32+
pnpm install
33+
pnpm run watch
3434
```
3535

3636
2. Inside of [VS Code Insiders](https://code.visualstudio.com/insiders/) open this directory and press `F5` to begin debugging the extension. This should launch a new VSCode window which is running the extension.
@@ -46,14 +46,14 @@ You can launch a debugging task for tests inside VSCode with the **"Run Tests"**
4646
You can run tests using command line along with an optional `MOCHA_GREP` environment variable to apply a grep filter on tests to run.
4747

4848
```shell
49-
MOCHA_GREP="Participant .* prompt builders" npm test
49+
MOCHA_GREP="Participant .* prompt builders" pnpm test
5050
```
5151

52-
It may be quicker to be more specific and use `npm run test-extension` or `npm run test-webview` after compiling.
52+
It may be quicker to be more specific and use `pnpm run test-extension` or `pnpm run test-webview` after compiling.
5353

5454
### Using Proposed API
5555

56-
The vscode extension will occasionally need to use [proposed API](https://code.visualstudio.com/api/advanced-topics/using-proposed-api) that haven't been promoted to stable yet. To enable an API proposal, add it to the `enabledApiProposals` section in `package.json`, then run `cd src/vscode-dts && npx @vscode/dts dev` to install the type definitions for the API you want to enable.
56+
The vscode extension will occasionally need to use [proposed API](https://code.visualstudio.com/api/advanced-topics/using-proposed-api) that haven't been promoted to stable yet. To enable an API proposal, add it to the `enabledApiProposals` section in `package.json`, then run `cd src/vscode-dts && pnpm exec @vscode/dts dev` to install the type definitions for the API you want to enable.
5757

5858
**Note**: Using proposed API is only possible during local development and will prevent publishing the extension.
5959

0 commit comments

Comments
 (0)