Skip to content

Commit df1ca64

Browse files
authored
Merge pull request #2478 from pyth-network/cprussin/move-prettier-to-turbo
chore: move all prettier formatting into individual packages
2 parents 74ca371 + a909544 commit df1ca64

File tree

275 files changed

+5533
-3271
lines changed

Some content is hidden

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

275 files changed

+5533
-3271
lines changed

.github/workflows/ci-message-buffer.yml

+7-5
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,24 @@ jobs:
3838
run: |
3939
sudo apt-get install g++-12
4040
echo "CXX=/usr/bin/g++-12" >> "${GITHUB_ENV}"
41+
- uses: actions/setup-node@v4
42+
with:
43+
node-version-file: "package.json"
4144
# Libusb is a build requirement for the node-hid package and so pnpm
4245
# install will fail if this isn't in the build environment and if a
4346
# precompiled binary isn't found.
4447
- name: Install libusb
4548
run: sudo apt install -y libusb-1.0-0-dev libudev-dev
4649
- uses: pnpm/action-setup@v4
4750
name: Install pnpm
48-
- name: Install prettier globally
49-
run: pnpm install -g [email protected]
51+
with:
52+
run_install: true
5053
- name: Build and generate IDLs
5154
run: anchor build
5255
- name: Copy anchor target files
5356
run: cp ./target/idl/message_buffer.json idl/ && cp ./target/types/message_buffer.ts idl/
54-
- name: Run prettier (to avoid pre-commit failures)
55-
run: |
56-
pnpm dlx [email protected] --write "./idl/*"
57+
- name: Fix formatting (to avoid pre-commit failures)
58+
run: pnpm turbo --filter message_buffer fix:format
5759
- name: Check IDL changes
5860
# Fails if the IDL files are not up to date. Please use anchor build to regenerate the IDL files for
5961
# the current version of the contract and update idl directory.

.github/workflows/ci-pre-commit.yml

-71
This file was deleted.

.github/workflows/ci-turbo-test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ jobs:
3131
- name: Cache for Turbo
3232
uses: rharkor/[email protected]
3333
- name: Test
34-
run: pnpm test:ci
34+
run: pnpm turbo test

.pre-commit-config.yaml

+5-10
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,13 @@ repos:
2323
target_chains/sui/vendor/|
2424
patches/
2525
)
26-
# Hook to format many type of files in the repo
27-
# including solidity contracts.
28-
- repo: https://github.com/pre-commit/mirrors-prettier
29-
rev: "v2.7.1"
30-
hooks:
31-
- id: prettier
32-
additional_dependencies:
33-
34-
35-
exclude: target_chains/sui/vendor/
3626
- repo: local
3727
hooks:
28+
- id: turbo-fix
29+
name: Run turbo fix on packages changed since the last commit
30+
language: system
31+
entry: sh -c 'TURBO_SCM_BASE="HEAD^1" pnpm turbo fix --affected'
32+
pass_filenames: false
3833
# Hooks for the remote executor
3934
- id: cargo-fmt-remote-executor
4035
name: Cargo format for remote executor

.prettierignore

+34-20
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,39 @@
11
pnpm-lock.yaml
22
patches/
33
.turbo/
4+
target_chains/sui/vendor/
45

