Skip to content

Commit b425407

Browse files
authored
Prevent GitHubClient types from being bundled (#81)
* Prevent `GitHubClient` types from being bundled * just use structural typing * add changeset * fmt
1 parent 6f89c14 commit b425407

5 files changed

Lines changed: 42 additions & 104 deletions

File tree

.changeset/curvy-lies-walk.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@changesets/ghcommit": patch
3+
---
4+
5+
Fixed an issue that caused GitHub types being bundled into the package and thus creating type incompatibilities in the dependent projects.

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@
6464
"@changesets/changelog-github": "^0.5.1",
6565
"@changesets/cli": "^2.27.7",
6666
"@graphql-codegen/cli": "^7.0.0",
67-
"@octokit/core": "^6.1.2",
68-
"@octokit/graphql": "^8.1.1",
6967
"@tsconfig/node22": "^22.0.5",
7068
"@types/node": "^20.11.24",
7169
"dotenv": "^16.4.5",

pnpm-lock.yaml

Lines changed: 0 additions & 99 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/github/graphql/queries.ts

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,37 @@
1-
export type GitHubClient = ReturnType<
2-
typeof import("@actions/github").getOctokit
3-
>;
1+
// Octokit types are messy. To avoid adding any (peer)dependencies we rely on TS structural typing here
2+
export type GitHubClient = {
3+
graphql: <T>(
4+
query: string,
5+
variables?: Record<string, unknown>,
6+
) => Promise<T>;
7+
rest: {
8+
git: {
9+
createRef: (params: {
10+
owner: string;
11+
repo: string;
12+
ref: string;
13+
sha: string;
14+
}) => Promise<{ data: { node_id?: string } }>;
15+
updateRef: (params: {
16+
owner: string;
17+
repo: string;
18+
ref: string;
19+
sha: string;
20+
force?: boolean;
21+
}) => Promise<{ data: { node_id?: string } }>;
22+
deleteRef: (params: {
23+
owner: string;
24+
repo: string;
25+
ref: string;
26+
}) => Promise<unknown>;
27+
getRef?: (params: {
28+
owner: string;
29+
repo: string;
30+
ref: string;
31+
}) => Promise<unknown>;
32+
};
33+
};
34+
};
435

536
import type {
637
CreateCommitOnBranchMutation,

tsdown.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ export default defineConfig({
1414
exports: false,
1515
// useful for running `build --watch` and `test` concurrently
1616
clean: !process.argv.includes("--watch"),
17+
deps: {
18+
onlyBundle: [], // require explicitly listing inlined dependencies
19+
},
1720

1821
sourcemap: !isCi,
1922
dts: { enabled: true, parallel: !isCi, sourcemap: !isCi },

0 commit comments

Comments
 (0)