@snelusha/noto 1.0.8 → 1.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 +7 -0
- package/dist/index.js +129 -44
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -100,6 +100,13 @@ 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
|
+
|
|
103
110
|
## Pro Tips
|
|
104
111
|
|
|
105
112
|
- 🚀 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,32 @@ 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 () => {
|
|
212
|
+
try {
|
|
213
|
+
const branches = await git.branch();
|
|
214
|
+
return Object.keys(branches.branches).filter(
|
|
215
|
+
(b) => !b.startsWith("remotes/")
|
|
216
|
+
);
|
|
217
|
+
} catch {
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
var checkout = async (branch) => {
|
|
222
|
+
try {
|
|
223
|
+
await git.checkout(branch);
|
|
224
|
+
return true;
|
|
225
|
+
} catch {
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
};
|
|
203
229
|
|
|
204
230
|
// src/middleware/git.ts
|
|
205
231
|
var withRepository = (fn, options = { enabled: true }) => {
|
|
@@ -557,30 +583,89 @@ var command2 = {
|
|
|
557
583
|
};
|
|
558
584
|
var prev_default = command2;
|
|
559
585
|
|
|
560
|
-
// src/commands/
|
|
586
|
+
// src/commands/checkout.ts
|
|
561
587
|
import * as p5 from "@clack/prompts";
|
|
562
588
|
import color5 from "picocolors";
|
|
589
|
+
import dedent5 from "dedent";
|
|
590
|
+
var command3 = {
|
|
591
|
+
name: "checkout",
|
|
592
|
+
description: "checkout a branch",
|
|
593
|
+
usage: "checkout [options]",
|
|
594
|
+
execute: withRepository(
|
|
595
|
+
async (options) => {
|
|
596
|
+
if (!options.isRepo) {
|
|
597
|
+
p5.log.error(
|
|
598
|
+
dedent5`${color5.red("no git repository found in cwd.")}
|
|
599
|
+
${color5.dim(`run ${color5.cyan("`git init`")} to initialize a new repository.`)}`
|
|
600
|
+
);
|
|
601
|
+
return await exit(1);
|
|
602
|
+
}
|
|
603
|
+
const branches = await getBranches();
|
|
604
|
+
if (!branches) {
|
|
605
|
+
p5.log.error("failed to fetch branches");
|
|
606
|
+
return await exit(1);
|
|
607
|
+
}
|
|
608
|
+
const currentBranch = await getCurrentBranch();
|
|
609
|
+
const branch = await p5.select({
|
|
610
|
+
message: "select a branch to checkout",
|
|
611
|
+
options: branches.map((branch2) => ({
|
|
612
|
+
value: branch2,
|
|
613
|
+
label: color5.bold(
|
|
614
|
+
branch2 === currentBranch ? color5.green(branch2) : branch2
|
|
615
|
+
),
|
|
616
|
+
hint: branch2 === currentBranch ? "current branch" : void 0
|
|
617
|
+
})),
|
|
618
|
+
initialValue: currentBranch
|
|
619
|
+
});
|
|
620
|
+
if (p5.isCancel(branch)) {
|
|
621
|
+
p5.log.error("nothing selected!");
|
|
622
|
+
return await exit(1);
|
|
623
|
+
}
|
|
624
|
+
if (!branch) {
|
|
625
|
+
p5.log.error("no branch selected");
|
|
626
|
+
return await exit(1);
|
|
627
|
+
}
|
|
628
|
+
if (branch === currentBranch) {
|
|
629
|
+
p5.log.error(`${color5.red("already on branch")}`);
|
|
630
|
+
return await exit(1);
|
|
631
|
+
}
|
|
632
|
+
const result = await checkout(branch);
|
|
633
|
+
if (!result) {
|
|
634
|
+
p5.log.error(`failed to checkout ${color5.bold(branch)}`);
|
|
635
|
+
return await exit(1);
|
|
636
|
+
}
|
|
637
|
+
p5.log.success(`checked out ${color5.green(branch)}`);
|
|
638
|
+
await exit(0);
|
|
639
|
+
},
|
|
640
|
+
{ enabled: false }
|
|
641
|
+
)
|
|
642
|
+
};
|
|
643
|
+
var checkout_default = command3;
|
|
644
|
+
|
|
645
|
+
// src/commands/config.ts
|
|
646
|
+
import * as p6 from "@clack/prompts";
|
|
647
|
+
import color6 from "picocolors";
|
|
563
648
|
var key = {
|
|
564
649
|
name: "key",
|
|
565
650
|
description: "configure api key",
|
|
566
651
|
usage: "noto config key [options]",
|
|
567
652
|
execute: async (options) => {
|
|
568
653
|
if ((await StorageManager.get()).llm?.apiKey) {
|
|
569
|
-
const confirm2 = await
|
|
654
|
+
const confirm2 = await p6.confirm({
|
|
570
655
|
message: "noto api key already configured, do you want to update it?"
|
|
571
656
|
});
|
|
572
|
-
if (
|
|
573
|
-
|
|
657
|
+
if (p6.isCancel(confirm2) || !confirm2) {
|
|
658
|
+
p6.log.error(color6.red("nothing changed!"));
|
|
574
659
|
return await exit(1);
|
|
575
660
|
}
|
|
576
661
|
}
|
|
577
662
|
let apiKey = options._[0];
|
|
578
663
|
if (!apiKey) {
|
|
579
|
-
const result = await
|
|
664
|
+
const result = await p6.text({
|
|
580
665
|
message: "enter your noto api key"
|
|
581
666
|
});
|
|
582
|
-
if (
|
|
583
|
-
|
|
667
|
+
if (p6.isCancel(result)) {
|
|
668
|
+
p6.log.error(color6.red("nothing changed!"));
|
|
584
669
|
return await exit(1);
|
|
585
670
|
}
|
|
586
671
|
apiKey = result;
|
|
@@ -592,7 +677,7 @@ var key = {
|
|
|
592
677
|
apiKey
|
|
593
678
|
}
|
|
594
679
|
}));
|
|
595
|
-
|
|
680
|
+
p6.log.success(color6.green("noto api key configured!"));
|
|
596
681
|
console.log();
|
|
597
682
|
}
|
|
598
683
|
};
|
|
@@ -601,7 +686,7 @@ var model = {
|
|
|
601
686
|
description: "configure model",
|
|
602
687
|
usage: "noto config model [options]",
|
|
603
688
|
execute: async (options) => {
|
|
604
|
-
const model2 = await
|
|
689
|
+
const model2 = await p6.select({
|
|
605
690
|
message: "select a model",
|
|
606
691
|
initialValue: (await StorageManager.get()).llm?.model,
|
|
607
692
|
options: Object.keys(models).map((model3) => ({
|
|
@@ -609,16 +694,16 @@ var model = {
|
|
|
609
694
|
value: model3
|
|
610
695
|
}))
|
|
611
696
|
});
|
|
612
|
-
if (
|
|
613
|
-
|
|
697
|
+
if (p6.isCancel(model2)) {
|
|
698
|
+
p6.log.error(color6.red("nothing changed!"));
|
|
614
699
|
return await exit(1);
|
|
615
700
|
}
|
|
616
701
|
if (model2 === "gemini-2.5-pro-exp-03-25") {
|
|
617
|
-
const confirm2 = await
|
|
702
|
+
const confirm2 = await p6.confirm({
|
|
618
703
|
message: "this model has a rate limit of 5 RPM (requests per minute) 50 requests per day, do you want to continue?"
|
|
619
704
|
});
|
|
620
|
-
if (
|
|
621
|
-
|
|
705
|
+
if (p6.isCancel(confirm2) || !confirm2) {
|
|
706
|
+
p6.log.error(color6.red("nothing changed!"));
|
|
622
707
|
return await exit(1);
|
|
623
708
|
}
|
|
624
709
|
}
|
|
@@ -629,7 +714,7 @@ var model = {
|
|
|
629
714
|
model: model2
|
|
630
715
|
}
|
|
631
716
|
}));
|
|
632
|
-
|
|
717
|
+
p6.log.success(color6.green("model configured!"));
|
|
633
718
|
console.log();
|
|
634
719
|
}
|
|
635
720
|
};
|
|
@@ -638,37 +723,37 @@ var reset = {
|
|
|
638
723
|
description: "reset configuration",
|
|
639
724
|
usage: "noto config reset",
|
|
640
725
|
execute: async () => {
|
|
641
|
-
const confirm2 = await
|
|
726
|
+
const confirm2 = await p6.confirm({
|
|
642
727
|
message: "are you sure you want to reset the configuration?"
|
|
643
728
|
});
|
|
644
|
-
if (
|
|
645
|
-
|
|
729
|
+
if (p6.isCancel(confirm2) || !confirm2) {
|
|
730
|
+
p6.log.error(color6.red("nothing changed!"));
|
|
646
731
|
return await exit(1);
|
|
647
732
|
}
|
|
648
733
|
await StorageManager.clear();
|
|
649
|
-
|
|
734
|
+
p6.log.success(color6.green("configuration reset!"));
|
|
650
735
|
console.log();
|
|
651
736
|
}
|
|
652
737
|
};
|
|
653
738
|
var subCommands = [key, model, reset];
|
|
654
|
-
var
|
|
739
|
+
var command4 = {
|
|
655
740
|
name: "config",
|
|
656
741
|
description: "configure noto",
|
|
657
742
|
usage: "noto config [subcommand]",
|
|
658
743
|
execute: async (options) => {
|
|
659
|
-
const
|
|
744
|
+
const command5 = await p6.select({
|
|
660
745
|
message: "Select a subcommand",
|
|
661
746
|
options: subCommands.map((cmd2) => ({
|
|
662
747
|
label: cmd2.description,
|
|
663
748
|
value: cmd2.name
|
|
664
749
|
}))
|
|
665
750
|
});
|
|
666
|
-
if (
|
|
751
|
+
if (p6.isCancel(command5)) {
|
|
667
752
|
return await exit(1);
|
|
668
753
|
}
|
|
669
|
-
const cmd = getCommand(
|
|
754
|
+
const cmd = getCommand(command5, subCommands);
|
|
670
755
|
if (!cmd) {
|
|
671
|
-
|
|
756
|
+
p6.log.error(color6.red("unknown config command"));
|
|
672
757
|
return await exit(1);
|
|
673
758
|
}
|
|
674
759
|
options._ = options._.slice(1);
|
|
@@ -676,34 +761,34 @@ var command3 = {
|
|
|
676
761
|
},
|
|
677
762
|
subCommands
|
|
678
763
|
};
|
|
679
|
-
var config_default =
|
|
764
|
+
var config_default = command4;
|
|
680
765
|
|
|
681
766
|
// src/commands/help.ts
|
|
682
|
-
import
|
|
767
|
+
import color7 from "picocolors";
|
|
683
768
|
var help = {
|
|
684
769
|
name: "help",
|
|
685
770
|
description: "show help",
|
|
686
771
|
usage: "noto help [command]",
|
|
687
772
|
execute: async (options) => {
|
|
688
|
-
const
|
|
689
|
-
if (
|
|
773
|
+
const command5 = getCommand(options._[0]);
|
|
774
|
+
if (command5) {
|
|
690
775
|
console.log();
|
|
691
|
-
console.log(
|
|
692
|
-
console.log(` ${
|
|
776
|
+
console.log(color7.bold("Usage"));
|
|
777
|
+
console.log(` ${command5.usage}`);
|
|
693
778
|
console.log();
|
|
694
|
-
console.log(
|
|
695
|
-
console.log(` ${
|
|
779
|
+
console.log(color7.bold("Description"));
|
|
780
|
+
console.log(` ${command5.description}`);
|
|
696
781
|
console.log();
|
|
697
782
|
} else {
|
|
698
783
|
const commands2 = listCommand();
|
|
699
784
|
console.log();
|
|
700
|
-
console.log(
|
|
785
|
+
console.log(color7.bold("Usage"));
|
|
701
786
|
console.log(` noto [command] [options]`);
|
|
702
787
|
console.log();
|
|
703
|
-
console.log(
|
|
704
|
-
commands2.forEach((
|
|
788
|
+
console.log(color7.bold("Commands"));
|
|
789
|
+
commands2.forEach((command6) => {
|
|
705
790
|
console.log(
|
|
706
|
-
` ${
|
|
791
|
+
` ${color7.bold(command6.name)} ${color7.dim(command6.description)}`
|
|
707
792
|
);
|
|
708
793
|
});
|
|
709
794
|
console.log();
|
|
@@ -713,7 +798,7 @@ var help = {
|
|
|
713
798
|
var help_default = help;
|
|
714
799
|
|
|
715
800
|
// src/commands/index.ts
|
|
716
|
-
var commands = [noto_default, prev_default, config_default, help_default];
|
|
801
|
+
var commands = [noto_default, prev_default, checkout_default, config_default, help_default];
|
|
717
802
|
var getCommand = (name, cmds = commands) => {
|
|
718
803
|
return cmds.find((cmd) => cmd.name === name);
|
|
719
804
|
};
|
|
@@ -722,7 +807,7 @@ var listCommand = () => {
|
|
|
722
807
|
};
|
|
723
808
|
|
|
724
809
|
// package.json
|
|
725
|
-
var version = "1.0
|
|
810
|
+
var version = "1.1.0";
|
|
726
811
|
|
|
727
812
|
// src/index.ts
|
|
728
813
|
var globalSpec = {
|
|
@@ -733,15 +818,15 @@ var globalSpec = {
|
|
|
733
818
|
};
|
|
734
819
|
function main() {
|
|
735
820
|
const args = process.argv.slice(2);
|
|
736
|
-
const { command:
|
|
821
|
+
const { command: command5, options: globalOptions } = parse(globalSpec, args);
|
|
737
822
|
console.log();
|
|
738
|
-
|
|
739
|
-
if (globalOptions["--version"]) return
|
|
823
|
+
p7.intro(`${color8.bgCyan(color8.black(" @snelusha/noto "))}`);
|
|
824
|
+
if (globalOptions["--version"]) return p7.outro(version);
|
|
740
825
|
if (globalOptions["--help"]) {
|
|
741
826
|
getCommand("help")?.execute(globalOptions);
|
|
742
827
|
return;
|
|
743
828
|
}
|
|
744
|
-
const cmd = getCommand(
|
|
829
|
+
const cmd = getCommand(command5) ?? getCommand("noto");
|
|
745
830
|
if (!cmd) return getCommand("noto")?.execute(globalOptions);
|
|
746
831
|
let commandArgs = args;
|
|
747
832
|
let selectedCommand = cmd;
|