https://github.com/bird-studio/hoipoi_capsule
Fill in message with Deno
https://github.com/bird-studio/hoipoi_capsule
commit cui deno gitmoji gitmojis terminal tui typescript
Last synced: 8 days ago
JSON representation
Fill in message with Deno
- Host: GitHub
- URL: https://github.com/bird-studio/hoipoi_capsule
- Owner: bird-studio
- License: mit
- Created: 2022-11-14T15:18:23.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-10-01T12:18:53.000Z (7 months ago)
- Last Synced: 2026-02-15T12:54:33.660Z (2 months ago)
- Topics: commit, cui, deno, gitmoji, gitmojis, terminal, tui, typescript
- Language: TypeScript
- Homepage: https://deno.land/x/hoipoi_capsule
- Size: 75.2 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# hoipoi capsule
## What is this?
Create a commit message in an interactive format.
Sorry, your browser doesn't support embedded videos.
## Try
```bash
# Go to git directory
brew install deno
deno run --allow-net --allow-write --allow-run "https://deno.land/x/hoipoi_capsule/demo/fill_in_commit_message/conventionalcommits_style.ts?source"
cat .git/COMMIT_EDITMSG
```
## Use
Run with Git hook.
It works without gh. gh is used to obtain github issues.Please complete the gh
setup in advance.
```bash
brew install deno gh
```
Prepare Git hook.
```bash
mkdir .githooks
cat < .githooks/prepare-commit-msg
#!/bin/sh
exec < /dev/tty deno run --allow-net --allow-write --allow-run "https://deno.land/x/hoipoi_capsule/demo/fill_in_commit_message/conventionalcommits_style.ts?source"
EOF
git config --local core.hooksPath .githooks
chmod +x .githooks/prepare-commit-msg
```
Execution.
```bash
touch myFile.txt
git add myFile.txt
git commit
```
## Customize
Here is a reference.
- [conventionalcommits_style](https://github.com/bird-studio/hoipoi_capsule/blob/main/demo/fill_in_commit_message/conventionalcommits_style.ts)
```ts
import * as hoipoiCapsule from "https://deno.land/x/hoipoi_capsule/mod.ts";
const commitMessageTemplate = `{{type}}({{scope}}): {{summary}}
{{body}}
BREAKING CHANGE: {{breakingChange}}`;
hoipoiCapsule.useCase.fillInCommitMessage.run({
commitMessageTemplate,
questionList: [
{
/**
* The answer applies to the {{type}} part of commitMessageTemplate.
*/
target: "type",
/**
* Pre-prepared questions.
*/
q: hoipoiCapsule.preset.fillInCommitMessage.conventionalcommits.qMap.type,
/**
* Thus, you can also create your own questions.
*/
// q: typeQ,
/**
* Modify the commit message.
* Use this function when a message is unanswered, for example.
*/
fixCommitMessage: (p) => {
if (p.answerMap["type"] === "???") {
return p.commitMessage.replace(/\r?\n{2,}/, "\n").trim();
}
return p.commitMessage;
},
},
],
});
/**
* Please check here.
* https://github.com/c4spar/deno-cliffy
*/
const typeQ = () =>
hoipoiCapsule.userInterface.prompt.Select.prompt({
message: "Select type.",
search: true,
options: [
{
name:
"Build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)",
value: "Build",
},
{
name:
"CI: Changes to our CI configuration files and scripts (examples: CircleCi, SauceLabs)",
value: "CI",
},
{ name: "Docs: Documentation only changes", value: "Docs" },
{ name: "Feat: A new feature", value: "Feat" },
{ name: "Fix: A bug fix", value: "Fix:" },
{ name: "Perf: A code change that improves performance", value: "Perf" },
{
name:
"Refactor: A code change that neither fixes a bug nor adds a feature",
value: "Refactor",
},
{
name: "Test: Adding missing tests or correcting existing tests",
value: "Test",
},
],
});
```
## Convenient Use
- [gitmoji_style](https://github.com/bird-studio/hoipoi_capsule/blob/main/demo/fill_in_commit_message/gitmoji_style.ts)
Sorry, your browser doesn't support embedded videos.