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

Jhipster 8 #1389

Merged
merged 10 commits into from
Nov 25, 2023
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
25 changes: 8 additions & 17 deletions generators/client/files-vue.js → .blueprint/cli/commands.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -17,20 +17,11 @@
* limitations under the License.
*/

const constants = require('../generator-dotnetcore-constants.cjs');

/* Constants use throughout */
const SERVER_SRC_DIR = constants.SERVER_SRC_DIR;


function updateHomeTitle() {
this.replaceContent(`${SERVER_SRC_DIR}${this.mainClientAppDir}/app/core/home/home.vue`, 'Java', '.Net Core', false);
}

function writeFiles() {
updateHomeTitle.call(this);
}

module.exports = {
writeFiles,
const defaultCommands = {
'generate-sample': {
desc: 'Generate a test sample',
blueprint: '@jhipster/jhipster-dev',
},
};

export default defaultCommands;
42 changes: 42 additions & 0 deletions .blueprint/generate-sample/command.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* Copyright 2013-2023 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.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { GENERATOR_APP } from 'generator-jhipster/generators';
/**
* @type {import('generator-jhipster').JHipsterCommandDefinition}
*/
const command = {
arguments: {
sampleName: {
type: String,
},
},
options: {
withEntities: {
type: Boolean,
scope: 'generator',
},
configOnly: {
type: Boolean,
scope: 'generator',
},
},
import: [GENERATOR_APP],
};

export default command;
109 changes: 109 additions & 0 deletions .blueprint/generate-sample/generator.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import { readdir, stat } from 'node:fs/promises';
import BaseGenerator from 'generator-jhipster/generators/base';
import command from './command.mjs';
import { statSync } from 'node:fs';

export default class extends BaseGenerator {
sampleName;
jdlSample;
withEntities;
configOnly;

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;
}
},
});
}

get [BaseGenerator.WRITING]() {
return this.asWritingTaskGroup({
async copySample() {
let isDir = false;
let jdlFile = false;
try {
const pathStat = await stat(this.templatePath(`samples/${this.sampleName}`));
isDir = pathStat.isDirectory();
jdlFile = pathStat.isFile();
} catch (error) {
try {
this.sampleName += '.jdl';
jdlFile = (await stat(this.templatePath(`samples/${this.sampleName}`))).isFile();
} catch {
throw error;
}
}

if (jdlFile) {
this.jdlSample = this.sampleName;
this.copyTemplate(`samples/${this.sampleName}`, this.sampleName, { noGlob: true });
} else if (isDir) {
this.copyTemplate(`samples/${this.sampleName}/.yo-rc.json`, '.yo-rc.json', { noGlob: true });
} else {
throw new Error(`Sample ${this.sampleName} was not identified`);
}
},
async jdlEntities() {
if (this.withEntities) {
if (this.sampleName.includes('-mongo-')) {
this.jdlSample = 'app_mongo.jdl';
} else if (this.sampleName.includes('-react-')) {
this.jdlSample = 'app-react.jdl';
} else {
this.jdlSample = 'app.jdl';
}
this.copyTemplate(`samples/jdl-default/${this.jdlSample}`, this.jdlSample, { noGlob: true });
}
},
});
}

get [BaseGenerator.END]() {
return this.asEndTaskGroup({
async generateSample() {
if (this.jdlSample && !this.configOnly) {
await this.composeWithJHipster('jdl', {
generatorArgs: [this.jdlSample],
generatorOptions: {
jsonOnly: true,
},
});
}
},
async generateApp() {
if (this.configOnly) {
return;
}

await this.composeWithJHipster('app', {
generatorOptions: {
skipJhipsterDependencies: true,
insight: false,
skipChecks: true,
skipInstall: true,
},
});
},
async jhipsterInfo() {
await this.composeWithJHipster('info');
},
});
}
}
2 changes: 2 additions & 0 deletions .blueprint/generate-sample/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default } from './generator.mjs';
export { default as command } from './command.mjs';
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,9 @@
"jhiPrefix": "jhi",
"entitySuffix": "",
"dtoSuffix": "DTO",
"otherModules": [
{
"name": "generator-jhipster-dotnetcore",
"version": "3.9.1"
}
],
"blueprints": [
{
"name": "generator-jhipster-dotnetcore",
"version": "2.0.0"
"name": "generator-jhipster-dotnetcore"
}
]
},
Expand Down
117 changes: 117 additions & 0 deletions .blueprint/generate-sample/templates/samples/jdl-default/app-react.jdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
entity Region {
regionName String
}

