Skip to content

Commit fb2b88a

Browse files
committed
test: add vitest with coverage for non-interactive agentic flow
Test suite (91 tests) focused on the agent-facing interface: - nonInteractive: flag validation (missing/invalid name, mode, features), full-mode execution (operation order, all features in output, postInstall), custom-mode execution (feature selection, partial postInstall), edge cases (empty features, trailing commas, whitespace trimming), error handling (operation failures produce JSON errors), JSON output format (parseable, required fields, absolute path) - info: JSON structure, all features present with description/default, postInstall conditional, no internal fields leaked, modes present - operations: cloneRepo (5-step sequence, execFile for user input, exec only for shell substitution, no projectName in shell strings), createEnvFile (correct cp command and cwd), installPackages (full/custom/all-selected modes, pnpm remove with correct packages, postinstall after remove, selected packages excluded), cleanupFiles (full-mode no-op, per-feature file removal, subgraph compound condition, package.json script patching, .install-files last) - utils: isValidName, isFeatureSelected, getPackagesToRemove, getPostInstallMessages Coverage: nonInteractive 95%, info/config/all operations 100%.
1 parent eef5a61 commit fb2b88a

12 files changed

Lines changed: 1928 additions & 2 deletions

AGENTS.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# AGENTS.md
2+
3+
This file provides guidance to AI coding agents working with code in this repository.
4+
5+
## What This Is
6+
7+
A CLI installer tool for dAppBooster projects, built with React + Ink (terminal UI framework). It walks users through an interactive setup flow: project naming, repo cloning, installation mode selection, optional packages, and post-install steps.
8+
9+
## Commands
10+
11+
- `pnpm build` — compile TypeScript (`tsc`)
12+
- `pnpm dev` — watch mode compilation
13+
- `pnpm test` — run tests (`vitest run`)
14+
- `pnpm lint` — run Biome linter (`biome check`)
15+
- `pnpm lint:fix` — auto-fix lint issues (`biome check --write`)
16+
17+
## Architecture
18+
19+
Entry: `source/cli.tsx` → renders the Ink React app.
20+
21+
`source/app.tsx` is the main component — a step-based state machine (`currentStep` integer) that renders each installer step in sequence. Steps advance via a `finishStep` callback.
22+
23+
### Key directories
24+
25+
- `source/components/steps/` — each installer step as a React component (ProjectName, CloneRepo, InstallationMode, OptionalPackages, Install, FileCleanup, PostInstall)
26+
- `source/components/` — reusable UI components (Ask, Divider, MainTitle, Multiselect)
27+
- `source/constants/config.ts` — feature package mappings and repo URL
28+
- `source/types/types.ts` — shared TypeScript types
29+
- `source/utils/utils.ts` — helper functions (validation, step visibility)
30+
31+
## Code Conventions
32+
33+
- **ESM**: `"type": "module"` — imports use explicit `.js` extensions
34+
- **Formatting**: Biome — single quotes, no semicolons, 2-space indent, 100-char line width
35+
- **Components**: Functional components with TypeScript (`FC<Props>`)
36+
- **State**: Local `useState` only, props/callbacks for parent-child communication
37+
- **Skip pattern**: Steps accept a `skip` prop to conditionally bypass themselves
38+
- **Node**: Requires v20+ (see `.nvmrc`)
39+
40+
## Release
41+
42+
GitHub Actions workflow (`.github/workflows/release.yml`) triggers on GitHub release events. Pre-releases do a dry-run; full releases publish to npm.

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
"scripts": {
1111
"build": "tsc",
1212
"dev": "tsc --watch",
13+
"test": "vitest run",
14+
"test:coverage": "vitest run --coverage",
1315
"lint": "pnpm biome check",
1416
"lint:fix": "pnpm biome check --write"
1517
},
@@ -31,8 +33,10 @@
3133
"@sindresorhus/tsconfig": "^7.0.0",
3234
"@types/node": "^22.15.21",
3335
"@types/react": "^18.3.22",
36+
"@vitest/coverage-v8": "^4.1.0",
3437
"ts-node": "^10.9.1",
35-
"typescript": "^5.8.3"
38+
"typescript": "^5.8.3",
39+
"vitest": "^4.1.0"
3640
},
3741
"pnpm": {
3842
"onlyBuiltDependencies": ["@biomejs/biome"]

0 commit comments

Comments
 (0)