| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.formatAuthStatusMessage = formatAuthStatusMessage; | ||
| exports.formatExchangeStatusMessage = formatExchangeStatusMessage; | ||
| exports.formatOutcomeMessage = formatOutcomeMessage; | ||
| const color_js_1 = require("./colors.js"); | ||
| function colorForOptions(options = {}) { | ||
| return (0, color_js_1.createColor)({ | ||
| env: options.env, | ||
| json: Boolean(options.flags?.json), | ||
| stream: options.stream ?? process.stdout, | ||
| }); | ||
| } | ||
| function colorFirstLine(message, kind, options = {}) { | ||
| const color = colorForOptions(options); | ||
| const lines = String(message).split("\n"); | ||
| lines[0] = color[kind](lines[0]); | ||
| return lines.join("\n"); | ||
| } | ||
| function formatOutcomeMessage(message, options = {}) { | ||
| return /^(No |.*not configured)/i.test(message) | ||
| ? colorFirstLine(message, "warning", options) | ||
| : colorFirstLine(message, "success", options); | ||
| } | ||
| function formatAuthStatusMessage(message, options = {}) { | ||
| if (/not configured/i.test(message)) { | ||
| const color = colorForOptions(options); | ||
| const lines = String(message).split("\n"); | ||
| lines[0] = color.warning(lines[0]); | ||
| if (lines[1]) | ||
| lines[1] = color.muted(lines[1]); | ||
| return lines.join("\n"); | ||
| } | ||
| return colorFirstLine(message, "success", options); | ||
| } | ||
| function formatExchangeStatusMessage(message, options = {}) { | ||
| const color = colorForOptions(options); | ||
| const lines = String(message).split("\n"); | ||
| if (/not configured/i.test(lines[0] ?? "")) { | ||
| lines[0] = color.warning(lines[0]); | ||
| return lines.join("\n"); | ||
| } | ||
| if (/configured via/i.test(lines[0] ?? "")) { | ||
| lines[0] = color.success(lines[0]); | ||
| return lines.join("\n"); | ||
| } | ||
| if (/Stored exchange credentials|Environment exchange credential vars/i.test(message)) { | ||
| return lines.map((line) => /^(Stored exchange credentials|Environment exchange credential vars):$/.test(line) | ||
| ? color.info(line) | ||
| : /^none$/.test(line) | ||
| ? color.muted(line) | ||
| : line).join("\n"); | ||
| } | ||
| return message; | ||
| } |
+100
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.ANSI_PATTERN = void 0; | ||
| exports.shouldUseColor = shouldUseColor; | ||
| exports.createColorizer = createColorizer; | ||
| exports.createColor = createColor; | ||
| exports.semanticColor = semanticColor; | ||
| exports.colorize = semanticColor; | ||
| exports.stripAnsi = stripAnsi; | ||
| exports.ANSI_PATTERN = /\x1B\[[0-?]*[ -/]*[@-~]/g; | ||
| const ANSI = { | ||
| bold: ["\x1b[1m", "\x1b[22m"], | ||
| dim: ["\x1b[2m", "\x1b[22m"], | ||
| red: ["\x1b[31m", "\x1b[39m"], | ||
| green: ["\x1b[32m", "\x1b[39m"], | ||
| yellow: ["\x1b[33m", "\x1b[39m"], | ||
| blue: ["\x1b[34m", "\x1b[39m"], | ||
| cyan: ["\x1b[36m", "\x1b[39m"], | ||
| }; | ||
| const SEMANTIC = { | ||
| command: "cyan", | ||
| error: "red", | ||
| info: "cyan", | ||
| label: "yellow", | ||
| muted: "dim", | ||
| success: "green", | ||
| url: "cyan", | ||
| warning: "yellow", | ||
| }; | ||
| function envHas(env, key) { | ||
| return Object.prototype.hasOwnProperty.call(env, key); | ||
| } | ||
| function forcedColor(env) { | ||
| if (!envHas(env, "FORCE_COLOR")) return undefined; | ||
| const value = String(env.FORCE_COLOR ?? "").trim().toLowerCase(); | ||
| if (value === "0" || value === "false" || value === "no") return false; | ||
| return true; | ||
| } | ||
| function shouldUseColor(options = {}) { | ||
| if (typeof options === "boolean") return options; | ||
| if (options.json || options.flags?.json || options.enabled === false) return false; | ||
| const env = options.env ?? process.env; | ||
| if (envHas(env, "NO_COLOR")) return false; | ||
| const forced = forcedColor(env); | ||
| if (forced !== undefined) return forced; | ||
| const stream = options.stream ?? process.stdout; | ||
| return Boolean(stream?.isTTY); | ||
| } | ||
| function wrap(enabled, pair, value) { | ||
| const text = String(value); | ||
| return enabled ? `${pair[0]}${text}${pair[1]}` : text; | ||
| } | ||
| function createColorizer(options = {}) { | ||
| const enabled = shouldUseColor(options); | ||
| const color = { | ||
| enabled, | ||
| bold: (value) => wrap(enabled, ANSI.bold, value), | ||
| dim: (value) => wrap(enabled, ANSI.dim, value), | ||
| red: (value) => wrap(enabled, ANSI.red, value), | ||
| green: (value) => wrap(enabled, ANSI.green, value), | ||
| yellow: (value) => wrap(enabled, ANSI.yellow, value), | ||
| blue: (value) => wrap(enabled, ANSI.blue, value), | ||
| cyan: (value) => wrap(enabled, ANSI.cyan, value), | ||
| }; | ||
| return { | ||
| ...color, | ||
| command: color.cyan, | ||
| error: color.red, | ||
| info: color.cyan, | ||
| label: color.yellow, | ||
| flag: color.yellow, | ||
| muted: color.dim, | ||
| success: color.green, | ||
| url: color.cyan, | ||
| warning: color.yellow, | ||
| }; | ||
| } | ||
| function createColor(options = {}) { | ||
| return createColorizer(options); | ||
| } | ||
| function semanticColor(kind, value, options = {}) { | ||
| const color = createColorizer(options); | ||
| const method = SEMANTIC[kind]; | ||
| return method ? color[method](value) : String(value); | ||
| } | ||
| function stripAnsi(value) { | ||
| return String(value).replace(exports.ANSI_PATTERN, ""); | ||
| } |
+2
-2
@@ -7,3 +7,3 @@ #!/usr/bin/env node | ||
| const { normalizeArgvAliases } = require("../cli/argv-aliases.js"); | ||
| const { ROOT_HELP, shouldShowRootHelp } = require("../cli/help.js"); | ||
| const { formatRootHelp, shouldShowRootHelp } = require("../cli/help.js"); | ||
@@ -17,3 +17,3 @@ const packageRoot = | ||
| if (shouldShowRootHelp(rawArgs)) { | ||
| process.stdout.write(`${ROOT_HELP}\n`); | ||
| process.stdout.write(`${formatRootHelp({ stream: process.stdout, env: process.env })}\n`); | ||
| process.exit(0); | ||
@@ -20,0 +20,0 @@ } |
+20
-0
@@ -5,3 +5,5 @@ "use strict"; | ||
| exports.ROOT_HELP = void 0; | ||
| exports.formatRootHelp = formatRootHelp; | ||
| exports.shouldShowRootHelp = shouldShowRootHelp; | ||
| const color_js_1 = require("./colors.js"); | ||
@@ -68,1 +70,19 @@ exports.ROOT_HELP = `PMXT command-line interface | ||
| } | ||
| function formatRootHelp(options = {}) { | ||
| const color = (0, color_js_1.createColorizer)({ | ||
| env: options.env, | ||
| stream: options.stream ?? process.stdout, | ||
| }); | ||
| return exports.ROOT_HELP.split("\n").map((line) => { | ||
| if (line === "PMXT command-line interface") | ||
| return color.bold(line); | ||
| if (/^[A-Z][A-Z ]+$/.test(line)) | ||
| return color.bold(line); | ||
| if (/^ (pmxt|PMXT_API_KEY=)/.test(line)) | ||
| return line.replace(/^( )(.+?)(\s{2,}.+)?$/, (_match, indent, command, suffix = "") => `${indent}${color.command(command)}${suffix}`); | ||
| if (/^ --/.test(line)) | ||
| return line.replace(/^( )(--[^\s]+)/, (_match, indent, flag) => `${indent}${color.flag(flag)}`); | ||
| return line; | ||
| }).join("\n"); | ||
| } |
+10
-6
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.outputResult = outputResult; | ||
| const color_js_1 = require("./colors.js"); | ||
| function isRecord(value) { | ||
@@ -22,9 +23,9 @@ return Boolean(value) && typeof value === "object" && !Array.isArray(value); | ||
| } | ||
| function outputHuman(command, data, label = "result") { | ||
| function outputHuman(command, data, label = "result", color = (0, color_js_1.createColorizer)({ enabled: false })) { | ||
| if (data === undefined || data === null) { | ||
| command.log("ok"); | ||
| command.log(color.success("ok")); | ||
| return; | ||
| } | ||
| if (Array.isArray(data)) { | ||
| command.log(`${label}: ${data.length}`); | ||
| command.log(`${color.label(label)}: ${data.length}`); | ||
| for (const item of data.slice(0, 10)) | ||
@@ -40,6 +41,6 @@ command.log(`- ${summarizeValue(item)}`); | ||
| for (const [key, value] of primitiveEntries) | ||
| command.log(`${key}: ${String(value)}`); | ||
| command.log(`${color.dim(key)}: ${String(value)}`); | ||
| for (const [key, value] of Object.entries(data)) | ||
| if (Array.isArray(value)) | ||
| command.log(`${key}: ${value.length}`); | ||
| command.log(`${color.dim(key)}: ${value.length}`); | ||
| return; | ||
@@ -55,3 +56,6 @@ } | ||
| } | ||
| outputHuman(command, data, options.label); | ||
| outputHuman(command, data, options.label, (0, color_js_1.createColorizer)({ | ||
| enabled: !flags.json, | ||
| stream: process.stdout, | ||
| })); | ||
| } |
+38
-27
@@ -48,2 +48,3 @@ "use strict"; | ||
| const constants_js_1 = require("./constants.js"); | ||
| const color_js_1 = require("./colors.js"); | ||
| const server_manager_js_1 = require("./server-manager.js"); | ||
@@ -140,2 +141,8 @@ exports.ALLOWED_EXCHANGES = new Set([ | ||
| } | ||
| function commandLine(colors, command) { | ||
| return ` ${colors.command(command)}`; | ||
| } | ||
| function labeledValue(colors, label, value) { | ||
| return `${colors.label(label)} ${colors.url(value)}`; | ||
| } | ||
| function resolveAuthStorePath(explicitPath, env) { | ||
@@ -320,14 +327,15 @@ if (explicitPath) | ||
| const message = responseErrorMessage(parsed, response.statusText); | ||
| const colors = config.color ?? (0, color_js_1.createColor)({ enabled: false }); | ||
| if (config.mode === "local") { | ||
| return [ | ||
| `Local PMXT rejected the request: ${message ?? "missing or invalid local access token"}.`, | ||
| `${colors.error("Local PMXT rejected the request")}: ${message ?? "missing or invalid local access token"}.`, | ||
| "", | ||
| `Endpoint: ${config.baseUrl}`, | ||
| labeledValue(colors, "Endpoint:", config.baseUrl), | ||
| "", | ||
| "Try restarting the local PMXT instance:", | ||
| " pmxt server restart", | ||
| colors.warning("Try restarting the local PMXT instance:"), | ||
| commandLine(colors, "pmxt server restart"), | ||
| "", | ||
| "Or use hosted PMXT:", | ||
| " pmxt auth login --api-key <pmxt_api_key>", | ||
| " pmxt <exchange> <command> --hosted", | ||
| colors.warning("Or use hosted PMXT:"), | ||
| commandLine(colors, "pmxt auth login --api-key <pmxt_api_key>"), | ||
| commandLine(colors, "pmxt <exchange> <command> --hosted"), | ||
| ].join("\n"); | ||
@@ -339,16 +347,16 @@ } | ||
| return [ | ||
| `${heading}: ${message ?? "the key was missing or rejected"}.`, | ||
| `${colors.error(heading)}: ${message ?? "the key was missing or rejected"}.`, | ||
| "", | ||
| `Endpoint: ${config.baseUrl}`, | ||
| labeledValue(colors, "Endpoint:", config.baseUrl), | ||
| "", | ||
| "Hosted:", | ||
| " pmxt auth login --api-key <pmxt_api_key>", | ||
| " PMXT_API_KEY=<pmxt_api_key> pmxt <exchange> <command>", | ||
| " pmxt <exchange> <command> --hosted --pmxt-api-key <pmxt_api_key>", | ||
| colors.warning("Hosted:"), | ||
| commandLine(colors, "pmxt auth login --api-key <pmxt_api_key>"), | ||
| commandLine(colors, "PMXT_API_KEY=<pmxt_api_key> pmxt <exchange> <command>"), | ||
| commandLine(colors, "pmxt <exchange> <command> --hosted --pmxt-api-key <pmxt_api_key>"), | ||
| "", | ||
| "Local:", | ||
| " pmxt <exchange> <command> --local", | ||
| " npm install -g pmxt-core", | ||
| colors.warning("Local:"), | ||
| commandLine(colors, "pmxt <exchange> <command> --local"), | ||
| commandLine(colors, "npm install -g pmxt-core"), | ||
| "", | ||
| "Check auth with: pmxt auth status", | ||
| `Check auth with: ${colors.command("pmxt auth status")}`, | ||
| ].join("\n"); | ||
@@ -359,14 +367,14 @@ } | ||
| } | ||
| function localUnavailableMessage(error) { | ||
| function localUnavailableMessage(error, color = (0, color_js_1.createColor)({ enabled: false })) { | ||
| const detail = error instanceof Error ? error.message : String(error); | ||
| return [ | ||
| "Local PMXT instance is not available.", | ||
| color.error("Local PMXT instance is not available."), | ||
| "", | ||
| detail, | ||
| color.dim(detail), | ||
| "", | ||
| "Use hosted PMXT instead:", | ||
| " pmxt auth login --api-key <pmxt_api_key>", | ||
| " pmxt <exchange> <command> --hosted", | ||
| color.warning("Use hosted PMXT instead:"), | ||
| commandLine(color, "pmxt auth login --api-key <pmxt_api_key>"), | ||
| commandLine(color, "pmxt <exchange> <command> --hosted"), | ||
| "", | ||
| "Hosted PMXT is faster for indexed search, router matches, and enterprise data.", | ||
| color.warning("Hosted PMXT is faster for indexed search, router matches, and enterprise data."), | ||
| ].join("\n"); | ||
@@ -390,2 +398,4 @@ } | ||
| async function prepareRuntimeConfig(config, flags = {}, env = process.env) { | ||
| const color = (0, color_js_1.createColor)({ env, json: Boolean(flags.json), stream: process.stderr }); | ||
| config = { ...config, color }; | ||
| if (config.mode === "hosted" && config.baseUrl === constants_js_1.HOSTED_URL && !config.pmxtApiKey) { | ||
@@ -400,3 +410,3 @@ throw new Error(hostedMissingAuthMessage(config)); | ||
| catch (error) { | ||
| throw new Error(localUnavailableMessage(error)); | ||
| throw new Error(localUnavailableMessage(error, config.color)); | ||
| } | ||
@@ -422,2 +432,3 @@ maybeSuggestHosted(flags, env); | ||
| return; | ||
| const color = (0, color_js_1.createColor)({ env, json: Boolean(flags.json), stream: process.stderr }); | ||
| const hintPath = path.join(env.HOME || os.homedir(), ".pmxt", "cli-hints.json"); | ||
@@ -435,5 +446,5 @@ try { | ||
| process.stderr.write([ | ||
| "Using local PMXT instance.", | ||
| color.warning("Using local PMXT instance."), | ||
| "Hosted PMXT is faster for indexed search, router matches, and enterprise data:", | ||
| " pmxt auth login --api-key <pmxt_api_key>", | ||
| commandLine(color, "pmxt auth login --api-key <pmxt_api_key>"), | ||
| "", | ||
@@ -440,0 +451,0 @@ ].join("\n")); |
+23
-14
@@ -6,2 +6,3 @@ "use strict"; | ||
| // @ts-nocheck | ||
| const color_js_1 = require("./colors.js"); | ||
| const server_manager_js_1 = require("./server-manager.js"); | ||
@@ -35,32 +36,40 @@ async function executeServerCommand(action, options = {}) { | ||
| } | ||
| function formatServerCommandResult(result) { | ||
| function formatServerCommandResult(result, options = {}) { | ||
| const color = (0, color_js_1.createColor)({ | ||
| env: options.env, | ||
| json: Boolean(options.json), | ||
| stream: options.stream ?? process.stdout, | ||
| }); | ||
| switch (result.action) { | ||
| case "start": | ||
| return "Local PMXT instance started"; | ||
| return color.success("Local PMXT instance started"); | ||
| case "stop": | ||
| return "Local PMXT instance stopped"; | ||
| return color.success("Local PMXT instance stopped"); | ||
| case "restart": | ||
| return "Local PMXT instance restarted"; | ||
| return color.success("Local PMXT instance restarted"); | ||
| case "status": | ||
| return formatStatus(result); | ||
| return formatStatus(result, color); | ||
| case "health": | ||
| return result.healthy ? "Local PMXT instance healthy" : "Local PMXT instance unhealthy"; | ||
| return result.healthy | ||
| ? color.success("Local PMXT instance healthy") | ||
| : color.warning("Local PMXT instance unhealthy"); | ||
| case "logs": | ||
| return result.lines.length > 0 | ||
| ? result.lines.join("\n") | ||
| : "No local PMXT logs found"; | ||
| : color.warning("No local PMXT logs found"); | ||
| } | ||
| } | ||
| function formatStatus(status) { | ||
| const lines = [`Local PMXT instance ${status.running ? "running" : "stopped"}`]; | ||
| function formatStatus(status, color) { | ||
| const state = status.running ? color.success("running") : color.warning("stopped"); | ||
| const lines = [`Local PMXT instance ${state}`]; | ||
| if (status.pid !== null) | ||
| lines.push(`pid: ${status.pid}`); | ||
| lines.push(`${color.dim("pid")}: ${status.pid}`); | ||
| if (status.port !== null) | ||
| lines.push(`port: ${status.port}`); | ||
| lines.push(`${color.dim("port")}: ${status.port}`); | ||
| if (status.version !== null) | ||
| lines.push(`version: ${status.version}`); | ||
| lines.push(`${color.dim("version")}: ${status.version}`); | ||
| if (status.uptimeSeconds !== null) { | ||
| lines.push(`uptime: ${formatDuration(status.uptimeSeconds)}`); | ||
| lines.push(`${color.dim("uptime")}: ${formatDuration(status.uptimeSeconds)}`); | ||
| } | ||
| lines.push(`lock: ${status.lockFile}`); | ||
| lines.push(`${color.dim("lock")}: ${status.lockFile}`); | ||
| return lines.join("\n"); | ||
@@ -67,0 +76,0 @@ } |
+38
-30
@@ -22,2 +22,3 @@ "use strict"; | ||
| const ws_1 = __importDefault(require("ws")); | ||
| const color_js_1 = require("./colors.js"); | ||
| const constants_js_1 = require("./constants.js"); | ||
@@ -150,2 +151,3 @@ const runtime_js_1 = require("./runtime.js"); | ||
| baseUrl: runtime.baseUrl, | ||
| color: (0, color_js_1.createColor)({ env, json: Boolean(flags.json), stream: process.stderr }), | ||
| mode: runtime.mode, | ||
@@ -164,3 +166,3 @@ noSuggestHosted: Boolean(flags["no-suggest-hosted"]), | ||
| if (credentials.mode === "hosted" && resolved.isHosted && !resolved.pmxtApiKey) { | ||
| throw new Error(authErrorMessage("missing api key", resolved.baseUrl, credentials.mode)); | ||
| throw new Error(authErrorMessage("missing api key", resolved.baseUrl, credentials.mode, credentials.color)); | ||
| } | ||
@@ -173,3 +175,3 @@ if (resolved.baseUrl === constants_js_1.LOCAL_URL || credentials.mode === "local") { | ||
| catch (error) { | ||
| throw new Error(localUnavailableMessage(error)); | ||
| throw new Error(localUnavailableMessage(error, credentials.color)); | ||
| } | ||
@@ -199,3 +201,3 @@ resolved = { | ||
| if (response.status === 401 || response.status === 403) { | ||
| throw new Error(authErrorMessage(errorMessage(body) || response.statusText, resolved.baseUrl, credentials.mode)); | ||
| throw new Error(authErrorMessage(errorMessage(body) || response.statusText, resolved.baseUrl, credentials.mode, credentials.color)); | ||
| } | ||
@@ -313,3 +315,3 @@ throw new Error(errorMessage(body) || response.statusText); | ||
| if (!resolved.pmxtApiKey) { | ||
| throw new Error(authErrorMessage("missing api key", resolved.baseUrl, credentials.mode)); | ||
| throw new Error(authErrorMessage("missing api key", resolved.baseUrl, credentials.mode, credentials.color)); | ||
| } | ||
@@ -326,3 +328,3 @@ return { | ||
| catch (error) { | ||
| throw new Error(localUnavailableMessage(error)); | ||
| throw new Error(localUnavailableMessage(error, credentials.color)); | ||
| } | ||
@@ -378,15 +380,21 @@ const token = manager.getAccessToken(); | ||
| } | ||
| function authErrorMessage(message, baseUrl, mode = "hosted") { | ||
| function commandLine(colors, command) { | ||
| return ` ${colors.command(command)}`; | ||
| } | ||
| function labeledValue(colors, label, value) { | ||
| return `${colors.label(label)} ${colors.url(value)}`; | ||
| } | ||
| function authErrorMessage(message, baseUrl, mode = "hosted", colors = (0, color_js_1.createColor)({ enabled: false })) { | ||
| if (mode === "local") { | ||
| return [ | ||
| `Local PMXT rejected the request: ${message || "missing or invalid local access token"}.`, | ||
| `${colors.error("Local PMXT rejected the request")}: ${message || "missing or invalid local access token"}.`, | ||
| "", | ||
| `Endpoint: ${baseUrl}`, | ||
| labeledValue(colors, "Endpoint:", baseUrl), | ||
| "", | ||
| "Try restarting the local PMXT instance:", | ||
| " pmxt server restart", | ||
| colors.warning("Try restarting the local PMXT instance:"), | ||
| commandLine(colors, "pmxt server restart"), | ||
| "", | ||
| "Or use hosted PMXT:", | ||
| " pmxt auth login --api-key <pmxt_api_key>", | ||
| " pmxt <exchange> <command> --hosted", | ||
| colors.warning("Or use hosted PMXT:"), | ||
| commandLine(colors, "pmxt auth login --api-key <pmxt_api_key>"), | ||
| commandLine(colors, "pmxt <exchange> <command> --hosted"), | ||
| ].join("\n"); | ||
@@ -396,30 +404,30 @@ } | ||
| return [ | ||
| `${heading}: ${message || "the key was missing or rejected"}.`, | ||
| `${colors.error(heading)}: ${message || "the key was missing or rejected"}.`, | ||
| "", | ||
| `Endpoint: ${baseUrl}`, | ||
| labeledValue(colors, "Endpoint:", baseUrl), | ||
| "", | ||
| "Hosted:", | ||
| " pmxt auth login --api-key <pmxt_api_key>", | ||
| " PMXT_API_KEY=<pmxt_api_key> pmxt <exchange> <command>", | ||
| " pmxt <exchange> <command> --hosted --pmxt-api-key <pmxt_api_key>", | ||
| colors.warning("Hosted:"), | ||
| commandLine(colors, "pmxt auth login --api-key <pmxt_api_key>"), | ||
| commandLine(colors, "PMXT_API_KEY=<pmxt_api_key> pmxt <exchange> <command>"), | ||
| commandLine(colors, "pmxt <exchange> <command> --hosted --pmxt-api-key <pmxt_api_key>"), | ||
| "", | ||
| "Local:", | ||
| " pmxt <exchange> <command> --local", | ||
| " npm install -g pmxt-core", | ||
| colors.warning("Local:"), | ||
| commandLine(colors, "pmxt <exchange> <command> --local"), | ||
| commandLine(colors, "npm install -g pmxt-core"), | ||
| "", | ||
| "Check auth with: pmxt auth status", | ||
| `Check auth with: ${colors.command("pmxt auth status")}`, | ||
| ].join("\n"); | ||
| } | ||
| function localUnavailableMessage(error) { | ||
| function localUnavailableMessage(error, colors = (0, color_js_1.createColor)({ enabled: false })) { | ||
| const detail = error instanceof Error ? error.message : String(error); | ||
| return [ | ||
| "Local PMXT instance is not available.", | ||
| colors.error("Local PMXT instance is not available."), | ||
| "", | ||
| detail, | ||
| colors.dim(detail), | ||
| "", | ||
| "Use hosted PMXT instead:", | ||
| " pmxt auth login --api-key <pmxt_api_key>", | ||
| " pmxt <exchange> <command> --hosted", | ||
| colors.warning("Use hosted PMXT instead:"), | ||
| commandLine(colors, "pmxt auth login --api-key <pmxt_api_key>"), | ||
| commandLine(colors, "pmxt <exchange> <command> --hosted"), | ||
| "", | ||
| "Hosted PMXT is faster for indexed search, router matches, and enterprise data.", | ||
| colors.warning("Hosted PMXT is faster for indexed search, router matches, and enterprise data."), | ||
| ].join("\n"); | ||
@@ -426,0 +434,0 @@ } |
+7
-6
@@ -11,2 +11,3 @@ "use strict"; | ||
| const status_exchange_js_1 = require("./auth/status-exchange.js"); | ||
| const auth_output_js_1 = require("../cli/auth-output.js"); | ||
@@ -70,11 +71,11 @@ const ACTION_ALIASES = { | ||
| if (action === "status") { | ||
| this.log(await (0, status_js_1.runAuthStatus)(flags)); | ||
| this.log((0, auth_output_js_1.formatAuthStatusMessage)(await (0, status_js_1.runAuthStatus)(flags), { flags })); | ||
| return; | ||
| } | ||
| if (action === "login") { | ||
| this.log(await (0, login_js_1.runAuthLogin)(flags)); | ||
| this.log((0, auth_output_js_1.formatOutcomeMessage)(await (0, login_js_1.runAuthLogin)(flags), { flags })); | ||
| return; | ||
| } | ||
| if (action === "logout") { | ||
| this.log(await (0, logout_js_1.runAuthLogout)(flags)); | ||
| this.log((0, auth_output_js_1.formatOutcomeMessage)(await (0, logout_js_1.runAuthLogout)(flags), { flags })); | ||
| return; | ||
@@ -86,3 +87,3 @@ } | ||
| } | ||
| this.log(await (0, set_exchange_js_1.runAuthSetExchange)(args.exchange, flags)); | ||
| this.log((0, auth_output_js_1.formatOutcomeMessage)(await (0, set_exchange_js_1.runAuthSetExchange)(args.exchange, flags), { flags })); | ||
| return; | ||
@@ -94,7 +95,7 @@ } | ||
| } | ||
| this.log(await (0, remove_exchange_js_1.runAuthRemoveExchange)(args.exchange, flags)); | ||
| this.log((0, auth_output_js_1.formatOutcomeMessage)(await (0, remove_exchange_js_1.runAuthRemoveExchange)(args.exchange, flags), { flags })); | ||
| return; | ||
| } | ||
| if (action === "status-exchange") { | ||
| this.log(await (0, status_exchange_js_1.runAuthStatusExchange)(args.exchange, flags)); | ||
| this.log((0, auth_output_js_1.formatExchangeStatusMessage)(await (0, status_exchange_js_1.runAuthStatusExchange)(args.exchange, flags), { flags })); | ||
| } | ||
@@ -101,0 +102,0 @@ } |
@@ -6,2 +6,3 @@ "use strict"; | ||
| const core_1 = require("@oclif/core"); | ||
| const auth_output_js_1 = require("../../cli/auth-output.js"); | ||
| const auth_store_js_1 = require("../../cli/auth-store.js"); | ||
@@ -35,5 +36,5 @@ const credentials_js_1 = require("../../cli/credentials.js"); | ||
| const { flags } = await this.parse(AuthLogin); | ||
| this.log(await runAuthLogin(flags)); | ||
| this.log((0, auth_output_js_1.formatOutcomeMessage)(await runAuthLogin(flags), { flags })); | ||
| } | ||
| } | ||
| exports.default = AuthLogin; |
@@ -6,2 +6,3 @@ "use strict"; | ||
| const core_1 = require("@oclif/core"); | ||
| const auth_output_js_1 = require("../../cli/auth-output.js"); | ||
| const auth_store_js_1 = require("../../cli/auth-store.js"); | ||
@@ -24,5 +25,5 @@ async function runAuthLogout(flags = {}, env = process.env) { | ||
| const { flags } = await this.parse(AuthLogout); | ||
| this.log(await runAuthLogout(flags)); | ||
| this.log((0, auth_output_js_1.formatOutcomeMessage)(await runAuthLogout(flags), { flags })); | ||
| } | ||
| } | ||
| exports.default = AuthLogout; |
@@ -6,2 +6,3 @@ "use strict"; | ||
| const core_1 = require("@oclif/core"); | ||
| const auth_output_js_1 = require("../../cli/auth-output.js"); | ||
| const auth_store_js_1 = require("../../cli/auth-store.js"); | ||
@@ -31,5 +32,5 @@ async function runAuthRemoveExchange(exchange, flags = {}, env = process.env) { | ||
| const { args, flags } = await this.parse(AuthRemoveExchange); | ||
| this.log(await runAuthRemoveExchange(args.exchange, flags)); | ||
| this.log((0, auth_output_js_1.formatOutcomeMessage)(await runAuthRemoveExchange(args.exchange, flags), { flags })); | ||
| } | ||
| } | ||
| exports.default = AuthRemoveExchange; |
@@ -6,2 +6,3 @@ "use strict"; | ||
| const core_1 = require("@oclif/core"); | ||
| const auth_output_js_1 = require("../../cli/auth-output.js"); | ||
| const auth_store_js_1 = require("../../cli/auth-store.js"); | ||
@@ -72,5 +73,5 @@ const credentials_js_1 = require("../../cli/credentials.js"); | ||
| const { args, flags } = await this.parse(AuthSetExchange); | ||
| this.log(await runAuthSetExchange(args.exchange, flags)); | ||
| this.log((0, auth_output_js_1.formatOutcomeMessage)(await runAuthSetExchange(args.exchange, flags), { flags })); | ||
| } | ||
| } | ||
| exports.default = AuthSetExchange; |
@@ -6,2 +6,3 @@ "use strict"; | ||
| const core_1 = require("@oclif/core"); | ||
| const auth_output_js_1 = require("../../cli/auth-output.js"); | ||
| const auth_store_js_1 = require("../../cli/auth-store.js"); | ||
@@ -53,5 +54,5 @@ const credentials_js_1 = require("../../cli/credentials.js"); | ||
| const { args, flags } = await this.parse(AuthStatusExchange); | ||
| this.log(await runAuthStatusExchange(args.exchange, flags)); | ||
| this.log((0, auth_output_js_1.formatExchangeStatusMessage)(await runAuthStatusExchange(args.exchange, flags), { flags })); | ||
| } | ||
| } | ||
| exports.default = AuthStatusExchange; |
@@ -6,2 +6,3 @@ "use strict"; | ||
| const core_1 = require("@oclif/core"); | ||
| const auth_output_js_1 = require("../../cli/auth-output.js"); | ||
| const auth_store_js_1 = require("../../cli/auth-store.js"); | ||
@@ -37,5 +38,5 @@ const credentials_js_1 = require("../../cli/credentials.js"); | ||
| const { flags } = await this.parse(AuthStatus); | ||
| this.log(await runAuthStatus(flags)); | ||
| this.log((0, auth_output_js_1.formatAuthStatusMessage)(await runAuthStatus(flags), { flags })); | ||
| } | ||
| } | ||
| exports.default = AuthStatus; |
@@ -11,5 +11,5 @@ "use strict"; | ||
| async run() { | ||
| await this.parse(ServerHealth); | ||
| const { flags } = await this.parse(ServerHealth); | ||
| const result = await (0, server_js_1.executeServerCommand)("health"); | ||
| this.log((0, server_js_1.formatServerCommandResult)(result)); | ||
| this.log((0, server_js_1.formatServerCommandResult)(result, { json: flags.json })); | ||
| if (result.action === "health" && !result.healthy) | ||
@@ -16,0 +16,0 @@ process.exitCode = 1; |
@@ -21,3 +21,3 @@ "use strict"; | ||
| const result = await (0, server_js_1.executeServerCommand)("logs", { lines: flags.lines }); | ||
| this.log((0, server_js_1.formatServerCommandResult)(result)); | ||
| this.log((0, server_js_1.formatServerCommandResult)(result, { json: flags.json })); | ||
| return result; | ||
@@ -24,0 +24,0 @@ } |
@@ -11,5 +11,5 @@ "use strict"; | ||
| async run() { | ||
| await this.parse(ServerRestart); | ||
| const { flags } = await this.parse(ServerRestart); | ||
| const result = await (0, server_js_1.executeServerCommand)("restart"); | ||
| this.log((0, server_js_1.formatServerCommandResult)(result)); | ||
| this.log((0, server_js_1.formatServerCommandResult)(result, { json: flags.json })); | ||
| return result; | ||
@@ -16,0 +16,0 @@ } |
@@ -11,5 +11,5 @@ "use strict"; | ||
| async run() { | ||
| await this.parse(ServerStart); | ||
| const { flags } = await this.parse(ServerStart); | ||
| const result = await (0, server_js_1.executeServerCommand)("start"); | ||
| this.log((0, server_js_1.formatServerCommandResult)(result)); | ||
| this.log((0, server_js_1.formatServerCommandResult)(result, { json: flags.json })); | ||
| return result; | ||
@@ -16,0 +16,0 @@ } |
@@ -11,5 +11,5 @@ "use strict"; | ||
| async run() { | ||
| await this.parse(ServerStatus); | ||
| const { flags } = await this.parse(ServerStatus); | ||
| const result = await (0, server_js_1.executeServerCommand)("status"); | ||
| this.log((0, server_js_1.formatServerCommandResult)(result)); | ||
| this.log((0, server_js_1.formatServerCommandResult)(result, { json: flags.json })); | ||
| return result; | ||
@@ -16,0 +16,0 @@ } |
@@ -11,5 +11,5 @@ "use strict"; | ||
| async run() { | ||
| await this.parse(ServerStop); | ||
| const { flags } = await this.parse(ServerStop); | ||
| const result = await (0, server_js_1.executeServerCommand)("stop"); | ||
| this.log((0, server_js_1.formatServerCommandResult)(result)); | ||
| this.log((0, server_js_1.formatServerCommandResult)(result, { json: flags.json })); | ||
| return result; | ||
@@ -16,0 +16,0 @@ } |
+2
-2
| { | ||
| "name": "@pmxt/cli", | ||
| "version": "2.46.1", | ||
| "version": "2.46.2", | ||
| "description": "Command-line interface for PMXT prediction market APIs", | ||
@@ -57,3 +57,3 @@ "author": "PMXT Contributors", | ||
| "prepack": "npm run build", | ||
| "test": "node scripts/validate.js && node scripts/verify-argv-alias-normalizer.js && node scripts/verify-root-help.js && node scripts/verify-runtime-errors.js && node scripts/verify-feed-cli.js && node scripts/verify-enterprise-cli.js && node scripts/verify-production-copy.js" | ||
| "test": "node scripts/validate.js && node scripts/verify-argv-alias-normalizer.js && node scripts/verify-root-help.js && node scripts/verify-color.js && node scripts/verify-runtime-errors.js && node scripts/verify-feed-cli.js && node scripts/verify-enterprise-cli.js && node scripts/verify-production-copy.js" | ||
| }, | ||
@@ -60,0 +60,0 @@ "keywords": [ |
275167
3.75%77
2.67%6962
2.97%30
7.14%