jhipster / generator-jhipster

JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
https://www.jhipster.tech
Apache License 2.0
21.58k stars 4.02k forks source link

JHipster generator can't regenerate a jdl change (using issue for one or more Application JDLs) #27944

Closed jperezdelafuente closed 12 hours ago

jperezdelafuente commented 2 days ago
Overview of the issue

I can't regenerate the application with changes in jdl I indicate the 3 steps to reproduce:

  1. I create an application with "jhipster jdl foo.jh" (foo.jh like a JDL definitions section)
  2. I add an attribute called foo2 to the entity foo (in the file a second JDL definitions section with second foo2 attribute)
    /* Foo 2 */
    foo2 String required maxlength(30)
    
  3. I try to regenerate the application with "jhipster jdl foo.jh"
JHipster JDL
JDL definitions
 application {
  config {
    applicationType monolith,
    baseName foo,
    packageName com.foo,
    jhiPrefix gsr,
    authenticationType session,
    databaseType sql,
    devDatabaseType h2Disk,
    prodDatabaseType postgresql,
    enableHibernateCache true,
    cacheProvider ehcache,
    buildTool maven,
    testFrameworks [cypress, gatling, cucumber],
    clientFramework angular,
    enableTranslation true,
    nativeLanguage es,
    languages [es, en]
    incrementalChangelog true
  }
  entities *
}

/** Entity Foo */

entity Foo(foo) {

/* Foo */
foo String required maxlength(20)

}

dto * with mapstruct

service all with serviceImpl

paginate all with pagination
  
JDL definitions (incremental with second foo2 attribute)
 application {
  config {
    applicationType monolith,
    baseName foo,
    packageName com.foo,
    jhiPrefix gsr,
    authenticationType session,
    databaseType sql,
    devDatabaseType h2Disk,
    prodDatabaseType postgresql,
    enableHibernateCache true,
    cacheProvider ehcache,
    buildTool maven,
    testFrameworks [cypress, gatling, cucumber],
    clientFramework angular,
    enableTranslation true,
    nativeLanguage es,
    languages [es, en]
    incrementalChangelog true
  }
  entities *
}

/** Entity Foo */

entity Foo(foo) {

/* Foo */
foo String required maxlength(20)

/* Foo2 */
foo2 String maxlength(20)

}

dto * with mapstruct

service all with serviceImpl

paginate all with pagination

  
Motivation for or Use Case

Perform regenerations in the application with changes in the jdl

Reproduce the error

With Node v22.11.0 It finishes without errors and without trying to regenerate the rest of the files

(node:29595) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
     info KeyStore '/home/foo22/src/main/resources/config/tls/keystore.p12' already exists. Leaving unchanged.
[@faker-js/faker]: faker.internet.userName() is deprecated since v9.1.0 and will be removed in v10.0.0. Please use faker.internet.username() instead.
✔ applying multi-step templates
     info Using existing git repository.
identical .prettierrc
identical .prettierignore
✔ prettier configuration files committed to disk
✔ loading translations
✔ updating package.json dependencies versions
✔ prettifying sonar-project.properties
✔ adding package-info.java files
✔ sorting pom.xml file
✔ translating angular application
identical sonar-project.properties
identical .husky/pre-commit
identical src/main/resources/banner.txt
identical .devcontainer/Dockerfile
identical pom.xml
identical src/main/resources/logback-spring.xml
identical src/main/resources/i18n/messages.properties
identical src/test/resources/logback.xml
identical src/test/resources/junit-platform.properties
identical mvnw
identical mvnw.cmd
identical .mvn/wrapper/maven-wrapper.jar
identical .mvn/wrapper/maven-wrapper.properties
identical .mvn/jvm.config
identical src/main/docker/jib/entrypoint.sh
identical checkstyle.xml

With Node v20.18.0 finishes with errors and without trying to regenerate the rest of the files:

     info KeyStore '/home/foo20/src/main/resources/config/tls/keystore.p12' already exists. Leaving unchanged.
