diverse-project / dev-dashboard

The tracker of this repository is used to track development requests so we can improve internal collaboration by organizing code sprints in the team
0 stars 0 forks source link

Converting JHipster prompts conf to Familiar #16

Open maxleiko opened 6 years ago

maxleiko commented 6 years ago

Donc ma problématique est la suivante: il faut transformer le JavaScript écrit ici https://github.com/jhipster/generator-jhipster/blob/master/generators/server/prompts.js#L45-L467 en un modèle de variabilité (feature model).

Si on prend l'exemple ici: https://github.com/jhipster/generator-jhipster/blob/master/generators/server/prompts.js#L111-L130

il faudrait être capable de dire que authentificationType (qui est une "feature") a pour sous-features "jwt", "session", "oauth2" (et celles-ci sont mutuellement exclusifs)

avec la syntaxe FAMILIAR ça donnerait quelque chose comme authentificationType : (jwt|session|auth2);

syntaxe ici: https://github.com/FAMILIAR-project/familiar-documentation/blob/master/manual/featuremodel.md

Pourquoi ce travail est important?

Guillaume a commencé quelque chose: https://github.com/gbecan/jhipster-fm

maxleiko commented 6 years ago

Work in progress here: https://github.com/maxleiko/jhipster-cli-bot

manuelleduc commented 6 years ago

Out of curiosity, which strategy did you apply? Are you able to reverse engineer the FM statically or do you have to execute some pieces of javascript?

maxleiko commented 6 years ago

I dropped the static-analysis of the source code. I took another approach which is: static-analysis of the prompt. Jhipster is using Yeoman which uses Inquirer.js (a prompt library).
I tried to formalize that prompt library output in a PEG.js grammar as it's the more common interface that we have.
Now I still have to run down all the possibilities by answering methodically to all the prompted questions in order to create the full feature model of the JHipster generator.

FAMILIAR-project commented 6 years ago

That's really awesome/original the direction you take!
This line kills me ;) https://github.com/maxleiko/jhipster-cli-bot/blob/master/grammar/prompt.pegjs#L104-L105 (PEG is very powerful)

You're already "connected" to JHipster with https://github.com/maxleiko/jhipster-cli-bot/blob/master/index.js#L9-L22 (it is perhaps obvious for you to manage stdin/stdout in JS, but not for me :D)

You're very close to a total success. Perhaps we need to think what we do at the end of a "full" configuration. I was thinking about simply retrieving the ".yo-rc.json"
Then we will have thousands (perhaps millions) of .yo-rc.json (it is exactly what we wanted ;))

@manuelleduc a static analysis of the source code is also possible, but hard if you want to be general and complete. Certainly worth doing afterwards ;-)

maxleiko commented 6 years ago

Good news, the Yeoman API is pretty cool as it allows devs to provide an adapter for the prompts.
So we can get the full power of Inquirer.js DSL without parsing the prompt (and without having any prompt at all)

Work in progress here https://github.com/maxleiko/familiar-yeoman