nonotify 0.1.14 → 0.1.15
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/CHANGELOG.md +6 -0
- package/dist/prompt.js +10 -15
- package/package.json +6 -6
- package/src/prompt.ts +12 -18
- package/tsconfig.json +1 -0
package/CHANGELOG.md
CHANGED
package/dist/prompt.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { cancel, confirm, isCancel, select, text } from "@clack/prompts";
|
|
2
|
+
function exitIfCancelled(value) {
|
|
3
|
+
if (isCancel(value)) {
|
|
4
|
+
cancel("Operation cancelled.");
|
|
5
|
+
process.exit(1);
|
|
6
|
+
}
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
2
9
|
export async function askRequired(question) {
|
|
3
10
|
return askRequiredWithInitial(question);
|
|
4
11
|
}
|
|
@@ -14,33 +21,21 @@ export async function askRequiredWithInitial(question, initialValue) {
|
|
|
14
21
|
return undefined;
|
|
15
22
|
},
|
|
16
23
|
});
|
|
17
|
-
|
|
18
|
-
cancel("Operation cancelled.");
|
|
19
|
-
process.exit(1);
|
|
20
|
-
}
|
|
21
|
-
return value.trim();
|
|
24
|
+
return exitIfCancelled(value).trim();
|
|
22
25
|
}
|
|
23
26
|
export async function askConfirm(question, initialValue = false) {
|
|
24
27
|
const value = await confirm({
|
|
25
28
|
message: normalizeQuestion(question),
|
|
26
29
|
initialValue,
|
|
27
30
|
});
|
|
28
|
-
|
|
29
|
-
cancel("Operation cancelled.");
|
|
30
|
-
process.exit(1);
|
|
31
|
-
}
|
|
32
|
-
return value;
|
|
31
|
+
return exitIfCancelled(value);
|
|
33
32
|
}
|
|
34
33
|
export async function askSelect(question, options) {
|
|
35
34
|
const value = await select({
|
|
36
35
|
message: normalizeQuestion(question),
|
|
37
36
|
options,
|
|
38
37
|
});
|
|
39
|
-
|
|
40
|
-
cancel("Operation cancelled.");
|
|
41
|
-
process.exit(1);
|
|
42
|
-
}
|
|
43
|
-
return value;
|
|
38
|
+
return exitIfCancelled(value);
|
|
44
39
|
}
|
|
45
40
|
function normalizeQuestion(question) {
|
|
46
41
|
return question.trim().replace(/:\s*$/, "");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nonotify",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
4
4
|
"description": "nnt CLI for Telegram notifications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
],
|
|
36
36
|
"license": "MIT",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@clack/prompts": "^1.0
|
|
38
|
+
"@clack/prompts": "^1.1.0",
|
|
39
39
|
"cli-table3": "^0.6.5",
|
|
40
|
-
"incur": "^0.
|
|
40
|
+
"incur": "^0.3.13"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@types/node": "^
|
|
44
|
-
"tsx": "^4.
|
|
45
|
-
"typescript": "^
|
|
43
|
+
"@types/node": "^25.5.0",
|
|
44
|
+
"tsx": "^4.21.0",
|
|
45
|
+
"typescript": "^6.0.2"
|
|
46
46
|
}
|
|
47
47
|
}
|
package/src/prompt.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { cancel, confirm, isCancel, select, text } from "@clack/prompts";
|
|
2
2
|
|
|
3
|
+
function exitIfCancelled<T>(value: T | symbol): T {
|
|
4
|
+
if (isCancel(value)) {
|
|
5
|
+
cancel("Operation cancelled.");
|
|
6
|
+
process.exit(1);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
return value;
|
|
10
|
+
}
|
|
11
|
+
|
|
3
12
|
export async function askRequired(question: string): Promise<string> {
|
|
4
13
|
return askRequiredWithInitial(question);
|
|
5
14
|
}
|
|
@@ -22,12 +31,7 @@ export async function askRequiredWithInitial(
|
|
|
22
31
|
},
|
|
23
32
|
});
|
|
24
33
|
|
|
25
|
-
|
|
26
|
-
cancel("Operation cancelled.");
|
|
27
|
-
process.exit(1);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return value.trim();
|
|
34
|
+
return exitIfCancelled(value).trim();
|
|
31
35
|
}
|
|
32
36
|
|
|
33
37
|
export async function askConfirm(
|
|
@@ -39,12 +43,7 @@ export async function askConfirm(
|
|
|
39
43
|
initialValue,
|
|
40
44
|
});
|
|
41
45
|
|
|
42
|
-
|
|
43
|
-
cancel("Operation cancelled.");
|
|
44
|
-
process.exit(1);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return value;
|
|
46
|
+
return exitIfCancelled(value);
|
|
48
47
|
}
|
|
49
48
|
|
|
50
49
|
type SelectOption = {
|
|
@@ -63,12 +62,7 @@ export async function askSelect(
|
|
|
63
62
|
options,
|
|
64
63
|
});
|
|
65
64
|
|
|
66
|
-
|
|
67
|
-
cancel("Operation cancelled.");
|
|
68
|
-
process.exit(1);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return value;
|
|
65
|
+
return exitIfCancelled(value);
|
|
72
66
|
}
|
|
73
67
|
|
|
74
68
|
function normalizeQuestion(question: string): string {
|