Skip to content

Commit f32efec

Browse files
committed
chore: move all prettier formatting into individual packages
This PR makes a few related changes: - Stops using `pre-commit` to run prettier anywhere in the monorepo, instead we now run prettier from each package and trigger the runs using turborepo at the root. - Upgrade the prettier version used in all packages that were previously relying on `pre-commit` to run prettier. - Reformat files that need it due to the new prettier version. - Cleans up the turborepo config so that it now runs some tasks in the root package, and also automatically runs `pnpm install` when needed. The main downside of this PR is that auto-formatting on pre-commit will no longer happen, but for that I think we should help developers get their prettier editor integration set up so it happens on file save.
1 parent 2699171 commit f32efec

File tree

71 files changed

+798
-668
lines changed

Some content is hidden

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

71 files changed

+798
-668
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ jobs:
3333
- name: Cache for Turbo
3434
uses: rharkor/caching-for-turbo@v1.5
3535
- name: Test
36-
run: pnpm test:ci
36+
run: pnpm turbo test

.pre-commit-config.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,6 @@ 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-
- "prettier@2.7.1"
34-
- "prettier-plugin-solidity@1.0.0-rc.1"
35-
exclude: target_chains/sui/vendor/
3626
- repo: local
3727
hooks:
3828
# Hooks for the remote executor

.prettierignore

Lines changed: 34 additions & 20 deletions
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

apps/api-reference/turbo.json

Lines changed: 0 additions & 16 deletions
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

Lines changed: 0 additions & 19 deletions
This file was deleted.

apps/hermes/client/js/README.md

Lines changed: 4 additions & 3 deletions
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/turbo.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,23 @@
33
"extends": ["//"],
44
"tasks": {
55
"build:schemas": {
6-
"dependsOn": ["pull:schema"],
6+
"dependsOn": ["//#install:modules", "pull:schema"],
77
"inputs": ["schema.json"],
88
"outputs": ["src/zodSchemas.ts"]
99
},
1010
"build:typescript": {
11-
"dependsOn": ["build:schemas", "^build"],
11+
"dependsOn": ["//#install:modules", "build:schemas", "^build"],
1212
"outputs": ["lib/**"]
1313
},
1414
"build": {
1515
"dependsOn": ["build:typescript", "build:schemas"]
1616
},
1717
"example": {
18-
"dependsOn": ["build"],
18+
"dependsOn": ["//#install:modules", "build"],
1919
"cache": false
2020
},
2121
"pull:schema": {
22+
"dependsOn": ["//#install:modules"],
2223
"outputs": ["schema.json"],
2324
"cache": false
2425
}

apps/insights/turbo.json

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
"extends": ["//"],
44
"tasks": {
55
"build": {
6-
"dependsOn": ["pull:env", "^build"],
7-
"outputs": [".next/**", "!.next/cache/**"],
86
"env": [
97
"VERCEL_ENV",
108
"GOOGLE_ANALYTICS_ID",
@@ -17,36 +15,28 @@
1715
]
1816
},
1917
"fix:lint": {
20-
"dependsOn": ["fix:lint:eslint", "fix:lint:stylelint"],
21-
"cache": false
18+
"dependsOn": [
19+
"//#install:modules",
20+
"fix:lint:eslint",
21+
"fix:lint:stylelint"
22+
]
2223
},
2324
"fix:lint:eslint": {
24-
"dependsOn": ["^build"],
25+
"dependsOn": ["//#install:modules", "^build"],
2526
"cache": false
2627
},
2728
"fix:lint:stylelint": {
28-
"cache": false
29-
},
30-
"pull:env": {
31-
"outputs": [".env.local"],
32-
"cache": false
33-
},
34-
"start:dev": {
35-
"dependsOn": ["pull:env"],
36-
"persistent": true,
37-
"cache": false
38-
},
39-
"start:prod": {
40-
"dependsOn": ["build"],
41-
"persistent": true,
29+
"dependsOn": ["//#install:modules"],
4230
"cache": false
4331
},
4432
"test:lint": {
4533
"dependsOn": ["test:lint:eslint", "test:lint:stylelint"]
4634
},
4735
"test:lint:eslint": {
48-
"dependsOn": ["^build"]
36+
"dependsOn": ["//#install:modules", "^build"]
4937
},
50-
"test:lint:stylelint": {}
38+
"test:lint:stylelint": {
39+
"dependsOn": ["//#install:modules"]
40+
}
5141
}
5242
}

apps/staking/turbo.json

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
"extends": ["//"],
44
"tasks": {
55
"build": {
6-
"dependsOn": ["pull:env", "^build"],
7-
"outputs": [".next/**", "!.next/cache/**"],
86
"env": [
97
"IP_ALLOWLIST",
108
"GOVERNANCE_ONLY_REGIONS",
@@ -17,23 +15,13 @@
1715
"GOOGLE_ANALYTICS_ID"
1816
]
1917
},
20-
"pull:env": {
21-
"outputs": [".env.local"],
22-
"cache": false
23-
},
2418
"start:dev": {
2519
"dependsOn": [
20+
"//#install:modules",
2621
"pull:env",
2722
"@pythnetwork/hermes-client#build",
2823
"@pythnetwork/solana-utils#build"
29-
],
30-
"persistent": true,
31-
"cache": false
32-
},
33-
"start:prod": {
34-
"dependsOn": ["build"],
35-
"persistent": true,
36-
"cache": false
24+
]
3725
}
3826
}
3927
}

