From a37e1241f05ad2b923f9d50cc63779092cba8511 Mon Sep 17 00:00:00 2001 From: Ashish Padhy Date: Tue, 21 Jan 2025 23:07:07 +0530 Subject: [PATCH] fix: deprecate --file and add release (#1639) * chore: deprecate -file flag in studio Signed-off-by: Ashish Padhy <100484401+Shurtu-gal@users.noreply.github.com> * chore: update action-template Signed-off-by: Ashish Padhy <100484401+Shurtu-gal@users.noreply.github.com> * chore: add changeset Signed-off-by: Ashish Padhy <100484401+Shurtu-gal@users.noreply.github.com> --------- Signed-off-by: Ashish Padhy <100484401+Shurtu-gal@users.noreply.github.com> --- .changeset/rude-pets-begin.md | 5 +++++ action-template.yml | 4 ++-- src/commands/start/studio.ts | 10 ++++++++-- src/core/flags/start/studio.flags.ts | 1 + src/core/models/Studio.ts | 4 ++-- 5 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 .changeset/rude-pets-begin.md diff --git a/.changeset/rude-pets-begin.md b/.changeset/rude-pets-begin.md new file mode 100644 index 00000000000..13bd6145284 --- /dev/null +++ b/.changeset/rude-pets-begin.md @@ -0,0 +1,5 @@ +--- +'@asyncapi/cli': minor +--- + +Deprecate the --file flag in `start studio` command diff --git a/action-template.yml b/action-template.yml index 40aba410cbb..7b948e50d69 100644 --- a/action-template.yml +++ b/action-template.yml @@ -1,5 +1,5 @@ -name: 'Generator, Validator, Converter and others - all in one for your AsyncAPI docs' -description: 'Use this action to generate docs or code from your AsyncAPI document. Use default templates or provide your custom ones.' +name: 'AsyncAPI CLI Action' +description: 'One stop solution for all your AsyncAPI Specification needs in github actions.' inputs: cli_version: description: 'Version of AsyncAPI CLI to be used. This is only needed if you want to test with a specific version of AsyncAPI CLI. Default is latest which is also the recommended option.' diff --git a/src/commands/start/studio.ts b/src/commands/start/studio.ts index 69e206c3bbd..0395490336f 100644 --- a/src/commands/start/studio.ts +++ b/src/commands/start/studio.ts @@ -15,7 +15,13 @@ export default class StartStudio extends Command { async run() { const { args, flags } = await this.parse(StartStudio); - let filePath = args['spec-file']; + + if (flags.file) { + this.warn('The file flag has been removed and is being replaced by the argument spec-file. Please pass the filename directly like `asyncapi start studio asyncapi.yml`'); + } + + let filePath = args['spec-file'] ?? flags.file; + const port = flags.port; if (!filePath) { try { @@ -23,7 +29,7 @@ export default class StartStudio extends Command { this.log(`Loaded specification from: ${filePath}`); } catch (error) { filePath = ''; - this.log('No file specified.'); + this.error('No file specified.'); } } try { diff --git a/src/core/flags/start/studio.flags.ts b/src/core/flags/start/studio.flags.ts index 008907f7994..532d40cce40 100644 --- a/src/core/flags/start/studio.flags.ts +++ b/src/core/flags/start/studio.flags.ts @@ -3,6 +3,7 @@ import { Flags } from '@oclif/core'; export const studioFlags = () => { return { help: Flags.help({ char: 'h' }), + file: Flags.string({ char: 'f', description: 'path to the AsyncAPI file to link with Studio', deprecated: true }), port: Flags.integer({ char: 'p', description: 'port in which to start Studio' }), }; }; diff --git a/src/core/models/Studio.ts b/src/core/models/Studio.ts index 69b08171686..21c291c5858 100644 --- a/src/core/models/Studio.ts +++ b/src/core/models/Studio.ts @@ -115,8 +115,8 @@ export function start(filePath: string, port: number = DEFAULT_PORT): void { if (filePath) { console.log(`Watching changes on file ${filePath}`); } else { - console.log( - 'Hint : 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.' + 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.' ); } open(url);