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

faker 8 location.country_code broken #22853

Closed anothergoodguy closed 1 year ago

anothergoodguy commented 1 year ago
Overview of the issue

Jhipster generation fails for countryCode String maxlength(10) in Address entity. Here is the error: [@faker-js/faker]: faker.address is deprecated since v8.0 and will be removed in v10.0. Please use faker.location instead. ERROR! An error occured while running jhipster:liquibase-changelogs#prepareFakeData ERROR! ERROR! The locale data for 'location.country_code' are missing in this locale. Please contribute the missing data to the project or use a locale/Faker instance that has these data. For more information see https://fakerjs.dev/guide/localization.html p [Error]: The locale data for 'location.country_code' are missing in this locale. Please contribute the missing data to the project or use a locale/Faker instance that has these data. For more information see https://fakerjs.dev/guide/localization.html at Object.get (file:///home/jhipster/generator-jhipster/node_modules/@faker-js/faker/dist/esm/chunk-2JBE4HP3.mjs:2:108) at H.countryCode (file:///home/jhipster/generator-jhipster/nodemodules/@faker-js/faker/dist/esm/chunk-2JBE4HP3.mjs:13:24833) at .fake (file:///home/jhipster/generator-jhipster/node_modules/@faker-js/faker/dist/esm/chunk-2JBE4HP3.mjs:13:117) at BootstrapApplicationBase.generateFakeDataForField (file:///home/jhipster/generator-jhipster/dist/generators/base-application/support/prepare-field.mjs:170:63) at field.generateFakeData (file:///home/jhipster/generator-jhipster/dist/generators/base-application/support/prepare-field.mjs:310:45) at file:///home/jhipster/generator-jhipster/dist/generators/liquibase-changelogs/generator.mjs:108:42 at Array.forEach () at DatabaseChangelogLiquibase.prepareFakeData (file:///home/jhipster/generator-jhipster/dist/generators/liquibase-changelogs/generator.mjs:91:28) at DatabaseChangelogLiquibase.executeTask (file:///home/jhipster/generator-jhipster/node_modules/yeoman-generator/dist/actions/lifecycle.js:240:26) at env.queueTask.once (file:///home/jhipster/generator-jhipster/node_modules/yeoman-generator/dist/actions/lifecycle.js:214:56) at runLoop.add.once (file:///home/jhipster/generator-jhipster/node_modules/yeoman-environment/dist/environment-base.js:383:23) at Immediate. (/home/jhipster/generator-jhipster/node_modules/grouped-queue/lib/subqueue.js:48:34) at process.processImmediate (node:internal/timers:476:21)

Motivation for or Use Case

Adding Country code to the Address.

Reproduce the error

Atached the JDL below and the issue is reproducible on jhipster --with-entities --force --skip-install --skip-git --no-insight

also tried with --skip-fake-data but it doesn't have any effect

Related issues

22811

JHipster Version(s)

8.0.0-beta.2

JHipster configuration
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "applicationIndex": 0,
  "applicationType": "monolith",
  "authenticationType": "oauth2",
  "baseName": "store",
  "buildTool": "gradle",
  "cacheProvider": "infinispan",
  "clientFramework": "react",
  "clientPackageManager": "npm",
  "clientTheme": "minty",
  "clientThemeVariant": "light",
  "creationTimestamp": 1688745650477,
  "databaseType": "sql",
  "devDatabaseType": "mysql",
  "devServerPort": 9060,
  "dtoSuffix": "DTO",
  "enableGradleEnterprise": false,
  "enableHibernateCache": true,
  "enableSwaggerCodegen": false,
  "enableTranslation": true,
  "entities": [
    "Category",
    "Product",
    "Customer",
    "Address",
    "WishList"
  ],
  "entitySuffix": "",
  "jhiPrefix": "tm",
  "jhipsterVersion": "8.0.0-beta.2",
  "languages": [
    "en"
  ],
  "lastLiquibaseTimestamp": 1688745654000,
  "messageBroker": "no",
  "nativeLanguage": "en",
  "otherModules": [],
  "packageFolder": "com/sample/shop",
  "packageName": "com.sample.shop",
  "pages": [],
  "pkType": "UUID",
  "prodDatabaseType": "mysql",
  "reactive": false,
  "searchEngine": "elasticsearch",
  "serverPort": 8080,
  "serverSideOptions": [
    "searchEngine:elasticsearch"
  ],
  "serviceDiscoveryType": "eureka",
  "skipCheckLengthOfIdentifier": false,
  "skipClient": false,
  "skipFakeData": false,
  "skipServer": false,
  "skipUserManagement": true,
  "testFrameworks": [
    "cypress",
    "protractor",
    "gatling",
    "cucumber"
  ],
  "websocket": false,
  "withAdminUi": true
}
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.25.1

node: v18.16.1 npm: 9.5.1

