Skip to content

Commit 05ad99f

Browse files
authored
chore: migrate tooling to oxc, pnpm, and bazel (#58)
## Summary - replace ESLint and Prettier with Oxlint 1.75 and Oxfmt 0.60 - switch Yarn to pnpm 11.17 and add Lefthook 2.1 - build CJS, ESM, declarations, tests, and publish package with native Bazel rules - generate IDE `tsconfig.json` from a Starlark source of truth - upgrade Bazel to 9.2, Node to 26.5, and TypeScript to 7.0 - remove Jest, SWC, scripts, tool wrappers, and legacy build configs ## Test - `lefthook run pre-commit --all-files` - `bazel test //...` - `pnpm build` - `pnpm lint` - `pnpm test` - CJS and ESM package smoke tests
1 parent d33da21 commit 05ad99f

111 files changed

Lines changed: 3613 additions & 4502 deletions

File tree

Some content is hidden

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

‎.bazelrc‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
common --enable_bzlmod
2+
common --enable_platform_specific_config
3+
4+
test --test_output=errors

‎.bazelversion‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
9.2.0

‎.devcontainer/devcontainer.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"features": {
77
"ghcr.io/devcontainers/features/node:1": {}
88
},
9-
"postCreateCommand": "yarn install",
9+
"postCreateCommand": "corepack enable pnpm && pnpm install",
1010
"customizations": {
1111
"vscode": {
1212
"extensions": ["esbenp.prettier-vscode"]

‎.github/workflows/ci.yml‎

Lines changed: 55 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,26 @@ jobs:
2323
steps:
2424
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2525

26+
- name: Set up Bazel
27+
uses: bazel-contrib/setup-bazel@c5acdfb288317d0b5c0bbd7a396a3dc868bb0f86
28+
with:
29+
bazelisk-cache: true
30+
disk-cache: ${{ github.workflow }}-lint
31+
repository-cache: true
32+
2633
- name: Set up Node
2734
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
2835
with:
29-
node-version: '24'
36+
node-version: '26'
37+
38+
- name: Enable pnpm
39+
run: corepack enable pnpm
3040

31-
- name: Bootstrap
32-
run: ./scripts/bootstrap
41+
- name: Install dependencies
42+
run: pnpm install --frozen-lockfile
3343

34-
- name: Check types
35-
run: ./scripts/lint
44+
- name: Lint
45+
run: bazel test //:lint
3646

3747
build:
3848
timeout-minutes: 5
@@ -45,16 +55,26 @@ jobs:
4555
steps:
4656
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
4757

58+
- name: Set up Bazel
59+
uses: bazel-contrib/setup-bazel@c5acdfb288317d0b5c0bbd7a396a3dc868bb0f86
60+
with:
61+
bazelisk-cache: true
62+
disk-cache: ${{ github.workflow }}-build
63+
repository-cache: true
64+
4865
- name: Set up Node
4966
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
5067
with:
51-
node-version: '24'
68+
node-version: '26'
5269

53-
- name: Bootstrap
54-
run: ./scripts/bootstrap
70+
- name: Enable pnpm
71+
run: corepack enable pnpm
72+
73+
- name: Install dependencies
74+
run: pnpm install --frozen-lockfile
5575

5676
- name: Check build
57-
run: ./scripts/build
77+
run: bazel build //:pkg
5878

5979
- name: Get GitHub OIDC Token
6080
if: |-
@@ -73,7 +93,18 @@ jobs:
7393
URL: https://pkg.stainless.com/s
7494
AUTH: ${{ steps.github-oidc.outputs.github_token }}
7595
SHA: ${{ github.sha }}
76-
run: ./scripts/utils/upload-artifact.sh
96+
run: |
97+
set -euo pipefail
98+
package_path="$(bazel cquery --output=files //:pkg)"
99+
response="$(curl -fsS -X POST "$URL" \
100+
-H "Authorization: Bearer $AUTH" \
101+
-H "Content-Type: application/json")"
102+
signed_url="$(echo "$response" | jq -r -e '.url')"
103+
tarball="$(npm pack --silent "$package_path")"
104+
curl -fsS -X PUT \
105+
-H "Content-Type: application/gzip" \
106+
--data-binary "@$tarball" "$signed_url"
107+
echo "Installation: npm install 'https://pkg.stainless.com/s/perplexity-typescript/$SHA'"
77108
test:
78109
timeout-minutes: 10
79110
name: test
@@ -82,13 +113,23 @@ jobs:
82113
steps:
83114
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
84115

116+
- name: Set up Bazel
117+
uses: bazel-contrib/setup-bazel@c5acdfb288317d0b5c0bbd7a396a3dc868bb0f86
118+
with:
119+
bazelisk-cache: true
120+
disk-cache: ${{ github.workflow }}-test
121+
repository-cache: true
122+
85123
- name: Set up Node
86124
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
87125
with:
88-
node-version: '24'
126+
node-version: '26'
127+
128+
- name: Enable pnpm
129+
run: corepack enable pnpm
89130

90-
- name: Bootstrap
91-
run: ./scripts/bootstrap
131+
- name: Install dependencies
132+
run: pnpm install --frozen-lockfile
92133

93134
- name: Run tests
94-
run: ./scripts/test
135+
run: bazel test //:test

‎.github/workflows/publish-npm.yml‎

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,31 @@ jobs:
1919
steps:
2020
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2121

22+
- name: Set up Bazel
23+
uses: bazel-contrib/setup-bazel@c5acdfb288317d0b5c0bbd7a396a3dc868bb0f86
24+
with:
25+
bazelisk-cache: true
26+
disk-cache: ${{ github.workflow }}-publish
27+
repository-cache: true
28+
2229
- name: Set up Node
2330
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
2431
with:
25-
node-version: '24'
32+
node-version: '26'
2633

27-
- name: Install dependencies
28-
run: |
29-
yarn install
34+
- name: Enable pnpm
35+
run: corepack enable pnpm
3036

3137
- name: Publish to NPM
3238
run: |
33-
bash ./bin/publish-npm
39+
set -euo pipefail
40+
bazel build //:pkg
41+
package_path="$(bazel cquery --output=files //:pkg)"
42+
package_version="$(node -p "require('./$package_path/package.json').version")"
43+
if [[ "$package_version" == *-* ]]; then
44+
npm_dist_tag="${package_version#*-}"
45+
npm_dist_tag="${npm_dist_tag%%.*}"
46+
else
47+
npm_dist_tag=latest
48+
fi
49+
npm publish "$package_path" --access public --tag "$npm_dist_tag" --provenance

‎.gitignore‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
.prism.log
22
.stdy.log
33
node_modules
4-
yarn-error.log
4+
pnpm-debug.log*
55
codegen.log
66
Brewfile.lock.json
77
dist
88
dist-deno
9+
bazel-*
910
/*.tgz
1011
.idea/
1112
.eslintcache

‎.oxfmtrc.json‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"$schema": "./node_modules/oxfmt/configuration_schema.json",
3+
"arrowParens": "always",
4+
"printWidth": 110,
5+
"singleQuote": true,
6+
"trailingComma": "all",
7+
"sortPackageJson": false,
8+
"ignorePatterns": ["dist/**", "bazel-*/**"]
9+
}

‎.oxlintrc.json‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"$schema": "./node_modules/oxlint/configuration_schema.json",
3+
"ignorePatterns": ["dist/**", "bazel-*/**"],
4+
"categories": {
5+
"correctness": "off"
6+
},
7+
"plugins": ["typescript"],
8+
"rules": {
9+
"no-unused-vars": [
10+
"error",
11+
{
12+
"varsIgnorePattern": "^_",
13+
"args": "none",
14+
"caughtErrors": "none"
15+
}
16+
],
17+
"no-restricted-imports": [
18+
"error",
19+
{
20+
"patterns": [
21+
{
22+
"regex": "^@perplexity-ai/perplexity_ai(/.*)?",
23+
"message": "Use a relative import, not a package import."
24+
}
25+
]
26+
}
27+
]
28+
},
29+
"overrides": [
30+
{
31+
"files": ["tests/**", "examples/**"],
32+
"rules": {
33+
"no-restricted-imports": "off"
34+
}
35+
}
36+
]
37+
}

‎.prettierignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ CHANGELOG.md
55

66
# don't format tsc output, will break source maps
77
/dist
8+
/tsconfig.json

‎.prettierrc.json‎

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

0 commit comments

Comments
 (0)