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.54k stars 4.02k forks source link

Entity-client template error when generating entities in JHipster 7.9.0 #19304

Closed edilsonmendes closed 2 years ago

edilsonmendes commented 2 years ago
Overview of the issue

During the generation of entities (jhipster jdl jhipster-jdl.jdl) in a monolith angular application, the following error is happening in entity-client template:

`` An error occured while running jhipster:entity-client#writeClientFiles Error running generator entities: ReferenceError: /home/edilsonmendes/.nvm/versions/node/v16.13.1/lib/nodemodules/generator-jhipster/generators/entity-client/templates/angular/src/main/webapp/app/entities/update/entity-form.service.ts.ejs:195 193| ...<%= entityInstance %>RawValue, 194| <% for (const field of fields.filter(field => field.id)) { _%>

195| <%= field.fieldName %>: { value: <%= entityInstance %>RawValue.<%= field.fieldName %>, disabled: <% if (field.autoGenerate) { %>true<% } else { %><%= entityInstance %>RawValue.<%= fieldName %> !== null<% } %> }, 196| <% } %> 197| } as any / cast to workaround https://github.com/angular/angular/issues/46458 /); 198| }

fieldName is not defined `` It seems that the expression <%= fieldName %> in line 195 of the file generator-jhipster/generators/entity-client/templates/angular/src/main/webapp/app/entities/update/entity-form.service.ts should be <%= field.fieldName %>. As workaround, changing this on node_modules manually works fine.

Motivation for or Use Case

Its not possible generating any entities with this error.

Reproduce the error

1) Generate a new monolith jhipster 7.9.0, command: Jhipster 2) Create a jdl file with any entity and run: jhispter jdl

Related issues

I have never seen this before jhipster v7.9.0

Suggest a Fix

Change expression <%= fieldName %> in line 195 of the file generator-jhipster/generators/entity-client/templates/angular/src/main/webapp/app/entities/update/entity-form.service.ts should be <%= field.fieldName %>

JHipster Version(s)

7.9.0

JHipster configuration

Welcome to JHipster v7.9.0

Welcome to the JHipster Information Sub-Generator

JHipster Version(s)
demo@0.0.1-SNAPSHOT /home/edilsonmendes/jhipster/demo-7.9.0
└── (empty)
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "applicationType": "monolith",
    "authenticationType": "jwt",
    "baseName": "demo",
    "blueprints": [],
    "buildTool": "maven",
    "cacheProvider": "ehcache",
    "clientFramework": "angularX",
    "clientPackageManager": "npm",
    "clientTheme": "sandstone",
    "clientThemeVariant": "primary",
    "creationTimestamp": 1659308956406,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "devServerPort": 4200,
    "dtoSuffix": "DTO",
    "enableGradleEnterprise": false,
    "enableHibernateCache": false,
    "enableSwaggerCodegen": false,
    "enableTranslation": false,
    "entities": [],
    "entitySuffix": "",
    "jhiPrefix": "jhi",
    "jhipsterVersion": "7.9.0",
    "jwtSecretKey": "YourJWTSecretKeyWasReplacedByThisMeaninglessTextByTheJHipsterInfoCommandForObviousSecurityReasons",
    "languages": ["en", "fr"],
    "lastLiquibaseTimestamp": 1659310279000,
    "messageBroker": false,
    "microfrontend": false,
    "microfrontends": [],
    "nativeLanguage": "pt-br",
    "otherModules": [],
    "packageName": "com.jhipster.demo",
    "pages": [],
    "prodDatabaseType": "postgresql",
    "reactive": false,
    "searchEngine": false,
    "serverPort": "8080",
    "serverSideOptions": [],
    "serviceDiscoveryType": "no",
    "skipCheckLengthOfIdentifier": false,
    "skipFakeData": false,
    "skipUserManagement": false,
    "testFrameworks": [],
    "websocket": false,
    "withAdminUi": true
  }
}

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions
entity Documento(DOCUMENTO) {
id Long
numeroAutenticacao String
dataAutenticacao ZonedDateTime
documentoPDF AnyBlob
usuarioUpload String maxlength(11)
hashDocumento String maxlength(32)
dataCancelamento ZonedDateTime
usuarioCancelamento String maxlength(11)
}

entity Parametro(PARAMETRO) {
id String
valor String maxlength(4000)
descricao String maxlength(4000)
tipo TipoParametro
}

entity TipoDocumento(TIPODOCUMENTO) {
descricao String maxlength(200)
privadoMagistrado SimNao
ativo SimNao
}

enum SimNao {
  S(Sim),
  N(Nao)
}

enum TipoParametro {
  BL(BOOLEANO),
  TX(TEXTO)
}

relationship ManyToOne {
  Documento to TipoDocumento{id(descricao)}
}

paginate * with pagination

filter *

Environment and Tools

openjdk version "11.0.15" 2022-04-19 OpenJDK Runtime Environment Temurin-11.0.15+10 (build 11.0.15+10) OpenJDK 64-Bit Server VM Temurin-11.0.15+10 (build 11.0.15+10, mixed mode)

git version 2.25.1

node: v16.13.1

npm: 8.1.2

Docker version 20.10.11, build dea9396

docker-compose version 1.29.1, build c34c88b2

Entity configuration(s) entityName.json files generated in the .jhipster directory
Browsers and Operating System

Ubuntu (on WSL Windows 10)

mshima commented 2 years ago

Manually generated id is not covered by our CI. Do you want to provide a PR?