Skip to content

Commit

Permalink
move mergeYoRcContent to lib
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Sep 5, 2024
1 parent b14c5b8 commit 32502fd
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Minimatch } from 'minimatch';
import { upperFirst } from 'lodash-es';
import { GENERATOR_JHIPSTER } from '../../generator-constants.js';
import { createImporterFromContent } from '../../../jdl/jdl-importer.js';
import { mergeYoRcContent } from '../../../jdl/index.js';
import { mergeYoRcContent } from '../../../lib/yo-rc/config.js';
import jhipsterDefinition from '../../../generators/app/jdl/index.js';

export const importJDLTransform = ({ destinationPath, jdlStorePath }: { destinationPath: string; jdlStorePath: string }) =>
Expand Down
2 changes: 1 addition & 1 deletion generators/jdl/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { GENERATOR_APP, GENERATOR_ENTITIES, GENERATOR_WORKSPACES } from '../gene
import type { ApplicationWithEntities } from '../../jdl/jdl-importer.js';
import { createImporterFromContent } from '../../jdl/jdl-importer.js';
import { GENERATOR_JHIPSTER, JHIPSTER_CONFIG_DIR } from '../generator-constants.js';
import { mergeYoRcContent } from '../../jdl/index.js';
import { mergeYoRcContent } from '../../lib/yo-rc/config.js';
import { normalizeBlueprintName } from '../base/internal/blueprint.js';
import { updateApplicationEntitiesTransform } from '../base-application/support/update-application-entities-transform.js';
import jhipsterDefinition from '../../generators/app/jdl/index.js';
Expand Down
14 changes: 0 additions & 14 deletions jdl/exporters/config.ts

This file was deleted.

2 changes: 1 addition & 1 deletion jdl/exporters/export-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import fs from 'fs';
import { doesFileExist } from '../utils/file-utils.js';
import type { JHipsterYoRcContent } from '../converters/types.js';
import { mergeYoRcContent } from './config.js';
import { mergeYoRcContent } from '../../lib/yo-rc/config.js';

export const GENERATOR_NAME = 'generator-jhipster';

Expand Down
2 changes: 1 addition & 1 deletion jdl/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './jdl-importer.js';
export * from './parsing/api.js';
export * from './jhipster/index.js';
export * from './exporters/config.js';
export * from '../lib/yo-rc/config.js';
14 changes: 14 additions & 0 deletions lib/yo-rc/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
type YoRcContent = Record<typeof YO_RC_CONFIG_KEY, any>;

export const YO_RC_CONFIG_KEY = 'generator-jhipster' as const;

export const mergeYoRcContent = (oldConfig: YoRcContent, newConfig: YoRcContent): YoRcContent => {
const merged: YoRcContent = { [YO_RC_CONFIG_KEY]: {} };
for (const ns of new Set([...Object.keys(oldConfig), ...Object.keys(newConfig)])) {
merged[ns] = { ...oldConfig[ns], ...newConfig[ns] };
}
if (oldConfig[YO_RC_CONFIG_KEY]?.creationTimestamp) {
merged[YO_RC_CONFIG_KEY]!.creationTimestamp = oldConfig[YO_RC_CONFIG_KEY].creationTimestamp;
}
return merged;
};

0 comments on commit 32502fd

Please sign in to comment.