From 24a2adcc34e6275e2be78b989b4c594ce3c731f9 Mon Sep 17 00:00:00 2001 From: Simon Laux Date: Mon, 4 Aug 2025 14:12:16 +0000 Subject: [PATCH 1/2] clearer startup message - Log url the user should open in browser and make that log message stand out a bit - hide instance started messages unless `NODE_DEBUG` is set closes #73 --- backend/instance.ts | 5 ++++- backend/run.ts | 11 +++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/backend/instance.ts b/backend/instance.ts index 7c3c297..c3660df 100644 --- a/backend/instance.ts +++ b/backend/instance.ts @@ -10,6 +10,7 @@ import { AppInfo } from "./appInfo"; import { getColorForId } from "./color"; import { Instance as FrontendInstance } from "../types/instance"; import { getInstanceUrl } from "./instance_url"; +import { env } from "process"; export type Options = { basePort: number; @@ -53,7 +54,9 @@ class Instance { start() { this.server = this.app.listen(this.port, () => { - console.log(`Starting webxdc instance at port ${this.port}`); + if (env['NODE_DEBUG']) { + console.debug(`Starting webxdc instance at port ${this.port}`); + } }); } diff --git a/backend/run.ts b/backend/run.ts index c47b0b1..9140af6 100644 --- a/backend/run.ts +++ b/backend/run.ts @@ -1,11 +1,12 @@ import detectPort from "detect-port"; -import process from "process"; +import process, { env } from "process"; import open from "open"; import { createFrontend, InjectExpress } from "./app"; import { Instances, Options } from "./instance"; import { getLocation, Location, LocationError } from "./location"; import { getAppInfo, AppInfo, AppInfoError } from "./appInfo"; +import { getInstanceUrl } from "./instance_url"; export type Inject = { injectFrontend: InjectExpress; @@ -35,12 +36,14 @@ async function actualRun( ); frontend.listen(options.basePort, () => { - console.log("Starting webxdc-dev frontend"); + console.info(`\n=> Started webxdc-dev frontend on ${getInstanceUrl(options.basePort)}`); }); instances.start(); - open("http://localhost:" + options.basePort); + if (!env["CODESPACE_NAME"]) { // do not auto open on gh codespace + open("http://localhost:" + options.basePort); + } } export async function run( @@ -65,7 +68,7 @@ export async function run( }); } - console.log("Starting webxdc project in:", locationStr); + console.debug("Starting webxdc project in:", locationStr); try { const appInfo = await getAppInfo(location); From c2a4054c62057ddf73e8fbb66dabcf9b99520462 Mon Sep 17 00:00:00 2001 From: Simon Laux Date: Mon, 4 Aug 2025 14:17:46 +0000 Subject: [PATCH 2/2] fix fmt --- backend/instance.ts | 2 +- backend/run.ts | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/backend/instance.ts b/backend/instance.ts index c3660df..b987cdb 100644 --- a/backend/instance.ts +++ b/backend/instance.ts @@ -54,7 +54,7 @@ class Instance { start() { this.server = this.app.listen(this.port, () => { - if (env['NODE_DEBUG']) { + if (env["NODE_DEBUG"]) { console.debug(`Starting webxdc instance at port ${this.port}`); } }); diff --git a/backend/run.ts b/backend/run.ts index 9140af6..9cdfd78 100644 --- a/backend/run.ts +++ b/backend/run.ts @@ -36,12 +36,15 @@ async function actualRun( ); frontend.listen(options.basePort, () => { - console.info(`\n=> Started webxdc-dev frontend on ${getInstanceUrl(options.basePort)}`); + console.info( + `\n=> Started webxdc-dev frontend on ${getInstanceUrl(options.basePort)}`, + ); }); instances.start(); - if (!env["CODESPACE_NAME"]) { // do not auto open on gh codespace + if (!env["CODESPACE_NAME"]) { + // do not auto open on gh codespace open("http://localhost:" + options.basePort); } }