@snelusha/noto 1.0.6 → 1.0.8
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 +8 -0
- package/dist/index.js +53 -16
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -90,6 +90,14 @@ Retrieve the previously generated commit message:
|
|
|
90
90
|
noto prev
|
|
91
91
|
```
|
|
92
92
|
|
|
93
|
+
Amend the previously generated commit message:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
noto prev --amend --edit # or simply: noto prev --amend -e
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
> Note: When using the `--amend` flag with the noto prev command, the `--edit` (`-e`) flag is also required. This combination will allow you to modify (amend) the previous commit message before applying it.
|
|
100
|
+
|
|
93
101
|
Note: All of the flags shown above (`--apply`, `--copy`, `--type`, `--edit`) can also be used with the `noto prev` command to work with the previously generated commit message.
|
|
94
102
|
|
|
95
103
|
## Pro Tips
|
package/dist/index.js
CHANGED
|
@@ -176,21 +176,30 @@ var isFirstCommit = async () => {
|
|
|
176
176
|
};
|
|
177
177
|
var getStagedDiff = async () => {
|
|
178
178
|
try {
|
|
179
|
-
return git.diff(["--cached"]);
|
|
179
|
+
return git.diff(["--cached", "--", ":!*.lock"]);
|
|
180
180
|
} catch {
|
|
181
181
|
return null;
|
|
182
182
|
}
|
|
183
183
|
};
|
|
184
|
-
var commit = async (message) => {
|
|
184
|
+
var commit = async (message, amend) => {
|
|
185
185
|
try {
|
|
186
|
+
const options = amend ? { "--amend": null } : void 0;
|
|
186
187
|
const {
|
|
187
188
|
summary: { changes }
|
|
188
|
-
} = await git.commit(message);
|
|
189
|
+
} = await git.commit(message, void 0, options);
|
|
189
190
|
return Boolean(changes);
|
|
190
191
|
} catch {
|
|
191
192
|
return false;
|
|
192
193
|
}
|
|
193
194
|
};
|
|
195
|
+
var push = async () => {
|
|
196
|
+
try {
|
|
197
|
+
const result = await git.push();
|
|
198
|
+
return result.update || result.pushed && result.pushed.length > 0;
|
|
199
|
+
} catch {
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
};
|
|
194
203
|
|
|
195
204
|
// src/middleware/git.ts
|
|
196
205
|
var withRepository = (fn, options = { enabled: true }) => {
|
|
@@ -199,20 +208,22 @@ var withRepository = (fn, options = { enabled: true }) => {
|
|
|
199
208
|
if (!isRepo && options.enabled) {
|
|
200
209
|
p2.log.error(
|
|
201
210
|
dedent2`${color2.red("no git repository found in cwd.")}
|
|
202
|
-
|
|
211
|
+
${color2.dim(`run ${color2.cyan("`git init`")} to initialize a new repository.`)}`
|
|
203
212
|
);
|
|
204
213
|
return await exit(1);
|
|
205
214
|
}
|
|
206
215
|
opts.isRepo = isRepo;
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
216
|
+
if (isRepo) {
|
|
217
|
+
const diff = await getStagedDiff();
|
|
218
|
+
if (!diff && options.enabled) {
|
|
219
|
+
p2.log.error(
|
|
220
|
+
dedent2`${color2.red("no staged changes found.")}
|
|
221
|
+
${color2.dim(`run ${color2.cyan("`git add <file>`")} or ${color2.cyan("`git add .`")} to stage changes.`)}`
|
|
222
|
+
);
|
|
223
|
+
return await exit(1);
|
|
224
|
+
}
|
|
225
|
+
opts.diff = diff;
|
|
214
226
|
}
|
|
215
|
-
opts.diff = diff;
|
|
216
227
|
return fn(opts);
|
|
217
228
|
};
|
|
218
229
|
};
|
|
@@ -352,6 +363,12 @@ var command = {
|
|
|
352
363
|
alias: "-a",
|
|
353
364
|
description: "commit the generated message directly"
|
|
354
365
|
},
|
|
366
|
+
{
|
|
367
|
+
type: Boolean,
|
|
368
|
+
flag: "--push",
|
|
369
|
+
alias: "-p",
|
|
370
|
+
description: "commit and push the changes"
|
|
371
|
+
},
|
|
355
372
|
{
|
|
356
373
|
type: Boolean,
|
|
357
374
|
flag: "--edit",
|
|
@@ -416,6 +433,14 @@ var command = {
|
|
|
416
433
|
p3.log.error(color3.red("failed to commit changes"));
|
|
417
434
|
}
|
|
418
435
|
}
|
|
436
|
+
if (options["--push"]) {
|
|
437
|
+
const success = await push();
|
|
438
|
+
if (success) {
|
|
439
|
+
p3.log.step(color3.dim("push successful"));
|
|
440
|
+
} else {
|
|
441
|
+
p3.log.error(color3.red("failed to push changes"));
|
|
442
|
+
}
|
|
443
|
+
}
|
|
419
444
|
return await exit(0);
|
|
420
445
|
} catch {
|
|
421
446
|
spin.stop(color3.red("failed to generate commit message"), 1);
|
|
@@ -453,6 +478,11 @@ var command2 = {
|
|
|
453
478
|
flag: "--edit",
|
|
454
479
|
alias: "-e",
|
|
455
480
|
description: "edit the last generated commit message"
|
|
481
|
+
},
|
|
482
|
+
{
|
|
483
|
+
type: Boolean,
|
|
484
|
+
flag: "--amend",
|
|
485
|
+
description: "amend the last commit with the last generated message"
|
|
456
486
|
}
|
|
457
487
|
],
|
|
458
488
|
execute: withAuth(
|
|
@@ -464,6 +494,13 @@ var command2 = {
|
|
|
464
494
|
return await exit(1);
|
|
465
495
|
}
|
|
466
496
|
const isEditMode = options["--edit"];
|
|
497
|
+
const isAmend = options["--amend"];
|
|
498
|
+
if (isAmend && !isEditMode) {
|
|
499
|
+
p4.log.error(
|
|
500
|
+
color4.red("the --amend option requires the --edit option")
|
|
501
|
+
);
|
|
502
|
+
return await exit(1);
|
|
503
|
+
}
|
|
467
504
|
p4.log.step(
|
|
468
505
|
isEditMode ? color4.white(lastGeneratedMessage) : color4.green(lastGeneratedMessage)
|
|
469
506
|
);
|
|
@@ -490,7 +527,7 @@ var command2 = {
|
|
|
490
527
|
color4.dim("copied last generated commit message to clipboard")
|
|
491
528
|
);
|
|
492
529
|
}
|
|
493
|
-
if (options["--apply"]) {
|
|
530
|
+
if (options["--apply"] || isAmend) {
|
|
494
531
|
if (!options.isRepo) {
|
|
495
532
|
p4.log.error(
|
|
496
533
|
dedent4`${color4.red("no git repository found in cwd.")}
|
|
@@ -498,14 +535,14 @@ var command2 = {
|
|
|
498
535
|
);
|
|
499
536
|
return await exit(1);
|
|
500
537
|
}
|
|
501
|
-
if (!options.diff) {
|
|
538
|
+
if (!options.diff && !isAmend) {
|
|
502
539
|
p4.log.error(
|
|
503
540
|
dedent4`${color4.red("no staged changes found.")}
|
|
504
541
|
${color4.dim(`run ${color4.cyan("`git add <file>`")} or ${color4.cyan("`git add .`")} to stage changes.`)}`
|
|
505
542
|
);
|
|
506
543
|
return await exit(1);
|
|
507
544
|
}
|
|
508
|
-
const success = await commit(lastGeneratedMessage);
|
|
545
|
+
const success = await commit(lastGeneratedMessage, isAmend);
|
|
509
546
|
if (success) {
|
|
510
547
|
p4.log.step(color4.dim("commit successful"));
|
|
511
548
|
} else {
|
|
@@ -685,7 +722,7 @@ var listCommand = () => {
|
|
|
685
722
|
};
|
|
686
723
|
|
|
687
724
|
// package.json
|
|
688
|
-
var version = "1.0.
|
|
725
|
+
var version = "1.0.8";
|
|
689
726
|
|
|
690
727
|
// src/index.ts
|
|
691
728
|
var globalSpec = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@snelusha/noto",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "Generate clean commit messages in a snap! ✨",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"homepage": "https://noto.snelusha.dev",
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
|
-
"url": "
|
|
15
|
+
"url": "https://github.com/snelusha/noto.git",
|
|
16
16
|
"directory": "packages/cli"
|
|
17
17
|
},
|
|
18
18
|
"bugs": {
|
|
@@ -42,21 +42,21 @@
|
|
|
42
42
|
"cli"
|
|
43
43
|
],
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@types/node": "^22.
|
|
45
|
+
"@types/node": "^22.14.0",
|
|
46
46
|
"tsup": "^8.4.0",
|
|
47
|
-
"typescript": "^5.8.
|
|
47
|
+
"typescript": "^5.8.3",
|
|
48
|
+
"vitest": "^3.1.1"
|
|
48
49
|
},
|
|
49
50
|
"dependencies": {
|
|
50
|
-
"@ai-sdk/google": "^1.2.
|
|
51
|
+
"@ai-sdk/google": "^1.2.7",
|
|
51
52
|
"@clack/prompts": "^0.10.0",
|
|
52
|
-
"ai": "^4.2
|
|
53
|
+
"ai": "^4.3.2",
|
|
53
54
|
"arg": "^5.0.2",
|
|
54
55
|
"clipboardy": "^4.0.0",
|
|
55
56
|
"dedent": "^1.5.3",
|
|
56
57
|
"picocolors": "^1.1.1",
|
|
57
58
|
"simple-git": "^3.27.0",
|
|
58
59
|
"tinyexec": "^0.3.2",
|
|
59
|
-
"vitest": "^3.0.9",
|
|
60
60
|
"zod": "^3.24.2"
|
|
61
61
|
}
|
|
62
62
|
}
|