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 JHipster main #604

Merged
merged 82 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
255a753
Update .yo-resolve
mshima Jun 25, 2024
18aaeb8
Update generator-jhipster to 8.6.0
mshima Jun 25, 2024
ed1c4e6
Merge pull request #1 from mshima/generator-jhipster-8.6.0
mshima Nov 6, 2024
d67c84f
cleanup .yo-resolve
mshima Nov 6, 2024
5b5f81f
Update generator-jhipster to 8.7.3
mshima Nov 6, 2024
568a78a
Update cli/cli-customizations.cjs
mshima Nov 6, 2024
8b1d32a
recreate package-lock
mshima Nov 6, 2024
8df283b
adjusts
mshima Nov 6, 2024
03b2a7c
drop samples workflow
mshima Nov 6, 2024
a75762e
skip workflows files in .yo-resolve
mshima Nov 6, 2024
960de5d
samples adjusts
mshima Nov 6, 2024
0b0892a
prettier fix
mshima Nov 6, 2024
44232d2
Revert "drop samples workflow"
mshima Nov 6, 2024
a8d90d5
angular workflow adjusts
mshima Nov 6, 2024
840f427
fix angular workflow
mshima Nov 6, 2024
c6dd19c
fix angular workflow
mshima Nov 6, 2024
a9261ff
adjusts
mshima Nov 6, 2024
b067566
Update angular.js
mshima Nov 6, 2024
9a15aa9
Update generator.mjs
mshima Nov 6, 2024
f6e4d90
Update angular.js
mshima Nov 6, 2024
e51b6e8
Update test-integration-angular.yml
mshima Nov 6, 2024
e795d94
Update test-integration-react.yml
mshima Nov 6, 2024
0f14c42
Update test-integration-vue.yml
mshima Nov 6, 2024
1909746
Update test-integration-microservice.yml
mshima Nov 6, 2024
7453b3f
Update generator.mjs
mshima Nov 6, 2024
a878cca
Update angular.js
mshima Nov 6, 2024
c349e35
Update angular.js
mshima Nov 6, 2024
d9f5a5f
Update generator.mjs
mshima Nov 6, 2024
6410776
Update generator.mjs
mshima Nov 6, 2024
8439e79
fixes
mshima Nov 6, 2024
a9b4508
adjusts
mshima Nov 6, 2024
a0feb14
fixes
mshima Nov 6, 2024
fae5404
adjusts
mshima Nov 6, 2024
3089475
fix
mshima Nov 6, 2024
ce580bb
fixes
mshima Nov 6, 2024
6c4138c
fix
mshima Nov 6, 2024
3858144
build-matrix
mshima Nov 6, 2024
be95f02
update jhipster commit
mshima Nov 6, 2024
09d43bc
fixes
mshima Nov 7, 2024
8858200
Update test-integration-angular.yml
mshima Nov 7, 2024
f2b0d93
Update prepare-sample.js
mshima Nov 7, 2024
55f1e9a
Update package.json.ejs
mshima Nov 7, 2024
a5ff214
Update auth.service.ts.ejs
mshima Nov 7, 2024
f4ae881
Update generator.mjs
mshima Nov 7, 2024
682747e
Delete .github/workflows/samples.yml
mshima Nov 7, 2024
bcc29d6
Update generator.mjs
mshima Nov 7, 2024
0761424
Update generator.mjs
mshima Nov 7, 2024
69549d7
Update generator.mjs
mshima Nov 7, 2024
78663d0
generate-sample adjusts
mshima Nov 7, 2024
3e91d4c
update jhipster commit
mshima Nov 7, 2024
c1ae624
update snapshot
mshima Nov 7, 2024
1c98e1c
ci adjusts
mshima Nov 7, 2024
17a5097
ci adjusts
mshima Nov 7, 2024
9a312c5
ci adjusts
mshima Nov 7, 2024
fb4e102
migrate to eslint v9
mshima Nov 7, 2024
e1df513
fixes
mshima Nov 7, 2024
f84680d
fixes
mshima Nov 7, 2024
0c63430
add pretest script
mshima Nov 7, 2024
af1dfb7
add @eslint/js
mshima Nov 7, 2024
40cb1fb
ignore rules
mshima Nov 7, 2024
d776dea
eslint adjusts
mshima Nov 7, 2024
362e46c
Update eslint.config.mjs.ejs
mshima Nov 7, 2024
bdd14e3
ignore error
mshima Nov 8, 2024
48b104c
fix
mshima Nov 8, 2024
da15717
update workflows
mshima Nov 8, 2024
21c7668
Merge remote-tracking branch 'upstream/main' into generator-jhipster-…
mshima Nov 12, 2024
bc477e6
recreate package-lock
mshima Nov 12, 2024
f6bc3df
lint fix
mshima Nov 12, 2024
c835d20
improve entity cleanup
mshima Nov 12, 2024
4fe6fd7
revert old generate sample
mshima Nov 12, 2024
af11905
Update tsconfig.json.ejs
mshima Nov 12, 2024
e209be2
adjusts
mshima Nov 12, 2024
054c1db
matrix adjusts
mshima Nov 12, 2024
93627b6
adjusts
mshima Nov 12, 2024
b89e816
adjusts
mshima Nov 12, 2024
0ed280a
fix ci
mshima Nov 12, 2024
fc692b0
ci adjusts
mshima Nov 12, 2024
07f3bb2
fixes
mshima Nov 12, 2024
3e14840
fixes
mshima Nov 12, 2024
8b97122
fixes
mshima Nov 12, 2024
23b4d88
fixes
mshima Nov 12, 2024
8b46c89
add concurrency to workflows
mshima Nov 13, 2024
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
6 changes: 5 additions & 1 deletion .blueprint/cli/commands.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2013-2023 the original author or authors from the JHipster project.
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
* This file is part of the JHipster project, see https://www.jhipster.tech/
* for more information.
Expand All @@ -22,6 +22,10 @@ const defaultCommands = {
desc: 'Generate a test sample',
blueprint: '@jhipster/jhipster-dev',
},
'github-build-matrix': {
desc: 'Build a matrix of jobs for github actions',
blueprint: '@jhipster/jhipster-dev',
},
};

