Skip to content

Commit

Permalink
update husky to v9.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Jul 23, 2024
1 parent 2d8514f commit 33e6a32
Show file tree
Hide file tree
Showing 15 changed files with 38 additions and 95 deletions.
10 changes: 9 additions & 1 deletion generators/app/__snapshots__/generator.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ Options:
--skip-jhipster-dependencies Don't write jhipster dependencies to package.json.
--creation-timestamp <value> Project creation timestamp (used for reproducible builds)
--jdl-store <value> JDL store
--skip-commit-hook Skip adding husky commit hooks
--prettier-tab-width <value> Default tab width for prettier
--monorepository Use monorepository
--skip-commit-hook Skip adding husky commit hooks
--db <value> Provide DB name for the application when skipping server side generation
--incremental-changelog Creates incremental database changelogs
--skip-user-management Skip the user management module during app generation
Expand Down Expand Up @@ -720,6 +720,8 @@ exports[`generator - app with default config should match snapshot 1`] = `
"packageName": "com.mycompany.myapp.web.rest.vm",
},
],
"packageJsonNodeEngine": undefined,
"packageJsonType": "commonjs",
"packageName": "com.mycompany.myapp",
"pages": [],
"prettierConfigFile": ".prettierrc",
Expand Down Expand Up @@ -1330,6 +1332,8 @@ exports[`generator - app with gateway should match snapshot 1`] = `
"packageName": "com.mycompany.myapp.web.rest.vm",
},
],
"packageJsonNodeEngine": undefined,
"packageJsonType": "commonjs",
"packageName": "com.mycompany.myapp",
"pages": [],
"prettierConfigFile": ".prettierrc",
Expand Down Expand Up @@ -1836,6 +1840,8 @@ exports[`generator - app with microservice should match snapshot 1`] = `
},
"nodeDependencies": {
"concurrently": "CONCURRENTLY_VERSION",
"eslint-config-prettier": "ESLINT_CONFIG_PRETTIER_VERSION",
"eslint-plugin-prettier": "ESLINT_PLUGIN_PRETTIER_VERSION",
"husky": "HUSKY_VERSION",
"lint-staged": "LINT_STAGED_VERSION",
"npm": "NPM_VERSION",
Expand Down Expand Up @@ -1885,6 +1891,8 @@ exports[`generator - app with microservice should match snapshot 1`] = `
"packageName": "com.mycompany.myapp.web.rest.vm",
},
],
"packageJsonNodeEngine": undefined,
"packageJsonType": "commonjs",
"packageName": "com.mycompany.myapp",
"pages": [],
"prettierConfigFile": ".prettierrc",
Expand Down
27 changes: 15 additions & 12 deletions generators/common/__snapshots__/generator.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ trim_trailing_whitespace = false
"stateCleared": "modified",
},
".husky/pre-commit": {
"contents": "#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
"$(dirname "$0")/../npmw" exec --no-install lint-staged
"contents": "lint-staged
",
"stateCleared": "modified",
},
Expand Down Expand Up @@ -111,20 +107,27 @@ This application was generated using JHipster JHIPSTER_VERSION, you can find doc
},
"package.json": {
"contents": "{
"config": {
"default_environment": "prod"
},
"private": true,
"dependencies": {},
"devDependencies": {
"generator-jhipster": "JHIPSTER_VERSION",
"husky": "HUSKY_VERSION",
"lint-staged": "LINT_STAGED_VERSION",
"prettier": "PRETTIER_VERSION",
"prettier-plugin-packagejson": "PRETTIER_PLUGIN_PACKAGEJSON_VERSION",
"prettier-plugin-java": "PRETTIER_PLUGIN_JAVA_VERSION"
"husky": "HUSKY_VERSION",
"lint-staged": "LINT_STAGED_VERSION"
},
"engines": {},
"scripts": {
"prepare": "husky"
}
},
"config": {
"default_environment": "prod"
},
"name": "jhipster",
"version": "0.0.0",
"description": "Description for JHipster",
"license": "UNLICENSED",
"type": "commonjs"
}
",
"stateCleared": "modified",
Expand Down
9 changes: 1 addition & 8 deletions generators/common/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@ import { JHipsterCommandDefinition } from '../base/api.js';
import { GENERATOR_BOOTSTRAP_APPLICATION_BASE } from '../generator-list.js';

const command: JHipsterCommandDefinition = {
options: {
skipCommitHook: {
description: 'Skip adding husky commit hooks',
type: Boolean,
scope: 'storage',
},
},
configs: {
defaultEnvironment: {
description: 'Default environment for the application',
Expand All @@ -40,7 +33,7 @@ const command: JHipsterCommandDefinition = {
scope: 'storage',
},
},
import: [GENERATOR_BOOTSTRAP_APPLICATION_BASE, 'jhipster:javascript:prettier'],
import: [GENERATOR_BOOTSTRAP_APPLICATION_BASE, 'jhipster:javascript:prettier', 'jhipster:javascript:husky'],
};

export default command;
6 changes: 0 additions & 6 deletions generators/common/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ export const commonFiles = {
templates: ['sonar-project.properties'],
},
],
commitHooks: [
{
condition: generator => !generator.skipCommitHook,
templates: ['.lintstagedrc.cjs', '.husky/pre-commit'],
},
],
};