'docker' command could not be found

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions
entity Category {
  description String required
  sortOrder Integer
  dateAdded LocalDate
  dateModified LocalDate
  status CategoryStatus
}
entity Product {
  title String required
  keywords String
  description String
  rating Integer
  dateAdded LocalDate
  dateModified LocalDate
}
entity Customer {
  firstName String
  lastName String
  email String
  telephone String
}
entity Address {
  address1 String
  address2 String
  city String
  postcode String required maxlength(10)
  country String required maxlength(2)
  contactNumber String maxlength(45)
  mobileNumber String maxlength(45)
  countryCode String maxlength(10)
}
entity WishList {
  title String required
  restricted Boolean
}
enum CategoryStatus {
  AVAILABLE,
  RESTRICTED,
  DISABLED
}

relationship OneToMany {
  Customer{wishList(title)} to WishList{customer}
  Customer{address} to Address{customer}
  WishList{product(title)} to Product{wishList}
}
relationship ManyToOne {
  Category{parent} to Category
}
relationship ManyToMany {
  Category{product(title)} to Product{category}
}

dto Category, Product, Customer, Address, WishList with mapstruct
paginate Category, Product, Customer, Address, WishList with infinite-scroll
service Category, Product, Customer, Address, WishList with serviceClass
search Category, Product, Customer, Address, WishList with elasticsearch

Entity configuration(s) entityName.json files generated in the .jhipster directory

Address.json:

{ "applications": ["store"], "changelogDate": "20230707160053", "dto": "mapstruct", "entityTableName": "address", "fields": [ { "fieldName": "address1", "fieldType": "String" }, { "fieldName": "address2", "fieldType": "String" }, { "fieldName": "city", "fieldType": "String" }, { "fieldName": "postcode", "fieldType": "String", "fieldValidateRules": ["required", "maxlength"], "fieldValidateRulesMaxlength": "10" }, { "fieldName": "country", "fieldType": "String", "fieldValidateRules": ["required", "maxlength"], "fieldValidateRulesMaxlength": "2" }, { "fieldName": "contactNumber", "fieldType": "String", "fieldValidateRules": ["maxlength"], "fieldValidateRulesMaxlength": "45" }, { "fieldName": "mobileNumber", "fieldType": "String", "fieldValidateRules": ["maxlength"], "fieldValidateRulesMaxlength": "45" }, { "fieldName": "countryCode", "fieldType": "String", "fieldValidateRules": ["maxlength"], "fieldValidateRulesMaxlength": "10" } ], "name": "Address", "pagination": "infinite-scroll", "relationships": [ { "otherEntityName": "customer", "otherEntityRelationshipName": "address", "relationshipName": "customer", "relationshipSide": "right", "relationshipType": "many-to-one" } ], "searchEngine": "elasticsearch", "service": "serviceClass" }

Browsers and Operating System

Docker on MacOS : 13.4.1 (22F82)

anothergoodguy commented 1 year ago

I tried to make the changes locally and try running the generation, Getting one Warning and One `Error``:

  1. Warning:

[@faker-js/faker]: faker.name is deprecated since v8.0 and will be removed in v10.0. Please use faker.person instead.

  1. Error:
ERROR! An error occured while running jhipster:liquibase-changelogs#prepareFakeData
ERROR! ERROR! Invalid module method or definition: commerce.color
- faker.commerce.color is not a function
- faker.definitions.commerce.color is not an array
p [Error]: Invalid module method or definition: commerce.color
- faker.commerce.color is not a function
- faker.definitions.commerce.color is not an array
    at _.fake (file:///home/jhipster/generator-jhipster/node_modules/@faker-js/faker/dist/esm/chunk-2JBE4HP3.mjs:11:7179)
    at BootstrapApplicationBase.generateFakeDataForField (file:///home/jhipster/generator-jhipster/dist/generators/base-application/support/prepare-field.mjs:170:63)
    at field.generateFakeData (file:///home/jhipster/generator-jhipster/dist/generators/base-application/support/prepare-field.mjs:310:45)
    at file:///home/jhipster/generator-jhipster/dist/generators/liquibase-changelogs/generator.mjs:108:42
    at Array.forEach (<anonymous>)
    at DatabaseChangelogLiquibase.prepareFakeData (file:///home/jhipster/generator-jhipster/dist/generators/liquibase-changelogs/generator.mjs:91:28)
    at DatabaseChangelogLiquibase.executeTask (file:///home/jhipster/generator-jhipster/node_modules/yeoman-generator/dist/actions/lifecycle.js:240:26)
    at env.queueTask.once (file:///home/jhipster/generator-jhipster/node_modules/yeoman-generator/dist/actions/lifecycle.js:214:56)
    at runLoop.add.once (file:///home/jhipster/generator-jhipster/node_modules/yeoman-environment/dist/environment-base.js:383:23)
    at Immediate.<anonymous> (/home/jhipster/generator-jhipster/node_modules/grouped-queue/lib/subqueue.js:48:34)
    at process.processImmediate (node:internal/timers:476:21)

commenting the below snippet is allowing to proceed further, but that might not be the ideal.

else if (columnName === 'color') {
    fakeTemplate = 'commerce.color';
  }
anothergoodguy commented 1 year ago

I mean the changes that are yet to be merged

anothergoodguy commented 1 year ago

could you please advise on --skip-fake-data. not sure if it's considered during the initial steps or it's considered only during generation. It will be great if it can skip these validations also for running these experiments

anothergoodguy commented 1 year ago

still fails for color