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

chore: move all prettier formatting into individual packages #2478

Merged
merged 7 commits into from
Mar 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 7 additions & 5 deletions .github/workflows/ci-message-buffer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,24 @@ jobs:
run: |
sudo apt-get install g++-12
echo "CXX=/usr/bin/g++-12" >> "${GITHUB_ENV}"
- uses: actions/setup-node@v4
with:
node-version-file: "package.json"
# Libusb is a build requirement for the node-hid package and so pnpm
# install will fail if this isn't in the build environment and if a
# precompiled binary isn't found.
- name: Install libusb
run: sudo apt install -y libusb-1.0-0-dev libudev-dev
- uses: pnpm/action-setup@v4
name: Install pnpm
- name: Install prettier globally
run: pnpm install -g [email protected]
with:
run_install: true
- name: Build and generate IDLs
run: anchor build
- name: Copy anchor target files
run: cp ./target/idl/message_buffer.json idl/ && cp ./target/types/message_buffer.ts idl/
- name: Run prettier (to avoid pre-commit failures)
run: |
pnpm dlx [email protected] --write "./idl/*"
- name: Fix formatting (to avoid pre-commit failures)
run: pnpm turbo --filter message_buffer fix:format
- 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
71 changes: 0 additions & 71 deletions .github/workflows/ci-pre-commit.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/ci-turbo-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ jobs:
- name: Cache for Turbo
uses: rharkor/[email protected]
- name: Test
run: pnpm test:ci
run: pnpm turbo test
15 changes: 5 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,13 @@ repos:
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
rev: "v2.7.1"
hooks:
- id: prettier
additional_dependencies:
- "[email protected]"
- "[email protected]"
exclude: target_chains/sui/vendor/
- repo: local
hooks:
- id: turbo-fix
name: Run turbo fix on packages changed since the last commit
language: system
entry: sh -c 'TURBO_SCM_BASE="HEAD^1" pnpm turbo fix --affected'
pass_filenames: false
# Hooks for the remote executor
- id: cargo-fmt-remote-executor
name: Cargo format for remote executor
Expand Down
54 changes: 34 additions & 20 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,25 +1,39 @@
pnpm-lock.yaml
patches/
.turbo/
target_chains/sui/vendor/

