├── .husky ├── .gitignore ├── pre-commit └── commit-msg ├── .npmrc ├── .prettierignore ├── .vscode ├── settings.json └── launch.json ├── assets └── images │ └── gacp.gif ├── renovate.json ├── .github └── FUNDING.yml ├── .travis.yml ├── .gitignore ├── .npmignore ├── src ├── shell │ ├── logger.ts │ ├── run-hook.ts │ └── get-info.ts ├── errors │ └── gacp.ts ├── configs │ ├── __tests__ │ │ ├── gitmojis.test.ts │ │ └── index.test.ts │ ├── index.ts │ └── gitmojis.ts ├── files │ ├── file-exists.ts │ ├── directory-exists.ts │ └── __tests__ │ │ └── file-exists.test.ts ├── messages │ ├── __tests__ │ │ └── gitmoji-config-manager.test.ts │ ├── commitlint-config.ts │ ├── gitmoji-config-manager.ts │ ├── commit-types-config-manager.ts │ ├── history.ts │ ├── commit-types.ts │ └── gitmojis.ts ├── git │ └── check-needs-push.ts ├── gacp.ts ├── bin.ts └── prompt.ts ├── tsconfig.json ├── CONTRIBUTING.md ├── .editorconfig ├── .prettierrc ├── LICENSE ├── package.json ├── README.md └── CHANGELOG.md /.husky/.gitignore: -------------------------------------------------------------------------------- 1 | _ 2 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | registry=https://registry.npmjs.org/ 2 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | CHANGELOG.md 2 | README.md 3 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "typescript.tsdk": "node_modules/typescript/lib" 3 | } 4 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . "$(dirname "$0")/_/husky.sh" 3 | 4 | yarn lint-staged 5 | -------------------------------------------------------------------------------- /assets/images/gacp.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vivaxy/gacp/HEAD/assets/images/gacp.gif -------------------------------------------------------------------------------- /.husky/commit-msg: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . "$(dirname "$0")/_/husky.sh" 3 | 4 | yarn commitlint --edit $1 5 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:base", 4 | ":preserveSemverRanges" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | patreon: vivaxy 2 | open_collective: gacp 3 | custom: ['https://gist.github.com/vivaxy/58eed1803a2eddda05c90aed99430de2'] 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "node" 4 | - "lts/*" 5 | after_success: 6 | - npm run coverage && bash <(curl -s https://codecov.io/bash) 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .DS_Store 3 | node_modules 4 | npm-debug.log 5 | /build 6 | .nyc_output 7 | coverage 8 | coverage.lcov 9 | lib 10 | yarn-error.log 11 | /debug 12 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | /assets 2 | /.idea 3 | node_modules 4 | .DS_Store 5 | npm-debug.log 6 | /scripts 7 | /test 8 | /.babelrc 9 | /.editorconfig 10 | /.eslintrc 11 | .nyc_output 12 | coverage 13 | /coverage.lcov 14 | -------------------------------------------------------------------------------- /src/shell/logger.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @since 2016-11-22 16:16 3 | * @author vivaxy 4 | */ 5 | import chalk = require('chalk'); 6 | import * as figures from 'figures'; 7 | import { createLogger, levels } from 'log-util'; 8 | 9 | export const command = createLogger(levels.info, chalk.yellow(figures.pointer)); 10 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "esnext", 4 | "module": "commonjs", 5 | "declaration": true, 6 | "outDir": "./lib", 7 | "strict": true, 8 | "skipLibCheck": true 9 | }, 10 | "include": ["src/**/*.ts", "src/**/*.tsx"], 11 | "exclude": ["node_modules"] 12 | } 13 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # PR 2 | 3 | * Update codes. (Do not update CHANGELOG.md and package.json.version) 4 | * Commit message with standard version. 5 | 6 | # Publish 7 | 8 | * After merging to master, admin runs `yarn run release`. This will bump version by git commit messages, update changelog, push changes to git remote, and publish to npm. 9 | -------------------------------------------------------------------------------- /src/errors/gacp.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @since 2018-01-29 14:55 3 | * @author vivaxy 4 | */ 5 | 6 | import { ERROR_TYPES } from '../configs'; 7 | 8 | export default class GacpError extends Error { 9 | readonly type: ERROR_TYPES; 10 | 11 | constructor(message: string) { 12 | super(message); 13 | this.type = ERROR_TYPES.GACP; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/configs/__tests__/gitmojis.test.ts: -------------------------------------------------------------------------------- 1 | import gitmojis from '../gitmojis'; 2 | 3 | test('should export a defined shape', function() { 4 | gitmojis.gitmojis.forEach(function(gitmoji) { 5 | expect(typeof gitmoji.code).toBe('string'); 6 | expect(typeof gitmoji.description).toBe('string'); 7 | expect(typeof gitmoji.emoji).toBe('string'); 8 | }); 9 | }); 10 | -------------------------------------------------------------------------------- /src/shell/run-hook.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @since 2020-04-29 10:39 3 | * @author vivaxy 4 | */ 5 | import * as execa from 'execa'; 6 | 7 | export default async function runHook( 8 | script: string, 9 | { 10 | cwd, 11 | }: { 12 | cwd: string; 13 | }, 14 | ) { 15 | if (!script) { 16 | return; 17 | } 18 | await execa.command(script, { cwd, stdio: 'inherit' }); 19 | } 20 | -------------------------------------------------------------------------------- /src/shell/get-info.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @since 2016-11-22 16:04 3 | * @author vivaxy 4 | */ 5 | 6 | import * as execa from 'execa'; 7 | 8 | export default async function getInfoFromShell( 9 | file: string, 10 | args: string[], 11 | ): Promise { 12 | const { exitCode, stdout } = await execa(file, args); 13 | if (exitCode === 0) { 14 | return stdout.split('\n')[0]; 15 | } 16 | return ''; 17 | } 18 | -------------------------------------------------------------------------------- /src/files/file-exists.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @since 2016-11-27 15:36 3 | * @author vivaxy 4 | */ 5 | 6 | import * as fs from 'fs'; 7 | 8 | export default async function fileExists(filename: string) { 9 | return await new Promise(function(resolve) { 10 | fs.access(filename, function(err) { 11 | if (err) { 12 | resolve(false); 13 | } else { 14 | resolve(true); 15 | } 16 | }); 17 | }); 18 | } 19 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | curly_bracket_next_line = false 11 | spaces_around_operators = true 12 | indent_brace_style = 1tbs 13 | 14 | [*.js] 15 | quote_type = single 16 | 17 | [*.{html,less,css,json}] 18 | quote_type = double 19 | 20 | [package.json] 21 | indent_size = 2 22 | -------------------------------------------------------------------------------- /src/files/directory-exists.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @since 2016-11-27 15:57 3 | * @author vivaxy 4 | */ 5 | 6 | import * as fs from 'fs'; 7 | 8 | export default async function directoryExists(filename: string) { 9 | return await new Promise(function(resolve) { 10 | fs.stat(filename, function(err, stats) { 11 | if (err) { 12 | resolve(false); 13 | } else { 14 | resolve(stats.isDirectory()); 15 | } 16 | }); 17 | }); 18 | } 19 | -------------------------------------------------------------------------------- /src/files/__tests__/file-exists.test.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @since 2019-06-13 15:01 3 | * @author vivaxy 4 | */ 5 | import fileExists from '../file-exists'; 6 | 7 | test('should tell file not exists', async function() { 8 | const result = await fileExists('invalid file name'); 9 | expect(result).toBe(false); 10 | }); 11 | 12 | test('should tell file exists', async function() { 13 | const result = await fileExists(__filename); 14 | expect(result).toBe(true); 15 | }); 16 | -------------------------------------------------------------------------------- /src/configs/__tests__/index.test.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @since 2019-06-17 19:19 3 | * @author vivaxy 4 | */ 5 | import { PATHS, GITMOJIS, ERROR_TYPES } from '..'; 6 | 7 | test('should export paths configs', function() { 8 | expect(typeof PATHS).toBe('object'); 9 | }); 10 | 11 | test('should export error types object', function() { 12 | expect(typeof ERROR_TYPES).toBe('object'); 13 | }); 14 | 15 | test('should export gitmojis object', function() { 16 | expect(Array.isArray(GITMOJIS)).toBe(true); 17 | }); 18 | -------------------------------------------------------------------------------- /src/messages/__tests__/gitmoji-config-manager.test.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @since 2017-02-05 12:49 3 | * @author vivaxy 4 | */ 5 | import * as gitmojiConfigManager from '../gitmoji-config-manager'; 6 | 7 | test('config should has correct exports', function() { 8 | expect(typeof gitmojiConfigManager.read).toBe('function'); 9 | expect(typeof gitmojiConfigManager.write).toBe('function'); 10 | expect(typeof gitmojiConfigManager.exist).toBe('function'); 11 | expect(typeof gitmojiConfigManager.readListByStatOrder).toBe('function'); 12 | }); 13 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "launch", 10 | "name": "Debug", 11 | "skipFiles": ["/**"], 12 | "program": "${workspaceFolder}/lib/bin.js", 13 | "console": "integratedTerminal", 14 | "cwd": "${workspaceFolder}" 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 80, 3 | "tabWidth": 2, 4 | "useTabs": false, 5 | "semi": true, 6 | "singleQuote": true, 7 | "quoteProps": "as-needed", 8 | "jsxSingleQuote": false, 9 | "trailingComma": "all", 10 | "bracketSpacing": true, 11 | "jsxBracketSameLine": false, 12 | "arrowParens": "always", 13 | "proseWrap": "always", 14 | "htmlWhitespaceSensitivity": "css", 15 | "endOfLine": "lf", 16 | "overrides": [ 17 | { 18 | "files": "*.{css,less,json,html,yml,yaml,pcss}", 19 | "options": { 20 | "singleQuote": false 21 | } 22 | } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /src/messages/commitlint-config.ts: -------------------------------------------------------------------------------- 1 | import load from '@commitlint/load'; 2 | import { QualifiedRules, RuleConfigTuple } from '@commitlint/types'; 3 | 4 | export async function getCommitlintConfigRules(): Promise { 5 | let rules; 6 | try { 7 | const config = await load(); 8 | rules = config.rules; 9 | } catch (e) { 10 | rules = {}; 11 | } 12 | return rules; 13 | } 14 | 15 | export function getRuleValue( 16 | [level, applicable, value = 0]: RuleConfigTuple = [0, 'never', 0], 17 | defaultValue: number, 18 | ) { 19 | return level === 2 && applicable === 'always' ? value : defaultValue; 20 | } 21 | -------------------------------------------------------------------------------- /src/configs/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @since 2017-02-04 17:05 3 | * @author vivaxy 4 | */ 5 | import gitmojisConfig from './gitmojis'; 6 | 7 | const { HOME, HOMEPATH, USERPROFILE } = process.env; 8 | 9 | export const PATHS = { 10 | GACPHOME: `${HOME || HOMEPATH || USERPROFILE}/.gacp`, 11 | // from https://raw.githubusercontent.com/carloscuesta/gitmoji/master/src/data/gitmojis.json 12 | GITMOJI_CONFIG_FILE_NAME: 'gitmojis.json', 13 | // from conventional-commit-types 14 | COMMIT_TYPES_CONFIG_FILE_NAME: 'conventional-commit-types.json', 15 | HISTORY_FILE_NAME: 'history.json', 16 | }; 17 | 18 | const { gitmojis: GITMOJIS } = gitmojisConfig; 19 | export { GITMOJIS }; 20 | 21 | export enum ERROR_TYPES { 22 | GACP = 'gacp', 23 | } 24 | 25 | export enum EMOJI_TYPES { 26 | EMOJI = 'emoji', 27 | CODE = 'code', 28 | NONE = 'none', 29 | } 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 vivaxy 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/messages/gitmoji-config-manager.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @since 2016-11-17 11:36 3 | * @author vivaxy 4 | */ 5 | 6 | import * as path from 'path'; 7 | import * as fse from 'fs-extra'; 8 | 9 | import fileExists from '../files/file-exists'; 10 | import { PATHS } from '../configs'; 11 | 12 | export interface GitmojiConfigItem { 13 | emoji: string; 14 | code: string; 15 | description: string; 16 | } 17 | 18 | export type GitmojiConfigItemWithStat = GitmojiConfigItem & { 19 | stat: number; 20 | }; 21 | 22 | export interface GitmojiConfig { 23 | gitmojis: GitmojiConfigItem[]; 24 | } 25 | 26 | export interface GitmojiConfigWithStat { 27 | gitmojis: GitmojiConfigItemWithStat[]; 28 | } 29 | 30 | const { GACPHOME, GITMOJI_CONFIG_FILE_NAME } = PATHS; 31 | const userConfigFile = path.join(GACPHOME, GITMOJI_CONFIG_FILE_NAME); 32 | 33 | export function read(): GitmojiConfigWithStat { 34 | return require(userConfigFile); 35 | } 36 | 37 | export async function write(json: object) { 38 | return await fse.outputFile(userConfigFile, JSON.stringify(json, null, 2)); 39 | } 40 | 41 | export async function exist() { 42 | return await fileExists(userConfigFile); 43 | } 44 | 45 | export function readListByStatOrder() { 46 | const userConfig = read(); 47 | const configList = userConfig.gitmojis; 48 | configList.sort((prev, next) => { 49 | return next.stat - prev.stat; 50 | }); 51 | return configList; 52 | } 53 | -------------------------------------------------------------------------------- /src/git/check-needs-push.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @since 2016-11-27 13:59 3 | * @author vivaxy 4 | */ 5 | import * as execa from 'execa'; 6 | import * as git from '@vivaxy/git'; 7 | 8 | async function hasCommitInShell( 9 | file: string, 10 | args: string[], 11 | ): Promise { 12 | let result = true; 13 | try { 14 | const { exitCode, stdout } = await execa(file, args); 15 | if (exitCode === 0) { 16 | const splitResult = stdout.split('\n\r'); 17 | if (splitResult[0] === '') { 18 | result = false; 19 | } 20 | } 21 | } catch (ex) { 22 | // fatal: ambiguous argument 'remote/sonar..sonar': unknown revision or path not in the working tree. 23 | // Use '--' to separate paths from revisions, like this: 24 | // 'git [...] -- [...]' 25 | // remote branch not exits 26 | // result = true; 27 | } 28 | return result; 29 | } 30 | 31 | export default async function checkNeedPush({ 32 | cwd, 33 | }: { 34 | cwd: string; 35 | }): Promise { 36 | let result = true; 37 | const remote = await git.getCurrentRemote({ cwd }); 38 | if (!remote) { 39 | result = false; 40 | } else { 41 | const branch = await git.getCurrentBranch({ cwd }); 42 | result = await hasCommitInShell('git', [ 43 | 'log', 44 | `${remote}/${branch}..${branch}`, 45 | '--pretty=format:%H', 46 | ]); 47 | } 48 | return result; 49 | } 50 | -------------------------------------------------------------------------------- /src/messages/commit-types-config-manager.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @since 2016-11-17 11:36 3 | * @author vivaxy 4 | */ 5 | 6 | import * as path from 'path'; 7 | import * as fse from 'fs-extra'; 8 | // @ts-ignore 9 | import * as rightPad from 'right-pad'; 10 | 11 | import fileExists from '../files/file-exists'; 12 | import { PATHS } from '../configs'; 13 | 14 | const { GACPHOME, COMMIT_TYPES_CONFIG_FILE_NAME } = PATHS; 15 | 16 | const userConfigFile = path.join(GACPHOME, COMMIT_TYPES_CONFIG_FILE_NAME); 17 | 18 | export function read() { 19 | return require(userConfigFile); 20 | } 21 | 22 | export async function write(json: object) { 23 | return await fse.outputFile(userConfigFile, JSON.stringify(json, null, 2)); 24 | } 25 | 26 | export async function exist() { 27 | return await fileExists(userConfigFile); 28 | } 29 | 30 | const formatTypeChoices = (map: { 31 | [key: string]: { 32 | stat: number; 33 | description: string; 34 | }; 35 | }) => { 36 | const keys = Object.keys(map); 37 | const length = keys.reduce((len, item) => { 38 | if (item.length > len) { 39 | return item.length; 40 | } 41 | return len; 42 | }, 0); 43 | 44 | return keys.map((key) => { 45 | return { 46 | title: `${rightPad(`${key}:`, length)} ${map[key].description}`, 47 | value: key, 48 | stat: map[key].stat, 49 | }; 50 | }); 51 | }; 52 | 53 | export function readListByStatOrder() { 54 | const userConfig = exports.read(); 55 | const configMap = userConfig.types; 56 | const configList = formatTypeChoices(configMap); 57 | configList.sort((prev, next) => { 58 | return next.stat - prev.stat; 59 | }); 60 | return configList; 61 | } 62 | -------------------------------------------------------------------------------- /src/messages/history.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @since 2019-06-13 14:14 3 | * @author vivaxy 4 | */ 5 | 6 | import * as path from 'path'; 7 | import * as log from 'log-util'; 8 | import * as fse from 'fs-extra'; 9 | import { PATHS } from '../configs'; 10 | 11 | const { GACPHOME, HISTORY_FILE_NAME } = PATHS; 12 | const historyFile = path.join(GACPHOME, HISTORY_FILE_NAME); 13 | 14 | export interface Messages { 15 | type: string; 16 | scope: string; 17 | gitmoji: string; 18 | subject: string; 19 | body: string; 20 | footer: string; 21 | } 22 | 23 | export const DEFAULT_MESSAGES: Messages = { 24 | type: '', 25 | scope: '', 26 | gitmoji: '', 27 | subject: '', 28 | body: '', 29 | footer: '', 30 | }; 31 | 32 | let cache: Messages; 33 | 34 | function debug(...message: any[]) { 35 | log.debug('gacp:history', ...message); 36 | } 37 | 38 | export function getHistory(): Messages { 39 | debug('reading history'); 40 | if (cache) { 41 | // already read from file system 42 | return cache; 43 | } 44 | try { 45 | cache = require(historyFile) as Messages; 46 | } catch (e) { 47 | debug('history file not exists'); 48 | cache = DEFAULT_MESSAGES; 49 | } 50 | return cache; 51 | } 52 | 53 | export function setHistory(history: Partial) { 54 | debug(`set: ${JSON.stringify(history)}`); 55 | cache = { ...cache, ...history }; 56 | } 57 | 58 | export function clearHistory() { 59 | debug(`clear: ${JSON.stringify(DEFAULT_MESSAGES)}`); 60 | cache = DEFAULT_MESSAGES; 61 | } 62 | 63 | export async function flushHistory() { 64 | debug(`flush: ${JSON.stringify(cache || {})}`); 65 | await fse.outputFile(historyFile, JSON.stringify(cache || {}, null, 2)); 66 | } 67 | -------------------------------------------------------------------------------- /src/messages/commit-types.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @since 2017-02-04 16:59 3 | * @author vivaxy 4 | */ 5 | import * as configManager from './commit-types-config-manager'; 6 | 7 | const defaultConfig = require('conventional-commit-types'); 8 | 9 | interface ConfigItem { 10 | description: string; 11 | title: string; 12 | } 13 | 14 | type ConfigItemWithStat = ConfigItem & { 15 | stat: number; 16 | }; 17 | 18 | interface Config { 19 | types: { 20 | [type: string]: ConfigItem; 21 | }; 22 | } 23 | 24 | interface ConfigWithStat { 25 | types: { 26 | [type: string]: ConfigItemWithStat; 27 | }; 28 | } 29 | 30 | /** 31 | * { 32 | * types: { 33 | * // ... 34 | * } 35 | * } 36 | * @param config - use config info 37 | * @param statConfig - use stat info 38 | * @returns {{types}} 39 | */ 40 | function mapConfigWithStat( 41 | config: ConfigWithStat, 42 | statConfig: ConfigWithStat = { types: {} }, 43 | ): ConfigWithStat { 44 | const typesWithStat = statConfig.types; 45 | const resultTypes: { 46 | [key: string]: { 47 | description: string; 48 | title: string; 49 | stat: number; 50 | }; 51 | } = {}; 52 | Object.keys(config.types).forEach((typeKey: string) => { 53 | const typeInfo = config.types[typeKey]; 54 | const typeInfoWithStat = typesWithStat[typeKey]; 55 | resultTypes[typeKey] = { 56 | ...typeInfo, 57 | stat: typeInfoWithStat ? typeInfoWithStat.stat : 0, 58 | }; 59 | }); 60 | return { types: resultTypes }; 61 | } 62 | 63 | function hasNewTypes() { 64 | const { types } = configManager.read(); 65 | return Object.keys(defaultConfig.types).length !== Object.keys(types).length; 66 | } 67 | 68 | async function useNewTypesConfig() { 69 | const currentConfig = configManager.read(); 70 | await configManager.write(mapConfigWithStat(defaultConfig, currentConfig)); 71 | } 72 | 73 | async function ensureTypesConfig() { 74 | if (!(await configManager.exist())) { 75 | // map config with `stat: 0` 76 | await configManager.write(mapConfigWithStat(defaultConfig)); 77 | } 78 | if (hasNewTypes()) { 79 | await useNewTypesConfig(); 80 | } 81 | } 82 | 83 | export async function getCommitTypes() { 84 | await ensureTypesConfig(); 85 | 86 | const commitTypes = await configManager.readListByStatOrder(); 87 | return commitTypes.map(({ title, value }) => { 88 | return { title, value }; 89 | }); 90 | } 91 | 92 | export async function updateTypesStat(typeKey: string) { 93 | const { types } = configManager.read(); 94 | types[typeKey].stat++; 95 | await configManager.write({ types }); 96 | } 97 | -------------------------------------------------------------------------------- /src/messages/gitmojis.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @since 2017-02-04 16:59 3 | * @author vivaxy 4 | */ 5 | 6 | import * as configManager from './gitmoji-config-manager'; 7 | // from https://github.com/carloscuesta/gitmoji/blob/master/src/data/gitmojis.json 8 | import defaultConfig from '../configs/gitmojis'; 9 | import { 10 | GitmojiConfig, 11 | GitmojiConfigItemWithStat, 12 | GitmojiConfigWithStat, 13 | } from './gitmoji-config-manager'; 14 | import { EMOJI_TYPES } from '../configs'; 15 | 16 | function mapConfigWithStat( 17 | config: GitmojiConfig, 18 | statConfig: GitmojiConfigWithStat = { gitmojis: [] }, 19 | ) { 20 | const gitmojisWithStat = statConfig.gitmojis; 21 | return { 22 | gitmojis: config.gitmojis.map((item) => { 23 | const findGitmojiWithStat = gitmojisWithStat.find((gitmoji) => { 24 | return gitmoji.code === item.code; 25 | }); 26 | 27 | const stat = findGitmojiWithStat ? findGitmojiWithStat.stat : 0; 28 | 29 | return { ...item, stat }; 30 | }), 31 | }; 32 | } 33 | 34 | const hasNewGitmoji = () => { 35 | const { gitmojis } = configManager.read(); 36 | return defaultConfig.gitmojis.length !== gitmojis.length; 37 | }; 38 | 39 | const addNewGitmoji = async () => { 40 | const currentConfig = configManager.read(); 41 | await configManager.write(mapConfigWithStat(defaultConfig, currentConfig)); 42 | }; 43 | 44 | const ensureGitmojiConfig = async () => { 45 | if (!(await configManager.exist())) { 46 | // map config with `stat: 0` 47 | await configManager.write(mapConfigWithStat(defaultConfig)); 48 | } 49 | if (hasNewGitmoji()) { 50 | await addNewGitmoji(); 51 | } 52 | }; 53 | 54 | export async function getGitmojis({ emojiType }: { emojiType: EMOJI_TYPES }) { 55 | if (emojiType === EMOJI_TYPES.NONE) { 56 | return [] 57 | } 58 | await ensureGitmojiConfig(); 59 | 60 | const gitmojis = await configManager.readListByStatOrder(); 61 | const gitmojiList = gitmojis.map((gitmoji) => { 62 | return { 63 | title: `${gitmoji.emoji} - ${gitmoji.description}`, 64 | value: gitmoji[emojiType] || gitmoji.code, 65 | }; 66 | }); 67 | 68 | gitmojiList.unshift({ title: 'none', value: '' }); 69 | return gitmojiList; 70 | } 71 | 72 | export async function updateGitmojisStat({ 73 | key, 74 | value, 75 | }: { 76 | key: EMOJI_TYPES.EMOJI | EMOJI_TYPES.CODE; 77 | value: string; 78 | }) { 79 | const { gitmojis: originalGitmojis } = configManager.read(); 80 | const gitmojis = originalGitmojis.map( 81 | (gitmoji: GitmojiConfigItemWithStat) => { 82 | if (gitmoji[key] === value) { 83 | return { ...gitmoji, stat: gitmoji.stat + 1 }; 84 | } 85 | return gitmoji; 86 | }, 87 | ); 88 | await configManager.write({ gitmojis }); 89 | } 90 | -------------------------------------------------------------------------------- /src/gacp.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @since 2016-11-22 14:55 3 | * @author vivaxy 4 | */ 5 | import * as log from 'log-util'; 6 | import * as git from '@vivaxy/git'; 7 | 8 | import prompt from './prompt'; 9 | import runHook from './shell/run-hook'; 10 | import { EMOJI_TYPES } from './configs'; 11 | import * as logger from './shell/logger'; 12 | import checkNeedsPush from './git/check-needs-push'; 13 | import { clearHistory } from './messages/history'; 14 | 15 | type Hooks = { 16 | postpush: string; 17 | }; 18 | 19 | function debug(...message: any[]) { 20 | log.debug('gacp:gacp', ...message); 21 | } 22 | 23 | function getNow() { 24 | return new Date().getTime(); 25 | } 26 | 27 | async function runTasks({ 28 | add, 29 | push, 30 | emoji, 31 | editor, 32 | verify, 33 | cwd, 34 | hooks, 35 | }: { 36 | add: boolean; 37 | push: boolean; 38 | emoji: EMOJI_TYPES; 39 | editor: boolean; 40 | verify: boolean; 41 | cwd: string; 42 | hooks: Hooks; 43 | }) { 44 | let needsAdd = add; 45 | let needsCommit = true; 46 | let needsPush = push; 47 | let commitMessage = ''; 48 | 49 | const gitRoot = await git.getRootPath({ cwd }); 50 | 51 | const gitClean = await git.isClean({ cwd: gitRoot }); 52 | debug('gitClean', gitClean); 53 | needsAdd = needsAdd && !gitClean; 54 | 55 | const hasStagedFiles = 56 | (await git.getStagedFiles({ cwd: gitRoot })).length !== 0; 57 | debug('hasStagedFiles', hasStagedFiles); 58 | needsCommit = needsAdd || hasStagedFiles; 59 | 60 | // prompt first before performing any actions 61 | if (needsCommit) { 62 | commitMessage = await prompt({ emojiType: emoji, editor }); 63 | debug('commitMessage:', commitMessage); 64 | } 65 | 66 | if (needsAdd) { 67 | logger.command('git add .'); 68 | await git.add({ cwd: gitRoot }); 69 | } else { 70 | if (add) { 71 | log.info('Nothing to add, working tree clean.'); 72 | } else { 73 | log.info('Skipping add.'); 74 | } 75 | } 76 | 77 | if (needsCommit) { 78 | await git.commit(commitMessage, { cwd: gitRoot, noVerify: !verify }); 79 | } else { 80 | log.info('Nothing to commit, working tree clean.'); 81 | } 82 | // If commit success, remove last commit message 83 | clearHistory(); 84 | 85 | if (!needsAdd && !needsCommit) { 86 | await git.fetch({ cwd: gitRoot }); 87 | needsPush = needsPush && (await checkNeedsPush({ cwd: gitRoot })); 88 | } 89 | 90 | if (needsPush) { 91 | await git.push({ cwd: gitRoot, setUpstream: true, noVerify: !verify }); 92 | await runHook(hooks.postpush, { cwd: gitRoot }); 93 | } else { 94 | if (push) { 95 | log.info('Nothing to push, everything up-to-date.'); 96 | } else { 97 | log.info('Skipping push.'); 98 | } 99 | } 100 | } 101 | 102 | export default async function gacp({ 103 | cwd, 104 | add, 105 | push, 106 | emoji, 107 | editor, 108 | verify, 109 | hooks, 110 | }: { 111 | cwd: string; 112 | add: boolean; 113 | push: boolean; 114 | emoji: EMOJI_TYPES; 115 | editor: boolean; 116 | verify: boolean; 117 | hooks: Hooks; 118 | }) { 119 | const startTime = getNow(); 120 | await runTasks({ cwd, add, push, emoji, editor, verify, hooks }); 121 | const endTime = getNow(); 122 | log.success(`Done in ${(endTime - startTime) / 1000}s`); 123 | } 124 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gacp", 3 | "version": "3.0.3", 4 | "description": "💬Git add, commit, push with Conventional Commits and Gitmoji.", 5 | "main": "lib/gacp.js", 6 | "types": "lib/gacp.d.ts", 7 | "bin": { 8 | "gacp": "lib/bin.js" 9 | }, 10 | "scripts": { 11 | "build": "tsc", 12 | "test": "jest", 13 | "coverage": "jest --collect-coverage", 14 | "beta": "npm run test && npm run build && npm publish --registry=https://registry.npmjs.org/ --tag beta", 15 | "release": "npm run test && npm run build && standard-version && git push --follow-tags && npm publish --registry=https://registry.npmjs.org/", 16 | "postinstall": "husky install", 17 | "prepublishOnly": "pinst --disable", 18 | "postpublish": "pinst --enable" 19 | }, 20 | "repository": { 21 | "type": "git", 22 | "url": "git+https://github.com/vivaxy/gacp.git" 23 | }, 24 | "keywords": [ 25 | "git", 26 | "changelog", 27 | "nodejs", 28 | "conventional-changelog", 29 | "gitmoji", 30 | "emoji", 31 | "standard-version", 32 | "commit", 33 | "commit-message", 34 | "commit-conventions", 35 | "commitizen", 36 | "git-add", 37 | "git-commit", 38 | "git-push", 39 | "gacp" 40 | ], 41 | "author": "vivaxy", 42 | "license": "MIT", 43 | "bugs": { 44 | "url": "https://github.com/vivaxy/gacp/issues" 45 | }, 46 | "homepage": "https://github.com/vivaxy/gacp#readme", 47 | "dependencies": { 48 | "@commitlint/load": "^12.0.0", 49 | "@commitlint/types": "^12.0.0", 50 | "@vivaxy/git": "^4.2.1", 51 | "chalk": "^4.0.0", 52 | "conventional-commit-types": "^3.0.0", 53 | "cosmiconfig": "^7.0.0", 54 | "execa": "^5.0.0", 55 | "external-editor": "^3.1.0", 56 | "figures": "^3.0.0", 57 | "fs-extra": "^10.0.0", 58 | "log-util": "^2.3.0", 59 | "prompts": "^2.3.1", 60 | "right-pad": "^1.0.1", 61 | "update-notifier": "^5.0.0", 62 | "word-wrap": "^1.2.3", 63 | "yargs": "^17.0.0" 64 | }, 65 | "devDependencies": { 66 | "@commitlint/cli": "^12.0.0", 67 | "@commitlint/config-conventional": "^12.0.0", 68 | "@types/execa": "^0.9.0", 69 | "@types/fs-extra": "^9.0.1", 70 | "@types/jest": "^26.0.0", 71 | "@types/node": "^14.0.0", 72 | "@types/prompts": "^2.0.1", 73 | "@types/update-notifier": "^5.0.0", 74 | "@types/word-wrap": "^1.2.0", 75 | "@types/yargs": "^17.0.0", 76 | "cross-env": "^7.0.2", 77 | "husky": "6", 78 | "jest": "^26.0.1", 79 | "lint-staged": "^11.0.0", 80 | "pinst": "^2.1.4", 81 | "prettier": "^2.0.0", 82 | "standard-version": "^9.0.0", 83 | "ts-jest": "^26.0.0", 84 | "typescript": "^4.0.0" 85 | }, 86 | "lint-staged": { 87 | "*.{js,ts,css,less,json,md,html,yml,yaml,pcss,jsx,tsx}": [ 88 | "prettier --write" 89 | ] 90 | }, 91 | "commitlint": { 92 | "extends": [ 93 | "@commitlint/config-conventional" 94 | ] 95 | }, 96 | "gacp": { 97 | "hooks": { 98 | "postpush": "echo 'push done'" 99 | } 100 | }, 101 | "jest": { 102 | "testEnvironment": "node", 103 | "preset": "ts-jest", 104 | "testMatch": [ 105 | "/src/**/__tests__/**/*.test.ts?(x)" 106 | ], 107 | "collectCoverageFrom": [ 108 | "src/**/*.ts", 109 | "!src/**/__tests__/**/*.ts" 110 | ] 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /src/bin.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | /** 3 | * @since 2016-11-22 13:29 4 | * @author vivaxy 5 | */ 6 | import * as yargs from 'yargs'; 7 | import chalk = require('chalk'); 8 | import * as log from 'log-util'; 9 | import { cosmiconfig } from 'cosmiconfig'; 10 | import * as updateNotifier from 'update-notifier'; 11 | 12 | import gacp from './gacp'; 13 | import { flushHistory } from './messages/history'; 14 | import { EMOJI_TYPES } from './configs'; 15 | 16 | const pkg = require('../package.json'); 17 | 18 | function debug(...message: any[]) { 19 | log.debug('gacp:bin', ...message); 20 | } 21 | 22 | async function configureYargs() { 23 | const explorer = cosmiconfig(pkg.name); 24 | const cosmiconfigResult = await explorer.search(); 25 | const { config = {} } = cosmiconfigResult || {}; 26 | ((yargs 27 | .options({ 28 | add: { 29 | type: 'boolean', 30 | desc: 'run git add .', 31 | default: true, 32 | }, 33 | push: { 34 | type: 'boolean', 35 | desc: 'run git push', 36 | default: true, 37 | }, 38 | emoji: { 39 | type: 'string', 40 | desc: 'use emoji or code', 41 | choices: ['none', 'code', 'emoji'], 42 | default: 'code', 43 | }, 44 | editor: { 45 | type: 'boolean', 46 | desc: 'use node external editor in longer description', 47 | default: false, 48 | }, 49 | logLevel: { 50 | type: 'number', 51 | desc: 'log level', 52 | default: 1, 53 | }, 54 | cwd: { 55 | type: 'string', 56 | desc: 'working directory', 57 | default: process.cwd(), 58 | }, 59 | verify: { 60 | type: 'boolean', 61 | desc: 'verify git commit and git push', 62 | default: true, 63 | }, 64 | }) 65 | .config(config) 66 | .help() 67 | .version().argv as unknown) as any)._; 68 | 69 | const hooks = config.hooks || {}; 70 | return { 71 | hooks: { 72 | postpush: hooks.postpush || '', 73 | }, 74 | }; 75 | } 76 | 77 | function notifyUpdate() { 78 | const notifier = updateNotifier({ pkg }); 79 | const { update } = notifier; 80 | if (update) { 81 | const installCommand = `npm i -g ${update.name}`; 82 | const message = 83 | 'Update available ' + 84 | chalk.dim(update.current) + 85 | chalk.reset(' → ') + 86 | chalk.green(update.latest) + 87 | ' \nRun ' + 88 | chalk.cyan(installCommand) + 89 | ' to update'; 90 | 91 | notifier.notify({ message }); 92 | } 93 | } 94 | 95 | (async function () { 96 | try { 97 | notifyUpdate(); 98 | const extraConfigs = await configureYargs(); 99 | const { 100 | logLevel, 101 | cwd, 102 | emoji, 103 | add, 104 | push, 105 | verify, 106 | editor, 107 | } = (yargs.argv as unknown) as { 108 | logLevel: number; 109 | cwd: string; 110 | emoji: EMOJI_TYPES; 111 | add: boolean; 112 | push: boolean; 113 | verify: boolean; 114 | editor: boolean; 115 | }; 116 | log.setLevel(logLevel); 117 | await gacp({ 118 | cwd: cwd as string, 119 | add: add as boolean, 120 | push: push as boolean, 121 | emoji: emoji as EMOJI_TYPES, 122 | editor: editor as boolean, 123 | verify: verify as boolean, 124 | hooks: { 125 | postpush: extraConfigs.hooks.postpush, 126 | }, 127 | }); 128 | await flushHistory(); 129 | } catch (e) { 130 | log.error(e.message); 131 | log.debug(e.stack); 132 | await flushHistory(); 133 | process.exit(1); 134 | } 135 | })(); 136 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # gacp 2 | 3 | [![Build Status][travis-image]][travis-url] 4 | [![NPM Version][npm-version-image]][npm-url] 5 | [![NPM Downloads][npm-downloads-image]][npm-url] 6 | [![MIT License][license-image]][license-url] 7 | [![Standard Version][standard-version-image]][standard-version-url] 8 | [![Codecov][codecov-image]][codecov-url] 9 | [![Financial Contributors on Open Collective](https://opencollective.com/gacp/all/badge.svg?label=financial+contributors)](https://opencollective.com/gacp) 10 | 11 | 💬Git add, commit, push with [Conventional Commits](https://www.conventionalcommits.org/) and [Gitmoji](https://gitmoji.carloscuesta.me/). 12 | 13 | ![GACP](./assets/images/gacp.gif) 14 | 15 | ## Installation 16 | 17 | `npm i -g gacp` 18 | 19 | ## Usage 20 | 21 | `gacp` 22 | 23 | `gacp --help` 24 | 25 | `gacp --no-add` 26 | 27 | `gacp --no-push` 28 | 29 | `gacp --emoji emoji` 30 | 31 | `gacp --editor` 32 | 33 | `gacp --no-verify` 34 | 35 | `gacp --emoji none` 36 | 37 | ## Configuration File 38 | 39 | You can configure gacp via: 40 | 41 | - A `gacp` property in `package.json`. 42 | - A `.gacprc` file in JSON, YAML or CommonJS with or without extensions `.json`, `.yaml`, `.yml`, `.js`. 43 | - A `gacp.config.js` file in CommonJS. 44 | 45 | ### Basic Configuration 46 | 47 | Default configuration: 48 | 49 | ```json 50 | { 51 | "add": true, 52 | "push": true, 53 | "emoji": "code", 54 | "editor": false, 55 | "hooks": { 56 | "postpush": "" 57 | } 58 | } 59 | ``` 60 | 61 | ### emoji 62 | 63 | - code: `:grinning:` 64 | - emoji: `😀` 65 | - none: no emoji 66 | 67 | ## Change log 68 | 69 | [Change log](CHANGELOG.md) 70 | 71 | ## Contributing 72 | 73 | [Contributing](CONTRIBUTING.md) 74 | 75 | ## Contributors 76 | 77 | ### Code Contributors 78 | 79 | This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)]. 80 | 81 | 82 | ### Financial Contributors 83 | 84 | Become a financial contributor and help us sustain our community. [[Contribute](https://opencollective.com/gacp/contribute)] 85 | 86 | #### Individuals 87 | 88 | 89 | 90 | #### Organizations 91 | 92 | Support this project with your organization. Your logo will show up here with a link to your website. [[Contribute](https://opencollective.com/gacp/contribute)] 93 | 94 | 95 | 96 | ## Related Projects 97 | 98 | - [VSCode Conventional Commits](https://github.com/vivaxy/vscode-conventional-commits) 99 | - [gcmt](https://github.com/vivaxy/gcmt) 100 | - [commitizen](https://github.com/commitizen/cz-cli) 101 | - [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog) 102 | - [gitmoji-cli](https://github.com/carloscuesta/gitmoji-cli) 103 | - [git-commit-cp](https://github.com/Dolov/git-commit-cp) 104 | - [git-cz](https://github.com/streamich/git-cz) 105 | - [cz-emoji](https://github.com/ngryman/cz-emoji) 106 | 107 | # 108 | 109 | [travis-image]: https://img.shields.io/travis/vivaxy/gacp.svg?style=flat-square 110 | [travis-url]: https://travis-ci.org/vivaxy/gacp 111 | [npm-version-image]: http://img.shields.io/npm/v/gacp.svg?style=flat-square 112 | [npm-url]: https://www.npmjs.com/package/gacp 113 | [npm-downloads-image]: https://img.shields.io/npm/dt/gacp.svg?style=flat-square 114 | [license-image]: https://img.shields.io/npm/l/gacp.svg?style=flat-square 115 | [license-url]: LICENSE 116 | [standard-version-image]: https://img.shields.io/badge/release-standard%20version-brightgreen.svg?style=flat-square 117 | [standard-version-url]: https://github.com/conventional-changelog/standard-version 118 | [codecov-image]: https://img.shields.io/codecov/c/github/vivaxy/gacp.svg?style=flat-square 119 | [codecov-url]: https://codecov.io/gh/vivaxy/gacp 120 | -------------------------------------------------------------------------------- /src/prompt.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @since 2016-11-23 10:23 3 | * @author vivaxy 4 | */ 5 | import * as chalk from 'chalk'; 6 | import * as log from 'log-util'; 7 | import * as wrap from 'word-wrap'; 8 | import * as prompts from 'prompts'; 9 | import { edit } from 'external-editor'; 10 | import { RuleConfigTuple } from '@commitlint/types'; 11 | 12 | import { 13 | getHistory, 14 | setHistory, 15 | Messages, 16 | DEFAULT_MESSAGES, 17 | } from './messages/history'; 18 | 19 | import { getCommitTypes, updateTypesStat } from './messages/commit-types'; 20 | 21 | import { getGitmojis, updateGitmojisStat } from './messages/gitmojis'; 22 | import { 23 | getCommitlintConfigRules, 24 | getRuleValue, 25 | } from './messages/commitlint-config'; 26 | import { EMOJI_TYPES } from './configs'; 27 | 28 | function debug(...message: any[]) { 29 | log.debug('gacp:prompt', ...message); 30 | } 31 | 32 | function trim(input: string) { 33 | return input.trim(); 34 | } 35 | 36 | export default async function prompt({ 37 | editor, 38 | emojiType, 39 | }: { 40 | editor: boolean; 41 | emojiType: EMOJI_TYPES; 42 | }) { 43 | const [typeList, gitmojiList] = await Promise.all([ 44 | getCommitTypes(), 45 | getGitmojis({ emojiType }), 46 | ]); 47 | const history = getHistory(); 48 | 49 | function findInitial(list: Array<{ value: string }>, key: string) { 50 | const index = list.findIndex(function ({ value }) { 51 | return value === key; 52 | }); 53 | if (index === -1) { 54 | return 0; 55 | } 56 | return index; 57 | } 58 | 59 | function suggest( 60 | input: string, 61 | choices: Array<{ title: string; value: string }>, 62 | ) { 63 | if (!input) { 64 | return choices; 65 | } 66 | return choices.filter(function ({ title, value }) { 67 | return ( 68 | title.toLowerCase().indexOf(input.toLowerCase()) > -1 || 69 | value.toLowerCase().indexOf(input.toLowerCase()) > -1 70 | ); 71 | }); 72 | } 73 | 74 | debug('history:', history); 75 | 76 | // ${type}(${scope}): ${emoji}${subject} \n\n ${body} \n\n ${footer} 77 | const questions: prompts.PromptObject[] = [ 78 | { 79 | type: 'autocomplete', 80 | name: 'type', 81 | message: "Select the type of change that you're committing", 82 | choices: typeList, 83 | initial: findInitial(typeList, history.type), 84 | suggest, 85 | format: trim, 86 | }, 87 | { 88 | type: 'text', 89 | name: 'scope', 90 | message: 'Denote the scope of this change', 91 | initial: history.scope, 92 | format: trim, 93 | } 94 | ]; 95 | if (gitmojiList.length) { 96 | questions.push({ 97 | type: 'autocomplete', 98 | name: 'gitmoji', 99 | message: 'Choose a gitmoji', 100 | choices: gitmojiList, 101 | initial: findInitial(gitmojiList, history.gitmoji), 102 | suggest, 103 | format(input: string) { 104 | if (input === 'none') { 105 | return ''; 106 | } 107 | return trim(input); 108 | }, 109 | }) 110 | } 111 | questions.push({ 112 | type: 'text', 113 | name: 'subject', 114 | message: 'Write a short, imperative tense description of the change', 115 | initial: history.subject, 116 | format: trim, 117 | }, 118 | { 119 | type: 'text', 120 | name: 'body', 121 | message: 'Provide a longer description of the change', 122 | initial: history.body, 123 | format: trim, 124 | }, 125 | { 126 | type: 'text', 127 | name: 'footer', 128 | message: 'List any breaking changes or issues closed by this change', 129 | initial: history.footer, 130 | format: trim, 131 | }); 132 | 133 | const answers: Messages = { ...DEFAULT_MESSAGES }; 134 | 135 | for (const q of questions) { 136 | let answer = {}; 137 | if (editor && q.name === 'body') { 138 | const body = trim(edit(history.body)); 139 | answer = { 140 | body, 141 | }; 142 | log.success(chalk.bold(q.message), chalk.grey('…'), body); 143 | } else { 144 | answer = await prompts(q, { 145 | onCancel() { 146 | process.exit(0); 147 | }, 148 | }); 149 | } 150 | 151 | debug('got answer', answer); 152 | Object.assign(answers, answer); 153 | } 154 | debug('got answers', answers); 155 | setHistory(answers); 156 | 157 | const { 158 | 'header-max-length': headerMaxLengthRule, 159 | 'body-max-line-length': bodyMaxLengthRule, 160 | 'footer-max-line-length': footerMaxLengthRule, 161 | } = await getCommitlintConfigRules(); 162 | 163 | const maxHeaderLength = getRuleValue(headerMaxLengthRule, Infinity); 164 | debug('maxHeaderLength', maxHeaderLength); 165 | 166 | // parentheses are only needed when a scope is present 167 | const scope = answers.scope ? `(${answers.scope})` : ''; 168 | const gitmoji = answers.gitmoji ? `${answers.gitmoji} ` : ''; 169 | 170 | // Hard limit this line 171 | let head = `${answers.type}${scope}: ${gitmoji} ${answers.subject}`; 172 | head = head.slice(0, maxHeaderLength); 173 | 174 | // Wrap these lines 175 | function getWrapOptions(width: number) { 176 | return { 177 | trim: true, 178 | newline: '\n', 179 | indent: '', 180 | width, 181 | }; 182 | } 183 | 184 | function wrapWords(words: string, rule?: RuleConfigTuple): string { 185 | const maxLineWidth = getRuleValue(rule, words.length); 186 | return wrap(words, getWrapOptions(maxLineWidth)); 187 | } 188 | 189 | const body = wrapWords(answers.body, bodyMaxLengthRule); 190 | const footer = wrapWords(answers.footer, footerMaxLengthRule); 191 | 192 | await updateTypesStat(answers.type); 193 | 194 | if (emojiType === EMOJI_TYPES.CODE || emojiType === EMOJI_TYPES.EMOJI) { 195 | await updateGitmojisStat({ key: emojiType, value: answers.gitmoji }); 196 | } 197 | 198 | let res = head; 199 | if (body) { 200 | res += `\n\n${body}`; 201 | } 202 | if (footer) { 203 | res += `\n\n${footer}`; 204 | } 205 | return res; 206 | } 207 | -------------------------------------------------------------------------------- /src/configs/gitmojis.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | gitmojis: [ 3 | { 4 | emoji: '🎨', 5 | entity: '🎨', 6 | code: ':art:', 7 | description: 'Improving structure / format of the code.', 8 | name: 'art', 9 | }, 10 | { 11 | emoji: '⚡️', 12 | entity: '⚡', 13 | code: ':zap:', 14 | description: 'Improving performance.', 15 | name: 'zap', 16 | }, 17 | { 18 | emoji: '🔥', 19 | entity: '🔥', 20 | code: ':fire:', 21 | description: 'Removing code or files.', 22 | name: 'fire', 23 | }, 24 | { 25 | emoji: '🐛', 26 | entity: '🐛', 27 | code: ':bug:', 28 | description: 'Fixing a bug.', 29 | name: 'bug', 30 | }, 31 | { 32 | emoji: '🚑', 33 | entity: '🚑', 34 | code: ':ambulance:', 35 | description: 'Critical hotfix.', 36 | name: 'ambulance', 37 | }, 38 | { 39 | emoji: '✨', 40 | entity: '✨', 41 | code: ':sparkles:', 42 | description: 'Introducing new features.', 43 | name: 'sparkles', 44 | }, 45 | { 46 | emoji: '📝', 47 | entity: '📝', 48 | code: ':pencil:', 49 | description: 'Writing docs.', 50 | name: 'pencil', 51 | }, 52 | { 53 | emoji: '🚀', 54 | entity: '🚀', 55 | code: ':rocket:', 56 | description: 'Deploying stuff.', 57 | name: 'rocket', 58 | }, 59 | { 60 | emoji: '💄', 61 | entity: '&#ff99cc;', 62 | code: ':lipstick:', 63 | description: 'Updating the UI and style files.', 64 | name: 'lipstick', 65 | }, 66 | { 67 | emoji: '🎉', 68 | entity: '🎉', 69 | code: ':tada:', 70 | description: 'Initial commit.', 71 | name: 'tada', 72 | }, 73 | { 74 | emoji: '✅', 75 | entity: '✅', 76 | code: ':white_check_mark:', 77 | description: 'Updating tests.', 78 | name: 'white-check-mark', 79 | }, 80 | { 81 | emoji: '🔒', 82 | entity: '🔒', 83 | code: ':lock:', 84 | description: 'Fixing security issues.', 85 | name: 'lock', 86 | }, 87 | { 88 | emoji: '🍎', 89 | entity: '🍎', 90 | code: ':apple:', 91 | description: 'Fixing something on macOS.', 92 | name: 'apple', 93 | }, 94 | { 95 | emoji: '🐧', 96 | entity: '🐧', 97 | code: ':penguin:', 98 | description: 'Fixing something on Linux.', 99 | name: 'penguin', 100 | }, 101 | { 102 | emoji: '🏁', 103 | entity: '🏁', 104 | code: ':checkered_flag:', 105 | description: 'Fixing something on Windows.', 106 | name: 'checkered-flag', 107 | }, 108 | { 109 | emoji: '🤖', 110 | entity: '🤖', 111 | code: ':robot:', 112 | description: 'Fixing something on Android.', 113 | name: 'robot', 114 | }, 115 | { 116 | emoji: '🍏', 117 | entity: '🍏', 118 | code: ':green_apple:', 119 | description: 'Fixing something on iOS.', 120 | name: 'green-apple', 121 | }, 122 | { 123 | emoji: '🔖', 124 | entity: '🔖', 125 | code: ':bookmark:', 126 | description: 'Releasing / Version tags.', 127 | name: 'bookmark', 128 | }, 129 | { 130 | emoji: '🚨', 131 | entity: '🚨', 132 | code: ':rotating_light:', 133 | description: 'Removing linter warnings.', 134 | name: 'rotating-light', 135 | }, 136 | { 137 | emoji: '🚧', 138 | entity: '🚧', 139 | code: ':construction:', 140 | description: 'Work in progress.', 141 | name: 'construction', 142 | }, 143 | { 144 | emoji: '💚', 145 | entity: '💚', 146 | code: ':green_heart:', 147 | description: 'Fixing CI Build.', 148 | name: 'green-heart', 149 | }, 150 | { 151 | emoji: '⬇️', 152 | entity: '⬇️', 153 | code: ':arrow_down:', 154 | description: 'Downgrading dependencies.', 155 | name: 'arrow-down', 156 | }, 157 | { 158 | emoji: '⬆️', 159 | entity: '⬆️', 160 | code: ':arrow_up:', 161 | description: 'Upgrading dependencies.', 162 | name: 'arrow-up', 163 | }, 164 | { 165 | emoji: '📌', 166 | entity: '📌', 167 | code: ':pushpin:', 168 | description: 'Pinning dependencies to specific versions.', 169 | name: 'pushpin', 170 | }, 171 | { 172 | emoji: '👷', 173 | entity: '👷', 174 | code: ':construction_worker:', 175 | description: 'Adding CI build system.', 176 | name: 'construction-worker', 177 | }, 178 | { 179 | emoji: '📈', 180 | code: ':chart_with_upwards_trend:', 181 | description: 'Adding analytics or tracking code.', 182 | name: 'chart-with-upwards-trend', 183 | }, 184 | { 185 | emoji: '♻️', 186 | entity: '♲', 187 | code: ':recycle:', 188 | description: 'Refactoring code.', 189 | name: 'recycle', 190 | }, 191 | { 192 | emoji: '🐳', 193 | entity: '🐳', 194 | code: ':whale:', 195 | description: 'Work about Docker.', 196 | name: 'whale', 197 | }, 198 | { 199 | emoji: '➕', 200 | entity: '➕', 201 | code: ':heavy_plus_sign:', 202 | description: 'Adding a dependency.', 203 | name: 'heavy-plus-sign', 204 | }, 205 | { 206 | emoji: '➖', 207 | entity: '➖', 208 | code: ':heavy_minus_sign:', 209 | description: 'Removing a dependency.', 210 | name: 'heavy-minus-sign', 211 | }, 212 | { 213 | emoji: '🔧', 214 | entity: '🔧', 215 | code: ':wrench:', 216 | description: 'Changing configuration files.', 217 | name: 'wrench', 218 | }, 219 | { 220 | emoji: '🌐', 221 | entity: '🌐', 222 | code: ':globe_with_meridians:', 223 | description: 'Internationalization and localization.', 224 | name: 'globe-with-meridians', 225 | }, 226 | { 227 | emoji: '✏️', 228 | entity: '', 229 | code: ':pencil2:', 230 | description: 'Fixing typos.', 231 | name: 'pencil', 232 | }, 233 | { 234 | emoji: '💩', 235 | entity: '', 236 | code: ':poop:', 237 | description: 'Writing bad code that needs to be improved.', 238 | name: 'poop', 239 | }, 240 | { 241 | emoji: '⏪', 242 | entity: '⏪', 243 | code: ':rewind:', 244 | description: 'Reverting changes.', 245 | name: 'rewind', 246 | }, 247 | { 248 | emoji: '🔀', 249 | entity: '🔀', 250 | code: ':twisted_rightwards_arrows:', 251 | description: 'Merging branches.', 252 | name: 'twisted-rightwards-arrows', 253 | }, 254 | { 255 | emoji: '📦', 256 | entity: 'F4E6;', 257 | code: ':package:', 258 | description: 'Updating compiled files or packages.', 259 | name: 'package', 260 | }, 261 | { 262 | emoji: '👽', 263 | entity: 'F47D;', 264 | code: ':alien:', 265 | description: 'Updating code due to external API changes.', 266 | name: 'alien', 267 | }, 268 | { 269 | emoji: '🚚', 270 | entity: 'F69A;', 271 | code: ':truck:', 272 | description: 'Moving or renaming files.', 273 | name: 'truck', 274 | }, 275 | { 276 | emoji: '📄', 277 | entity: 'F4C4;', 278 | code: ':page_facing_up:', 279 | description: 'Adding or updating license.', 280 | name: 'page-facing-up', 281 | }, 282 | { 283 | emoji: '💥', 284 | entity: '💥', 285 | code: ':boom:', 286 | description: 'Introducing breaking changes.', 287 | name: 'boom', 288 | }, 289 | { 290 | emoji: '🍱', 291 | entity: 'F371', 292 | code: ':bento:', 293 | description: 'Adding or updating assets.', 294 | name: 'bento', 295 | }, 296 | { 297 | emoji: '👌', 298 | entity: '👌', 299 | code: ':ok_hand:', 300 | description: 'Updating code due to code review changes.', 301 | name: 'ok-hand', 302 | }, 303 | { 304 | emoji: '♿️', 305 | entity: '♿', 306 | code: ':wheelchair:', 307 | description: 'Improving accessibility.', 308 | name: 'wheelchair', 309 | }, 310 | { 311 | emoji: '💡', 312 | entity: '💡', 313 | code: ':bulb:', 314 | description: 'Documenting source code.', 315 | name: 'bulb', 316 | }, 317 | { 318 | emoji: '🍻', 319 | entity: '🍻', 320 | code: ':beers:', 321 | description: 'Writing code drunkenly.', 322 | name: 'beers', 323 | }, 324 | { 325 | emoji: '💬', 326 | entity: '💬', 327 | code: ':speech_balloon:', 328 | description: 'Updating text and literals.', 329 | name: 'speech-balloon', 330 | }, 331 | { 332 | emoji: '🗃', 333 | entity: '🗃', 334 | code: ':card_file_box:', 335 | description: 'Performing database related changes.', 336 | name: 'card-file-box', 337 | }, 338 | { 339 | emoji: '🔊', 340 | entity: '🔊', 341 | code: ':loud_sound:', 342 | description: 'Adding logs.', 343 | name: 'loud-sound', 344 | }, 345 | { 346 | emoji: '🔇', 347 | entity: '🔇', 348 | code: ':mute:', 349 | description: 'Removing logs.', 350 | name: 'mute', 351 | }, 352 | { 353 | emoji: '👥', 354 | entity: '👥', 355 | code: ':busts_in_silhouette:', 356 | description: 'Adding contributor(s).', 357 | name: 'busts-in-silhouette', 358 | }, 359 | { 360 | emoji: '🚸', 361 | entity: '🚸', 362 | code: ':children_crossing:', 363 | description: 'Improving user experience / usability.', 364 | name: 'children-crossing', 365 | }, 366 | { 367 | emoji: '🏗', 368 | entity: 'f3d7;', 369 | code: ':building_construction:', 370 | description: 'Making architectural changes.', 371 | name: 'building-construction', 372 | }, 373 | { 374 | emoji: '📱', 375 | entity: '📱', 376 | code: ':iphone:', 377 | description: 'Working on responsive design.', 378 | name: 'iphone', 379 | }, 380 | { 381 | emoji: '🤡', 382 | entity: '🤡', 383 | code: ':clown_face:', 384 | description: 'Mocking things.', 385 | name: 'clown-face', 386 | }, 387 | { 388 | emoji: '🥚', 389 | entity: '🥚', 390 | code: ':egg:', 391 | description: 'Adding an easter egg.', 392 | name: 'egg', 393 | }, 394 | { 395 | emoji: '🙈', 396 | entity: 'bdfe7;', 397 | code: ':see_no_evil:', 398 | description: 'Adding or updating a .gitignore file', 399 | name: 'see-no-evil', 400 | }, 401 | { 402 | emoji: '📸', 403 | entity: '📸', 404 | code: ':camera_flash:', 405 | description: 'Adding or updating snapshots', 406 | name: 'camera-flash', 407 | }, 408 | { 409 | emoji: '⚗', 410 | entity: '📸', 411 | code: ':alembic:', 412 | description: 'Experimenting new things', 413 | name: 'alembic', 414 | }, 415 | { 416 | emoji: '🔍', 417 | entity: '🔍', 418 | code: ':mag:', 419 | description: 'Improving SEO', 420 | name: 'mag', 421 | }, 422 | { 423 | emoji: '☸️', 424 | entity: '☸', 425 | code: ':wheel_of_dharma:', 426 | description: 'Work about Kubernetes', 427 | name: 'wheel-of-dharma', 428 | }, 429 | { 430 | emoji: '🏷️', 431 | entity: '🏷', 432 | code: ':label:', 433 | description: 'Adding or updating types (Flow, TypeScript)', 434 | name: 'label', 435 | }, 436 | ], 437 | }; 438 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. 4 | 5 | ### [3.0.3](https://github.com/vivaxy/gacp/compare/v3.0.2...v3.0.3) (2022-08-17) 6 | 7 | 8 | ### Bug Fixes 9 | 10 | * :bug: cannot push when multiple remotes ([002ecbd](https://github.com/vivaxy/gacp/commit/002ecbdef192439646103430b81dd8d6ae15374b)), closes [#92](https://github.com/vivaxy/gacp/issues/92) 11 | 12 | ### [3.0.2](https://github.com/vivaxy/gacp/compare/v3.0.1...v3.0.2) (2022-05-19) 13 | 14 | 15 | ### Bug Fixes 16 | 17 | * :bug: fix no-verify behaviour ([156c75b](https://github.com/vivaxy/gacp/commit/156c75bb7cc17398b6b285f2bfe22e2b50479d0e)), closes [#124](https://github.com/vivaxy/gacp/issues/124) 18 | 19 | ### [3.0.1](https://github.com/vivaxy/gacp/compare/v3.0.0...v3.0.1) (2022-05-05) 20 | 21 | 22 | ### Bug Fixes 23 | 24 | * :bug: revert default emoji config from none to code ([3000e9e](https://github.com/vivaxy/gacp/commit/3000e9e79e5caa8fe815ae8d7f4c1cbad4bfe625)) 25 | 26 | ## [3.0.0](https://github.com/vivaxy/gacp/compare/v2.10.2...v3.0.0) (2022-05-04) 27 | 28 | 29 | ### ⚠ BREAKING CHANGES 30 | 31 | * set gitmoji disabled by default. closes: #118 32 | * gacp no longer push tags. closes #123 33 | 34 | ### Features 35 | 36 | * support disable gitmoji ([0b9e9dd](https://github.com/vivaxy/gacp/commit/0b9e9dd048e42e4f2e92c8097c49a78c6f71c4b3)) 37 | * **add `--no-verify` option`:** :sparkles: ([1d81dab](https://github.com/vivaxy/gacp/commit/1d81dabcba5a250b15cd99da6abd7293da9d67f4)), closes [#121](https://github.com/vivaxy/gacp/issues/121) 38 | * remove `--follow-tags` when pushing ([f94879e](https://github.com/vivaxy/gacp/commit/f94879e392d00ca000b08cce9e900b2f38e1b0af)) 39 | 40 | 41 | ### Bug Fixes 42 | 43 | * **deps:** update dependency execa to v5 ([c8d39de](https://github.com/vivaxy/gacp/commit/c8d39defe4d2e81966368817b74d704b8ad577f0)) 44 | * **deps:** update dependency fs-extra to v10 ([69d3ace](https://github.com/vivaxy/gacp/commit/69d3acec47a02629943b44b41be3084cdc43cfac)) 45 | * **deps:** update dependency yargs to v17 ([78ea990](https://github.com/vivaxy/gacp/commit/78ea9902ff6b198deeb19a0240e81e54cf5c5028)) 46 | 47 | ### [2.10.2](https://github.com/vivaxy/gacp/compare/v2.10.1...v2.10.2) (2020-10-13) 48 | 49 | 50 | ### Bug Fixes 51 | 52 | * :bug: fix history not cleared ([b7fb625](https://github.com/vivaxy/gacp/commit/b7fb625d2aca5fd7b5042d7bc1d885d9e4adde87)) 53 | * :bug: fix history not cleared after a successfully commit ([c06e3e6](https://github.com/vivaxy/gacp/commit/c06e3e6fb07f9e73dd31f1c38fe48d8ba8070fbe)) 54 | 55 | ### [2.10.1](https://github.com/vivaxy/gacp/compare/v2.10.0...v2.10.1) (2020-10-13) 56 | 57 | 58 | ### Bug Fixes 59 | 60 | * :bug: fix history not working ([8cb774d](https://github.com/vivaxy/gacp/commit/8cb774d6ff11a40b0a5a6268e2a06a1fe57492ab)) 61 | * **deps:** update dependency cosmiconfig to v7 ([6cd362b](https://github.com/vivaxy/gacp/commit/6cd362b1eb54b005337d37af0f9f4801c04ddc78)) 62 | * **deps:** update dependency update-notifier to v5 ([781ce71](https://github.com/vivaxy/gacp/commit/781ce71eae1d656a59a2d4c019ff8dcd4902707c)) 63 | * **deps:** update dependency yargs to v16 ([98f5753](https://github.com/vivaxy/gacp/commit/98f57538a78e926080b4cd344c5ed95a1cfe0d6f)) 64 | 65 | ## [2.10.0](https://github.com/vivaxy/gacp/compare/v2.9.0...v2.10.0) (2020-06-23) 66 | 67 | 68 | ### Features 69 | 70 | * :sparkles: support multi-line longer description ([42c431a](https://github.com/vivaxy/gacp/commit/42c431a73974b293df730731ffe75ccd46aec1e4)), closes [#40](https://github.com/vivaxy/gacp/issues/40) [#43](https://github.com/vivaxy/gacp/issues/43) 71 | 72 | 73 | ### Bug Fixes 74 | 75 | * **deps:** update dependency chalk to v4 ([4dd27bd](https://github.com/vivaxy/gacp/commit/4dd27bd040488599c57089fb74fe472b2188b2a7)) 76 | * **deps:** update dependency conventional-commit-types to v3 ([44fe77d](https://github.com/vivaxy/gacp/commit/44fe77d06b988447d93d6e2d0f8ef31ef869cf6e)) 77 | * **deps:** update dependency cosmiconfig to v6 ([bf0168e](https://github.com/vivaxy/gacp/commit/bf0168e555953f412d3597bebbe2a3244c31d0b2)) 78 | * **deps:** update dependency execa to ^0.11.0 ([55e4b14](https://github.com/vivaxy/gacp/commit/55e4b147e640ae137151c39f465d094a9d255cce)) 79 | * **deps:** update dependency execa to v4 ([87a4dc4](https://github.com/vivaxy/gacp/commit/87a4dc48269ec443e259b3fa3dffcdf20036ec21)) 80 | * **deps:** update dependency fs-extra to v9 ([ada4c09](https://github.com/vivaxy/gacp/commit/ada4c092147eb0c65fa003d84f5808d0713345b5)) 81 | * **deps:** update dependency update-notifier to v4 ([2e1670f](https://github.com/vivaxy/gacp/commit/2e1670f3df1ae59ced7b06c390ee349a1d68298a)) 82 | * **deps:** update dependency yargs to v15 ([f8cde91](https://github.com/vivaxy/gacp/commit/f8cde91994068a23d5c4f77b1d450274c6a73059)) 83 | 84 | ## [2.9.0](https://github.com/vivaxy/gacp/compare/v2.8.0...v2.9.0) (2020-05-05) 85 | 86 | 87 | ### Features 88 | 89 | * :sparkles: support run `gacp` in a git subdirectory ([9bad872](https://github.com/vivaxy/gacp/commit/9bad872)) 90 | 91 | 92 | 93 | ## [2.8.0](https://github.com/vivaxy/gacp/compare/v2.7.2...v2.8.0) (2020-04-29) 94 | 95 | 96 | ### Bug Fixes 97 | 98 | * :bug: fix commitlint rule when rule config is set to `never` ([6ffbe7c](https://github.com/vivaxy/gacp/commit/6ffbe7c)) 99 | 100 | 101 | ### Build System 102 | 103 | * :children_crossing: add vscode debug config ([2aa6aaa](https://github.com/vivaxy/gacp/commit/2aa6aaa)) 104 | 105 | 106 | ### Features 107 | 108 | * :sparkles: support run postpush hook ([d7bc7d8](https://github.com/vivaxy/gacp/commit/d7bc7d8)), closes [#45](https://github.com/vivaxy/gacp/issues/45) [#46](https://github.com/vivaxy/gacp/issues/46) 109 | * :sparkles: add `--set-upstream` option when `git push` ([50d9258](https://github.com/vivaxy/gacp/commit/50d9258)), closes [#44](https://github.com/vivaxy/gacp/issues/44) 110 | 111 | 112 | 113 | ### [2.7.2](https://github.com/vivaxy/gacp/compare/v2.7.1...v2.7.2) (2020-02-25) 114 | 115 | 116 | ### Bug Fixes 117 | 118 | * **typo:** :rewind: revert last fix, `terse` to `tense` ([5aa6bc1](https://github.com/vivaxy/gacp/commit/5aa6bc1)) 119 | 120 | 121 | 122 | ### [2.7.1](https://github.com/vivaxy/gacp/compare/v2.7.0...v2.7.1) (2020-02-25) 123 | 124 | 125 | ### Bug Fixes 126 | 127 | * :pencil2: `tense` to `terse` ([2bd14f5](https://github.com/vivaxy/gacp/commit/2bd14f5)), closes [#39](https://github.com/vivaxy/gacp/issues/39) 128 | 129 | 130 | 131 | ## [2.7.0](https://github.com/vivaxy/gacp/compare/v2.6.3...v2.7.0) (2020-02-19) 132 | 133 | 134 | ### Features 135 | 136 | * :sparkles: support `--no-add` ([bd5fb4f](https://github.com/vivaxy/gacp/commit/bd5fb4f)) 137 | 138 | 139 | 140 | ### [2.6.3](https://github.com/vivaxy/gacp/compare/v2.6.2...v2.6.3) (2020-02-03) 141 | 142 | 143 | 144 | ### [2.6.2](https://github.com/vivaxy/gacp/compare/v2.6.1...v2.6.2) (2019-07-16) 145 | 146 | 147 | ### Bug Fixes 148 | 149 | * **import:** :bug: remove useless import ([9ee670a](https://github.com/vivaxy/gacp/commit/9ee670a)) 150 | * **word wrap:** :bug: width value ([b5444a2](https://github.com/vivaxy/gacp/commit/b5444a2)) 151 | 152 | 153 | 154 | ### [2.6.1](https://github.com/vivaxy/gacp/compare/v2.6.0...v2.6.1) (2019-07-16) 155 | 156 | 157 | ### Bug Fixes 158 | 159 | * **format:** :bug: fix wrap body or footer at the right width ([1b62903](https://github.com/vivaxy/gacp/commit/1b62903)) 160 | * **format:** :bug: fix wrap body or footer at the right width ([#33](https://github.com/vivaxy/gacp/issues/33)) ([3f29a7c](https://github.com/vivaxy/gacp/commit/3f29a7c)) 161 | 162 | 163 | ### Tests 164 | 165 | * **nyc:** :white_check_mark: fix nyc coverage report ([89f1d02](https://github.com/vivaxy/gacp/commit/89f1d02)) 166 | 167 | 168 | 169 | ## [2.6.0](https://github.com/vivaxy/gacp/compare/v2.5.8...v2.6.0) (2019-07-04) 170 | 171 | 172 | ### Bug Fixes 173 | 174 | * **prompt:** :bug: Fix prompt ([0d83543](https://github.com/vivaxy/gacp/commit/0d83543)) 175 | * **prompt:** none ([369c88b](https://github.com/vivaxy/gacp/commit/369c88b)) 176 | * **remove:** :fire: remove lib/index.js ([65546ec](https://github.com/vivaxy/gacp/commit/65546ec)) 177 | 178 | 179 | ### Features 180 | 181 | * **commitlint config:** :sparkles: format commit message with local com ([3481762](https://github.com/vivaxy/gacp/commit/3481762)) 182 | 183 | 184 | 185 | ### [2.5.8](https://github.com/vivaxy/gacp/compare/v2.5.7...v2.5.8) (2019-06-20) 186 | 187 | 188 | ### Bug Fixes 189 | 190 | * **error output:** :bug: Improve uncaught error output ([dcb91fe](https://github.com/vivaxy/gacp/commit/dcb91fe)) 191 | 192 | 193 | 194 | ### [2.5.7](https://github.com/vivaxy/gacp/compare/v2.5.6...v2.5.7) (2019-06-20) 195 | 196 | 197 | ### Bug Fixes 198 | 199 | * **error output:** :bug: Improve uncaught error output ([9c2f3a9](https://github.com/vivaxy/gacp/commit/9c2f3a9)) 200 | 201 | 202 | 203 | ### [2.5.6](https://github.com/vivaxy/gacp/compare/v2.5.5...v2.5.6) (2019-06-20) 204 | 205 | 206 | ### Bug Fixes 207 | 208 | * **shebang:** :bug: Fix missing shebang ([9b72b9b](https://github.com/vivaxy/gacp/commit/9b72b9b)) 209 | 210 | 211 | 212 | ### [2.5.5](https://github.com/vivaxy/gacp/compare/v2.5.4...v2.5.5) (2019-06-20) 213 | 214 | 215 | ### Bug Fixes 216 | 217 | * **stdout:** :bug: Fix stdout without colors ([c4d959a](https://github.com/vivaxy/gacp/commit/c4d959a)) 218 | 219 | 220 | 221 | ### [2.5.4](https://github.com/vivaxy/gacp/compare/v2.5.3...v2.5.4) (2019-06-19) 222 | 223 | 224 | ### Bug Fixes 225 | 226 | * **update notifier:** :bug: Fix install command will be `yarn add gacp` ([3248e60](https://github.com/vivaxy/gacp/commit/3248e60)) 227 | 228 | 229 | 230 | ### [2.5.3](https://github.com/vivaxy/gacp/compare/v2.5.2...v2.5.3) (2019-06-17) 231 | 232 | 233 | 234 | 235 | ## [2.5.2](https://github.com/vivaxy/gacp/compare/v2.5.1...v2.5.2) (2019-06-17) 236 | 237 | 238 | ### Bug Fixes 239 | 240 | * **emoji:** :bug: Fix none in emoji ([98f6048](https://github.com/vivaxy/gacp/commit/98f6048)) 241 | 242 | 243 | 244 | 245 | ## [2.5.1](https://github.com/vivaxy/gacp/compare/v2.5.0...v2.5.1) (2019-06-14) 246 | 247 | 248 | ### Bug Fixes 249 | 250 | * **prompt:** :bug: Fix prompt default value ([4cfa76a](https://github.com/vivaxy/gacp/commit/4cfa76a)) 251 | 252 | 253 | 254 | 255 | # [2.5.0](https://github.com/vivaxy/gacp/compare/v2.4.0...v2.5.0) (2019-06-14) 256 | 257 | 258 | ### Features 259 | 260 | * **prompt:** :sparkles: Use autocomplete to improve select experience ([b3af533](https://github.com/vivaxy/gacp/commit/b3af533)) 261 | 262 | 263 | 264 | 265 | # [2.4.0](https://github.com/vivaxy/gacp/compare/v2.3.3...v2.4.0) (2019-06-14) 266 | 267 | 268 | ### Bug Fixes 269 | 270 | * **commitlint:** :bug:fix header-max-length to 72 ([c08b207](https://github.com/vivaxy/gacp/commit/c08b207)) 271 | 272 | 273 | ### Features 274 | 275 | * **config:** :sparkles: support .rc files ([5570d57](https://github.com/vivaxy/gacp/commit/5570d57)) 276 | * **options:** :sparkles:add whether to use emoji code option ([69ebe29](https://github.com/vivaxy/gacp/commit/69ebe29)) 277 | 278 | 279 | 280 | 281 | ## [2.3.3](https://github.com/vivaxy/gacp/compare/v2.3.2...v2.3.3) (2019-06-13) 282 | 283 | 284 | ### Performance Improvements 285 | 286 | * **history:** :zap:Optimize history performance ([c4850db](https://github.com/vivaxy/gacp/commit/c4850db)) 287 | 288 | 289 | 290 | 291 | ## [2.3.2](https://github.com/vivaxy/gacp/compare/v2.3.1...v2.3.2) (2019-06-13) 292 | 293 | 294 | 295 | 296 | ## [2.3.1](https://github.com/vivaxy/gacp/compare/v2.3.0...v2.3.1) (2019-06-13) 297 | 298 | 299 | 300 | 301 | # [2.3.0](https://github.com/vivaxy/gacp/compare/v2.2.1...v2.3.0) (2019-06-13) 302 | 303 | 304 | ### Bug Fixes 305 | 306 | * **push:** :bug:argv ([e5b4abf](https://github.com/vivaxy/gacp/commit/e5b4abf)) 307 | * **push:** :bug:function ([df569f3](https://github.com/vivaxy/gacp/commit/df569f3)) 308 | 309 | 310 | ### Features 311 | 312 | * **add options:** :sparkles:add push option ([f94fc07](https://github.com/vivaxy/gacp/commit/f94fc07)) 313 | 314 | 315 | 316 | 317 | ## [2.2.1](https://github.com/vivaxy/gacp/compare/v2.2.0...v2.2.1) (2019-06-13) 318 | 319 | 320 | ### Bug Fixes 321 | 322 | * **history:** :bug:Keep history only when commit message fails ([1379167](https://github.com/vivaxy/gacp/commit/1379167)) 323 | 324 | 325 | 326 | 327 | # [2.2.0](https://github.com/vivaxy/gacp/compare/v2.1.2...v2.2.0) (2019-06-13) 328 | 329 | 330 | ### Features 331 | 332 | * **gitmoji:** :sparkles:Update gitmojis.json ([db727c5](https://github.com/vivaxy/gacp/commit/db727c5)) 333 | * **history:** :sparkles:Support history ([d515f60](https://github.com/vivaxy/gacp/commit/d515f60)) 334 | 335 | 336 | 337 | 338 | ## [2.1.2](https://github.com/vivaxy/gacp/compare/v2.1.1...v2.1.2) (2019-04-01) 339 | 340 | 341 | 342 | 343 | ## [2.1.1](https://github.com/vivaxy/gacp/compare/v2.1.0...v2.1.1) (2019-01-10) 344 | 345 | 346 | ### Bug Fixes 347 | 348 | * **push:** :bug:fix push with --follow-tags ([f0b9ef2](https://github.com/vivaxy/gacp/commit/f0b9ef2)) 349 | 350 | 351 | 352 | 353 | # [2.1.0](https://github.com/vivaxy/gacp/compare/v2.0.1...v2.1.0) (2018-08-02) 354 | 355 | 356 | ### Features 357 | 358 | * **gitmojis:** :sparkles:Add 3 more emoji ([cc7aa71](https://github.com/vivaxy/gacp/commit/cc7aa71)) 359 | 360 | 361 | 362 | 363 | ## [2.0.1](https://github.com/vivaxy/gacp/compare/v2.0.0...v2.0.1) (2018-01-29) 364 | 365 | 366 | 367 | 368 | # [2.0.0](https://github.com/vivaxy/gacp/compare/v1.9.2...v2.0.0) (2018-01-29) 369 | 370 | 371 | ### Features 372 | 373 | * **console:** :sparkles:Update console output, show more details. ([f7fb480](https://github.com/vivaxy/gacp/commit/f7fb480)) 374 | * **prettier:** :sparkles:Replace eslint with prettier ([f6a131c](https://github.com/vivaxy/gacp/commit/f6a131c)) 375 | 376 | 377 | 378 | 379 | ## [1.9.2](https://github.com/vivaxy/gacp/compare/v1.9.1...v1.9.2) (2018-01-22) 380 | 381 | 382 | 383 | 384 | ## [1.9.1](https://github.com/vivaxy/gacp/compare/v1.9.0...v1.9.1) (2018-01-22) 385 | 386 | 387 | 388 | 389 | # [1.9.0](https://github.com/vivaxy/gacp/compare/v1.8.0...v1.9.0) (2018-01-22) 390 | 391 | 392 | ### Features 393 | 394 | * **gtimojis:** :sparkles:Update gitmojis ([58ee25b](https://github.com/vivaxy/gacp/commit/58ee25b)) 395 | 396 | 397 | 398 | 399 | # [1.8.0](https://github.com/vivaxy/gacp/compare/v1.7.0...v1.8.0) (2017-05-31) 400 | 401 | 402 | ### Features 403 | 404 | * **update-notifier:** :sparkles:Add `update-notifier` ([545f95a](https://github.com/vivaxy/gacp/commit/545f95a)) 405 | 406 | 407 | 408 | 409 | # [1.7.0](https://github.com/vivaxy/gacp/compare/v1.6.1...v1.7.0) (2017-05-27) 410 | 411 | 412 | ### Features 413 | 414 | * :sparkles: ([9a24f5c](https://github.com/vivaxy/gacp/commit/9a24f5c)) 415 | * :sparkles:Prompt when password needed ([a19c09e](https://github.com/vivaxy/gacp/commit/a19c09e)) 416 | * **listr:** :sparkles:Switching to VerboseRenderer ([ee4e91a](https://github.com/vivaxy/gacp/commit/ee4e91a)) 417 | 418 | 419 | 420 | 421 | ## [1.6.1](https://github.com/vivaxy/gacp/compare/v1.6.1-0...v1.6.1) (2017-03-20) 422 | 423 | 424 | 425 | 426 | # [1.6.0](https://github.com/vivaxy/gacp/compare/v1.5.1...v1.6.0) (2017-02-05) 427 | 428 | 429 | ### Features 430 | 431 | * **commit types:** :sparkles:Select commit types with order ([8e95772](https://github.com/vivaxy/gacp/commit/8e95772)) 432 | 433 | 434 | 435 | 436 | ## [1.5.1](https://github.com/vivaxy/gacp/compare/v1.5.0...v1.5.1) (2017-02-05) 437 | 438 | 439 | ### Bug Fixes 440 | 441 | * **configManager:** :bug:Fix gitmoji stat order ([a21ffbe](https://github.com/vivaxy/gacp/commit/a21ffbe)) 442 | 443 | 444 | 445 | 446 | # [1.5.0](https://github.com/vivaxy/gacp/compare/v1.4.6...v1.5.0) (2017-02-04) 447 | 448 | 449 | ### Features 450 | 451 | * :sparkles:Update gitmoji list; Use yarn; Sort gitmoji by usage count ([022b38e](https://github.com/vivaxy/gacp/commit/022b38e)) 452 | 453 | 454 | 455 | 456 | ## [1.4.6](https://github.com/vivaxy/gacp/compare/v1.4.5...v1.4.6) (2017-01-27) 457 | 458 | 459 | ### Bug Fixes 460 | 461 | * **checkGitRepository:** :bug:fix not a git repository ([8d37c6b](https://github.com/vivaxy/gacp/commit/8d37c6b)) 462 | * **push:** :bug:Fix push with tags ([0f06702](https://github.com/vivaxy/gacp/commit/0f06702)) 463 | 464 | 465 | 466 | 467 | ## [1.4.5](https://github.com/vivaxy/gacp/compare/v1.4.4...v1.4.5) (2016-12-21) 468 | 469 | 470 | ### Reverts 471 | 472 | * :bug:revert fix when user presses key, console output gets wired, preserve user input ([5dd304c](https://github.com/vivaxy/gacp/commit/5dd304c)) 473 | 474 | 475 | 476 | 477 | ## [1.4.4](https://github.com/vivaxy/gacp/compare/v1.4.3...v1.4.4) (2016-12-04) 478 | 479 | 480 | ### Bug Fixes 481 | 482 | * :bug:fix process not exiting after `listr` have done ([9710067](https://github.com/vivaxy/gacp/commit/9710067)) 483 | 484 | 485 | 486 | 487 | ## [1.4.3](https://github.com/vivaxy/gacp/compare/v1.4.2...v1.4.3) (2016-12-03) 488 | 489 | 490 | ### Bug Fixes 491 | 492 | * :bug:fix when user presses key, console output gets wired ([7301f00](https://github.com/vivaxy/gacp/commit/7301f00)) 493 | 494 | 495 | 496 | 497 | ## [1.4.2](https://github.com/vivaxy/gacp/compare/v1.4.1...v1.4.2) (2016-11-28) 498 | 499 | 500 | ### Bug Fixes 501 | 502 | * **push:** :bug:fix check push, when remote branch not exists, an error thrown ([8e7a70e](https://github.com/vivaxy/gacp/commit/8e7a70e)) 503 | * **push:** :bug:fix check push, when remote branch not exists, output errors ([d116891](https://github.com/vivaxy/gacp/commit/d116891)) 504 | 505 | 506 | 507 | 508 | ## [1.4.1](https://github.com/vivaxy/gacp/compare/v1.4.0...v1.4.1) (2016-11-27) 509 | 510 | 511 | ### Bug Fixes 512 | 513 | * **git:** :bug:fix check remote differ ([c8603cc](https://github.com/vivaxy/gacp/commit/c8603cc)) 514 | 515 | 516 | 517 | 518 | # [1.4.0](https://github.com/vivaxy/gacp/compare/v1.3.3...v1.4.0) (2016-11-27) 519 | 520 | 521 | ### Bug Fixes 522 | 523 | * **babel:** :bug:fix babel rest spread arguments ([9c8352b](https://github.com/vivaxy/gacp/commit/9c8352b)) 524 | * **git:** :bug:fetch before check need push ([68db649](https://github.com/vivaxy/gacp/commit/68db649)) 525 | * **prompt:** :bug:if nothing changed, prompt is not needed ([84498d0](https://github.com/vivaxy/gacp/commit/84498d0)) 526 | * **tasks:** :bug:fix no traking remote ([860f272](https://github.com/vivaxy/gacp/commit/860f272)) 527 | 528 | 529 | ### Features 530 | 531 | * **commit:** check if a git tree is clean ([707750d](https://github.com/vivaxy/gacp/commit/707750d)) 532 | * **exec:** :hammer:using `execa` instead of `shelljs` ([6dc5256](https://github.com/vivaxy/gacp/commit/6dc5256)) 533 | * **git:** :sparkles:check remote differ to info users to pull first; check local status to decide i ([7bca53c](https://github.com/vivaxy/gacp/commit/7bca53c)) 534 | * **git:** :sparkles:skip tasks or add task according to git status ([3793d68](https://github.com/vivaxy/gacp/commit/3793d68)) 535 | * **tasks:** :sparkles:skip git push when there is no tracking remote ([d4a6fe9](https://github.com/vivaxy/gacp/commit/d4a6fe9)) 536 | 537 | 538 | 539 | 540 | ## [1.3.3](https://github.com/vivaxy/gacp/compare/v1.3.2...v1.3.3) (2016-11-27) 541 | 542 | 543 | ### Bug Fixes 544 | 545 | * **commit:** :bug:fix: `"` string in commit message causes command spilt ([68206c5](https://github.com/vivaxy/gacp/commit/68206c5)) 546 | 547 | 548 | 549 | 550 | ## [1.3.2](https://github.com/vivaxy/gacp/compare/v1.3.1...v1.3.2) (2016-11-26) 551 | 552 | 553 | ### Bug Fixes 554 | 555 | * **commit:** :bug:fix commit when message contains '`', fix push when remote not exists ([f198c2c](https://github.com/vivaxy/gacp/commit/f198c2c)) 556 | 557 | 558 | 559 | 560 | ## [1.3.1](https://github.com/vivaxy/gacp/compare/v1.3.0...v1.3.1) (2016-11-23) 561 | 562 | 563 | ### Bug Fixes 564 | 565 | * **push:** :sparkles:push with tag ([64009d2](https://github.com/vivaxy/gacp/commit/64009d2)) 566 | 567 | 568 | 569 | 570 | # [1.3.0](https://github.com/vivaxy/gacp/compare/v1.2.0...v1.3.0) (2016-11-23) 571 | 572 | 573 | ### Features 574 | 575 | * **emoji:** add emoji support in commit ([b6f6233](https://github.com/vivaxy/gacp/commit/b6f6233)) 576 | 577 | 578 | 579 | 580 | # [1.2.0](https://github.com/vivaxy/gacp/compare/v1.1.2...v1.2.0) (2016-11-23) 581 | 582 | 583 | ### Features 584 | 585 | * **changelog:** :memo:test emoji on cz ([07c0707](https://github.com/vivaxy/gacp/commit/07c0707)) 586 | 587 | 588 | 589 | 590 | ## [1.1.2](https://github.com/vivaxy/gacp/compare/v1.1.1...v1.1.2) (2016-11-23) 591 | 592 | 593 | 594 | 595 | ## [1.1.1](https://github.com/vivaxy/gacp/compare/v1.1.0...v1.1.1) (2016-11-23) 596 | 597 | 598 | 599 | 600 | # [1.1.0](https://github.com/vivaxy/gacp/compare/v1.0.0...v1.1.0) (2016-11-22) 601 | 602 | 603 | ### Features 604 | 605 | * add standard-version ([f493227](https://github.com/vivaxy/gacp/commit/f493227)) 606 | * **cz:** add cz support ([3d313c5](https://github.com/vivaxy/gacp/commit/3d313c5)) 607 | * **cz:** add up cz ([ecefae8](https://github.com/vivaxy/gacp/commit/ecefae8)) 608 | 609 | 610 | # [1.0.0](https://github.com/vivaxy/gacp/compare/546577...v1.0.0) (2016-11-22) 611 | 612 | ### Features 613 | 614 | * check git repository ([ff0585a](https://github.com/vivaxy/gacp/commit/ff0585a)) 615 | * optimize help message 616 | 617 | 618 | # [0.0.0](https://github.com/vivaxy/gacp/compare/d4b3c3...546577) (2016-11-22) 619 | 620 | * first version 621 | --------------------------------------------------------------------------------