@reliverse/rempts-core 1.6.1 → 2.3.2
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/README.md +398 -102
- package/dist/cli.d.ts +32 -0
- package/dist/cli.js +731 -0
- package/dist/config-loader.d.ts +42 -0
- package/dist/config-loader.js +20 -0
- package/dist/config.d.ts +99 -0
- package/dist/config.js +188 -0
- package/dist/file-loader.d.ts +43 -0
- package/dist/file-loader.js +199 -0
- package/dist/global-flags.d.ts +36 -0
- package/dist/global-flags.js +36 -0
- package/dist/mod.d.ts +13 -0
- package/dist/mod.js +19 -0
- package/dist/parser.d.ts +6 -0
- package/dist/parser.js +137 -0
- package/dist/plugin/context.d.ts +13 -0
- package/dist/plugin/context.js +53 -0
- package/dist/plugin/create.d.ts +92 -0
- package/dist/plugin/create.js +61 -0
- package/dist/plugin/loader.d.ts +12 -0
- package/dist/plugin/loader.js +65 -0
- package/dist/plugin/manager.d.ts +53 -0
- package/dist/plugin/manager.js +135 -0
- package/dist/plugin/mod.d.ts +10 -0
- package/dist/plugin/mod.js +27 -0
- package/dist/plugin/store.d.ts +45 -0
- package/dist/plugin/store.js +60 -0
- package/dist/plugin/testing.d.ts +38 -0
- package/dist/plugin/testing.js +175 -0
- package/dist/plugin/types.d.ts +146 -0
- package/dist/tui/registry.d.ts +8 -0
- package/dist/tui/registry.js +10 -0
- package/dist/tui/types.d.ts +58 -0
- package/dist/tui/types.js +10 -0
- package/dist/types.d.ts +178 -0
- package/dist/types.js +25 -0
- package/dist/utils/logger.d.ts +10 -0
- package/dist/utils/logger.js +27 -0
- package/dist/utils/merge.d.ts +13 -0
- package/dist/utils/merge.js +25 -0
- package/dist/utils/mod.d.ts +6 -0
- package/dist/utils/mod.js +2 -0
- package/dist/utils/type-helpers.d.ts +41 -0
- package/dist/utils/type-helpers.js +0 -0
- package/dist/validation.d.ts +30 -0
- package/dist/validation.js +121 -0
- package/package.json +47 -44
- package/src/cli.ts +1049 -0
- package/src/config-loader.ts +71 -0
- package/src/config.ts +270 -0
- package/src/file-loader.ts +346 -0
- package/src/global-flags.ts +50 -0
- package/src/mod.ts +74 -0
- package/src/parser.ts +212 -0
- package/src/plugin/context.ts +88 -0
- package/src/plugin/create.ts +174 -0
- package/src/plugin/loader.ts +111 -0
- package/src/plugin/manager.ts +244 -0
- package/src/plugin/mod.ts +51 -0
- package/src/plugin/store.ts +124 -0
- package/src/plugin/testing.ts +236 -0
- package/src/plugin/types.ts +206 -0
- package/src/tui/registry.ts +22 -0
- package/src/tui/types.ts +79 -0
- package/src/types.ts +285 -0
- package/src/utils/logger.ts +43 -0
- package/src/utils/merge.ts +54 -0
- package/src/utils/mod.ts +7 -0
- package/src/utils/type-helpers.ts +151 -0
- package/src/validation.ts +177 -0
- package/LICENSE +0 -21
- package/bin/core-impl/anykey/anykey-mod.d.ts +0 -12
- package/bin/core-impl/anykey/anykey-mod.js +0 -125
- package/bin/core-impl/date/date.d.ts +0 -2
- package/bin/core-impl/date/date.js +0 -236
- package/bin/core-impl/editor/editor-mod.d.ts +0 -25
- package/bin/core-impl/editor/editor-mod.js +0 -896
- package/bin/core-impl/figures/figures-mod.d.ts +0 -233
- package/bin/core-impl/figures/figures-mod.js +0 -286
- package/bin/core-impl/figures/figures.test.d.ts +0 -1
- package/bin/core-impl/figures/figures.test.js +0 -474
- package/bin/core-impl/input/confirm-prompt.d.ts +0 -5
- package/bin/core-impl/input/confirm-prompt.js +0 -173
- package/bin/core-impl/input/input-prompt.d.ts +0 -16
- package/bin/core-impl/input/input-prompt.js +0 -370
- package/bin/core-impl/launcher/_parser.d.ts +0 -2
- package/bin/core-impl/launcher/_parser.js +0 -122
- package/bin/core-impl/launcher/_utils.d.ts +0 -8
- package/bin/core-impl/launcher/_utils.js +0 -29
- package/bin/core-impl/launcher/args.d.ts +0 -3
- package/bin/core-impl/launcher/args.js +0 -89
- package/bin/core-impl/launcher/command.d.ts +0 -8
- package/bin/core-impl/launcher/command.js +0 -68
- package/bin/core-impl/launcher/launcher-mod.d.ts +0 -8
- package/bin/core-impl/launcher/launcher-mod.js +0 -34
- package/bin/core-impl/launcher/usage.d.ts +0 -3
- package/bin/core-impl/launcher/usage.js +0 -104
- package/bin/core-impl/msg-fmt/colors.d.ts +0 -30
- package/bin/core-impl/msg-fmt/colors.js +0 -42
- package/bin/core-impl/msg-fmt/logger.d.ts +0 -17
- package/bin/core-impl/msg-fmt/logger.js +0 -106
- package/bin/core-impl/msg-fmt/mapping.d.ts +0 -3
- package/bin/core-impl/msg-fmt/mapping.js +0 -49
- package/bin/core-impl/msg-fmt/messages.d.ts +0 -35
- package/bin/core-impl/msg-fmt/messages.js +0 -314
- package/bin/core-impl/msg-fmt/terminal.d.ts +0 -15
- package/bin/core-impl/msg-fmt/terminal.js +0 -59
- package/bin/core-impl/msg-fmt/variants.d.ts +0 -11
- package/bin/core-impl/msg-fmt/variants.js +0 -52
- package/bin/core-impl/next-steps/next-steps.d.ts +0 -14
- package/bin/core-impl/next-steps/next-steps.js +0 -24
- package/bin/core-impl/number/number-mod.d.ts +0 -28
- package/bin/core-impl/number/number-mod.js +0 -197
- package/bin/core-impl/results/results.d.ts +0 -7
- package/bin/core-impl/results/results.js +0 -27
- package/bin/core-impl/select/multiselect-prompt.d.ts +0 -2
- package/bin/core-impl/select/multiselect-prompt.js +0 -341
- package/bin/core-impl/select/nummultiselect-prompt.d.ts +0 -6
- package/bin/core-impl/select/nummultiselect-prompt.js +0 -105
- package/bin/core-impl/select/numselect-prompt.d.ts +0 -7
- package/bin/core-impl/select/numselect-prompt.js +0 -115
- package/bin/core-impl/select/select-prompt.d.ts +0 -33
- package/bin/core-impl/select/select-prompt.js +0 -302
- package/bin/core-impl/select/toggle-prompt.d.ts +0 -5
- package/bin/core-impl/select/toggle-prompt.js +0 -208
- package/bin/core-impl/st-end/end.d.ts +0 -2
- package/bin/core-impl/st-end/end.js +0 -42
- package/bin/core-impl/st-end/start.d.ts +0 -17
- package/bin/core-impl/st-end/start.js +0 -66
- package/bin/core-impl/task/progress.d.ts +0 -2
- package/bin/core-impl/task/progress.js +0 -57
- package/bin/core-impl/task/spinner.d.ts +0 -15
- package/bin/core-impl/task/spinner.js +0 -110
- package/bin/core-impl/utils/colorize.d.ts +0 -2
- package/bin/core-impl/utils/colorize.js +0 -134
- package/bin/core-impl/utils/errors.d.ts +0 -1
- package/bin/core-impl/utils/errors.js +0 -15
- package/bin/core-impl/utils/prevent.d.ts +0 -10
- package/bin/core-impl/utils/prevent.js +0 -69
- package/bin/core-impl/utils/prompt-end.d.ts +0 -8
- package/bin/core-impl/utils/prompt-end.js +0 -33
- package/bin/core-impl/utils/stream-text.d.ts +0 -18
- package/bin/core-impl/utils/stream-text.js +0 -136
- package/bin/core-impl/utils/system.d.ts +0 -6
- package/bin/core-impl/utils/system.js +0 -7
- package/bin/core-impl/utils/validate.d.ts +0 -22
- package/bin/core-impl/utils/validate.js +0 -17
- package/bin/core-impl/visual/animate/animate.d.ts +0 -14
- package/bin/core-impl/visual/animate/animate.js +0 -64
- package/bin/core-impl/visual/ascii-art/ascii-art.d.ts +0 -6
- package/bin/core-impl/visual/ascii-art/ascii-art.js +0 -12
- package/bin/core-types.d.ts +0 -434
- package/bin/main.d.ts +0 -41
- package/bin/main.js +0 -96
- /package/{bin/core-types.js → dist/plugin/types.js} +0 -0
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { ArgsDef, CommandDef } from "../../core-types.js";
|
|
2
|
-
import { showUsage as _showUsage } from "./usage.js";
|
|
3
|
-
export type RunMainOptions = {
|
|
4
|
-
rawArgs?: string[];
|
|
5
|
-
showUsage?: typeof _showUsage;
|
|
6
|
-
};
|
|
7
|
-
export declare function runMain<T extends ArgsDef = ArgsDef>(cmd: CommandDef<T>, opts?: RunMainOptions): Promise<void>;
|
|
8
|
-
export declare function createMain<T extends ArgsDef = ArgsDef>(cmd: CommandDef<T>): (opts?: RunMainOptions) => Promise<void>;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { relinka } from "@reliverse/relinka";
|
|
2
|
-
import { CLIError } from "./_utils.js";
|
|
3
|
-
import { resolveSubCommand, runCommand } from "./command.js";
|
|
4
|
-
import { showUsage as _showUsage } from "./usage.js";
|
|
5
|
-
export async function runMain(cmd, opts = {}) {
|
|
6
|
-
const rawArgs = opts.rawArgs || process.argv.slice(2);
|
|
7
|
-
const showUsage = opts.showUsage || _showUsage;
|
|
8
|
-
try {
|
|
9
|
-
if (rawArgs.includes("--help") || rawArgs.includes("-h")) {
|
|
10
|
-
await showUsage(...await resolveSubCommand(cmd, rawArgs));
|
|
11
|
-
process.exit(0);
|
|
12
|
-
} else if (rawArgs.length === 1 && rawArgs[0] === "--version") {
|
|
13
|
-
const meta = typeof cmd.meta === "function" ? await cmd.meta() : await cmd.meta;
|
|
14
|
-
if (!meta?.version) {
|
|
15
|
-
throw new CLIError("No version specified", "E_NO_VERSION");
|
|
16
|
-
}
|
|
17
|
-
relinka("info", meta.version);
|
|
18
|
-
} else {
|
|
19
|
-
await runCommand(cmd, { rawArgs });
|
|
20
|
-
}
|
|
21
|
-
} catch (error) {
|
|
22
|
-
const isCLIError = error instanceof CLIError;
|
|
23
|
-
if (isCLIError) {
|
|
24
|
-
await showUsage(...await resolveSubCommand(cmd, rawArgs));
|
|
25
|
-
relinka("error", error.message);
|
|
26
|
-
} else {
|
|
27
|
-
relinka("error", error, "\n");
|
|
28
|
-
}
|
|
29
|
-
process.exit(1);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
export function createMain(cmd) {
|
|
33
|
-
return (opts = {}) => runMain(cmd, opts);
|
|
34
|
-
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { ArgsDef, CommandDef } from "../../core-types.js";
|
|
2
|
-
export declare function showUsage<T extends ArgsDef = ArgsDef>(cmd: CommandDef<T>, parent?: CommandDef<T>): Promise<void>;
|
|
3
|
-
export declare function renderUsage<T extends ArgsDef = ArgsDef>(cmd: CommandDef<T>, parent?: CommandDef<T>): Promise<string>;
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { re } from "@reliverse/relico";
|
|
2
|
-
import { relinka } from "@reliverse/relinka";
|
|
3
|
-
import { formatLineColumns, resolveValue } from "./_utils.js";
|
|
4
|
-
import { resolveArgs } from "./args.js";
|
|
5
|
-
export async function showUsage(cmd, parent) {
|
|
6
|
-
try {
|
|
7
|
-
relinka("info", await renderUsage(cmd, parent) + "\n");
|
|
8
|
-
} catch (error) {
|
|
9
|
-
relinka("error", String(error));
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
const negativePrefixRe = /^no[-A-Z]/;
|
|
13
|
-
export async function renderUsage(cmd, parent) {
|
|
14
|
-
const cmdMeta = await resolveValue(cmd.meta || {});
|
|
15
|
-
const cmdArgs = resolveArgs(await resolveValue(cmd.args || {}));
|
|
16
|
-
const parentMeta = await resolveValue(parent?.meta || {});
|
|
17
|
-
const commandName = (parentMeta.name ? `${parentMeta.name} ` : "") + (cmdMeta.name || process.argv[1]);
|
|
18
|
-
const argLines = [];
|
|
19
|
-
const posLines = [];
|
|
20
|
-
const commandsLines = [];
|
|
21
|
-
const usageLine = [];
|
|
22
|
-
for (const arg of cmdArgs) {
|
|
23
|
-
if (arg.type === "positional") {
|
|
24
|
-
const name = arg.name.toUpperCase();
|
|
25
|
-
const isRequired = arg.required !== false && arg.default === void 0;
|
|
26
|
-
const defaultHint = arg.default ? `="${arg.default}"` : "";
|
|
27
|
-
posLines.push([
|
|
28
|
-
// biome-ignore lint/style/useTemplate: <explanation>
|
|
29
|
-
"`" + name + defaultHint + "`",
|
|
30
|
-
arg.description || "",
|
|
31
|
-
arg.valueHint ? `<${arg.valueHint}>` : ""
|
|
32
|
-
]);
|
|
33
|
-
usageLine.push(isRequired ? `<${name}>` : `[${name}]`);
|
|
34
|
-
} else {
|
|
35
|
-
const isRequired = arg.required === true && arg.default === void 0;
|
|
36
|
-
const argStr = [...(arg.alias || []).map((a) => `-${a}`), `--${arg.name}`].join(", ") + (arg.type === "string" && (arg.valueHint || arg.default) ? `=${arg.valueHint ? `<${arg.valueHint}>` : `"${arg.default || ""}"`}` : "") + (arg.type === "enum" && arg.options ? `=<${arg.options.join("|")}>` : "");
|
|
37
|
-
argLines.push([
|
|
38
|
-
// biome-ignore lint/style/useTemplate: <explanation>
|
|
39
|
-
"`" + argStr + (isRequired ? " (required)" : "") + "`",
|
|
40
|
-
arg.description || ""
|
|
41
|
-
]);
|
|
42
|
-
if (arg.type === "boolean" && (arg.default === true || arg.negativeDescription) && !negativePrefixRe.test(arg.name)) {
|
|
43
|
-
const negativeArgStr = [
|
|
44
|
-
...(arg.alias || []).map((a) => `--no-${a}`),
|
|
45
|
-
`--no-${arg.name}`
|
|
46
|
-
].join(", ");
|
|
47
|
-
argLines.push([
|
|
48
|
-
// biome-ignore lint/style/useTemplate: <explanation>
|
|
49
|
-
"`" + negativeArgStr + (isRequired ? " (required)" : "") + "`",
|
|
50
|
-
arg.negativeDescription || ""
|
|
51
|
-
]);
|
|
52
|
-
}
|
|
53
|
-
if (isRequired) {
|
|
54
|
-
usageLine.push(argStr);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
if (cmd.subCommands) {
|
|
59
|
-
const commandNames = [];
|
|
60
|
-
const subCommands = await resolveValue(cmd.subCommands);
|
|
61
|
-
for (const [name, sub] of Object.entries(subCommands)) {
|
|
62
|
-
const subCmd = await resolveValue(sub);
|
|
63
|
-
const meta = await resolveValue(subCmd?.meta);
|
|
64
|
-
if (meta?.hidden) {
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
commandsLines.push([`\`${name}\``, meta?.description || ""]);
|
|
68
|
-
commandNames.push(name);
|
|
69
|
-
}
|
|
70
|
-
usageLine.push(commandNames.join("|"));
|
|
71
|
-
}
|
|
72
|
-
const usageLines = [];
|
|
73
|
-
const version = cmdMeta.version || parentMeta.version;
|
|
74
|
-
usageLines.push(
|
|
75
|
-
re.gray(
|
|
76
|
-
`${cmdMeta.description} (${commandName + (version ? ` v${version}` : "")})`
|
|
77
|
-
),
|
|
78
|
-
""
|
|
79
|
-
);
|
|
80
|
-
const hasOptions = argLines.length > 0 || posLines.length > 0;
|
|
81
|
-
usageLines.push(
|
|
82
|
-
`${re.underline(re.bold("USAGE"))} \`${commandName}${hasOptions ? " [OPTIONS]" : ""} ${usageLine.join(" ")}\``,
|
|
83
|
-
""
|
|
84
|
-
);
|
|
85
|
-
if (posLines.length > 0) {
|
|
86
|
-
usageLines.push(re.underline(re.bold("ARGUMENTS")), "");
|
|
87
|
-
usageLines.push(formatLineColumns(posLines, " "));
|
|
88
|
-
usageLines.push("");
|
|
89
|
-
}
|
|
90
|
-
if (argLines.length > 0) {
|
|
91
|
-
usageLines.push(re.underline(re.bold("OPTIONS")), "");
|
|
92
|
-
usageLines.push(formatLineColumns(argLines, " "));
|
|
93
|
-
usageLines.push("");
|
|
94
|
-
}
|
|
95
|
-
if (commandsLines.length > 0) {
|
|
96
|
-
usageLines.push(re.underline(re.bold("COMMANDS")), "");
|
|
97
|
-
usageLines.push(formatLineColumns(commandsLines, " "));
|
|
98
|
-
usageLines.push(
|
|
99
|
-
"",
|
|
100
|
-
`Use \`${commandName} <command> --help\` for more information about a command.`
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
return usageLines.filter((l) => typeof l === "string").join("\n");
|
|
104
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { ColorName, OutputColor, StandardColor } from "../../core-types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Maps complex colors (gradients, bright, background) to standard terminal colors.
|
|
4
|
-
* Used by ora spinners and other terminal utilities that only support basic colors.
|
|
5
|
-
*
|
|
6
|
-
* Handles:
|
|
7
|
-
* - Gradient colors -> solid colors (e.g., retroGradient -> cyan)
|
|
8
|
-
* - Bright colors -> base colors (e.g., redBright -> red)
|
|
9
|
-
* - Background colors -> foreground colors (e.g., bgRed -> red)
|
|
10
|
-
* - Special colors -> undefined (reset, inverse, dim, none)
|
|
11
|
-
*
|
|
12
|
-
* @param color The complex color to convert
|
|
13
|
-
* @returns A standard terminal color or undefined for special colors
|
|
14
|
-
*/
|
|
15
|
-
export declare function toBaseColor(color?: ColorName): StandardColor | undefined;
|
|
16
|
-
/**
|
|
17
|
-
* Maps any color type to a standard solid color for consistent display.
|
|
18
|
-
* Similar to toBaseColor but always returns a color (never undefined).
|
|
19
|
-
*
|
|
20
|
-
* Handles:
|
|
21
|
-
* - Gradient colors -> solid colors (e.g., retroGradient -> cyan)
|
|
22
|
-
* - Bright colors -> base colors (e.g., redBright -> red)
|
|
23
|
-
* - Background colors -> foreground colors (e.g., bgRed -> red)
|
|
24
|
-
* - Special colors (reset, inverse, none) -> dim
|
|
25
|
-
* - Undefined -> dim
|
|
26
|
-
*
|
|
27
|
-
* @param color The color to convert
|
|
28
|
-
* @returns A standard terminal color, defaulting to "dim" for special cases
|
|
29
|
-
*/
|
|
30
|
-
export declare function toSolidColor(color?: ColorName): OutputColor;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
const GRADIENT_COLOR_MAP = {
|
|
2
|
-
retroGradient: "cyan",
|
|
3
|
-
viceGradient: "green",
|
|
4
|
-
gradientGradient: "blue",
|
|
5
|
-
rainbowGradient: "blue",
|
|
6
|
-
cristalGradient: "blue",
|
|
7
|
-
mindGradient: "blue",
|
|
8
|
-
passionGradient: "blue"
|
|
9
|
-
};
|
|
10
|
-
const SPECIAL_COLORS = ["reset", "inverse", "none"];
|
|
11
|
-
function stripBrightModifier(color) {
|
|
12
|
-
return color.replace("Bright", "");
|
|
13
|
-
}
|
|
14
|
-
function stripBgModifier(color) {
|
|
15
|
-
return color.replace("bg", "").toLowerCase();
|
|
16
|
-
}
|
|
17
|
-
function stripColorModifiers(color) {
|
|
18
|
-
if (color.includes("Bright")) {
|
|
19
|
-
return stripBrightModifier(color);
|
|
20
|
-
}
|
|
21
|
-
if (color.startsWith("bg")) {
|
|
22
|
-
return stripBgModifier(color);
|
|
23
|
-
}
|
|
24
|
-
return color;
|
|
25
|
-
}
|
|
26
|
-
export function toBaseColor(color) {
|
|
27
|
-
if (!color || color === "dim" || SPECIAL_COLORS.includes(color)) {
|
|
28
|
-
return void 0;
|
|
29
|
-
}
|
|
30
|
-
if (color in GRADIENT_COLOR_MAP) {
|
|
31
|
-
return GRADIENT_COLOR_MAP[color];
|
|
32
|
-
}
|
|
33
|
-
if (color.includes("Bright") || color.startsWith("bg")) {
|
|
34
|
-
const baseColor = stripColorModifiers(color);
|
|
35
|
-
return baseColor;
|
|
36
|
-
}
|
|
37
|
-
return color;
|
|
38
|
-
}
|
|
39
|
-
export function toSolidColor(color) {
|
|
40
|
-
const baseColor = toBaseColor(color);
|
|
41
|
-
return baseColor ?? "dim";
|
|
42
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { AllKinds } from "../../core-types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Logs messages with configurable styling and formatting.
|
|
4
|
-
* Doesn't support streaming functionality.
|
|
5
|
-
*/
|
|
6
|
-
export declare function relinkaByRemptsDeprecated(kind: AllKinds, title: string, content?: string, hint?: string): void;
|
|
7
|
-
/**
|
|
8
|
-
* Asynchronous version of relinka that supports streaming functionality.
|
|
9
|
-
* Use this when you want animated text output with optional spinner.
|
|
10
|
-
*
|
|
11
|
-
* Streaming is controlled by the streamOpts parameter:
|
|
12
|
-
* - Use { useSpinner: true } for spinner animation
|
|
13
|
-
* - Use { delay: number } for character-by-character streaming
|
|
14
|
-
* - Content and hint are optional regardless of streaming
|
|
15
|
-
*/
|
|
16
|
-
export declare const relinkaAsyncByRemptsDeprecated: (kind: AllKinds, title: string, content?: string, hint?: string, streamOpts?: any) => Promise<void>;
|
|
17
|
-
export declare const throwError: (error: unknown) => never;
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
streamText,
|
|
3
|
-
streamTextWithSpinner
|
|
4
|
-
} from "../utils/stream-text.js";
|
|
5
|
-
import { toSolidColor } from "./colors.js";
|
|
6
|
-
import { msg } from "./messages.js";
|
|
7
|
-
const verboseLogging = false;
|
|
8
|
-
const MESSAGE_CONFIGS = {
|
|
9
|
-
log: {
|
|
10
|
-
type: "M_INFO",
|
|
11
|
-
titleColor: "retroGradient",
|
|
12
|
-
titleTypography: "bold"
|
|
13
|
-
},
|
|
14
|
-
info: {
|
|
15
|
-
type: "M_INFO",
|
|
16
|
-
titleColor: "retroGradient",
|
|
17
|
-
titleTypography: "bold"
|
|
18
|
-
},
|
|
19
|
-
success: {
|
|
20
|
-
type: "M_INFO",
|
|
21
|
-
titleColor: "viceGradient",
|
|
22
|
-
titleTypography: "bold"
|
|
23
|
-
},
|
|
24
|
-
warn: {
|
|
25
|
-
type: "M_ERROR",
|
|
26
|
-
titleColor: "yellowBright",
|
|
27
|
-
titleTypography: "bold"
|
|
28
|
-
},
|
|
29
|
-
error: {
|
|
30
|
-
type: "M_ERROR",
|
|
31
|
-
titleColor: "yellowBright",
|
|
32
|
-
titleTypography: "bold"
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
export function relinkaByRemptsDeprecated(kind, title, content, hint) {
|
|
36
|
-
const isVerbose = kind.endsWith("-verbose");
|
|
37
|
-
const baseKind = isVerbose ? kind.replace("-verbose", "") : kind;
|
|
38
|
-
if (isVerbose && !verboseLogging) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
const config = MESSAGE_CONFIGS[baseKind];
|
|
42
|
-
msg({
|
|
43
|
-
...config,
|
|
44
|
-
title: isVerbose ? `[debug] ${title}` : title,
|
|
45
|
-
content: content ?? "",
|
|
46
|
-
contentColor: "dim",
|
|
47
|
-
contentTypography: "italic",
|
|
48
|
-
hint: hint ?? ""
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
export const relinkaAsyncByRemptsDeprecated = async (kind, title, content, hint, streamOpts) => {
|
|
52
|
-
const isVerbose = kind.endsWith("-verbose");
|
|
53
|
-
const baseKind = isVerbose ? kind.replace("-verbose", "") : kind;
|
|
54
|
-
if (isVerbose && !verboseLogging) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
const config = MESSAGE_CONFIGS[baseKind];
|
|
58
|
-
if (!streamOpts) {
|
|
59
|
-
msg({
|
|
60
|
-
...config,
|
|
61
|
-
title: isVerbose ? `[debug] ${title}` : title,
|
|
62
|
-
content: content ?? "",
|
|
63
|
-
contentColor: "dim",
|
|
64
|
-
contentTypography: "italic",
|
|
65
|
-
hint: hint ?? ""
|
|
66
|
-
});
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
const titleText = isVerbose ? `[debug] ${title}` : title;
|
|
70
|
-
if (streamOpts.useSpinner) {
|
|
71
|
-
await streamTextWithSpinner({
|
|
72
|
-
text: titleText,
|
|
73
|
-
color: toSolidColor(config.titleColor),
|
|
74
|
-
delay: streamOpts.delay,
|
|
75
|
-
spinnerFrames: streamOpts.spinnerFrames,
|
|
76
|
-
spinnerDelay: streamOpts.spinnerDelay
|
|
77
|
-
});
|
|
78
|
-
} else {
|
|
79
|
-
await streamText({
|
|
80
|
-
text: titleText,
|
|
81
|
-
color: toSolidColor(config.titleColor),
|
|
82
|
-
delay: streamOpts.delay
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
if (content) {
|
|
86
|
-
await streamText({
|
|
87
|
-
text: content,
|
|
88
|
-
color: toSolidColor(config.contentColor) ?? "dim",
|
|
89
|
-
delay: streamOpts.delay
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
if (hint) {
|
|
93
|
-
await streamText({
|
|
94
|
-
text: hint,
|
|
95
|
-
color: "dim",
|
|
96
|
-
delay: streamOpts.delay
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
export const throwError = (error) => {
|
|
101
|
-
msg({
|
|
102
|
-
type: "M_ERROR",
|
|
103
|
-
title: error instanceof Error ? `\u{1F914} Failed to set up the project: ${error.message}` : "\u{1F914} An unknown error occurred."
|
|
104
|
-
});
|
|
105
|
-
process.exit(1);
|
|
106
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { re } from "@reliverse/relico";
|
|
2
|
-
import gradient, { cristal, mind, passion, retro, vice } from "gradient-string";
|
|
3
|
-
import { rainbow } from "gradient-string";
|
|
4
|
-
export const colorMap = {
|
|
5
|
-
// @reliverse/relico
|
|
6
|
-
none: (text) => text,
|
|
7
|
-
reset: re.reset,
|
|
8
|
-
bgCyan: re.bgCyan,
|
|
9
|
-
bgCyanBright: re.bgCyanBright,
|
|
10
|
-
black: re.black,
|
|
11
|
-
blue: re.blue,
|
|
12
|
-
blueBright: re.blueBright,
|
|
13
|
-
cyan: re.cyan,
|
|
14
|
-
cyanBright: re.cyanBright,
|
|
15
|
-
dim: re.dim,
|
|
16
|
-
gray: re.gray,
|
|
17
|
-
green: re.green,
|
|
18
|
-
greenBright: re.greenBright,
|
|
19
|
-
inverse: (text) => re.bold(re.inverse(text)),
|
|
20
|
-
magenta: re.magenta,
|
|
21
|
-
magentaBright: re.magentaBright,
|
|
22
|
-
red: re.red,
|
|
23
|
-
redBright: re.redBright,
|
|
24
|
-
white: re.white,
|
|
25
|
-
yellow: re.yellow,
|
|
26
|
-
yellowBright: re.yellowBright,
|
|
27
|
-
// gradient-string
|
|
28
|
-
cristalGradient: cristal,
|
|
29
|
-
gradientGradient: gradient([
|
|
30
|
-
"red",
|
|
31
|
-
"yellow",
|
|
32
|
-
"green",
|
|
33
|
-
"cyan",
|
|
34
|
-
"blue",
|
|
35
|
-
"magenta"
|
|
36
|
-
]),
|
|
37
|
-
mindGradient: mind,
|
|
38
|
-
passionGradient: passion,
|
|
39
|
-
rainbowGradient: rainbow,
|
|
40
|
-
retroGradient: retro,
|
|
41
|
-
viceGradient: vice
|
|
42
|
-
};
|
|
43
|
-
export const typographyMap = {
|
|
44
|
-
none: (text) => text,
|
|
45
|
-
bold: re.bold,
|
|
46
|
-
italic: re.italic,
|
|
47
|
-
strikethrough: re.strikethrough,
|
|
48
|
-
underline: re.underline
|
|
49
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { ColorName, FmtMsgOptions, Symbols } from "../../core-types.js";
|
|
2
|
-
export declare const symbols: Symbols;
|
|
3
|
-
/**
|
|
4
|
-
* Returns a colored vertical bar symbol. Prevents gradient colors for bars.
|
|
5
|
-
*/
|
|
6
|
-
export declare const bar: ({ borderColor, }?: {
|
|
7
|
-
borderColor?: any;
|
|
8
|
-
}) => string;
|
|
9
|
-
/**
|
|
10
|
-
* Main formatter function: builds the final text output based on FmtMsgOptions.
|
|
11
|
-
*/
|
|
12
|
-
export declare function fmt(opts: FmtMsgOptions): {
|
|
13
|
-
text: string;
|
|
14
|
-
lineCount: number;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Logs a formatted message to the console and records how many lines it occupies.
|
|
18
|
-
*/
|
|
19
|
-
export declare function msg(opts: FmtMsgOptions): void;
|
|
20
|
-
/**
|
|
21
|
-
* Undo the last printed message by deleting its lines from the terminal.
|
|
22
|
-
* @param count How many messages to undo. Defaults to 1.
|
|
23
|
-
*/
|
|
24
|
-
export declare function msgUndo(count?: number): void;
|
|
25
|
-
/**
|
|
26
|
-
* Undo all printed messages so far.
|
|
27
|
-
*/
|
|
28
|
-
export declare function msgUndoAll(): void;
|
|
29
|
-
/**
|
|
30
|
-
* Prints: "│ <text>" (two spaces after the bar).
|
|
31
|
-
* If text is empty, it just prints "│".
|
|
32
|
-
* If indent is 1, it prints "│ <text>" (one space).
|
|
33
|
-
* If indent is 2, it prints "│ <text>" (two spaces), etc.
|
|
34
|
-
*/
|
|
35
|
-
export declare function printLineBar(text: string, indent?: number): void;
|