# These apps have their own prettier config that uses a later version of
# prettier
#
# TODO(cprussin): eventually I'll figure out how to upgrade prettier everywhere
# and hook it in to pre-commit. For now, I don't want to downgrade prettier in
# the packages that are using the later version, and pre-commit doesn't support
# later versions of prettier directly.
#
# Ideally, we should probably hook up a pre-commit script to run auto-fixes in a
# generic way that packages can hook into by defining lifecycle scripts, or by
# using the nx task graph. Then, packages can use their own formatters /
# formatter versions and can also hook up other auto-fixes like eslint, etc.
#
# I'll explore doing this when I get around to spending some time on our nx
# build graph config.
apps/api-reference
apps/staking
apps/insights
apps/entropy-debugger
governance/pyth_staking_sdk
# This should stay in sync with the list of workspaces from
# `pnpm-workspace.yaml`
apps/*
packages/*
apps/hermes/client/js
governance/xc_admin/packages/*
governance/pyth_staking_sdk
price_service/sdk/js
price_service/client/js
pythnet/message_buffer
target_chains/aptos/cli
target_chains/aptos/sdk/js
target_chains/cosmwasm/tools
target_chains/cosmwasm/deploy-scripts
target_chains/ethereum/contracts
target_chains/ethereum/abi_generator
target_chains/ethereum/entropy_sdk/solidity
target_chains/ethereum/sdk/js
target_chains/ethereum/sdk/solidity
target_chains/ethereum/sdk/stylus/pyth-mock-solidity
target_chains/ethereum/examples/coin_flip/app
target_chains/fuel/sdk/js
target_chains/starknet/sdk/js
target_chains/sui/sdk/js
target_chains/sui/sdk/js-iota
target_chains/sui/cli
target_chains/sui/cli-iota
target_chains/solana/sdk/js/solana_utils
target_chains/solana/sdk/js/pyth_solana_receiver
target_chains/ton/contracts
target_chains/ton/sdk/js
contract_manager
lazer/contracts/solana
lazer/sdk/js
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ If you don't use nix at all, then install the required system packages:
`package.json`; you can experiment with
[corepack](https://nodejs.org/api/corepack.html) to manage your pnpm version
for you.
- [turbo](https://turbo.build/repo/docs/getting-started/installation)

#### Common tasks

Expand All @@ -109,13 +108,13 @@ and will only re-run as necessary. For any of the following tasks, you can pass
[any valid `turbo run` option](https://turbo.build/repo/docs/reference/run)
after `--`, for instance you could run `pnpm test -- --concurrency 2`.

- `pnpm test`: Run all unit tests, integration tests, linting, and format
- `pnpm turbo test`: Run all unit tests, integration tests, linting, and format
checks, as well as whatever other code checks any packages support.
- `pnpm fix`: Run auto fixes, including reformatting code and auto-fixing lint
rules where possible.
- `pnpm start:dev`: Start all development servers in parallel.
- `pnpm start:prod`: Run production builds and start production mode servers in
parallel.
- `pnpm turbo fix`: Run auto fixes, including reformatting code and auto-fixing
lint rules where possible.
- `pnpm turbo start:dev`: Start all development servers in parallel.
- `pnpm turbo start:prod`: Run production builds and start production mode
servers in parallel.

#### Building a new package

Expand Down
2 changes: 1 addition & 1 deletion apps/api-reference/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"eslint": "^9.5.0",
"jest": "^29.7.0",
"postcss": "^8.4.38",
"prettier": "^3.3.2",
"prettier": "catalog:",
"tailwindcss": "^3.4.4",
"typescript": "^5.5.2",
"vercel": "^34.2.7"
Expand Down
16 changes: 0 additions & 16 deletions apps/api-reference/turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,11 @@
"extends": ["//"],
"tasks": {
"build": {
"dependsOn": ["pull:env", "^build"],
"outputs": [".next/**", "!.next/cache/**"],
"env": [
"WALLETCONNECT_PROJECT_ID",
"AMPLITUDE_API_KEY",
"GOOGLE_ANALYTICS_ID"
]
},
"pull:env": {
"outputs": [".env.local"],
"cache": false
},
"start:dev": {
"dependsOn": ["pull:env"],
"persistent": true,
"cache": false
},
"start:prod": {
"dependsOn": ["build"],
"persistent": true,
"cache": false
}
}
}
19 changes: 0 additions & 19 deletions apps/entropy-debugger/turbo.json

This file was deleted.

7 changes: 4 additions & 3 deletions apps/hermes/client/js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,12 @@ The [HermesClient](./src/examples/HermesClient.ts) example demonstrates both the
examples above. To run the example:

1. Clone [the Pyth monorepo](https://github.com/pyth-network/pyth-crosschain)
2. In the root of the monorepo, run `pnpm example:hermes-client -- <args>`. For
example, to print BTC and ETH price feeds in the testnet network, run:
2. In the root of the monorepo, run `pnpm turbo --filter
@pythnetwork/hermes-client example -- <args>`. For example, to print BTC and
ETH price feeds in the testnet network, run:

```bash
pnpm example:hermes-client -- \
pnpm turbo --filter @pythnetwork/hermes-client example -- \
--endpoint https://hermes.pyth.network \
--price-ids \
0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43 \
Expand Down
6 changes: 4 additions & 2 deletions apps/hermes/client/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
"build:schemas": "openapi-zod-client ./schema.json --output src/zodSchemas.ts",
"pull:schema": "curl -o schema.json -z schema.json https://hermes.pyth.network/docs/openapi.json",
"example": "node lib/examples/HermesClient.js",
"format": "prettier --write \"src/**/*.ts\"",
"fix:lint": "eslint src/ --fix --max-warnings 0",
"fix:format": "prettier --write \"src/**/*.ts\"",
"test:lint": "eslint src/ --max-warnings 0",
"test:format": "prettier --check \"src/**/*.ts\"",
"prepublishOnly": "pnpm run build:typescript && pnpm run test:lint",
"preversion": "pnpm run test:lint",
"version": "pnpm run format && git add -A src"
Expand All @@ -44,7 +46,7 @@
"eslint": "^8.14.0",
"jest": "^29.4.0",
"openapi-zod-client": "^1.18.1",
"prettier": "^2.6.2",
"prettier": "catalog:",
"ts-jest": "^29.0.5",
"typescript": "catalog:",
"yargs": "^17.4.1"
Expand Down
Loading
Loading