@sorrell/cli-utilities 1.0.12 → 1.0.13
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/Distribution/Confirm.Types.d.ts +8 -0
- package/Distribution/Confirm.Types.d.ts.map +1 -0
- package/Distribution/Confirm.Types.js +7 -0
- package/Distribution/Confirm.Types.js.map +1 -0
- package/Distribution/Confirm.d.ts +5 -0
- package/Distribution/Confirm.d.ts.map +1 -0
- package/Distribution/Confirm.js +52 -0
- package/Distribution/Confirm.js.map +1 -0
- package/Distribution/index.d.ts +2 -0
- package/Distribution/index.d.ts.map +1 -1
- package/Distribution/index.js +2 -0
- package/Distribution/index.js.map +1 -1
- package/package.json +3 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Confirm.Types.d.ts","sourceRoot":"","sources":["../Source/Confirm.Types.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5C,MAAM,MAAM,cAAc,GACtB;IACI,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;CAC9B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Confirm.Types.js","sourceRoot":"","sources":["../Source/Confirm.Types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { FConfirmConfig } from "./index.js";
|
|
2
|
+
import type { Prompt } from "@inquirer/type";
|
|
3
|
+
/** An `inquirer` prompt identical to `confirm`, but with more natural handling of keypresses. */
|
|
4
|
+
export declare const Confirm: Prompt<boolean, FConfirmConfig>;
|
|
5
|
+
//# sourceMappingURL=Confirm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Confirm.d.ts","sourceRoot":"","sources":["../Source/Confirm.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAO7C,iGAAiG;AACjG,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,cAAc,CAwDnD,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/* File: Confirm.ts
|
|
2
|
+
* Author: Gage Sorrell <gage@sorrell.sh>
|
|
3
|
+
* Copyright: (c) 2026 Gage Sorrell
|
|
4
|
+
* License: MIT
|
|
5
|
+
*/
|
|
6
|
+
import { createPrompt, isEnterKey, makeTheme, useKeypress, usePrefix, useState } from "@inquirer/core";
|
|
7
|
+
function GetAnswerString(Value) {
|
|
8
|
+
return Value ? "Yes" : "No";
|
|
9
|
+
}
|
|
10
|
+
/** An `inquirer` prompt identical to `confirm`, but with more natural handling of keypresses. */
|
|
11
|
+
export const Confirm = createPrompt((Configuration, Done) => {
|
|
12
|
+
const [StatusValue, SetStatusValue] = useState("idle");
|
|
13
|
+
const [DisplayValue, SetDisplayValue] = useState("");
|
|
14
|
+
const ThemeValue = makeTheme(Configuration.theme);
|
|
15
|
+
const Prefix = usePrefix({ status: StatusValue, theme: ThemeValue });
|
|
16
|
+
useKeypress((Key) => {
|
|
17
|
+
if (StatusValue !== "idle") {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const KeyName = Key.name?.toLowerCase();
|
|
21
|
+
if (KeyName === "y") {
|
|
22
|
+
SetDisplayValue(ThemeValue.style.answer("Yes"));
|
|
23
|
+
SetStatusValue("done");
|
|
24
|
+
Done(true);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (KeyName === "n") {
|
|
28
|
+
SetDisplayValue(ThemeValue.style.answer("No"));
|
|
29
|
+
SetStatusValue("done");
|
|
30
|
+
Done(false);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (isEnterKey(Key)) {
|
|
34
|
+
const Answer = Configuration.default ?? true;
|
|
35
|
+
SetDisplayValue(ThemeValue.style.answer(GetAnswerString(Answer)));
|
|
36
|
+
SetStatusValue("done");
|
|
37
|
+
Done(Answer);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
const DefaultHint = StatusValue === "idle"
|
|
41
|
+
? ` ${ThemeValue.style.defaultAnswer(Configuration.default === false ? "y/N" : "Y/n")}`
|
|
42
|
+
: "";
|
|
43
|
+
return [
|
|
44
|
+
Prefix,
|
|
45
|
+
" ",
|
|
46
|
+
ThemeValue.style.message(Configuration.message, StatusValue),
|
|
47
|
+
DefaultHint,
|
|
48
|
+
" ",
|
|
49
|
+
DisplayValue
|
|
50
|
+
].join("");
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=Confirm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Confirm.js","sourceRoot":"","sources":["../Source/Confirm.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAIH,YAAY,EACZ,UAAU,EACV,SAAS,EACT,WAAW,EACX,SAAS,EACT,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAIrC,SAAS,eAAe,CAAC,KAAc;IAEnC,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AAChC,CAAC;AAED,iGAAiG;AACjG,MAAM,CAAC,MAAM,OAAO,GAAoC,YAAY,CAChE,CAAC,aAA6B,EAAE,IAAgC,EAAE,EAAE;IAEhE,MAAM,CAAE,WAAW,EAAE,cAAc,CAAE,GAAG,QAAQ,CAAS,MAAM,CAAC,CAAC;IACjE,MAAM,CAAE,YAAY,EAAE,eAAe,CAAE,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IACvD,MAAM,UAAU,GAAU,SAAS,CAAC,aAAa,CAAC,KA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C,CAAC,EAAE,CAAC;IAEb,OAAO;QACH,MAAM;QACN,GAAG;QACH,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,EAAE,WAAW,CAAC;QAC5D,WAAW;QACX,GAAG;QACH,YAAY;KACf,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACf,CAAC,CACJ,CAAC"}
|
package/Distribution/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../Source/index.ts"],"names":[],"mappings":"AAMA,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../Source/index.ts"],"names":[],"mappings":"AAMA,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC"}
|
package/Distribution/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../Source/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../Source/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sorrell/cli-utilities",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"description": "Utilities for CLI tools.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -33,7 +33,9 @@
|
|
|
33
33
|
"@typescript/native-preview": "^7.0.0-dev.20260326.1"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
+
"@inquirer/core": "^11.1.7",
|
|
36
37
|
"@inquirer/prompts": "^8.3.2",
|
|
38
|
+
"@inquirer/type": "^4.0.4",
|
|
37
39
|
"chalk": "^5.6.2",
|
|
38
40
|
"cli-table3": "^0.6.5",
|
|
39
41
|
"clipboardy": "^5.3.1",
|