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

Git commit fails in Windows after lint-staged upgrade to v9 #10312

Closed kaidohallik closed 5 years ago

kaidohallik commented 5 years ago
Overview of the issue

10254 upgraded lint-staged version from 8.2.0 to 9.2.3.

After that initial generated application is not committed to Git in Windows, the following error occurs:

Git commit error in Windows
husky > pre-commit (node v10.15.3)
‼  lint-staged generated an argument string of 21937 characters, and commands might not run correctly on your platform.
It is recommended to use functions as linters and split your command based on the number of staged files. For more info, please visit:
https://github.com/okonet/lint-staged#using-js-functions-to-customize-linter-commands
Stashing changes... [started]
Stashing changes... [skipped]
→ No partially staged files found...
Running tasks... [started]
Running tasks for {,src/**/}*.{md,json,ts,css,scss,yml} [started]
prettier --write [started]
prettier --write [failed]
→ 
Running tasks for {,src/**/}*.{md,json,ts,css,scss,yml} [failed]
→ 
Running tasks... [failed]

× prettier --write found some errors. Please fix them and try committing again.

The command line is too long.
husky > pre-commit hook failed (add --no-verify to bypass)

git did not exit cleanly (exit code 1) (1422 ms @ 30.08.2019 03:38:55)
  

lint-staged has some breaking changes from version 9.0.0 (see https://github.com/okonet/lint-staged/releases), one of them is: "Very long arguments strings are no longer chunked on Windows. Function linters should be used instead to customise this behaviour.".

Motivation for or Use Case

Want to commit application to Git also in Windows.

Reproduce the error

Generate app in Windows with command jhipster and try to commit this to Git.

Related issues
Suggest a Fix

Try to implement JS function as described in https://github.com/okonet/lint-staged#using-js-functions-to-customize-linter-commands

JHipster Version(s)
jhipster@0.0.1-SNAPSHOT C:\projects\teest\jhipster-git-commit2
`-- generator-jhipster@6.2.0  -> C:\projects\kaido-github\generator-jhipster
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "com.mycompany.myapp",
      "nativeLanguage": "et"
    },
    "jhipsterVersion": "6.2.0",
    "applicationType": "monolith",
    "baseName": "jhipster",
    "packageName": "com.mycompany.myapp",
    "packageFolder": "com/mycompany/myapp",
    "serverPort": "8080",
    "authenticationType": "jwt",
    "cacheProvider": "ehcache",
    "enableHibernateCache": true,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "prodDatabaseType": "mysql",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": false,
    "buildTool": "gradle",
    "enableSwaggerCodegen": false,
    "jwtSecretKey": "bXktc2VjcmV0LXRva2VuLXRvLWNoYW5nZS1pbi1wcm9kdWN0aW9uLWFuZC10by1rZWVwLWluLWEtc2VjdXJlLXBsYWNl",
    "useSass": true,
    "clientPackageManager": "npm",
    "clientFramework": "angularX",
    "clientTheme": "none",
    "clientThemeVariant": "",
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "otherModules": [],
    "enableTranslation": true,
    "nativeLanguage": "et",
    "languages": ["et", "en", "ru"],
    "blueprints": []
  }
}

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions

Environment and Tools

java version "1.8.0_211" Java(TM) SE Runtime Environment (build 1.8.0_211-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)

git version 2.21.0.windows.1

node: v10.15.3

npm: 6.9.0

yeoman: 2.0.6

yarn: 1.15.2

Docker version 19.03.1, build 74b1e89

docker-compose version 1.24.1, build 4667896b

Browsers and Operating System

Windows 10

vishal423 commented 5 years ago

Thanks @kaidohallik for reporting. I will handle this.

FlorianLeitgeb commented 4 years ago

Why is this closed? The issue still exists. "lint-staged": "^9.4.1", "husky": "^3.0.8",

vishal423 commented 4 years ago

@FlorianLeitgeb, please don't comment on a closed issue. If you see an issue, kindly open a new ticket with requisite details.

FYI, we reverted to the old version in our templates. Check this: https://github.com/jhipster/generator-jhipster/blob/56a5d39cb086ed823af3bf1c7479e766da0f740f/generators/client/templates/angular/package.json.ejs#L113