Skip to content

Commit 6b7c178

Browse files
sxlijinseawatts
andauthored
[chore] refactor typescript directory (#2087)
# Major TypeScript Directory Refactor ## Overview This PR introduces a **major refactor of the TypeScript codebase**. The primary goal is to modernize, modularize, and clarify the structure of our TypeScript projects, making it easier to maintain, extend, and onboard new contributors. This is a breaking, high-impact change that affects nearly every TypeScript-related file and package. --- ## What Changed ### 1. **Monorepo Structure: All TypeScript Packages Moved to `/packages`** - **Before:** Many packages and apps (e.g., `fiddle-frontend`, `vscode-ext`, `playground-common`, `common`, etc.) were scattered directly under `typescript/` or in ad-hoc subfolders. - **After:** All reusable packages and libraries now live under `typescript/packages/`. This includes: - `baml-schema-wasm-node` - `baml-schema-wasm-web` - `codemirror-lang-baml` - `common` - `fiddle-proxy` - `language-server` - `nextjs-plugin` - `playground-common` - `ui` (new, see below) ### 2. **Apps Consolidated Under `/apps`** - **Before:** Apps like the playground and VSCode extension were in their own folders (`fiddle-frontend`, `vscode-ext/packages/vscode`, etc.). - **After:** All TypeScript-based apps now live under `typescript/apps/`: - `fiddle-web-app` (formerly `fiddle-frontend`) - `vscode-ext` (formerly `vscode-ext/packages/vscode` and `web-panel`) ### 3. **New `ui` Package** - All shared UI components (buttons, dialogs, forms, etc.) are now in `typescript/packages/ui/`. - This package is intended to be the single source of truth for UI primitives across all apps. ### 4. **Shared Code and Utilities** - The `common` and `playground-common` packages have been moved and refactored for clarity. - Shared logic, types, and utilities are now easier to find and import. ### 5. **Configuration and Tooling** - All build, lint, and workspace configuration files have been updated to reflect the new structure. - New workspace tools and base configs are in `typescript/workspace-tools/`. ### 6. **Removed/Deleted Files** - Legacy, duplicate, or now-unnecessary files and configs have been deleted. - Old package.jsons, tsconfigs, and other configs from the previous structure are gone. --- ## Why This Matters - **Consistency:** All TypeScript code now follows a clear, industry-standard monorepo structure. - **Maintainability:** Easier to update dependencies, share code, and onboard new contributors. - **Scalability:** Adding new packages or apps is now straightforward. - **Clarity:** No more confusion about where a package, component, or utility lives. --- ## Impact for Contributors - **Imports:** You may need to update import paths in your branches or local changes. - **Docs:** Please refer to the new folder structure when writing documentation or onboarding guides. - **Build/Test:** All scripts and CI should now reference the new locations. If you have custom scripts, update their paths. - **VSCode/IDE:** You may need to reload your workspace or update your project settings. --- ## Migration Guide - **Apps:** Look in `typescript/apps/` for all runnable applications. - **Packages:** Look in `typescript/packages/` for all libraries, shared code, and utilities. - **UI Components:** Use `@boundaryml/ui` for all shared UI needs. - **Workspace Tools:** See `typescript/workspace-tools/` for base configs and scripts. --- ## Summary Table | Old Location | New Location | | ------------------------------------------- | -------------------------------------------- | | `typescript/fiddle-frontend/` | `typescript/apps/fiddle-web-app/` | | `typescript/vscode-ext/packages/vscode/` | `typescript/apps/vscode-ext/` | | `typescript/vscode-ext/packages/web-panel/` | `typescript/apps/vscode-ext/src/web-panel/` | | `typescript/playground-common/` | `typescript/packages/playground-common/` | | `typescript/common/` | `typescript/packages/common/` | | `typescript/fiddle-proxy/` | `typescript/packages/fiddle-proxy/` | | `typescript/nextjs-plugin/` | `typescript/packages/nextjs-plugin/` | | `typescript/codemirror-lang-baml/` | `typescript/packages/codemirror-lang-baml/` | | `typescript/baml-schema-wasm-node/` | `typescript/packages/baml-schema-wasm-node/` | | `typescript/baml-schema-wasm-web/` | `typescript/packages/baml-schema-wasm-web/` | | `typescript/language-server/` | `typescript/packages/language-server/` | --- ## Final Notes - This is a **breaking change** for anyone with open PRs or local branches. Please rebase and update paths as needed. - If you find any missing or misplaced files, please open a follow-up PR or issue. --- --------- Co-authored-by: Chris Watts <chris@boundaryml.com>
1 parent 0db53c1 commit 6b7c178

768 files changed

Lines changed: 51123 additions & 59957 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.

.claude/settings.local.json

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,33 @@
99
"Bash(find:*)",
1010
"Bash(rg:*)",
1111
"Bash(cargo check:*)",
12+
"Bash(cargo build:*)",
13+
"Bash(find:*)",
14+
"Bash(ls:*)",
15+
"Bash(cargo install:*)",
16+
"Bash(*)",
17+
"Bash(pnpm build:*)",
18+
"Bash(pushd:*)",
19+
"Bash(popd:*)",
20+
"Bash(grep:*)",
21+
"Bash(pnpm:*)",
22+
"Bash(rm:*)",
23+
"Bash(dist/baml-cli --version)",
24+
"Bash(cargo:*)",
25+
"Bash(node_modules/.bin/baml-cli:*)",
26+
"Bash(node:*)",
27+
"Bash(chmod:*)",
28+
"Bash(timeout:*)",
29+
"Bash(gtimeout:*)",
30+
"Bash(mkdir:*)",
31+
"Bash(npx vitest run:*)",
32+
"mcp__ide__getDiagnostics",
33+
"Bash(cp:*)",
34+
"Bash(mv:*)",
35+
"Bash(tree:*)",
36+
"Bash(rg:*)",
1237
"Bash(cargo build:*)"
1338
],
1439
"deny": []
1540
}
16-
}
41+
}

