From 64b7cbd492060178691e09c57eb653b6d7cfedbe Mon Sep 17 00:00:00 2001 From: Adi-204 Date: Tue, 4 Feb 2025 19:19:28 +0530 Subject: [PATCH 1/4] feat: change the implementation of new command --- docs/usage.md | 49 +++------------------------------------ src/commands/new/index.ts | 11 +++++++-- 2 files changed, 12 insertions(+), 48 deletions(-) diff --git a/docs/usage.md b/docs/usage.md index 62349fbdb7c..0b2b8df4e6e 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -537,58 +537,15 @@ _See code: [src/commands/generate/models.ts](https://github.com/asyncapi/cli/blo ## `asyncapi new` -Creates a new asyncapi file +Create a new AsyncAPI project, specification files, or templates for clients and applications. ``` USAGE - $ asyncapi new [-h] [-n ] [-e ] [-s] [-p ] [--no-tty] - -FLAGS - -e, --example= - name of the example to use. Available examples are: - - simple-asyncapi.yml - - adeo-kafka-request-reply-asyncapi.yml - - anyof-asyncapi.yml - - application-headers-asyncapi.yml - - correlation-id-asyncapi.yml - - websocket-gemini-asyncapi.yml - - gitter-streaming-asyncapi.yml - - kraken-websocket-request-reply-message-filter-in-reply-asyncapi.yml - - kraken-websocket-request-reply-multiple-channels-asyncapi.yml - - mercure-asyncapi.yml - - not-asyncapi.yml - - operation-security-asyncapi.yml - - oneof-asyncapi.yml - - rpc-client-asyncapi.yml - - rpc-server-asyncapi.yml - - slack-rtm-asyncapi.yml - - tutorial.yml - - streetlights-kafka-asyncapi.yml - - streetlights-operation-security-asyncapi.yml - - streetlights-mqtt-asyncapi.yml - - -h, --help - Show CLI help. - - -n, --file-name= - name of the file - - -p, --port= - port in which to start Studio - - -s, --studio - open in Studio - - --no-tty - do not use an interactive terminal + $ asyncapi new DESCRIPTION - Creates a new asyncapi file - -EXAMPLES - $ asyncapi new - start creation of a file in interactive mode + Create a new AsyncAPI project, specification files, or templates for clients and applications. - $ asyncapi new --file-name=my-asyncapi.yaml --example=default-example.yaml --no-tty - create a new file with a specific name, using one of the examples and without interactive mode ``` _See code: [src/commands/new/index.ts](https://github.com/asyncapi/cli/blob/v2.14.1/src/commands/new/index.ts)_ diff --git a/src/commands/new/index.ts b/src/commands/new/index.ts index 046699a4497..21681adcf11 100644 --- a/src/commands/new/index.ts +++ b/src/commands/new/index.ts @@ -1,3 +1,10 @@ -import File from './file'; +import Command from '../../core/base'; +import { Help } from '@oclif/core'; -export default class New extends File {} +export default class New extends Command { + static description = 'Create a new AsyncAPI project, specification files, or templates for clients and applications.'; + async run() { + const help = new Help(this.config); + help.showHelp(['new', '--help']); + } +} From b67cd4f2986c3f5dd455fc0824143e4e6a00ff34 Mon Sep 17 00:00:00 2001 From: Adi-204 Date: Tue, 4 Feb 2025 19:51:52 +0530 Subject: [PATCH 2/4] fix: changes in testing --- src/commands/new/index.ts | 2 +- test/integration/new/file.test.ts | 20 -------------------- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/src/commands/new/index.ts b/src/commands/new/index.ts index 21681adcf11..7367ea5e8b4 100644 --- a/src/commands/new/index.ts +++ b/src/commands/new/index.ts @@ -2,7 +2,7 @@ import Command from '../../core/base'; import { Help } from '@oclif/core'; export default class New extends Command { - static description = 'Create a new AsyncAPI project, specification files, or templates for clients and applications.'; + static readonly description = 'Create a new AsyncAPI project, specification files, or templates for clients and applications.'; async run() { const help = new Help(this.config); help.showHelp(['new', '--help']); diff --git a/test/integration/new/file.test.ts b/test/integration/new/file.test.ts index d957857d49f..b1505c62d96 100644 --- a/test/integration/new/file.test.ts +++ b/test/integration/new/file.test.ts @@ -5,31 +5,11 @@ import { expect } from '@oclif/test'; const testHelper = new TestHelper(); describe('new', () => { - before(() => { - try { - testHelper.deleteSpecFileAtWorkingDir(); - } catch (e: any) { - if (e.code !== 'ENOENT') { - throw e; - } - } - }); - describe('create new file', () => { afterEach(() => { testHelper.deleteSpecFileAtWorkingDir(); }); - test - .stderr() - .stdout() - .command(['new', '--no-tty', '-n=specification.yaml']) - .it('runs new command', async (ctx,done) => { - expect(ctx.stderr).to.equal(''); - expect(ctx.stdout).to.equal('The specification.yaml has been successfully created.\n'); - done(); - }); - test .stderr() .stdout() From d6c220971d5c088ec650c54b867b8571817b1752 Mon Sep 17 00:00:00 2001 From: Adi-204 Date: Tue, 4 Feb 2025 20:06:30 +0530 Subject: [PATCH 3/4] fix: some more changes in testing --- test/integration/new/file.test.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/integration/new/file.test.ts b/test/integration/new/file.test.ts index b1505c62d96..89174319a74 100644 --- a/test/integration/new/file.test.ts +++ b/test/integration/new/file.test.ts @@ -5,6 +5,16 @@ import { expect } from '@oclif/test'; const testHelper = new TestHelper(); describe('new', () => { + before(() => { + try { + testHelper.deleteSpecFileAtWorkingDir(); + } catch (e: any) { + if (e.code !== 'ENOENT') { + throw e; + } + } + }); + describe('create new file', () => { afterEach(() => { testHelper.deleteSpecFileAtWorkingDir(); From 864d156f4c7d392ed40d547a923076c649745bf9 Mon Sep 17 00:00:00 2001 From: Moderator <60972989+AayushSaini101@users.noreply.github.com> Date: Fri, 14 Feb 2025 13:08:14 +0530 Subject: [PATCH 4/4] Create cuddly-files-move.md --- .changeset/cuddly-files-move.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/cuddly-files-move.md diff --git a/.changeset/cuddly-files-move.md b/.changeset/cuddly-files-move.md new file mode 100644 index 00000000000..cdf69cb7c02 --- /dev/null +++ b/.changeset/cuddly-files-move.md @@ -0,0 +1,5 @@ +--- +"@asyncapi/cli": patch +--- + +feat: change the implementation of new command