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 code by jdl cannot adjust the original line separators, always convert code with LF instead of CRLF #27783

Open
1 task done
flyliu33 opened this issue Nov 4, 2024 · 2 comments

Comments

@flyliu33
Copy link

flyliu33 commented Nov 4, 2024

Overview of the issue

I developed a project by jhipster with jdl on Windows 11 platform, after generating code by jdl, the line separator mode of the files of my project will tranform from CRLF to LF which conflict against git while comparing code by Jetbrains IDEAJ.

image

Motivation for or Use Case
Reproduce the error
  1. Generate app from JDL (files are generated with LF ending)
  2. Change the line separators of the whole project from LF to CRLF in IDEAJ. Select the root folder -> click File Menu -> select File Properties -> Select Line Separators -> Select CRLF.
  3. Now all of the files would be CRLF mode.
  4. Rerun app generation
  5. Compare files in Commit View. It will show difference of line separators.
Related issues

#19461

Suggest a Fix
JHipster Version(s)

8.7.3

JHipster configuration

microservice-ecommerce-store-4-apps.txt

.yo-rc.json file
{
  "generator-jhipster": {
    "applicationIndex": 0,
    "applicationType": "gateway",
    "applications": {
      "invoice": {
        "applicationIndex": 2,
        "serverPort": "8082"
      },
      "notification": {
        "applicationIndex": 3,
        "serverPort": "8083"
      },
      "product": {
        "applicationIndex": 1,
        "serverPort": "8081"
      }
    },
    "authenticationType": "jwt",
    "baseName": "store",
    "buildTool": "maven",
    "cacheProvider": "no",
    "clientFramework": "vue",
    "devServerPort": 9060,
    "entities": [
      "Customer",
      "Product",
      "ProductCategory",
      "ProductOrder",
      "OrderItem",
      "Invoice",
      "Shipment",
      "Notification"
    ],
    "jhipsterVersion": "8.7.3",
    "languages": [
      "en"
    ],
    "lastLiquibaseTimestamp": 1730345890000,
    "nativeLanguage": "en",
    "packageName": "com.jhipster.demo.store",
    "prodDatabaseType": "mysql",
    "reactive": true,
    "serverPort": 8080,
    "serviceDiscoveryType": "consul",
    "testFrameworks": [
      "cypress"
    ]
  }
}
Environment and Tools

