Skip to content

Commit

Permalink
update generator-jhipster to 8.7.3 (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima authored Oct 30, 2024
1 parent 7284b3f commit 835da54
Show file tree
Hide file tree
Showing 11 changed files with 1,040 additions and 1,968 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
10 changes: 5 additions & 5 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,22 +50,22 @@ jobs:
binary-dir: ${{ github.workspace }}/generator-jhipster-jooq/cli/
- run: npm install
working-directory: ${{ github.workspace }}/generator-jhipster-jooq
- run: cli.cjs generate-sample ${{ matrix.sample-name }} --skip-jhipster-dependencies ${{ 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-jooq
cmd: cli.cjs generate-sample ${{ matrix.sample-name }} --skip-jhipster-dependencies --skip-install ${{ matrix.extra-args }}
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 run ci:frontend:test --if-present
if: steps.compare.outputs.equals != 'true'
- 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:prepare
if: steps.compare.outputs.equals != 'true'
- run: npm run ci:e2e:run --if-present
Expand Down
2 changes: 1 addition & 1 deletion .yo-rc.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
}
},
"githubWorkflows": true,
"jhipsterVersion": "8.7.1",
"jhipsterVersion": "8.7.3",
"js": false,
"localBlueprint": false,
"packageJsonType": "module",
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
Loading

0 comments on commit 835da54

Please sign in to comment.