Skip to content

Commit dca296e

Browse files
committed
Migrate SDK type generation from ts-rs to but-ts (schemars)
Rust side: - Register all frontend-facing types with schemars JsonSchema + register_sdk_type!() across gitbutler-branch-actions, but-api, but-workspace, but-settings, but-core, but-github, but-gitlab, gitbutler-edit-mode, and gitbutler-operating-modes - Add export-schema Cargo feature to gitbutler-branch-actions and gitbutler-edit-mode with conditional schemars guards - Add rename_all = "camelCase" to but_core::ui::WorktreeChanges (fixes ignored_changes field being snake_case in JSON) - Remove skip_serializing_if from SDK-registered types so nullable fields are always serialized (as null), matching the but-ts assumption - Remove ts-rs derives and Cargo feature flags from all crates - Delete generate-ts-definitions-from-rust.sh script - Enhance but-ts: --source-crates filter, nullable-but-required field handling, append-to-existing output mode TypeScript side: - Delete all ts-rs generated files from @gitbutler/core - Remove hand-written type duplicates from the desktop app (~40 files) and replace with direct imports from @gitbutler/but-sdk - Add browser export condition to @gitbutler/but-sdk package.json with empty stub so Vite serves it instead of the napi index.js - Add @gitbutler/but-sdk to Vite optimizeDeps.exclude
1 parent d307086 commit dca296e

228 files changed

Lines changed: 1533 additions & 2673 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.

.github/workflows/push.yaml

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -92,27 +92,6 @@ jobs:
9292
- uses: ./.github/actions/init-env-node
9393
- run: pnpm prettier
9494

95-
generate-ts-definitions:
96-
needs: changes
97-
if: ${{ needs.changes.outputs.node == 'true' || needs.changes.outputs.rust == 'true' }}
98-
runs-on: ubuntu-latest
99-
env:
100-
CARGO_TERM_COLOR: always
101-
steps:
102-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
103-
with:
104-
persist-credentials: false
105-
- name: Rust Cache
106-
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
107-
with:
108-
shared-key: ts-def-gen
109-
save-if: ${{ github.ref == 'refs/heads/master' }}
110-
# Node is needed for the formatting of typescript files.
111-
- uses: ./.github/actions/init-env-node
112-
- name: Dependencies for 'keyring'
113-
run: sudo ./scripts/install-minimal-debian-dependencies.sh
114-
- run: ./scripts/generate-ts-definitions-from-rust.sh
115-
11695
lint-node:
11796
needs: changes
11897
if: ${{ needs.changes.outputs.node == 'true' }}

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ gix = { version = "0.81.0", git = "https://github.com/GitoxideLabs/gitoxide", re
217217
] }
218218
gix-testtools = { version = "0.19.0", git = "https://github.com/GitoxideLabs/gitoxide", rev = "50fb46f17acba7d75d4ed6795b7b9cef484e34c6" }
219219

220-
ts-rs = { version = "11.1.0", features = ["serde-compat", "no-serde-warnings"] }
220+
221221
insta = { version = "1.45.1", features = ["json"] }
222222
git2 = { version = "0.20.4", features = [
223223
"vendored-openssl",

apps/desktop/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
},
2121
"devDependencies": {
2222
"@anthropic-ai/sdk": "^0.80.0",
23+
"@gitbutler/but-sdk": "workspace:*",
2324
"@gitbutler/core": "workspace:*",
2425
"@gitbutler/design-core": "2.2.2",
2526
"@gitbutler/shared": "workspace:*",

apps/desktop/src/components/branch/BranchBadge.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script lang="ts">
22
import { getBranchStatusLabelAndColor } from "$components/lib";
3-
import type { PushStatus } from "$lib/stacks/stack";
3+
import type { PushStatus } from "@gitbutler/but-sdk";
44
55
type Props = {
66
pushStatus: PushStatus;

apps/desktop/src/components/branch/BranchCard.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import { isDefined } from "@gitbutler/ui/utils/typeguards";
2323
import type { BranchIconName } from "$lib/branches/branchIcon";
2424
import type { DropzoneHandler } from "$lib/dragging/handler";
25-
import type { PushStatus } from "$lib/stacks/stack";
25+
import type { PushStatus } from "@gitbutler/but-sdk";
2626
import type { Snippet } from "svelte";
2727
2828
interface BranchCardProps {

apps/desktop/src/components/branch/BranchDetails.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script lang="ts">
22
import BranchBadge from "$components/branch/BranchBadge.svelte";
3-
import { type BranchDetails } from "$lib/stacks/stack";
43
import { AvatarGroup, Button } from "@gitbutler/ui";
4+
import type { BranchDetails } from "@gitbutler/but-sdk";
55
import type { Snippet } from "svelte";
66
77
type Props = {

apps/desktop/src/components/branch/BranchHeader.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import { DRAG_STATE_SERVICE } from "@gitbutler/ui/drag/dragStateService.svelte";
2020
import { focusable } from "@gitbutler/ui/focus/focusable";
2121
import { slide } from "svelte/transition";
22-
import type { PushStatus } from "$lib/stacks/stack";
22+
import type { PushStatus } from "@gitbutler/but-sdk";
2323
import type { Snippet } from "svelte";
2424
import type { ComponentProps } from "svelte";
2525

apps/desktop/src/components/branch/BranchHeaderContextMenu.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
} from "@gitbutler/ui";
3333
3434
import { tick } from "svelte";
35-
import type { AnchorPosition, BranchDetails } from "$lib/stacks/stack";
35+
import type { AnchorPosition } from "$lib/stacks/stack";
36+
import type { BranchDetails } from "@gitbutler/but-sdk";
3637
3738
type Props = {
3839
projectId: string;

apps/desktop/src/components/branch/BranchIntegrationModal.svelte

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,7 @@
22
import CommitTimelineNode from "$components/commit/CommitTimelineNode.svelte";
33
import ReduxResult from "$components/shared/ReduxResult.svelte";
44
import { CLIPBOARD_SERVICE } from "$lib/backend/clipboard";
5-
import {
6-
commitCreatedAtDate,
7-
extractUpstreamCommitId,
8-
isCommit,
9-
type Commit,
10-
type UpstreamCommit,
11-
} from "$lib/branches/v3";
5+
import { commitCreatedAtDate, extractUpstreamCommitId, isCommit } from "$lib/branches/v3";
126
import { STACK_SERVICE } from "$lib/stacks/stackService.svelte";
137
import {
148
canShiftStepDown,
@@ -27,6 +21,7 @@
2721
import { untrack } from "svelte";
2822
import { flip } from "svelte/animate";
2923
import type { InteractiveIntegrationStep } from "$lib/stacks/stack";
24+
import type { Commit, UpstreamCommit } from "@gitbutler/but-sdk";
3025
3126
type Props = {
3227
modalRef: Modal | undefined;

0 commit comments

Comments
 (0)