Skip to content

feat(migrate): add post-bootstrap compile phase (tsc + optional vite build) - #112

Merged
vibe-dex merged 1 commit into
mainfrom
feat/migrate-compile-phase
May 1, 2026
Merged

vibe-dex merged 1 commit into
mainfrom
feat/migrate-compile-phase

Conversation

@vibe-dex

@vibe-dex vibe-dex commented May 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds Phase 8 — Compile to the migration pipeline. After bootstrap finishes installing deps and running codegen, the script actually invokes the TypeScript compiler (and optionally a full Vite build) to catch regressions that slip past the static `phase-verify` checks.

This is the gate that would have caught past migration regressions:

Behavior

Flag Effect
(default) Runs `npx tsc --noEmit`. Failures are warnings — migration completes, output truncated to ~50 lines.
`--strict` Promotes typecheck/build failures to errors (exit code 2). For CI.
`--with-build` Also runs `npx vite build` after typecheck. Slower (~30-90s) but catches runtime-only issues like missing exports / broken barrels.
`--no-compile` Skips the phase entirely.

Auto-skipped when `node_modules/` is missing (bootstrap install likely failed) — printed as a warning so the user knows why.

Design notes

  • `compile(ctx, opts)` returns `{ shouldFail }` and never calls `process.exit`. The CLI decides exit codes. Keeps the phase unit-testable.
  • Command runner is injectable via `opts.runner` so tests don't need to mock `child_process`. Default uses `execSync`.
  • Output capture uses `stdio: "pipe"` and prints a truncated tail of stdout+stderr on failure — users see the actual TS diagnostics rather than `Command failed: npx tsc`.

Files

  • `scripts/migrate/phase-compile.ts` — new phase (~140 lines).
  • `scripts/migrate.ts` — three new CLI flags wired through, `--help` updated.
  • `scripts/migrate/phase-compile.test.ts` — 11 new tests covering dry-run, missing `node_modules`, tsc success/failure, strict promotion, `--with-build` gating, and the `truncate` helper.
  • `.agents/skills/deco-migrate-script/SKILL.md` — new "Phase 8: Compile" section, options table updated, CI usage pattern documented.

Test plan

  • `npx vitest run` → 132 passed (was 121, +11 new)
  • `npm run typecheck` → clean
  • (Smoke later) Run the full migration script with `--strict --with-build` against a known-broken site and confirm it exits 2 with useful diagnostic output.

Recommended CI pattern

```bash
npx tsx node_modules/@decocms/start/scripts/migrate.ts --source ./site --strict --with-build
```

Pair with the existing `run-migration` skill for end-to-end test runs.

Made with Cursor


Summary by cubic

Adds Phase 8 — Compile to the migration pipeline. Runs tsc --noEmit and optional vite build after bootstrap to catch type and runtime regressions and provide a strict CI gate.

  • New Features

    • New compile phase runs TypeScript checks by default with truncated diagnostics; optional vite build for runtime issues.
    • Flags: --strict (fail with exit 2 on errors), --with-build (run vite build), --no-compile (skip phase). Auto-skips if node_modules/ is missing.
    • Injectable runner for tests; CLI help and .agents/skills/deco-migrate-script/SKILL.md updated; 11 tests added.
  • Migration

    • CI: run npx tsx node_modules/@decocms/start/scripts/migrate.ts --source ./site --strict --with-build.

Written for commit c09df31. Summary will update on new commits. Review in cubic

…build)

Adds a new Phase 8 to the migration pipeline that actually compiles the
migrated site after bootstrap completes. This is the gate that catches
regressions which slip past the static `phase-verify` checks — the same
class of bugs we hit in #105 (TS5097, rewriter leaving `.ts` in import
paths) and the dead `src/lib/*` shims that broke `phase-cleanup`.

## Behavior

- Default: runs `npx tsc --noEmit`. Failures are warnings — migration
  completes, but the user sees the truncated diagnostic output.
- `--strict`: failures abort the migration with exit code 2 so CI can
  fail the pipeline.
- `--with-build`: also runs `npx vite build` after typecheck. Slower
  (~30-90s) but catches runtime-only issues.
- `--no-compile`: skips the phase entirely.
- Auto-skipped when `node_modules/` is missing (bootstrap likely failed).

## Implementation

- `scripts/migrate/phase-compile.ts` — exports `compile(ctx, opts)`.
  Returns `{ shouldFail }` so the caller decides exit codes; we don't
  `process.exit` ourselves which keeps it unit-testable. The command
  runner is injectable via `opts.runner` for tests.
- `scripts/migrate.ts` — wires three new flags (`--strict`,
  `--with-build`, `--no-compile`) through to the phase. Updated
  `--help` output.
- `scripts/migrate/phase-compile.test.ts` — 11 tests covering dry-run,
  missing node_modules, success path, failure paths, strict promotion,
  build flag gating, and the truncate helper.
- `.agents/skills/deco-migrate-script/SKILL.md` — documents the new
  phase, flags, and CI usage pattern (`--strict --with-build`).

## Validation

- `npx vitest run` → 132 tests pass (was 121, +11 new)
- `npm run typecheck` → clean

Co-authored-by: Cursor <[email protected]>
@vibe-dex
vibe-dex merged commit 9f86cee into main May 1, 2026
1 check passed
@github-actions

github-actions Bot commented May 1, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 2.8.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant