1.7.1 • Published 2 months ago

@lzwme/git-helper v1.7.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

@lzwme/git-helper

@lzwme/git-helper

NPM version node version license

build status npm download GitHub issues GitHub forks GitHub stars

一个基于 Node.js 的简单的 git commit 等操作的辅助性工具。

在中大型前端项目的开发中,为了编码规范与质量保障,基本都会配置 husky、lint-staged 等 githooks 工具来约束 git 提交的规范性检测,如 commitlint、ESLint、StyleLint、prettier、单元测试等等。

这些约束在保障开发提交规范性的同时,也大大的增加了 git commit 的执行时间,随着项目开发周期的增长和复杂度的提升,带来的开发体验也会越来越糟糕。

最常见的 git commit 动作一般主要为:

git add *
git commit -m "feat: test"
git pull --rebase
git push

那么不如将这个动作写为一个脚本,让它自己飞一会儿。本项目主要就是实现为一个包含这样的功能的小工具。

你也可以结合一些 git 客户端提供的工作流功能一起辅助性配置该流程。

INSTALL

npm global install:

npm i -g @lzwme/git-helper
gh --help

or use npx:

npx @lzwme/git-helper -h

npm.io

Useage

githelper --help
gh commit --help
gh run --help

提示:

githelper 有一个短的别名 gh,类似的:

  • githelper commit 命令有短别名 gh cmgh c
  • gh run 命令有短别名: gh r

gh commit 示例:

# git add & git commit & git pull --rebase
gh c -m "chore: update deps"

# git add & git commit --amend
gh c -m "chore: update deps" --amend

# git add & git commit & git pull --rebase & git push
gh c -m "chore: update deps" -p

# git add & git commit --no-veify & git pull --rebase & git push
gh c -m "chore: update deps" -p -n

# git add & # git commit --no-veify & git push
gh c -m "chore: update deps" -p -n -N

gh run 示例:

# help
gh r -h

# git update
gh r -u

# run custom conmand group of abc
gh r -c abc

配置文件

配置文件名称为 git-helper.config.js, 默认在当前项目执行目录下,也可以通过命令行参数 -c 指定。示例:

// git-helper.config.js

/**
 * @type {import('@lzwme/git-helper').IConfig}
 */
 export default {
  debug: false,
  baseDir: process.cwd(),
  commit: {
    messageReg: /^(fix|feat|pref|test|doc):.+/,
    push: true,
    noVerify: false,
  },
  run: {
    cmds: {
      test: {
        desc: 'test',
        list: ['npm run lint', 'npm run test']
      },
    },
  },
};

配置文件是可以缺省的,命令行参数的优先级比它更高。

常见使用方式示例

  • githelper commit 命令常用方式示例:
# 执行 git commit,包括 add、commit、rebase
gh c -m "feat: test for lzwme"

# 执行 git commit,包括 add、commit、rebase、push
gh c -m "feat: test for lzwme" --push

# 执行 git commit,覆盖上一次的提交(若最近一次提交已推送至远端则失败)
gh c -m "feat: test for lzwme" --amend

# 执行 git commit,覆盖上一次的提交,且不修改注释
gh c --amend

# 执行 git commit,不执行 pull、push
gh c -m "feat: test for lzwme" --no-push --no-pull

开发

本地二次开发:

git clone https://github.com/lzwme/git-helper
yarn install
npm link
yarn dev

或者 fork 本项目进行代码贡献。

欢迎贡献想法与代码。

License

@lzwme/git-helper is released under the MIT license.

该插件由志文工作室开发和维护。

1.7.1

2 months ago

1.7.0

8 months ago

1.6.0

10 months ago

1.5.1

1 year ago

1.4.2

1 year ago

1.5.0

1 year ago

1.4.1

2 years ago

1.4.0

3 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.0.0

3 years ago