Skip to content

Commit 29fd654

Browse files
authored
build: finish Bazel-native tooling cleanup (#64)
## Summary - remove Stainless metadata, telemetry, generated comments, hosted assets, and obsolete config - remove package scripts and unused `iconv-lite` - add `gazelle_ts` to own TypeScript source and dependency targets - update contributing commands to use Bazel, Gazelle, and Lefthook directly ## Test - `bazel build //:pkg` - `bazel test //...` - `bazel run //:gazelle -- -mode=diff` - Lefthook Oxfmt, Oxlint, and commitlint hooks
1 parent 3d3fcc0 commit 29fd654

91 files changed

Lines changed: 1023 additions & 602 deletions

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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
common --enable_bzlmod
22
common --enable_platform_specific_config
3+
common --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
4+
common --repo_env=BAZEL_NO_APPLE_CPP_TOOLCHAIN=1
5+
common --@llvm//config:experimental_stub_libgcc_s=True
6+
common:linux --host_platform=@gazelle_ts//platforms:local_gnu
7+
common:windows --host_platform=@gazelle_ts//platforms:local_windows_msvc
8+
9+
build:linux --linkopt=-no-pie
310

411
test --test_output=errors

.devcontainer/devcontainer.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,5 @@
66
"features": {
77
"ghcr.io/devcontainers/features/node:1": {}
88
},
9-
"postCreateCommand": "corepack enable pnpm && pnpm install",
10-
"customizations": {
11-
"vscode": {
12-
"extensions": ["esbenp.prettier-vscode"]
13-
}
14-
}
9+
"postCreateCommand": "corepack enable pnpm && pnpm install"
1510
}

.github/workflows/ci.yml

Lines changed: 5 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,15 @@
11
name: CI
22
on:
3+
pull_request:
34
push:
45
branches:
5-
- '**'
6-
- '!integrated/**'
7-
- '!stl-preview-head/**'
8-
- '!stl-preview-base/**'
9-
- '!generated'
10-
- '!codegen/**'
11-
- 'codegen/stl/**'
12-
pull_request:
13-
branches-ignore:
14-
- 'stl-preview-head/**'
15-
- 'stl-preview-base/**'
6+
- main
167