export function writeFiles() {
Expand Down
24 changes: 3 additions & 21 deletions generators/common/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ export default class CommonGenerator extends BaseApplicationGenerator {
return this.asComposingTaskGroup({
async composing() {
await this.composeWithJHipster('jhipster:javascript:prettier');
if (!this.jhipsterConfig.skipCommitHook) {
await this.composeWithJHipster('jhipster:javascript:husky');
}
},
});
}
Expand Down Expand Up @@ -225,27 +228,6 @@ export default class CommonGenerator extends BaseApplicationGenerator {
},
});
},
addCommitHookDependencies({ application }) {
if (application.skipCommitHook) return;
this.packageJson.merge({
scripts: {
prepare: 'husky',
},
devDependencies: {
husky: application.nodeDependencies.husky,
'lint-staged': application.nodeDependencies['lint-staged'],
prettier: application.nodeDependencies.prettier,
'prettier-plugin-packagejson': application.nodeDependencies['prettier-plugin-packagejson'],
},
});
if (application.backendTypeJavaAny) {
this.packageJson.merge({
devDependencies: {
'prettier-plugin-java': application.nodeDependencies['prettier-plugin-java'],
},
});
}
},
});
}

Expand Down
2 changes: 0 additions & 2 deletions generators/common/resources/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"devDependencies": {
"concurrently": "8.2.2",
"husky": "9.0.11",
"lint-staged": "15.2.7",
"npm": "10.8.2",
"wait-on": "7.2.0"
}
Expand Down
9 changes: 0 additions & 9 deletions generators/common/templates/.husky/pre-commit.ejs

This file was deleted.

21 changes: 0 additions & 21 deletions generators/common/templates/.lintstagedrc.cjs.ejs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ exports[`generator - javascript:husky skipCommitHook(false) should call source s
exports[`generator - javascript:husky skipCommitHook(false) should match files snapshot 1`] = `
{
".husky/pre-commit": {
"contents": "#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx --no-install lint-staged",
"contents": "lint-staged
",
"stateCleared": "modified",
},
".lintstagedrc.cjs": {
"contents": "module.exports = {
'{,src/**/,webpack/}*.{md,json,yml,html,js,ts,tsx,css,scss,vue,java}': ['prettier --write'],
'{PRETTIER_FOLDERS}*.{PRETTIER_EXTENSIONS}': ['prettier --write'],
};
",
"stateCleared": "modified",
Expand Down
4 changes: 2 additions & 2 deletions generators/javascript/generators/husky/generator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe(`generator - ${generator}`, () => {
.withMockedJHipsterGenerators()
.withMockedSource()
.withMockedNodeDependencies()
.withSharedApplication({})
.withSharedApplication({ prettierExtensions: 'PRETTIER_EXTENSIONS', prettierFolders: 'PRETTIER_FOLDERS' })
.withJHipsterConfig(config);
});

Expand All @@ -54,7 +54,7 @@ describe(`generator - ${generator}`, () => {
});

it('should compose with generators', () => {
expect(result.composedMockedGenerators).toMatchObject(expect.arrayContaining(['jhipster:javascript:bootstrap']));
expect(result.composedMockedGenerators).toMatchObject(['jhipster:javascript:prettier'] as any);
});
});
}
Expand Down
2 changes: 1 addition & 1 deletion generators/javascript/generators/husky/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class HuskyGenerator extends BaseApplicationGenerator {
}

if (!this.delegateToBlueprint) {
await this.dependsOnJHipster('jhipster:javascript:bootstrap');
await this.dependsOnJHipster('jhipster:javascript:prettier');
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install lint-staged
lint-staged
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
limitations under the License.
-%>
module.exports = {
'{,src/**/,webpack/}*.{md,json,yml,html,js,ts,tsx,css,scss,vue,java}': ['prettier --write'],
'{<%= prettierFolders %>}*.{<%= prettierExtensions %>}': ['prettier --write'],
};
2 changes: 1 addition & 1 deletion generators/javascript/resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"dependencies": {
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prettier": "5.2.1",
"husky": "9.0.11",
"husky": "9.1.1",
"lint-staged": "15.2.7"
}
}
2 changes: 1 addition & 1 deletion generators/jdl/__snapshots__/generator.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ Options:
--skip-jhipster-dependencies Don't write jhipster dependencies to package.json.
--creation-timestamp <value> Project creation timestamp (used for reproducible builds)
--jdl-store <value> JDL store
--skip-commit-hook Skip adding husky commit hooks
--prettier-tab-width <value> Default tab width for prettier
--skip-commit-hook Skip adding husky commit hooks
--db <value> Provide DB name for the application when skipping server side generation
--incremental-changelog Creates incremental database changelogs
--recreate-initial-changelog Recreate the initial database changelog based on the current config
Expand Down

0 comments on commit 33e6a32

Please sign in to comment.