5-
# These apps have their own prettier config that uses a later version of
6-
# prettier
7-
#
8-
# TODO(cprussin): eventually I'll figure out how to upgrade prettier everywhere
9-
# and hook it in to pre-commit. For now, I don't want to downgrade prettier in
10-
# the packages that are using the later version, and pre-commit doesn't support
11-
# later versions of prettier directly.
12-
#
13-
# Ideally, we should probably hook up a pre-commit script to run auto-fixes in a
14-
# generic way that packages can hook into by defining lifecycle scripts, or by
15-
# using the nx task graph. Then, packages can use their own formatters /
16-
# formatter versions and can also hook up other auto-fixes like eslint, etc.
17-
#
18-
# I'll explore doing this when I get around to spending some time on our nx
19-
# build graph config.
20-
apps/api-reference
21-
apps/staking
22-
apps/insights
23-
apps/entropy-debugger
24-
governance/pyth_staking_sdk
6+
# This should stay in sync with the list of workspaces from
7+
# `pnpm-workspace.yaml`
8+
apps/*
259
packages/*
10+
apps/hermes/client/js
11+
governance/xc_admin/packages/*
12+
governance/pyth_staking_sdk
13+
price_service/sdk/js
14+
price_service/client/js
15+
pythnet/message_buffer
16+
target_chains/aptos/cli
17+
target_chains/aptos/sdk/js
18+
target_chains/cosmwasm/tools
19+
target_chains/cosmwasm/deploy-scripts
20+
target_chains/ethereum/contracts
21+
target_chains/ethereum/abi_generator
22+
target_chains/ethereum/entropy_sdk/solidity
23+
target_chains/ethereum/sdk/js
24+
target_chains/ethereum/sdk/solidity
25+
target_chains/ethereum/sdk/stylus/pyth-mock-solidity
26+
target_chains/ethereum/examples/coin_flip/app
27+
target_chains/fuel/sdk/js
28+
target_chains/starknet/sdk/js
29+
target_chains/sui/sdk/js
30+
target_chains/sui/sdk/js-iota
31+
target_chains/sui/cli
32+
target_chains/sui/cli-iota
33+
target_chains/solana/sdk/js/solana_utils
34+
target_chains/solana/sdk/js/pyth_solana_receiver
35+
target_chains/ton/contracts
36+
target_chains/ton/sdk/js
37+
contract_manager
38+
lazer/contracts/solana
39+
lazer/sdk/js

README.md

+6-7
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ If you don't use nix at all, then install the required system packages:
9898
`package.json`; you can experiment with
9999
[corepack](https://nodejs.org/api/corepack.html) to manage your pnpm version
100100
for you.
101-
- [turbo](https://turbo.build/repo/docs/getting-started/installation)
102101

103102
#### Common tasks
104103

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

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

120119
#### Building a new package
121120

apps/api-reference/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"eslint": "^9.5.0",
6161
"jest": "^29.7.0",
6262
"postcss": "^8.4.38",
63-
"prettier": "^3.3.2",
63+
"prettier": "catalog:",
6464
"tailwindcss": "^3.4.4",
6565
"typescript": "^5.5.2",
6666
"vercel": "^34.2.7"

apps/api-reference/turbo.json

-16
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,11 @@
33
"extends": ["//"],
44
"tasks": {
55
"build": {
6-
"dependsOn": ["pull:env", "^build"],
7-
"outputs": [".next/**", "!.next/cache/**"],
86
"env": [
97
"WALLETCONNECT_PROJECT_ID",
108
"AMPLITUDE_API_KEY",
119
"GOOGLE_ANALYTICS_ID"
1210
]
13-
},
14-
"pull:env": {
15-
"outputs": [".env.local"],
16-
"cache": false
17-
},
18-
"start:dev": {
19-
"dependsOn": ["pull:env"],
20-
"persistent": true,
21-
"cache": false
22-
},
23-
"start:prod": {
24-
"dependsOn": ["build"],
25-
"persistent": true,
26-
"cache": false
2711
}
2812
}
2913
}

apps/entropy-debugger/turbo.json

-19
This file was deleted.

apps/hermes/client/js/README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,12 @@ The [HermesClient](./src/examples/HermesClient.ts) example demonstrates both the
7676
examples above. To run the example:
7777

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

8283
```bash
83-
pnpm example:hermes-client -- \
84+
pnpm turbo --filter @pythnetwork/hermes-client example -- \
8485
--endpoint https://hermes.pyth.network \
8586
--price-ids \
8687
0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43 \

apps/hermes/client/js/package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@
2424
"build:schemas": "openapi-zod-client ./schema.json --output src/zodSchemas.ts",
2525
"pull:schema": "curl -o schema.json -z schema.json https://hermes.pyth.network/docs/openapi.json",
2626
"example": "node lib/examples/HermesClient.js",
27-
"format": "prettier --write \"src/**/*.ts\"",
27+
"fix:lint": "eslint src/ --fix --max-warnings 0",
28+
"fix:format": "prettier --write \"src/**/*.ts\"",
2829
"test:lint": "eslint src/ --max-warnings 0",
30+
"test:format": "prettier --check \"src/**/*.ts\"",
2931
"prepublishOnly": "pnpm run build:typescript && pnpm run test:lint",
3032
"preversion": "pnpm run test:lint",
3133
"version": "pnpm run format && git add -A src"
@@ -44,7 +46,7 @@
4446
"eslint": "^8.14.0",
4547
"jest": "^29.4.0",
4648
"openapi-zod-client": "^1.18.1",
47-
"prettier": "^2.6.2",
49+
"prettier": "catalog:",
4850
"ts-jest": "^29.0.5",
4951
"typescript": "catalog:",
5052
"yargs": "^17.4.1"

0 commit comments

Comments
 (0)