Closed mrts closed 4 years ago
Hi! Interesting idea that you have! What would the JSON content look like?
Thanks :)!
I think the JSON content could be simply an array of entities that have the existing JSON structure with added name
field for the name of the entity, something like this:
[
{
"name": "BankAccount",
"relationships": [
...
],
"fields": [
...
],
...
},
{
"name": "Operation",
"relationships": [
...
],
"fields": [
...
],
...
}
]
And the result should be interoperable with existing .jhipster
convention, so I would envision a command-line option that would either output a single file as above or multiple files according to .jhipster
convention.
Hi! I've read the entire thread here and in the django-extensions repo, and I believe that such CL tools shouldn't be there as JCore only is a lib (a provider).
Here are my points:
You've already written the code to perform what you need. You just need to create a project that performs such tasks, or include in another project. I'd be available to help if needed.
Overview of the feature request
Add two command-line tools
jdl2json
for converting from JDL to JSONjson2jdl
for converting from JSON to JDLThe tools would be available after
npm install jhipster-core
(althoughjhipster-jdl-tools
would be a more apt name for the package).Motivation for or Use Case
This would make it possible to use JDL and JDL Studio for modelling in other frameworks besides JHipster; see for example a proposal of using JDL with the Django web framework here: https://github.com/django-extensions/django-extensions/issues/1416. Other frameworks would use JHipster JSON files as input, as JSON is easy to parse, so a command-line tool is needed for JDL to JSON conversion.
Conversion from JSON to JDL would help to convert models from other frameworks to JSON and then to JDL. It would also simplify importing JSON from existing JHipster projects to JDL Studio.
Implementation
Implementation is straightforward, here are draft blueprints (just to get the idea through, better error checking and configurability required):
jdl2json
const jhiCore = require('jhipster-core');
const files = process.argv.slice(2); const jdlImporter = new jhiCore.JDLImporter(files); const entities = jdlImporter.import().exportedEntities; console.log(JSON.stringify(entities);