flake.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
cli = prev.lib.mkCli "cli" {
1919
_noAll = true;
2020

21-
start = "${prev.lib.getExe prev.pnpm} start:dev";
21+
start = "${prev.lib.getExe prev.pnpm} turbo start:dev";
2222

2323
test = {
2424
nix = {
2525
lint = "${prev.statix}/bin/statix check --ignore node_modules .";
2626
dead-code = "${prev.deadnix}/bin/deadnix --exclude ./node_modules .";
2727
format = "${prev.alejandra}/bin/alejandra --exclude ./node_modules --check .";
2828
};
29-
turbo = "${prev.lib.getExe prev.pnpm} test -- --ui stream";
29+
turbo = "${prev.lib.getExe prev.pnpm} turbo test -- --ui stream";
3030
};
3131

3232
fix = {
@@ -35,7 +35,7 @@
3535
dead-code = "${prev.deadnix}/bin/deadnix --exclude ./node_modules -e .";
3636
format = "${prev.alejandra}/bin/alejandra --exclude ./node_modules .";
3737
};
38-
turbo = "${prev.lib.getExe prev.pnpm} fix -- --ui stream";
38+
turbo = "${prev.lib.getExe prev.pnpm} turbo fix -- --ui stream";
3939
};
4040
};
4141
};

governance/xc_admin/packages/xc_admin_frontend/components/tabs/Proposals/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const PROPOSAL_STATUSES = [
2020
'draft',
2121
'unkwown',
2222
] as const
23-
export type ProposalStatus = typeof PROPOSAL_STATUSES[number]
23+
export type ProposalStatus = (typeof PROPOSAL_STATUSES)[number]
2424

2525
export const getProposalStatus = (
2626
proposal: TransactionAccount | undefined,

governance/xc_admin/packages/xc_admin_frontend/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
"pull:env": "[ $CI ] || VERCEL_ORG_ID=team_BKQrg3JJFLxZyTqpuYtIY0rj VERCEL_PROJECT_ID=prj_TCjesnm3pxM7Ay8oxlTH4xLkkmP9 vercel env pull",
1111
"start:dev": "next dev --port 3004",
1212
"start:prod": "next start --port 3004",
13+
"test:format": "prettier --check .",
14+
"fix:format": "prettier --write .",
1315
"test:lint": "next lint --max-warnings 0"
1416
},
1517
"dependencies": {

governance/xc_admin/packages/xc_admin_frontend/turbo.json

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,14 @@
33
"extends": ["//"],
44
"tasks": {
55
"build": {
6-
"dependsOn": ["pull:env", "^build"],
7-
"outputs": [".next/**", "!.next/cache/**"],
86
"env": [
97
"BUILD_STANDALONE",
108
"NEXT_PUBLIC_MAINNET_RPC",
119
"NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID"
1210
]
1311
},
14-
"pull:env": {
15-
"outputs": [".env.local"],
16-
"cache": false
17-
},
1812
"start:dev": {
19-
"dependsOn": ["pull:env", "^build"],
20-
"persistent": true,
21-
"cache": false
22-
},
23-
"start:prod": {
24-
"dependsOn": ["build"],
25-
"persistent": true,
26-
"cache": false
13+
"dependsOn": ["//#install:modules", "pull:env", "^build"]
2714
}
2815
}
2916
}

lazer/contracts/solana/turbo.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
"$schema": "https://turbo.build/schema.json",
33
"extends": ["//"],
44
"tasks": {
5-
"test": {
6-
"dependsOn": ["test:format"]
7-
},
85
"test:anchor": {}
96
}
107
}

lazer/sdk/js/examples/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const client = await PythLazerClient.create(
1010
["wss://pyth-lazer.dourolabs.app/v1/stream"],
1111
"access_token",
1212
3, // Optionally specify number of parallel redundant connections to reduce the chance of dropped messages. The connections will round-robin across the provided URLs. Default is 3.
13-
console // Optionally log socket operations (to the console in this case.)
13+
console, // Optionally log socket operations (to the console in this case.)
1414
);
1515

1616
// Read and process messages from the Lazer stream
@@ -23,7 +23,7 @@ client.addMessageListener((message) => {
2323
"stream updated for subscription",
2424
message.value.subscriptionId,
2525
":",
26-
message.value.parsed?.priceFeeds
26+
message.value.parsed?.priceFeeds,
2727
);
2828
}
2929
break;

lazer/sdk/js/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
"fix:lint": "eslint --fix . --max-warnings 0",
2727
"test:lint": "eslint . --max-warnings 0",
2828
"test:types": "tsc",
29+
"test:format": "prettier --check .",
30+
"fix:format": "prettier --write .",
2931
"example": "node --loader ts-node/esm examples/index.js",
3032
"doc": "typedoc --out docs/typedoc src",
3133
"publish": "pnpm run script -- publish"

0 commit comments

Comments
 (0)