diff --git a/.git_consistent b/.git_consistent new file mode 100644 index 0000000..1877d98 --- /dev/null +++ b/.git_consistent @@ -0,0 +1,52 @@ +:type: + :type: :enum + :required: false + :description: 'commit type' + :values: + - + :name: feat + :description: 'when implementing function' + - + :name: fix + :description: 'when fixing a bug' + - + :name: refactor + :description: 'when refactoring' + - + :name: docs + :description: 'when writing docs' + - + :name: test + :description: 'when adding tests' + - + :name: remove + :description: 'when removing function' + - + :name: perf + :description: 'when improving performance' + - + :name: ci + :description: 'when fixing the CI build' + - + :name: sec + :description: 'when dealing with security' + - + :name: up + :description: 'when upgrading dependencies' + - + :name: down + :description: 'when downgrading dependencies' + - + :name: tada + :description: 'when celebrating' + - + :name: revert + :description: 'when reverts a previous commit' +:subject: + :type: :string + :required: false + :description: 'The subject contains succinct description of the change' +:body: + :type: :text + :required: true + :description: 'Body' diff --git a/.git_consistent.yaml b/.git_consistent.yaml deleted file mode 100644 index d6ca52f..0000000 --- a/.git_consistent.yaml +++ /dev/null @@ -1,93 +0,0 @@ -type: - type: enum - required: true - description: 'commit type' - values: - - - name: feat - description: 'when implementing function' - - - name: fix - description: 'when fixing a bug' - - - name: refactor - description: 'when refactoring' - - - name: docs - description: 'when writing docs' - - - name: test - description: 'when adding tests' - - - name: chore - description: "when change other that don't modify code or test files" - - - name: remove - description: 'when removing function' - - - name: perf - description: 'when improving performance' - - - name: ci - description: 'when fixing the CI build' - - - name: sec - description: 'when dealing with security' - - - name: up - description: 'when upgrading dependencies' - - - name: down - description: 'when downgrading dependencies' - - - name: tada - description: 'when celebrating' - - - name: revert - description: 'when reverts a previous commit' -scope: - type: enum - required: false - description: 'The scope could be specifying place of the commit change.' - prefix: '(' - suffix: ')' - values: - - - name: "main" - description: 'main.js' - - - name: "gen-config" - description: 'gen-config.js' -subject: - type: string - required: true - description: 'The subject contains succinct description of the change' - rules: - firstLetter: lower - dotAtEnd: false - nonAscii: false -issueKeyword: - type: branch - required: false - description: 'Github issue link' - regExp: 'issue([0-9]+)' - regExpFlag: 'i' - prefix: '(close #' - suffix: ")" -issueLink: - type: branch - required: false - description: 'Github issue link' - regExp: 'issue([0-9]+)' - regExpFlag: 'i' - prefix: 'https://github.com/isuke/git-consistent/issues/' - suffix: "\n" -body: - type: text - default: '' - required: false - description: 'The body contains details of the change' - rules: - firstLetter: upper - dotAtEnd: true - nonAscii: false diff --git a/.gitcommit_template b/.gitcommit_template index e71b3c7..263e4fa 100644 --- a/.gitcommit_template +++ b/.gitcommit_template @@ -1,3 +1,5 @@ -: +: - + +# comment +# comment diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index e54531b..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Test and Lint - -on: [push] - -jobs: - test: - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [16.x, 18.x, 20.x, 22.x, 24.x] - - steps: - - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - cache: 'npm' - - run: npm install - - run: npm run test - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 20.x - cache: 'npm' - - run: npm install - - run: npm run lint diff --git a/.gitignore b/.gitignore index ee64b27..dd3d82b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ node_modules/ - -.vscode/launch.json +yarn-error.log diff --git a/.prettierrc.json b/.prettierrc.json deleted file mode 100644 index a89e00b..0000000 --- a/.prettierrc.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "printWidth": 160, - "tabWidth": 2, - "useTabs": false, - "semi": false, - "singleQuote": true, - "quoteProps": "consistent", - "trailingComma": "all", - "bracketSpacing": true, - "arrowParens": "always" -} diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..a21a3cb --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,34 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Launch Program", + "program": "${workspaceFolder}/git-consistent", + "cwd": "${workspaceFolder}", + "args": [ + "-i", + "--type='feat'", + "--scope=''", + // "--subject='this is test'", + "-D" + ] + }, + { + "type": "node", + "request": "launch", + "name": "Run Test", + "program": "${workspaceRoot}/node_modules/ava/profile.js", + "args": [ + "${file}" + ], + "skipFiles": [ + "/**/*.js" + ] + } + ] +} diff --git a/AGENTS.md b/AGENTS.md deleted file mode 100644 index f619a46..0000000 --- a/AGENTS.md +++ /dev/null @@ -1,91 +0,0 @@ -# AGENTS.md - -This document defines **project-specific assumptions, restrictions, and priorities** for AI agents working in this repository. -It is intended to be read by both human contributors and AI assistants. - ---- - -## 1. Communication - -- **Language** - - Conversations, explanations, and review comments may be in Japanese or English depending on the user’s preference. - - Code comments and documentation should follow the existing style in the repo and are **primarily written in English** (e.g. `README.md`). -- **Tone** - - Keep explanations **concise and information-dense**. - - Always leave at least a short note about the motivation or background of non-trivial changes. - ---- - -## 2. Project Overview (for AI) - -- This package is a **CLI tool to keep git commit messages consistent**. -- Entry point: `lib/index.js` (wired via `bin.git-consistent`). -- Main tech stack: - - Node.js ESM (`"type": "module"`) - - CLI: `commander`, `inquirer`, `prompt-sync` - - Configuration: `.git_consistent.yaml` (YAML) and `.gitcommit_template` - - Tests: `ava` - - Lint / formatting: `eslint` + `prettier` - -**Key files / directories** - -- `lib/` – CLI implementation -- `.git_consistent.yaml` – sample configuration for user projects -- `.gitcommit_template` – commit template -- `test/` – AVA tests -- `.github/workflows/main.yml` – CI (lint + test) - ---- - -## 3. Change Policy and Priorities - -- **Do not break existing CLI behavior** - - When changing flags, prompts, or interactive flows, **update tests and documentation** accordingly. -- **Treat user-facing surfaces as public API** - - Command-line options, configuration file format, and template variable names are de facto public API. - - If compatibility is intentionally broken, update `CHANGELOG.md` and the relevant sections of `README.md`. -- **Prefer small and safe steps** - - Before large refactors, introduce internal helpers and additional tests to create a safety net. - ---- - -## 4. Coding Guidelines (for AI-generated code) - -- **Style** - - Use **ES Modules** (`import` / `export`) to match existing code. - - Follow eslint/prettier for details like semicolons and indentation; do not introduce a custom manual style. -- **Lint / Format** - - Write code with `npm run lint` in mind; avoid patterns that will obviously violate rules. - - Assume `npm run fix` exists for auto-fixes, but do not rely on it to hide poor structure. -- **Tests** - - When adding or changing logic, usually add or update **AVA tests in `test/`**. - - Read existing test names and assertions carefully to avoid breaking their intent. - ---- - -## 5. `.git_consistent.yaml` and `.gitcommit_template` - -- These files directly affect users’ commit workflows, so **prioritize compatibility and clarity**. -- When changing samples: - - Ensure the examples are consistent with explanations in `README.md`. - - Ensure the configuration actually works with `git consistent` and produces sensible commit messages. - ---- - -## 6. Documentation Rules - -- When changing CLI options or behavior: - - Update the relevant sections in `README.md` (for example the **Command Reference**). - - Add a short note to `CHANGELOG.md` describing the change (in English). -- If only internal implementation details change and behavior stays the same: - - README updates are usually unnecessary, but you may add comments or tests to clarify intent. - ---- - -## 7. Special Instructions for AI Agents - -- Avoid asking the user for clarification more than necessary; instead, **infer reasonable assumptions** from existing code and `README.md`. -- For changes that might be controversial or breaking, leave clear reasoning: - - Potentially breaking changes in behavior or semantics - - Modifications to CLI interface or configuration format -- When reasonable, add 1–2 lines explaining **why** a change was made, either here in `AGENTS.md`, in commit messages, or in code comments. diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 0d284ab..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,213 +0,0 @@ -# CHANGELOG - -## v1.3.0 2026-01-29 - -- [feat: change file name from .git_consistent to .git_consistent.yaml](https://github.com/isuke/git-consistent/commit/820e9b0) - -## v1.2.0 2025-06-05 - -- [up: upgrade dependencies](https://github.com/isuke/git-consistent/commit/ff55c04) -- [up: upgrade test library](https://github.com/isuke/git-consistent/commit/62ea531) -- [up: upgrade node to 24.1.0](https://github.com/isuke/git-consistent/commit/f39811b) - -## v1.1.4 2023-09-01 - -- [up: upgrade dependencies](https://github.com/isuke/git-consistent/commit/88750d2) -- [up: upgrade node to 20.5.0](https://github.com/isuke/git-consistent/commit/0f2dde1) - -## v1.1.3 2023-02-09 - -- [chore: fix typo](https://github.com/isuke/git-consistent/commit/9ef4594) - -## v1.1.1 2022-10-23 - -- [up: upgrade dependencies and devDependencies](https://github.com/isuke/git-consistent/commit/11173e4) - - -## v1.0.4 2020-04-22 - -- [up: upgrade dependencies](https://github.com/isuke/git-consistent/commit/bb21e7b) -- [up: upgrade commander to 4.1.1](https://github.com/isuke/git-consistent/commit/2764400) -- [up: upgrade devDependencies for Security Alerts](https://github.com/isuke/git-consistent/commit/b4e6bc6) -- [up: upgrade node to v12.16.2](https://github.com/isuke/git-consistent/commit/128e85c) -- [chore: remove unnecessary file](https://github.com/isuke/git-consistent/commit/5420652) - -## v1.0.3 2019-10-26 - -- [up: upgrade inquirer](https://github.com/isuke/git-consistent/commit/fc08d88) -- [up: upgrade csv-parse](https://github.com/isuke/git-consistent/commit/fceb3db) -- [up: upgrade commander](https://github.com/isuke/git-consistent/commit/d014fe0) -- [up: upgrade eslint](https://github.com/isuke/git-consistent/commit/2cc8369) - -## v1.0.2 2019-08-20 - -- [up: upgrade ava and lodash.merge](https://github.com/isuke/git-consistent/commit/634f90d) - -## v1.0.1 2019-08-20 - -- [fix: hotfix version test](https://github.com/isuke/git-consistent/commit/5a1529b) - -## v1.0.0 2019-07-27 - -- [remove(main): remove old function](https://github.com/isuke/git-consistent/commit/797321c) -- [up: upgrade dependencies](https://github.com/isuke/git-consistent/commit/d96bf03) -- [up: upgrade node to v12.7.0](https://github.com/isuke/git-consistent/commit/9c96c53) - -## v0.9.9 2019-06-09 - -- [up: upgrade devDependencies](https://github.com/isuke/git-consistent/commit/17cbaa4) -- [up: upgrade dependencies](https://github.com/isuke/git-consistent/commit/a1f3742) -- [up: upgrade node to v12.4.0](https://github.com/isuke/git-consistent/commit/887f218) - -## v0.9.8 2019-04-26 - -- [up: upgrade node to v12.0.0](https://github.com/isuke/git-consistent/commit/d7f5c48) - -## v0.9.7 2019-01-01 - -- [up: upgrade node to v11.6.0](https://github.com/isuke/git-consistent/commit/719f65f) - -## v0.9.6 2018-11-14 - -- [feat(gen-config): change '--gen-config' option to 'init' command](https://github.com/isuke/git-consistent/commit/a8b7546) -- [fix(main): fix can not catch error bug](https://github.com/isuke/git-consistent/commit/2b93432) -- [up: upgrade 'commander'](https://github.com/isuke/git-consistent/commit/c2a3991) - -## v0.9.5 2018-11-12 - -- [up: upgrade node to 11](https://github.com/isuke/git-consistent/commit/ca3f275) -- [feat: add file paths to help](https://github.com/isuke/git-consistent/commit/896a260) - -## v0.9.4 2018-10-18 - -- [fix(main): fix error occured when first commit (close #3)](https://github.com/isuke/git-consistent/commit/769c987) - -## v0.9.3 2018-09-28 - -- [feat(main): add rule of 'maxLength' and 'minLength'](https://github.com/isuke/git-consistent/commit/40fb159) - -## v0.9.2 2018-09-07 - -- [remove(main): remove typo check (close #2)](https://github.com/isuke/git-consistent/commit/9f87209) - -## v0.9.1 2018-03-18 - -- [fix: fix get global setting file found bug](https://github.com/isuke/git-consistent/commit/d6e45e4) - -## v0.9.0 2018-03-10 - -- [fix(gen-config): fix generate type list bug](https://github.com/isuke/git-consistent/commit/218c15c) - -## v0.8.9 2018-03-10 - -- [chore: add ui to type list](https://github.com/isuke/git-consistent/commit/6cd15ed) - -## v0.8.8 2018-03-10 - -- [fix(gen-config): fix 'no such file or directory' error bug](https://github.com/isuke/git-consistent/commit/b42e464) - -## v0.8.7 2018-03-08 - -- [fix(main): trim value](https://github.com/isuke/git-consistent/commit/bd2fd35) - -## v0.8.6 2018-03-08 - -- [chore(main): add warning message for 'ascii'](https://github.com/isuke/git-consistent/commit/4529abe) - -## v0.8.5 2018-03-08 - -- [fix: rename 'ascii' rule to 'notAscii' rule (the meaning does not change)](https://github.com/isuke/git-consistent/commit/ad79a60) - -## v0.8.0 2018-03-08 - -- [refactor(main): make use inquirer](https://github.com/isuke/git-consistent/commit/a056146) -- [refactor(gen-config): make use inquirer](https://github.com/isuke/git-consistent/commit/218c15c) - -## v0.7.3 2018-03-01 - -- [fix(main): fix error message when violate dotAtEnd rule](https://github.com/isuke/git-consistent/commit/bd71882) - -## v0.7.2 2018-03-01 - -- [fix: remove debug code](https://github.com/isuke/git-consistent/commit/168611a) - -## v0.7.1 2018-02-26 - -- [feat(main): add regExpFlag option](https://github.com/isuke/git-consistent/commit/1f504f6) - -## v0.7.0 2018-02-26 - -- [feat(main): implement type: branch](https://github.com/isuke/git-consistent/commit/33388d5) - -## v0.6.1 2018-02-25 - -- [fix(main): fix first term ignore bug](https://github.com/isuke/git-consistent/commit/a7c6d0f) - -## v0.6.0 2018-02-25 - -- [feat(gen-config): implement gen-config](https://github.com/isuke/git-consistent/commit/6a24e28) - -## v0.5.2 2018-02-13 - -- [fix(main): fix exec git error when not a git repository](https://github.com/isuke/git-consistent/commit/1f9e9ff) - -## v0.5.1 2018-02-12 - -- [feat(main): check enum value](https://github.com/isuke/git-consistent/commit/7a57cf3) - -## v0.5.0 2018-02-11 - -- [fix(main): fix quotes escape bug](https://github.com/isuke/git-consistent/commit/6096ab6) - -## v0.4.4 2018-02-11 - -- [feat(main): support emoji](https://github.com/isuke/git-consistent/commit/24aa1a8) - -## v0.4.3 2018-02-11 - -- [feat(main): implement spellcheck](https://github.com/isuke/git-consistent/commit/eac3bf9) - -## v0.4.2 2018-02-10 - -- [feat(main): exit if not exist added files](https://github.com/isuke/git-consistent/commit/7d0d3bc) - -## v0.4.1 2018-02-10 - -- [feat(main): add silent mode](https://github.com/isuke/git-consistent/commit/33f9d5d) -- [feat(main): add numberOnly rule](https://github.com/isuke/git-consistent/commit/fc81cce) - -## v0.4.0 2018-02-10 - -- [fix(main): fix multiline format check bug](https://github.com/isuke/git-consistent/commit/1cc2942) -- [feat(main): show command](https://github.com/isuke/git-consistent/commit/93bb6fa) -- [feat(main): implement variable](https://github.com/isuke/git-consistent/commit/2e35e18) - -## v0.3.0 2018-02-10 - -- [feat(main): implement forment check](https://github.com/isuke/git-consistent/commit/0f964f3) - -## v0.2.1 2018-02-10 - -- [feat(main): add 'default' define option](https://github.com/isuke/git-consistent/commit/5870973) -- [feat(main): support git-duet](https://github.com/isuke/git-consistent/commit/23a7ae7) -- [feat(main): colorize messages](https://github.com/isuke/git-consistent/commit/0725454) - -## v0.2.0 2018-02-10 - -- [feat(main): support not required enum](https://github.com/isuke/git-consistent/commit/9ab139d) -- [feat: implement decorate function](https://github.com/isuke/git-consistent/commit/a261cc1) -- [feat: add skip-options option](https://github.com/isuke/git-consistent/commit/157cad9) -- [feat: improvement rquired value input](https://github.com/isuke/git-consistent/commit/3d2198e) -- [feat: improvement error message](https://github.com/isuke/git-consistent/commit/33b068d) -- [feat: add '-m' option](https://github.com/isuke/git-consistent/commit/33b068d) - - -## v0.1.1 2018-02-09 - -- [fix: fix required bug](https://github.com/isuke/git-consistent/commit/56f084a) - -## v0.1.0 2018-02-09 - -- [chore: create deploy command](https://github.com/isuke/git-consistent/commit/cf2d49f) - -## v0.0.1 2018-02-09 diff --git a/LICENSE b/LICENSE deleted file mode 100644 index eaaa874..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 FUJIYAMA Isuke - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/README.md b/README.md index 38ab96a..2f42600 100644 --- a/README.md +++ b/README.md @@ -1,356 +1,8 @@ # git-consistent -[![Test and Lint](https://github.com/isuke/git-consistent/actions/workflows/main.yml/badge.svg)](https://github.com/isuke/git-consistent/actions/workflows/main.yml) -[![npm version](https://img.shields.io/npm/v/git-consistent.svg)](https://www.npmjs.com/package/git-consistent) -[![License: MIT](https://img.shields.io/github/license/mashape/apistatus.svg)](https://raw.githubusercontent.com/isuke/git-consistent/main/LICENSE) -[![git-consistent friendly](https://img.shields.io/badge/git--consistent-friendly-brightgreen.svg)](https://github.com/isuke/git-consistent) +![git-consistent demo](https://raw.githubusercontent.com/isuke/git-consistent/images/git-consistent01.gif) -

