Skip to content

Commit

Permalink
Update generator-jhipster to v8.8.0 (#2059)
Browse files Browse the repository at this point in the history
* update generator-jhipster to 8.8.0

* revert test

* ci adjust
  • Loading branch information
mshima authored Dec 24, 2024
1 parent c62dd86 commit 70f3b4b
Show file tree
Hide file tree
Showing 12 changed files with 1,694 additions and 975 deletions.
27 changes: 24 additions & 3 deletions .blueprint/generate-sample/command.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
* limitations under the License.
*/
import { GENERATOR_APP } from 'generator-jhipster/generators';
import { getGithubSamplesGroup } from 'generator-jhipster/testing';
import { getGithubSamplesGroup, getGithubSamplesGroups } from 'generator-jhipster/testing';

const DEFAULT_SAMPLES_GROUP = 'samples';

/**
* @type {import('generator-jhipster').JHipsterCommandDefinition}
Expand All @@ -34,15 +36,34 @@ const command = {
cli: {
type: String,
},
default: 'samples',
scope: 'generator',
},
samplesGroup: {
description: 'Samples group to lookup',
cli: {
type: String,
},
prompt: gen => ({
when: !gen.all && !gen.sampleName,
type: 'list',
message: 'which sample group do you want to lookup?',
choices: async () => getGithubSamplesGroups(gen.templatePath(gen.samplesFolder ?? '')),
default: DEFAULT_SAMPLES_GROUP,
}),
configure: gen => {
gen.samplesGroup = DEFAULT_SAMPLES_GROUP;
},
scope: 'generator',
},
sampleName: {
prompt: gen => ({
when: !gen.all,
type: 'list',
message: 'which sample do you want to generate?',
choices: async () => getGithubSamplesGroup(gen.templatePath(gen.samplesFolder)),
choices: async answers => {
const samples = await getGithubSamplesGroup(gen.templatePath(), answers.samplesFolder ?? gen.samplesFolder);
return Object.keys(samples.samples);
},
}),
scope: 'generator',
},
Expand Down
76 changes: 58 additions & 18 deletions .blueprint/generate-sample/generator.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,20 @@ import BaseGenerator from 'generator-jhipster/generators/base';
import { getGithubSamplesGroup } from 'generator-jhipster/testing';

export default class extends BaseGenerator {
/** @type {string | undefined} */
samplesFolder;
/** @type {string} */
samplesGroup;
/** @type {string} */
sampleName;
/** @type {boolean} */
all;
samplesFolder;
/** @type {string} */
sampleType;
/** @type {string} */
sampleFile;
/** @type {any} */
generatorOptions;

constructor(args, opts, features) {
super(args, opts, { ...features, queueCommandTasks: true, jhipsterBootstrap: false });
Expand All @@ -16,20 +27,33 @@ export default class extends BaseGenerator {
get [BaseGenerator.WRITING]() {
return this.asWritingTaskGroup({
async copySample() {
const { samplesFolder, all, sampleName } = this;
const { samplesFolder, samplesGroup, all, sampleName } = this;
const samplesPath = samplesFolder ? join(samplesFolder, samplesGroup) : samplesGroup;
if (all) {
this.copyTemplate(`${samplesFolder}/*.jdl`, '');
this.copyTemplate(`${samplesPath}/*.jdl`, '');
this.sampleType = 'jdl';
} else if (extname(sampleName) === '.jdl') {
this.copyTemplate(join(samplesFolder, sampleName), sampleName, { noGlob: true });
this.copyTemplate(join(samplesPath, sampleName), sampleName, { noGlob: true });
this.sampleType = 'jdl';
} else {
const { samples } = await getGithubSamplesGroup(this.templatePath(), samplesFolder);
const { 'sample-type': sampleType } = samples[sampleName];
const { samples } = await getGithubSamplesGroup(this.templatePath(), samplesPath);
const {
'sample-type': sampleType,
'sample-file': sampleFile = sampleName,
'sample-folder': sampleFolder = samplesPath,
generatorOptions,
} = samples[sampleName];

this.generatorOptions = generatorOptions;
this.sampleType = sampleType;

if (sampleType === 'jdl') {
const jdlFile = `${sampleName}.jdl`;
this.copyTemplate(join(samplesFolder, jdlFile), jdlFile, { noGlob: true });
const jdlFile = `${sampleFile}.jdl`;
this.copyTemplate(join(sampleFolder, jdlFile), jdlFile, { noGlob: true });
} else if (sampleType === 'yo-rc') {
this.copyTemplate(join(samplesFolder, sampleName, '**'), '', {
fromBasePath: this.templatesPath(samplesFolder, sampleName),
this.copyTemplate('**', '', {
fromBasePath: this.templatePath(sampleFolder, sampleFile),
globOptions: { dot: true },
});
}
}
Expand All @@ -39,17 +63,23 @@ export default class extends BaseGenerator {

get [BaseGenerator.END]() {
return this.asEndTaskGroup({
async generateSample() {
const packageJson = JSON.parse(readFileSync(new URL('../../package.json', import.meta.url)));
const projectVersion = `${packageJson.version}-git`;
async generateYoRcSample() {
if (this.sampleType !== 'yo-rc') return;

const generatorOptions = this.getDefaultComposeOptions();
await this.composeWithJHipster('app', { generatorOptions });
},
async generateJdlSample() {
if (this.sampleType !== 'jdl') return;

const generatorOptions = this.getDefaultComposeOptions();
const folderContent = await readdir(this.destinationPath());
const jdlFiles = folderContent.filter(file => file.endsWith('.jdl'));

await this.composeWithJHipster('jdl', {
generatorArgs: this.all ? await readdir(this.templatePath('samples')) : [this.sampleName],
generatorArgs: jdlFiles,
generatorOptions: {
skipJhipsterDependencies: true,
insight: false,
skipChecks: true,
projectVersion,
...generatorOptions,
...(this.all ? { workspaces: true, monorepository: true } : { skipInstall: true }),
},
});
Expand All @@ -59,4 +89,14 @@ export default class extends BaseGenerator {
},
});
}

getDefaultComposeOptions() {
const packageJson = JSON.parse(readFileSync(new URL('../../package.json', import.meta.url)));
const projectVersion = `${packageJson.version}-git`;
return {
skipJhipsterDependencies: true,
projectVersion,
...this.generatorOptions,
};
}
}
2 changes: 1 addition & 1 deletion .blueprint/generate-sample/templates/ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default Object.fromEntries(
sample,
{
...spec,
'docker-services': !sample.includes('oauth2'),
'docker-services': `${!sample.includes('oauth2')}`,
...(sample.includes('oauth2')
? { os: 'macos-13', 'default-environment': 'prod', 'skip-e2e': 'true' }
: { os: 'macos-15', 'default-environment': 'dev' }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,38 @@ exports[`generator - github-build-matrix > with ios > should match matrix value
"include": [
{
"default-environment": "dev",
"docker-services": true,
"docker-services": "true",
"java-version": "17",
"job-name": "21points-jwt",
"jwt-secret-key": "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ=",
"node-version": "22.11.0",
"npm-version": "10.9.0",
"node-version": "22.12.0",
"npm-version": "11.0.0",
"os": "macos-15",
"sample": "21points-jwt",
"sample-type": "jdl",
"samples-group": "ios",
},
{
"default-environment": "dev",
"docker-services": true,
"docker-services": "true",
"java-version": "17",
"job-name": "app-jwt",
"jwt-secret-key": "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ=",
"node-version": "22.11.0",
"npm-version": "10.9.0",
"node-version": "22.12.0",
"npm-version": "11.0.0",
"os": "macos-15",
"sample": "app-jwt",
"sample-type": "jdl",
"samples-group": "ios",
},
{
"default-environment": "prod",
"docker-services": false,
"docker-services": "false",
"java-version": "17",
"job-name": "app-oauth2",
"jwt-secret-key": "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ=",
"node-version": "22.11.0",
"npm-version": "10.9.0",
"node-version": "22.12.0",
"npm-version": "11.0.0",
"os": "macos-13",
"sample": "app-oauth2",
"sample-type": "jdl",
Expand All @@ -45,25 +45,25 @@ exports[`generator - github-build-matrix > with ios > should match matrix value
},
{
"default-environment": "dev",
"docker-services": true,
"docker-services": "true",
"java-version": "17",
"job-name": "app-websocket",
"jwt-secret-key": "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ=",
"node-version": "22.11.0",
"npm-version": "10.9.0",
"node-version": "22.12.0",
"npm-version": "11.0.0",
"os": "macos-15",
"sample": "app-websocket",
"sample-type": "jdl",
"samples-group": "ios",
},
{
"default-environment": "dev",
"docker-services": true,
"docker-services": "true",
"java-version": "17",
"job-name": "flickr2-jwt",
"jwt-secret-key": "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ=",
"node-version": "22.11.0",
"npm-version": "10.9.0",
"node-version": "22.12.0",
"npm-version": "11.0.0",
"os": "macos-15",
"sample": "flickr2-jwt",
"sample-type": "jdl",
Expand All @@ -81,8 +81,8 @@ exports[`generator - github-build-matrix > with samples > should match matrix va
"java-version": "17",
"job-name": "21points-jwt",
"jwt-secret-key": "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ=",
"node-version": "22.11.0",
"npm-version": "10.9.0",
"node-version": "22.12.0",
"npm-version": "11.0.0",
"os": "ubuntu-latest",
"sample": "21points-jwt",
"sample-type": "jdl",
Expand All @@ -93,8 +93,8 @@ exports[`generator - github-build-matrix > with samples > should match matrix va
"java-version": "17",
"job-name": "app-jwt",
"jwt-secret-key": "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ=",
"node-version": "22.11.0",
"npm-version": "10.9.0",
"node-version": "22.12.0",
"npm-version": "11.0.0",
"os": "ubuntu-latest",
"sample": "app-jwt",
"sample-type": "jdl",
Expand All @@ -105,8 +105,8 @@ exports[`generator - github-build-matrix > with samples > should match matrix va
"java-version": "17",
"job-name": "app-oauth2",
"jwt-secret-key": "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ=",
"node-version": "22.11.0",
"npm-version": "10.9.0",
"node-version": "22.12.0",
"npm-version": "11.0.0",
"os": "ubuntu-latest",
"sample": "app-oauth2",
"sample-type": "jdl",
Expand All @@ -117,8 +117,8 @@ exports[`generator - github-build-matrix > with samples > should match matrix va
"java-version": "17",
"job-name": "app-websocket",
"jwt-secret-key": "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ=",
"node-version": "22.11.0",
"npm-version": "10.9.0",
"node-version": "22.12.0",
"npm-version": "11.0.0",
"os": "ubuntu-latest",
"sample": "app-websocket",
"sample-type": "jdl",
Expand All @@ -129,8 +129,8 @@ exports[`generator - github-build-matrix > with samples > should match matrix va
"java-version": "17",
"job-name": "flickr2-jwt",
"jwt-secret-key": "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ=",
"node-version": "22.11.0",
"npm-version": "10.9.0",
"node-version": "22.12.0",
"npm-version": "11.0.0",
"os": "ubuntu-latest",
"sample": "flickr2-jwt",
"sample-type": "jdl",
Expand Down
2 changes: 1 addition & 1 deletion .blueprint/github-build-matrix/generator.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default class extends BaseGenerator {
get [BaseGenerator.WRITING]() {
return this.asWritingTaskGroup({
async buildMatrix() {
const { samplesGroup } = this;
const { samplesGroup = 'samples' } = this;
const templatePath = this.templatePath('../../generate-sample/templates/');
const samplesFolder = this.samplesFolder ? join(templatePath, this.samplesFolder) : templatePath;
const { samples, warnings } = await getGithubSamplesGroup(samplesFolder, samplesGroup);
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ jobs:
# if: matrix.default-environment == 'prod' && steps.compare.outputs.equals != 'true'
# timeout-minutes: 10
- run: npm run services:up
if: matrix.default-environment == 'prod' && steps.compare.outputs.equals != 'true' && matrix.docker-services != 'no'
if: matrix.default-environment == 'prod' && steps.compare.outputs.equals != 'true' && matrix.docker-services != 'false'
working-directory: ${{ github.workspace }}/backend

- run: npm install
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ Desktop.ini
######################
# Code coverage
######################
/coverage/
/.nyc_output/
coverage/
.nyc_output/

# added by generate-blueprint:
generators/**/package-lock.json
2 changes: 1 addition & 1 deletion .yo-rc.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
}
},
"githubWorkflows": true,
"jhipsterVersion": "8.7.3",
"jhipsterVersion": "8.8.0",
"js": false,
"localBlueprint": false,
"packageJsonType": "module",
Expand Down
Loading

0 comments on commit 70f3b4b

Please sign in to comment.