.devcontainer/devcontainer.json

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
{
2-
"name": "BAML",
3-
"build": {
4-
"dockerfile": "Dockerfile"
5-
},
6-
"customizations": {
7-
"vscode": {
8-
"extensions": [
9-
"rust-lang.rust-analyzer",
10-
"ms-python.python",
11-
"Shopify.ruby-lsp",
12-
"golang.go",
13-
"vadimcn.vscode-lldb",
14-
"Boundary.baml-extension",
15-
"ms-azuretools.vscode-docker",
16-
"tamasfe.even-better-toml",
17-
"samuelcolvin.jinjahtml",
18-
"unifiedjs.vscode-mdx",
19-
"pest.pest-ide-tools",
20-
"biomejs.biome"
21-
]
22-
}
2+
"name": "BAML",
3+
"build": {
4+
"dockerfile": "Dockerfile"
5+
},
6+
"customizations": {
7+
"vscode": {
8+
"extensions": [
9+
"rust-lang.rust-analyzer",
10+
"ms-python.python",
11+
"Shopify.ruby-lsp",
12+
"golang.go",
13+
"vadimcn.vscode-lldb",
14+
"Boundary.baml-extension",
15+
"ms-azuretools.vscode-docker",
16+
"tamasfe.even-better-toml",
17+
"samuelcolvin.jinjahtml",
18+
"unifiedjs.vscode-mdx",
19+
"pest.pest-ide-tools",
20+
"biomejs.biome"
21+
]
2322
}
23+
}
2424
}

.github/actions/README.md

Lines changed: 253 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,253 @@
1+
# GitHub Actions - Setup Actions
2+
3+
This directory contains modular setup actions for the BAML project. Each action is focused on setting up a specific technology stack, allowing for better composability and caching strategies.
4+
5+
## Available Actions
6+
7+
### setup-all
8+
Sets up the complete development environment using all modular actions.
9+
10+
```yaml
11+
- name: Setup All
12+
uses: ./.github/actions/setup-all
13+
with:
14+
# Node.js configuration
15+
setup-node: 'true' # Optional, default: 'true'
16+
node-version: '20' # Optional, default: '20'
17+
pnpm-version: '9.12.0' # Optional, default: '9.12.0'
18+
install-node-dependencies: 'true' # Optional, default: 'true'
19+
enable-turbo-cache: 'true' # Optional, default: 'true'
20+
21+
# Rust configuration
22+
setup-rust: 'true' # Optional, default: 'true'
23+
rust-toolchain: 'stable' # Optional, default: 'stable'
24+
rust-enable-wasm: 'true' # Optional, default: 'true'
25+
rust-targets: '' # Optional, space-separated targets
26+
rust-workspace: 'engine' # Optional, default: 'engine'
27+
28+
# Python configuration
29+
setup-python: 'false' # Optional, default: 'false'
30+
python-version: '3.13' # Optional, default: '3.13'
31+
python-use-uv: 'false' # Optional, default: 'false'
32+
33+
# Go configuration
34+
setup-go: 'true' # Optional, default: 'true'
35+
go-version: '1.24' # Optional, default: '1.24'
36+
go-install-protoc-gen-go: 'true' # Optional, default: 'true'
37+
38+
# Tools configuration
39+
setup-tools: 'true' # Optional, default: 'true'
40+
tools-install-mise: 'true' # Optional, default: 'true'
41+
```
42+
43+
### setup-node
44+
Sets up Node.js with pnpm package manager.
45+
46+
```yaml
47+
- name: Setup Node.js
48+
uses: ./.github/actions/setup-node
49+
with:
50+
node-version: '20' # Optional, default: '20'
51+
pnpm-version: '9.12.0' # Optional, default: '9.12.0'
52+
install-dependencies: 'true' # Optional, default: 'true'
53+
frozen-lockfile: 'true' # Optional, default: 'true'
54+
enable-turbo-cache: 'true' # Optional, default: 'true'
55+
turbo-cache-path: '.turbo' # Optional, default: '.turbo'
56+
```
57+
58+
### setup-rust
59+
Sets up Rust toolchain with caching and optional WASM support.
60+
61+
```yaml
62+
- name: Setup Rust
63+
uses: ./.github/actions/setup-rust
64+
with:
65+
toolchain: 'stable' # Optional, default: 'stable'
66+
enable-wasm: 'false' # Optional, default: 'false'
67+
targets: 'x86_64-pc-windows-msvc' # Optional, space-separated targets
68+
workspace: 'engine' # Optional, default: 'engine'
69+
```
70+
71+
### setup-python
72+
Sets up Python with optional uv package manager.
73+
74+
```yaml
75+
- name: Setup Python
76+
uses: ./.github/actions/setup-python
77+
with:
78+
python-version: '3.13' # Optional, default: '3.13'
79+
use-uv: 'false' # Optional, default: 'false'
80+
cache: 'true' # Optional, default: 'true'
81+
```
82+
83+
### setup-go
84+
Sets up Go with optional protoc-gen-go.
85+
86+
```yaml
87+
- name: Setup Go
88+
uses: ./.github/actions/setup-go
89+
with:
90+
go-version: '1.24' # Optional, default: '1.24'
91+
install-protoc-gen-go: 'false' # Optional, default: 'false'
92+
cache: 'true' # Optional, default: 'true'
93+
```
94+
95+
### setup-tools
96+
Sets up common development tools.
97+
98+
```yaml
99+
- name: Setup Tools
100+
uses: ./.github/actions/setup-tools
101+
with:
102+
install-mise: 'false' # Optional, default: 'false'
103+
```
104+
105+
## Usage Patterns
106+
107+
### Complete Environment Setup
108+
For jobs that need everything (like full integration tests):
109+
```yaml
110+
- name: Setup All
111+
uses: ./.github/actions/setup-all
112+
with:
113+
setup-python: 'true'
114+
python-use-uv: 'true'
115+
```
116+
117+
### Full Environment (Minimal Python)
118+
For jobs that need most tools but minimal Python setup:
119+
```yaml
120+
- name: Setup All
121+
uses: ./.github/actions/setup-all
122+
with:
123+
setup-python: 'true'
124+
python-use-uv: 'false'
125+
```
126+
127+
### No Python Environment
128+
For jobs that don't need Python at all:
129+
```yaml
130+
- name: Setup All
131+
uses: ./.github/actions/setup-all
132+
# Python is disabled by default
133+
```
134+
135+
### TypeScript Lint Job
136+
Only needs Node.js and pnpm:
137+
```yaml
138+
- name: Setup Node.js
139+
uses: ./.github/actions/setup-node
140+
with:
141+
node-version: ${{ env.NODE_VERSION }}
142+
pnpm-version: ${{ env.PNPM_VERSION }}
143+
```
144+
145+
### Rust Build Job
146+
Only needs Rust toolchain:
147+
```yaml
148+
- name: Setup Rust
149+
uses: ./.github/actions/setup-rust
150+
with:
151+
toolchain: ${{ env.RUST_TOOLCHAIN }}
152+
targets: ${{ matrix.target }}
153+
```
154+
155+
### WASM Build Job
156+
Needs Rust with WASM support:
157+
```yaml
158+
- name: Setup Rust
159+
uses: ./.github/actions/setup-rust
160+
with:
161+
toolchain: ${{ env.RUST_TOOLCHAIN }}
162+
enable-wasm: 'true'
163+
```
164+
165+
### Integration Test Job
166+
Needs multiple technologies:
167+
```yaml
168+
- name: Setup Rust
169+
uses: ./.github/actions/setup-rust
170+
with:
171+
toolchain: ${{ env.RUST_TOOLCHAIN }}
172+
173+
- name: Setup Node.js
174+
uses: ./.github/actions/setup-node
175+
with:
176+
node-version: ${{ env.NODE_VERSION }}
177+
pnpm-version: ${{ env.PNPM_VERSION }}
178+
179+
- name: Setup Python
180+
uses: ./.github/actions/setup-python
181+
with:
182+
python-version: ${{ env.PYTHON_VERSION }}
183+
use-uv: 'true'
184+
```
185+
186+
## Benefits
187+
188+
1. **Modularity**: Each job only sets up what it needs
189+
2. **Reusability**: Actions can be reused across different workflows
190+
3. **Caching**: Each action handles its own caching strategy
191+
4. **Maintainability**: Changes to setup logic are isolated to specific actions
192+
5. **Performance**: Faster builds by avoiding unnecessary setup steps
193+
194+
## Migration from setup-environment
195+
196+
The old monolithic `setup-environment` action has been replaced with these modular actions. When migrating, you have two options:
197+
198+
### Option 1: Use setup-all (Easy Migration)
199+
Replace `setup-environment` with `setup-all`:
200+
```yaml
201+
# Before
202+
- name: Setup environment
203+
uses: ./.github/actions/setup-environment
204+
205+
# After
206+
- name: Setup All
207+
uses: ./.github/actions/setup-all
208+
# Uses sensible defaults for most BAML jobs
209+
```
210+
211+
### Option 2: Use Granular Actions (Optimal Performance)
212+
1. Identify what technologies your job actually needs
213+
2. Use only the relevant setup actions
214+
3. Remove the `setup-environment` action call
215+
4. Update any hardcoded tool versions to use the action inputs
216+
217+
This approach gives you the fastest builds by only setting up what you need.
218+
219+
## Turborepo Caching
220+
221+
The setup actions include optimized [Turborepo caching](https://turborepo.com/docs/guides/ci-vendors/github-actions) configuration:
222+
223+
### Dual Caching Strategy
224+
- **GitHub Actions Cache**: Fast local caching using `actions/cache@v4`
225+
- **Vercel Remote Cache**: Team-wide cache sharing using `TURBO_TOKEN` and `TURBO_TEAM`
226+
227+
### Configuration
228+
The `setup-node` action automatically configures Turbo caching:
229+
```yaml
230+
- name: Cache Turbo build setup
231+
uses: actions/cache@v4
232+
with:
233+
path: .turbo
234+
key: ${{ runner.os }}-turbo-${{ github.sha }}
235+
restore-keys: |
236+
${{ runner.os }}-turbo-
237+
```
238+
239+
### Environment Variables
240+
Set these in your workflow for remote caching:
241+
```yaml
242+
env:
243+
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
244+
TURBO_TEAM: gloo
245+
```
246+
247+
## pnpm Integration
248+
249+
As requested, the Node.js setup action prioritizes pnpm usage:
250+
- Automatically sets up pnpm caching
251+
- Installs dependencies via pnpm by default
252+
- Supports frozen lockfile mode for CI
253+
- All package.json scripts should run through pnpm when possible

0 commit comments

Comments
 (0)