178
jobs:
189
lint:
1910
timeout-minutes: 10
2011
name: lint
21-
runs-on: ${{ github.repository == 'stainless-sdks/perplexity-typescript' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
22-
if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')
12+
runs-on: ubuntu-24.04
2313
steps:
2414
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2515
with:
@@ -72,11 +62,9 @@ jobs:
7262
build:
7363
timeout-minutes: 5
7464
name: build
75-
runs-on: ${{ github.repository == 'stainless-sdks/perplexity-typescript' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
76-
if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')
65+
runs-on: ubuntu-24.04
7766
permissions:
7867
contents: read
79-
id-token: write
8068
steps:
8169
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
8270

@@ -101,40 +89,10 @@ jobs:
10189
- name: Check build
10290
run: bazel build //:pkg
10391

104-
- name: Get GitHub OIDC Token
105-
if: |-
106-
github.repository == 'stainless-sdks/perplexity-typescript' &&
107-
!startsWith(github.ref, 'refs/heads/stl/')
108-
id: github-oidc
109-
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
110-
with:
111-
script: core.setOutput('github_token', await core.getIDToken());
112-
113-
- name: Upload tarball
114-
if: |-
115-
github.repository == 'stainless-sdks/perplexity-typescript' &&
116-
!startsWith(github.ref, 'refs/heads/stl/')
117-
env:
118-
URL: https://pkg.stainless.com/s
119-
AUTH: ${{ steps.github-oidc.outputs.github_token }}
120-
SHA: ${{ github.sha }}
121-
run: |
122-
set -euo pipefail
123-
package_path="$(bazel cquery --output=files //:pkg)"
124-
response="$(curl -fsS -X POST "$URL" \
125-
-H "Authorization: Bearer $AUTH" \
126-
-H "Content-Type: application/json")"
127-
signed_url="$(echo "$response" | jq -r -e '.url')"
128-
tarball="$(npm pack --silent "$package_path")"
129-
curl -fsS -X PUT \
130-
-H "Content-Type: application/gzip" \
131-
--data-binary "@$tarball" "$signed_url"
132-
echo "Installation: npm install 'https://pkg.stainless.com/s/perplexity-typescript/$SHA'"
13392
test:
13493
timeout-minutes: 10
13594
name: test
136-
runs-on: ${{ github.repository == 'stainless-sdks/perplexity-typescript' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
137-
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
95+
runs-on: ubuntu-24.04
13896
steps:
13997
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
14098

.gitignore

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
.prism.log
2-
.stdy.log
31
node_modules
42
pnpm-debug.log*
5-
codegen.log
63
Brewfile.lock.json
74
dist
8-
dist-deno
95
bazel-*
106
/*.tgz
117
.idea/
12-
.eslintcache
13-
oidc

.oxfmtrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
"singleQuote": true,
66
"trailingComma": "all",
77
"sortPackageJson": false,
8-
"ignorePatterns": ["dist/**", "bazel-*/**", "src/generated/**"]
8+
"ignorePatterns": ["dist/**", "bazel-*/**", "src/generated/**", "CHANGELOG.md", "tsconfig.json"]
99
}

.prettierignore

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

.stats.yml

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

BUILD.bazel

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,72 @@ load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
22
load("@aspect_rules_js//npm:defs.bzl", "npm_link_package", "npm_package")
33
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
44
load("@bazel_skylib//rules:write_file.bzl", "write_file")
5+
load("@gazelle//:def.bzl", "gazelle", "gazelle_binary")
56
load("@npm//:@arethetypeswrong/cli/package_json.bzl", attw_bin = "bin")
7+
load("@npm//:defs.bzl", "npm_link_all_packages")
68
load("@npm//:mocha/package_json.bzl", mocha_bin = "bin")
79
load("@npm//:publint/package_json.bzl", publint_bin = "bin")
810
load("@npm//:typescript/package_json.bzl", typescript_bin = "bin")
9-
load("@npm//:defs.bzl", "npm_link_all_packages")
1011
load("//:tsconfig.bzl", "BASE_COMPILER_OPTIONS", "TSCONFIG")
1112

1213
package(default_visibility = ["//visibility:public"])
1314

15+
# gazelle:exclude bazel-*
16+
# gazelle:exclude dist
17+
# gazelle:exclude node_modules
18+
# gazelle:exclude target
19+
# gazelle:exclude test-dist
20+
# gazelle:exclude tests
21+
# gazelle:map_kind ts_library ts_library //:ts.bzl
22+
# gazelle:map_kind ts_test ts_test //:ts.bzl
23+
# gazelle:ts_npm_link_pattern //:node_modules/{pkg}
24+
1425
exports_files(["package.json"])
1526

1627
npm_link_all_packages()
1728

29+
gazelle_binary(
30+
name = "gazelle_bin",
31+
languages = ["@gazelle_ts//ts"],
32+
)
33+
34+
gazelle(
35+
name = "gazelle",
36+
gazelle = ":gazelle_bin",
37+
)
38+
1839
typescript_bin.tsc_binary(name = "tsc")
1940

2041
write_file(
2142
name = "tsconfig_json",
2243
out = "_tsconfig.json",
23-
content = [json.encode_indent(TSCONFIG, indent = " ") + "\n"],
44+
content = [json.encode_indent(
45+
TSCONFIG,
46+
indent = " ",
47+
) + "\n"],
2448
)
2549

2650
write_source_files(
2751
name = "tsconfig",
2852
files = {"tsconfig.json": ":tsconfig_json"},
2953
)
3054

31-
TS_SOURCES = glob(["src/**/*.ts"])
55+
TS_SOURCES = [
56+
"//src",
57+
"//src/core",
58+
"//src/generated",
59+
"//src/internal",
60+
"//src/internal/decoders",
61+
"//src/internal/utils",
62+
"//src/lib",
63+
"//src/resources",
64+
"//src/resources/async",
65+
"//src/resources/async/chat",
66+
"//src/resources/browser",
67+
"//src/resources/chat",
68+
"//src/resources/responses",
69+
]
70+
3271
TEST_SOURCES = glob(["tests/**/*.ts"])
3372

3473
ts_project(
@@ -82,10 +121,10 @@ npm_link_package(
82121

83122
ts_project(
84123
name = "test_js",
124+
testonly = True,
85125
srcs = TEST_SOURCES,
86126
out_dir = "test-dist",
87127
root_dir = "tests",
88-
testonly = True,
89128
transpiler = "tsc",
90129
tsc = ":tsc",
91130
tsconfig = {
@@ -117,9 +156,9 @@ mocha_bin.mocha_test(
117156
"test-dist/**/*.test.js",
118157
],
119158
data = [
159+
"tests/uploads.test.ts",
120160
":node_modules/@perplexity-ai/perplexity_ai",
121161
":test_js",
122-
"tests/uploads.test.ts",
123162
],
124163
)
125164

CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ Full Changelog: [v0.26.1...v0.26.2](https://github.com/perplexityai/perplexity-n
184184

185185
### Chores
186186

187-
* **ci:** skip uploading artifacts on stainless-internal branches ([3d2b6b3](https://github.com/perplexityai/perplexity-node/commit/3d2b6b3abcc61ba4284b0c7382d8d53a5b0c167b))
188187
* **internal:** update dependencies to address dependabot vulnerabilities ([b494823](https://github.com/perplexityai/perplexity-node/commit/b494823152750452f7eaee967274904e30076615))
189188

190189
## 0.26.1 (2026-02-26)

CONTRIBUTING.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,26 @@ To set up the repository, run:
77
```sh
88
$ corepack enable pnpm
99
$ pnpm install
10-
$ pnpm build
10+
$ pnpm lefthook install
11+
$ bazel build //:pkg
1112
```
1213

1314
This installs dependencies and builds the publishable package at `bazel-bin/package/`.
1415

1516
## Modifying/Adding code
1617

17-
Most of the SDK is generated code. Modifications to code will be persisted between generations, but may
18-
result in merge conflicts between manual patches and changes from the generator. The generator will never
19-
modify the contents of the `src/lib/` and `examples/` directories.
18+
API resources are generated from the OpenAPI specification. Keep manual helpers in `src/lib/`.
19+
20+
Run Gazelle after adding, removing, or changing TypeScript imports. Gazelle owns
21+
TypeScript sources and dependencies in `BUILD.bazel` files.
22+
23+
```sh
24+
$ bazel run //:gazelle
25+
```
2026

2127
## Adding and running examples
2228

23-
All files in the `examples/` directory are not modified by the generator and can be freely edited or added to.
29+
Examples can be added under `examples/`.
2430

2531
```ts
2632
// add an example to examples/<your-example>.mts
@@ -40,7 +46,7 @@ $ node --experimental-transform-types examples/<your-example>.mts
4046
To link a local build:
4147

4248
```sh
43-
$ pnpm build
49+
$ bazel build //:pkg
4450
$ pnpm --dir bazel-bin/package link --global
4551
$ cd ../my-package
4652
$ pnpm link --global @perplexity-ai/perplexity_ai
@@ -49,7 +55,7 @@ $ pnpm link --global @perplexity-ai/perplexity_ai
4955
## Running tests
5056

5157
```sh
52-
$ pnpm test
58+
$ bazel test //...
5359
```
5460

5561
## Linting and formatting
@@ -60,13 +66,13 @@ This repository uses [Oxfmt](https://www.npmjs.com/package/oxfmt) and
6066
To lint:
6167

6268
```sh
63-
$ pnpm lint
69+
$ pnpm lefthook run pre-commit --all-files --force --fail-on-changes
6470
```
6571

6672
To format and fix all lint issues automatically:
6773

6874
```sh
69-
$ pnpm fix
75+
$ pnpm lefthook run pre-commit --all-files
7076
```
7177

7278
## Publishing and releases
@@ -80,5 +86,4 @@ You can release to package managers by using [the `Publish NPM` GitHub action](h
8086

8187
### Publish manually
8288

83-
If you need to manually release a package, you can run the `bin/publish-npm` script with an `NPM_TOKEN` set on
84-
the environment.
89+
If needed, build the package with `bazel build //:pkg` and publish `bazel-bin/package` with npm.

0 commit comments

Comments
 (0)