Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add studio-version param to studio URL to address cache issues #1182

Merged
merged 2 commits into from
Feb 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/models/Studio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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}&studio-version=${studioVersion}`;
console.log(`Studio is running at ${url}`);
console.log(`Watching changes on file ${filePath}`);
open(url);
Expand Down
Loading