Skip to content

Commit 72b9851

Browse files
committed
Split sweetpad-lib into a lib/core/cli workspace + vscode native addon
1 parent e77c55e commit 72b9851

138 files changed

Lines changed: 689 additions & 492 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/catalyst-oracle.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,18 @@ on:
55
branches: [main]
66
paths:
77
- "sweetpad-lib/**"
8+
- "sweetpad-core/**"
9+
- "sweetpad-cli/**"
10+
- "Cargo.toml"
11+
- "Cargo.lock"
812
- ".github/workflows/catalyst-oracle.yaml"
913
pull_request:
1014
paths:
1115
- "sweetpad-lib/**"
16+
- "sweetpad-core/**"
17+
- "sweetpad-cli/**"
18+
- "Cargo.toml"
19+
- "Cargo.lock"
1220
- ".github/workflows/catalyst-oracle.yaml"
1321
workflow_dispatch:
1422

@@ -37,7 +45,7 @@ jobs:
3745
- name: Cache cargo build
3846
uses: Swatinem/rust-cache@v2
3947
with:
40-
workspaces: sweetpad-lib
48+
workspaces: .
4149

4250
- name: Tooling versions
4351
run: |
@@ -56,5 +64,5 @@ jobs:
5664

5765
- name: Catalyst misdetection oracle
5866
env:
59-
SWEETPAD_BIN: ${{ github.workspace }}/sweetpad-lib/target/debug/sweetpad
67+
SWEETPAD_BIN: ${{ github.workspace }}/target/debug/sweetpad
6068
run: bash ci/catalyst-oracle.sh

.github/workflows/ci.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ jobs:
2323
with:
2424
node-version: 24
2525
- name: Install Rust toolchain
26-
working-directory: sweetpad-lib
27-
# Installs the channel + Apple targets pinned in sweetpad-lib/rust-toolchain.toml
26+
# Installs the channel + Apple targets pinned in rust-toolchain.toml
2827
run: rustup show
2928
- name: Install Dependencies
3029
run: npm ci

.github/workflows/cli-release.yaml

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ jobs:
2222
with:
2323
node-version: 24
2424
- name: Install Rust toolchain
25-
working-directory: sweetpad-lib
26-
# Installs the channel + Apple targets pinned in sweetpad-lib/rust-toolchain.toml
25+
# Installs the channel + Apple targets pinned in rust-toolchain.toml
2726
run: rustup show
2827

