Skip to content

Commit

Permalink
Merge pull request #23010 from mshima/skip_ci-fix-export
Browse files Browse the repository at this point in the history
fix export jdl with nullish configs
  • Loading branch information
DanielFran authored Jul 30, 2023
2 parents f6ecaf6 + 104ec77 commit 8ebc568
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
10 changes: 10 additions & 0 deletions jdl/converters/json-to-jdl-converter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,5 +369,15 @@ describe('jdl - JSONToJDLConverter', () => {
jestExpect(jdl).toMatch(/microfrontends \[foo, bar\]/);
});
});
context('with nullish attributes', () => {
it('should not fail', () => {
convertSingleContentToJDL({
'generator-jhipster': {
blueprints: null,
microfrontends: undefined,
},
});
});
});
});
});
16 changes: 10 additions & 6 deletions jdl/converters/json-to-jdl-converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import { convertApplicationToJDL } from './json-to-jdl-application-converter.js'
import { convertEntitiesToJDL } from './json-to-jdl-entity-converter.js';
import exportJDLObject from '../exporters/jdl-exporter.js';
import { Entity } from './types.js';
import { removeFieldsWithNullishValues } from '../../generators/base/support/config.mjs';
import { GENERATOR_JHIPSTER } from '../../generators/generator-constants.mjs';

export default {
convertToJDL,
Expand Down Expand Up @@ -101,13 +103,15 @@ function getJDLObjectFromSingleApplication(
}

function cleanYoRcFileContent(yoRcFileContent) {
const [generatorName] = Object.keys(yoRcFileContent);
delete yoRcFileContent[generatorName].promptValues;
if (yoRcFileContent[generatorName].blueprints) {
yoRcFileContent[generatorName].blueprints = yoRcFileContent[generatorName].blueprints.map(blueprint => blueprint.name);
for (const key of Object.keys(yoRcFileContent)) {
yoRcFileContent[key] = removeFieldsWithNullishValues(yoRcFileContent[key]);
}
if (yoRcFileContent[generatorName].microfrontends) {
yoRcFileContent[generatorName].microfrontends = yoRcFileContent[generatorName].microfrontends.map(({ baseName }) => baseName);
delete yoRcFileContent[GENERATOR_JHIPSTER].promptValues;
if (yoRcFileContent[GENERATOR_JHIPSTER].blueprints) {
yoRcFileContent[GENERATOR_JHIPSTER].blueprints = yoRcFileContent[GENERATOR_JHIPSTER].blueprints.map(blueprint => blueprint.name);
}
if (yoRcFileContent[GENERATOR_JHIPSTER].microfrontends) {
yoRcFileContent[GENERATOR_JHIPSTER].microfrontends = yoRcFileContent[GENERATOR_JHIPSTER].microfrontends.map(({ baseName }) => baseName);
}
return yoRcFileContent;
}
Expand Down

0 comments on commit 8ebc568

Please sign in to comment.