Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate to pnpm and fix CVE for ip transitive dependency #419

Merged
merged 27 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f8cd926
fix CVE for ip transitive dependency
shamilovtim Feb 20, 2024
ac56a57
ci
shamilovtim Feb 20, 2024
de5702c
migrate to pnpm
shamilovtim Feb 21, 2024
60c96a0
add pnpm setup action
shamilovtim Feb 21, 2024
ca39adc
fix ordering
shamilovtim Feb 21, 2024
8f48216
fix npx
shamilovtim Feb 21, 2024
955f986
fix npx
shamilovtim Feb 21, 2024
a3544de
be explicit about bins
shamilovtim Feb 21, 2024
fb996e3
missed dep
shamilovtim Feb 21, 2024
0451952
fix filters
shamilovtim Feb 21, 2024
7fe9669
fix filters
shamilovtim Feb 21, 2024
3e8ea60
fix playwright
shamilovtim Feb 21, 2024
1267de1
fix playwright
shamilovtim Feb 21, 2024
f56c926
fix browser to run in sequence
shamilovtim Feb 21, 2024
62f8c70
Minor fix to type only import in VP tests
frankhinek Feb 22, 2024
1e07ea4
Update CONTRIBUTING.md
shamilovtim Feb 22, 2024
261e7cf
Update CONTRIBUTING.md
shamilovtim Feb 22, 2024
c05d553
Merge branch 'main' into tshamilov/cve-ip
shamilovtim Feb 22, 2024
4442df4
Minor fixes
frankhinek Feb 22, 2024
4249c98
Bump lock files
frankhinek Feb 22, 2024
56e01be
fix test node
shamilovtim Feb 23, 2024
c66be9b
Add @types/node to all packages
frankhinek Feb 23, 2024
9823649
Bump PNPM lockfile and remove NPM lockfile
frankhinek Feb 23, 2024
2e45466
Improve CONTRIBUTING doc
frankhinek Feb 23, 2024
a75f451
Fix ordering of clean script
frankhinek Feb 23, 2024
0e8d453
Consistent use of quotation marks in GH workflows
frankhinek Feb 23, 2024
eb10571
Add version comments to pinned GH workflow actions
frankhinek Feb 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .codesandbox/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"setupTasks": [
{
"name": "Installing Dependencies",
"command": "npm install"
"command": "pnpm install"
}
],
"tasks": {
"dev": {
"name": "Build Web5 SDK",
"command": "npm run build",
"command": "pnpm build",
"runAtStart": true,
"restartOn": {
"files": [
Expand All @@ -19,7 +19,7 @@
},
"tests": {
"name": "Run tests",
"command": "npm run test:node --ws"
"command": "pnpm --recursive --stream test:node"
}
}
}
14 changes: 9 additions & 5 deletions .github/workflows/alpha-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,26 @@ jobs:
- name: Checkout source
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1

- uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d
with:
version: 8

- name: Set up Node.js
uses: actions/setup-node@5ef044f9d09786428e6e895be6be17937becee3a #v4.0.0
with:
node-version: 18
registry-url: https://registry.npmjs.org/
cache: "npm"
cache: "pnpm"

# Note - this is not required but it gives a clean failure prior to attempting a release if
# the GH workflow runner is not authenticated with NPMjs.com
- name: Verify NPM token is authenticated with NPMjs.com
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
run: npm whoami
run: pnpm whoami

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

- name: Generate alpha prerelease and bump package.json @web5/* versions
env:
Expand All @@ -55,15 +59,15 @@ jobs:
shell: bash

- name: Build all workspace packages
run: npm run build
run: pnpm --recursive --stream build

- name: Publish selected @web5/* packages
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
run: |
for package in $PACKAGES; do
cd packages/$package
npm publish --tag alpha --no-git-tag-version --access public --provenance
pnpm publish --tag alpha --no-git-tag-version --access public --provenance
cd ../..
done
shell: bash
10 changes: 7 additions & 3 deletions .github/workflows/docs-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,22 @@ jobs:
- name: Checkout source
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1

- uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d
with:
version: 8

- name: Set up Node.js
uses: actions/setup-node@5ef044f9d09786428e6e895be6be17937becee3a #v4.0.0
with:
node-version: 18
registry-url: https://registry.npmjs.org/
cache: "npm"
cache: "pnpm"

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

- name: Build all workspace packages
run: npm run build
run: pnpm --recursive --stream build

- name: TBDocs Reporter
id: tbdocs-reporter-protocol
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/docs-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,23 @@ jobs:
- name: Checkout source
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1

- uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d
with:
version: 8

- name: Set up Node.js
uses: actions/setup-node@5ef044f9d09786428e6e895be6be17937becee3a #v4.0.0
with:
node-version: 18
registry-url: https://registry.npmjs.org/
cache: 'npm'
cache: 'pnpm'
frankhinek marked this conversation as resolved.
Show resolved Hide resolved

- name: Install dependencies
run: |
npm ci
pnpm install --frozen-lockfile

- name: Build all workspace packages
run: npm run build
run: pnpm --recursive --stream build

- name: TBDocs Reporter
id: tbdocs-reporter-protocol
Expand Down
16 changes: 10 additions & 6 deletions .github/workflows/release-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,25 @@ jobs:
- name: Checkout source
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1

- uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d
with:
version: 8

- name: Set up Node.js
uses: actions/setup-node@5ef044f9d09786428e6e895be6be17937becee3a #v4.0.0
with:
node-version: 18
registry-url: https://registry.npmjs.org/
cache: "npm"
cache: "pnpm"
frankhinek marked this conversation as resolved.
Show resolved Hide resolved

- name: Install semver utility
run: npm install -g [email protected]
run: pnpm install -g [email protected]

# Note - this is not required but it gives a clean failure prior to attempting a release if the GH workflow runner is not authenticated with NPMjs.com
- name: Verify NPM token is authenticated with NPMjs.com
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
run: npm whoami
run: pnpm whoami

- name: Check if GitHub repo package version is latest
env:
Expand Down Expand Up @@ -84,17 +88,17 @@ jobs:

- name: Install dependencies
if: env.IS_LATEST == 'true'
run: npm ci
run: pnpm ci

- name: Build all workspace packages
if: env.IS_LATEST == 'true'
run: npm run build
run: pnpm build

- name: Publish @web5/${{ matrix.package }}@${{ env.REPO_VERSION }}
if: env.IS_LATEST == 'true'
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
run: |
cd packages/${{ matrix.package }}
npm publish --access public --provenance
pnpm publish --access public --provenance
shell: bash
48 changes: 30 additions & 18 deletions .github/workflows/tests-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@ jobs:
- name: Checkout source
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1

- uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d
with:
version: 8

- name: Set up Node.js
uses: actions/setup-node@5ef044f9d09786428e6e895be6be17937becee3a #v4.0.0
with:
node-version: 18
cache: "npm"
cache: "pnpm"
frankhinek marked this conversation as resolved.
Show resolved Hide resolved

- name: Report known vulnerabilities
run: npm audit
run: pnpm audit

test-with-node:
runs-on: ubuntu-latest
Expand All @@ -34,30 +38,34 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
with:
submodules: true

- uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d
with:
version: 8

- name: Set up Node.js
uses: actions/setup-node@5ef044f9d09786428e6e895be6be17937becee3a #v4.0.0
with:
node-version: 18
registry-url: https://registry.npmjs.org/
cache: "npm"
cache: "pnpm"
frankhinek marked this conversation as resolved.
Show resolved Hide resolved

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

- name: Build all workspace packages
run: npm run build:esm --ws && npm run build:cjs --ws
run: pnpm --recursive --stream build:esm && pnpm --recursive --stream build:cjs

- name: Run linter for all packages
run: npm run lint --ws
run: pnpm --recursive --stream lint

- name: Run dwn-server (background)
run: |
node node_modules/@web5/dwn-server/dist/esm/src/main.js &
pnpm exec node node_modules/@web5/dwn-server/dist/esm/src/main.js &
echo "DWN_SERVER_BACKGROUND_PROCESS=$!" >> $GITHUB_ENV

- name: Run tests for all packages
run: npm run test:node --ws -- --color --reporter mocha-junit-reporter --reporter-options mochaFile=./results.xml
run: pnpm --recursive --stream test:node -- --color --reporter mocha-junit-reporter --reporter-options mochaFile=./results.xml
env:
TEST_DWN_URL: http://localhost:3000

Expand Down Expand Up @@ -107,31 +115,35 @@ jobs:
matrix:
include:
- group: "A"
packages: "--workspace packages/agent"
packages: "--filter agent"
- group: "B"
packages: "--workspace packages/credentials --workspace packages/crypto --workspace packages/dids --workspace packages/proxy-agent --workspace packages/identity-agent --workspace packages/user-agent"
packages: "--filter credentials --filter crypto --filter dids --filter proxy-agent --filter identity-agent --filter user-agent"
- group: "C"
packages: "--workspace packages/api --workspace packages/common"
packages: "--filter api --filter common"
steps:
- name: Checkout source
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
with:
submodules: true

- uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d
with:
version: 8

- name: Set up Node.js
uses: actions/setup-node@5ef044f9d09786428e6e895be6be17937becee3a #v4.0.0
with:
node-version: 18
registry-url: https://registry.npmjs.org/
cache: "npm"
cache: "pnpm"

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

- name: Get Playwright Version (for cache)
id: get-playwright-version
run: |
PLAYWRIGHT_VERSION=$(npm ls @playwright/test --workspace=./packages/api | grep '@playwright/test' | awk 'NR==1{print $2}')
PLAYWRIGHT_VERSION=$(pnpm --filter agent ls @playwright/test | grep '@playwright/test' | awk 'NR==1{print $2}')
frankhinek marked this conversation as resolved.
Show resolved Hide resolved
echo "Playwright Version: $PLAYWRIGHT_VERSION"
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV

Expand All @@ -144,21 +156,21 @@ jobs:

- name: Install Playwright Browsers (if no cache)
if: steps.cache-playwright-restore.outputs.cache-hit != 'true'
run: npx playwright install --with-deps
run: pnpm --filter api exec playwright install --with-deps

- name: Build esm
run: npm run build:esm --ws
run: pnpm --recursive --stream build:esm

- name: Build browser for matrix ${{ matrix.group }}
run: npm run build:browser ${{ matrix.packages }}
run: pnpm ${{ matrix.packages }} build:browser

- name: Run dwn-server (background)
run: |
node node_modules/@web5/dwn-server/dist/esm/src/main.js &
echo "DWN_SERVER_BACKGROUND_PROCESS=$!" >> $GITHUB_ENV

- name: Run tests for matrix ${{ matrix.group }}
run: npm run test:browser ${{ matrix.packages }}
run: pnpm ${{ matrix.packages }} --sequential test:browser

- name: Terminate dwn-server
run: kill $DWN_SERVER_BACKGROUND_PROCESS || true
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"npm.packageManager": "npm"
"npm.packageManager": "pnpm"
}
20 changes: 10 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,18 @@ Build and Test cycles are run on every commit to every branch using [GitHub Acti
| Requirement | Tested Version | Installation Instructions |
| ----------- | -------------- | ---------------------------------------------------------------------------------------------- |
| Node.js | 18.16.0 | [Introduction to Node.js](https://nodejs.dev/en/learn/) |
| NPM | 9.6.3 | [NPM Package Manager](https://nodejs.dev/en/learn/an-introduction-to-the-npm-package-manager/) |
| PNPM | 8.15.3 | [PNPM Package Manager](https://pnpm.io/installation) |
frankhinek marked this conversation as resolved.
Show resolved Hide resolved

### TypeScript

This project is written in TypeScript, a strongly typed programming language that builds on JavaScript.

You may verify your `node` and `npm` installation via the terminal:
You may verify your `node` and `pnpm` installation via the terminal:

```
$ node --version
v18.16.0
$ npm --version
$ pnpm --version
9.6.3
shamilovtim marked this conversation as resolved.
Show resolved Hide resolved
```

Expand Down Expand Up @@ -108,11 +108,11 @@ to your valuable work:

### Running Tests

- Running the `npm run test:node --ws` command from the root of the project will run all tests using node.
- Running the `pnpm --recursive test:node` command from the root of the project will run all tests using node.
- This is run via CI whenever a pull request is opened, or a commit is pushed to a branch that has an open PR
- Running the `npm run test:browser --ws` command from the root of the project will run the tests in a browser environment
- Running the `pnpm --recursive test:browser` command from the root of the project will run the tests in a browser environment
- Please make sure there are no failing tests before switching your PR to ready for review! We hope to have this automated via a github action very soon.
- You can also run `npm run test:node -w=packages/DIR` or `npm run test:browser -w=packages/DIR` from the root of the project to run tests for a single package. For example, to run the tests only for the `web5` package run `npm run test:node -w=packages/web5`.
- You can also run `pnpm --filter=PACKAGE test:node` or `pnpm --filter=PACKAGE test:browser` from the root of the project to run tests for a single package. For example, to run the tests only for the `web5` package run `pnpm --filter=web5 test:node`.
shamilovtim marked this conversation as resolved.
Show resolved Hide resolved

### Test Coverage Expectations

Expand Down Expand Up @@ -146,7 +146,7 @@ To see if the docs are being generated properly without errors, and to preview t
# to see if there are any doc errors
open .tbdocs/docs-report.md

# to serve the generated docs locally using a static server (e.g. `npm i -g http-server`)
# to serve the generated docs locally using a static server (e.g. `pnpm install -g http-server`)
http-server .tbdocs/docs
```

Expand Down Expand Up @@ -192,7 +192,7 @@ After one or more PRs have been approved and merged by project maintainers, a Gi
version tag. The act of creating the GitHub release triggers automated publication of the package to the
[NPM Registry](https://npmjs.com) which will be tagged as _latest_.

The next time someone runs `npm install @web5/<package_name>` the newly published release will be installed.
The next time someone runs `pnpm install @web5/<package_name>` the newly published release will be installed.

#### Alpha Releases

Expand All @@ -218,5 +218,5 @@ the [NPM Registry](https://npmjs.com) within a few minutes.
> **Note**
> Alpha version will never be tagged as _latest_.

To install an `alpha` tagged release use either the `npm install @web5/<package>@alpha` or
`npm install @web5/<package>@x.y.z-alpha-YYYYMMDD-commithash` syntax.
To install an `alpha` tagged release use either the `pnpm install @web5/<package>@alpha` or
`pnpm install @web5/<package>@x.y.z-alpha-YYYYMMDD-commithash` syntax.
Loading
Loading