2928
- name: Resolve version
@@ -34,16 +33,24 @@ jobs:
3433
if [[ "${GITHUB_REF:-}" == refs/tags/cli-v* ]]; then
3534
VERSION="${GITHUB_REF_NAME#cli-v}"
3635
else
37-
VERSION="$(grep -m1 '^version' sweetpad-lib/Cargo.toml | cut -d'"' -f2)-dryrun"
36+
VERSION="$(grep -m1 '^version' Cargo.toml | cut -d'"' -f2)-dryrun"
3837
fi
3938
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
4039
echo "TARBALL=sweetpad-cli-$VERSION-macos-universal.tar.gz" >> "$GITHUB_ENV"
4140
echo "Building sweetpad CLI $VERSION"
4241
4342
- name: Build universal CLI
44-
# Builds the bundled injection client + the universal sweetpad binary into
45-
# sweetpad-lib/sweetpad-cli.
46-
run: npm run build:cli:universal -w @sweetpad/lib
43+
# Build the bundled injection client, then the universal `sweetpad` binary.
44+
run: |
45+
set -euo pipefail
46+
bash sweetpad-cli/vendor/injection-client/build.sh
47+
cargo build --release --bin sweetpad --target aarch64-apple-darwin
48+
cargo build --release --bin sweetpad --target x86_64-apple-darwin
49+
mkdir -p dist
50+
lipo -create -output dist/sweetpad \
51+
target/aarch64-apple-darwin/release/sweetpad \
52+
target/x86_64-apple-darwin/release/sweetpad
53+
chmod +x dist/sweetpad
4754
4855
- name: Import Developer ID certificate
4956
env:
@@ -70,8 +77,8 @@ jobs:
7077
set -euo pipefail
7178
IDENTITY="$(security find-identity -v -p codesigning "$KEYCHAIN" | awk -F'"' '/Developer ID Application/ { print $2; exit }')"
7279
test -n "$IDENTITY"
73-
codesign --force --options runtime --timestamp --sign "$IDENTITY" sweetpad-lib/sweetpad-cli
74-
codesign --verify --strict --verbose=2 sweetpad-lib/sweetpad-cli
80+
codesign --force --options runtime --timestamp --sign "$IDENTITY" dist/sweetpad
81+
codesign --verify --strict --verbose=2 dist/sweetpad
7582
7683
- name: Notarize the CLI
7784
env:
@@ -82,16 +89,13 @@ jobs:
8289
set -euo pipefail
8390
KEY_PATH="$RUNNER_TEMP/notary_key.p8"
8491
echo "$MACOS_NOTARY_KEY_P8" | base64 --decode > "$KEY_PATH"
85-
/usr/bin/zip -j "$RUNNER_TEMP/notarize.zip" sweetpad-lib/sweetpad-cli
92+
/usr/bin/zip -j "$RUNNER_TEMP/notarize.zip" dist/sweetpad
8693
xcrun notarytool submit "$RUNNER_TEMP/notarize.zip" --key "$KEY_PATH" --key-id "$MACOS_NOTARY_KEY_ID" --issuer "$MACOS_NOTARY_ISSUER_ID" --wait
8794
rm -f "$KEY_PATH"
8895
8996
- name: Package tarball
9097
run: |
9198
set -euo pipefail
92-
mkdir -p dist
93-
cp sweetpad-lib/sweetpad-cli dist/sweetpad
94-
chmod +x dist/sweetpad
9599
tar -C dist -czf "$TARBALL" sweetpad
96100
echo "SHA256=$(shasum -a 256 "$TARBALL" | cut -d' ' -f1)" >> "$GITHUB_ENV"
97101
shasum -a 256 "$TARBALL"

.github/workflows/cli-smoke.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,18 @@ on:
55
branches: [main]
66
paths:
77
- "sweetpad-lib/**"
8+
- "sweetpad-core/**"
9+
- "sweetpad-cli/**"
10+
- "Cargo.toml"
11+
- "Cargo.lock"
812
- ".github/workflows/cli-smoke.yaml"
913
pull_request:
1014
paths:
1115
- "sweetpad-lib/**"
16+
- "sweetpad-core/**"
17+
- "sweetpad-cli/**"
18+
- "Cargo.toml"
19+
- "Cargo.lock"
1220
- ".github/workflows/cli-smoke.yaml"
1321
workflow_dispatch:
1422

@@ -33,7 +41,7 @@ jobs:
3341
- name: Cache cargo build
3442
uses: Swatinem/rust-cache@v2
3543
with:
36-
workspaces: sweetpad-lib
44+
workspaces: .
3745

3846
- name: Tooling versions
3947
run: |
@@ -52,6 +60,6 @@ jobs:
5260

5361
- name: End-to-end CLI coverage (app + Swift package)
5462
env:
55-
SWEETPAD_BIN: ${{ github.workspace }}/sweetpad-lib/target/debug/sweetpad
63+
SWEETPAD_BIN: ${{ github.workspace }}/target/debug/sweetpad
5664
# Steps inherit `working-directory: sweetpad-lib`, so the path is relative to it.
5765
run: bash ci/smoke.sh

.github/workflows/sweetpad-lib.yaml

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,53 @@ on:
55
branches: [main]
66
paths:
77
- "sweetpad-lib/**"
8+
- "sweetpad-core/**"
9+
- "sweetpad-cli/**"
10+
- "sweetpad-vscode/native/**"
11+
- "Cargo.toml"
12+
- "Cargo.lock"
13+
- "rust-toolchain.toml"
814
- ".github/workflows/sweetpad-lib.yaml"
915
pull_request:
1016
paths:
1117
- "sweetpad-lib/**"
18+
- "sweetpad-core/**"
19+
- "sweetpad-cli/**"
20+
- "sweetpad-vscode/native/**"
21+
- "Cargo.toml"
22+
- "Cargo.lock"
23+
- "rust-toolchain.toml"
1224
- ".github/workflows/sweetpad-lib.yaml"
1325

