Files
vue-tui/vite.config.ts
T
Yunfei He 16e49024da test(runtime-tests): guard the shipped examples launch+paint in CI (#212) (#220)
* fix(examples): restore flexDirection column on basic-template

A past restyle (#137) replaced the root Box's `flexDirection="column"
:paddingX="1"` with `backgroundColor/borderStyle/width="20"` and dropped
the column direction. With the Ink-aligned default (row) and a fixed
`width="20"`, the six children pack into ~3-char columns and the title
interleaves illegibly. Restore `flexDirection="column"` so the example
renders as the intended bordered card.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* test(runtime-tests): PTY smoke suite guarding the examples launch+paint (#212)

#212's `Calling \`require\` for "node:module"` crash came from the old
@vue-tui/cli bundledDev step. The @vue-tui/vite plugin (#215) removed it,
but nothing exercised the shipped examples end to end, so a future
regression could break "the examples run" silently.

Add a node-pty smoke suite that launches basic-template and basic-jsx
through both the dev server (`vite`) and the production build
(`node dist/main.js`) under a real TTY and waits for the frame to paint;
coding-agent (needs an LLM key to run) gets a key-free build guard. A
static `CJS_REQUIRE_SHIM` assertion on the built bundle locks the #212
invariant directly, and `[vue-tui] failed to launch` / process-exit
signals fail a broken launch fast instead of burning the render timeout.
Wired in as the `ci:test:examples` branch of the CI graph.

Verified RED->GREEN: injecting a bare `require()` into an entry
reproduces #212 exactly and the guard catches it (statically and at
runtime); a non-module throw is caught via the dev launch-failure signal.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* refactor(runtime-tests): simplify the examples smoke harness

Cleanup pass on the new #212 smoke suite (no behavior change):
- use the `strip-ansi` package instead of a hand-rolled CSI regex (already a
  devDep here and used across the suite; strips OSC too, drops the eslint
  no-control-regex suppression);
- drop the onExitWaiters wake-up set — the 100ms poll already observes the exit
  flag, so onExit only needs to record the code;
- fold the three reject sites into one `fail()` helper;
- give the #212 bundle-shim invariant a single home: move CJS_REQUIRE_SHIM next
  to the builder and factor `buildAndExpectNoCjsRequire`, shared by the runnable
  apps and the coding-agent build guard;
- drop dead exports (repoRoot, CRASH_SIGNATURE).

Re-verified RED->GREEN (bundled require still caught) and all 5 tests green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* test(runtime-tests): serialize the examples suite files (match #222)

Adversarial review flagged the examples config's parallel-safety comment as
imprecise: PTY-process isolation does NOT isolate on-disk state. Each launched
example writes its optimizeDeps cache (examples/<name>/node_modules/.vite) and
bundle (examples/<name>/dist), so two test files launching the SAME example at
once would race that shared dir — the exact #222 failure the sibling
@vue-tui/vite suite just fixed with fileParallelism:false.

It can't happen today (one serial file, per-example caches), but set
fileParallelism:false to match #222 and keep it safe as the suite grows, and
correct the comment to state the real guarantee.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-28 03:01:10 +08:00

94 lines
4.0 KiB
TypeScript

import { defineConfig } from "vite-plus";
export default defineConfig({
staged: {
"*": "vp check --fix",
},
fmt: {},
lint: {
options: { typeAware: true, typeCheck: false },
rules: {
// This is a terminal UI library: parsing keyboard escape sequences and
// stripping ANSI requires regexes that match control characters (ESC,
// BEL, etc.) by design. no-control-regex flags every such pattern as a
// false positive across the codebase, so disable it library-wide. We
// already write them as \x1b /  unicode escapes (the rule's own
// suggested form), not raw bytes.
"no-control-regex": "off",
},
},
run: {
cache: false,
// `ci` is the parallel verification graph used by .github/workflows/ci.yml.
// The task runner fans out independent branches concurrently. Only fmt has
// no build dependency, so it starts immediately; lint, check:type, and the
// test suites all depend on build because they need the built dist
// (@vue-tui/runtime exposes no "types" export — consumers, and the
// type-aware lint rules, resolve its types and runtime from dist/*.d.mts).
// So the wall-clock critical path is build -> test:pty. The serial `ready`
// script in package.json mirrors this order (build before lint) for local use.
tasks: {
"ci:build": { command: "vp run build" },
"ci:fmt": { command: "vp run check:fmt" },
// lint depends on build: type-aware rules (e.g. no-implied-eval) on the
// PTY fixtures need @vue-tui/runtime's built types resolved, or they
// misfire on a fresh checkout. build is already on the critical path, so
// this doesn't change overall wall-clock.
"ci:lint": { command: "vp run check:lint", dependsOn: ["ci:build"] },
"ci:type": { command: "vp run check:type", dependsOn: ["ci:build"] },
// Test branches, one per suite via package#script. Normal packages keep a
// plain `test`; only runtime-tests splits into test:integration +
// test:pty. Targeting each suite directly keeps runtime-tests' slow PTY
// suite on its own parallel branch (not serial inside its `test`), and
// covers the runtime/testing unit tests that a runtime-tests-only run
// would miss.
"ci:test:runtime": {
command: "vp run @vue-tui/runtime#test",
dependsOn: ["ci:build"],
},
"ci:test:testing": {
command: "vp run @vue-tui/testing#test",
dependsOn: ["ci:build"],
},
"ci:test:integration": {
command: "vp run @vue-tui/runtime-tests#test:integration",
dependsOn: ["ci:build"],
},
"ci:test:pty": {
command: "vp run @vue-tui/runtime-tests#test:pty",
dependsOn: ["ci:build"],
},
// @vue-tui/vite (the Vite plugin: in-process dev server + production
// build) carries its own unit suite; run it on its own parallel branch
// like the other packages.
"ci:test:vite-plugin": {
command: "vp run @vue-tui/vite#test",
dependsOn: ["ci:build"],
},
// Examples smoke suite (#212): launch examples/basic-template and basic-jsx through a real
// PTY — both the dev server and the `node dist/main.js` build — and assert each paints a
// frame with no module-system crash. This is the regression guard for "the shipped examples
// actually run". Depends on ci:build for the built @vue-tui/runtime + @vue-tui/vite dist the
// examples consume; its own PTY pool keeps it on a separate parallel branch.
"ci:test:examples": {
command: "vp run @vue-tui/runtime-tests#test:examples",
dependsOn: ["ci:build"],
},
ci: {
command: "echo ci ok",
dependsOn: [
"ci:fmt",
"ci:lint",
"ci:type",
"ci:test:runtime",
"ci:test:testing",
"ci:test:integration",
"ci:test:pty",
"ci:test:vite-plugin",
"ci:test:examples",
],
},
},
},
});