Skip to content

Commit

Permalink
Merge pull request #1678 from cprussin/migrate-to-pnpm
Browse files Browse the repository at this point in the history
Migrate to pnpm
  • Loading branch information
cprussin authored Jun 10, 2024
2 parents 31c1024 + 52592d4 commit bfe9b2c
Show file tree
Hide file tree
Showing 88 changed files with 32,317 additions and 99,387 deletions.
9 changes: 9 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
# the shebang is ignored, but nice for editors

if type -P lorri &>/dev/null; then
eval "$(lorri direnv)"
elif type -P nix-shell &>/dev/null; then
echo 'while direnv evaluated .envrc, could not find the command "lorri" [https://github.com/nix-community/lorri]'
use nix
fi
8 changes: 5 additions & 3 deletions .github/workflows/ci-ethereum-contract.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,18 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Install contract npm dependencies
run: npm ci
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
run_install: true

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1.1.1
with:
version: nightly

- name: Install Forge dependencies
run: npm run install-forge-deps
run: pnpm run install-forge-deps

- name: Run tests
run: forge test -vvv --deny-warnings
Expand Down
13 changes: 7 additions & 6 deletions .github/workflows/ci-hermes-client-api-types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 18
cache: "npm"
- name: Install deps
run: npm ci
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
run_install: true
- name: Generate API Types
run: npx lerna run generate-hermes-api-types
run: pnpm exec lerna run generate-hermes-api-types
- name: Check API Types
run: npx lerna run check-hermes-api-types
run: pnpm exec lerna run check-hermes-api-types
6 changes: 4 additions & 2 deletions .github/workflows/ci-message-buffer-idl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ jobs:
run: anchor build
- name: Copy anchor target files
run: cp ./target/idl/message_buffer.json idl/ && cp ./target/types/message_buffer.ts idl/
- uses: pnpm/action-setup@v4
name: Install pnpm
- name: Install prettier globally
run: npm install -g prettier@2.7.1
run: pnpm install -g prettier@2.7.1
- name: Run prettier (to avoid pre-commit failures)
run: |
npx prettier@2.7.1 --write "./idl/*"
pnpm dlx prettier@2.7.1 --write "./idl/*"
- name: Check IDL changes
# Fails if the IDL files are not up to date. Please use anchor build to regenerate the IDL files for
# the current version of the contract and update idl directory.
Expand Down
19 changes: 10 additions & 9 deletions .github/workflows/ci-typescript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 18
cache: "npm"
- name: Install deps
run: npm ci
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
run_install: true
- name: Build
run: npx lerna run build
run: pnpm exec lerna run build
- name: Test
run: npx lerna run test
run: pnpm exec lerna run test
- name: Lint
run: npx lerna run lint
run: pnpm exec lerna run lint
- name: Generate ABIs
run: npx lerna run generate-abi
run: pnpm exec lerna run generate-abi
- name: Check ABIs
run: npx lerna run check-abi
run: pnpm exec lerna run check-abi
12 changes: 7 additions & 5 deletions .github/workflows/publish-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/setup-node@v4
with:
node-version: "18"
registry-url: "https://registry.npmjs.org"
- run: npm ci
- run: npx lerna run build --no-private
- run: npx lerna publish from-package --no-private --no-git-tag-version --yes
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
run_install: true
- run: pnpm exec lerna run build --no-private
- run: pnpm exec lerna publish from-package --no-private --no-git-tag-version --yes
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
8 changes: 4 additions & 4 deletions .github/workflows/release-pyth-cosmwasm-contract.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Setup tool
run: npm ci
run: pnpm i
- name: Build generic cosmwasm contract
run: |
npm run build-contract -- --cosmwasm
pnpm run build-contract -- --cosmwasm
mv ../artifacts ../cosmwasm
zip -r cosmwasm.zip ../cosmwasm
- name: Build injective cosmwasm contract
run: |
npm run build-contract -- --injective
pnpm run build-contract -- --injective
mv ../artifacts ../injective
zip -r injective.zip ../injective
- name: Build osmosis cosmwasm contract
run: |
npm run build-contract -- --osmosis
pnpm run build-contract -- --osmosis
mv ../artifacts ../osmosis
zip -r osmosis.zip ../osmosis
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ bigtable-writer.json
tsconfig.tsbuildinfo
*~
*mnemonic*
.envrc
*/*.sui.log*
__pycache__
.DS_Store
.vercel
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ repos:
rev: v3.2.0
hooks:
- id: trailing-whitespace
exclude: target_chains/sui/vendor/
exclude: target_chains/sui/vendor/|patches/
- id: end-of-file-fixer
exclude: target_chains/sui/vendor/
exclude: target_chains/sui/vendor/|patches/
- id: check-added-large-files
exclude: package-lock.json,target_chains/sui/vendor/
exclude: target_chains/sui/vendor/|patches/
# Hook to format many type of files in the repo
# including solidity contracts.
- repo: https://github.com/pre-commit/mirrors-prettier
Expand Down
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pnpm-lock.yaml
patches/
2 changes: 1 addition & 1 deletion Dockerfile.lerna
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ COPY --from=base --chown=1000:1000 /home/node ./

RUN --mount=type=cache,uid=1000,gid=1000,id=lerna,target=/home/node/.npm \
--mount=type=cache,uid=1000,gid=1000,id=lerna,target=/home/node/node_modules \
npm ci && cp -r node_modules node_modules_cache
pnpm i && cp -r node_modules node_modules_cache

# Folders in the cache are not visible in the container that's why we copy
# them and then move them back.
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,19 @@ Integration tests run in Tilt (via the `tilt ci` command). The Tilt CI workflow

All of the typescript / javascript packages in this repository are part of a lerna monorepo.
This setup allows each package to reference the current version of the others.
You can install dependencies using `npm ci` from the repository root.
You can build all of the packages using `npx lerna run build` and test with `npx lerna run test`.
You can install dependencies using `pnpm i` from the repository root.
You can build all of the packages using `pnpm exec lerna run build` and test with `pnpm exec lerna run test`.

Lerna has some common failure modes that you may encounter:

1. `npm ci` fails with a typescript compilation error about a missing package.
1. `pnpm i` fails with a typescript compilation error about a missing package.
This error likely means that the failing package has a `prepare` entry compiling the typescript in its `package.json`.
Fix this error by moving that logic to the `prepublishOnly` entry.
2. The software builds locally but fails in CI, or vice-versa.
This error likely means that some local build caches need to be cleaned.
The build error may not indicate that this is a caching issue, e.g., it may appear that the packages are being built in the wrong order.
Delete `node_modules/`, `lib/` and `tsconfig.tsbuildinfo` from each package's subdirectory. then try again.
3. `npm ci` fails due to wrong node version. Make sure to be using `v18`. Node version `v21` is not supported and known to cause issues.
3. `pnpm i` fails due to wrong node version. Make sure to be using `v18`. Node version `v21` is not supported and known to cause issues.

## Audit / Feature Status

Expand Down
10 changes: 6 additions & 4 deletions apps/hermes/client/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
"build": "tsc",
"generate-hermes-api-types": "openapi-zod-client https://hermes.pyth.network/docs/openapi.json --output src/zodSchemas.ts && prettier --write src/zodSchemas.ts",
"check-hermes-api-types": "git diff --exit-code src/zodSchemas.ts",
"example": "npm run build && node lib/examples/HermesClient.js",
"example": "pnpm run build && node lib/examples/HermesClient.js",
"format": "prettier --write \"src/**/*.ts\"",
"lint": "eslint src/",
"prepublishOnly": "npm run build && npm test && npm run lint",
"preversion": "npm run lint",
"version": "npm run format && git add -A src"
"prepublishOnly": "pnpm run build && pnpm test && pnpm run lint",
"preversion": "pnpm run lint",
"version": "pnpm run format && git add -A src"
},
"keywords": [
"pyth",
Expand All @@ -40,6 +40,7 @@
"devDependencies": {
"@types/eventsource": "^1.1.15",
"@types/jest": "^29.4.0",
"@types/node": "^20.14.2",
"@types/yargs": "^17.0.10",
"@typescript-eslint/eslint-plugin": "^5.21.0",
"@typescript-eslint/parser": "^5.21.0",
Expand All @@ -52,6 +53,7 @@
"yargs": "^17.4.1"
},
"dependencies": {
"@zodios/core": "^10.9.6",
"eventsource": "^2.0.2",
"zod": "^3.23.8"
}
Expand Down
4 changes: 2 additions & 2 deletions apps/price_pusher/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ COPY --chown=1000:1000 target_chains/solana/sdk/js target_chains/solana/sdk/js

COPY --chown=1000:1000 apps/price_pusher apps/price_pusher

RUN npx lerna run build --scope="@pythnetwork/price-pusher" --include-dependencies
RUN pnpm exec lerna run build --scope="@pythnetwork/price-pusher" --include-dependencies

WORKDIR /home/node/apps/price_pusher

ENTRYPOINT [ "npm", "run", "start" ]
ENTRYPOINT [ "pnpm", "run", "start" ]
2 changes: 1 addition & 1 deletion apps/price_pusher/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ To run the price pusher, please run the following commands, replacing the comman
```sh
# Please run the two following commands once from the root of the repo to build the code.
npm install
npx lerna run build --scope @pythnetwork/price-pusher --include-dependencies
pnpm exec lerna run build --scope @pythnetwork/price-pusher --include-dependencies
# Navigate to the price_pusher folder
cd apps/price_pusher
Expand Down
24 changes: 15 additions & 9 deletions apps/price_pusher/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
"lint": "eslint src/",
"start": "node lib/index.js",
"dev": "ts-node src/index.ts",
"prepublishOnly": "npm run build && npm test && npm run lint",
"preversion": "npm run lint",
"version": "npm run format && git add -A src"
"prepublishOnly": "pnpm run build && pnpm test && pnpm run lint",
"preversion": "pnpm run lint",
"version": "pnpm run format && git add -A src"
},
"keywords": [
"pyth",
Expand All @@ -42,27 +42,33 @@
"@types/ethereum-protocol": "^1.0.2",
"@types/jest": "^27.4.1",
"@types/yargs": "^17.0.10",
"@typescript-eslint/eslint-plugin": "^5.20.0",
"@typescript-eslint/parser": "^5.20.0",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"eslint": "^8.13.0",
"jest": "^29.7.0",
"prettier": "^2.6.2",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typescript": "^5.3.3"
},
"dependencies": {
"@coral-xyz/anchor": "^0.30.0",
"@injectivelabs/networks": "^1.14.6",
"@injectivelabs/sdk-ts": "1.10.72",
"@mysten/sui.js": "^0.49.1",
"@pythnetwork/price-service-client": "*",
"@pythnetwork/pyth-sdk-solidity": "*",
"@pythnetwork/pyth-solana-receiver": "*",
"@pythnetwork/pyth-sui-js": "*",
"@pythnetwork/price-service-client": "workspace:*",
"@pythnetwork/price-service-sdk": "workspace:^",
"@pythnetwork/pyth-sdk-solidity": "workspace:*",
"@pythnetwork/pyth-solana-receiver": "workspace:*",
"@pythnetwork/pyth-sui-js": "workspace:*",
"@pythnetwork/solana-utils": "workspace:*",
"@truffle/hdwallet-provider": "^2.1.3",
"aptos": "^1.8.5",
"jito-ts": "^3.0.1",
"joi": "^17.6.0",
"near-api-js": "^3.0.2",
"web3": "^1.8.1",
"web3-core": "^1.8.1",
"web3-eth-contract": "^1.8.1",
"yaml": "^2.1.1",
"yargs": "^17.5.1"
Expand Down
7 changes: 4 additions & 3 deletions apps/price_pusher/src/evm/evm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ import { addLeading0x, DurationInSeconds, removeLeading0x } from "../utils";
import AbstractPythAbi from "@pythnetwork/pyth-sdk-solidity/abis/AbstractPyth.json";
import HDWalletProvider from "@truffle/hdwallet-provider";
import Web3 from "web3";
import { HttpProvider, WebsocketProvider } from "web3-core";
import { isWsEndpoint } from "../utils";
import {
PriceServiceConnection,
HexString,
UnixTimestamp,
} from "@pythnetwork/price-service-client";
import { CustomGasStation } from "./custom-gas-station";
import { Provider } from "web3/providers";
import { PushAttempt } from "../common";
import { ProviderOrUrl } from "@truffle/hdwallet-provider/dist/constructor/types";

export class EvmPriceListener extends ChainPriceListener {
private pythContractFactory: PythContractFactory;
Expand Down Expand Up @@ -356,7 +357,7 @@ export class PythContractFactory {
return isWsEndpoint(this.endpoint);
}

createWeb3Provider() {
createWeb3Provider(): HttpProvider | WebsocketProvider {
if (isWsEndpoint(this.endpoint)) {
Web3.providers.WebsocketProvider.prototype.sendAsync =
Web3.providers.WebsocketProvider.prototype.send;
Expand Down Expand Up @@ -387,7 +388,7 @@ export class PythContractFactory {
mnemonic: {
phrase: this.mnemonic,
},
providerOrUrl: this.createWeb3Provider() as Provider,
providerOrUrl: this.createWeb3Provider() as ProviderOrUrl,
});
}
}
6 changes: 4 additions & 2 deletions apps/price_pusher/src/solana/solana.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ export class SolanaPricePusher implements IPricePusher {

async updatePriceFeed(
priceIds: string[],
pubTimesToPush: number[]
// eslint-disable-next-line @typescript-eslint/no-unused-vars
_pubTimesToPush: number[]
): Promise<void> {
if (priceIds.length === 0) {
return;
Expand Down Expand Up @@ -122,7 +123,8 @@ export class SolanaPricePusherJito implements IPricePusher {

async updatePriceFeed(
priceIds: string[],
pubTimesToPush: number[]
// eslint-disable-next-line @typescript-eslint/no-unused-vars
_pubTimesToPush: number[]
): Promise<void> {
let priceFeedUpdateData: string[];
try {
Expand Down
4 changes: 2 additions & 2 deletions contract_manager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ Each of these entities has a specialized class for each supported chain (EVM/Cos

# Docs

You can generate the docs by running `npx typedoc src/index.ts` from this directory. Open the docs by opening `docs/index.html` in your browser.
You can generate the docs by running `pnpm exec typedoc src/index.ts` from this directory. Open the docs by opening `docs/index.html` in your browser.

# Scripts

You can run the scripts by executing `npx ts-node scripts/<script_name>.ts` from this directory.
You can run the scripts by executing `pnpm exec ts-node scripts/<script_name>.ts` from this directory.
Loading

0 comments on commit bfe9b2c

Please sign in to comment.