preguito 0.2.0 → 0.2.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "preguito",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "A lazy git CLI tool with commit templates and shortcuts",
5
5
  "type": "module",
6
6
  "bin": {
package/README.md DELETED
@@ -1,464 +0,0 @@
1
- # 🦥 preguito
2
-
3
- > A lazy git CLI with commit templates and shortcuts.
4
-
5
- Typing the same commit prefix, squad name, and ticket number over and over is tedious. preguito lets you define a commit template once and reuse it on every commit — single-letter shortcodes replace verbose flags, so you only type what matters.
6
-
7
- - 🔤 **Single-letter shortcodes** — `f` for feat, `x` for fix, `p` for prd
8
- - 📝 **Template-based commits** — define once, reuse forever
9
- - ⚡ **Git shortcuts** — commit, push, rebase, stash, undo in 2-3 chars
10
- - 📁 **Per-project config** — `.preguitorc` in your repo for team conventions
11
- - 📦 **One dependency** — just [Commander.js](https://github.com/tj/commander.js), nothing else
12
- - 🖥️ **Standalone binary** — works without Node.js via SEA
13
-
14
- ---
15
-
16
- ## Table of Contents
17
-
18
- - [Quick Demo](#-quick-demo)
19
- - [Installation](#-installation)
20
- - [Getting Started](#-getting-started)
21
- - [Cheat Sheet](#-cheat-sheet)
22
- - [Template System](#-template-system)
23
- - [Commands](#-commands)
24
- - [Common Workflows](#-common-workflows)
25
- - [Configuration](#%EF%B8%8F-configuration)
26
- - [Programmatic API](#-programmatic-api)
27
- - [FAQ](#-faq)
28
- - [Contributing](#-contributing)
29
- - [License](#-license)
30
-
31
- ---
32
-
33
- ## 🎬 Quick Demo
34
-
35
- **Without preguito:**
36
-
37
- ```bash
38
- git add -A && git commit -m "[PAYMENTS-42] feat(prd): add login endpoint" && git push
39
- ```
40
-
41
- **With preguito:**
42
-
43
- ```bash
44
- guito c 42 fp "add login endpoint" -p
45
- # → Committing: [PAYMENTS-42] feat(prd): add login endpoint
46
- # ✔ Committed.
47
- # ⠋ Pushing...
48
- # ✔ Pushed.
49
- ```
50
-
51
- `42` is the card ID, `f` = feat, `p` = prd — everything else comes from your config.
52
-
53
- ---
54
-
55
- ## 📦 Installation
56
-
57
- ### npm (requires Node.js >= 20)
58
-
59
- ```bash
60
- npm install -g preguito
61
- ```
62
-
63
- ### Standalone binary (.deb)
64
-
65
- Download the `.deb` from [GitHub Releases](https://github.com/jacodoisdois/preguito/releases) and install:
66
-
67
- ```bash
68
- sudo dpkg -i preguito_0.1.0_amd64.deb
69
- ```
70
-
71
- No Node.js required — the binary bundles everything via Node.js SEA.
72
-
73
- ---
74
-
75
- ## 🚀 Getting Started
76
-
77
- ### 1. Run the setup wizard
78
-
79
- ```bash
80
- guito i
81
- ```
82
-
83
- The wizard walks you through picking features, shortcodes, and creating your config:
84
-
85
- ```
86
- ✨ Welcome to preguito setup!
87
-
88
- 📋 Choose which features to enable:
89
-
90
- 🎫 Include card/ticket ID in commits? (y/n): y
91
- 🏷️ Include commit type (feat, fix, chore...)? (y/n): y
92
- 🌍 Include environment (prd, uat, dev...)? (y/n): y
93
-
94
- 🔤 Project prefix/sigla (e.g. PROJ): PAYMENTS
95
-
96
- ─────────────────────────────────────
97
- ✅ Setup complete!
98
-
99
- 📄 Config saved to /home/you/.config/preguito/config.json
100
- 📝 Template: [PAYMENTS-{{card_id}}] {{type}}({{environment}}): <message>
101
-
102
- 🔑 Your shortcodes:
103
- Types: f=feat, x=fix, c=chore, t=test, r=refactor, d=docs
104
- Envs: p=prd, u=uat, d=dev, s=stg, l=local
105
- ─────────────────────────────────────
106
- ```
107
-
108
- Or skip the wizard and use the default template:
109
-
110
- ```bash
111
- guito i --default
112
- # ✅ Config written to ~/.config/preguito/config.json
113
- # Template: {{type}}: <message> (type defaults to feat)
114
- ```
115
-
116
- ### 2. Make your first commit
117
-
118
- ```bash
119
- guito c 42 f "add login endpoint"
120
- # → Committing: [PAYMENTS-42] feat: add login endpoint
121
- # ✔ Committed.
122
- ```
123
-
124
- With environment shortcode:
125
-
126
- ```bash
127
- guito c 42 fp "add login endpoint"
128
- # f = feat, p = prd
129
- # → Committing: [PAYMENTS-42] feat(prd): add login endpoint
130
- # ✔ Committed.
131
- ```
132
-
133
- Commit and push in one go:
134
-
135
- ```bash
136
- guito c 42 f "add login endpoint" -p
137
- # → Committing: [PAYMENTS-42] feat: add login endpoint
138
- # ✔ Committed.
139
- # ⠋ Pushing...
140
- # ✔ Pushed.
141
- ```
142
-
143
- Preview without committing:
144
-
145
- ```bash
146
- guito c 42 f "test message" -d
147
- # [PAYMENTS-42] feat: test message
148
- ```
149
-
150
- ---
151
-
152
- ## 📋 Cheat Sheet
153
-
154
- ### Commits
155
-
156
- ```bash
157
- guito c 42 f "message" # Templated commit
158
- guito c 42 fp "message" # With type + environment
159
- guito c 42 f "message" -p # Commit + push
160
- guito c 42 f "message" -f # Commit + force push (lease)
161
- guito c 42 f "message" -d # Dry run (preview only)
162
- guito c 42 f "message" -S # Skip auto-staging
163
- ```
164
-
165
- ### Fixup
166
-
167
- ```bash
168
- guito cf abc123 # Fixup commit for abc123
169
- guito cf abc123 -f # Fixup + force push (lease)
170
- ```
171
-
172
- ### Amend & Undo
173
-
174
- ```bash
175
- guito ap # Amend + force push
176
- guito apl # Amend + force push (lease)
177
- guito u # Undo last commit (soft reset)
178
- guito u 3 # Undo last 3 commits
179
- ```
180
-
181
- ### Branches & Stash
182
-
183
- ```bash
184
- guito sw main # Switch branch
185
- guito sw -n feature/login # Create + switch
186
- guito st # Stash changes
187
- guito stp # Stash pop
188
- ```
189
-
190
- ### Rebase
191
-
192
- ```bash
193
- guito r main # Quick rebase on main
194
- guito ri 3 # Interactive rebase last 3
195
- guito re abc123 # Edit rebase at commit
196
- ```
197
-
198
- ### Push
199
-
200
- ```bash
201
- guito p # Simple push (git push)
202
- guito pu # Push + set upstream
203
- ```
204
-
205
- ### Inspect
206
-
207
- ```bash
208
- guito s # Short status
209
- guito l # Last 10 commits
210
- guito l 20 # Last 20 commits
211
- guito f "login" # Search commits by message
212
- guito t v1.0.0 # Commits since tag
213
- guito t v1.0.0 -a # All commits reachable from tag
214
- ```
215
-
216
- ### Config
217
-
218
- ```bash
219
- guito i # Setup wizard
220
- guito i --default # Use default config
221
- guito cfg # View current config
222
- guito cfg --path # Show config file path
223
- guito cfg --template # Show template only
224
- ```
225
-
226
- ---
227
-
228
- ## 🔤 Template System
229
-
230
- Templates use `{{variable}}` for named parameters and `<placeholder>` for the commit message body.
231
-
232
- ```
233
- [{{prefix}}-{{card_id}}] {{type}}({{environment}}): <message>
234
- ```
235
-
236
- Variables are resolved from **shortcodes** first, then **config defaults**:
237
-
238
- ```bash
239
- guito c 42 fp "add login"
240
- # 42 → card_id
241
- # f → type = feat
242
- # p → environment = prd
243
- # "add..." → message
244
- # → [PAYMENTS-42] feat(prd): add login
245
- ```
246
-
247
- Shortcodes are single letters you define during `guito i` setup:
248
-
249
- | Letter | Type | Letter | Environment |
250
- |--------|------|--------|-------------|
251
- | `f` | feat | `p` | prd |
252
- | `x` | fix | `u` | uat |
253
- | `c` | chore | `d` | dev |
254
- | `t` | test | `s` | stg |
255
- | `r` | refactor | `l` | local |
256
- | `d` | docs | | |
257
-
258
- See [template-system.md](docs/template-system.md) for full syntax, resolution order, and more examples.
259
-
260
- ---
261
-
262
- ## 🔧 Commands
263
-
264
- | Command | Alias | Description |
265
- |---------|-------|-------------|
266
- | `guito c [id] [codes] "msg"` | `commit` | Templated commit with auto-stage |
267
- | `guito cf <hash>` | — | Create a fixup commit |
268
- | `guito ap` | — | Amend + force push |
269
- | `guito apl` | — | Amend + force push with lease |
270
- | `guito u [count]` | `undo` | Undo last N commits (soft reset) |
271
- | `guito p` | `push` | Simple push (git push) |
272
- | `guito pu` | — | Push with --set-upstream |
273
- | `guito r <branch>` | `rebase` | Quick rebase on branch |
274
- | `guito re <hash>` | — | Edit rebase at commit |
275
- | `guito ri <count>` | — | Interactive rebase last N commits |
276
- | `guito sw <branch>` | `switch` | Switch/create branch (`-n` to create) |
277
- | `guito st` | — | Stash changes |
278
- | `guito stp` | — | Pop latest stash |
279
- | `guito s` | `status` | Short status |
280
- | `guito l [count]` | `log` | Compact log (default: 10) |
281
- | `guito f <keyword>` | `find` | Search commits by message |
282
- | `guito t <tag>` | `tag` | Commits since/from a tag |
283
- | `guito i` | `init` | Setup wizard |
284
- | `guito cfg` | `config` | View configuration |
285
-
286
- See the [full command reference](docs/README.md) for detailed usage, flags, and examples.
287
-
288
- ---
289
-
290
- ## 🔄 Common Workflows
291
-
292
- ### Start a new feature
293
-
294
- ```bash
295
- guito sw -n feature/login # Create branch
296
- # ... make changes ...
297
- guito c 42 f "add login" -p # Commit + push
298
- ```
299
-
300
- ### Quick fix on current branch
301
-
302
- ```bash
303
- # ... fix the bug ...
304
- guito c 99 x "fix timeout" -p # x = fix, push immediately
305
- ```
306
-
307
- ### Oops, need to change the last commit
308
-
309
- ```bash
310
- # ... make more changes ...
311
- guito apl # Amend + force push (safe)
312
- ```
313
-
314
- ### Rebase before opening a PR
315
-
316
- ```bash
317
- guito r main # Pull main, rebase on top
318
- guito pu # Push with upstream
319
- ```
320
-
321
- ### Clean up commit history
322
-
323
- ```bash
324
- guito ri 5 # Interactive rebase last 5 commits
325
- # or create fixup commits:
326
- guito cf abc123 -f # Fixup + force push
327
- ```
328
-
329
- ---
330
-
331
- ## ⚙️ Configuration
332
-
333
- ### Config File Locations
334
-
335
- preguito searches for config files in this order:
336
-
337
- 1. `.preguitorc` (project root)
338
- 2. `.preguitorc.json` (project root)
339
- 3. `~/.preguitorc`
340
- 4. `~/.preguitorc.json`
341
- 5. `~/.config/preguito/config.json`
342
- 6. Built-in default: `{{type}}: <message>` with `type=feat`
343
-
344
- Project-local configs take priority, so different repos can use different templates.
345
-
346
- ### Config Schema
347
-
348
- ```json
349
- {
350
- "template": "[PAYMENTS-{{card_id}}] {{type}}({{environment}}): <message>",
351
- "features": {
352
- "cardId": true,
353
- "type": true,
354
- "environment": true
355
- },
356
- "types": [
357
- { "key": "f", "label": "feat" },
358
- { "key": "x", "label": "fix" }
359
- ],
360
- "environments": [
361
- { "key": "p", "label": "prd" },
362
- { "key": "u", "label": "uat" }
363
- ],
364
- "defaults": {
365
- "prefix": "PAYMENTS"
366
- }
367
- }
368
- ```
369
-
370
- ### Per-Project Config
371
-
372
- Place a `.preguitorc` or `.preguitorc.json` at your project root to share a commit convention with your team:
373
-
374
- ```json
375
- {
376
- "template": "[CHECKOUT-{{card_id}}] {{type}}: <message>",
377
- "features": { "cardId": true, "type": true, "environment": false },
378
- "types": [
379
- { "key": "f", "label": "feat" },
380
- { "key": "x", "label": "fix" },
381
- { "key": "c", "label": "chore" }
382
- ],
383
- "environments": [],
384
- "defaults": { "prefix": "CHECKOUT" }
385
- }
386
- ```
387
-
388
- The global config at `~/.config/preguito/config.json` serves as your personal fallback.
389
-
390
- ---
391
-
392
- ## 📚 Programmatic API
393
-
394
- preguito exports its core functions for use in other tools:
395
-
396
- ```typescript
397
- import {
398
- parseTemplate,
399
- renderTemplate,
400
- mergeContext,
401
- loadConfig,
402
- loadConfigOrDefault,
403
- writeConfig,
404
- } from "preguito";
405
-
406
- const parsed = parseTemplate("[{{squad}}] {{type}}: <message>");
407
- // { variables: ["squad", "type"], messagePlaceholder: "message" }
408
-
409
- const context = mergeContext({ type: "feat" }, { type: "fix" });
410
- // { type: "fix" }
411
-
412
- const msg = renderTemplate(
413
- "[{{squad}}] {{type}}: <message>",
414
- { squad: "TEAM", type: "fix" },
415
- "resolve timeout"
416
- );
417
- // "[TEAM] fix: resolve timeout"
418
- ```
419
-
420
- ---
421
-
422
- ## ❓ FAQ
423
-
424
- **Can I use preguito without running `guito i` first?**
425
- Yes. Without a config, preguito uses the built-in default template `{{type}}: <message>` with `type=feat`. Just run `guito c f "your message"`.
426
-
427
- **Can my team share a config?**
428
- Yes. Place a `.preguitorc` or `.preguitorc.json` in your project root and commit it. Everyone on the team will use the same template and shortcodes.
429
-
430
- **Does it work without Node.js?**
431
- Yes. Download the standalone `.deb` binary from GitHub Releases — it bundles everything via Node.js SEA.
432
-
433
- **What if I need different templates per project?**
434
- Project-local config (`.preguitorc` in repo root) takes priority over global config. Each repo can have its own template, types, and environments.
435
-
436
- **Can I customize the shortcode letters?**
437
- Yes. During `guito i` setup, you can reassign any letter to any type or environment. Run `guito i` again to reconfigure.
438
-
439
- ---
440
-
441
- ## 🤝 Contributing
442
-
443
- ```bash
444
- git clone https://github.com/jacodoisdois/preguito.git
445
- cd preguito
446
- npm install
447
- ```
448
-
449
- | Script | Description |
450
- |--------|-------------|
451
- | `npm run dev` | Watch mode (tsdown) |
452
- | `npm test` | Run tests (vitest) |
453
- | `npm run lint` | Type check (tsc --noEmit) |
454
- | `npm run build` | Production build |
455
- | `npm run build:sea` | Build standalone binary (Node.js SEA) |
456
- | `npm run build:deb` | Build .deb package |
457
-
458
- **Tech stack:** TypeScript, Commander.js, tsdown (Rolldown-based bundler), Vitest.
459
-
460
- ---
461
-
462
- ## 📄 License
463
-
464
- MIT