generator icon indicating copy to clipboard operation
generator copied to clipboard

Proof of concept of templates as part of generator monorepo

Open derberg opened this issue 1 year ago • 8 comments

We know we want to have some core templates developed under this repo, as a result of:

  • https://github.com/asyncapi/generator/issues/1249
  • https://github.com/asyncapi/generator/issues/1044

This PoC needs to answer questions like:

  • do we need to release such internal templates separately, as npm modules
  • how generator release relates to template release
  • how it will be used in the AsyncAPI CLI
  • do we keep name templates? or leave it only for extensibility part?
  • maybe https://github.com/asyncapi/nodejs-template could be moved as an example - not 100% sure as it may make things complex for review
  • how shared helpers will be maintained and tested
  • how shared components will be maintained and tested
  • should helpers and components be released as independent package? so template developers that write templates outside, can still use these. For example instead of telling people https://www.asyncapi.com/docs/tools/generator/model-generation we could have a build in components for types generation, so people do not really have to even know what modelina is and add it to dependencies
  • how testing is split

Resulting PR not necessarily needs to be merged, but should be in state that helps to followup with exact implementation

derberg avatar Sep 16 '24 11:09 derberg

As maintainer of generator I wanna work on this issue

derberg avatar Sep 16 '24 11:09 derberg

Looking forward to see a working solution of it

Gmin2 avatar Sep 16 '24 12:09 Gmin2

I have been thinking about this in the past couple weeks. I will come up with a tentative plan sometime today.

lmgyuan avatar Sep 16 '24 12:09 lmgyuan

Bounty Issue's service comment

Text labels: bounty/2024-Q4, bounty/advanced, bounty/coding First assignment to regular contributors: 2024-09-20 00:00:00 UTC+12:00 End Of Life after: 2024-10-31 23:59:59 UTC-12:00

@asyncapi/bounty_team

The Bounty Program is not a Mentorship Program. The accepted level of Bounty Program Participants is Middle/Senior.
Regular contributors should explain in meaningful words how they are going to approach the resolution process when expressing a desire to work on this Bounty Issue.

aeworxet avatar Sep 16 '24 15:09 aeworxet

@derberg says,

As maintainer of generator I wanna work on this issue

https://github.com/asyncapi/generator/issues/1269#issuecomment-2352704655

aeworxet avatar Sep 16 '24 17:09 aeworxet

@derberg is an AsyncAPI Maintainer specified in https://raw.githubusercontent.com/asyncapi/community/master/MAINTAINERS.yaml, so they fall under the first category in the prioritization list.

aeworxet avatar Sep 18 '24 10:09 aeworxet

Bounty Issue's Timeline

Complexity Level Assignment Date (by GitHub) Start Date (by BP Rules) End Date (by BP Rules) Draft PR Submission Final PR Merge Start Final PR Merge End
Advanced 2024-09-18 2024-10-07 2024-12-01 2024-10-27 2024-11-17 2024-12-01
Please note that the dates given represent deadlines, not specific dates, so if the goal is reached sooner, it's better.
Keep in mind the responsibility for violations of the Timeline.

aeworxet avatar Sep 18 '24 10:09 aeworxet

fyi, I'm a bit delayed here, lost laptop and conference travel, now a bit overwhelmed by PRs from Hacktoberfest - but all good, still on track

derberg avatar Oct 09 '24 13:10 derberg

ok, I started working on the PoC

first focus is on reusable components package, and first citizen componen we need, for models generatio, so instead of asking people to do

/ 1
import { File } from '@asyncapi/generator-react-sdk';
// 2
import { PythonGenerator, FormatHelpers } from '@asyncapi/modelina';

/**
 * @typedef RenderArgument
 * @type {object}
 * @property {AsyncAPIDocument} asyncapi document object received from the generator.
 */

/**
 * Render all schema models
 * @param {RenderArgument} param0 
 * @returns 
 */
// 3
export default async function schemaRender({ asyncapi }) {
  // 4 
  const pythonGenerator = new PythonGenerator();
  // 5
  const models = await pythonGenerator.generate(asyncapi);
  // 6
  const files = [];
  // 7
  for (const model of models) {
    // 8
    const modelFileName = `${FormatHelpers.toPascalCase(model.modelName)}.py`;
    // 9
    files.push(<File name={modelFileName}>{model.result}</File>);
  }
  return files;
}

we just tell them to install @asyncapi/generator-components and then import { Models } from '@asyncapi/generator-components' and do something like <Models asyncapi=asyncapi language=python>

derberg avatar Oct 29 '24 12:10 derberg

@derberg (githubID 6995927,) please provide an update to the PR.

aeworxet avatar Nov 19 '24 08:11 aeworxet

I need more time on this one, there is much more code that needs to be written to see the concept in action. I don't wanna rush, and also do not want to cut the scope just to get the bounty. More important is to have something working and be able to explain what we are aiming for. I hope december is enough

derberg avatar Nov 27 '24 10:11 derberg

Upon request of the AsyncAPI Maintainer, who is responsible for the resolution of the Bounty Issue from the AsyncAPI's side and is also the Bounty Program Participant (@derberg (githubID 6995927), all remaining target dates of the Bounty Issue's Timeline are extended by four calendar weeks.

Bounty Issue's Timeline Extended

Complexity Level Assignment Date (by GitHub) Start Date (by BP Rules) End Date (by BP Rules) Draft PR Submission Final PR Merge Start Final PR Merge End
Advanced 2024-09-18 2024-10-07 2024-12-29 2024-10-27 2024-12-15 2024-12-29
Please note that the dates given represent deadlines, not specific dates, so if the goal is reached sooner, it's better.
Keep in mind the responsibility for violations of the Timeline.

aeworxet avatar Nov 28 '24 10:11 aeworxet

@derberg (githubID 6995927,) please provide an update to the PR.

aeworxet avatar Dec 03 '24 10:12 aeworxet

@derberg (githubID 6995927,) please provide an update to the PR.

aeworxet avatar Dec 11 '24 06:12 aeworxet

proof of concept done: https://github.com/asyncapi/generator/tree/master/packages

this issue is completed and more work to be done next

derberg avatar Dec 27 '24 13:12 derberg

Bounty Issue Is Completed 🎉

@derberg (githubID 6995927), please go to the AsyncAPI page on Open Collective and submit an invoice for USD 400.00 with the expense title Bounty generator#1269, tag bounty, and full URL of this Bounty Issue in the description.

aeworxet avatar Dec 29 '24 08:12 aeworxet