@reliverse/rempts 1.7.43 → 1.7.45

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 (134) hide show
  1. package/README.md +1 -1
  2. package/dist-npm/bin/mod.d.mts +2333 -0
  3. package/dist-npm/bin/mod.mjs +8236 -0
  4. package/package.json +84 -42
  5. package/bin/libs/animate/animate-mod.d.ts +0 -14
  6. package/bin/libs/animate/animate-mod.js +0 -62
  7. package/bin/libs/anykey/anykey-mod.d.ts +0 -12
  8. package/bin/libs/anykey/anykey-mod.js +0 -125
  9. package/bin/libs/cancel/cancel.d.ts +0 -45
  10. package/bin/libs/cancel/cancel.js +0 -72
  11. package/bin/libs/confirm/confirm-alias.d.ts +0 -2
  12. package/bin/libs/confirm/confirm-alias.js +0 -2
  13. package/bin/libs/confirm/confirm-mod.d.ts +0 -5
  14. package/bin/libs/confirm/confirm-mod.js +0 -179
  15. package/bin/libs/date/date.d.ts +0 -2
  16. package/bin/libs/date/date.js +0 -236
  17. package/bin/libs/editor/editor-mod.d.ts +0 -25
  18. package/bin/libs/editor/editor-mod.js +0 -897
  19. package/bin/libs/figures/figures-mod.d.ts +0 -461
  20. package/bin/libs/figures/figures-mod.js +0 -285
  21. package/bin/libs/group/group-mod.d.ts +0 -33
  22. package/bin/libs/group/group-mod.js +0 -93
  23. package/bin/libs/input/input-alias.d.ts +0 -5
  24. package/bin/libs/input/input-alias.js +0 -4
  25. package/bin/libs/input/input-mod.d.ts +0 -16
  26. package/bin/libs/input/input-mod.js +0 -372
  27. package/bin/libs/intro/intro-alias.d.ts +0 -2
  28. package/bin/libs/intro/intro-alias.js +0 -3
  29. package/bin/libs/intro/intro-mod.d.ts +0 -20
  30. package/bin/libs/intro/intro-mod.js +0 -81
  31. package/bin/libs/launcher/command-runner.d.ts +0 -18
  32. package/bin/libs/launcher/command-runner.js +0 -76
  33. package/bin/libs/launcher/command-typed.d.ts +0 -16
  34. package/bin/libs/launcher/command-typed.js +0 -60
  35. package/bin/libs/launcher/launcher-alias.d.ts +0 -2
  36. package/bin/libs/launcher/launcher-alias.js +0 -2
  37. package/bin/libs/launcher/launcher-mod.d.ts +0 -162
  38. package/bin/libs/launcher/launcher-mod.js +0 -1222
  39. package/bin/libs/launcher/launcher-types.d.ts +0 -159
  40. package/bin/libs/launcher/launcher-types.js +0 -0
  41. package/bin/libs/launcher/trpc-orpc-support/completions.d.ts +0 -4
  42. package/bin/libs/launcher/trpc-orpc-support/completions.js +0 -45
  43. package/bin/libs/launcher/trpc-orpc-support/errors.d.ts +0 -11
  44. package/bin/libs/launcher/trpc-orpc-support/errors.js +0 -10
  45. package/bin/libs/launcher/trpc-orpc-support/index.d.ts +0 -34
  46. package/bin/libs/launcher/trpc-orpc-support/index.js +0 -641
  47. package/bin/libs/launcher/trpc-orpc-support/json-schema.d.ts +0 -17
  48. package/bin/libs/launcher/trpc-orpc-support/json-schema.js +0 -168
  49. package/bin/libs/launcher/trpc-orpc-support/json.d.ts +0 -44
  50. package/bin/libs/launcher/trpc-orpc-support/json.js +0 -41
  51. package/bin/libs/launcher/trpc-orpc-support/logging.d.ts +0 -11
  52. package/bin/libs/launcher/trpc-orpc-support/logging.js +0 -26
  53. package/bin/libs/launcher/trpc-orpc-support/parse-procedure.d.ts +0 -2
  54. package/bin/libs/launcher/trpc-orpc-support/parse-procedure.js +0 -486
  55. package/bin/libs/launcher/trpc-orpc-support/prompts.d.ts +0 -18
  56. package/bin/libs/launcher/trpc-orpc-support/prompts.js +0 -534
  57. package/bin/libs/launcher/trpc-orpc-support/standard-schema/contract.d.ts +0 -53
  58. package/bin/libs/launcher/trpc-orpc-support/standard-schema/contract.js +0 -0
  59. package/bin/libs/launcher/trpc-orpc-support/standard-schema/errors.d.ts +0 -9
  60. package/bin/libs/launcher/trpc-orpc-support/standard-schema/errors.js +0 -47
  61. package/bin/libs/launcher/trpc-orpc-support/standard-schema/utils.d.ts +0 -3
  62. package/bin/libs/launcher/trpc-orpc-support/standard-schema/utils.js +0 -6
  63. package/bin/libs/launcher/trpc-orpc-support/trpc-compat.d.ts +0 -71
  64. package/bin/libs/launcher/trpc-orpc-support/trpc-compat.js +0 -11
  65. package/bin/libs/launcher/trpc-orpc-support/types.d.ts +0 -276
  66. package/bin/libs/launcher/trpc-orpc-support/types.js +0 -0
  67. package/bin/libs/launcher/trpc-orpc-support/util.d.ts +0 -9
  68. package/bin/libs/launcher/trpc-orpc-support/util.js +0 -9
  69. package/bin/libs/log/log-alias.d.ts +0 -1
  70. package/bin/libs/log/log-alias.js +0 -2
  71. package/bin/libs/msg-fmt/colors.d.ts +0 -30
  72. package/bin/libs/msg-fmt/colors.js +0 -42
  73. package/bin/libs/msg-fmt/logger.d.ts +0 -17
  74. package/bin/libs/msg-fmt/logger.js +0 -103
  75. package/bin/libs/msg-fmt/mapping.d.ts +0 -3
  76. package/bin/libs/msg-fmt/mapping.js +0 -49
  77. package/bin/libs/msg-fmt/messages.d.ts +0 -35
  78. package/bin/libs/msg-fmt/messages.js +0 -319
  79. package/bin/libs/msg-fmt/terminal.d.ts +0 -15
  80. package/bin/libs/msg-fmt/terminal.js +0 -60
  81. package/bin/libs/msg-fmt/variants.d.ts +0 -11
  82. package/bin/libs/msg-fmt/variants.js +0 -52
  83. package/bin/libs/multiselect/multiselect-alias.d.ts +0 -2
  84. package/bin/libs/multiselect/multiselect-alias.js +0 -2
  85. package/bin/libs/multiselect/multiselect-prompt.d.ts +0 -2
  86. package/bin/libs/multiselect/multiselect-prompt.js +0 -348
  87. package/bin/libs/next-steps/next-steps.d.ts +0 -14
  88. package/bin/libs/next-steps/next-steps.js +0 -24
  89. package/bin/libs/number/number-mod.d.ts +0 -28
  90. package/bin/libs/number/number-mod.js +0 -194
  91. package/bin/libs/outro/outro-alias.d.ts +0 -2
  92. package/bin/libs/outro/outro-alias.js +0 -3
  93. package/bin/libs/outro/outro-mod.d.ts +0 -8
  94. package/bin/libs/outro/outro-mod.js +0 -55
  95. package/bin/libs/results/results.d.ts +0 -7
  96. package/bin/libs/results/results.js +0 -27
  97. package/bin/libs/select/nummultiselect-prompt.d.ts +0 -6
  98. package/bin/libs/select/nummultiselect-prompt.js +0 -105
  99. package/bin/libs/select/numselect-prompt.d.ts +0 -7
  100. package/bin/libs/select/numselect-prompt.js +0 -115
  101. package/bin/libs/select/select-alias.d.ts +0 -9
  102. package/bin/libs/select/select-alias.js +0 -9
  103. package/bin/libs/select/select-prompt.d.ts +0 -5
  104. package/bin/libs/select/select-prompt.js +0 -314
  105. package/bin/libs/select/toggle-prompt.d.ts +0 -5
  106. package/bin/libs/select/toggle-prompt.js +0 -209
  107. package/bin/libs/spinner/spinner-alias.d.ts +0 -1
  108. package/bin/libs/spinner/spinner-alias.js +0 -2
  109. package/bin/libs/spinner/spinner-mod.d.ts +0 -106
  110. package/bin/libs/spinner/spinner-mod.js +0 -265
  111. package/bin/libs/task/progress.d.ts +0 -2
  112. package/bin/libs/task/progress.js +0 -57
  113. package/bin/libs/task/task-spin.d.ts +0 -15
  114. package/bin/libs/task/task-spin.js +0 -110
  115. package/bin/libs/utils/colorize.d.ts +0 -2
  116. package/bin/libs/utils/colorize.js +0 -135
  117. package/bin/libs/utils/errors.d.ts +0 -1
  118. package/bin/libs/utils/errors.js +0 -17
  119. package/bin/libs/utils/prevent.d.ts +0 -8
  120. package/bin/libs/utils/prevent.js +0 -65
  121. package/bin/libs/utils/prompt-end.d.ts +0 -8
  122. package/bin/libs/utils/prompt-end.js +0 -34
  123. package/bin/libs/utils/stream-text.d.ts +0 -18
  124. package/bin/libs/utils/stream-text.js +0 -136
  125. package/bin/libs/utils/system.d.ts +0 -6
  126. package/bin/libs/utils/system.js +0 -7
  127. package/bin/libs/utils/validate.d.ts +0 -21
  128. package/bin/libs/utils/validate.js +0 -17
  129. package/bin/libs/visual/visual-mod.d.ts +0 -6
  130. package/bin/libs/visual/visual-mod.js +0 -13
  131. package/bin/mod.d.ts +0 -69
  132. package/bin/mod.js +0 -159
  133. package/bin/types.d.ts +0 -371
  134. package/bin/types.js +0 -0
