@snelusha/noto 1.2.4 → 1.2.6

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.
Files changed (2) hide show
  1. package/dist/index.js +56 -2
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -220,7 +220,15 @@ var getBranches = async (remote) => {
220
220
  };
221
221
  var checkout = async (branch) => {
222
222
  try {
223
- await git.checkout(branch);
223
+ await git.checkout(branch, {});
224
+ return true;
225
+ } catch {
226
+ return false;
227
+ }
228
+ };
229
+ var checkoutLocalBranch = async (branch) => {
230
+ try {
231
+ await git.checkoutLocalBranch(branch);
224
232
  return true;
225
233
  } catch {
226
234
  return false;
@@ -822,10 +830,17 @@ var command4 = {
822
830
  flag: "--copy",
823
831
  alias: "-c",
824
832
  description: "copy the selected branch to clipboard"
833
+ },
834
+ {
835
+ type: Boolean,
836
+ flag: "--create",
837
+ alias: "-b",
838
+ description: "create a new branch"
825
839
  }
826
840
  ],
827
841
  execute: withRepository(
828
842
  async (options) => {
843
+ const args = options._.slice(1);
829
844
  if (!options.isRepo) {
830
845
  p6.log.error(
831
846
  dedent6`${color6.red("no git repository found in cwd.")}
@@ -839,6 +854,45 @@ var command4 = {
839
854
  return await exit(1);
840
855
  }
841
856
  const currentBranch = await getCurrentBranch();
857
+ const branchName = args[0];
858
+ if (options["--create"]) {
859
+ if (branches.includes(branchName)) {
860
+ p6.log.error(
861
+ `branch ${color6.red(branchName)} already exists in the repository`
862
+ );
863
+ return await exit(1);
864
+ }
865
+ const result2 = await checkoutLocalBranch(branchName);
866
+ if (!result2) {
867
+ p6.log.error(
868
+ `failed to create and checkout ${color6.bold(branchName)}`
869
+ );
870
+ return await exit(1);
871
+ }
872
+ p6.log.success(`created and checked out ${color6.green(branchName)}`);
873
+ return await exit(0);
874
+ }
875
+ if (branchName) {
876
+ if (!branches.includes(branchName)) {
877
+ p6.log.error(
878
+ `branch ${color6.red(branchName)} does not exist in the repository`
879
+ );
880
+ return await exit(1);
881
+ }
882
+ if (branchName === currentBranch) {
883
+ p6.log.error(
884
+ `${color6.red("already on branch")} ${color6.green(branchName)}`
885
+ );
886
+ return await exit(1);
887
+ }
888
+ const result2 = await checkout(branchName);
889
+ if (!result2) {
890
+ p6.log.error(`failed to checkout ${color6.bold(branchName)}`);
891
+ return await exit(1);
892
+ }
893
+ p6.log.success(`checked out ${color6.green(branchName)}`);
894
+ return await exit(0);
895
+ }
842
896
  const branch = await p6.select({
843
897
  message: "select a branch to checkout",
844
898
  options: branches.map((branch2) => ({
@@ -1045,7 +1099,7 @@ var listCommand = () => {
1045
1099
  };
1046
1100
 
1047
1101
  // package.json
1048
- var version = "1.2.4";
1102
+ var version = "1.2.6";
1049
1103
 
1050
1104
  // src/index.ts
1051
1105
  var globalSpec = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snelusha/noto",
3
- "version": "1.2.4",
3
+ "version": "1.2.6",
4
4
  "description": "Generate clean commit messages in a snap! ✨",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -41,13 +41,13 @@
41
41
  "cli"
42
42
  ],
43
43
  "devDependencies": {
44
- "@types/node": "^22.15.19",
44
+ "@types/node": "^22.15.23",
45
45
  "tsup": "^8.5.0",
46
46
  "typescript": "^5.8.3",
47
- "vitest": "^3.1.4"
47
+ "vitest": "^3.2.0"
48
48
  },
49
49
  "dependencies": {
50
- "@ai-sdk/google": "^1.2.18",
50
+ "@ai-sdk/google": "^1.2.19",
51
51
  "@clack/prompts": "^0.10.1",
52
52
  "ai": "^4.3.16",
53
53
  "arg": "^5.0.2",
@@ -56,6 +56,6 @@
56
56
  "picocolors": "^1.1.1",
57
57
  "simple-git": "^3.27.0",
58
58
  "tinyexec": "^0.3.2",
59
- "zod": "^3.25.3"
59
+ "zod": "^3.25.49"
60
60
  }
61
61
  }