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: deprecate --file and add release #1639

Merged
merged 3 commits into from
Jan 21, 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/rude-pets-begin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@asyncapi/cli': minor
---

Deprecate the --file flag in `start studio` command
4 changes: 2 additions & 2 deletions action-template.yml
Original file line number Diff line number Diff line change
@@ -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.'
Expand Down
10 changes: 8 additions & 2 deletions src/commands/start/studio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,21 @@ 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 {
filePath = ((await load()).getFilePath());
this.log(`Loaded specification from: ${filePath}`);
} catch (error) {
filePath = '';
this.log('No file specified.');
this.error('No file specified.');
}
}
try {
Expand Down
1 change: 1 addition & 0 deletions src/core/flags/start/studio.flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' }),
};
};
4 changes: 2 additions & 2 deletions src/core/models/Studio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 @@ -115,8 +115,8 @@
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);
Expand Down
Loading