14-
# The fast nets resolve against the committed `xcspec-cache/`, so they need no
15-
# Xcode and form the always-on regression gate — including the BSP arg-invariant
16-
# linter (the SDKROOT=auto class) and the compiler-args/settings oracles.
26+
# The fast nets resolve against the committed `sweetpad-lib/xcspec-cache/`, so
27+
# they need no Xcode and form the always-on regression gate — the BSP
28+
# arg-invariant linter, the compiler-args/settings oracles, and the parsers.
1729
#
1830
# The heavy tiers are NOT run here: they need a real Xcode 26.5 plus the
1931
# gitignored OSS corpus, so they're run locally / nightly off-CI —
20-
# BSP_CORPUS=1 cargo test --test bsp_corpus_completion (e2e clean-rate)
21-
# BSP_LIVE_DIFF=1 cargo test --test showbuildsettings_live_diff
22-
# python3 scripts/21_mutation_audit.py [--e2e] (coverage audit)
32+
# BSP_CORPUS=1 cargo test -p sweetpad-core --test bsp_corpus_completion
33+
# BSP_LIVE_DIFF=1 cargo test -p sweetpad-core --test showbuildsettings_live_diff
34+
# python3 sweetpad-lib/scripts/21_mutation_audit.py [--e2e]
2335

2436
jobs:
2537
check:
2638
name: fmt · clippy · test
2739
runs-on: macos-latest
28-
defaults:
29-
run:
30-
working-directory: sweetpad-lib
3140
steps:
3241
- uses: actions/checkout@v7
3342

3443
- name: Install Rust toolchain
35-
# Installs the channel + components pinned in sweetpad-lib/rust-toolchain.toml.
44+
# Installs the channel + components pinned in rust-toolchain.toml.
3645
run: rustup show
3746

3847
- name: Cache cargo build
3948
uses: Swatinem/rust-cache@v2
40-
with:
41-
workspaces: sweetpad-lib
4249

4350
- name: Format
44-
run: cargo fmt --check
51+
run: cargo fmt --all --check
4552

4653
- name: Clippy
47-
run: cargo clippy -- -D warnings
54+
run: cargo clippy --workspace --all-targets -- -D warnings
4855

4956
- name: Test
50-
run: cargo test
57+
run: cargo test --workspace

.github/workflows/xcode-tests.yaml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,18 @@ on:
1313
branches: [main, claude/cli-hot-reloading-c52yf2]
1414
paths:
1515
- "sweetpad-lib/**"
16+
- "sweetpad-core/**"
17+
- "sweetpad-cli/**"
18+
- "Cargo.toml"
19+
- "Cargo.lock"
1620
- ".github/workflows/xcode-tests.yaml"
1721
pull_request:
1822
paths:
1923
- "sweetpad-lib/**"
24+
- "sweetpad-core/**"
25+
- "sweetpad-cli/**"
26+
- "Cargo.toml"
27+
- "Cargo.lock"
2028
- ".github/workflows/xcode-tests.yaml"
2129
workflow_dispatch:
2230
schedule:
@@ -60,20 +68,20 @@ jobs:
6068
- name: Cache cargo build
6169
uses: Swatinem/rust-cache@v2
6270
with:
63-
workspaces: sweetpad-lib
71+
workspaces: .
6472
shared-key: xcode-tests
6573
- name: Build the sweetpad CLI
6674
run: cargo build --bin sweetpad
6775
- name: Unit tests
68-
run: cargo test
76+
run: cargo test --workspace
6977
- name: Install XcodeGen
7078
run: brew install xcodegen
7179
- name: Generate the fixture project
7280
working-directory: sweetpad-lib/ci/fixture-app
7381
run: xcodegen generate
7482
- name: End-to-end CLI coverage
7583
env:
76-
SWEETPAD_BIN: ${{ github.workspace }}/sweetpad-lib/target/debug/sweetpad
84+
SWEETPAD_BIN: ${{ github.workspace }}/target/debug/sweetpad
7785
run: bash ci/smoke.sh
7886

