preguito 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +258 -0
- package/dist/cli-sea.cjs +4165 -0
- package/dist/cli.mjs +1234 -0
- package/dist/index.cjs +276 -0
- package/dist/index.d.cts +37 -0
- package/dist/index.d.mts +37 -0
- package/dist/index.mjs +269 -0
- package/package.json +42 -0
package/README.md
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
# preguito
|
|
2
|
+
|
|
3
|
+
A lazy git CLI with commit templates and shortcuts.
|
|
4
|
+
|
|
5
|
+
## Why
|
|
6
|
+
|
|
7
|
+
Typing the same commit prefix, squad name, and ticket number over and over is tedious. Teams need consistent commit messages, but enforcing a format manually is error-prone. preguito lets you define a commit template once and reuse it on every commit — variables are filled from defaults or CLI flags, so you only type what matters.
|
|
8
|
+
|
|
9
|
+
## Quick Demo
|
|
10
|
+
|
|
11
|
+
**Without preguito:**
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
git add -A && git commit -m "[PAYMENTS-42] feat(api): add login endpoint" && git push
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
**With preguito:**
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
guito c -m "add login endpoint" -p
|
|
21
|
+
# → Committing: [PAYMENTS-42] feat(api): add login endpoint
|
|
22
|
+
# ✔ Committed.
|
|
23
|
+
# → Pushing...
|
|
24
|
+
# ✔ Pushed.
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The template fills in `[PAYMENTS-42] feat(api):` automatically from your config defaults. You can override any variable on the fly with `--variable value`.
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
### npm (requires Node.js >= 20)
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm install -g preguito
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Standalone binary (.deb)
|
|
38
|
+
|
|
39
|
+
Download the `.deb` from [GitHub Releases](https://github.com/jacodoisdois/preguito/releases) and install:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
sudo dpkg -i preguito_0.1.0_amd64.deb
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
No Node.js required — the binary bundles everything via Node.js SEA.
|
|
46
|
+
|
|
47
|
+
## Getting Started
|
|
48
|
+
|
|
49
|
+
### 1. Run the setup wizard
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
guito init
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The wizard walks you through creating your config:
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
✨ Welcome to preguito setup!
|
|
59
|
+
|
|
60
|
+
Define your commit template.
|
|
61
|
+
Use {{variable}} for named parameters and <message> for the commit message body.
|
|
62
|
+
Example: [{{squad}}-{{card_id}}] {{type}}({{scope}}): <message>
|
|
63
|
+
|
|
64
|
+
Template: [{{squad}}-{{card_id}}] {{type}}({{scope}}): <message>
|
|
65
|
+
|
|
66
|
+
Variables found: squad, card_id, type, scope
|
|
67
|
+
Message placeholder: <message>
|
|
68
|
+
|
|
69
|
+
Set default values (press Enter to skip):
|
|
70
|
+
squad: PAYMENTS
|
|
71
|
+
card_id:
|
|
72
|
+
type: feat
|
|
73
|
+
scope: api
|
|
74
|
+
|
|
75
|
+
✔ Config written to /home/you/.config/preguito/config.json
|
|
76
|
+
Edit it anytime or run 'guito cfg' to view it.
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Or skip the wizard and use the default template (`{{type}}: <message>`):
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
guito init --default
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### 2. Understand the config
|
|
86
|
+
|
|
87
|
+
The wizard creates a JSON file like this:
|
|
88
|
+
|
|
89
|
+
```json
|
|
90
|
+
{
|
|
91
|
+
"template": "[{{squad}}-{{card_id}}] {{type}}({{scope}}): <message>",
|
|
92
|
+
"defaults": {
|
|
93
|
+
"squad": "PAYMENTS",
|
|
94
|
+
"type": "feat",
|
|
95
|
+
"scope": "api"
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
- `{{variable}}` — named parameters, replaced with values from defaults or CLI flags.
|
|
101
|
+
- `<message>` — the commit message body, passed via `-m`.
|
|
102
|
+
- `defaults` — values used when you don't pass a flag. Variables without a default must be passed on the CLI.
|
|
103
|
+
|
|
104
|
+
### 3. Make your first commit
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
guito c -m "add login endpoint" --card_id 42
|
|
108
|
+
# → Committing: [PAYMENTS-42] feat(api): add login endpoint
|
|
109
|
+
# ✔ Committed.
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Override any default:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
guito c -m "fix timeout" --type fix --scope core --card_id 99
|
|
116
|
+
# → Committing: [PAYMENTS-99] fix(core): fix timeout
|
|
117
|
+
# ✔ Committed.
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Preview without committing:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
guito c -m "test message" --card_id 10 -d
|
|
124
|
+
# [PAYMENTS-10] feat(api): test message
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Template System
|
|
128
|
+
|
|
129
|
+
Use `{{variable}}` for named parameters and `<placeholder>` for the commit message body. Variables resolve from CLI flags first, then config defaults.
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# Template: [{{squad}}-{{card_id}}] {{type}}({{scope}}): <message>
|
|
133
|
+
guito c -m "add login" --card_id 42
|
|
134
|
+
# → Committing: [PAYMENTS-42] feat(api): add login
|
|
135
|
+
# ✔ Committed.
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
See [template-system.md](docs/template-system.md) for full syntax, resolution order, and more examples.
|
|
139
|
+
|
|
140
|
+
## Commands
|
|
141
|
+
|
|
142
|
+
| Command | Alias | Description |
|
|
143
|
+
|---------|-------|-------------|
|
|
144
|
+
| `guito c -m "msg"` | `commit` | Templated commit with auto-stage |
|
|
145
|
+
| `guito cf <hash>` | — | Create a fixup commit |
|
|
146
|
+
| `guito ap` | — | Amend + force push |
|
|
147
|
+
| `guito apl` | — | Amend + force push with lease |
|
|
148
|
+
| `guito u [count]` | `undo` | Undo last N commits (soft reset) |
|
|
149
|
+
| `guito pu` | — | Push with --set-upstream |
|
|
150
|
+
| `guito r <branch>` | `rebase` | Quick rebase on branch |
|
|
151
|
+
| `guito re <hash>` | — | Edit rebase at commit |
|
|
152
|
+
| `guito ri <count>` | — | Interactive rebase last N commits |
|
|
153
|
+
| `guito sw <branch>` | `switch` | Switch/create branch |
|
|
154
|
+
| `guito st` | — | Stash changes |
|
|
155
|
+
| `guito stp` | — | Pop latest stash |
|
|
156
|
+
| `guito s` | `status` | Short status |
|
|
157
|
+
| `guito l [count]` | `log` | Compact log (default: 10) |
|
|
158
|
+
| `guito f <keyword>` | `find` | Search commits by message |
|
|
159
|
+
| `guito t <tag>` | `tag` | Commits since/from a tag |
|
|
160
|
+
| `guito i` | `init` | Setup wizard |
|
|
161
|
+
| `guito cfg` | `config` | View configuration |
|
|
162
|
+
|
|
163
|
+
See the [full command reference](docs/README.md) for detailed usage, flags, and examples.
|
|
164
|
+
|
|
165
|
+
## Configuration
|
|
166
|
+
|
|
167
|
+
### Config File Locations
|
|
168
|
+
|
|
169
|
+
preguito searches for config files in this order:
|
|
170
|
+
|
|
171
|
+
1. `.preguitorc` (project root)
|
|
172
|
+
2. `.preguitorc.json` (project root)
|
|
173
|
+
3. `~/.preguitorc`
|
|
174
|
+
4. `~/.preguitorc.json`
|
|
175
|
+
5. `~/.config/preguito/config.json`
|
|
176
|
+
6. Built-in default: `{{type}}: <message>` with `type=feat`
|
|
177
|
+
|
|
178
|
+
Project-local configs take priority, so different repos can use different templates.
|
|
179
|
+
|
|
180
|
+
### Config Schema
|
|
181
|
+
|
|
182
|
+
```json
|
|
183
|
+
{
|
|
184
|
+
"template": "[{{squad}}-{{card_id}}] {{type}}({{scope}}): <message>",
|
|
185
|
+
"defaults": {
|
|
186
|
+
"squad": "PAYMENTS",
|
|
187
|
+
"type": "feat",
|
|
188
|
+
"scope": "api"
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
- `template` **(required)** — your commit message template string.
|
|
194
|
+
- `defaults` *(optional)* — default values for template variables. All values must be strings.
|
|
195
|
+
|
|
196
|
+
### Per-Project Config
|
|
197
|
+
|
|
198
|
+
Place a `.preguitorc` or `.preguitorc.json` at your project root to share a commit convention with your team. This file can be committed to the repo.
|
|
199
|
+
|
|
200
|
+
```json
|
|
201
|
+
// .preguitorc.json
|
|
202
|
+
{
|
|
203
|
+
"template": "[{{squad}}-{{card_id}}] {{type}}: <message>",
|
|
204
|
+
"defaults": {
|
|
205
|
+
"squad": "CHECKOUT",
|
|
206
|
+
"type": "feat"
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
The global config at `~/.config/preguito/config.json` serves as your personal fallback.
|
|
212
|
+
|
|
213
|
+
## Programmatic API
|
|
214
|
+
|
|
215
|
+
preguito exports its core functions for use in other tools:
|
|
216
|
+
|
|
217
|
+
```typescript
|
|
218
|
+
import {
|
|
219
|
+
parseTemplate,
|
|
220
|
+
renderTemplate,
|
|
221
|
+
mergeContext,
|
|
222
|
+
loadConfig,
|
|
223
|
+
loadConfigOrDefault,
|
|
224
|
+
writeConfig,
|
|
225
|
+
} from "preguito";
|
|
226
|
+
|
|
227
|
+
const parsed = parseTemplate("[{{squad}}] {{type}}: <message>");
|
|
228
|
+
// { variables: ["squad", "type"], messagePlaceholder: "message" }
|
|
229
|
+
|
|
230
|
+
const context = mergeContext({ type: "feat" }, { type: "fix" });
|
|
231
|
+
// { type: "fix" }
|
|
232
|
+
|
|
233
|
+
const msg = renderTemplate("[{{squad}}] {{type}}: <message>", { squad: "TEAM", type: "fix" }, "resolve timeout");
|
|
234
|
+
// "[TEAM] fix: resolve timeout"
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## Contributing
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
git clone https://github.com/jacodoisdois/preguito.git
|
|
241
|
+
cd preguito
|
|
242
|
+
npm install
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
| Script | Description |
|
|
246
|
+
|--------|-------------|
|
|
247
|
+
| `npm run dev` | Watch mode (tsdown) |
|
|
248
|
+
| `npm test` | Run tests (vitest) |
|
|
249
|
+
| `npm run lint` | Type check (tsc --noEmit) |
|
|
250
|
+
| `npm run build` | Production build |
|
|
251
|
+
| `npm run build:sea` | Build standalone binary (Node.js SEA) |
|
|
252
|
+
| `npm run build:deb` | Build .deb package |
|
|
253
|
+
|
|
254
|
+
**Tech stack:** TypeScript, Commander.js, tsdown (Rolldown-based bundler), Vitest.
|
|
255
|
+
|
|
256
|
+
## License
|
|
257
|
+
|
|
258
|
+
MIT
|