chore: remove debug trace logs (#2545)
This commit is contained in:
@@ -78,6 +78,6 @@
|
||||
"jsxPrecompileSkipElements": ["a", "img", "source", "body", "html", "head"]
|
||||
},
|
||||
"lint": {
|
||||
"rules": { "exclude": ["no-window"] }
|
||||
"rules": { "exclude": ["no-window"], "include": ["no-console"] }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,9 +62,11 @@ const realTTY: MockTTY = {
|
||||
return confirm(message);
|
||||
},
|
||||
log(...args) {
|
||||
// deno-lint-ignore no-console
|
||||
console.log(...args);
|
||||
},
|
||||
logError(...args) {
|
||||
// deno-lint-ignore no-console
|
||||
console.error(...args);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -216,11 +216,13 @@ export class App<State> {
|
||||
} catch (err) {
|
||||
if (err instanceof HttpError) {
|
||||
if (err.status >= 500) {
|
||||
// deno-lint-ignore no-console
|
||||
console.error(err);
|
||||
}
|
||||
return new Response(err.message, { status: err.status });
|
||||
}
|
||||
|
||||
// deno-lint-ignore no-console
|
||||
console.error(err);
|
||||
return new Response("Internal server error", { status: 500 });
|
||||
}
|
||||
@@ -243,16 +245,20 @@ export class App<State> {
|
||||
|
||||
// Don't spam logs with this on live deployments
|
||||
if (!DENO_DEPLOYMENT_ID) {
|
||||
// deno-lint-ignore no-console
|
||||
console.log();
|
||||
// deno-lint-ignore no-console
|
||||
console.log(
|
||||
colors.bgRgb8(colors.rgb8(" 🍋 Fresh ready ", 0), 121),
|
||||
);
|
||||
const sep = options.remoteAddress ? "" : "\n";
|
||||
const space = options.remoteAddress ? " " : "";
|
||||
// deno-lint-ignore no-console
|
||||
console.log(` ${localLabel} ${space}${address}${sep}`);
|
||||
if (options.remoteAddress) {
|
||||
const remoteLabel = colors.bold("Remote:");
|
||||
const remoteAddress = colors.cyan(options.remoteAddress);
|
||||
// deno-lint-ignore no-console
|
||||
console.log(` ${remoteLabel} ${remoteAddress}\n`);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -199,10 +199,10 @@ export class Builder implements FreshBuilder {
|
||||
buildCache.islands.set(island.name, `/${chunk}`);
|
||||
}
|
||||
|
||||
console.trace("FLUSH");
|
||||
await buildCache.flush();
|
||||
|
||||
if (!dev) {
|
||||
// deno-lint-ignore no-console
|
||||
console.log(
|
||||
`Assets written to: ${colors.cyan(build.outDir)}`,
|
||||
);
|
||||
|
||||
@@ -11,21 +11,18 @@ Deno.test({
|
||||
builder.onTransformStaticFile(
|
||||
{ pluginName: "A", filter: /\.css$/ },
|
||||
() => {
|
||||
console.trace();
|
||||
logs.push("A");
|
||||
},
|
||||
);
|
||||
builder.onTransformStaticFile(
|
||||
{ pluginName: "B", filter: /\.css$/ },
|
||||
() => {
|
||||
console.trace();
|
||||
logs.push("B");
|
||||
},
|
||||
);
|
||||
builder.onTransformStaticFile(
|
||||
{ pluginName: "C", filter: /\.css$/ },
|
||||
() => {
|
||||
console.trace();
|
||||
logs.push("C");
|
||||
},
|
||||
);
|
||||
|
||||
@@ -143,7 +143,6 @@ export class MemoryBuildCache implements DevBuildCache {
|
||||
|
||||
// deno-lint-ignore require-await
|
||||
async flush(): Promise<void> {
|
||||
console.log("FLUSH MEMORY CACHE");
|
||||
this.#ready.resolve();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ export function devErrorOverlay<T>(): MiddlewareFn<T> {
|
||||
}
|
||||
|
||||
// At this point we're pretty sure to have a server error
|
||||
// deno-lint-ignore no-console
|
||||
console.error(err);
|
||||
|
||||
return ctx.render(<FreshScripts />, init);
|
||||
|
||||
@@ -106,6 +106,7 @@ export async function updateCheck(
|
||||
checkFile.last_checked = new Date().toISOString();
|
||||
} catch (err) {
|
||||
// Update check is optional and shouldn't abort the program.
|
||||
// deno-lint-ignore no-console
|
||||
console.error(
|
||||
colors.red(` Update check failed: `) + err.message,
|
||||
);
|
||||
@@ -125,12 +126,15 @@ export async function updateCheck(
|
||||
|
||||
const current = colors.bold(colors.rgb8(checkFile.current_version, 208));
|
||||
const latest = colors.bold(colors.rgb8(checkFile.latest_version, 121));
|
||||
// deno-lint-ignore no-console
|
||||
console.log(
|
||||
` Fresh ${latest} is available. You're on ${current}`,
|
||||
);
|
||||
// deno-lint-ignore no-console
|
||||
console.log(
|
||||
` To upgrade, run: deno run -A -r https://fresh.deno.dev/update`,
|
||||
);
|
||||
// deno-lint-ignore no-console
|
||||
console.log();
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ function reconnect() {
|
||||
|
||||
reconnectTimer = setTimeout(() => {
|
||||
if (backoffIdx === 0) {
|
||||
// deno-lint-ignore no-console
|
||||
console.log(
|
||||
`%c Fresh %c Connection closed. Trying to reconnect...`,
|
||||
"background-color: #86efac; color: black",
|
||||
@@ -84,6 +85,7 @@ function handleMessage(e: MessageEvent) {
|
||||
switch (data.type) {
|
||||
case "initial-state": {
|
||||
if (revision === 0) {
|
||||
// deno-lint-ignore no-console
|
||||
console.log(
|
||||
`%c Fresh %c Connected to development server.`,
|
||||
"background-color: #86efac; color: black",
|
||||
|
||||
@@ -481,6 +481,7 @@ function revivePartials(
|
||||
|
||||
const instance = ACTIVE_PARTIALS.get(partialName);
|
||||
if (instance === undefined) {
|
||||
// deno-lint-ignore no-console
|
||||
console.warn(`Partial "${partialName}" not found. Skipping...`);
|
||||
// Partial doesn't exist on the current page
|
||||
} else {
|
||||
|
||||
@@ -74,6 +74,7 @@ export function assetInternal(path: string, buildId: string): string {
|
||||
url.searchParams.set(ASSET_CACHE_BUST_KEY, buildId);
|
||||
return url.pathname + url.search + url.hash;
|
||||
} catch (err) {
|
||||
// deno-lint-ignore no-console
|
||||
console.warn(
|
||||
`Failed to create asset() URL, falling back to regular path ('${path}'):`,
|
||||
err,
|
||||
|
||||
@@ -27,4 +27,5 @@ const app = new App({ staticDir: "./static" }).get(
|
||||
|
||||
const handler = await app.handler();
|
||||
const res = await handler(new Request("http://localhost/"));
|
||||
// deno-lint-ignore no-console
|
||||
console.log(await res.text());
|
||||
|
||||
@@ -3,6 +3,7 @@ import { DAY } from "@std/datetime";
|
||||
|
||||
// deno-lint-ignore require-await
|
||||
async function getLatestVersion() {
|
||||
// deno-lint-ignore no-console
|
||||
console.log("fetching latest version");
|
||||
return Deno.env.get("LATEST_VERSION") ?? "99.99.999";
|
||||
}
|
||||
|
||||
@@ -244,6 +244,7 @@ export function parseHtml(input: string): TestDocument {
|
||||
// deno-lint-ignore no-explicit-any
|
||||
const doc = new DOMParser().parseFromString(input, "text/html") as any;
|
||||
Object.defineProperty(doc, "debug", {
|
||||
// deno-lint-ignore no-console
|
||||
value: () => console.log(prettyDom(doc)),
|
||||
enumerable: false,
|
||||
});
|
||||
@@ -284,6 +285,7 @@ export function assertMetaContent(
|
||||
}
|
||||
|
||||
if (el === null) {
|
||||
// deno-lint-ignore no-console
|
||||
console.log(prettyDom(doc));
|
||||
throw new Error(
|
||||
`No <meta>-tag found with content "${expected}"`,
|
||||
@@ -312,6 +314,7 @@ export async function waitForText(
|
||||
// deno-lint-ignore no-explicit-any
|
||||
const pretty = prettyDom(parseHtml(body) as any);
|
||||
|
||||
// deno-lint-ignore no-console
|
||||
console.log(
|
||||
`Text "${text}" not found on selector "${selector}" in html:\n\n${pretty}`,
|
||||
);
|
||||
|
||||
@@ -4,12 +4,14 @@ import type { DenoJson } from "../update/src/update.ts";
|
||||
import * as semver from "@std/semver";
|
||||
|
||||
function showHelp() {
|
||||
// deno-lint-ignore no-console
|
||||
console.log(`
|
||||
Usage: deno run -A release.ts <major|minor|patch|...>
|
||||
`);
|
||||
}
|
||||
|
||||
function exitError(msg: string): never {
|
||||
// deno-lint-ignore no-console
|
||||
console.error(cl.red(msg));
|
||||
showHelp();
|
||||
Deno.exit(1);
|
||||
@@ -71,8 +73,11 @@ function formatUpgradeMsg(
|
||||
return ` ${nameMsg}: ${fromMsg} -> ${toMsg}`;
|
||||
}
|
||||
|
||||
// deno-lint-ignore no-console
|
||||
console.log(formatUpgradeMsg(denoJson.name!, current, next));
|
||||
// deno-lint-ignore no-console
|
||||
console.log(formatUpgradeMsg(initJson.name!, currentInit, next));
|
||||
// deno-lint-ignore no-console
|
||||
console.log(formatUpgradeMsg(updateJson.name!, currentUpdate, next));
|
||||
|
||||
if (!confirm("Proceed with update?")) {
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
import * as tsmorph from "ts-morph";
|
||||
import { type ImportState, SyntaxKind } from "./update.ts";
|
||||
|
||||
export function maybePrependReqVar(
|
||||
method:
|
||||
| tsmorph.MethodDeclaration
|
||||
| tsmorph.FunctionDeclaration
|
||||
| tsmorph.FunctionExpression
|
||||
| tsmorph.ArrowFunction,
|
||||
newImports: ImportState,
|
||||
hasInferredTypes: boolean,
|
||||
) {
|
||||
let hasRequestVar = false;
|
||||
const params = method.getParameters();
|
||||
if (params.length > 0) {
|
||||
const paramName = params[0].getName();
|
||||
|
||||
// Add explicit types if the user did that
|
||||
if (hasInferredTypes && params[0].getTypeNode()) {
|
||||
hasInferredTypes = false;
|
||||
}
|
||||
|
||||
hasRequestVar = params.length > 1 || paramName === "req";
|
||||
if (hasRequestVar || paramName === "_req") {
|
||||
if (hasRequestVar && params.length === 1) {
|
||||
params[0].replaceWithText("ctx");
|
||||
if (!hasInferredTypes) {
|
||||
newImports.core.add("FreshContext");
|
||||
params[0].setType("FreshContext");
|
||||
}
|
||||
} else {
|
||||
params[0].remove();
|
||||
|
||||
// Use proper type
|
||||
if (params.length > 1) {
|
||||
const initType = params[1].getTypeNode()?.getText();
|
||||
if (initType !== undefined && initType === "RouteContext") {
|
||||
newImports.core.add("FreshContext");
|
||||
params[1].setType("FreshContext");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const maybeObjBinding = params.length > 1
|
||||
? params[1].getNameNode()
|
||||
: undefined;
|
||||
|
||||
if (method.isKind(SyntaxKind.ArrowFunction)) {
|
||||
const body = method.getBody();
|
||||
if (body !== undefined && !body.isKind(SyntaxKind.Block)) {
|
||||
// deno-lint-ignore no-console
|
||||
console.warn(`Cannot transform arrow function`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
(maybeObjBinding === undefined ||
|
||||
!maybeObjBinding.isKind(SyntaxKind.ObjectBindingPattern)) &&
|
||||
hasRequestVar &&
|
||||
!paramName.startsWith("_")
|
||||
) {
|
||||
method.insertVariableStatement(0, {
|
||||
declarationKind: tsmorph.VariableDeclarationKind.Const,
|
||||
declarations: [{
|
||||
name: paramName,
|
||||
initializer: "ctx.req",
|
||||
}],
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
maybeObjBinding !== undefined &&
|
||||
maybeObjBinding.isKind(SyntaxKind.ObjectBindingPattern)
|
||||
) {
|
||||
const objBinding = maybeObjBinding as tsmorph.ObjectBindingPattern;
|
||||
const bindings = objBinding.getElements();
|
||||
if (bindings.length > 0) {
|
||||
let needsRemoteAddr = false;
|
||||
for (let i = 0; i < bindings.length; i++) {
|
||||
const binding = bindings[i];
|
||||
const name = binding.getName();
|
||||
if (name === "remoteAddr") {
|
||||
binding.replaceWithText("info");
|
||||
needsRemoteAddr = true;
|
||||
}
|
||||
}
|
||||
if (hasRequestVar && !paramName.startsWith("_")) {
|
||||
const txt = maybeObjBinding.getFullText().slice(0, -2);
|
||||
maybeObjBinding.replaceWithText(txt + ", req }");
|
||||
}
|
||||
|
||||
if (needsRemoteAddr) {
|
||||
method.insertVariableStatement(0, {
|
||||
declarationKind: tsmorph.VariableDeclarationKind.Const,
|
||||
declarations: [{
|
||||
name: "remoteAddr",
|
||||
initializer: "info.remoteAddr",
|
||||
}],
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,16 +22,20 @@ ensureMinDenoVersion(MIN_DENO_VERSION);
|
||||
|
||||
const flags = parseArgs(Deno.args, {});
|
||||
|
||||
// deno-lint-ignore no-console
|
||||
console.log(colors.bgRgb8(
|
||||
colors.rgb8(" 🍋 Fresh Updater ", 0),
|
||||
121,
|
||||
));
|
||||
// deno-lint-ignore no-console
|
||||
console.log();
|
||||
// deno-lint-ignore no-console
|
||||
console.log(
|
||||
colors.italic(
|
||||
"Note: Breaking changes may require additional manual updates.",
|
||||
),
|
||||
);
|
||||
// deno-lint-ignore no-console
|
||||
console.log();
|
||||
|
||||
let unresolvedDirectory = Deno.args[0];
|
||||
|
||||
@@ -2,7 +2,7 @@ import * as path from "@std/path";
|
||||
import * as JSONC from "@std/jsonc";
|
||||
import * as tsmorph from "ts-morph";
|
||||
|
||||
const SyntaxKind = tsmorph.ts.SyntaxKind;
|
||||
export const SyntaxKind = tsmorph.ts.SyntaxKind;
|
||||
|
||||
export const FRESH_VERSION = "2.0.0-alpha.16";
|
||||
export const PREACT_VERSION = "10.22.0";
|
||||
@@ -57,7 +57,7 @@ async function updateDenoJson(
|
||||
throw new Error(`Could not find deno.json or deno.jsonc in: ${dir}`);
|
||||
}
|
||||
|
||||
interface ImportState {
|
||||
export interface ImportState {
|
||||
core: Set<string>;
|
||||
runtime: Set<string>;
|
||||
compat: Set<string>;
|
||||
@@ -101,6 +101,7 @@ export async function updateProject(dir: string) {
|
||||
try {
|
||||
return await updateFile(sourceFile);
|
||||
} catch (err) {
|
||||
// deno-lint-ignore no-console
|
||||
console.error(`Could not process ${sourceFile.getFilePath()}`);
|
||||
throw err;
|
||||
}
|
||||
@@ -348,6 +349,7 @@ function maybePrependReqVar(
|
||||
if (method.isKind(SyntaxKind.ArrowFunction)) {
|
||||
const body = method.getBody();
|
||||
if (!body.isKind(SyntaxKind.Block)) {
|
||||
// deno-lint-ignore no-console
|
||||
console.warn(`Cannot transform arrow function`);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ export function ensureMinDenoVersion(minVersion: string) {
|
||||
}
|
||||
|
||||
export function error(message: string): never {
|
||||
// deno-lint-ignore no-console
|
||||
console.error(`%cerror%c: ${message}`, "color: red; font-weight: bold", "");
|
||||
Deno.exit(1);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ export default function CopyArea(props: { code: string }) {
|
||||
copied.value = true;
|
||||
} catch (error) {
|
||||
copied.value = false;
|
||||
// deno-lint-ignore no-console
|
||||
console.error((error && error.message) || "Copy failed");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ function ga4(
|
||||
if (GA4_MEASUREMENT_ID === undefined) {
|
||||
if (!showedMissingEnvWarning) {
|
||||
showedMissingEnvWarning = true;
|
||||
// deno-lint-ignore no-console
|
||||
console.warn(
|
||||
"GA4_MEASUREMENT_ID environment variable not set. Google Analytics reporting disabled.",
|
||||
);
|
||||
@@ -81,6 +82,7 @@ function ga4(
|
||||
|
||||
await report.send();
|
||||
}).catch((err) => {
|
||||
// deno-lint-ignore no-console
|
||||
console.error(err);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -6,16 +6,19 @@ const url = Deno.args[0];
|
||||
const id = Deno.args[1];
|
||||
|
||||
if (Deno.args.length == 0) {
|
||||
// deno-lint-ignore no-console
|
||||
console.log("Usage: screenshot <url> <id>");
|
||||
Deno.exit(0);
|
||||
}
|
||||
|
||||
if (!(url.match(/^http[s]?:\/\//)) || !url) {
|
||||
// deno-lint-ignore no-console
|
||||
console.log("Provided URL is Broken or Wrong");
|
||||
Deno.exit(0);
|
||||
}
|
||||
|
||||
if (!id) {
|
||||
// deno-lint-ignore no-console
|
||||
console.log("Provide id to Process");
|
||||
Deno.exit(0);
|
||||
}
|
||||
@@ -31,6 +34,7 @@ const raw = await page.screenshot();
|
||||
await browser.close();
|
||||
|
||||
if (!(raw instanceof Uint8Array)) {
|
||||
// deno-lint-ignore no-console
|
||||
console.log("Invalid Image");
|
||||
Deno.exit(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user