From 81b11cdaf1f589dc72558362c455fce4eecba345 Mon Sep 17 00:00:00 2001 From: Samir AMZANI Date: Mon, 19 Feb 2024 16:56:16 +0100 Subject: [PATCH] fix: Studio cache issues --- src/models/Studio.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/models/Studio.ts b/src/models/Studio.ts index 8baab2ec012..a65e614cbc9 100644 --- a/src/models/Studio.ts +++ b/src/models/Studio.ts @@ -6,6 +6,7 @@ import { WebSocketServer } from 'ws'; import chokidar from 'chokidar'; import open from 'open'; import path from 'path'; +import { version as studioVersion } from '@asyncapi/studio/package.json'; const { readFile, writeFile } = fPromises; @@ -46,7 +47,7 @@ export function start(filePath: string, port: number = DEFAULT_PORT): void { const server = createServer((request, response) => { //not all CLI users use npm. Some package managers put dependencies in different weird places - //this is why we need to first figure out where exactly is the index.html located + //this is why we need to first figure out where exactly is the index.html located //and then strip index.html from the path to point to directory with the rest of the studio const indexLocation = require.resolve('@asyncapi/studio/build/index.html'); const hostFolder = indexLocation.substring(0, indexLocation.lastIndexOf(path.sep)); @@ -88,16 +89,16 @@ export function start(filePath: string, port: number = DEFAULT_PORT): void { } } catch (e) { console.error(`Live Server: An invalid event has been received. See details:\n${event}`); - } + } }); }); - + wsServer.on('close', (socket: any) => { sockets.splice(sockets.findIndex(s => s === socket)); }); server.listen(port, () => { - const url = `http://localhost:${port}?liveServer=${port}`; + const url = `http://localhost:${port}?liveServer=${port}&_sv=${studioVersion}`; console.log(`Studio is running at ${url}`); console.log(`Watching changes on file ${filePath}`); open(url);