feat: generate Swift design-token adapter - #157
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a deterministic TypeScript-based generator that adapts the published @putdotio/design token graph into committed SwiftUI theme APIs (PutioTheme) inside PutioCore, then wires the placeholder iOS/watchOS/tvOS shells to consume that theme and adds drift checks to verification.
Changes:
- Introduces a boundary-validated token parser + Swift emitter (
scripts/generate-design-tokens.ts) and commits the generatedPutioTheme+Generated.swift. - Pins Node/pnpm/TypeScript tooling and integrates
pnpmverification (typecheck + node tests + tokens drift check) into the repo’s verify/test lanes. - Updates all three app shells to use the generated theme values (spacing/typography/colors), with tvOS-only theme values scoped under
#if os(tvOS).
Reviewed changes
Copilot reviewed 14 out of 18 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tsconfig.json | Adds TS config for NodeNext, strict typechecking, and script-only includes. |
| scripts/verify.sh | Runs pnpm install --frozen-lockfile before the repo’s verification pipeline. |
| scripts/test.sh | Adds pnpm run verify ahead of Swift lint/tests to enforce token/tooling verification. |
| scripts/generate-design-tokens.ts | Implements token parsing/validation and Swift code generation + drift check mode. |
| scripts/generate-design-tokens.test.ts | Adds node tests for boundary parsing behavior. |
| scripts/bootstrap.sh | Installs JS tooling deps during bootstrap to support token workflows. |
| README.md | Documents mise run tokens and the design-token ownership/drift model. |
| pnpm-lock.yaml | Locks @putdotio/design 2.0.1 and dev tooling versions for deterministic installs. |
| Packages/PutioCore/Tests/PutioCoreTests/PutioThemeTests.swift | Adds tests asserting the generated theme reports the pinned source + a few known values. |
| Packages/PutioCore/Sources/PutioCore/Generated/PutioTheme+Generated.swift | Adds committed generated Swift theme surface (PutioTheme, dynamic colors, font roles, motion, tvOS namespace). |
| package.json | Defines pnpm scripts for generation, drift checking, node tests, and typechecking. |
| mise.toml | Pins Node/pnpm via mise and adds a tokens task. |
| CONTRIBUTING.md | Documents design-token regeneration and drift expectations in contributor workflow. |
| Apps/watchOS/Sources/PutioWatchApp.swift | Switches signed-out placeholder styling to use PutioTheme. |
| Apps/tvOS/Sources/PutioTVApp.swift | Switches signed-out placeholder styling to use PutioTheme.TV + PutioTheme. |
| Apps/iOS/Sources/PutioApp.swift | Switches signed-out placeholder styling to use PutioTheme. |
| AGENTS.md | Updates agent workflow notes to include token generation and “don’t edit generated Swift”. |
| .gitignore | Ignores node_modules/ for the new JS tooling surface. |
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
All reported issues were addressed across 18 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 6 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
Summary
Generate the native SwiftUI theme from the exact published
@putdotio/designtoken graph and make it the only theming surface used by the iOS, watchOS, and tvOS placeholders.Closes #125.
Changed
@putdotio/design2.0.1PutioTheme.TVbehind#if os(tvOS)Review aids
Headless dark-mode screenshots will be attached to this PR after creation.
Risks
putio-design; this repository only adapts its versioned artifact.Verification
mise run verifypnpm tokens:checkfail with the regeneration instruction5443132; its sole finding was rejected because all three shell roots already force.preferredColorScheme(.dark)Complexity
The generator is deliberately explicit: it parses the external schema once, rejects unsupported values, and emits a shallow public theme API. No runtime package or token parsing ships in the apps.
Summary by cubic
Generate a SwiftUI design‑token adapter from
@putdotio/design2.0.1 and make it the single theming surface across iOS, watchOS, and tvOS. Fix dark‑mode color resolution at the app root and scale token line spacing with Dynamic Type; add tests to lock the generator and color resolution, implementing Linear #125.New Features
PutioTheme+Generated.swiftfrom the flat token graph (palettes, typography, spacing, radii, borders, motion, tvOS-only).PutioDynamicColor,PutioFontRole, andPutioCubicBezier; exposePutioTheme.TVbehind#if os(tvOS).@Environment(\.colorScheme)and set.preferredColorScheme(.dark)on the app root.Dependencies
pnpm11.2.2, TypeScript 7.0.2, and@putdotio/design2.0.1; addpackage.json,pnpm-lock.yaml, andtsconfig.json.mise run tokens; extend tasks/CI to install tooling, generate tokens, runtokens:check, and verify drift with Node and Swift tests.Written for commit 4cd282e. Summary will update on new commits.