- git-consistent demo -

+Give consistency to your project's git logs. -**Give consistency to your project's git logs.** - -`git-consistent` helps you and your team maintain a consistent and readable git commit history by enforcing a configurable commit message format. - -Supported Node.js versions: -[!["node v16"](https://img.shields.io/badge/node-v16-026e00.svg)](https://nodejs.org/en/download/releases) -[!["node v18"](https://img.shields.io/badge/node-v18-026e00.svg)](https://nodejs.org/en/download/releases) -[!["node v20"](https://img.shields.io/badge/node-v20-026e00.svg)](https://nodejs.org/en/download/releases) -[!["node v22"](https://img.shields.io/badge/node-v22-026e00.svg)](https://nodejs.org/en/download/releases) -[!["node v24"](https://img.shields.io/badge/node-v24-026e00.svg)](https://nodejs.org/en/download/releases) - -## Features - -- **Interactive & Inline Modes**: Create commits interactively or directly from the command line. -- **Customizable Commit Format**: Define your own commit message structure with a simple YAML configuration file (`.git_consistent.yaml`). -- **Validation Rules**: Enforce standards like case rules for the subject, character limits, and more. -- **Dynamic Variables**: Automatically insert values like issue numbers into your commit messages. -- **Branch Name Parsing**: Extract information (e.g., issue IDs) directly from your git branch name. -- **Emoji Support**: Easily include emojis in your commit types. -- **git-duet Integration**: Works with `git-duet` for pair programming commits. - -## Installation - -```sh -npm install -g git-consistent -``` - -### Optional: Set up a Git Alias - -For easier access, you can create a git alias. - -```sh -git config --global alias.con "consistent -i" -``` - -This allows you to run `git con` instead of `git consistent -i`. - -### Optional: Configure Your Editor - -For multiline commit bodies, `git-consistent` uses the editor defined in your environment variables. - -```sh -# For Visual Studio Code -export EDITOR='code -w' - -# For Cursor -export EDITOR='cursor -w' -``` - -## Getting Started - -### 1. Initialize Configuration - -Run the init command in your project repository. - -```sh -git consistent --init -``` - -This will ask you a few questions and generate two files: -- `.git_consistent.yaml`: Your configuration file. -- `.gitcommit_template`: The template for your commit messages. - -Feel free to edit these files to match your project's conventions. - -### 2. Create a Commit - -You can create commits in several ways. - -#### Interactive Mode - -Run `git consistent` in interactive mode to be prompted for each part of the commit message. - -```sh -$ git consistent -i -? Select type: feat -? Enter subject: implement new feature -? Enter body multiline: -This is an amazing new feature. -``` - -You can also combine interactive mode with command-line arguments. The tool will only prompt for the missing parts. - -```sh -$ git consistent -i --subject="implement new feature" -? Select type: feat -? Enter body multiline: -This is an amazing new feature. -``` - -#### Inline Mode - -Provide all the information using command-line flags. - -```sh -git consistent --type="feat" --subject="implement new feature" --body="This is an amazing feature." -``` - -## Configuration (`.git_consistent.yaml`) - -The `.git_consistent.yaml` file allows you to define and customize the structure of your commit messages. It uses a simple YAML-like format. - -Here is the basic structure: - -```yml -: -