@snelusha/noto 1.0.8 → 1.1.1
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 +18 -0
- package/dist/index.js +153 -45
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -100,6 +100,24 @@ noto prev --amend --edit # or simply: noto prev --amend -e
|
|
|
100
100
|
|
|
101
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.
|
|
102
102
|
|
|
103
|
+
Switch between branches in you git repo with an interactive prompt:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
noto checkout
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
To copy the selected branch to your clipboard immediately after choosing it, use the new `-c` flag:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
noto checkout -c
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
To list all branches, including remote branches, use the -r flag (note: while remote branches are listed, you currently cannot checkout to remote branches):
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
noto checkout -r
|
|
119
|
+
```
|
|
120
|
+
|
|
103
121
|
## Pro Tips
|
|
104
122
|
|
|
105
123
|
- 🚀 Get fast commits on the fly with `noto -e -a` to streamline your workflow!
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
2
|
+
import * as p7 from "@clack/prompts";
|
|
3
|
+
import color8 from "picocolors";
|
|
4
4
|
|
|
5
5
|
// src/utils/parser.ts
|
|
6
6
|
import arg from "arg";
|
|
@@ -200,6 +200,30 @@ var push = async () => {
|
|
|
200
200
|
return false;
|
|
201
201
|
}
|
|
202
202
|
};
|
|
203
|
+
var getCurrentBranch = async () => {
|
|
204
|
+
try {
|
|
205
|
+
const branch = await git.branch();
|
|
206
|
+
return branch.current;
|
|
207
|
+
} catch {
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
var getBranches = async (remote) => {
|
|
212
|
+
try {
|
|
213
|
+
const branches = await git.branch();
|
|
214
|
+
return remote ? branches.all : Object.keys(branches.branches).filter((b) => !b.startsWith("remotes/"));
|
|
215
|
+
} catch {
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
var checkout = async (branch) => {
|
|
220
|
+
try {
|
|
221
|
+
await git.checkout(branch);
|
|
222
|
+
return true;
|
|
223
|
+
} catch {
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
};
|
|
203
227
|
|
|
204
228
|
// src/middleware/git.ts
|
|
205
229
|
var withRepository = (fn, options = { enabled: true }) => {
|
|
@@ -557,30 +581,114 @@ var command2 = {
|
|
|
557
581
|
};
|
|
558
582
|
var prev_default = command2;
|
|
559
583
|
|
|
560
|
-
// src/commands/
|
|
584
|
+
// src/commands/checkout.ts
|
|
561
585
|
import * as p5 from "@clack/prompts";
|
|
562
586
|
import color5 from "picocolors";
|
|
587
|
+
import clipboard3 from "clipboardy";
|
|
588
|
+
import dedent5 from "dedent";
|
|
589
|
+
var command3 = {
|
|
590
|
+
name: "checkout",
|
|
591
|
+
description: "checkout a branch",
|
|
592
|
+
usage: "checkout [options]",
|
|
593
|
+
options: [
|
|
594
|
+
{
|
|
595
|
+
type: Boolean,
|
|
596
|
+
flag: "--copy",
|
|
597
|
+
alias: "-c",
|
|
598
|
+
description: "copy the selected branch to clipboard"
|
|
599
|
+
},
|
|
600
|
+
{
|
|
601
|
+
type: Boolean,
|
|
602
|
+
flag: "--remote",
|
|
603
|
+
alias: "-r",
|
|
604
|
+
description: "list branches including remotes"
|
|
605
|
+
}
|
|
606
|
+
],
|
|
607
|
+
execute: withRepository(
|
|
608
|
+
async (options) => {
|
|
609
|
+
if (!options.isRepo) {
|
|
610
|
+
p5.log.error(
|
|
611
|
+
dedent5`${color5.red("no git repository found in cwd.")}
|
|
612
|
+
${color5.dim(`run ${color5.cyan("`git init`")} to initialize a new repository.`)}`
|
|
613
|
+
);
|
|
614
|
+
return await exit(1);
|
|
615
|
+
}
|
|
616
|
+
const remote = options["--remote"];
|
|
617
|
+
const branches = await getBranches(remote);
|
|
618
|
+
if (!branches) {
|
|
619
|
+
p5.log.error("failed to fetch branches");
|
|
620
|
+
return await exit(1);
|
|
621
|
+
}
|
|
622
|
+
const currentBranch = await getCurrentBranch();
|
|
623
|
+
const branch = await p5.select({
|
|
624
|
+
message: "select a branch to checkout",
|
|
625
|
+
options: branches.map((branch2) => ({
|
|
626
|
+
value: branch2,
|
|
627
|
+
label: color5.bold(
|
|
628
|
+
branch2 === currentBranch ? color5.green(branch2) : branch2
|
|
629
|
+
),
|
|
630
|
+
hint: branch2 === currentBranch ? "current branch" : void 0
|
|
631
|
+
})),
|
|
632
|
+
initialValue: currentBranch
|
|
633
|
+
});
|
|
634
|
+
if (p5.isCancel(branch)) {
|
|
635
|
+
p5.log.error("nothing selected!");
|
|
636
|
+
return await exit(1);
|
|
637
|
+
}
|
|
638
|
+
if (!branch) {
|
|
639
|
+
p5.log.error("no branch selected");
|
|
640
|
+
return await exit(1);
|
|
641
|
+
}
|
|
642
|
+
if (options["--copy"]) {
|
|
643
|
+
clipboard3.writeSync(branch);
|
|
644
|
+
p5.log.success(`copied ${color5.green(branch)} to clipboard`);
|
|
645
|
+
return await exit(0);
|
|
646
|
+
}
|
|
647
|
+
if (remote && branch.startsWith("remotes/")) {
|
|
648
|
+
p5.log.error(color5.red("cannot checkout remote branch"));
|
|
649
|
+
return await exit(1);
|
|
650
|
+
}
|
|
651
|
+
if (branch === currentBranch) {
|
|
652
|
+
p5.log.error(`${color5.red("already on branch")}`);
|
|
653
|
+
return await exit(1);
|
|
654
|
+
}
|
|
655
|
+
const result = await checkout(branch);
|
|
656
|
+
if (!result) {
|
|
657
|
+
p5.log.error(`failed to checkout ${color5.bold(branch)}`);
|
|
658
|
+
return await exit(1);
|
|
659
|
+
}
|
|
660
|
+
p5.log.success(`checked out ${color5.green(branch)}`);
|
|
661
|
+
await exit(0);
|
|
662
|
+
},
|
|
663
|
+
{ enabled: false }
|
|
664
|
+
)
|
|
665
|
+
};
|
|
666
|
+
var checkout_default = command3;
|
|
667
|
+
|
|
668
|
+
// src/commands/config.ts
|
|
669
|
+
import * as p6 from "@clack/prompts";
|
|
670
|
+
import color6 from "picocolors";
|
|
563
671
|
var key = {
|
|
564
672
|
name: "key",
|
|
565
673
|
description: "configure api key",
|
|
566
674
|
usage: "noto config key [options]",
|
|
567
675
|
execute: async (options) => {
|
|
568
676
|
if ((await StorageManager.get()).llm?.apiKey) {
|
|
569
|
-
const confirm2 = await
|
|
677
|
+
const confirm2 = await p6.confirm({
|
|
570
678
|
message: "noto api key already configured, do you want to update it?"
|
|
571
679
|
});
|
|
572
|
-
if (
|
|
573
|
-
|
|
680
|
+
if (p6.isCancel(confirm2) || !confirm2) {
|
|
681
|
+
p6.log.error(color6.red("nothing changed!"));
|
|
574
682
|
return await exit(1);
|
|
575
683
|
}
|
|
576
684
|
}
|
|
577
685
|
let apiKey = options._[0];
|
|
578
686
|
if (!apiKey) {
|
|
579
|
-
const result = await
|
|
687
|
+
const result = await p6.text({
|
|
580
688
|
message: "enter your noto api key"
|
|
581
689
|
});
|
|
582
|
-
if (
|
|
583
|
-
|
|
690
|
+
if (p6.isCancel(result)) {
|
|
691
|
+
p6.log.error(color6.red("nothing changed!"));
|
|
584
692
|
return await exit(1);
|
|
585
693
|
}
|
|
586
694
|
apiKey = result;
|
|
@@ -592,7 +700,7 @@ var key = {
|
|
|
592
700
|
apiKey
|
|
593
701
|
}
|
|
594
702
|
}));
|
|
595
|
-
|
|
703
|
+
p6.log.success(color6.green("noto api key configured!"));
|
|
596
704
|
console.log();
|
|
597
705
|
}
|
|
598
706
|
};
|
|
@@ -600,8 +708,8 @@ var model = {
|
|
|
600
708
|
name: "model",
|
|
601
709
|
description: "configure model",
|
|
602
710
|
usage: "noto config model [options]",
|
|
603
|
-
execute: async (
|
|
604
|
-
const model2 = await
|
|
711
|
+
execute: async () => {
|
|
712
|
+
const model2 = await p6.select({
|
|
605
713
|
message: "select a model",
|
|
606
714
|
initialValue: (await StorageManager.get()).llm?.model,
|
|
607
715
|
options: Object.keys(models).map((model3) => ({
|
|
@@ -609,16 +717,16 @@ var model = {
|
|
|
609
717
|
value: model3
|
|
610
718
|
}))
|
|
611
719
|
});
|
|
612
|
-
if (
|
|
613
|
-
|
|
720
|
+
if (p6.isCancel(model2)) {
|
|
721
|
+
p6.log.error(color6.red("nothing changed!"));
|
|
614
722
|
return await exit(1);
|
|
615
723
|
}
|
|
616
724
|
if (model2 === "gemini-2.5-pro-exp-03-25") {
|
|
617
|
-
const confirm2 = await
|
|
725
|
+
const confirm2 = await p6.confirm({
|
|
618
726
|
message: "this model has a rate limit of 5 RPM (requests per minute) 50 requests per day, do you want to continue?"
|
|
619
727
|
});
|
|
620
|
-
if (
|
|
621
|
-
|
|
728
|
+
if (p6.isCancel(confirm2) || !confirm2) {
|
|
729
|
+
p6.log.error(color6.red("nothing changed!"));
|
|
622
730
|
return await exit(1);
|
|
623
731
|
}
|
|
624
732
|
}
|
|
@@ -629,7 +737,7 @@ var model = {
|
|
|
629
737
|
model: model2
|
|
630
738
|
}
|
|
631
739
|
}));
|
|
632
|
-
|
|
740
|
+
p6.log.success(color6.green("model configured!"));
|
|
633
741
|
console.log();
|
|
634
742
|
}
|
|
635
743
|
};
|
|
@@ -638,37 +746,37 @@ var reset = {
|
|
|
638
746
|
description: "reset configuration",
|
|
639
747
|
usage: "noto config reset",
|
|
640
748
|
execute: async () => {
|
|
641
|
-
const confirm2 = await
|
|
749
|
+
const confirm2 = await p6.confirm({
|
|
642
750
|
message: "are you sure you want to reset the configuration?"
|
|
643
751
|
});
|
|
644
|
-
if (
|
|
645
|
-
|
|
752
|
+
if (p6.isCancel(confirm2) || !confirm2) {
|
|
753
|
+
p6.log.error(color6.red("nothing changed!"));
|
|
646
754
|
return await exit(1);
|
|
647
755
|
}
|
|
648
756
|
await StorageManager.clear();
|
|
649
|
-
|
|
757
|
+
p6.log.success(color6.green("configuration reset!"));
|
|
650
758
|
console.log();
|
|
651
759
|
}
|
|
652
760
|
};
|
|
653
761
|
var subCommands = [key, model, reset];
|
|
654
|
-
var
|
|
762
|
+
var command4 = {
|
|
655
763
|
name: "config",
|
|
656
764
|
description: "configure noto",
|
|
657
765
|
usage: "noto config [subcommand]",
|
|
658
766
|
execute: async (options) => {
|
|
659
|
-
const
|
|
767
|
+
const command5 = await p6.select({
|
|
660
768
|
message: "Select a subcommand",
|
|
661
769
|
options: subCommands.map((cmd2) => ({
|
|
662
770
|
label: cmd2.description,
|
|
663
771
|
value: cmd2.name
|
|
664
772
|
}))
|
|
665
773
|
});
|
|
666
|
-
if (
|
|
774
|
+
if (p6.isCancel(command5)) {
|
|
667
775
|
return await exit(1);
|
|
668
776
|
}
|
|
669
|
-
const cmd = getCommand(
|
|
777
|
+
const cmd = getCommand(command5, subCommands);
|
|
670
778
|
if (!cmd) {
|
|
671
|
-
|
|
779
|
+
p6.log.error(color6.red("unknown config command"));
|
|
672
780
|
return await exit(1);
|
|
673
781
|
}
|
|
674
782
|
options._ = options._.slice(1);
|
|
@@ -676,34 +784,34 @@ var command3 = {
|
|
|
676
784
|
},
|
|
677
785
|
subCommands
|
|
678
786
|
};
|
|
679
|
-
var config_default =
|
|
787
|
+
var config_default = command4;
|
|
680
788
|
|
|
681
789
|
// src/commands/help.ts
|
|
682
|
-
import
|
|
790
|
+
import color7 from "picocolors";
|
|
683
791
|
var help = {
|
|
684
792
|
name: "help",
|
|
685
793
|
description: "show help",
|
|
686
794
|
usage: "noto help [command]",
|
|
687
795
|
execute: async (options) => {
|
|
688
|
-
const
|
|
689
|
-
if (
|
|
796
|
+
const command5 = getCommand(options._[0]);
|
|
797
|
+
if (command5) {
|
|
690
798
|
console.log();
|
|
691
|
-
console.log(
|
|
692
|
-
console.log(` ${
|
|
799
|
+
console.log(color7.bold("Usage"));
|
|
800
|
+
console.log(` ${command5.usage}`);
|
|
693
801
|
console.log();
|
|
694
|
-
console.log(
|
|
695
|
-
console.log(` ${
|
|
802
|
+
console.log(color7.bold("Description"));
|
|
803
|
+
console.log(` ${command5.description}`);
|
|
696
804
|
console.log();
|
|
697
805
|
} else {
|
|
698
806
|
const commands2 = listCommand();
|
|
699
807
|
console.log();
|
|
700
|
-
console.log(
|
|
808
|
+
console.log(color7.bold("Usage"));
|
|
701
809
|
console.log(` noto [command] [options]`);
|
|
702
810
|
console.log();
|
|
703
|
-
console.log(
|
|
704
|
-
commands2.forEach((
|
|
811
|
+
console.log(color7.bold("Commands"));
|
|
812
|
+
commands2.forEach((command6) => {
|
|
705
813
|
console.log(
|
|
706
|
-
` ${
|
|
814
|
+
` ${color7.bold(command6.name)} ${color7.dim(command6.description)}`
|
|
707
815
|
);
|
|
708
816
|
});
|
|
709
817
|
console.log();
|
|
@@ -713,7 +821,7 @@ var help = {
|
|
|
713
821
|
var help_default = help;
|
|
714
822
|
|
|
715
823
|
// src/commands/index.ts
|
|
716
|
-
var commands = [noto_default, prev_default, config_default, help_default];
|
|
824
|
+
var commands = [noto_default, prev_default, checkout_default, config_default, help_default];
|
|
717
825
|
var getCommand = (name, cmds = commands) => {
|
|
718
826
|
return cmds.find((cmd) => cmd.name === name);
|
|
719
827
|
};
|
|
@@ -722,7 +830,7 @@ var listCommand = () => {
|
|
|
722
830
|
};
|
|
723
831
|
|
|
724
832
|
// package.json
|
|
725
|
-
var version = "1.
|
|
833
|
+
var version = "1.1.1";
|
|
726
834
|
|
|
727
835
|
// src/index.ts
|
|
728
836
|
var globalSpec = {
|
|
@@ -733,15 +841,15 @@ var globalSpec = {
|
|
|
733
841
|
};
|
|
734
842
|
function main() {
|
|
735
843
|
const args = process.argv.slice(2);
|
|
736
|
-
const { command:
|
|
844
|
+
const { command: command5, options: globalOptions } = parse(globalSpec, args);
|
|
737
845
|
console.log();
|
|
738
|
-
|
|
739
|
-
if (globalOptions["--version"]) return
|
|
846
|
+
p7.intro(`${color8.bgCyan(color8.black(" @snelusha/noto "))}`);
|
|
847
|
+
if (globalOptions["--version"]) return p7.outro(version);
|
|
740
848
|
if (globalOptions["--help"]) {
|
|
741
849
|
getCommand("help")?.execute(globalOptions);
|
|
742
850
|
return;
|
|
743
851
|
}
|
|
744
|
-
const cmd = getCommand(
|
|
852
|
+
const cmd = getCommand(command5) ?? getCommand("noto");
|
|
745
853
|
if (!cmd) return getCommand("noto")?.execute(globalOptions);
|
|
746
854
|
let commandArgs = args;
|
|
747
855
|
let selectedCommand = cmd;
|