Skip to content

Commit

Permalink
modeled JSONGeneratorJhipsterContent
Browse files Browse the repository at this point in the history
  • Loading branch information
Tcharl committed May 16, 2024
1 parent 5796d22 commit 16c9e43
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"entities": ["Country", "Department", "Employee", "Job", "JobHistory", "Location", "Region", "Task"],
"generator-jhipster": {
"entities": ["Country", "Department", "Employee", "Job", "JobHistory", "Location", "Region", "Task"],
"promptValues": {
"packageName": "com.mycompany.myapp"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"entities": ["Country"],
"generator-jhipster": {
"entities": ["Country"],
"promptValues": {
"packageName": "com.mycompany.myapp"
},
Expand Down
6 changes: 5 additions & 1 deletion jdl/converters/json-to-jdl-converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@ function getJSONEntityFiles(applicationDirectory: string, yoRcFileContent: Parti
const entities: Map<string, JSONEntity> = new Map();
fs.readdirSync(path.join(applicationDirectory, '.jhipster')).forEach(file => {
const entityName = file.slice(0, file.indexOf('.json'));
if (!yoRcFileContent.entities?.includes(entityName)) {
if (
yoRcFileContent['generator-jhipster'] &&
yoRcFileContent['generator-jhipster']!.entities &&
!yoRcFileContent['generator-jhipster']!.entities!.includes(entityName)
) {
throw new Error(
`Mismatch identified between the application description amount of entity listed and the entity found in the .jhipster folder for entity name: ${entityName}`,
);
Expand Down
30 changes: 28 additions & 2 deletions jdl/converters/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,36 @@ export type JSONEntity = {
} & Record<string, any>;

export type JSONGeneratorJhipsterContent = {
applicationType: string;
baseName: string;
applicationType?: string;
entities?: string[];
jhipsterVersion?: string;
packageName?: string;
packageFolder?: string;
serverPort?: string;
authenticationType?: string;
buildTool?: string;
cacheProvider?: string;
clientPackageManager?: string;
creationTimestamp?: number;
databaseType?: string;
devDatabaseType?: string;
enableHibernateCache?: boolean;
enableTranslation?: boolean;
jhiPrefix?: string;
jwtSecretKey?: string;
languages?: string[];
messageBroker?: string;
nativeLanguage?: string;
prodDatabaseType?: string;
searchEngine?: string;
serviceDiscoveryType?: string;
skipClient?: boolean;
skipUserManagement?: boolean;
testFrameworks: string[];
websocket: string;
} & Record<string, any>;

export type JSONRootObject = {
entities: string[];
['generator-jhipster']: JSONGeneratorJhipsterContent;
};

0 comments on commit 16c9e43

Please sign in to comment.