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

chore: added UI/UX improvements to start command #1641

Merged
merged 2 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .changeset/five-moles-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@asyncapi/cli": patch
---

Added UI/UX improvements to start command
9 changes: 5 additions & 4 deletions src/core/models/Studio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import open from 'open';
import path from 'path';
import { version as studioVersion } from '@asyncapi/studio/package.json';
import { gray } from 'picocolors';
import { blueBright,redBright } from 'picocolors';

const { readFile, writeFile } = fPromises;

Expand All @@ -20,7 +20,7 @@
return existsSync(filePath);
}

export function start(filePath: string, port: number = DEFAULT_PORT): void {

Check warning on line 23 in src/core/models/Studio.ts

View workflow job for this annotation

GitHub Actions / Test NodeJS PR - ubuntu-latest

Refactor this function to reduce its Cognitive Complexity from 23 to the 15 allowed
if (filePath && !isValidFilePath(filePath)) {
throw new SpecificationFileNotFound(filePath);
}
Expand Down Expand Up @@ -110,10 +110,11 @@

server.listen(port, () => {
const url = `http://localhost:${port}?liveServer=${port}&studio-version=${studioVersion}`;
console.log(`Studio is now running at ${url}.`);
console.log(`You can open this URL in your web browser, and if needed, press ${gray('Ctrl + C')} to stop the process.`);
console.log(`🎉 Connected to Live Server running at ${blueBright(url)}.`);
console.log(`🌐 Open this URL in your web browser: ${blueBright(url)}`);
console.log(`🛑 If needed, press ${redBright('Ctrl + C')} to stop the process.`);
if (filePath) {
console.log(`Watching changes on file ${filePath}`);
console.log(`👁️ Watching changes on file ${blueBright(filePath)}`);
} else {
console.warn(
'Warning: No file was provided, and we couldn\'t find a default file (like "asyncapi.yaml" or "asyncapi.json") in the current folder. Starting Studio with a blank workspace.'
Expand Down
Loading