Skip to content

Commit

Permalink
client: adjust readme (#28335)
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima authored Jan 8, 2025
1 parent 91143ac commit a862a1c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 6 deletions.
9 changes: 9 additions & 0 deletions generators/app/__snapshots__/generator.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ exports[`generator - app with default config should match snapshot 1`] = `
"clientBundler": "webpack",
"clientBundlerAny": true,
"clientBundlerExperimentalEsbuild": false,
"clientBundlerName": "Webpack",
"clientBundlerVite": false,
"clientBundlerWebpack": true,
"clientDistDir": "target/classes/static/",
Expand All @@ -275,6 +276,8 @@ exports[`generator - app with default config should match snapshot 1`] = `
"clientRootDir": "",
"clientSrcDir": "src/main/webapp/",
"clientTestDir": "src/test/javascript/",
"clientTestFramework": "jest",
"clientTestFrameworkName": "Jest",
"clientTestFrameworks": undefined,
"clientTestFrameworksAny": false,
"clientTestFrameworksCypress": false,
Expand Down Expand Up @@ -929,6 +932,7 @@ exports[`generator - app with gateway should match snapshot 1`] = `
"clientBundler": "webpack",
"clientBundlerAny": true,
"clientBundlerExperimentalEsbuild": false,
"clientBundlerName": "Webpack",
"clientBundlerVite": false,
"clientBundlerWebpack": true,
"clientDistDir": "target/classes/static/",
Expand All @@ -944,6 +948,8 @@ exports[`generator - app with gateway should match snapshot 1`] = `
"clientRootDir": "",
"clientSrcDir": "src/main/webapp/",
"clientTestDir": "src/test/javascript/",
"clientTestFramework": "jest",
"clientTestFrameworkName": "Jest",
"clientTestFrameworks": undefined,
"clientTestFrameworksAny": false,
"clientTestFrameworksCypress": false,
Expand Down Expand Up @@ -1592,6 +1598,7 @@ exports[`generator - app with microservice should match snapshot 1`] = `
"clientBundler": undefined,
"clientBundlerAny": false,
"clientBundlerExperimentalEsbuild": false,
"clientBundlerName": undefined,
"clientBundlerVite": false,
"clientBundlerWebpack": false,
"clientDistDir": "target/classes/static/",
Expand All @@ -1607,6 +1614,8 @@ exports[`generator - app with microservice should match snapshot 1`] = `
"clientRootDir": "",
"clientSrcDir": "src/main/webapp/",
"clientTestDir": "src/test/javascript/",
"clientTestFramework": undefined,
"clientTestFrameworkName": undefined,
"clientTestFrameworks": undefined,
"clientTestFrameworksAny": false,
"clientTestFrameworksCypress": false,
Expand Down
12 changes: 12 additions & 0 deletions generators/client/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,18 @@ const command = {
choices: ['webpack', 'vite', 'experimentalEsbuild'],
scope: 'storage',
},
clientBundlerName: {
cli: { type: String, hide: true },
scope: 'storage',
},
clientTestFramework: {
cli: { type: String, hide: true },
scope: 'storage',
},
clientTestFrameworkName: {
cli: { type: String, hide: true },
scope: 'storage',
},
devServerPort: {
cli: {
type: Number,
Expand Down
8 changes: 8 additions & 0 deletions generators/client/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { startCase } from 'lodash-es';

import BaseApplicationGenerator from '../base-application/index.js';

Expand Down Expand Up @@ -137,6 +138,13 @@ export default class JHipsterClientGenerator extends BaseApplicationGenerator {
// Public API method used by the getter and also by Blueprints
get preparing() {
return this.asPreparingTaskGroup({
preparing({ applicationDefaults }) {
applicationDefaults({
clientBundlerName: ctx => (ctx.clientBundlerExperimentalEsbuild ? 'esbuild' : startCase(ctx.clientBundler)),
clientTestFramework: ctx => (ctx.clientFrameworkVue ? 'vitest' : 'jest'),
clientTestFrameworkName: ctx => startCase(ctx.clientTestFramework),
});
},
microservice({ application }) {
if (application.applicationTypeMicroservice) {
application.withAdminUi = false;
Expand Down
18 changes: 12 additions & 6 deletions generators/client/templates/README.md.jhi.client.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ You will only need to run this command when dependencies change in [package.json
<%= clientPackageMngrWrapper %> install
```
We use <%= clientPackageManager %> scripts and <&- fragments.customCliSection(' ') &>[Webpack][] as our build system.
We use <%= clientPackageManager %> scripts and <&- fragments.customCliSection(' ') &>[<%= clientBundlerName %>][] as our build system.
<%_ if (cacheProviderRedis || cacheProviderHazelcast || cacheProviderMemcached) { _%>
If you are using <%= cacheProvider %> as a cache, you will have to launch a cache server.
Expand Down Expand Up @@ -139,7 +139,7 @@ To benefit from TypeScript type definitions from [DefinitelyTyped][] repository
<%= clientPackageMngrWrapper %> <%= clientPackageMngrAddDev %> @types/leaflet
```
Then you would import the JS and CSS files specified in library's installation instructions so that [Webpack][] knows about them:
Then you would import the JS and CSS files specified in library's installation instructions so that [<%= clientBundlerName %>][] knows about them:
<%_ if (clientFrameworkAngular) { _%>
Edit [<%= clientSrcDir %>app/app.config.ts](<%= clientSrcDir %>app/app.config.ts) file:
Expand Down Expand Up @@ -196,7 +196,7 @@ cd microfrontend
<&_ if (fragment.testingSection) { -&>
### Client tests
Unit tests are run by [Jest][]. They're located in [<%= clientTestDir %>](<%= clientTestDir %>) and can be run with:
Unit tests are run by [<%= clientTestFrameworkName %>][]. They're located near components and can be run with:
```
<%= clientPackageMngrWrapper %> test
Expand All @@ -214,12 +214,18 @@ The lighthouse report is created in <% if (buildToolMaven) { %>`target/cypress/l
<%_ } _%>
<&_ } -&>
<&_ if (fragment.referenceSection) { -&>
<%_ if (clientBundlerWebpack) { _%>
[Webpack]: https://webpack.github.io/
<%_ } -%>
<%_ if (clientFrameworkReact || clientFrameworkAngular || microfrontend) { _%>
[BrowserSync]: https://www.browsersync.io/
[Jest]: https://facebook.github.io/jest/
<%_ if (cypressTests) { _%>
<%_ } -%>
<%_ if (clientFrameworkAngular || clientFrameworkReact) { _%>
[Jest]: https://jestjs.io
<%_ } -%>
<%_ if (cypressTests) { _%>
[Cypress]: https://www.cypress.io/
<%_ } -%>
<%_ } -%>
[Leaflet]: https://leafletjs.com/
[DefinitelyTyped]: https://definitelytyped.org/
<&_ } -&>
Expand Down

0 comments on commit a862a1c

Please sign in to comment.