[@faker-js/faker]: faker.internet.userName() is deprecated since v9.1.0 and will be removed in v10.0.0. Please use faker.internet.username() instead.
✔ applying multi-step templates
     info Using existing git repository.
identical .prettierrc
identical .prettierignore
✔ prettier configuration files committed to disk
✔ loading translations
✔ updating package.json dependencies versions
✔ prettifying sonar-project.properties
✔ adding package-info.java files
✔ sorting pom.xml file
✔ translating angular application
identical sonar-project.properties
identical .husky/pre-commit
identical src/main/resources/banner.txt
identical .devcontainer/Dockerfile
identical pom.xml
identical src/main/resources/logback-spring.xml
identical src/main/resources/i18n/messages.properties
identical src/test/resources/logback.xml
identical src/test/resources/junit-platform.properties
identical mvnw
identical mvnw.cmd
identical .mvn/wrapper/maven-wrapper.properties
identical .mvn/wrapper/maven-wrapper.jar
identical .mvn/jvm.config
identical src/main/docker/jib/entrypoint.sh
identical checkstyle.xml
**ERROR! ERROR! Cannot read properties of undefined (reading 'added')
TypeError: Cannot read properties of undefined (reading 'added')
    at Conflicter._detectConflict (file:///home/.nvm/versions/node/v20.18.0/lib/node_modules/generator-jhipster/node_modules/@yeoman/conflicter/dist/conflicter.js:182:58)
    at async Conflicter._checkForCollision (file:///home/.nvm/versions/node/v20.18.0/lib/node_modules/generator-jhipster/node_modules/@yeoman/conflicter/dist/conflicter.js:260:13)
    at async Conflicter.checkForCollision (file:///home/.nvm/versions/node/v20.18.0/lib/node_modules/generator-jhipster/node_modules/@yeoman/conflicter/dist/conflicter.js:205:20)
    at async Object. (file:///home/.nvm/versions/node/v20.18.0/lib/node_modules/generator-jhipster/node_modules/@yeoman/conflicter/dist/conflicter.js:391:36)
    at async file:///home/.nvm/versions/node/v20.18.0/lib/node_modules/generator-jhipster/node_modules/p-transform/dist/queue.js:68:28
    at async file:///home/.nvm/versions/node/v20.18.0/lib/node_modules/generator-jhipster/node_modules/p-queue/dist/index.js:187:36**

With Node v18.20.4 finishes with errors and without trying to regenerate the rest of the files:

          info KeyStore '/home/foo18/src/main/resources/config/tls/keystore.p12' already exists. Leaving unchanged.
[@faker-js/faker]: faker.internet.userName() is deprecated since v9.1.0 and will be removed in v10.0.0. Please use faker.internet.username() instead.
✔ applying multi-step templates
     info Using existing git repository.
identical .prettierrc
identical .prettierignore
✔ prettier configuration files committed to disk
✔ loading translations
✔ updating package.json dependencies versions
✔ prettifying sonar-project.properties
✔ adding package-info.java files
✔ sorting pom.xml file
✔ translating angular application
identical sonar-project.properties
identical .husky/pre-commit
identical src/main/resources/banner.txt
identical .devcontainer/Dockerfile
identical pom.xml
identical src/main/resources/logback-spring.xml
identical src/main/resources/i18n/messages.properties
identical src/test/resources/logback.xml
identical src/test/resources/junit-platform.properties
identical mvnw
identical mvnw.cmd
identical .mvn/wrapper/maven-wrapper.jar
identical .mvn/wrapper/maven-wrapper.properties
identical .mvn/jvm.config
identical src/main/docker/jib/entrypoint.sh
identical checkstyle.xml
ERROR! ERROR! Cannot read properties of undefined (reading 'added')
TypeError: Cannot read properties of undefined (reading 'added')
    at Conflicter._detectConflict (file:///home/.nvm/versions/node/v18.20.4/lib/node_modules/generator-jhipster/node_modules/@yeoman/conflicter/dist/conflicter.js:182:58)
    at async Conflicter._checkForCollision (file:///home/.nvm/versions/node/v18.20.4/lib/node_modules/generator-jhipster/node_modules/@yeoman/conflicter/dist/conflicter.js:260:13)
    at async Conflicter.checkForCollision (file:///home/.nvm/versions/node/v18.20.4/lib/node_modules/generator-jhipster/node_modules/@yeoman/conflicter/dist/conflicter.js:205:20)
    at async Object. (file:///home/.nvm/versions/node/v18.20.4/lib/node_modules/generator-jhipster/node_modules/@yeoman/conflicter/dist/conflicter.js:391:36)
    at async file:///home/.nvm/versions/node/v18.20.4/lib/node_modules/generator-jhipster/node_modules/p-transform/dist/queue.js:68:28
    at async file:///home/.nvm/versions/node/v18.20.4/lib/node_modules/generator-jhipster/node_modules/p-queue/dist/index.js:187:36
Related issues

JHipster generator can't regenerate a jdl change #27866

Suggest a Fix
JHipster Version(s)

8.7.3

Browsers and Operating System

Ubuntu 22.04.2

Environment and Tools

openjdk version "17.0.7" 2023-04-18 OpenJDK Runtime Environment Temurin-17.0.7+7 (build 17.0.7+7) OpenJDK 64-Bit Server VM Temurin-17.0.7+7 (build 17.0.7+7, mixed mode, sharing)

git version 2.34.1

node: v22.11.0 npm: 10.9.0

Docker version 24.0.2, build cb74dfc

mraible commented 2 days ago

Can you try with the following command:

jhipster entity Foo --single-entity
jperezdelafuente commented 2 days ago

When I launch "jhipster entity Foo --single-entity" in an empty directory, I get the following output with Node v18.20.3 (and similar with Node v20.18.0 or Node v22.11.0):

 ~/testfoo/  jhipster entity Foo --single-entity

        ██╗ ██╗   ██╗ ████████╗ ███████╗   ██████╗ ████████╗ ████████╗ ███████╗
        ██║ ██║   ██║ ╚══██╔══╝ ██╔═══██╗ ██╔════╝ ╚══██╔══╝ ██╔═════╝ ██╔═══██╗
        ██║ ████████║    ██║    ███████╔╝ ╚█████╗     ██║    ██████╗   ███████╔╝
  ██╗   ██║ ██╔═══██║    ██║    ██╔════╝   ╚═══██╗    ██║    ██╔═══╝   ██╔══██║
  ╚██████╔╝ ██║   ██║ ████████╗ ██║       ██████╔╝    ██║    ████████╗ ██║  ╚██╗
   ╚═════╝  ╚═╝   ╚═╝ ╚═══════╝ ╚═╝       ╚═════╝     ╚═╝    ╚═══════╝ ╚═╝   ╚═╝
                            https://www.jhipster.tech
Welcome to JHipster v8.7.3

 _______________________________________________________________________________________________________________

  Documentation for creating an application is at https://www.jhipster.tech/creating-an-app/

  Application files will be generated in folder: /home/geiser/testfoo
 _______________________________________________________________________________________________________________

✔ What is the base name of your application? testfoo
INFO!
The entity Foo is being created.

Generating field #1

✔ Do you want to add a field to your entity? yes
✔ What is the name of your field? fooAttribute
✔ What is the type of your field? String
✔ Do you want to add validation rules to your field? no

================= Foo =================
Fields
fooAttribute (String)

Generating field #2

✔ Do you want to add a field to your entity? no

================= Foo =================
Fields
fooAttribute (String)

Generating relationships to other entities

✔ Do you want to add a relationship to another entity? no

================= Foo =================
Fields
fooAttribute (String)

✔ Do you want to use separate service class for your business logic? Yes, generate a separate service
interface and implementation
✔ Do you want to use a Data Transfer Object (DTO)? Yes, generate a DTO with MapStruct
✔ Do you want to add filtering? Dynamic filtering for the entities with JPA Static metamodel
✔ Is this entity read-only? no
✔ Do you want pagination and sorting on your entity? Yes, with pagination links and sorting headers

Everything is configured, generating the entity...

INFO! Generating entities Foo
✔ Which *type* of application would you like to create? Monolithic application (recommended for simple
projects)
✔ What is your default Java package name? com.mycompany.myapp
✔ Would you like to use Maven or Gradle for building the backend? Maven
✔ Do you want to make it reactive with Spring WebFlux? no
✔ Which *type* of authentication would you like to use? HTTP Session Authentication (stateful, default
Spring Security mechanism)
✔ Besides JUnit, which testing frameworks would you like to use?
✔ Which *type* of database would you like to use? SQL (H2, PostgreSQL, MySQL, MariaDB, Oracle, MSSQL)
✔ Which *production* database would you like to use? Oracle
✔ Which *development* database would you like to use? H2 with disk-based persistence
✔ Which cache do you want to use? (Spring cache abstraction) Ehcache (local cache, for a single node)
✔ Do you want to use Hibernate 2nd level cache? yes
✔ Which other technologies would you like to use?
✔ Which *framework* would you like to use for the client? Angular
✔ Besides Jest/Vitest, which testing frameworks would you like to use?
✔ Do you want to generate the admin UI? yes
✔ Would you like to use a Bootswatch theme (https://bootswatch.com/)? Default JHipster
✔ Would you like to enable internationalization support? yes
✔ Please choose the native language of the application Spanish
✔ Please choose additional languages to install English
✔ applying multi-step templates
✔ prettier configuration files committed to disk
ERROR! An error occured while running jhipster:spring-cache#customizeFiles
ERROR! ERROR! Unable to find /home/testfoo/src/main/java/com/mycompany/myapp/config/CacheConfiguration.java.
Error: Unable to find /home/testfoo/src/main/java/com/mycompany/myapp/config/CacheConfiguration.java.
    at SpringCacheGenerator.editFile (file:///home/.nvm/versions/node/v18.20.3/lib/node_modules/generator-jhipster/dist/generators/base-core/generator.js:1047:23)
    at source.addEntityToCache (file:///home/.nvm/versions/node/v18.20.3/lib/node_modules/generator-jhipster/dist/generators/spring-cache/generator.js:74:30)
    at SpringCacheGenerator.customizeFiles (file:///home/.nvm/versions/node/v18.20.3/lib/node_modules/generator-jhipster/dist/generators/spring-cache/generator.js:168:50)
    at SpringCacheGenerator.executeTask (file:///home/.nvm/versions/node/v18.20.3/lib/node_modules/generator-jhipster/node_modules/yeoman-generator/dist/actions/lifecycle.js:258:26)
    at env.queueTask.once (file:///home/.nvm/versions/node/v18.20.3/lib/node_modules/generator-jhipster/node_modules/yeoman-generator/dist/actions/lifecycle.js:232:56)
    at runLoop.add.once (file:///home/.nvm/versions/node/v18.20.3/lib/node_modules/generator-jhipster/node_modules/yeoman-environment/dist/environment-base.js:395:23)
    at Immediate. (/home/.nvm/versions/node/v18.20.3/lib/node_modules/generator-jhipster/node_modules/grouped-queue/lib/subqueue.js:48:34)
    at process.processImmediate (node:internal/timers:476:21)
    at process.callbackTrampoline (node:internal/async_hooks:128:17)
jperezdelafuente commented 2 days ago

When I launch "jhipster entity Foo --single-entity" in an empty directory and select "No cache", I get the following output with Node v18.20.3 (and similar with Node v20.18.0 or Node v22.11.0):

 ~/testfoo/ jhipster entity Foo --single-entity

        ██╗ ██╗   ██╗ ████████╗ ███████╗   ██████╗ ████████╗ ████████╗ ███████╗
        ██║ ██║   ██║ ╚══██╔══╝ ██╔═══██╗ ██╔════╝ ╚══██╔══╝ ██╔═════╝ ██╔═══██╗
        ██║ ████████║    ██║    ███████╔╝ ╚█████╗     ██║    ██████╗   ███████╔╝
  ██╗   ██║ ██╔═══██║    ██║    ██╔════╝   ╚═══██╗    ██║    ██╔═══╝   ██╔══██║
  ╚██████╔╝ ██║   ██║ ████████╗ ██║       ██████╔╝    ██║    ████████╗ ██║  ╚██╗
   ╚═════╝  ╚═╝   ╚═╝ ╚═══════╝ ╚═╝       ╚═════╝     ╚═╝    ╚═══════╝ ╚═╝   ╚═╝
                            https://www.jhipster.tech
Welcome to JHipster v8.7.3

 _______________________________________________________________________________________________________________

  Documentation for creating an application is at https://www.jhipster.tech/creating-an-app/

  Application files will be generated in folder: /home/geiser/testfoo
 _______________________________________________________________________________________________________________

✔ What is the base name of your application? testfoo
INFO!
The entity Foo is being created.

Generating field #1

✔ Do you want to add a field to your entity? yes
✔ What is the name of your field? fooAttribute
✔ What is the type of your field? String
✔ Do you want to add validation rules to your field? no

================= Foo =================
Fields
fooAttribute (String)

Generating field #2

✔ Do you want to add a field to your entity? no

================= Foo =================
Fields
fooAttribute (String)

Generating relationships to other entities

✔ Do you want to add a relationship to another entity? no

================= Foo =================
Fields
fooAttribute (String)

✔ Do you want to use separate service class for your business logic? Yes, generate a separate service interface and implementation
✔ Do you want to use a Data Transfer Object (DTO)? Yes, generate a DTO with MapStruct
✔ Do you want to add filtering? Dynamic filtering for the entities with JPA Static metamodel
✔ Is this entity read-only? no
✔ Do you want pagination and sorting on your entity? Yes, with pagination links and sorting headers

Everything is configured, generating the entity...

INFO! Generating entities Foo
✔ Which *type* of application would you like to create? Monolithic application (recommended for simple projects)
✔ What is your default Java package name? com.mycompany.myapp
✔ Would you like to use Maven or Gradle for building the backend? Maven
✔ Do you want to make it reactive with Spring WebFlux? no
✔ Which *type* of authentication would you like to use? HTTP Session Authentication (stateful, default Spring Security mechanism)
✔ Besides JUnit, which testing frameworks would you like to use?
✔ Which *type* of database would you like to use? SQL (H2, PostgreSQL, MySQL, MariaDB, Oracle, MSSQL)
✔ Which *production* database would you like to use? Oracle
✔ Which *development* database would you like to use? H2 with disk-based persistence
✔ Which cache do you want to use? (Spring cache abstraction) No cache - Warning, when using an SQL database, this will disable the Hibernate 2nd level cache!
✔ Which other technologies would you like to use?
✔ Which *framework* would you like to use for the client? Angular
✔ Besides Jest/Vitest, which testing frameworks would you like to use?
✔ Do you want to generate the admin UI? yes
✔ Would you like to use a Bootswatch theme (https://bootswatch.com/)? Default JHipster
✔ Would you like to enable internationalization support? yes
✔ Please choose the native language of the application Spanish
✔ Please choose additional languages to install English
✔ applying multi-step templates
✔ prettier configuration files committed to disk
ERROR! An error occured while running jhipster:liquibase#postWriteChangelogs
ERROR! ERROR! Unable to find /home/testfoo/src/main/resources/config/liquibase/master.xml.
Error: Unable to find /home/testfoo/src/main/resources/config/liquibase/master.xml.
    at LiquibaseGenerator.editFile (file:///home/.nvm/versions/node/v18.20.3/lib/node_modules/generator-jhipster/dist/generators/base-core/generator.js:1047:23)
    at source.addLiquibaseChangelog (file:///home/.nvm/versions/node/v18.20.3/lib/node_modules/generator-jhipster/dist/generators/liquibase/generator.js:74:66)
    at LiquibaseGenerator._addLiquibaseFilesReferences (file:///home/.nvm/versions/node/v18.20.3/lib/node_modules/generator-jhipster/dist/generators/liquibase/generator.js:499:16)
    at LiquibaseGenerator.postWriteChangelog (file:///home/.nvm/versions/node/v18.20.3/lib/node_modules/generator-jhipster/dist/generators/liquibase/generator.js:710:25)
    at file:///home/.nvm/versions/node/v18.20.3/lib/node_modules/generator-jhipster/dist/generators/liquibase/generator.js:462:90
    at Array.map ()
    at LiquibaseGenerator.postWriteChangelogs (file:///home/.nvm/versions/node/v18.20.3/lib/node_modules/generator-jhipster/dist/generators/liquibase/generator.js:462:60)
    at LiquibaseGenerator.executeTask (file:///home/.nvm/versions/node/v18.20.3/lib/node_modules/generator-jhipster/node_modules/yeoman-generator/dist/actions/lifecycle.js:258:26)
    at env.queueTask.once (file:///home/.nvm/versions/node/v18.20.3/lib/node_modules/generator-jhipster/node_modules/yeoman-generator/dist/actions/lifecycle.js:232:56)
    at runLoop.add.once (file:///home/.nvm/versions/node/v18.20.3/lib/node_modules/generator-jhipster/node_modules/yeoman-environment/dist/environment-base.js:395:23)
github-actions[bot] commented 2 days ago

Issue check: JHipster has completed the sample check

27944 Value
JDL :heavy_check_mark:
Entities JDL -
--- ---
Application Generation :heavy_check_mark:
Check Status
Frontend check :heavy_check_mark:
Backend check :heavy_check_mark:
E2E check :heavy_check_mark:

This check uses jhipster info or jdl output from the issue description to generate the sample. Bug report that does not contain this information will be marked as invalid.

app.jdl ````jdl application { config { applicationType monolith, baseName foo, packageName com.foo, jhiPrefix gsr, authenticationType session, databaseType sql, devDatabaseType h2Disk, prodDatabaseType postgresql, enableHibernateCache true, cacheProvider ehcache, buildTool maven, testFrameworks [cypress, gatling, cucumber], clientFramework angular, enableTranslation true, nativeLanguage es, languages [es, en] incrementalChangelog true } entities * } /** Entity Foo */ entity Foo(foo) { /* Foo */ foo String required maxlength(20) } dto * with mapstruct service all with serviceImpl paginate all with pagination ````
app-1.jdl ````jdl application { config { applicationType monolith, baseName foo, packageName com.foo, jhiPrefix gsr, authenticationType session, databaseType sql, devDatabaseType h2Disk, prodDatabaseType postgresql, enableHibernateCache true, cacheProvider ehcache, buildTool maven, testFrameworks [cypress, gatling, cucumber], clientFramework angular, enableTranslation true, nativeLanguage es, languages [es, en] incrementalChangelog true } entities * } /** Entity Foo */ entity Foo(foo) { /* Foo */ foo String required maxlength(20) /* Foo2 */ foo2 String maxlength(20) } dto * with mapstruct service all with serviceImpl paginate all with pagination ````
mshima commented 1 day ago

Node 22 issue will be tracked at https://github.com/jhipster/generator-jhipster/issues/27948.

mshima commented 1 day ago

This issue is in @yeoman/conflicter package due to diff breaking changes https://github.com/kpdecker/jsdiff/blob/master/release-notes.md#600

mshima commented 12 hours ago

This issue is in @yeoman/conflicter package due to diff breaking changes https://github.com/kpdecker/jsdiff/blob/master/release-notes.md#600

Fix is released in new @yeoman/conflicter version. Will be part of next JHipster release.