$ show uni-helper/create-uni
This is a monorepo housing `create-uni`, a CLI scaffolding tool for quickly generating `uni-app` projects. `uni-app` is a cross-platform framework based on Vue, allowing development for iOS, Android, Web, and various mini-programs. The CLI supports interactive prompts (via `@clack/prompts`), command-line flags, a native desktop GUI (via a Rust `napi-rs` addon encapsulating `wry`), and an MCP (Model Context Protocol) server for AI-assisted project creation. The core package (`packages/core`) handles template rendering using EJS with a callback-driven data injection pattern, while `packages/config` provides the option catalogues. The GUI package combines a Rust webview with a Preact/TypeScript UI (built with shadcn/ui). The MCP package exposes two tools (`create-with-template`, `create-custom`) with Zod schemas auto-derived from config data. The project demonstrates strong architectural separation, modern tooling, and a novel integration of a native GUI into a Node.js CLI. Though tightly focused on the uni-app ecosystem, several internal patterns (template rendering, object merging, directory traversal, MCP server setup) are cleanly implemented and potentially reusable.
The LLM identified 6 files worth highlighting for reuse:
The core scaffolding engine. It recursively copies template files, handles package.json merging (via deepMerge), appends to .gitignore, and executes .data.mjs files as configuration callbacks. This design allows template extensions to inject data without modifying core logic, demonstrating a clean separation between template definition and rendering. Could be extracted for other project generators.
Provides helper functions (`addResolver`, `addImport`, `mergeExtraConfig`) used by `.data.mjs` template files to mutate the Vite configuration object. These functions manipulate plugin initializer strings and array inclusions, effectively creating a lightweight DSL for extending scaffolding output without direct code modification. This pattern is reusable in any code generation context that requires composable extensions.
Implements both pre-order and post-order directory traversal, skipping `.git` directories. The functions are generic, stateless, and exported as standalone utilities. They handle the typical file-system manipulation needs of scaffolding tools and could be published as a minimal npm package.
A recursive object merge that deduplicates arrays and deeply merges nested objects. Used extensively for merging package.json and Vite configuration from multiple template layers. The implementation is concise, idiomatic, and free of project-specific dependencies, making it a candidate for extraction into a shared utility library.
A Rust native addon (via napi-rs) that creates a desktop webview window using `wry`. It accepts configuration data via an environment variable, serves a bundled HTML UI, and communicates IPC events (file dialog, drag window, close) back to the CLI process. This pattern enables a Node.js CLI tool to offer a rich GUI without requiring Electron, and could be reused for other CLI tools needing a simple desktop interface.
Implements two MCP tools for creating uni-app projects. It dynamically builds CLI arguments and executes `npx create-uni@latest` via cross-spawn. The code demonstrates how to wrap an existing CLI as an MCP server, using Zod schemas auto-generated from the project's configuration data for rich AI-assisted parameter description. This pattern is directly applicable to other CLI tools wanting to expose MCP capabilities.