entity Country {
countryName String
}

// an ignored comment
/** not an ignored comment */
entity Location {
streetAddress String,
postalCode String,
city String,
stateProvince String
}

entity Department {
departmentName String required
}

/**
* PieceOfWork entity.
* @author The JHipster team.
*/
entity PieceOfWork {
title String,
description String
}

/**
* The Employee entity.
*/
entity Employee {
/**
* The firstname attribute.
*/
firstName String,
lastName String,
email String,
phoneNumber String,
hireDate Instant,
salary Long,
commissionPct Long
}

entity Job {
jobTitle String,
minSalary Long,
maxSalary Long
}

entity JobHistory {
startDate Instant,
endDate Instant,
language Language
}

enum Language {
FRENCH, ENGLISH, SPANISH
}



relationship OneToOne {
Country{region} to Region
}

relationship OneToOne {
Location{country} to Country
}

relationship OneToOne {
Department{location} to Location
}

// defining multiple OneToMany relationships with comments
relationship OneToMany {
Employee to Job{employee},
/**
* A relationship
*/
Department to
/**
* Another side of the same relationship
*/
Employee{department}
}

relationship ManyToOne {
Employee{manager} to Employee
}

// defining multiple oneToOne relationships
relationship OneToOne {
JobHistory{job} to Job,
JobHistory{department} to Department,
JobHistory{employee} to Employee
}

relationship ManyToMany {
Job{chore(title)} to PieceOfWork{job}
}

// Set pagination options
// .Net does not generates link header for pagination.
// paginate JobHistory, Employee with infinite-scroll
// paginate Job with pagination

// Use Data Transfert Objects (DTO)
dto * with mapstruct

// Set service options to all except few
service all with serviceImpl except Employee, Job

// Set an angular suffix
// angularSuffix * with mySuffix
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,9 @@
"entitySuffix": "",
"dtoSuffix": "DTO",
"testFrameworks": ["cypress"],
"otherModules": [
{
"name": "generator-jhipster-dotnetcore",
"version": "3.9.1"
}
],
"blueprints": [
{
"name": "generator-jhipster-dotnetcore",
"version": "2.0.0"
"name": "generator-jhipster-dotnetcore"
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
"packageName": "JhipsterSampleApplication",
"authenticationType": "jwt",
"serverPort": "5000",
"databaseType": "postgres",
"databaseType": "sqllite",
"prodDatabaseType": "mysql",
"cqrsEnabled": true,
"enableTranslation": false,
"namespace": "JhipsterSampleApplication",
"jhipsterVersion": "7.9.3",
Expand All @@ -19,16 +20,9 @@
"entitySuffix": "",
"dtoSuffix": "DTO",
"testFrameworks": ["cypress"],
"otherModules": [
{
"name": "generator-jhipster-dotnetcore",
"version": "3.9.1"
}
],
"blueprints": [
{
"name": "generator-jhipster-dotnetcore",
"version": "2.0.0"
"name": "generator-jhipster-dotnetcore"
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,9 @@
"jhiPrefix": "jhi",
"entitySuffix": "",
"dtoSuffix": "DTO",
"otherModules": [
{
"name": "generator-jhipster-dotnetcore",
"version": "3.9.1"
}
],
"blueprints": [
{
"name": "generator-jhipster-dotnetcore",
"version": "2.0.0"
"name": "generator-jhipster-dotnetcore"
}
]
},
Expand Down
Loading
Loading