From e7b086d4ebc1a5bc6f00106c67e5789e1d793ef6 Mon Sep 17 00:00:00 2001 From: sarthakKarode Date: Fri, 1 Aug 2025 18:20:25 +0530 Subject: [PATCH 1/3] bump modelina-cli #1818 --- .modelina-cli | 1 + package-lock.json | 36 ++++++++++++------- package.json | 2 +- .../newtemplate/__transpiled/index.js | 2 +- 4 files changed, 27 insertions(+), 14 deletions(-) create mode 100644 .modelina-cli diff --git a/.modelina-cli b/.modelina-cli new file mode 100644 index 00000000000..58e0072ead9 --- /dev/null +++ b/.modelina-cli @@ -0,0 +1 @@ +{"current":"home","store":{"home":"test/fixtures/specification.yml"}} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 6b3bd43f125..7de7babe495 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,7 @@ "@asyncapi/converter": "^1.6.2", "@asyncapi/diff": "^0.5.0", "@asyncapi/generator": "^1.17.25", - "@asyncapi/modelina-cli": "^4.0.4", + "@asyncapi/modelina-cli": "^5.3.5", "@asyncapi/openapi-schema-parser": "^3.0.24", "@asyncapi/optimizer": "^1.0.4", "@asyncapi/parser": "^3.3.0", @@ -388,9 +388,9 @@ "link": true }, "node_modules/@asyncapi/modelina": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@asyncapi/modelina/-/modelina-4.0.4.tgz", - "integrity": "sha512-jYXvcTvqM12LirYXOFVrx9wsSCoq0zVPY66QipkPH7n02rfc2WCbChoWvWteDnNSDv6u0JMd8iW/FqKwNcvNTg==", + "version": "5.3.7", + "resolved": "https://registry.npmjs.org/@asyncapi/modelina/-/modelina-5.3.7.tgz", + "integrity": "sha512-2K3wduAkSs3YyJ6BoitbqeCmVFPQdUzMaMpemMlgve4162xmCu0An+Y6eDqvnDEzn4DLP6UeYo2R6DMIoI9VCg==", "license": "Apache-2.0", "dependencies": { "@apidevtools/json-schema-ref-parser": "^11.1.0", @@ -400,7 +400,7 @@ "alterschema": "^1.1.2", "change-case": "^4.1.2", "js-yaml": "^4.1.0", - "openapi-types": "9.3.0", + "openapi-types": "^12.1.3", "typescript-json-schema": "^0.58.1" }, "engines": { @@ -408,12 +408,12 @@ } }, "node_modules/@asyncapi/modelina-cli": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@asyncapi/modelina-cli/-/modelina-cli-4.0.4.tgz", - "integrity": "sha512-xSHv2t4er7CreI4/edzCzmxE18tqnqRkGnYnV0omTQh6WC3foXBdNVixlIr1z0IMMITTQmDBurCNdEhv7fmmWw==", + "version": "5.3.5", + "resolved": "https://registry.npmjs.org/@asyncapi/modelina-cli/-/modelina-cli-5.3.5.tgz", + "integrity": "sha512-012vJKYbpBpF5VtFC2bg58yAbfGYnYbvvdqDh9cdOhNrzPUcCcATGbXSrKFJ9KnvlCb50KSHAQoiOdROUr/e3g==", "license": "Apache-2.0", "dependencies": { - "@asyncapi/modelina": "^4.0.0-next.64", + "@asyncapi/modelina": "^5.0.0", "@oclif/core": "^3.26.0", "@oclif/errors": "^1.3.6", "@oclif/plugin-autocomplete": "^3.0.16", @@ -3549,6 +3549,18 @@ "sisteransi": "^1.0.5" } }, + "node_modules/@clack/prompts/node_modules/is-unicode-supported": { + "version": "1.3.0", + "extraneous": true, + "inBundle": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/@codemirror/autocomplete": { "version": "6.18.6", "license": "MIT", @@ -19798,9 +19810,9 @@ } }, "node_modules/openapi-types": { - "version": "9.3.0", - "resolved": "https://registry.npmjs.org/openapi-types/-/openapi-types-9.3.0.tgz", - "integrity": "sha512-sR23YjmuwDSMsQVZDHbV9mPgi0RyniQlqR0AQxTC2/F3cpSjRFMH3CFPjoWvNqhC4OxPkDYNb2l8Mc1Me6D/KQ==", + "version": "12.1.3", + "resolved": "https://registry.npmjs.org/openapi-types/-/openapi-types-12.1.3.tgz", + "integrity": "sha512-N4YtSYJqghVu4iek2ZUvcN/0aqH1kRDuNqzcycDxhOUpg7GdvLa2F3DgS6yBNhInhv2r/6I0Flkn7CqL8+nIcw==", "license": "MIT" }, "node_modules/optionator": { diff --git a/package.json b/package.json index 5367c5bcff1..71b116d80d1 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "@asyncapi/converter": "^1.6.2", "@asyncapi/diff": "^0.5.0", "@asyncapi/generator": "^1.17.25", - "@asyncapi/modelina-cli": "^4.0.4", + "@asyncapi/modelina-cli": "^5.3.5", "@asyncapi/openapi-schema-parser": "^3.0.24", "@asyncapi/optimizer": "^1.0.4", "@asyncapi/parser": "^3.3.0", diff --git a/test/fixtures/newtemplate/__transpiled/index.js b/test/fixtures/newtemplate/__transpiled/index.js index d1963faea69..57b3ea31ec0 100644 --- a/test/fixtures/newtemplate/__transpiled/index.js +++ b/test/fixtures/newtemplate/__transpiled/index.js @@ -2,7 +2,7 @@ require('source-map-support/register'); var generatorReactSdk = require('@asyncapi/generator-react-sdk'); -var jsxRuntime = require('/Users/aaayush/Desktop/OpenSourceContribution/cli/node_modules/@asyncapi/generator-react-sdk/node_modules/react/cjs/react-jsx-runtime.production.min.js'); +var jsxRuntime = require('/Users/sarthakkarode/cli/node_modules/@asyncapi/generator-react-sdk/node_modules/react/cjs/react-jsx-runtime.production.min.js'); function index ({ asyncapi, From f1b604c67962720c5f998cfad5c10f5744a293d2 Mon Sep 17 00:00:00 2001 From: sarthakKarode Date: Fri, 1 Aug 2025 23:09:47 +0530 Subject: [PATCH 2/3] fixed issue#1829 --- asyncapi.yaml | 34 +++++++++++++++++++ src/commands/generate/fromTemplate.ts | 8 +++-- src/core/flags/generate/fromTemplate.flags.ts | 5 +++ 3 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 asyncapi.yaml diff --git a/asyncapi.yaml b/asyncapi.yaml new file mode 100644 index 00000000000..41a84acd4fb --- /dev/null +++ b/asyncapi.yaml @@ -0,0 +1,34 @@ +asyncapi: '2.6.0' +info: + title: Streetlights API + version: '1.0.0' + description: | + The Smartylighting Streetlights API allows you to remotely manage streetlights. + You can turn them on/off, change their brightness and color. +servers: + production: + url: mqtt://smartylighting.com + protocol: mqtt +defaultContentType: application/json +channels: + light/measured: + description: The topic on which light measurements are sent. + subscribe: + summary: Receive information about environmental lighting conditions of a particular streetlight. + message: + name: lightMeasured + payload: + type: object + properties: + id: + type: integer + minimum: 0 + description: Id of the streetlight. + lumens: + type: integer + minimum: 0 + description: Light intensity measured in lumens. + sentAt: + type: string + format: date-time + description: Date and time when the message was sent. diff --git a/src/commands/generate/fromTemplate.ts b/src/commands/generate/fromTemplate.ts index e5706fd38b9..a7a41cc856f 100644 --- a/src/commands/generate/fromTemplate.ts +++ b/src/commands/generate/fromTemplate.ts @@ -71,6 +71,7 @@ export default class Template extends Command { async run() { const { args, flags } = await this.parse(Template); // NOSONAR + const compile = flags['compile']; const interactive = !flags['no-interactive']; let asyncapi = args['asyncapi'] ?? ''; let template = args['template'] ?? ''; @@ -123,7 +124,7 @@ export default class Template extends Command { } } if (flags['use-new-generator']) { - await this.generateUsingNewGenerator(asyncapi, template, output, options, genOption); + await this.generateUsingNewGenerator(asyncapi, template, output, options, genOption, compile); } else { await this.generate(asyncapi, template, output, options, genOption, interactive); } @@ -287,7 +288,8 @@ export default class Template extends Command { s.stop(`${yellow('Check out your shiny new generated files at ') + magenta(output) + yellow('.')}\n`); } - private async generateUsingNewGenerator(asyncapi: string | undefined, template: string, output: string, options: any, genOption: any) { + private async generateUsingNewGenerator(asyncapi: string | undefined, template: string, output: string, options: any, genOption: any, compile: boolean) { + console.log('⚙️ compile flag is:', compile); let specification: Specification; try { specification = await load(asyncapi); @@ -300,7 +302,7 @@ export default class Template extends Command { { exit: 1 }, ); } - const generator = new AsyncAPINewGenerator(template, output || path.resolve(os.tmpdir(), 'asyncapi-generator'), options); + const generator = new AsyncAPINewGenerator(template, output || path.resolve(os.tmpdir(), 'asyncapi-generator'), { ...options, compile }); this.log('Generation in progress. Keep calm and wait a bit'); try { await generator.generateFromString(specification.text(), { ...genOption, path: asyncapi }); diff --git a/src/core/flags/generate/fromTemplate.flags.ts b/src/core/flags/generate/fromTemplate.flags.ts index 0469cedfddd..52c171dfbfc 100644 --- a/src/core/flags/generate/fromTemplate.flags.ts +++ b/src/core/flags/generate/fromTemplate.flags.ts @@ -35,6 +35,11 @@ export const fromTemplateFlags = () => { default: false, description: 'Force writing of the generated files to given directory even if it is a git repo with unstaged files or not empty dir (defaults to false)' }), + compile: Flags.boolean({ + description: 'Compile the template before generating. Set to false to skip.', + default: true, + allowNo: true, + }), watch: watchFlag( 'Watches the template directory and the AsyncAPI document, and re-generate the files when changes occur. Ignores the output directory.' ), From 69f50fa5da76d67e74ac6ad9aafbe445460baff5 Mon Sep 17 00:00:00 2001 From: asyncapi-bot Date: Fri, 1 Aug 2025 17:46:56 +0000 Subject: [PATCH 3/3] chore: add changeset for PR #1832 --- .changeset/1832.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .changeset/1832.md diff --git a/.changeset/1832.md b/.changeset/1832.md new file mode 100644 index 00000000000..595346aed4c --- /dev/null +++ b/.changeset/1832.md @@ -0,0 +1,10 @@ +--- +'@asyncapi/cli': minor +--- + +feat: add --compile flag support to generate fromTemplate command Issue#1829 + +- e7b086d: bump modelina-cli #1818 +- f1b604c: fixed issue#1829 + +