@reliverse/rempts 1.7.61 → 1.7.63
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/bin/libs/launcher/command-runner.js +2 -2
- package/bin/libs/launcher/launcher-mod.js +69 -15
- package/bin/libs/spinner/spinner-impl.d.ts +1 -1
- package/bin/libs/spinner/spinner-impl.js +1 -1
- package/bin/libs/spinner/spinner-mod.d.ts +0 -4
- package/bin/libs/spinner/spinner-mod.js +2 -5
- package/bin/libs/utils/stream-text.js +1 -1
- package/bin/mod.d.ts +2 -2
- package/bin/mod.js +10 -4
- package/bin/types.d.ts +1 -1
- package/package.json +3 -3
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import process from "node:process";
|
|
2
|
-
import { relinka } from "@reliverse/relinka";
|
|
2
|
+
import { relinka, relinkaConfig } from "@reliverse/relinka";
|
|
3
3
|
import { reliArgParser } from "../reliarg/reliarg-mod.js";
|
|
4
4
|
export async function callCmd(command, input, options = {}) {
|
|
5
5
|
const { autoExit = false, debug = false, useLifecycleHooks = true, parserOptions = {} } = options;
|
|
6
6
|
const debugLog = (...args) => {
|
|
7
7
|
if (debug) {
|
|
8
|
-
relinka("log", "[callCmd DEBUG]", ...args);
|
|
8
|
+
void relinkaConfig().then(() => relinka("log", "[callCmd DEBUG]", ...args));
|
|
9
9
|
}
|
|
10
10
|
};
|
|
11
11
|
debugLog("Calling command with input:", input);
|
|
@@ -5,14 +5,58 @@ import { relinka, relinkaConfig, relinkaShutdown } from "@reliverse/relinka";
|
|
|
5
5
|
import path from "path";
|
|
6
6
|
import { readPackageJSON } from "pkg-types";
|
|
7
7
|
import { reliArgParser } from "../reliarg/reliarg-mod.js";
|
|
8
|
-
|
|
8
|
+
const isBunRuntime = Boolean(
|
|
9
|
+
// Prefer versions flag to avoid TS type needs
|
|
10
|
+
process?.versions?.bun || typeof globalThis.Bun !== "undefined"
|
|
11
|
+
);
|
|
12
|
+
const _pathExistsCache = /* @__PURE__ */ new Map();
|
|
13
|
+
async function pathExists(p) {
|
|
14
|
+
const cached = _pathExistsCache.get(p);
|
|
15
|
+
if (cached !== void 0) return cached;
|
|
9
16
|
try {
|
|
10
|
-
|
|
17
|
+
if (isBunRuntime) {
|
|
18
|
+
const bun = globalThis.Bun;
|
|
19
|
+
if (bun?.file) {
|
|
20
|
+
const exists = await bun.file(p).exists();
|
|
21
|
+
_pathExistsCache.set(p, exists);
|
|
22
|
+
return exists;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
await stat(p);
|
|
26
|
+
_pathExistsCache.set(p, true);
|
|
11
27
|
return true;
|
|
12
|
-
} catch (
|
|
28
|
+
} catch (_error) {
|
|
29
|
+
_pathExistsCache.set(p, false);
|
|
13
30
|
return false;
|
|
14
31
|
}
|
|
15
32
|
}
|
|
33
|
+
async function isDirectory(p) {
|
|
34
|
+
try {
|
|
35
|
+
const s = await stat(p);
|
|
36
|
+
return s.isDirectory();
|
|
37
|
+
} catch {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
let _cachedPkgJson;
|
|
42
|
+
async function readPkgJsonCached() {
|
|
43
|
+
if (_cachedPkgJson) return _cachedPkgJson;
|
|
44
|
+
try {
|
|
45
|
+
if (isBunRuntime) {
|
|
46
|
+
const bun = globalThis.Bun;
|
|
47
|
+
if (bun?.file) {
|
|
48
|
+
_cachedPkgJson = await bun.file("package.json").json();
|
|
49
|
+
} else {
|
|
50
|
+
_cachedPkgJson = await readPackageJSON();
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
_cachedPkgJson = await readPackageJSON();
|
|
54
|
+
}
|
|
55
|
+
} catch (_e) {
|
|
56
|
+
_cachedPkgJson = void 0;
|
|
57
|
+
}
|
|
58
|
+
return _cachedPkgJson;
|
|
59
|
+
}
|
|
16
60
|
function buildExampleArgs(args) {
|
|
17
61
|
const parts = [];
|
|
18
62
|
const positionalKeys = Object.keys(args || {}).filter((k) => args?.[k]?.type === "positional");
|
|
@@ -49,9 +93,15 @@ function buildExampleArgs(args) {
|
|
|
49
93
|
return parts.join(" ");
|
|
50
94
|
}
|
|
51
95
|
const isDebugMode = process.argv.includes("--debug");
|
|
96
|
+
let _relinkaConfigured = false;
|
|
97
|
+
async function ensureRelinkaConfigured() {
|
|
98
|
+
if (_relinkaConfigured) return;
|
|
99
|
+
await relinkaConfig();
|
|
100
|
+
_relinkaConfigured = true;
|
|
101
|
+
}
|
|
52
102
|
function debugLog(...args) {
|
|
53
103
|
if (isDebugMode) {
|
|
54
|
-
relinka("log", "[DEBUG]", ...args);
|
|
104
|
+
void ensureRelinkaConfigured().then(() => relinka("log", "[DEBUG]", ...args));
|
|
55
105
|
}
|
|
56
106
|
}
|
|
57
107
|
function isFlag(str) {
|
|
@@ -90,17 +140,21 @@ export function defineCommand(options) {
|
|
|
90
140
|
}
|
|
91
141
|
let _cachedDefaultCliName;
|
|
92
142
|
let _cachedDefaultCliVersion;
|
|
143
|
+
let _cachedDefaultCliDescription;
|
|
93
144
|
async function getDefaultCliNameAndVersion() {
|
|
94
145
|
if (_cachedDefaultCliName)
|
|
95
146
|
return { name: _cachedDefaultCliName, version: _cachedDefaultCliVersion };
|
|
96
147
|
try {
|
|
97
|
-
const pkg = await
|
|
148
|
+
const pkg = await readPkgJsonCached() ?? {};
|
|
98
149
|
let name = pkg.name || "cli";
|
|
99
150
|
if (name.startsWith("@")) {
|
|
100
151
|
name = name.split("/").pop() || name;
|
|
101
152
|
}
|
|
102
153
|
_cachedDefaultCliName = name;
|
|
103
154
|
_cachedDefaultCliVersion = pkg.version;
|
|
155
|
+
if (pkg.description && !_cachedDefaultCliDescription) {
|
|
156
|
+
_cachedDefaultCliDescription = pkg.description;
|
|
157
|
+
}
|
|
104
158
|
return { name, version: pkg.version };
|
|
105
159
|
} catch (_e) {
|
|
106
160
|
return { name: "cli", version: void 0 };
|
|
@@ -154,11 +208,8 @@ export async function showUsage(command, parserOptions = {}, globalCliMeta) {
|
|
|
154
208
|
if (parserOptions.metaSettings?.showDescriptionOnMain) {
|
|
155
209
|
let description = globalCliMeta?.description || command.meta?.description;
|
|
156
210
|
if (!description) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (pkg.description) description = pkg.description;
|
|
160
|
-
} catch (_e) {
|
|
161
|
-
}
|
|
211
|
+
await getDefaultCliNameAndVersion();
|
|
212
|
+
if (_cachedDefaultCliDescription) description = _cachedDefaultCliDescription;
|
|
162
213
|
}
|
|
163
214
|
if (description) {
|
|
164
215
|
relinka("log", description);
|
|
@@ -405,6 +456,7 @@ export function createCli(options, legacyParserOptions) {
|
|
|
405
456
|
const rawArgv = process.argv.slice(2);
|
|
406
457
|
const autoExit = parserOptions.autoExit !== false;
|
|
407
458
|
if (!(parserOptions.fileBased?.enable || command.commands && Object.keys(command.commands).length > 0 || command.run)) {
|
|
459
|
+
await ensureRelinkaConfigured();
|
|
408
460
|
relinka(
|
|
409
461
|
"error",
|
|
410
462
|
"Invalid CLI configuration: No file-based commands, subCommands, or run() handler are defined. This CLI will not do anything.\n\u2502 To fix: add file-based commands (./app), or provide at least one subCommand, or a run() handler."
|
|
@@ -453,6 +505,7 @@ export function createCli(options, legacyParserOptions) {
|
|
|
453
505
|
if (autoExit) process.exit(0);
|
|
454
506
|
return;
|
|
455
507
|
} catch (err) {
|
|
508
|
+
await ensureRelinkaConfigured();
|
|
456
509
|
relinka("error", "Error loading file-based subcommand:", err.message);
|
|
457
510
|
if (autoExit) process.exit(1);
|
|
458
511
|
throw err;
|
|
@@ -508,13 +561,14 @@ export function createCli(options, legacyParserOptions) {
|
|
|
508
561
|
if (autoExit) process.exit(0);
|
|
509
562
|
return;
|
|
510
563
|
} catch (err) {
|
|
564
|
+
await ensureRelinkaConfigured();
|
|
511
565
|
relinka("error", "Error running subcommand:", err.message);
|
|
512
566
|
if (autoExit) process.exit(1);
|
|
513
567
|
throw err;
|
|
514
568
|
}
|
|
515
569
|
}
|
|
516
570
|
}
|
|
517
|
-
await
|
|
571
|
+
await ensureRelinkaConfigured();
|
|
518
572
|
if (rawArgv[0] === "help" || checkHelp(rawArgv)) {
|
|
519
573
|
await showUsage(command, parserOptions, globalCliMeta);
|
|
520
574
|
if (autoExit) process.exit(0);
|
|
@@ -534,7 +588,7 @@ export function createCli(options, legacyParserOptions) {
|
|
|
534
588
|
await runCommandWithArgs(command, rawArgv, parserOptions, globalCliMeta);
|
|
535
589
|
} finally {
|
|
536
590
|
}
|
|
537
|
-
await relinkaShutdown();
|
|
591
|
+
if (_relinkaConfigured) await relinkaShutdown();
|
|
538
592
|
} finally {
|
|
539
593
|
if (typeof command.onLauncherExit === "function") await command.onLauncherExit();
|
|
540
594
|
}
|
|
@@ -600,7 +654,7 @@ Info for this CLI's developer: No valid command file found in ${baseDir}`
|
|
|
600
654
|
);
|
|
601
655
|
}
|
|
602
656
|
const nextDir = path.join(baseDir, args[0] || "");
|
|
603
|
-
if (await
|
|
657
|
+
if (await isDirectory(nextDir)) {
|
|
604
658
|
return resolveCmdPath(nextDir, args.slice(1));
|
|
605
659
|
}
|
|
606
660
|
const possibleFiles = [path.join(baseDir, "cmd.js"), path.join(baseDir, "cmd.ts")];
|
|
@@ -616,7 +670,7 @@ Info for this CLI's developer: No valid command file found in ${baseDir}`
|
|
|
616
670
|
);
|
|
617
671
|
}
|
|
618
672
|
const startDir = path.join(fileCmdOpts.cmdsRootPath, subName);
|
|
619
|
-
if (!await
|
|
673
|
+
if (!await isDirectory(startDir)) {
|
|
620
674
|
const attempted = [subName, ...argv].join(" ");
|
|
621
675
|
const expectedPath = path.relative(
|
|
622
676
|
process.cwd(),
|
|
@@ -930,7 +984,7 @@ async function resolveFileBasedCommandPath(cmdsRoot, argv) {
|
|
|
930
984
|
let leftover = [...argv];
|
|
931
985
|
while (leftover.length > 0 && leftover[0] && !isFlag(leftover[0])) {
|
|
932
986
|
const nextDir = path.join(currentDir, leftover[0]);
|
|
933
|
-
if (await
|
|
987
|
+
if (await isDirectory(nextDir)) {
|
|
934
988
|
currentDir = nextDir;
|
|
935
989
|
pathSegments.push(leftover[0]);
|
|
936
990
|
leftover = leftover.slice(1);
|
|
@@ -63,7 +63,7 @@ export declare class Ora {
|
|
|
63
63
|
info(text?: string): this;
|
|
64
64
|
stopAndPersist(options?: StopAndPersistOptions): this;
|
|
65
65
|
}
|
|
66
|
-
export
|
|
66
|
+
export declare function ora(options?: string | OraOptions): Ora;
|
|
67
67
|
export declare function oraPromise<T>(action: ((spinner: Ora) => Promise<T>) | Promise<T>, options?: string | (OraPromiseOptions<T> & {
|
|
68
68
|
text?: string | undefined;
|
|
69
69
|
})): Promise<T>;
|
|
@@ -6,9 +6,6 @@
|
|
|
6
6
|
* Defaults:
|
|
7
7
|
* - spinner: "dots", color: "cyan", hideCursor: true, discardStdin: true, stream defaults to stderr.
|
|
8
8
|
*/
|
|
9
|
-
import prettyBytes from "pretty-bytes";
|
|
10
|
-
import prettyMilliseconds from "pretty-ms";
|
|
11
|
-
import { randomSpinner } from "./spinner-impl";
|
|
12
9
|
import { type Ora, type OraOptions, type OraPromiseOptions } from "./spinner-impl.js";
|
|
13
10
|
export interface SpinnerOptions extends Omit<OraOptions, "text"> {
|
|
14
11
|
readonly respectEnv?: boolean;
|
|
@@ -168,4 +165,3 @@ export declare function createTransferSpinner(operation: string, options?: Spinn
|
|
|
168
165
|
complete: (message?: string, totalBytesTransferred?: number) => void;
|
|
169
166
|
error: (error: Error | string) => void;
|
|
170
167
|
};
|
|
171
|
-
export { randomSpinner, prettyBytes, prettyMilliseconds };
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { re } from "@reliverse/relico";
|
|
2
2
|
import prettyBytes from "pretty-bytes";
|
|
3
3
|
import prettyMilliseconds from "pretty-ms";
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
oraPromise
|
|
7
|
-
} from "./spinner-impl.js";
|
|
4
|
+
import { ora } from "./spinner-impl.js";
|
|
5
|
+
import { oraPromise } from "./spinner-impl.js";
|
|
8
6
|
function isColorsEnabled(isSpinnerEnabledFlag) {
|
|
9
7
|
if (process.env["CLI_NO_COLOR"] === "1") return false;
|
|
10
8
|
return isSpinnerEnabledFlag;
|
|
@@ -447,4 +445,3 @@ export function createTransferSpinner(operation, options) {
|
|
|
447
445
|
}
|
|
448
446
|
};
|
|
449
447
|
}
|
|
450
|
-
export { randomSpinner, prettyBytes, prettyMilliseconds };
|
|
@@ -6,7 +6,7 @@ import wrapAnsi from "wrap-ansi";
|
|
|
6
6
|
import { toBaseColor } from "../msg-fmt/colors.js";
|
|
7
7
|
import { colorMap } from "../msg-fmt/mapping.js";
|
|
8
8
|
import { msg } from "../msg-fmt/messages.js";
|
|
9
|
-
import ora from "../spinner/spinner-impl.js";
|
|
9
|
+
import { ora } from "../spinner/spinner-impl.js";
|
|
10
10
|
function getTerminalWidth() {
|
|
11
11
|
return terminalSize().columns;
|
|
12
12
|
}
|
package/bin/mod.d.ts
CHANGED
|
@@ -37,9 +37,9 @@ export { select, selectSimple } from "./libs/select/select-alias";
|
|
|
37
37
|
export { selectPrompt } from "./libs/select/select-prompt";
|
|
38
38
|
export { togglePrompt } from "./libs/select/toggle-prompt";
|
|
39
39
|
export type { Ora, OraOptions, OraPromiseOptions, StopAndPersistOptions, } from "./libs/spinner/spinner-impl";
|
|
40
|
-
export { error, info, oraPromise, spinners, success, warning } from "./libs/spinner/spinner-impl";
|
|
40
|
+
export { error, info, ora, oraPromise, randomSpinner, spinners, success, warning, } from "./libs/spinner/spinner-impl";
|
|
41
41
|
export type { FileProgressOptions, SimpleSpinner, SpinnerGroupOptions, SpinnerOptions, } from "./libs/spinner/spinner-mod";
|
|
42
|
-
export { createBuildSpinner, createFileProgressSpinner, createMultiStepSpinner, createSpinner, createSpinnerGroup, createTimedSpinner, createTransferSpinner, defaultSpinnerOptions, formatSpinnerBytes, formatSpinnerElapsed, formatSpinnerTiming, isSpinnerEnabled, isSpinnerRunning,
|
|
42
|
+
export { createBuildSpinner, createFileProgressSpinner, createMultiStepSpinner, createSpinner, createSpinnerGroup, createTimedSpinner, createTransferSpinner, defaultSpinnerOptions, formatSpinnerBytes, formatSpinnerElapsed, formatSpinnerTiming, isSpinnerEnabled, isSpinnerRunning, safeStopSpinner, stopAndPersist, updateSpinnerText, withEnhancedSpinner, withSpinner, withSpinnerPromise, } from "./libs/spinner/spinner-mod";
|
|
43
43
|
export { colorize } from "./libs/utils/colorize";
|
|
44
44
|
export { errorHandler } from "./libs/utils/errors";
|
|
45
45
|
export { preventUnsupportedTTY, preventWindowsHomeDirRoot, preventWrongTerminalSize, } from "./libs/utils/prevent";
|
package/bin/mod.js
CHANGED
|
@@ -71,7 +71,16 @@ export { numSelectPrompt } from "./libs/select/numselect-prompt.js";
|
|
|
71
71
|
export { select, selectSimple } from "./libs/select/select-alias.js";
|
|
72
72
|
export { selectPrompt } from "./libs/select/select-prompt.js";
|
|
73
73
|
export { togglePrompt } from "./libs/select/toggle-prompt.js";
|
|
74
|
-
export {
|
|
74
|
+
export {
|
|
75
|
+
error,
|
|
76
|
+
info,
|
|
77
|
+
ora,
|
|
78
|
+
oraPromise,
|
|
79
|
+
randomSpinner,
|
|
80
|
+
spinners,
|
|
81
|
+
success,
|
|
82
|
+
warning
|
|
83
|
+
} from "./libs/spinner/spinner-impl.js";
|
|
75
84
|
export {
|
|
76
85
|
createBuildSpinner,
|
|
77
86
|
createFileProgressSpinner,
|
|
@@ -86,9 +95,6 @@ export {
|
|
|
86
95
|
formatSpinnerTiming,
|
|
87
96
|
isSpinnerEnabled,
|
|
88
97
|
isSpinnerRunning,
|
|
89
|
-
prettyBytes,
|
|
90
|
-
prettyMilliseconds,
|
|
91
|
-
randomSpinner,
|
|
92
98
|
safeStopSpinner,
|
|
93
99
|
stopAndPersist,
|
|
94
100
|
updateSpinnerText,
|
package/bin/types.d.ts
CHANGED
|
@@ -114,7 +114,7 @@ export interface ProgressBar {
|
|
|
114
114
|
/**
|
|
115
115
|
* Union type for available prompt types.
|
|
116
116
|
*/
|
|
117
|
-
export type PromptType = "input" | "inputmasked" | "select" | "multiselect" | "nummultiselect" | "numselect" | "toggle" | "confirm" | "spinner" | "progressbar" | "results" | "nextsteps" | "
|
|
117
|
+
export type PromptType = "input" | "inputmasked" | "select" | "multiselect" | "nummultiselect" | "numselect" | "toggle" | "confirm" | "spinner" | "progressbar" | "results" | "nextsteps" | "date" | "end";
|
|
118
118
|
export interface ConfirmPromptOptions {
|
|
119
119
|
title?: string;
|
|
120
120
|
message?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dependencies": {
|
|
3
|
-
"@reliverse/relico": "^1.
|
|
3
|
+
"@reliverse/relico": "^1.4.0",
|
|
4
4
|
"@reliverse/relinka": "^1.6.1",
|
|
5
5
|
"@reliverse/reltime": "^1.1.1",
|
|
6
6
|
"ansi-escapes": "^7.0.0",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"pretty-ms": "^9.2.0",
|
|
16
16
|
"sisteransi": "^1.0.5",
|
|
17
17
|
"stdin-discarder": "^0.2.2",
|
|
18
|
-
"string-width": "^8.
|
|
18
|
+
"string-width": "^8.1.0",
|
|
19
19
|
"strip-ansi": "^7.1.0",
|
|
20
20
|
"terminal-size": "^4.0.0",
|
|
21
21
|
"ts-regex-builder": "^1.8.2",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"name": "@reliverse/rempts",
|
|
28
28
|
"type": "module",
|
|
29
|
-
"version": "1.7.
|
|
29
|
+
"version": "1.7.63",
|
|
30
30
|
"author": "reliverse",
|
|
31
31
|
"bugs": {
|
|
32
32
|
"email": "blefnk@gmail.com",
|