diff --git a/cli/dev/DevServer.ts b/cli/dev/DevServer.ts index 7ad4735c..856cb5c8 100644 --- a/cli/dev/DevServer.ts +++ b/cli/dev/DevServer.ts @@ -20,6 +20,7 @@ import kleur from "kleur" import { loadProjectConfig } from "lib/project-config" import { shouldIgnorePath } from "lib/shared/should-ignore-path" import { getAllNodeModuleFilePaths } from "lib/dependency-analysis/getNodeModuleDependencies" +import { setSessionToken } from "lib/cli-config" const debug = Debug("tscircuit:devserver") @@ -118,6 +119,10 @@ export class DevServer { this.handleInstallPackage(event.full_package_name), ) + this.eventsWatcher.on("TOKEN_UPDATED", (event) => + this.handleTokenUpdated(event.registry_token), + ) + this.filesystemWatcher = chokidar.watch(this.projectDir, { persistent: true, ignoreInitial: true, @@ -488,4 +493,15 @@ export class DevServer { ) } } + + private handleTokenUpdated(registry_token: string) { + try { + setSessionToken(registry_token) + console.log( + kleur.green("Session token overridden successfully via runframe"), + ) + } catch (err) { + console.error("Failed to update session token:", err) + } + } }