Skip to content

Commit

Permalink
update generator-jhipster to 8.7.3 (#416)
Browse files Browse the repository at this point in the history
* Update configuration.component.spec.ts.ejs

* Update configuration.service.spec.ts.ejs

* update generator-jhipster to 8.7.3

* customize printLogo

* add mysql sleep in docker

* mysql customization

* Update generator.js

* lint fix

---------

Co-authored-by: JHipster Bot <[email protected]>
  • Loading branch information
mshima and jhipster-bot authored Oct 30, 2024
1 parent 257e749 commit 6d45c59
Show file tree
Hide file tree
Showing 19 changed files with 1,076 additions and 2,963 deletions.
20 changes: 10 additions & 10 deletions .blueprint/generate-sample/command.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* limitations under the License.
*/
import { GENERATOR_APP } from 'generator-jhipster/generators';
import { getSamples } from './get-samples.mjs';
import { getGithubSamplesGroup } from 'generator-jhipster/testing';

/**
* @type {import('generator-jhipster').JHipsterCommandDefinition}
Expand All @@ -29,12 +29,20 @@ const command = {
},
},
configs: {
samplesFolder: {
description: 'Path to the samples folder',
cli: {
type: String,
},
default: 'samples',
scope: 'generator',
},
sampleName: {
prompt: gen => ({
when: !gen.all,
type: 'list',
message: 'which sample do you want to generate?',
choices: async () => getSamples(gen.templatePath(gen.samplesFolder)),
choices: async () => getGithubSamplesGroup(gen.templatePath(gen.samplesFolder)),
}),
scope: 'generator',
},
Expand All @@ -45,14 +53,6 @@ const command = {
},
scope: 'generator',
},
samplesFolder: {
description: 'Path to the samples folder',
cli: {
type: String,
},
default: 'samples',
scope: 'generator',
},
},
options: {},
import: [GENERATOR_APP],
Expand Down
21 changes: 17 additions & 4 deletions .blueprint/generate-sample/generator.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { readdir } from 'node:fs/promises';
import { readFileSync } from 'node:fs';
import { extname, join } from 'node:path';
import BaseGenerator from 'generator-jhipster/generators/base';
import { getGithubSamplesGroup } from 'generator-jhipster/testing';

export default class extends BaseGenerator {
sampleName;
Expand All @@ -14,11 +16,22 @@ export default class extends BaseGenerator {
get [BaseGenerator.WRITING]() {
return this.asWritingTaskGroup({
async copySample() {
const samplesFolder = `${this.samplesFolder ?? 'samples'}/`;
if (this.all) {
this.copyTemplate(`${samplesFolder}*.jdl`, '');
const { samplesFolder, all, sampleName } = this;
if (all) {
this.copyTemplate(`${samplesFolder}/*.jdl`, '');
} else if (extname(sampleName) === '.jdl') {
this.copyTemplate(join(samplesFolder, sampleName), sampleName, { noGlob: true });
} else {
this.copyTemplate(`${samplesFolder}${this.sampleName}`, this.sampleName, { noGlob: true });
const { samples } = await getGithubSamplesGroup(this.templatePath(), samplesFolder);
const { 'sample-type': sampleType } = samples[sampleName];
if (sampleType === 'jdl') {
const jdlFile = `${sampleName}.jdl`;
this.copyTemplate(join(samplesFolder, jdlFile), jdlFile, { noGlob: true });
} else if (sampleType === 'yo-rc') {
this.copyTemplate(join(samplesFolder, sampleName, '**'), '', {
fromBasePath: this.templatesPath(samplesFolder, sampleName),
});
}
}
},
});
Expand Down
11 changes: 0 additions & 11 deletions .blueprint/generate-sample/get-samples.mjs

This file was deleted.

24 changes: 0 additions & 24 deletions .blueprint/github-build-matrix/build-matrix.mjs

This file was deleted.

24 changes: 12 additions & 12 deletions .blueprint/github-build-matrix/generator.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { appendFileSync, existsSync } from 'node:fs';
import os from 'node:os';
import BaseGenerator from 'generator-jhipster/generators/base';
import { getSamples } from '../generate-sample/get-samples.mjs';
import { buildMatrix } from './build-matrix.mjs';
import { convertToGitHubMatrix, getGithubOutputFile, getGithubSamplesGroup, setGithubTaskOutput } from 'generator-jhipster/testing';

export default class extends BaseGenerator {
/** @type {string} */
samplesFolder;

constructor(args, opts, features) {
Expand All @@ -14,14 +12,16 @@ export default class extends BaseGenerator {
get [BaseGenerator.WRITING]() {
return this.asWritingTaskGroup({
async buildMatrix() {
const samplesFolder = this.samplesFolder ?? 'samples';
const samples = await getSamples(this.templatePath(`../../generate-sample/templates/${samplesFolder}`));
const matrix = buildMatrix({ samples, samplesFolder });
const matrixoutput = `matrix<<EOF${os.EOL}${JSON.stringify(matrix)}${os.EOL}EOF${os.EOL}`;
const filePath = process.env.GITHUB_OUTPUT;
console.log(matrixoutput);
if (filePath && existsSync(filePath)) {
appendFileSync(filePath, matrixoutput, { encoding: 'utf8' });
const { samplesFolder } = this;
const { samples, warnings } = await getGithubSamplesGroup(this.templatePath('../../generate-sample/templates/'), samplesFolder);
if (warnings.length > 0) {
this.info(warnings.join('\n'));
}
const matrix = JSON.stringify(convertToGitHubMatrix(samples));
const githubOutputFile = getGithubOutputFile(matrix);
this.log.info('matrix', matrix);
if (githubOutputFile) {
setGithubTaskOutput('matrix', matrix);
}
},
});
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/generator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22
cache: 'npm'
- run: npm ci
- run: npm run test
13 changes: 6 additions & 7 deletions .github/workflows/samples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22
- id: build
run: |
npm install
Expand Down Expand Up @@ -50,24 +50,23 @@ jobs:
binary-dir: ${{ github.workspace }}/generator-jhipster-micronaut/cli/
- run: npm install
working-directory: ${{ github.workspace }}/generator-jhipster-micronaut
- run: cli.cjs generate-sample ${{ matrix.sample-name }} --skip-jhipster-dependencies --skip-install ${{ matrix.extra-args }}
- run: cli.cjs generate-sample ${{ matrix.sample }}.jdl --skip-jhipster-dependencies --skip-install ${{ matrix.extra-args }}
- uses: jhipster/actions/compare-sample@v0
id: compare
if: >-
github.event.pull_request &&
!contains(github.event.pull_request.labels.*.name, 'pr: disable-compare')
with:
generator-path: generator-jhipster-micronaut
cmd: cli.cjs generate-sample ${{ matrix.sample-name }} --skip-jhipster-dependencies --skip-install ${{ matrix.extra-args }}
- run: npm run ci:e2e:prepare
if: steps.compare.outputs.equals != 'true'
cmd: cli.cjs generate-sample ${{ matrix.sample }}.jdl --skip-jhipster-dependencies --skip-install ${{ matrix.extra-args }}
- run: npm run ci:backend:test
if: steps.compare.outputs.equals != 'true'
id: backend
- run: npm install
- run: npm run ci:e2e:package
if: steps.compare.outputs.equals != 'true'
- run: npm run ci:frontend:test --if-present
if: steps.compare.outputs.equals != 'true'
- run: npm run ci:e2e:package
- run: npm run ci:e2e:prepare
if: steps.compare.outputs.equals != 'true'
- run: npm run ci:e2e:run --if-present
if: steps.compare.outputs.equals != 'true'
Expand Down
2 changes: 1 addition & 1 deletion .yo-rc.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
}
},
"githubWorkflows": true,
"jhipsterVersion": "8.7.1",
"jhipsterVersion": "8.7.3",
"js": true,
"localBlueprint": false,
"packageJsonType": "module",
Expand Down
4 changes: 4 additions & 0 deletions cli/cli-customizations.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
// This file will not be overwritten by generate-blueprint
module.exports = {
printBlueprintLogo: undefined,
printLogo: async () => {
const { getLogo } = await import('./logo.js');
console.log(getLogo());
},
};
4 changes: 0 additions & 4 deletions cli/cli.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const blueprint = packageFolderName.startsWith('jhipster-') ? `generator-${packa

(async () => {
const { runJHipster, done, logger } = await import('generator-jhipster/cli');
const { getLogo } = await import('./logo.js');
const executableName = Object.keys(bin)[0];

runJHipster({
Expand All @@ -27,9 +26,6 @@ const blueprint = packageFolderName.startsWith('jhipster-') ? `generator-${packa
console.log('===================== JHipster Micronaut =====================');
console.log('');
},
printLogo: () => {
console.log(getLogo());
},
lookups: [{ packagePaths: [packagePath] }],
...require('./cli-customizations.cjs'),
}).catch(done);
Expand Down
5 changes: 1 addition & 4 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import globals from 'globals';
import prettier from 'eslint-plugin-prettier/recommended';
import jhipster from 'generator-jhipster/eslint/recommended';

// Workaround for jhipster export issue.
delete jhipster.recommended.recommended;
import jhipster from 'generator-jhipster/eslint';
// jhipster-needle-eslint-add-import - JHipster will add additional import here

export default [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ distributed under the License is distributed on an "AS IS" BASIS,
limitations under the License.
-%>
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { provideHttpClientTesting } from '@angular/common/http/testing';
import { provideHttpClient } from '@angular/common/http';
import { of } from 'rxjs';

import ConfigurationComponent from './configuration.component';
Expand All @@ -31,8 +32,8 @@ describe('ConfigurationComponent', () => {
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule, ConfigurationComponent],
providers: [ConfigurationService],
imports: [ConfigurationComponent],
providers: [ConfigurationService, provideHttpClient(), provideHttpClientTesting()],
})
.overrideTemplate(ConfigurationComponent, '')
.compileComponents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ distributed under the License is distributed on an "AS IS" BASIS,
limitations under the License.
-%>
import { TestBed } from '@angular/core/testing';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { provideHttpClientTesting, HttpTestingController } from '@angular/common/http/testing';
import { provideHttpClient } from '@angular/common/http';

import { ConfigurationService } from 'app/admin/configuration/configuration.service';

Expand All @@ -29,7 +30,7 @@ describe('Service Tests', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule]
providers: [provideHttpClient(), provideHttpClientTesting()]
});

expectedResult = null;
Expand Down
3 changes: 3 additions & 0 deletions generators/cypress/__snapshots__/generator.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ exports[`SubGenerator cypress of micronaut JHipster blueprint > run > should suc
"src/test/javascript/cypress/e2e/account/login-page.cy.ts": {
"stateCleared": "modified",
},
"src/test/javascript/cypress/e2e/account/logout.cy.ts": {
"stateCleared": "modified",
},
"src/test/javascript/cypress/e2e/account/password-page.cy.ts": {
"stateCleared": "modified",
},
Expand Down
Loading

0 comments on commit 6d45c59

Please sign in to comment.