openjdk version "17.0.12" 2024-07-16 LTS
OpenJDK Runtime Environment Corretto-17.0.12.7.1 (build 17.0.12+7-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.12.7.1 (build 17.0.12+7-LTS, mixed mode, sharing)

git version 2.45.1.windows.1

node: v20.17.0
npm: 10.8.2

Docker version 27.1.1, build 6312585

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions
@ChangelogDate("20241031033110")
entity Customer {
  firstName String required
  lastName String required
  gender Gender required
  email String required pattern(/^[^@\s]+@[^@\s]+\.[^@\s]+$/)
  phone String required
  addressLine1 String required
  addressLine2 String
  city String required
  country String required
}
/**
 * Product sold by the Online store
 */
@ChangelogDate("20241031033210")
entity Product {
  name String required
  description String
  price BigDecimal required min(0)
  productSize Size required
  image ImageBlob
}
@ChangelogDate("20241031033310")
entity ProductCategory {
  name String required
  description String
}
@ChangelogDate("20241031033410")
entity ProductOrder {
  placedDate Instant required
  status OrderStatus required
  code String required
  invoiceId Long
  customer String required
}
@ChangelogDate("20241031033510")
entity OrderItem {
  quantity Integer required min(0)
  totalPrice BigDecimal required min(0)
  status OrderItemStatus required
}
@ChangelogDate("20241031033610")
entity Invoice {
  code String required
  date Instant required
  details String
  status InvoiceStatus required
  paymentMethod PaymentMethod required
  paymentDate Instant required
  paymentAmount BigDecimal required
}
@ChangelogDate("20241031033710")
entity Shipment {
  trackingCode String
  date Instant required
  details String
}
@ChangelogDate("20241031033810")
entity Notification {
  date Instant required
  details String
  sentDate Instant required
  format NotificationType required
  userId Long required
  productId Long required
}

enum Gender {
  MALE,
  FEMALE,
  OTHER
}
enum Size {
  S,
  M,
  L,
  XL,
  XXL
}
enum OrderStatus {
  COMPLETED,
  PENDING,
  CANCELLED
}
enum OrderItemStatus {
  AVAILABLE,
  OUT_OF_STOCK,
  BACK_ORDER
}
enum InvoiceStatus {
  PAID,
  ISSUED,
  CANCELLED
}
enum PaymentMethod {
  CREDIT_CARD,
  CASH_ON_DELIVERY,
  PAYPAL
}
enum NotificationType {
  EMAIL,
  SMS,
  PARCEL
}

relationship OneToOne {
  Customer{user(login) required} to User with builtInEntity
}
relationship OneToMany {
  ProductCategory{product} to Product{productCategory(name)}
  ProductOrder{orderItem} to OrderItem{order(code) required}
  Invoice{shipment} to Shipment{invoice(code) required}
}
relationship ManyToOne {
  OrderItem{product(name) required} to Product
}

paginate Customer, Product, ProductOrder, OrderItem, Invoice, Shipment with pagination
service Customer, Product, ProductCategory, ProductOrder, OrderItem, Invoice, Shipment with serviceClass
search Customer, Product, ProductCategory, ProductOrder, OrderItem, Invoice, Shipment, Notification with no
microservice Product, ProductCategory, ProductOrder, OrderItem with product
microservice Invoice, Shipment with invoice
microservice Notification with notification
clientRootFolder Product, ProductCategory, ProductOrder, OrderItem with product
clientRootFolder Invoice, Shipment with invoice
clientRootFolder Notification with notification

Browsers and Operating System

git version = git version 2.45.1.windows.1
git config core.autocrlf = true

Edition Windows 11 Pro
Version 23H2
Installed on ‎8/‎19/‎2024
OS build 22631.4391
Experience Windows Feature Experience Pack 1000.22700.1047.0

  • Checking this box is mandatory (this is just to show you read everything)
@mshima
Copy link
Member

mshima commented Nov 4, 2024

You should use --auto-crlf option.

@flyliu33
Copy link
Author

flyliu33 commented Nov 5, 2024

This --auto-crlf option can work, I suggest if there are some descriptions for these kind of options on Jhipster Docs could be easy for developers.
Additionally, since my project is based on microservices architecture, while I executed command jhipster jdl .\store\microservice-ecommerce-store-4-apps.jdl --auto-crlf, error arose at the end, but the result is still successful. I am not sure if it need a optimization, because my ms-ecommerce-store as a regular root directory is actual without git management. And gateway and each microservice have their owe git configuration.

ERROR! An error occured while running jhipster:bootstrap#commitPrettierConfig
ERROR! ERROR! D:\workspace\ms-ecommerce-store is not inside a git repository
Error: D:\workspace\ms-ecommerce-store is not inside a git repository
    at autoCrlfTransform (file:///C:/Users/flyli/AppData/Roaming/nvm/v20.17.0/node_modules/generator-jhipster/dist/generators/bootstrap/support/auto-crlf-transform.js:56:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async BootstrapGenerator.commitSharedFs (file:///C:/Users/flyli/AppData/Roaming/nvm/v20.17.0/node_modules/generator-jhipster/dist/generators/bootstrap/generator.js:173:37)
    at async BootstrapGenerator.commitPrettierConfig (file:///C:/Users/flyli/AppData/Roaming/nvm/v20.17.0/node_modules/generator-jhipster/dist/generators/bootstrap/generator.js:137:9)
    at async BootstrapGenerator.method (file:///C:/Users/flyli/AppData/Roaming/nvm/v20.17.0/node_modules/generator-jhipster/dist/generators/bootstrap/generator.js:128:17)
    at async BootstrapGenerator.executeTask (file:///C:/Users/flyli/AppData/Roaming/nvm/v20.17.0/node_modules/generator-jhipster/node_modules/yeoman-generator/dist/actions/lifecycle.js:258:13)
    at async runLoop.add.once (file:///C:/Users/flyli/AppData/Roaming/nvm/v20.17.0/node_modules/generator-jhipster/node_modules/yeoman-environment/dist/environment-base.js:395:17)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants