cleanup: replace console.log/warn with $console, remove commented-out code

Removed various commented-out code and replaced direct `console.log` and `console.warn` usage across the codebase with `$console` from "core" for standardized logging. Also adjusted linting rules in biome.json to enable warnings for `console.log` usage.
This commit is contained in:
dswbx
2025-04-10 14:18:48 +02:00
parent ad7926db4c
commit 4e718a063d
79 changed files with 180 additions and 565 deletions
+2
View File
@@ -8,6 +8,8 @@ export const config: CliCommand = (program) => {
.option("--pretty", "pretty print")
.action((options) => {
const config = getDefaultConfig();
// biome-ignore lint/suspicious/noConsoleLog:
console.log(options.pretty ? JSON.stringify(config, null, 2) : JSON.stringify(config));
});
};
+1
View File
@@ -32,5 +32,6 @@ async function action(options: { out?: string; clean?: boolean }) {
// delete ".vite" directory in out
await fs.rm(path.resolve(out, ".vite"), { recursive: true });
// biome-ignore lint/suspicious/noConsoleLog:
console.log(c.green(`Assets copied to: ${c.bold(out)}`));
}
+21 -10
View File
@@ -43,10 +43,12 @@ export const create: CliCommand = (program) => {
function errorOutro() {
$p.outro(color.red("Failed to create project."));
// biome-ignore lint/suspicious/noConsoleLog:
console.log(
color.yellow("Sorry that this happened. If you think this is a bug, please report it at: ") +
color.cyan("https://github.com/bknd-io/bknd/issues"),
);
// biome-ignore lint/suspicious/noConsoleLog:
console.log("");
process.exit(1);
}
@@ -55,7 +57,14 @@ async function onExit() {
await flush();
}
async function action(options: { template?: string; dir?: string; integration?: string, yes?: boolean, clean?: boolean }) {
async function action(options: {
template?: string;
dir?: string;
integration?: string;
yes?: boolean;
clean?: boolean;
}) {
// biome-ignore lint/suspicious/noConsoleLog:
console.log("");
const $t = createScoped("create");
$t.capture("start", {
@@ -96,10 +105,12 @@ async function action(options: { template?: string; dir?: string; integration?:
$t.properties.at = "dir";
if (fs.existsSync(downloadOpts.dir)) {
const clean = options.clean ?? await $p.confirm({
message: `Directory ${color.cyan(downloadOpts.dir)} exists. Clean it?`,
initialValue: false,
});
const clean =
options.clean ??
(await $p.confirm({
message: `Directory ${color.cyan(downloadOpts.dir)} exists. Clean it?`,
initialValue: false,
}));
if ($p.isCancel(clean)) {
await onExit();
process.exit(1);
@@ -174,8 +185,6 @@ async function action(options: { template?: string; dir?: string; integration?:
process.exit(1);
}
//console.log("integration", { type, integration });
const choices = templates.filter((t) => t.integration === integration);
if (choices.length === 0) {
await onExit();
@@ -261,9 +270,11 @@ async function action(options: { template?: string; dir?: string; integration?:
$p.log.success(`Updated package name to ${color.cyan(ctx.name)}`);
{
const install = options.yes ?? await $p.confirm({
message: "Install dependencies?",
});
const install =
options.yes ??
(await $p.confirm({
message: "Install dependencies?",
}));
if ($p.isCancel(install)) {
await onExit();
+2
View File
@@ -17,6 +17,7 @@ export const debug: CliCommand = (program) => {
const subjects = {
paths: async () => {
// biome-ignore lint/suspicious/noConsoleLog:
console.log("[PATHS]", {
rootpath: getRootPath(),
distPath: getDistPath(),
@@ -27,6 +28,7 @@ const subjects = {
});
},
routes: async () => {
// biome-ignore lint/suspicious/noConsoleLog:
console.log("[APP ROUTES]");
const credentials = getConnectionCredentialsFromEnv();
const app = createApp({ connection: credentials });
+4 -3
View File
@@ -1,6 +1,6 @@
import path from "node:path";
import type { Config } from "@libsql/client/node";
import { config } from "core";
import { $console, config } from "core";
import type { MiddlewareHandler } from "hono";
import open from "open";
import { fileExists, getRelativeDistPath } from "../../utils/sys";
@@ -36,7 +36,7 @@ export async function startServer(
options: { port: number; open?: boolean },
) {
const port = options.port;
console.log(`Using ${server} serve`);
$console.log(`Using ${server} serve`);
switch (server) {
case "node": {
@@ -58,7 +58,8 @@ export async function startServer(
}
const url = `http://localhost:${port}`;
console.info("Server listening on", url);
$console.info("Server listening on", url);
if (options.open) {
await open(url);
}
+1
View File
@@ -8,6 +8,7 @@ export const schema: CliCommand = (program) => {
.option("--pretty", "pretty print")
.action((options) => {
const schema = getDefaultSchema();
// biome-ignore lint/suspicious/noConsoleLog:
console.log(options.pretty ? JSON.stringify(schema, null, 2) : JSON.stringify(schema));
});
};
+1
View File
@@ -169,6 +169,7 @@ async function token(app: App, options: any) {
}
$log.info(`User found: ${c.cyan(user.email)}`);
// biome-ignore lint/suspicious/noConsoleLog:
console.log(
`\n${c.dim("Token:")}\n${c.yellow(await app.module.auth.authenticator.jwt(user))}\n`,
);