package/package.json CHANGED
@@ -1,23 +1,73 @@
1
1
  {
2
+ "name": "@reliverse/rempts",
3
+ "author": "reliverse",
4
+ "version": "1.7.45",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "main": "./dist-npm/bin/mod.mjs",
8
+ "types": "./dist-npm/bin/mod.d.mts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist-npm/bin/mod.d.mts",
12
+ "import": "./dist-npm/bin/mod.mjs",
13
+ "default": "./dist-npm/bin/mod.mjs"
14
+ }
15
+ },
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "files": [
20
+ "package.json",
21
+ "README.md",
22
+ "LICENSE",
23
+ "dist-npm/bin/mod.d.mts",
24
+ "dist-npm/bin/mod.mjs"
25
+ ],
26
+ "keywords": [
27
+ "reliverse",
28
+ "prompts",
29
+ "rempts",
30
+ "citty",
31
+ "cli",
32
+ "unjs",
33
+ "toolkit",
34
+ "cli-toolkit",
35
+ "cli-prompts"
36
+ ],
37
+ "description": "@reliverse/rempts is a modern, type-safe toolkit for building delightful cli experiences. it's fast, flexible, and made for developer happiness. file-based commands keep things simple.",
38
+ "scripts": {
39
+ "build": "unbuild",
40
+ "prepack": "unbuild",
41
+ "pub": "bun run build && bun publish",
42
+ "dev": "node -e 'console.log(`👉 bun dev:[prompts,modern,classic]`)'",
43
+ "dev:prompts": "bun example/prompts/mod.ts",
44
+ "dev:modern": "bun example/launcher/modern.ts",
45
+ "dev:classic": "bun example/launcher/classic.ts",
46
+ "dev:trpc": "bun example/trpc-orpc/commander/main.ts",
47
+ "latest": "bun update --latest && bun check",
48
+ "check": "tsc --noEmit && biome check --fix --unsafe .",
49
+ "agg": "rse tools --tool agg --input src/libs/core/core-impl --out src/libs/core/core-main.ts --recursive --named --strip src/libs/core",
50
+ "tests": "bun test ./.tests"
51
+ },
2
52
  "dependencies": {
3
53
  "@clack/prompts": "^0.11.0",
4
54
  "@figliolia/chalk-animation": "^1.0.4",
5
- "@inquirer/prompts": "^7.7.1",
6
- "@orpc/server": "^1.7.5",
55
+ "@inquirer/prompts": "^7.8.3",
56
+ "@orpc/server": "^1.8.3",
7
57
  "@reliverse/pathkit": "^1.3.4",
8
58
  "@reliverse/reliarg": "^1.0.3",
9
- "@reliverse/relico": "^1.2.0",
59
+ "@reliverse/relico": "^1.3.4",
10
60
  "@reliverse/relifso": "^1.4.5",
11
- "@reliverse/relinka": "^1.5.3",
61
+ "@reliverse/relinka": "^1.5.5",
12
62
  "@reliverse/runtime": "^1.0.3",
13
- "@trpc/server": "^11.4.3",
63
+ "@trpc/server": "^11.5.0",
14
64
  "ansi-escapes": "^7.0.0",
15
65
  "arktype": "^2.1.20",
16
- "c12": "^3.1.0",
66
+ "c12": "^3.2.0",
17
67
  "cli-spinners": "^3.2.0",
18
68
  "commander": "^14.0.0",
19
69
  "detect-package-manager": "^3.0.2",
20
- "effect": "^3.17.2",
70
+ "effect": "^3.17.8",
21
71
  "enquirer": "^2.4.1",
22
72
  "figlet": "^1.8.2",
23
73
  "gradient-string": "^3.0.0",
@@ -27,49 +77,41 @@
27
77
  "node-emoji": "^2.2.0",
28
78
  "omelette": "^0.4.17",
29
79
  "ora": "^8.2.0",
30
- "pkg-types": "^2.2.0",
80
+ "pkg-types": "^2.3.0",
31
81
  "prompts": "^2.4.2",
32
82
  "sisteransi": "^1.0.5",
33
83
  "terminal-kit": "^3.1.2",
34
84
  "terminal-size": "^4.0.0",
35
85
  "ts-regex-builder": "^1.8.2",
36
- "tsx": "^4.20.3",
86
+ "tsx": "^4.20.4",
87
+ "unicorn-magic": "^0.3.0",
37
88
  "valibot": "^1.1.0",
38
89
  "wrap-ansi": "^9.0.0",
39
- "zod": "^4.0.10",
90
+ "zod": "^4.0.17",
40
91
  "zod-to-json-schema": "^3.24.6"
41
92
  },
