Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generating a new app with JDL and i18n doesn't compile #135

Closed
mraible opened this issue May 5, 2020 · 11 comments
Closed

Generating a new app with JDL and i18n doesn't compile #135

mraible opened this issue May 5, 2020 · 11 comments
Labels
enhancement New feature or request

Comments

@mraible
Copy link
Contributor

mraible commented May 5, 2020

Describe the bug

I created a new app from the following JDL and it doesn't compile.

application {
  config {
    applicationType monolith,
    baseName HealthPoints
    packageName com.okta.developer,
    authenticationType oauth2,
    prodDatabaseType postgresql,
    buildTool gradle,
    searchEngine elasticsearch,
    testFrameworks [protractor],
    clientFramework react,
    useSass true,
    enableTranslation true,
    nativeLanguage en,
    languages [en, es]
  }
  entities Points, BloodPressure, Weight, Preferences
}

entity BloodPressure {
  timestamp ZonedDateTime required,
  systolic Integer required,
  diastolic Integer required
}
entity Weight {
  timestamp ZonedDateTime required,
  weight Double required
}
entity Points {
  date LocalDate required,
  exercise Integer,
  meals Integer,
  alcohol Integer,
  notes String maxlength(140)
}
entity Preferences {
  weeklyGoal Integer required min(10) max(21),
  weightUnits Units required
}

enum Units {
  KG,
  LB
}

relationship OneToOne {
  Preferences{user(login)} to User
}
relationship ManyToOne {
  BloodPressure{user(login)} to User,
  Weight{user(login)} to User,
  Points{user(login)} to User
}

paginate BloodPressure, Weight with infinite-scroll
paginate Points with pagination

To Reproduce

Create a new directory and put the above JDL into an app.jdl file. Then run:

jhipster import-jdl app.jdl

Run npm install && cd server && npm install.

Then run npm run start:app. You'll get the following error:

ERROR in /Users/mraible/react-node/src/main/webapp/app/shared/layout/menus/entities.tsx
ERROR in /Users/mraible/react-node/src/main/webapp/app/shared/layout/menus/entities.tsx(12,8):
TS2304: Cannot find name 'Translate'.

ERROR in /Users/mraible/react-node/src/main/webapp/app/shared/layout/menus/entities.tsx
ERROR in /Users/mraible/react-node/src/main/webapp/app/shared/layout/menus/entities.tsx(15,8):
TS2304: Cannot find name 'Translate'.

ERROR in /Users/mraible/react-node/src/main/webapp/app/shared/layout/menus/entities.tsx
ERROR in /Users/mraible/react-node/src/main/webapp/app/shared/layout/menus/entities.tsx(18,8):
TS2304: Cannot find name 'Translate'.

ERROR in /Users/mraible/react-node/src/main/webapp/app/shared/layout/menus/entities.tsx
ERROR in /Users/mraible/react-node/src/main/webapp/app/shared/layout/menus/entities.tsx(21,8):
TS2304: Cannot find name 'Translate'.

ERROR in /Users/mraible/react-node/src/main/webapp/app/shared/layout/menus/entities.tsx
ERROR in /Users/mraible/react-node/src/main/webapp/app/shared/layout/menus/entities.tsx(12,8):
react/jsx-no-undef: 'Translate' is not defined.

ERROR in /Users/mraible/react-node/src/main/webapp/app/shared/layout/menus/entities.tsx
ERROR in /Users/mraible/react-node/src/main/webapp/app/shared/layout/menus/entities.tsx(15,8):
react/jsx-no-undef: 'Translate' is not defined.

ERROR in /Users/mraible/react-node/src/main/webapp/app/shared/layout/menus/entities.tsx
ERROR in /Users/mraible/react-node/src/main/webapp/app/shared/layout/menus/entities.tsx(18,8):
react/jsx-no-undef: 'Translate' is not defined.

ERROR in /Users/mraible/react-node/src/main/webapp/app/shared/layout/menus/entities.tsx
ERROR in /Users/mraible/react-node/src/main/webapp/app/shared/layout/menus/entities.tsx(21,8):
react/jsx-no-undef: 'Translate' is not defined.

Expected behavior

I expect npm run start:app to work, my entities to be be properly generated, and npm run e2e to pass. 🙂

JHipster Version(s)
[email protected] /Users/mraible/react-node
├── [email protected] 
└─┬ [email protected]
  └── [email protected]  deduped

JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "jhipsterVersion": "6.8.0",
    "applicationType": "monolith",
    "baseName": "HealthPoints",
    "packageName": "com.jhipster.node",
    "packageFolder": "com/jhipster/node",
    "serverPort": "8080",
    "authenticationType": "oauth2",
    "cacheProvider": "no",
    "enableHibernateCache": false,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "sqlite",
    "prodDatabaseType": "postgresql",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": false,
    "buildTool": "maven",
    "enableSwaggerCodegen": false,
    "embeddableLaunchScript": false,
    "useSass": true,
    "clientPackageManager": "npm",
    "clientFramework": "react",
    "clientTheme": "none",
    "clientThemeVariant": "",
    "creationTimestamp": 1588647540679,
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "otherModules": [
      {
        "name": "generator-jhipster-nodejs",
        "version": "1.0.2"
      }
    ],
    "enableTranslation": false,
    "blueprints": [
      {
        "name": "generator-jhipster-nodejs",
        "version": "1.0.2"
      }
    ],
    "skipUserManagement": true,
    "languages": ["en", "es"],
    "nativeLanguage": "en",
    "skipClient": false,
    "skipServer": false
  },
  "entities": ["Points", "BloodPressure", "Weight", "Preferences"]
}
JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions
entity BloodPressure {
  timestamp ZonedDateTime required,
  systolic Integer required,
  diastolic Integer required
}
entity Weight {
  timestamp ZonedDateTime required,
  weight Double required
}
entity Points {
  date LocalDate required,
  exercise Integer,
  meals Integer,
  alcohol Integer,
  notes String maxlength(140)
}
entity Preferences {
  weeklyGoal Integer required min(10) max(21),
  weightUnits Units required
}
enum Units {
  KG,
  LB
}

relationship OneToOne {
  Preferences{user(login)} to User
}
relationship ManyToOne {
  BloodPressure{user(login)} to User,
  Weight{user(login)} to User,
  Points{user(login)} to User
}

paginate BloodPressure, Weight with infinite-scroll
paginate Points with pagination

Environment and Tools

openjdk version "11.0.5" 2019-10-15
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.5+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.5+10, mixed mode)

git version 2.24.2 (Apple Git-127)

node: v12.16.3

npm: 6.14.4

yeoman: 3.1.1

yarn: 1.22.4

Docker version 19.03.8, build afacb8b

docker-compose version 1.25.4, build 8d51620a

INFO! Congratulations, JHipster execution is complete!

@ghost
Copy link

ghost commented May 5, 2020

