{"id":27995545,"url":"https://github.com/chokcoco/inithusky","last_synced_at":"2025-05-08T20:33:23.100Z","repository":{"id":57273932,"uuid":"248162466","full_name":"chokcoco/inithusky","owner":"chokcoco","description":"Install git hooks automatically.","archived":false,"fork":false,"pushed_at":"2020-05-11T03:50:19.000Z","size":8825,"stargazers_count":5,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-22T01:03:36.675Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/inithusky","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chokcoco.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-18T07:11:10.000Z","updated_at":"2020-06-28T09:07:55.000Z","dependencies_parsed_at":"2022-09-17T15:11:37.786Z","dependency_job_id":null,"html_url":"https://github.com/chokcoco/inithusky","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chokcoco%2Finithusky","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chokcoco%2Finithusky/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chokcoco%2Finithusky/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chokcoco%2Finithusky/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chokcoco","download_url":"https://codeload.github.com/chokcoco/inithusky/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253145267,"owners_count":21861217,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-08T20:33:13.203Z","updated_at":"2025-05-08T20:33:23.071Z","avatar_url":"https://github.com/chokcoco.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![npm_version](https://img.shields.io/npm/v/inithusky.svg)\n\n## initHusky\n\n配置 hushy 和 lint-staged 太繁琐？安装 initHusky 一键帮你搞定。\n\n## Feature\n\n+ 可选自动安装 commitlint git hook，向远端 Git 仓库提交代码时，自动进行 commitlint 检测\n+ 可选自动安装 eslint git hook，向远端 Git 仓库提交代码时，自动对增量 Javascript 代码进行 Eslint 检测\n+ 可选自动安装 stylelint git hook，向远端 Git 仓库提交代码时，自动对增量 Css 代码进行 stylelint 检测\n\n## Installation\n\n首先，全局安装 inithusky 指令：\n\n```\nnpm install -g inithusky\n```\n\n接着，便可以在任意项目的根目录下创建 Git 钩子。\n\n## Use\n\n进入任意项目根目录，执行 `inithusky`\n\n```\n$ inithusky\n```\n\n选择你要安装的钩子，提供三种钩子：\n\n1. commitlint（调用 husky 的 commit-msg 钩子） \n2. eslint（调用 husky 的 pre-commit 钩子）\n3. stylelint（调用 husky 的 pre-commit 钩子）\n\n```\n$ inithusky\n欢迎使用自动化 Git 钩子安装程序\n? 是否需要安装 commitlint Git 钩子? Yes\n? 是否需要安装 Eslint Git 钩子?(对 Javascript 代码进行风格规范检测) Yes\n? 是否需要安装 Stylelint Git 钩子?(对 CSS 代码进行风格规范检测) Yes\n```\n\n确定你想安装的钩子之后，\n\n1. 将会自动修改项目根目录下的 `package.json`，添加相关依赖，添加 husky 与 lint-staged 相关配置\n2. 针对 commitlint 钩子，在根目录下新增配置文件 `commitlint.config.js`\n3. 针对 eslint 钩子，在根目录下新增配置文件 `.eslintrc.js` 配置文件\n4. 针对 stylelint 钩子，在根目录下新增配置文件 `.stylelint.js` 配置文件\n5. 根据所选钩子，自动生成 `.huskyrc.js` 配置文件，存放 husky 相关配置\n6. 根据所选钩子，自动生成 `lint-staged.config.js` 配置文件，存放 lint-staged 相关配置\n7. 自动安装依赖\n\n依赖安装完毕，就可以愉快的使用了。\n\n## 注意\n\n1. 在项目根目录执行该命令，且确保根目录下已经有了 `package.json` 文件\n2. Git hooks 生效依赖于前置命令 `.git` 文件夹，确保使用该命令时，已经在根目录进行了 `git init` 初始化\n3. commitlint 具体规则请看 [commitlint](https://github.com/conventional-changelog/commitlint)\n4. eslint 默认采用了 eslint-airbnb 的规范，需要修改 eslint 规范可自行修改根目录下的 `.eslintrc.js` 文件\n5. eslint 规范检测默认针对 `/src/*.js` 文件，需要修改生效范围，自行修改 `package.json` 下的 lint-stage 配置\n6. stylelint 默认采用了 stylelint-config-standard 的规范，且兼容 SASS ，需要修改 stylelint 规范可自行修改根目录下的 `.stylelint.js` 文件\n7. stylelint 规范检测默认针对 `/css/*.css` 文件，需要修改生效范围，自行修改 `package.json` 下的 lint-stage 配置\n8. 只要选择了任何一个钩子的安装，将会自动生成 husky 的配置文件 `.huskyrc.js`，且如果 `package.json` 下原本存在 husky 相关配置，将会被覆盖删除，对于一些旧项目需要注意\n9. 选择了安装 eslint 及 stylelint，除了自动生成 husky 的配置文件 `.huskyrc.js`，还好额外生成 lint-staged 的配置文件 `lint-staged.config.js`，且如果 `package.json` 下原本存在 lint-staged 相关配置，将会被覆盖删除，对于一些旧项目需要注意\n\n\n## License\n\nMIT","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchokcoco%2Finithusky","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchokcoco%2Finithusky","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchokcoco%2Finithusky/lists"}