42
- "description": "@reliverse/rempts is a modern, type-safe toolkit for building delightful cli experiences. it's fast, flexible, and made for developer happiness. file-based commands keep things simple.",
43
- "homepage": "https://docs.reliverse.org",
44
- "license": "MIT",
45
- "name": "@reliverse/rempts",
46
- "type": "module",
47
- "version": "1.7.43",
48
- "author": "reliverse",
49
- "bugs": {
50
- "email": "blefnk@gmail.com",
51
- "url": "https://github.com/reliverse/rempts/issues"
52
- },
53
- "keywords": [
54
- "reliverse"
55
- ],
56
- "repository": {
57
- "type": "git",
58
- "url": "git+https://github.com/reliverse/rempts.git"
59
- },
60
- "devDependencies": {},
61
- "exports": {
62
- ".": "./bin/mod.js"
63
- },
64
- "files": [
65
- "bin",
66
- "package.json",
67
- "README.md",
68
- "LICENSE"
69
- ],
70
- "main": "./bin/mod.js",
71
- "module": "./bin/mod.js",
72
- "publishConfig": {
73
- "access": "public"
93
+ "devDependencies": {
94
+ "@biomejs/biome": "2.2.0",
95
+ "@orpc/contract": "^1.8.3",
96
+ "@reliverse/dler": "1.7.92",
97
+ "@reliverse/rse": "^1.7.12",
98
+ "@total-typescript/ts-reset": "^0.6.1",
99
+ "@types/bun": "^1.2.20",
100
+ "@types/figlet": "^1.7.0",
101
+ "@types/node": "^24.3.0",
102
+ "@types/omelette": "^0.4.5",
103
+ "@types/prompts": "^2.4.9",
104
+ "@types/terminal-kit": "^2.5.7",
105
+ "@types/wrap-ansi": "^8.1.0",
106
+ "@valibot/to-json-schema": "^1.3.0",
107
+ "expect-type": "^1.2.2",
108
+ "fs-syncer": "^0.5.3",
109
+ "minimatch": "^10.0.3",
110
+ "obuild": "^0.2.1",
111
+ "picocolors": "^1.1.1",
112
+ "strip-ansi": "^7.1.0",
113
+ "typescript": "^5.9.2",
114
+ "ultracite": "^5.2.5",
115
+ "unbuild": "^3.6.1"
74
116
  }
75
117
  }