7987
# Build the injection client from source against the active Xcode (no
@@ -111,13 +119,13 @@ jobs:
111119
- name: Cache cargo build
112120
uses: Swatinem/rust-cache@v2
113121
with:
114-
workspaces: sweetpad-lib
122+
workspaces: .
115123
shared-key: xcode-tests
116124
# Build the injection client (XCTest-free, from the pinned InjectionNext SPM
117125
# product — vendor/injection-client) *before* cargo build, so build.rs embeds
118126
# it into the CLI. This is the same step the release scripts run.
119127
- name: Build the bundled injection client
120-
run: bash vendor/injection-client/build.sh
128+
run: bash ../sweetpad-cli/vendor/injection-client/build.sh
121129
- name: Build the sweetpad CLI
122130
run: cargo build --bin sweetpad
123131
- name: Install XcodeGen
@@ -129,5 +137,5 @@ jobs:
129137
# build time, so this exercises the real shipping path on this Xcode.
130138
- name: Hot-reload / injection e2e (embedded client)
131139
env:
132-
SWEETPAD_BIN: ${{ github.workspace }}/sweetpad-lib/target/debug/sweetpad
140+
SWEETPAD_BIN: ${{ github.workspace }}/target/debug/sweetpad
133141
run: bash ci/hot-reload-e2e.sh

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ node_modules
44
.vscode-test/
55
*.vsix
66

7+
# Rust workspace build output
8+
/target
9+
10+
# N-API addon build outputs (regenerated by build:native:*)
11+
sweetpad-vscode/native/*.node
12+
sweetpad-vscode/native/index.js
13+
sweetpad-vscode/native/index.d.ts
14+
715

816
# Ensure .vscode is not ignored in this project
917
!sweetpad-vscode/.vscode/
Lines changed: 29 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
[workspace]
2+
resolver = "2"
3+
members = [
4+
"sweetpad-lib",
5+
"sweetpad-core",
6+
"sweetpad-cli",
7+
"sweetpad-vscode/native",
8+
]
9+
10+
[workspace.package]
11+
version = "0.1.0"
12+
edition = "2024"
13+
rust-version = "1.94"
14+
license = "MIT OR Apache-2.0"
15+
authors = ["Yevhenii Hyzyla <hyzyla@gmail.com>"]
16+
17+
[workspace.dependencies]
18+
sweetpad-lib = { path = "sweetpad-lib" }
19+
sweetpad-core = { path = "sweetpad-core" }
20+
# JSON is a well-known standard format, not worth reinventing; hand-rolled
21+
# parsing is reserved for Apple's project-domain formats (DOCS.md §3.1).
22+
serde_json = "1"
23+
# Unicode NFD for the DerivedData path hash (xcode_hash); UAX #15 with a
24+
# de-facto crate — not worth hand-rolling the decomposition tables.
25+
unicode-normalization = "0.1"
26+
# CLI-only: clap derives the resource-first command tree, help, completions;
27+
# serde+toml read/write the XDG config & state files; dialoguer is the TTY
28+
# picker; libc flips raw-input flags for the interactive rebuild session.
29+
clap = { version = "4", features = ["derive", "env"] }
30+
clap_complete = "4"
31+
dialoguer = { version = "0.11", default-features = false, features = ["fuzzy-select"] }
32+
serde = { version = "1", features = ["derive"] }
33+
toml = "0.8"
34+
libc = "0.2"
35+
# N-API addon only (sweetpad-vscode/native).
36+
napi = { version = "3", default-features = false, features = ["napi8"] }
37+
napi-derive = "3"
38+
napi-build = "2"
39+
40+
[workspace.lints.clippy]
41+
pedantic = { level = "warn", priority = -1 }
42+
missing_errors_doc = "allow"
43+
missing_panics_doc = "allow"
44+
module_name_repetitions = "allow"
45+
# Apple identifiers (ProductType, OpenStep, BuildSystem, etc.) appear in doc
46+
# comments in their natural casing; backtick-wrapping all of them is noise.
47+
doc_markdown = "allow"

0 commit comments

Comments
 (0)