From 9488292a23239c02061c38ca8719b1c262472b63 Mon Sep 17 00:00:00 2001 From: Igor Pnev Date: Wed, 8 May 2024 10:04:59 +0300 Subject: [PATCH] fix(main): add maxItems option to scope prompt Fixed glitch on small height screen for long scopes list. Base on @clack/prompts@0.7.0 via https://github.com/natemoo-re/clack/pull/174 --- package.json | 4 ++-- readme.md | 2 ++ src/index.ts | 1 + src/valibot-state.ts | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 1dbeae9..1b9ae9f 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "main": "dist/index.js", "bin": { "better-commits-init": "./dist/init.js", - "better-commits": "./dist/index.js", + "better-commits": "./dist/sindex.js", "better-branch": "./dist/branch.js", "bcommits": "./dist/index.js", "git-bc": "./dist/index.js" @@ -23,7 +23,7 @@ "license": "MIT", "dependencies": { "@clack/core": "^0.3.1", - "@clack/prompts": "^0.6.2", + "@clack/prompts": "^0.7.0", "configstore": "^5.0.1", "picocolors": "^1.0.0", "valibot": "^0.30.0" diff --git a/readme.md b/readme.md index c521af6..4c1ed2f 100644 --- a/readme.md +++ b/readme.md @@ -168,6 +168,7 @@ Better-commits (& better-branch) are highly flexible with sane defaults. These o "enable": true, "custom_scope": false, "initial_value": "app", + "max_items": Infinity "options": [ { "value": "app", @@ -292,6 +293,7 @@ Expand to see explanations and possible values | `commit_scope.enable` | If true include commit scope | | `commit_scope.custom_scope` | If true allow custom scope at run-time | | `commit_scope.initial_value` | Default commit scope selected | +| `commit_scope.max_items` | Maximum number of scope displayed on the screen | | `commit_scope.options.value` | Commit scope value | | `commit_scope.options.label` | Commit scope label | | `check_ticket.infer_ticket` | If true infer ticket from branch name | diff --git a/src/index.ts b/src/index.ts index b68723c..309c7cc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -107,6 +107,7 @@ export async function main(config: Output) { let commit_scope = await p.select({ message: "Select a commit scope", initialValue: config.commit_scope.initial_value, + maxItems: config.commit_scope.max_items, options: config.commit_scope.options, }); if (p.isCancel(commit_scope)) process.exit(0); diff --git a/src/valibot-state.ts b/src/valibot-state.ts index b3b1f9c..84f7021 100644 --- a/src/valibot-state.ts +++ b/src/valibot-state.ts @@ -65,6 +65,7 @@ export const Config = v.object({ { enable: v.optional(v.boolean(), true), custom_scope: v.optional(v.boolean(), false), + max_items: v.optional(v.number(), Infinity), initial_value: v.optional(v.string(), "app"), options: v.optional( v.array(