From f01ab1e5990b1655ad9bb9bda9f99e9a82cc4319 Mon Sep 17 00:00:00 2001 From: Paul Paterson Date: Mon, 13 Jan 2025 17:21:57 -0500 Subject: [PATCH] no need for special formatting --- src/lib/faunadb.mjs | 2 +- src/lib/formatting/codeToAnsi.mjs | 3 +-- src/lib/formatting/colorize.mjs | 15 --------------- test/commands/query/v4.mjs | 4 ++-- 4 files changed, 4 insertions(+), 20 deletions(-) diff --git a/src/lib/faunadb.mjs b/src/lib/faunadb.mjs index c96dbb98..cee5327e 100644 --- a/src/lib/faunadb.mjs +++ b/src/lib/faunadb.mjs @@ -189,7 +189,7 @@ export const formatQueryResponse = (res, opts = {}) => { if (!format || format === Format.FQL) { resolvedOutput = util.inspect(data, { showHidden: false, depth: null }); - resolvedFormat = Format.FQL_V4; + resolvedFormat = Format.FQL; } else { resolvedOutput = data; resolvedFormat = Format.JSON; diff --git a/src/lib/formatting/codeToAnsi.mjs b/src/lib/formatting/codeToAnsi.mjs index e1925cd6..843ac8c1 100644 --- a/src/lib/formatting/codeToAnsi.mjs +++ b/src/lib/formatting/codeToAnsi.mjs @@ -1,7 +1,6 @@ import chalk from "chalk"; import { createHighlighterCoreSync } from "shiki/core"; import { createJavaScriptRegexEngine } from "shiki/engine/javascript"; -import js from "shiki/langs/js.mjs"; import json from "shiki/langs/json.mjs"; import log from "shiki/langs/log.mjs"; import yaml from "shiki/langs/yaml.mjs"; @@ -15,7 +14,7 @@ const THEME = "github-dark-high-contrast"; export const createHighlighter = () => { const highlighter = createHighlighterCoreSync({ themes: [githubDarkHighContrast], - langs: [fql, log, json, yaml, js], + langs: [fql, log, json, yaml], engine: createJavaScriptRegexEngine(), }); diff --git a/src/lib/formatting/colorize.mjs b/src/lib/formatting/colorize.mjs index 52ac8e8a..2df1f1cc 100644 --- a/src/lib/formatting/colorize.mjs +++ b/src/lib/formatting/colorize.mjs @@ -6,7 +6,6 @@ import { codeToAnsi } from "./codeToAnsi.mjs"; export const Format = { FQL: "fql", - FQL_V4: "fql_v4", LOG: "log", JSON: "json", TEXT: "text", @@ -35,18 +34,6 @@ const fqlToAnsi = (obj) => { return res.trim(); }; -const fqlV4ToAnsi = (obj) => { - if (typeof obj !== "string") { - throw new Error("Unable to format FQL unless it is already a string."); - } - - const raw = stripAnsi(obj); - const codeToAnsi = container.resolve("codeToAnsi"); - const res = codeToAnsi(raw, "js"); - - return res.trim(); -}; - const jsonToAnsi = (obj) => { const codeToAnsi = container.resolve("codeToAnsi"); const stringified = objToString(obj); @@ -90,8 +77,6 @@ export const toAnsi = (obj, { format = Format.TEXT } = {}) => { switch (format) { case Format.FQL: return fqlToAnsi(obj); - case Format.FQL_V4: - return fqlV4ToAnsi(obj); case Format.JSON: return jsonToAnsi(obj); case Format.LOG: diff --git a/test/commands/query/v4.mjs b/test/commands/query/v4.mjs index c9f8900a..6f0f38b2 100644 --- a/test/commands/query/v4.mjs +++ b/test/commands/query/v4.mjs @@ -48,7 +48,7 @@ describe("query v4", function () { depth: null, }); expect(logger.stdout).to.have.been.calledWith( - colorize(output, { format: "fql_v4", color: true }), + colorize(output, { format: "fql", color: true }), ); expect(logger.stderr).to.not.be.called; }); @@ -72,7 +72,7 @@ describe("query v4", function () { runQueryFromString.resolves(createV4QuerySuccess(query)); await run(`query "null" --apiVersion 4 --secret=foo`, container); expect(logger.stdout).to.have.been.calledWith( - colorize(util.inspect(query), { format: "fql_v4", color: true }), + colorize(util.inspect(query), { format: "fql", color: true }), ); expect(logger.stderr).to.not.be.called; }),