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

add initial command integration to jdl #27152

Merged
merged 10 commits into from
Sep 5, 2024
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion generators/angular/support/needles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import type { Entity } from '../../base-application/index.js';
import type { BaseApplication, CommonClientServerApplication } from '../../base-application/types.js';
import { createNeedleCallback } from '../../base/support/needles.js';
import { upperFirstCamelCase } from '../../base/support/string.js';
import { upperFirstCamelCase } from '../../../lib/utils/string.js';
import { joinCallbacks } from '../../base/support/write-files.js';

export function addRoute({
Expand Down
2 changes: 1 addition & 1 deletion generators/app/support/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { camelCase, kebabCase, startCase, upperFirst } from 'lodash-es';
import { NODE_VERSION } from '../../generator-constants.js';
import { applicationTypes, authenticationTypes, databaseTypes, testFrameworkTypes } from '../../../jdl/index.js';
import { applicationTypes, authenticationTypes, databaseTypes, testFrameworkTypes } from '../../../jdl/jhipster/index.js';
import { getHipster, mutateData, pickFields, upperFirstCamelCase } from '../../base/support/index.js';
import { getDBTypeFromDBValue } from '../../server/support/index.js';
import detectLanguage from '../../languages/support/detect-language.js';
Expand Down
2 changes: 1 addition & 1 deletion generators/base-application/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import type { SpringBootSourceType } from '../server/types.js';
import type { ClientSourceType } from '../client/types.js';
import type { I18nApplication } from '../languages/types.js';
import type { JHipsterGeneratorFeatures, JHipsterGeneratorOptions } from '../base/api.js';
import { mutateData } from '../base/support/config.js';
import { mutateData } from '../../lib/utils/object.js';
import {
GENERATOR_BOOTSTRAP_APPLICATION,
GENERATOR_BOOTSTRAP_APPLICATION_BASE,
Expand Down
2 changes: 1 addition & 1 deletion generators/base-application/support/prepare-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { defaults, kebabCase, snakeCase, startCase, upperFirst } from 'lodash-es
import { fieldTypes, validations } from '../../../jdl/jhipster/index.js';
import { getTypescriptType, prepareField as prepareClientFieldForTemplates } from '../../client/support/index.js';
import { prepareField as prepareServerFieldForTemplates } from '../../server/support/index.js';
import { mutateData } from '../../base/support/config.js';
import { mutateData } from '../../../lib/utils/object.js';
import { fieldIsEnum } from './field-utils.js';
import { prepareProperty } from './prepare-property.js';

Expand Down
2 changes: 1 addition & 1 deletion generators/base-application/support/prepare-property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* limitations under the License.
*/
import { snakeCase, upperFirst } from 'lodash-es';
import { mutateData } from '../../base/support/config.js';
import { mutateData } from '../../../lib/utils/object.js';

export const prepareProperty = (property: any) => {
mutateData(property, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import pluralize from 'pluralize';

import { checkAndReturnRelationshipOnValue, databaseTypes, entityOptions, validations } from '../../../jdl/jhipster/index.js';
import { getJoinTableName, hibernateSnakeCase } from '../../server/support/index.js';
import { mutateData } from '../../base/support/config.js';
import { mutateData } from '../../../lib/utils/object.js';
import { stringifyApplicationData } from './debug.js';
import { prepareProperty } from './prepare-property.js';

Expand Down
2 changes: 1 addition & 1 deletion generators/base-core/generator-core.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { beforeEach, describe, it, expect as jestExpect } from 'esmocha';
import { basicHelpers as helpers } from '../../testing/index.js';

import { createJHipsterLogger } from '../base/support/logger.js';
import { createJHipsterLogger } from '../base/support/index.js';
import Base from './index.js';

const BaseGenerator: any = Base.prototype;
Expand Down
2 changes: 1 addition & 1 deletion generators/base-core/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ import { GENERATOR_JHIPSTER, YO_RC_FILE } from '../generator-constants.js';
import { loadConfig } from '../../lib/internal/index.js';
import { getGradleLibsVersionsProperties } from '../gradle/support/dependabot-gradle.js';
import { dockerPlaceholderGenerator } from '../docker/utils.js';
import { getConfigWithDefaults } from '../../jdl/index.js';
import { getConfigWithDefaults } from '../../jdl/jhipster/index.js';
import { extractArgumentsFromConfigs } from '../../lib/command/index.js';

const {
Expand Down
2 changes: 1 addition & 1 deletion generators/base-workspaces/internal/deployments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* limitations under the License.
*/
import { defaults } from 'lodash-es';
import { applicationOptions, deploymentOptions } from '../../../jdl/index.js';
import { applicationOptions, deploymentOptions } from '../../../jdl/jhipster/index.js';
import { loadDerivedPlatformConfig, loadDerivedServerAndPlatformProperties, loadPlatformConfig } from '../../server/support/index.js';
import type { GeneratorBaseCore } from '../../index.js';

Expand Down
2 changes: 1 addition & 1 deletion generators/base/support/hipster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { stringHashCode } from './string.js';
import { stringHashCode } from '../../../lib/utils/string.js';

/**
* get a hipster based on the applications name.
Expand Down
6 changes: 3 additions & 3 deletions generators/base/support/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
*/
export * from './basename.js';
export * from './configuration-helpers/options.js';
export * from './config.js';
export * from '../../../lib/utils/object.js';
export * from './contents.js';
export * from './faker.js';
export { default as getHipster } from './hipster.js';
export * from './jhipster7-context.js';
export * from './logger.js';
export * from '../../../lib/utils/logger.js';
export * from './namespace.js';
export * from './needles.js';
export * from './path.js';
export { default as httpsGet } from './remote.js';
export * from './secret.js';
export * from './string.js';
export * from '../../../lib/utils/string.js';
export * from './timestamp.js';
export * from './write-files.js';
4 changes: 2 additions & 2 deletions generators/base/support/jhipster7-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import {
} from '../../server/support/index.js';
import { getDBCExtraOption } from '../../spring-data-relational/support/database-data.js';
import { getJdbcUrl, getR2dbcUrl } from '../../spring-data-relational/support/database-url.js';
import { fieldTypes } from '../../../jdl/index.js';
import { upperFirstCamelCase } from './string.js';
import { fieldTypes } from '../../../jdl/jhipster/index.js';
import { upperFirstCamelCase } from '../../../lib/utils/string.js';

const { BYTES, BYTE_BUFFER } = fieldTypes.RelationalOnlyDBTypes;

Expand Down
5 changes: 3 additions & 2 deletions generators/bootstrap-application-base/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { GENERATOR_BOOTSTRAP, GENERATOR_COMMON, GENERATOR_PROJECT_NAME } from '.
import { packageJson } from '../../lib/index.js';
import { loadLanguagesConfig } from '../languages/support/index.js';
import { loadAppConfig, loadDerivedAppConfig, loadStoredAppOptions } from '../app/support/index.js';
import jdlDefinition from '../app/jdl/index.js';
import { createAuthorityEntity, createUserEntity, createUserManagementEntity } from './utils.js';
import { exportJDLTransform, importJDLTransform } from './support/index.js';

Expand Down Expand Up @@ -79,8 +80,8 @@ export default class BootstrapApplicationBase extends BaseApplicationGenerator {
const destinationPath = this.destinationPath();
const jdlStorePath = this.destinationPath(this.jhipsterConfig.jdlStore);

this.features.commitTransformFactory = () => exportJDLTransform({ destinationPath, jdlStorePath });
await this.pipeline({ refresh: true, pendingFiles: false }, importJDLTransform({ destinationPath, jdlStorePath }));
this.features.commitTransformFactory = () => exportJDLTransform({ destinationPath, jdlStorePath, jdlDefinition });
await this.pipeline({ refresh: true, pendingFiles: false }, importJDLTransform({ destinationPath, jdlStorePath, jdlDefinition }));
}
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,21 @@ import { setModifiedFileState } from 'mem-fs-editor/state';
import { GENERATOR_JHIPSTER } from '../../generator-constants.js';
import { getJDLObjectFromSingleApplication } from '../../../jdl/converters/json-to-jdl-converter.js';
import type { JSONEntity } from '../../../jdl/converters/types.js';
import { createRuntime } from '../../../jdl/runtime.js';
import type { JDLApplicationConfig } from '../../../jdl/types/types.js';

export const exportJDLTransform = ({
destinationPath,
jdlStorePath,
throwOnMissingConfig = true,
keepEntitiesConfig,
jdlDefinition,
}: {
destinationPath: string;
jdlStorePath: string;
throwOnMissingConfig?: boolean;
keepEntitiesConfig?: boolean;
jdlDefinition: JDLApplicationConfig;
}) =>
Duplex.from(async function* (files: AsyncGenerator<MemFsEditorFile>) {
const yoRcFilePath = join(destinationPath, '.yo-rc.json');
Expand Down Expand Up @@ -52,6 +56,8 @@ export const exportJDLTransform = ({
const jdlObject = getJDLObjectFromSingleApplication(
{ ...contents, [GENERATOR_JHIPSTER]: { ...rest, incrementalChangelog } },
entitiesMap,
undefined,
createRuntime(jdlDefinition),
);

const jdlContents = jdlObject.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,18 @@ 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 jhipsterDefinition from '../../../generators/app/jdl/index.js';
import { mergeYoRcContent } from '../../../lib/utils/yo-rc.js';
import type { JDLApplicationConfig } from '../../../jdl/types/types.js';

export const importJDLTransform = ({ destinationPath, jdlStorePath }: { destinationPath: string; jdlStorePath: string }) =>
export const importJDLTransform = ({
destinationPath,
jdlStorePath,
jdlDefinition,
}: {
destinationPath: string;
jdlStorePath: string;
jdlDefinition: JDLApplicationConfig;
}) =>
Duplex.from(async function* (files: AsyncGenerator<MemFsEditorFile>) {
const yoRcFilePath = join(destinationPath, '.yo-rc.json');
const entitiesFolder = join(destinationPath, '.jhipster');
Expand Down Expand Up @@ -45,7 +53,7 @@ export const importJDLTransform = ({ destinationPath, jdlStorePath }: { destinat
if (entityFields.length > 0) {
throw new Error('Entities configuration files are not supported by jdlStore');
}
const importer = createImporterFromContent(jdlStoreContents.toString(), undefined, jhipsterDefinition);
const importer = createImporterFromContent(jdlStoreContents.toString(), undefined, jdlDefinition);
const importState = importer.import();
const applicationWithEntities = Object.values(importState.exportedApplicationsWithEntities);
if (applicationWithEntities.length !== 1) {
Expand Down
8 changes: 6 additions & 2 deletions generators/client/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@
*/
import chalk from 'chalk';
import { intersection } from 'lodash-es';
import { testFrameworkTypes } from '../../jdl/jhipster/index.js';
import {
APPLICATION_TYPE_GATEWAY,
APPLICATION_TYPE_MICROSERVICE,
clientFrameworkTypes,
testFrameworkTypes,
} from '../../jdl/jhipster/index.js';
import type { JHipsterCommandDefinition } from '../../lib/command/index.js';
import { APPLICATION_TYPE_GATEWAY, APPLICATION_TYPE_MICROSERVICE, clientFrameworkTypes } from '../../jdl/index.js';
import { GENERATOR_COMMON } from '../generator-list.js';

const { CYPRESS } = testFrameworkTypes;
Expand Down
2 changes: 1 addition & 1 deletion generators/client/files-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { clientFrameworkTypes } from '../../jdl/index.js';
import { clientFrameworkTypes } from '../../jdl/jhipster/index.js';
import { clientRootTemplatesBlock, clientSrcTemplatesBlock } from './support/files.js';

const { ANGULAR, REACT, VUE } = clientFrameworkTypes;
Expand Down
5 changes: 3 additions & 2 deletions generators/export-jdl/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ import chalk from 'chalk';
import BaseGenerator from '../base/index.js';

import { applicationOptions } from '../../jdl/jhipster/index.js';
import JSONToJDLConverter from '../../jdl/converters/json-to-jdl-converter.js';
import { convertToJDL } from '../../jdl/converters/json-to-jdl-converter.js';
import type { JHipsterGeneratorFeatures, JHipsterGeneratorOptions } from '../base/api.js';
import jdlDefinition from '../app/jdl/index.js';

const { OptionNames } = applicationOptions;

Expand Down Expand Up @@ -50,7 +51,7 @@ export default class extends BaseGenerator {
return this.asDefaultTaskGroup({
convertToJDL() {
try {
const jdlObject = JSONToJDLConverter.convertToJDL(this.destinationPath(), false);
const jdlObject = convertToJDL(this.destinationPath(), false, jdlDefinition);
if (jdlObject) {
this.jdlContent = jdlObject.toString();
}
Expand Down
2 changes: 1 addition & 1 deletion generators/gradle/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import assert from 'assert/strict';
import BaseApplicationGenerator from '../base-application/index.js';

import { GRADLE_BUILD_SRC_DIR } from '../generator-constants.js';
import { mutateData } from '../base/support/config.js';
import { mutateData } from '../../lib/utils/object.js';
import { QUEUES } from '../base/priorities.js';
import files from './files.js';
import { GRADLE } from './constants.js';
Expand Down
2 changes: 1 addition & 1 deletion generators/java/generators/build-tool/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { buildToolTypes } from '../../../../jdl/index.js';
import { buildToolTypes } from '../../../../jdl/jhipster/index.js';
import { GENERATOR_GRADLE, GENERATOR_MAVEN } from '../../../generator-list.js';
import { asCommand } from '../../../type-utils.js';

Expand Down
2 changes: 1 addition & 1 deletion generators/java/generators/build-tool/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { buildToolTypes } from '../../../../jdl/index.js';
import { buildToolTypes } from '../../../../jdl/jhipster/index.js';
import BaseApplicationGenerator from '../../../base-application/index.js';
import { GENERATOR_GRADLE, GENERATOR_MAVEN } from '../../../generator-list.js';
import type { MavenDependency } from '../../../maven/types.js';
Expand Down
6 changes: 3 additions & 3 deletions generators/jdl/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ 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/utils/yo-rc.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';
import jdlDefinition from '../app/jdl/index.js';
import { addApplicationIndex, allNewApplications, customizeForMicroservices } from './internal/index.js';

/**
Expand Down Expand Up @@ -135,7 +135,7 @@ export default class JdlGenerator extends BaseGenerator {
skipUserManagement: this.options.skipUserManagement,
};

const importer = createImporterFromContent(this.jdlContents.join('\n'), configuration, jhipsterDefinition);
const importer = createImporterFromContent(this.jdlContents.join('\n'), configuration, jdlDefinition);

const importState = importer.import();

Expand Down
2 changes: 1 addition & 1 deletion generators/languages/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { updateLanguagesTask as updateLanguagesInJava } from '../server/support/
import { SERVER_MAIN_RES_DIR, SERVER_TEST_RES_DIR } from '../generator-constants.js';
import { QUEUES } from '../base-application/priorities.js';
import { PRIORITY_NAMES } from '../base/priorities.js';
import { clientFrameworkTypes } from '../../jdl/index.js';
import { clientFrameworkTypes } from '../../jdl/jhipster/index.js';
import { findLanguageForTag, supportedLanguages } from './support/languages.js';
import TranslationData, { createTranslationsFileFilter, createTranslationsFilter } from './translation-data.js';
import { writeEntityFiles } from './entity-files.js';
Expand Down
2 changes: 1 addition & 1 deletion generators/server/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import chalk from 'chalk';
import type { JHipsterCommandDefinition } from '../../lib/command/index.js';
import { GENERATOR_COMMON, GENERATOR_SPRING_BOOT } from '../generator-list.js';
import { APPLICATION_TYPE_GATEWAY, APPLICATION_TYPE_MICROSERVICE, APPLICATION_TYPE_MONOLITH } from '../../jdl/index.js';
import { APPLICATION_TYPE_GATEWAY, APPLICATION_TYPE_MICROSERVICE, APPLICATION_TYPE_MONOLITH } from '../../jdl/jhipster/index.js';

const command: JHipsterCommandDefinition = {
options: {
Expand Down
6 changes: 4 additions & 2 deletions generators/server/jdl/application-definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@ import { snakeCase, upperCase } from 'lodash-es';
import type { JDLApplicationConfig, JHipsterOptionDefinition } from '../../../jdl/types/types.js';
import databaseMigrationOption from '../options/database-migration.js';
import messageBrokerOption from '../options/message-broker.js';
import { feignClientDefinition, syncUserWithIdpDefinition } from '../options/index.js';
import { syncUserWithIdpDefinition } from '../options/index.js';
import { jdlRoutesOptions } from '../../spring-cloud/generators/gateway/jdl/jdl-routes-option.js';
import command from '../../spring-boot/command.js';
import { extractJdlDefinitionFromCommandConfig } from '../../../lib/command/index.js';

const jdlOptions: JHipsterOptionDefinition[] = [
databaseMigrationOption,
messageBrokerOption,
feignClientDefinition,
syncUserWithIdpDefinition,
jdlRoutesOptions,
...extractJdlDefinitionFromCommandConfig(command.configs),
];

const applicationConfig: JDLApplicationConfig = {
Expand Down
28 changes: 0 additions & 28 deletions generators/server/options/feign-client.ts

This file was deleted.

1 change: 0 additions & 1 deletion generators/server/options/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@

export * from './database-migration.js';
export * from './message-broker.js';
export * from './feign-client.js';
export * from './sync-user-with-idp.js';
2 changes: 1 addition & 1 deletion generators/server/support/prepare-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { snakeCase, upperFirst } from 'lodash-es';

import { databaseTypes, entityOptions, fieldTypes, reservedKeywords } from '../../../jdl/jhipster/index.js';
import { formatDocAsApiDescription, formatDocAsJavaDoc } from '../../java/support/doc.js';
import { mutateData } from '../../base/support/config.js';
import { mutateData } from '../../../lib/utils/object.js';
import { getUXConstraintName } from './database.js';
import { getJavaValueGeneratorForType } from './templates/field-values.js';

Expand Down
2 changes: 1 addition & 1 deletion generators/server/support/prepare-relationship.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { mutateData } from '../../base/support/config.js';
import { mutateData } from '../../../lib/utils/object.js';
import { formatDocAsApiDescription, formatDocAsJavaDoc } from '../../java/support/doc.js';

export function prepareRelationship({ relationship }: { relationship: any; entity: any }) {
Expand Down
2 changes: 1 addition & 1 deletion generators/server/support/relationship.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import type { JSONEntity } from '../../../jdl/converters/types.js';
import { addOtherRelationship } from '../../base-application/support/index.js';
import type { ValidationResult } from '../../base/api.js';
import { databaseTypes } from '../../../jdl/index.js';
import { databaseTypes } from '../../../jdl/jhipster/index.js';

const { NO: NO_DATABASE, SQL, NEO4J } = databaseTypes;

Expand Down
Loading
Loading