@@ -1,14 +0,0 @@
1
- import { type Animation, type AnimationName } from "@figliolia/chalk-animation";
2
- import type { BorderColorName, ColorName, MsgType, TypographyName } from "../../types.js";
3
- export declare const animationMap: Record<AnimationName, (text: string) => Animation>;
4
- export declare function animateText({ title, anim, delay, type, titleColor, titleTypography, border, borderColor, horizontalLineLength, }: {
5
- title: string;
6
- anim: AnimationName;
7
- delay?: number;
8
- type?: MsgType;
9
- titleColor?: ColorName;
10
- titleTypography?: TypographyName;
11
- borderColor?: BorderColorName;
12
- border?: boolean;
13
- horizontalLineLength?: number;
14
- }): Promise<void>;
@@ -1,62 +0,0 @@
1
- import {
2
- ChalkAnimation
3
- } from "@figliolia/chalk-animation";
4
- import { relinka } from "@reliverse/relinka";
5
- import { msg } from "../msg-fmt/messages.js";
6
- import { deleteLastLine, getTerminalWidth } from "../msg-fmt/terminal.js";
7
- export const animationMap = {
8
- rainbow: ChalkAnimation.rainbow,
9
- pulse: ChalkAnimation.pulse,
10
- glitch: ChalkAnimation.glitch,
11
- radar: ChalkAnimation.radar,
12
- neon: ChalkAnimation.neon,
13
- karaoke: ChalkAnimation.karaoke
14
- };
15
- function calculateDelay(text) {
16
- const baseDelay = 1e3;
17
- const delayPerCharacter = 50;
18
- return baseDelay + text.length * delayPerCharacter;
19
- }
20
- export async function animateText({
21
- title = "",
22
- anim,
23
- delay,
24
- type = "M_INFO",
25
- titleColor = "cyan",
26
- titleTypography = "none",
27
- border = true,
28
- borderColor = "dim",
29
- horizontalLineLength = 0
30
- }) {
31
- if (horizontalLineLength === 0) {
32
- horizontalLineLength = getTerminalWidth() - 5;
33
- }
34
- const finalDelay = delay ?? calculateDelay(title);
35
- const animation = animationMap[anim](title);
36
- try {
37
- await new Promise((resolve) => {
38
- setTimeout(() => {
39
- animation.stop();
40
- deleteLastLine();
41
- if (title.includes("\u2502 ")) {
42
- title = title.replace("\u2502 ", "");
43
- } else if (title.includes("\u2139 ")) {
44
- title = title.replace("\u2139 ", "");
45
- }
46
- msg({
47
- type,
48
- title,
49
- titleColor,
50
- titleTypography,
51
- content: "",
52
- borderColor,
53
- border,
54
- horizontalLineLength
55
- });
56
- resolve();
57
- }, finalDelay);
58
- });
59
- } catch (error) {
60
- relinka("error", "Animation failed to complete.", error);
61
- }
62
- }
@@ -1,12 +0,0 @@
1
- import type { ColorName } from "../../types.js";
2
- interface Options {
3
- ctrlC?: number | false | "reject";
4
- preserveLog?: boolean;
5
- hideMessage?: boolean;
6
- shouldStream?: boolean;
7
- streamDelay?: number;
8
- color?: ColorName;
9
- placeholderColor?: ColorName;
10
- }
11
- export declare function anykeyPrompt(message?: string, options?: Options): Promise<void>;
12
- export {};
@@ -1,125 +0,0 @@
1
- import logUpdate from "log-update";
2
- import { cursor } from "sisteransi";
3
- import { fmt } from "../msg-fmt/messages.js";
4
- import { outroPrompt } from "../outro/outro-mod.js";
5
- import { streamText } from "../utils/stream-text.js";
6
- const DEFAULT_MESSAGE = "Press any key to continue...";
7
- const CTRL_C_CODE = 3;
8
- const terminal = {
9
- /**
10
- * Move cursor to start of line
11
- */
12
- moveToStart: () => process.stdout.write("\r"),
13
- /**
14
- * Clear current line and move cursor up
15
- */
16
- clearLineAndMoveUp: () => process.stdout.write("\x1B[1A\x1B[2K"),
17
- /**
18
- * Clear multiple lines above current position
19
- */
20
- clearLines: (count) => {
21
- terminal.moveToStart();
22
- process.stdout.write("\x1B[2K");
23
- for (let i = 0; i < count; i++) {
24
- terminal.clearLineAndMoveUp();
25
- }
26
- }
27
- };
28
- export async function anykeyPrompt(message = DEFAULT_MESSAGE, options = {}) {
29
- const {
30
- ctrlC = 1,
31
- preserveLog = false,
32
- hideMessage = false,
33
- shouldStream = false,
34
- streamDelay = 20,
35
- color = "dim",
36
- placeholderColor = "gray"
37
- } = options;
38
- if (message) {
39
- if (!shouldStream) {
40
- const { text } = fmt({
41
- hintPlaceholderColor: placeholderColor,
42
- type: "M_GENERAL",
43
- title: message,
44
- titleColor: color,
45
- dontRemoveBar: true
46
- });
47
- message = text;
48
- }
49
- }
50
- if (message && !hideMessage) {
51
- if (shouldStream) {
52
- await streamText({
53
- text: `\u25C6 ${message}`,
54
- delay: streamDelay,
55
- newline: false,
56
- clearLine: true,
57
- color
58
- });
59
- const lineCount = message.split("\n").length;
60
- terminal.clearLines(lineCount);
61
- const { text } = fmt({
62
- hintPlaceholderColor: placeholderColor,
63
- type: "M_GENERAL",
64
- title: message,
65
- titleColor: color,
66
- dontRemoveBar: true
67
- });
68
- terminal.moveToStart();
69
- logUpdate(text);
70
- } else {
71
- logUpdate(message);
72
- }
73
- }
74
- return new Promise((resolve, reject) => {
75
- const cleanup = () => {
76
- process.stdin.removeListener("data", handler);
77
- if (process.stdin.isTTY && typeof process.stdin.setRawMode === "function") {
78
- process.stdin.setRawMode(false);
79
- }
80
- process.stdin.pause();
81
- process.stdout.write(cursor.show);
82
- };
83
- const handleCtrlC = () => {
84
- cleanup();
85
- void outroPrompt({
86
- title: "\u270B User pressed Ctrl+C, exiting...",
87
- titleAnimation: "pulse",
88
- titleColor: "redBright",
89
- titleTypography: "bold",
90
- endTitleColor: "redBright",
91
- titleAnimationDelay: 400
92
- }).then(() => {
93
- if (ctrlC === "reject") {
94
- reject(new Error("User pressed CTRL+C"));
95
- } else if (ctrlC === false) {
96
- resolve();
97
- } else if (typeof ctrlC === "number") {
98
- process.exit(0);
99
- } else {
100
- throw new TypeError("Invalid ctrlC option");
101
- }
102
- }).catch(reject);
103
- };
104
- const handler = (buffer) => {
105
- cleanup();
106
- if (message && !preserveLog) {
107
- logUpdate.clear();
108
- } else {
109
- logUpdate.done();
110
- process.stdout.write("\n");
111
- }
112
- const [firstByte] = buffer;
113
- if (firstByte === CTRL_C_CODE) {
114
- handleCtrlC();
115
- } else {
116
- resolve();
117
- }
118
- };
119
- process.stdin.resume();
120
- if (process.stdin.isTTY && typeof process.stdin.setRawMode === "function") {
121
- process.stdin.setRawMode(true);
122
- }
123
- process.stdin.once("data", handler);
124
- });
125
- }
@@ -1,45 +0,0 @@
1
- import type { Readable, Writable } from "node:stream";
2
- /**
3
- * Special value that indicates a cancelled operation
4
- */
5
- export declare const CANCEL: unique symbol;
6
- /**
7
- * Type for the cancel value
8
- */
9
- export type CancelValue = typeof CANCEL;
10
- export declare const isWindows: boolean;
11
- /**
12
- * Sets raw mode on input stream
13
- */
14
- export declare function setRawMode(input: Readable, value: boolean): void;
15
- /**
16
- * Gets the number of columns in the terminal
17
- */
18
- export declare function getColumns(output: Writable): number;
19
- interface BlockOptions {
20
- input?: Readable;
21
- output?: Writable;
22
- overwrite?: boolean;
23
- hideCursor?: boolean;
24
- }
25
- /**
26
- * Creates a block for handling input with proper cursor and cleanup
27
- */
28
- export declare function block({ input, output, overwrite, hideCursor, }?: BlockOptions): () => void;
29
- /**
30
- * Checks if a value represents a cancelled operation
31
- * @param value - The value to check
32
- * @returns true if the value represents a cancelled operation
33
- */
34
- export declare function isCancel(value: unknown): value is CancelValue;
35
- /**
36
- * Handles cancellation of an operation
37
- * @param message - Optional message to display before exiting
38
- */
39
- export declare function cancel(message?: string): never;
40
- /**
41
- * Creates a cancel value that can be returned from operations
42
- * @returns The cancel value
43
- */
44
- export declare function createCancel(): CancelValue;
45
- export {};
@@ -1,72 +0,0 @@
1
- import { stdin, stdout } from "node:process";
2
- import * as readline from "node:readline";
3
- import { ReadStream, WriteStream } from "node:tty";
4
- import { cursor } from "sisteransi";
5
- export const CANCEL = Symbol("CANCEL");
6
- export const isWindows = globalThis.process.platform.startsWith("win");
7
- export function setRawMode(input, value) {
8
- const i = input;
9
- if (i.isTTY) i.setRawMode(value);
10
- }
11
- export function getColumns(output) {
12
- if (output instanceof WriteStream && output.columns) {
13
- return output.columns;
14
- }
15
- return 80;
16
- }
17
- export function block({
18
- input = stdin,
19
- output = stdout,
20
- overwrite = true,
21
- hideCursor = true
22
- } = {}) {
23
- const rl = readline.createInterface({
24
- input,
25
- output,
26
- prompt: "",
27
- tabSize: 1
28
- });
29
- readline.emitKeypressEvents(input, rl);
30
- if (input instanceof ReadStream && input.isTTY) {
31
- input.setRawMode(true);
32
- }
33
- const clear = (data, { name, sequence }) => {
34
- const str = String(data);
35
- if (str === "" || name === "c" && sequence === "") {
36
- if (hideCursor) output.write(cursor.show);
37
- process.exit(0);
38
- return;
39
- }
40
- if (!overwrite) return;
41
- const dx = name === "return" ? 0 : -1;
42
- const dy = name === "return" ? -1 : 0;
43
- readline.moveCursor(output, dx, dy, () => {
44
- readline.clearLine(output, 1, () => {
45
- input.once("keypress", clear);
46
- });
47
- });
48
- };
49
- if (hideCursor) output.write(cursor.hide);
50
- input.once("keypress", clear);
51
- return () => {
52
- input.off("keypress", clear);
53
- if (hideCursor) output.write(cursor.show);
54
- if (input instanceof ReadStream && input.isTTY && !isWindows) {
55
- input.setRawMode(false);
56
- }
57
- rl.terminal = false;
58
- rl.close();
59
- };
60
- }
61
- export function isCancel(value) {
62
- return value === CANCEL;
63
- }
64
- export function cancel(message) {
65
- if (message) {
66
- console.log(message);
67
- }
68
- process.exit(0);
69
- }
70
- export function createCancel() {
71
- return CANCEL;
72
- }
@@ -1,2 +0,0 @@
1
- import type { ConfirmPromptOptions } from "../../types.js";
2
- export declare const confirm: (options: ConfirmPromptOptions) => Promise<boolean>;
@@ -1,2 +0,0 @@
1
- import { confirmPrompt } from "./confirm-mod.js";
2
- export const confirm = confirmPrompt;
@@ -1,5 +0,0 @@
1
- import type { ConfirmPromptOptions } from "../../types.js";
2
- /**
3
- * Prompts the user with a yes/no question, returning a boolean based on their input.
4
- */
5
- export declare function confirmPrompt(options: ConfirmPromptOptions): Promise<boolean>;
@@ -1,179 +0,0 @@
1
- import { re } from "@reliverse/relico";
2
- import { stdin as input, stdout as output } from "node:process";
3
- import readline from "node:readline/promises";
4
- import { bar, msg } from "../msg-fmt/messages.js";
5
- import { deleteLastLine } from "../msg-fmt/terminal.js";
6
- import { completePrompt } from "../utils/prompt-end.js";
7
- function renderPrompt(params) {
8
- const {
9
- title,
10
- content,
11
- borderColor,
12
- titleColor,
13
- titleTypography,
14
- titleVariant,
15
- contentColor,
16
- contentTypography,
17
- contentVariant,
18
- hintPlaceholderColor,
19
- border,
20
- variantOptions,
21
- errorMessage,
22
- displayInstructions,
23
- instructions,
24
- isRerender = false
25
- } = params;
26
- let uiLineCount = 0;
27
- if (!isRerender) {
28
- msg({
29
- hintPlaceholderColor,
30
- type: errorMessage ? "M_ERROR" : "M_GENERAL",
31
- title,
32
- titleColor,
33
- titleTypography,
34
- ...titleVariant ? { titleVariant } : {},
35
- ...content ? {
36
- content: content.split("\n").map((line) => line.trim()).join("\n")
37
- } : {},
38
- contentColor,
39
- contentTypography,
40
- ...contentVariant ? { contentVariant } : {},
41
- borderColor,
42
- variantOptions,
43
- errorMessage,
44
- border
45
- });
46
- }
47
- if (displayInstructions && !isRerender) {
48
- msg({
49
- type: "M_NULL",
50
- title: re.blue(instructions)
51
- });
52
- uiLineCount++;
53
- }
54
- if (errorMessage) {
55
- msg({
56
- type: "M_NULL",
57
- title: re.redBright(errorMessage)
58
- });
59
- uiLineCount++;
60
- }
61
- return uiLineCount;
62
- }
63
- export async function confirmPrompt(options) {
64
- const {
65
- title = "",
66
- message,
67
- // Alias for title
68
- defaultValue,
69
- initialValue,
70
- // Alias for defaultValue
71
- content,
72
- titleColor = "cyan",
73
- titleTypography = "none",
74
- titleVariant,
75
- contentColor = "dim",
76
- contentTypography = "italic",
77
- contentVariant,
78
- borderColor = "dim",
79
- hintPlaceholderColor = "blue",
80
- variantOptions,
81
- action,
82
- displayInstructions = false,
83
- endTitle = "",
84
- endTitleColor = "dim",
85
- border = true
86
- } = options;
87
- const finalTitle = message && title ? `${title}: ${message}` : message ?? title ?? "Confirm";
88
- const finalDefaultValue = defaultValue ?? initialValue;
89
- const rl = readline.createInterface({ input, output });
90
- let errorMessage = "";
91
- const effectiveDefault = finalDefaultValue ?? true;
92
- const defaultHint = effectiveDefault ? "[Y/n]" : "[y/N]";
93
- const adjustedTitle = displayInstructions ? finalTitle : `${re.blue(defaultHint)} ${finalTitle}`;
94
- const instructions = `Use <y/n> to confirm or deny, <Enter> for default (${effectiveDefault ? "Y" : "N"}), <Ctrl+C> to exit`;
95
- let lastUILineCount = 0;
96
- function endPrompt(isCtrlC = false) {
97
- if (endTitle !== "") {
98
- msg({
99
- type: "M_END",
100
- title: endTitle,
101
- titleColor: endTitleColor,
102
- titleTypography,
103
- ...titleVariant ? { titleVariant } : {},
104
- border,
105
- borderColor
106
- });
107
- }
108
- rl.close();
109
- if (isCtrlC) {
110
- process.exit(0);
111
- }
112
- }
113
- rl.on("SIGINT", () => {
114
- endPrompt(true);
115
- });
116
- try {
117
- while (true) {
118
- if (lastUILineCount > 0) {
119
- for (let i = 0; i < lastUILineCount; i++) {
120
- process.stdout.write("\x1B[1A\x1B[2K");
121
- }
122
- }
123
- lastUILineCount = renderPrompt({
124
- title: adjustedTitle,
125
- ...content ? { content } : {},
126
- borderColor,
127
- titleColor,
128
- titleTypography,
129
- ...titleVariant ? { titleVariant } : {},
130
- contentColor,
131
- contentTypography,
132
- ...contentVariant ? { contentVariant } : {},
133
- hintPlaceholderColor,
134
- border,
135
- variantOptions,
136
- errorMessage,
137
- effectiveDefault,
138
- displayInstructions,
139
- defaultHint,
140
- instructions,
141
- isRerender: errorMessage !== ""
142
- // Only rerender if there's an error
143
- });
144
- const formattedBar = bar({ borderColor });
145
- const answer = (await rl.question(`${formattedBar} `)).toLowerCase().trim();
146
- let result;
147
- if (!answer) {
148
- deleteLastLine();
149
- msg({
150
- type: "M_NULL",
151
- title: `${formattedBar} ${effectiveDefault ? "y" : "n"}`
152
- });
153
- result = effectiveDefault;
154
- } else if (answer === "y" || answer === "yes") {
155
- result = true;
156
- } else if (answer === "n" || answer === "no") {
157
- result = false;
158
- } else {
159
- errorMessage = 'Please answer with "y" or "n".';
160
- deleteLastLine();
161
- continue;
162
- }
163
- return await completePrompt(
164
- "confirm",
165
- false,
166
- endTitle,
167
- endTitleColor,
168
- titleTypography,
169
- titleVariant ? titleVariant : void 0,
170
- border,
171
- borderColor,
172
- action,
173
- result
174
- );
175
- }
176
- } finally {
177
- rl.close();
178
- }
179
- }
@@ -1,2 +0,0 @@
1
- import type { DatePromptOptions } from "../../types.js";
2
- export declare function datePrompt(opts: DatePromptOptions): Promise<string>;