Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace strip-ansi with stripVTControlCharacters from node:util #7860

Merged
merged 3 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions firebase-vscode/src/logger-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as fs from "fs";
import * as os from "os";
import { transports, format } from "winston";
import Transport from "winston-transport";
import stripAnsi from "strip-ansi";
import { stripVTControlCharacters } from "node:util";
import { SPLAT } from "triple-beam";
import { logger as cliLogger } from "../../src/logger";
import { setupLoggers, tryStringify } from "../../src/utils";
Expand Down Expand Up @@ -61,7 +61,7 @@ export function logSetup() {
const segments = [info.message, ...(info[SPLAT] || [])].map(
tryStringify,
);
return `[${info.level}] ${stripAnsi(segments.join(" "))}`;
return `[${info.level}] ${stripVTControlCharacters(segments.join(" "))}`;
}),
}),
);
Expand All @@ -81,7 +81,7 @@ class VSCodeOutputTransport extends Transport {
this.emit("logged", info);
});
const segments = [info.message, ...(info[SPLAT] || [])].map(tryStringify);
const text = `[${info.level}] ${stripAnsi(segments.join(" "))}`;
const text = `[${info.level}] ${stripVTControlCharacters(segments.join(" "))}`;

if (info.level !== "debug") {
// info or greater: write to output window
Expand Down
1 change: 0 additions & 1 deletion npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@
"sql-formatter": "^15.3.0",
"stream-chain": "^2.2.4",
"stream-json": "^1.7.3",
"strip-ansi": "^6.0.1",
"superstatic": "^9.0.3",
"tar": "^6.1.11",
"tcp-port-used": "^1.0.2",
Expand Down
4 changes: 2 additions & 2 deletions src/bin/firebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

// Check for older versions of Node no longer supported by the CLI.
import * as semver from "semver";
const pkg = require("../../package.json");

Check warning on line 5 in src/bin/firebase.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value

Check warning on line 5 in src/bin/firebase.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Require statement not part of import statement
const nodeVersion = process.version;
if (!semver.satisfies(nodeVersion, pkg.engines.node)) {

Check warning on line 7 in src/bin/firebase.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe argument of type `any` assigned to a parameter of type `string | Range`

Check warning on line 7 in src/bin/firebase.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .engines on an `any` value
console.error(
`Firebase CLI v${pkg.version} is incompatible with Node.js ${nodeVersion} Please upgrade Node.js to version ${pkg.engines.node}`,

Check warning on line 9 in src/bin/firebase.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Invalid type "any" of template literal expression

Check warning on line 9 in src/bin/firebase.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .version on an `any` value

Check warning on line 9 in src/bin/firebase.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Invalid type "any" of template literal expression

Check warning on line 9 in src/bin/firebase.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .engines on an `any` value
);
process.exit(1);
}
Expand All @@ -14,14 +14,14 @@
import * as updateNotifierPkg from "update-notifier-cjs";
import * as clc from "colorette";
import { markedTerminal } from "marked-terminal";
const updateNotifier = updateNotifierPkg({ pkg });

Check warning on line 17 in src/bin/firebase.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
import { marked } from "marked";
marked.use(markedTerminal() as any);

Check warning on line 19 in src/bin/firebase.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe argument of type `any` assigned to a parameter of type `MarkedExtension`

import { Command } from "commander";
import { join } from "node:path";
import { SPLAT } from "triple-beam";
const stripAnsi = require("strip-ansi");
import { stripVTControlCharacters } from "node:util";
import * as fs from "node:fs";

import { configstore } from "../configstore";
Expand Down Expand Up @@ -77,7 +77,7 @@
filename: logFilename,
format: winston.format.printf((info) => {
const segments = [info.message, ...(info[SPLAT] || [])].map(utils.tryStringify);
return `[${info.level}] ${stripAnsi(segments.join(" "))}`;
return `[${info.level}] ${stripVTControlCharacters(segments.join(" "))}`;
}),
}),
);
Expand Down
4 changes: 2 additions & 2 deletions src/emulator/loggingEmulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as WebSocket from "ws";
import { LogEntry } from "winston";
import * as TransportStream from "winston-transport";
import { logger } from "../logger";
const stripAnsi = require("strip-ansi");
import { stripVTControlCharacters } from "node:util";

export interface LoggingEmulatorArgs {
port?: number;
Expand Down Expand Up @@ -145,7 +145,7 @@ class WebSocketTransport extends TransportStream {
bundle.message = bundle.data.metadata.message;
}

bundle.message = stripAnsi(bundle.message);
bundle.message = stripVTControlCharacters(bundle.message);

this.history.push(bundle);
this.connections.forEach((ws) => {
Expand Down
4 changes: 2 additions & 2 deletions src/frameworks/vite/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { spawn } from "cross-spawn";
import { existsSync } from "fs";
import { copy, pathExists } from "fs-extra";
import { join } from "path";
const stripAnsi = require("strip-ansi");
import { stripVTControlCharacters } from "node:util";
import { FrameworkType, SupportLevel } from "../interfaces";
import { promptOnce } from "../../prompt";
import {
Expand Down Expand Up @@ -120,7 +120,7 @@ export async function getDevModeHandle(dir: string) {
const serve = spawn(cli, [], { cwd: dir });
serve.stdout.on("data", (data: any) => {
process.stdout.write(data);
const dataWithoutAnsiCodes = stripAnsi(data.toString());
const dataWithoutAnsiCodes = stripVTControlCharacters(data.toString());
const match = dataWithoutAnsiCodes.match(/(http:\/\/.+:\d+)/);
if (match) resolve(match[1]);
});
Expand Down
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { Readable } from "stream";
import * as winston from "winston";
import { SPLAT } from "triple-beam";
import { AssertionError } from "assert";
const stripAnsi = require("strip-ansi");
import { stripVTControlCharacters } from "node:util";
import { getPortPromise as getPort } from "portfinder";

import { configstore } from "./configstore";
Expand Down Expand Up @@ -508,7 +508,7 @@ export function setupLoggers() {
level: "debug",
format: winston.format.printf((info) => {
const segments = [info.message, ...(info[SPLAT] || [])].map(tryStringify);
return `${stripAnsi(segments.join(" "))}`;
return `${stripVTControlCharacters(segments.join(" "))}`;
}),
}),
);
Expand Down
Loading