jhipster / jhipster-core

JHipster Domain Language, used by JHipster UML and JDL-Studio to generate entities
Apache License 2.0
346 stars 116 forks source link

Exported Application JDL fails to Import #411

Closed ruddell closed 4 years ago

ruddell commented 4 years ago
Overview of the issue

JDL exported by an app should be able to be imported.

This issue can be moved to jhipster-core if the issue is there.

Reproduce the error

Copy the below .yo-rc.json into a folder and export the app JDL

Try to import the exported JDL

Fails with:

INFO! Using JHipster version installed locally in current project's node_modules
INFO! Executing import-jdl mono.jdl
INFO! Options: from-cli: true, inline: 
INFO! Found .yo-rc.json on path. This is an existing app
error: Error message:
    MismatchedTokenException: Expecting --> '}' <-- but found --> 'packageFolder' <--
    at line: 13, column: 5
Error during import-jdl: Error: MismatchedTokenException: Expecting --> '}' <-- but found --> 'packageFolder' <--
    at line: 13, column: 5
SyntaxError: Error: MismatchedTokenException: Expecting --> '}' <-- but found --> 'packageFolder' <--
    at line: 13, column: 5
    at callApiMethod (/private/tmp/jh/jdl-import-demo/node_modules/jhipster-core/lib/readers/jdl_reader.js:99:11)
    at parse (/private/tmp/jh/jdl-import-demo/node_modules/jhipster-core/lib/readers/jdl_reader.js:83:10)
    at Object.parseFromFiles (/private/tmp/jh/jdl-import-demo/node_modules/jhipster-core/lib/readers/jdl_reader.js:42:10)
    at parseFiles (/private/tmp/jh/jdl-import-demo/node_modules/jhipster-core/lib/jdl/jdl_importer.js:106:20)
    at Object.createImporterFromFiles (/private/tmp/jh/jdl-import-demo/node_modules/jhipster-core/lib/jdl/jdl_importer.js:48:19)
    at JDLProcessor.importJDL (/private/tmp/jh/jdl-import-demo/node_modules/generator-jhipster/cli/import-jdl.js:296:36)
    at module.exports (/private/tmp/jh/jdl-import-demo/node_modules/generator-jhipster/cli/import-jdl.js:465:21)
    at Command.<anonymous> (/private/tmp/jh/jdl-import-demo/node_modules/generator-jhipster/cli/cli.js:71:36)
    at Command.listener (/private/tmp/jh/jdl-import-demo/node_modules/commander/index.js:315:8)
Suggest a Fix

Not sure

JHipster Version(s)

Reproduced with v6.5.1 and Master

JHipster configuration
.yo-rc.json file
{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "com.mycompany.myapp",
      "nativeLanguage": "en"
    },
    "jhipsterVersion": "6.5.1",
    "applicationType": "monolith",
    "baseName": "mono",
    "packageName": "com.mycompany.myapp",
    "packageFolder": "com/mycompany/myapp",
    "serverPort": "8080",
    "authenticationType": "jwt",
    "cacheProvider": "ehcache",
    "enableHibernateCache": true,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "prodDatabaseType": "mysql",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": false,
    "buildTool": "maven",
    "enableSwaggerCodegen": false,
    "jwtSecretKey": "bXktc2VjcmV0LXRva2VuLXRvLWNoYW5nZS1pbi1wcm9kdWN0aW9uLWFuZC10by1rZWVwLWluLWEtc2VjdXJlLXBsYWNl",
    "clientFramework": "angularX",
    "useSass": true,
    "clientPackageManager": "npm",
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "enableTranslation": true,
    "nativeLanguage": "en",
    "languages": ["en"],
    "embeddableLaunchScript": false,
    "clientTheme": "none",
    "creationTimestamp": 1576175294237,
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "otherModules": [],
    "blueprints": []
  }
}

JDL App Definition
application {
  config {
    databaseType sql
    devDatabaseType h2Disk
    enableHibernateCache true
    enableSwaggerCodegen false
    enableTranslation true
    jhiPrefix jhi
    languages [en]
    messageBroker false
    nativeLanguage en
    packageName com.mycompany.myapp
    packageFolder com/mycompany/myapp
    prodDatabaseType mysql
    searchEngine false
    serviceDiscoveryType false
    skipClient false
    skipServer false
    testFrameworks []
    websocket false
    jhipsterVersion 6.5.1
    applicationType monolith
    baseName mono
    serverPort 8080
    authenticationType jwt
    cacheProvider ehcache
    buildTool maven
    jwtSecretKey N2NhMzI3YzdmNmM5YjRmNDBkZWE4N2Y2ODFmYjU0MjVhYzBmYzM0MmM2MjU2ZDFiMTU4NWNiZmVmMTU4MTViM2IyMzZkNWQxNzc5NDk2YTRhMjYyNWVhZTcxNTVmOTRkY2QyOTIwZmYyODA3MDUzMGEyMDljMjA2ZWUyMTE1YjE=
    clientFramework angularX
    useSass true
    clientPackageManager npm
    embeddableLaunchScript false
    clientTheme none
    creationTimestamp 1576175294237
    entitySuffix 
    dtoSuffix DTO
    otherModules []
    blueprints 
    skipUserManagement false
  }
}

Browsers and Operating System

Mac, Node LTS

MathieuAA commented 4 years ago

Thanks for reporting this Jon, I'll investigate

MathieuAA commented 4 years ago

Seems like dots are causing this.

MathieuAA commented 4 years ago

I've got the fix, I'm doing some tests

MathieuAA commented 4 years ago

Okay, here's how I've tried to fix this one (I've deleted a previous comment as I wanted it to be as accurate as possible):

Now, to check if this work: one has to have a npm link pointing to the updated code base, and export/import. I'm gonna try it out now.

MathieuAA commented 4 years ago

Thanks again @ruddell for reporting this