{"id":17335636,"url":"https://github.com/alanchenchen/gittask","last_synced_at":"2025-04-14T18:33:13.114Z","repository":{"id":57096120,"uuid":"156829656","full_name":"alanchenchen/GitTask","owner":"alanchenchen","description":"A plugin CLI to task your git operations","archived":false,"fork":false,"pushed_at":"2018-12-21T06:57:31.000Z","size":110,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-28T07:02:51.284Z","etag":null,"topics":["cli","git","task-list","workflow"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alanchenchen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-09T08:03:22.000Z","updated_at":"2019-07-05T07:30:51.000Z","dependencies_parsed_at":"2022-08-22T21:40:40.769Z","dependency_job_id":null,"html_url":"https://github.com/alanchenchen/GitTask","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alanchenchen%2FGitTask","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alanchenchen%2FGitTask/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alanchenchen%2FGitTask/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alanchenchen%2FGitTask/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alanchenchen","download_url":"https://codeload.github.com/alanchenchen/GitTask/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248937051,"owners_count":21186148,"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":["cli","git","task-list","workflow"],"created_at":"2024-10-15T15:11:38.790Z","updated_at":"2025-04-14T18:33:13.082Z","avatar_url":"https://github.com/alanchenchen.png","language":"JavaScript","readme":"# GitTask\n\n![](https://img.shields.io/npm/v/@alanchenchen/gittask.svg)\n![](https://img.shields.io/node/v/@alanchenchen/gittask.svg)\n![](https://img.shields.io/npm/dt/@alanchenchen/gittask.svg)\n![](https://img.shields.io/github/license/alanchenchen/GitTask.svg)\n\nA plugin CLI to task your git operations.将git命令模块组合的CLI插件\n\u003e Author：Alan Chen\n\n\u003e E-mail: 739709491@qq.com\n\n\u003e version: 0.0.6\n\n\u003e date: 2018/11/16\n\n\u003e 只能通过node来执行\n\n## Feature\n* 将常用的git命令业务组件化，然后像使用插槽一样自定义git的工作流。\n* 内置14个常用命令扩展，全部是CLI中文操作，高效便捷。\n* 支持自定义命令扩展，支持链式顺序执行，支持链式命令扩展之间参数传递。\n\n## Directory tree\n``` \n├─example       demo代码\n├─screenshot    效果截图\n└─src\n    └─commands  内置的命令扩展\n```\n\n![](./screenshot/task2.png)\n![](./screenshot/task1.png)\n\n## Usage\n* `yarn add @alanchenchen/gittask` or `npm install @alanchenchen/gittask --save` 安装依赖\n* 在项目根目录新建一个js文件，例如`wrok.js`，在其中调用如下：\n```js\n    const { WorkFlow } = require('@alanchenchen/gittask')\n    const questFlow = require('@alanchenchen/gittask/src/commands/questFlow')\n    const showBranch = require('@alanchenchen/gittask/src/commands/showBranch')\n    const modifyOldBranch = require('@alanchenchen/gittask/src/commands/modifyOldBranch') \n    const addModifiedFile = require('@alanchenchen/gittask/src/commands/addModifiedFile') \n    const commit = require('@alanchenchen/gittask/src/commands/commit') \n    const push = require('@alanchenchen/gittask/src/commands/push') \n    const deleteOrigin = require('@alanchenchen/gittask/src/commands/deleteOrigin')\n\n    /* 插件内置13个常用的命令扩展，先引入，然后自由组合，task内会按照索引顺序依次执行 */\n    const task = [showBranch, questFlow, modifyOldBranch, addModifiedFile, commit, push, deleteOrigin]\n    WorkFlow.use(task)\n\n```\n* 然后在当前目录工作区打开终端，输入`node work`,接下来就可以按照CLI的流程一步步操作啦~\n\n## Options\n* gittask包导出3个变量：\n    1. `WorkFlow`, `[Object]`, 包含一个可以使用的方法`use`。`use`支持传入一个数组，数组项必须是命令扩展(可以是自己定义的)\n    2. `git`, `[Object]`, 包含内置的13个命令扩展的命令参数。\n    3. `shell`, `[Function]`, 运行命令行的函数。参数如下：\n        * `cmd` `[Array]`, 必选，命令的参数数组，例如`git branch -a`，cmd则是`['branch', '-a']`\n        * `param` `[Array]`, 可选，默认命令参数后面的参数，默认为空数组，例如`git branch alan`，cmd是`['branch']`，param则是`['alan']`\n        * `prefixPath` `[String]`, 可选，命令行运行的程序路径，默认为`git`，可以是其他命令路径，支持非git操作\n    \n    \u003e 13种内置命令扩展\n\n    | name           |      description                   |  return value (扩展返回值)|\n    |:--------------:|:----------------------------------:|:------------------------:|\n    | addModifiedFile| 将项目中发生改变的文件添加到git缓存   | 透传上一个扩展传来的值 |\n    | checkoutBranch | 切换当前分支到指定分支               | 用户选择的新分支名 |\n    | checkVersion   | 显示当前git的版本信息                | / |\n    | commit         | 将git中的缓存提交到commit操作        | 透传上一个扩展传来的值 |\n    | deleteBranch   | 删除本地仓库某个分支                 | / |\n    | deleteOrigin   | 删除远程仓库某个分支                 | / |\n    | modifyOldBranch| 将某个分支名替换为新的分支名，命名分支 | 用户选择的新分支名 |\n    | newBranch      | 新建一个本地分支                     | 用户选择的新分支名 |\n    | pull           | 拉取指定分支的远程仓库 | 用户选择的拉取分支名 |\n    | push           | 将指定分支的文件提交到远程仓库，默认会取addModifiedFile传入的新分支名，如果没有，则会提交当前分支| / |\n    | questFlow      | 询问用户是否按照git工作流来配置的提问 | / |\n    | showBranch     | 显示当前所有分支，包含远程分支        | / |\n    | showLog        | 显示当前分支的log日志                | / |\n    | showStatus     | 显示当前分支文件的状态，只有当有状态变化，才能调用addModifiedFile| / |\n\n* 插件支持自定义命令扩展，但是格式必须如下：\n```js\n    const chalk = require('chalk') // 让终端可写流文本颜色改变的模块\n    const inquirer = require('inquirer') // 终端可读流交互的模块\n    const { git, shell } = require('@alanchenchen/gittask') // 插件自带的shell方法和默认git参数\n\n    // 一定要导出一个异步函数,可选接收一个参数，param是task中前一个命令扩展传入的参数\n    module.exports = async (param) =\u003e {\n        await shell(['-V'],[], 'node') // 异步打印出当前node版本号\n        return '我是传入给下一个命令扩展的参数' // return会将参数传入给task中下一个命令扩展，可以不传\n    }\n\n```\n\n## License\n* MIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falanchenchen%2Fgittask","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falanchenchen%2Fgittask","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falanchenchen%2Fgittask/lists"}