# init-husky **Repository Path**: vitarx/init-husky ## Basic Information - **Project Name**: init-husky - **Description**: 初始化husky,可用于任意项目。 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-09-05 - **Last Updated**: 2025-09-10 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # @vitarx/init-husky > 一键初始化 Husky + Commitlint 的 npm 工具,适合 TypeScript 项目,自动生成 `commit-msg` 钩子和 `commitlint.config.ts` > 配置文件。 --- ## 特性 - 自动安装依赖:`husky`、`@commitlint/cli`、`@commitlint/config-conventional`、`tsx` - 初始化 `.husky` 目录 - 添加 `commit-msg` 钩子,自动执行 commitlint - 生成 `commitlint.config.ts`,默认支持 [Conventional Commits](https://www.conventionalcommits.org/) --- ## 安装 全局安装(可选): ```bash pnpm add -D @vitarx/init-husky ``` 使用 `npx` 或 `pnpm dlx` 直接执行: ```bash npx @vitarx/init-husky # 或 pnpm dlx @vitarx/init-husky ``` ## 使用方法 在项目根目录运行: ```bash npx @vitarx/init-husky # 或 init-husky # 必须全局安装! ``` 执行后会自动完成: 1. 安装必要依赖 2. 初始化 .husky 目录 3. 创建 commit-msg 钩子 4. 添加或更新 package.json 的 prepare 脚本 5. 生成 commitlint.config.ts > 如果已经存在 .husky 或 commitlint.config.ts,会跳过创建,防止覆盖。