export default defaultCommands;
31 changes: 27 additions & 4 deletions .blueprint/generate-sample/command.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2013-2023 the original author or authors from the JHipster project.
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
* This file is part of the JHipster project, see https://www.jhipster.tech/
* for more information.
Expand All @@ -17,6 +17,8 @@
* limitations under the License.
*/
import { GENERATOR_APP } from 'generator-jhipster/generators';
import { getGithubSamplesGroups } from 'generator-jhipster/testing';

/**
* @type {import('generator-jhipster').JHipsterCommandDefinition}
*/
Expand All @@ -26,12 +28,33 @@ const command = {
type: String,
},
},
options: {
templateName: {
type: String,
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 () => getGithubSamplesGroups(gen.templatePath(gen.samplesFolder)),
}),
scope: 'generator',
},
all: {
description: 'Generate every sample in a workspace',
cli: {
type: Boolean,
},
scope: 'generator',
},
},
options: {},
import: [GENERATOR_APP],
};

Expand Down
151 changes: 71 additions & 80 deletions .blueprint/generate-sample/generator.mjs
Original file line number Diff line number Diff line change
@@ -1,85 +1,55 @@
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 { createNeedleCallback } from 'generator-jhipster/generators/base/support';
import command from './command.mjs';
import { getGithubSamplesGroup } from 'generator-jhipster/testing';

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

get [BaseGenerator.INITIALIZING]() {
return this.asInitializingTaskGroup({
async initializeOptions() {
this.parseJHipsterCommand(command);
},
});
}