Hi Matt,
thanks for the feedback!
Now the i18n for client is not implemented yet (See #121).

Could you set the EnableTranslation to false as my integration test that compile? :

After it, retry the compile task.

@ghost ghost added the enhancement New feature or request label May 5, 2020
@mraible
Copy link
Contributor Author

mraible commented May 6, 2020

@amanganiello90 I'm curious - why do you have to manually run npm install in the root directory? The main JHipster generator runs npm install as part of its generation process.

@mraible
Copy link
Contributor Author

mraible commented May 6, 2020

If I use above JDL with enableTranslation false, I get a different error:

/Users/mraible/nhipster/server/node_modules/ts-node/src/index.ts:240
    return new TSError(diagnosticText, diagnosticCodes)
           ^
TSError: ⨯ Unable to compile TypeScript:
src/orm.config.ts:28:5 - error TS2322: Type '"postgresql"' is not assignable to type '"mysql" | "mariadb" | "postgres" | "cockroachdb" | "sqlite" | "mssql" | "oracle" | "cordova" | "nativescript" | "react-native" | "sqljs" | "mongodb" | "expo"'.

28     type: 'postgresql',
       ~~~~

  node_modules/typeorm/driver/mysql/MysqlConnectionOptions.d.ts:12:14
    12     readonly type: "mysql" | "mariadb";
                    ~~~~
    The expected type comes from property 'type' which is declared here on type 'TypeOrmModuleOptions'

    at createTSError (/Users/mraible/nhipster/server/node_modules/ts-node/src/index.ts:240:12)
    at reportTSError (/Users/mraible/nhipster/server/node_modules/ts-node/src/index.ts:244:19)
    at getOutput (/Users/mraible/nhipster/server/node_modules/ts-node/src/index.ts:360:34)
    at Object.compile (/Users/mraible/nhipster/server/node_modules/ts-node/src/index.ts:393:11)
    at Module.m._compile (/Users/mraible/nhipster/server/node_modules/ts-node/src/index.ts:439:43)
    at Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
    at Object.require.extensions.<computed> [as .ts] (/Users/mraible/nhipster/server/node_modules/ts-node/src/index.ts:442:12)
    at Module.load (internal/modules/cjs/loader.js:977:32)
    at Function.Module._load (internal/modules/cjs/loader.js:877:14)
    at Module.require (internal/modules/cjs/loader.js:1019:19)
[nodemon] app crashed - waiting for file changes before starting...

@mraible
Copy link
Contributor Author

mraible commented May 6, 2020

If I change it to postgres like this blueprint seems to expect, I get an error too.

Error: Can't add invalid application. Error: Unknown value 'postgres' for option 'prodDatabaseType'.
Error while parsing applications and entities from the JDL Error: Can't add invalid application. Error: Unknown value 'postgres' for option 'prodDatabaseType'.

Therefore, I think it should be changed to postgresql. This is what the main JHipster generator expects.

@mraible
Copy link
Contributor Author

mraible commented May 6, 2020

If I change the database to mysql and disable i18n, I get a compilation error:

ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/blood-pressure/blood-pressure-delete-dialog.tsx
ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/blood-pressure/blood-pressure-delete-dialog.tsx(60,28):
TS2339: Property 'bloodPressure' does not exist on type 'IRootState'.

ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/blood-pressure/blood-pressure-detail.tsx
ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/blood-pressure/blood-pressure-detail.tsx(71,28):
TS2339: Property 'bloodPressure' does not exist on type 'IRootState'.

ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/blood-pressure/blood-pressure-update.tsx
ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/blood-pressure/blood-pressure-update.tsx(168,35):
TS2339: Property 'bloodPressure' does not exist on type 'IRootState'.

ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/blood-pressure/blood-pressure-update.tsx
ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/blood-pressure/blood-pressure-update.tsx(169,23):
TS2339: Property 'bloodPressure' does not exist on type 'IRootState'.

ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/blood-pressure/blood-pressure-update.tsx
ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/blood-pressure/blood-pressure-update.tsx(170,24):
TS2339: Property 'bloodPressure' does not exist on type 'IRootState'.

ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/blood-pressure/blood-pressure-update.tsx
ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/blood-pressure/blood-pressure-update.tsx(171,29):
TS2339: Property 'bloodPressure' does not exist on type 'IRootState'.

ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/blood-pressure/blood-pressure.tsx
ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/blood-pressure/blood-pressure.tsx(225,28):
TS2339: Property 'bloodPressure' does not exist on type 'IRootState'.

ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/points/points-delete-dialog.tsx
ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/points/points-delete-dialog.tsx(60,28):
TS2339: Property 'points' does not exist on type 'IRootState'.

ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/points/points-detail.tsx
ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/points/points-detail.tsx(83,28):
TS2339: Property 'points' does not exist on type 'IRootState'.

ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/points/points-update.tsx
ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/points/points-update.tsx(167,28):
TS2339: Property 'points' does not exist on type 'IRootState'.

ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/points/points-update.tsx
ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/points/points-update.tsx(168,23):
TS2339: Property 'points' does not exist on type 'IRootState'.

ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/points/points-update.tsx
ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/points/points-update.tsx(169,24):
TS2339: Property 'points' does not exist on type 'IRootState'.

ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/points/points-update.tsx
ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/points/points-update.tsx(170,29):
TS2339: Property 'points' does not exist on type 'IRootState'.

ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/points/points.tsx
ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/points/points.tsx(236,28):
TS2339: Property 'points' does not exist on type 'IRootState'.

ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/preferences/preferences-delete-dialog.tsx
ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/preferences/preferences-delete-dialog.tsx(60,28):
TS2339: Property 'preferences' does not exist on type 'IRootState'.

ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/preferences/preferences-detail.tsx
ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/preferences/preferences-detail.tsx(63,28):
TS2339: Property 'preferences' does not exist on type 'IRootState'.

ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/preferences/preferences-update.tsx
ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/preferences/preferences-update.tsx(154,33):
TS2339: Property 'preferences' does not exist on type 'IRootState'.

ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/preferences/preferences-update.tsx
ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/preferences/preferences-update.tsx(155,23):
TS2339: Property 'preferences' does not exist on type 'IRootState'.

ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/preferences/preferences-update.tsx
ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/preferences/preferences-update.tsx(156,24):
TS2339: Property 'preferences' does not exist on type 'IRootState'.

ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/preferences/preferences-update.tsx
ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/preferences/preferences-update.tsx(157,29):
TS2339: Property 'preferences' does not exist on type 'IRootState'.

ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/preferences/preferences.tsx
ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/preferences/preferences.tsx(141,28):
TS2339: Property 'preferences' does not exist on type 'IRootState'.

ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/weight/weight-delete-dialog.tsx
ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/weight/weight-delete-dialog.tsx(60,28):
TS2339: Property 'weight' does not exist on type 'IRootState'.

ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/weight/weight-detail.tsx
ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/weight/weight-detail.tsx(65,28):
TS2339: Property 'weight' does not exist on type 'IRootState'.

ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/weight/weight-update.tsx
ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/weight/weight-update.tsx(153,28):
TS2339: Property 'weight' does not exist on type 'IRootState'.

ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/weight/weight-update.tsx
ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/weight/weight-update.tsx(154,23):
TS2339: Property 'weight' does not exist on type 'IRootState'.

ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/weight/weight-update.tsx
ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/weight/weight-update.tsx(155,24):
TS2339: Property 'weight' does not exist on type 'IRootState'.

ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/weight/weight-update.tsx
ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/weight/weight-update.tsx(156,29):
TS2339: Property 'weight' does not exist on type 'IRootState'.

ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/weight/weight.tsx
ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/weight/weight.tsx(221,28):
TS2339: Property 'weight' does not exist on type 'IRootState'.

Here's my JDL:

application {
  config {
    applicationType monolith,
    baseName HealthPoints
    packageName com.okta.developer,
    authenticationType oauth2,
    prodDatabaseType mysql,
    buildTool gradle,
    searchEngine elasticsearch,
    testFrameworks [protractor],
    clientFramework react,
    useSass true,
    enableTranslation false,
    nativeLanguage en,
    languages [en, es]
  }
  entities Points, BloodPressure, Weight, Preferences
}

entity BloodPressure {
  timestamp ZonedDateTime required,
  systolic Integer required,
  diastolic Integer required
}
entity Weight {
  timestamp ZonedDateTime required,
  weight Double required
}
entity Points {
  date LocalDate required,
  exercise Integer,
  meals Integer,
  alcohol Integer,
  notes String maxlength(140)
}
entity Preferences {
  weeklyGoal Integer required min(10) max(21),
  weightUnits Units required
}

enum Units {
  KG,
  LB
}

relationship OneToOne {
  Preferences{user(login)} to User
}
relationship ManyToOne {
  BloodPressure{user(login)} to User,
  Weight{user(login)} to User,
  Points{user(login)} to User
}

paginate BloodPressure, Weight with infinite-scroll
paginate Points with pagination

@ghost
Copy link

ghost commented May 6, 2020

@amanganiello90 I'm curious - why do you have to manually run npm install in the root directory? The main JHipster generator runs npm install as part of its generation process.

There is another node_modules for the backend part under server folder.

If I change it to postgres like this blueprint seems to expect, I get an error too.

For the jdl validation you have to use postgresql..postgres is the object expected from typeORM. I will test it to pass from jdl.

If I change the database to mysql and disable i18n, I get a compilation error:

ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/blood-pressure/blood-pressure-delete-dialog.tsx
ERROR in /Users/mraible/nhip/src/main/webapp/app/entities/blood-pressure/blood-pressure-delete-dialog.tsx(60,28):
TS2339: Property 'bloodPressure' does not exist on type 'IRootState'.

This is an error of the client side that the blueprint does not change, related to typescript.
(all the client templates are inherited by jhipster, except to the home page file).

I have integration test with react client and entities, and it is ok: https://github.com/jhipster/generator-jhipster-nodejs/runs/621661955

Could you please use my jdl in order to understand the differences? Thanks

@mraible
Copy link
Contributor Author

mraible commented May 7, 2020

@amanganiello90 I tried removing Elasticsearch since that seems to be one difference between our JDLs. When I do that, I get a new error when the server starts.

DataTypeNotSupportedError: Data type "enum" in "Preferences.weightUnits" is not supported by "sqlite" database.

@ghost
Copy link

ghost commented May 7, 2020

Oh yes, in dev profile (sqlite db) the enums are not supported: https://github.com/jhipster/generator-jhipster-nodejs/blob/master/README.md#-what-we-have-now.

Run the app with prod profile in order to use your prod database:

 set NODE_ENV=prod&& npm run start:app

I have an issue to find a way not using that in dev profile #74

@mraible
Copy link
Contributor Author

mraible commented May 7, 2020

I'm on a Mac, so I had to use export instead of set. When I do this, it's unable to connect to MySQL. Should there be a mysql.yml created in src/main/docker? I don't see one in my project.

$ ll src/main/docker
total 24
-rw-r--r--  1 mraible  staff   329B May  7 10:20 app.yml
-rw-r--r--  1 mraible  staff   663B May  7 10:20 keycloak.yml
drwxr-xr-x  4 mraible  staff   128B May  7 10:20 realm-config
-rw-r--r--  1 mraible  staff   153B May  7 10:20 sonar.yml

@ghost
Copy link

ghost commented May 7, 2020

Now docker support is only for sonar and keycloak (there are not database containerization yet).
You have to use an external database configuring the host: https://github.com/jhipster/jhipster-sample-app-nodejs/blob/fdfd27c27c86476322fd3cf29fb93d4cf54c187c/server/src/orm.config.ts#L30

It is all explained in the README generated: https://github.com/jhipster/jhipster-sample-app-nodejs/tree/master/server#typeorm-configuration

Instead, If you want to use sqlite db (that is on file like H2 for java), before you have to delete enums from generation.

From what I understand, in summary, the errors to be tested and improved are two:

I will create two new issue. Thanks.

@ghost
Copy link

ghost commented May 12, 2020

I close it because there are two related issues for this. Thanks

@ghost ghost closed this as completed May 12, 2020
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant