Skip to content

Commit

Permalink
no need for special formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ptpaterson committed Jan 13, 2025
1 parent 81640a8 commit f01ab1e
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/lib/faunadb.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/lib/formatting/codeToAnsi.mjs
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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(),
});

Expand Down
15 changes: 0 additions & 15 deletions src/lib/formatting/colorize.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { codeToAnsi } from "./codeToAnsi.mjs";

export const Format = {
FQL: "fql",
FQL_V4: "fql_v4",
LOG: "log",
JSON: "json",
TEXT: "text",
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions test/commands/query/v4.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand All @@ -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;
}),
Expand Down

0 comments on commit f01ab1e

Please sign in to comment.