get [BaseGenerator.PROMPTING]() {
return this.asPromptingTaskGroup({
async askForSample() {
if (!this.sampleName) {
const answers = await this.prompt({
type: 'list',
name: 'sampleName',
message: 'which sample do you want to generate?',
choices: async () => readdir(this.templatePath('samples')),
});
this.sampleName = answers.sampleName;
}
},
});
constructor(args, opts, features) {
super(args, opts, { ...features, queueCommandTasks: true, jhipsterBootstrap: false });
}

get [BaseGenerator.WRITING]() {
return this.asWritingTaskGroup({
async copySample() {
this.copyTemplate(`{.,}**`, '', {
fromBasePath: this.templatePath(`samples/${this.sampleName}`),
});

if (this.sampleName.includes('-template-')) {
if (!this.templateName) {
throw new Error('Template name is required');
}

const clientFrameworks = ['angular', 'vue', 'react'];
const authenticationTypes = ['jwt', 'oauth2'];
const databaseTypes = ['mysql', 'mssql', 'postgresql', 'mongodb'];

const split = this.templateName.split('-');

this._.intersection(clientFrameworks, split);
const clientFramework = this._.intersection(clientFrameworks, split)[0];
const authenticationType = this._.intersection(authenticationTypes, split)[0];
const databaseType = this._.intersection(databaseTypes, split)[0];

if (clientFramework) {
this.editFile(
`${this.sampleName}.jdl`,
createNeedleCallback({
needle: 'jhipster-needle-jdl-application-config',
contentToAdd: `clientFramework ${clientFramework}`,
}),
);
}
if (authenticationType) {
this.editFile(
`${this.sampleName}.jdl`,
createNeedleCallback({
needle: 'jhipster-needle-jdl-application-config',
contentToAdd: `authenticationType ${authenticationType}`,
}),
);
}
if (databaseType) {
this.editFile(
`${this.sampleName}.jdl`,
createNeedleCallback({
needle: 'jhipster-needle-jdl-application-config',
contentToAdd: `${databaseType === 'mongodb' ? 'databaseType' : 'prodDatabaseType'} ${databaseType}`,
}),
);
const { samplesFolder, all, sampleName } = this;
if (all) {
this.copyTemplate(`${samplesFolder}/*.jdl`, '');
this.sampleType = 'jdl';
} else if (extname(sampleName) === '.jdl') {
this.copyTemplate(join(samplesFolder, sampleName), sampleName, { noGlob: true });
this.sampleType = 'jdl';
} else {
const { samples } = await getGithubSamplesGroup(this.templatePath(), samplesFolder);
const {
'sample-type': sampleType,
'sample-file': sampleFile = sampleName,
'sample-folder': sampleFolder = samplesFolder,
generatorOptions,
} = samples[sampleName];
this.generatorOptions = generatorOptions;
this.sampleType = sampleType;
if (sampleType === 'jdl') {
const jdlFile = `${sampleFile}.jdl`;
this.copyTemplate(join(sampleFolder, jdlFile), jdlFile, { noGlob: true });
} else if (sampleType === 'yo-rc') {
this.copyTemplate('**', '', {
fromBasePath: this.templatePath(sampleFolder, sampleFile),
globOptions: { dot: true },
});
}
}
},
Expand All @@ -88,19 +58,40 @@ export default class extends BaseGenerator {

get [BaseGenerator.END]() {
return this.asEndTaskGroup({
async generateSample() {
const generator = this.sampleName.endsWith('-jdl') ? 'jdl' : 'app';
const generatorArgs = this.sampleName.endsWith('-jdl') ? [this.sampleName] : undefined;
await this.composeWithJHipster(generator, {
generatorArgs,
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: jdlFiles,
generatorOptions: {
skipJhipsterDependencies: true,
insight: false,
skipChecks: true,
skipInstall: true,
...generatorOptions,
...(this.all ? { workspaces: true, monorepository: true } : { skipInstall: true }),
},
});
},
async jhipsterInfo() {
await this.composeWithJHipster('info');
},
});
}

getDefaultComposeOptions() {
const packageJson = JSON.parse(readFileSync(new URL('../../package.json', import.meta.url)));
const projectVersion = `${packageJson.version}-git`;
return {
skipJhipsterDependencies: true,
projectVersion,
...this.generatorOptions,
};
}
}
67 changes: 67 additions & 0 deletions .blueprint/generate-sample/support/prepare-sample.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import assert from 'node:assert';
import { existsSync } from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { intersection } from 'lodash-es';

const __dirname = path.dirname(fileURLToPath(import.meta.url));

export const prepareSampleEntry = sampleData => {
const [sample, data = {}] = Array.isArray(sampleData) ? sampleData : [sampleData];
const clientFrameworks = ['angular', 'vue', 'react'];
const authenticationTypes = ['jwt', 'oauth2'];
const databaseTypes = ['mysql', 'mssql', 'postgresql', 'mongodb'];

let split = sample.split('-');
if (!split.includes('jdl')) {
assert(existsSync(path.join(__dirname, '../templates/samples', `${sample}`)), `The sample ${sample} does not exist.`);
return [
sample,
{
'sample-file': sample,
'legacy-template-name': sample,
'legacy-sample-file': sample,
'sample-folder': 'samples/',
'sample-type': 'yo-rc',
...data,
},
];
}

intersection(clientFrameworks, split);
const clientFramework = intersection(clientFrameworks, split)[0];
const authenticationType = intersection(authenticationTypes, split)[0];
const databaseType = intersection(databaseTypes, split)[0];
split = split
.filter(s => s !== 'jdl')
.map(s => (s === clientFramework ? 'client' : s === authenticationType ? 'auth' : s === databaseType ? 'database' : s));

const generatorOptions = {};

if (clientFramework) {
generatorOptions.clientFramework = clientFramework;
}
if (authenticationType) {
generatorOptions.authenticationType = authenticationType;
}
if (databaseType) {
generatorOptions.prodDatabaseType = databaseType;
}

const sampleFile = [...split, 'template', 'jdl'].join('-');
const file = path.join(__dirname, '../templates/samples', `${sampleFile}.jdl`);
assert(existsSync(file), `The sample ${file} does not exist.`);

return [
sample,
{
'sample-file': sampleFile,
'legacy-template-name': sample,
'legacy-sample-file': sampleFile,
'sample-folder': 'samples/',
'sample-type': 'jdl',
generatorOptions,
...data,
},
];
};
15 changes: 15 additions & 0 deletions .blueprint/generate-sample/templates/angular.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { prepareSampleEntry } from '../support/prepare-sample.js';

const samples = [
'monolith-angular-jwt-jdl',
'monolith-angular-jwt-i18n-jdl',
'monolith-angular-oauth2-jdl',
['monolith-angular-oauth2-mongodb-jdl', { 'legacy-sample-file': 'monolith-angular-auth-mongodb-template-jdl', e2e: 'false' }],
'monolith-angular-oauth2-i18n-jdl',
'monolith-angular-jwt-i18n-dev',
['monolith-angular-jwt-mongodb-jdl', { 'legacy-sample-file': 'monolith-client-auth-database-template-jdl', e2e: 'false' }],
'monolith-angular-mssql-prod-jdl',
'monolith-angular-postgresql-prod-jdl',
];

export default Object.fromEntries(samples.map(sample => prepareSampleEntry(sample)));
6 changes: 6 additions & 0 deletions .blueprint/generate-sample/templates/microservice.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
'microservice-oauth2-jdl': {
'sample-folder': 'samples/',
'sample-type': 'jdl',
},
};
13 changes: 13 additions & 0 deletions .blueprint/generate-sample/templates/react.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { prepareSampleEntry } from '../support/prepare-sample.js';

const samples = [
'monolith-react-jwt-jdl',
'monolith-react-jwt-i18n-jdl',
'monolith-react-oauth2-jdl',
'monolith-react-oauth2-i18n-jdl',
'monolith-react-mysql-prod-jdl',
['monolith-react-mongodb-prod-jdl', { 'legacy-sample-file': 'monolith-client-database-prod-template-jdl', e2e: 'false' }],
'monolith-react-oauth2-dev',
];

export default Object.fromEntries(samples.map(sample => prepareSampleEntry(sample)));
Loading
Loading