From 2837e15cb304bba7b4f797eb3b45c73049f97778 Mon Sep 17 00:00:00 2001 From: Zack_Aayush <60972989+AayushSaini101@users.noreply.github.com> Date: Tue, 12 Sep 2023 16:40:17 +0530 Subject: [PATCH 1/2] feat: add checks to verify Extension of files (#795) Co-authored-by: Aayush --- src/commands/new/file.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/commands/new/file.ts b/src/commands/new/file.ts index ac94083201c..98159a3f6d4 100644 --- a/src/commands/new/file.ts +++ b/src/commands/new/file.ts @@ -138,8 +138,21 @@ export default class NewFile extends Command { async createAsyncapiFile(fileName:string, selectedTemplate:string) { const asyncApiFile = await readFile(resolve(__dirname, '../../../assets/examples/', selectedTemplate), { encoding: 'utf8' }); - const fileNameHasFileExtension = fileName.includes('.'); - const fileNameToWriteToDisk = fileNameHasFileExtension ? fileName : `${fileName}.yaml`; + let fileNameToWriteToDisk; + + if (!fileName.includes('.')) { + fileNameToWriteToDisk=`${fileName}.yaml`; + } else { + const extension=fileName.split('.')[1]; + + if (extension==='yml'||extension==='yaml'||extension==='json') { + fileNameToWriteToDisk=fileName; + } else { + console.log('CLI Support only yml, yaml and json extension for file'); + + return; + } + } try { const content = await readFile(fileNameToWriteToDisk, { encoding: 'utf8' }); From 27bef88cf0c9b7ba9079a616ab0e566389005dcd Mon Sep 17 00:00:00 2001 From: asyncapi-bot Date: Tue, 12 Sep 2023 13:18:06 +0200 Subject: [PATCH 2/2] chore(release): v0.55.0 (#796) --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index e779e02c882..262f19474f3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@asyncapi/cli", - "version": "0.54.8", + "version": "0.55.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@asyncapi/cli", - "version": "0.54.8", + "version": "0.55.0", "license": "Apache-2.0", "dependencies": { "@asyncapi/avro-schema-parser": "^3.0.2", diff --git a/package.json b/package.json index 6a195246171..3275258db08 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@asyncapi/cli", "description": "All in one CLI for all AsyncAPI tools", - "version": "0.54.8", + "version": "0.55.0", "author": "@asyncapi", "bin": { "asyncapi": "./bin/run"