Skip to content

refac: Extract shared script utilities into dev-tools - #792

Merged
simonrelet merged 4 commits into
devfrom
refactor-shared-style-uti
May 25, 2026
Merged

simonrelet merged 4 commits into
devfrom
refactor-shared-style-uti

Conversation

@simonrelet

Copy link
Copy Markdown
Member

Summary

  • Extract duplicated script utilities into @animeaux/dev-tools: all three apps copied getLengthValuePx, getBreakpoints, getSpacing, safelyReadFile, and relativeToCwd verbatim across their scripts/ directories.
  • Move oneAtTheTime from show's local scripts/shared.ts so it is available to any app.

Context

Each app's generate-theme.ts script and sprite generators duplicated the same helper functions with no meaningful variation. Centralising them in dev-tools is a natural fit: every app already depends on it, and dev-tools was always intended to host runtime utilities alongside its config exports.

The shared utilities are pure functions with no brand or app-specific logic — only the getColors / getFonts blocks remain app-specific, as intended.

Changes

  • Add libs/dev-tools/src/ with one file per utility: format-breakpoints.ts, format-spacing.ts, get-length-value-px.ts, one-at-the-time.ts, relative-to-cwd.ts, safely-read-file.ts, and a barrel index.ts.
  • Expose all utilities under the "." export so callers use import { … } from "@animeaux/dev-tools".
  • Rename code-generation helpers from getBreakpointsCode / getSpacingCode to formatBreakpoints / formatSpacing for consistency with the format* convention.
  • Add build infrastructure to dev-tools: TypeScript compilation, tsc-alias for #i/* path aliases, build:src / build:paths scripts, and postbuild: pnpm sync-workspace.
  • Remove scripts/shared.ts from admin, show, and website (now empty or superseded); update all script imports to @animeaux/dev-tools.

Risks and mitigations

  • N/A — pure refactor with no behaviour change. The generated src/generated/theme.ts output in each app is identical before and after.

Checklist

  • Added in-code documentation (wherever needed).
  • Ran the linter to ensure style guidelines were followed.
  • Reviewed the changes for regressions.
  • Manually tested the changed behaviour.

@simonrelet
simonrelet force-pushed the refactor-shared-style-uti branch from 120462b to 1b206e3 Compare May 25, 2026 11:44
@simonrelet
simonrelet merged commit 7c8c988 into dev May 25, 2026
7 checks passed
@simonrelet
simonrelet deleted the refactor-shared-style-uti branch May 25, 2026 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant