Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to generator-jhipster v8.7.3 #283

Merged
merged 3 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion .yo-rc.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
}
},
"githubWorkflows": true,
"jhipsterVersion": "8.7.1",
"jhipsterVersion": "8.7.3",
"js": true,
"localBlueprint": false,
"packageJsonType": "module",
Expand Down
2 changes: 1 addition & 1 deletion .yo-resolve
Original file line number Diff line number Diff line change
@@ -1 +1 @@
README.md
README.md diff
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
Loading