generators/entity/prompts.js
function logFieldsAndRelationships() {
    const context = this.context;
    if (context.fields.length > 0 || context.relationships.length > 0) {
        this.log(chalk.red(chalk.white('\n================= ') + context.entityNameCapitalized + chalk.white(' =================')));
    }
    if (context.fields.length > 0) {
        this.log(chalk.white('Fields'));
        context.fields.forEach(field => {
            const validationDetails = [];
            const fieldValidate = _.isArray(field.fieldValidateRules) && field.fieldValidateRules.length >= 1;
            if (fieldValidate === true) {
                if (field.fieldValidateRules.includes('required')) {
                    validationDetails.push('required');
                }
                if (field.fieldValidateRules.includes('unique')) {
                    validationDetails.push('unique');
                }
                if (field.fieldValidateRules.includes('minlength')) {
                    validationDetails.push(`minlength='${field.fieldValidateRulesMinlength}'`);
                }
                if (field.fieldValidateRules.includes('maxlength')) {
                    validationDetails.push(`maxlength='${field.fieldValidateRulesMaxlength}'`);
                }
                if (field.fieldValidateRules.includes('pattern')) {
                    validationDetails.push(`pattern='${field.fieldValidateRulesPattern}'`);
                }
                if (field.fieldValidateRules.includes('min')) {
                    validationDetails.push(`min='${field.fieldValidateRulesMin}'`);
                }
                if (field.fieldValidateRules.includes('max')) {
                    validationDetails.push(`max='${field.fieldValidateRulesMax}'`);
                }
                if (field.fieldValidateRules.includes('minbytes')) {
                    validationDetails.push(`minbytes='${field.fieldValidateRulesMinbytes}'`);
                }
                if (field.fieldValidateRules.includes('maxbytes')) {
                    validationDetails.push(`maxbytes='${field.fieldValidateRulesMaxbytes}'`);
                }
            }
            this.log(
                chalk.red(field.fieldName) +
                    chalk.white(` (${field.fieldType}${field.fieldTypeBlobContent ? ` ${field.fieldTypeBlobContent}` : ''}) `) +
                    chalk.cyan(validationDetails.join(' '))
            );
        });
        this.log();
    }
    if (context.relationships.length > 0) {
        this.log(chalk.white('Relationships'));
        context.relationships.forEach(relationship => {
            const validationDetails = [];
            if (relationship.relationshipValidateRules && relationship.relationshipValidateRules.includes('required')) {
                validationDetails.push('required');
            }
            this.log(
                `${chalk.red(relationship.relationshipName)} ${chalk.white(`(${_.upperFirst(relationship.otherEntityName)})`)} ${chalk.cyan(
                    relationship.relationshipType
                )} ${chalk.cyan(validationDetails.join(' '))}`
            );
        });
        this.log();
    }
}
function logFieldsAndRelationships() {
    const context = this.context;
    if (context.fields.length > 0 || context.relationships.length > 0) {
        this.log(chalk.red(chalk.white('\n================= ') + context.entityNameCapitalized + chalk.white(' =================')));
    }
    if (context.fields.length > 0) {
        this.log(chalk.white('Fields'));
        context.fields.forEach(field => {
            const validationDetails = [];
            const fieldValidate = _.isArray(field.fieldValidateRules) && field.fieldValidateRules.length >= 1;
            if (fieldValidate === true) {
                if (field.fieldValidateRules.includes('required')) {
                    validationDetails.push('required');
                }
                if (field.fieldValidateRules.includes('unique')) {
                    validationDetails.push('unique');
                }
                if (field.fieldValidateRules.includes('minlength')) {
                    validationDetails.push(`minlength='${field.fieldValidateRulesMinlength}'`);
                }
                if (field.fieldValidateRules.includes('maxlength')) {
                    validationDetails.push(`maxlength='${field.fieldValidateRulesMaxlength}'`);
                }
                if (field.fieldValidateRules.includes('pattern')) {
                    validationDetails.push(`pattern='${field.fieldValidateRulesPattern}'`);
                }
                if (field.fieldValidateRules.includes('min')) {
                    validationDetails.push(`min='${field.fieldValidateRulesMin}'`);
                }
                if (field.fieldValidateRules.includes('max')) {
                    validationDetails.push(`max='${field.fieldValidateRulesMax}'`);
                }
                if (field.fieldValidateRules.includes('minbytes')) {
                    validationDetails.push(`minbytes='${field.fieldValidateRulesMinbytes}'`);
                }
                if (field.fieldValidateRules.includes('maxbytes')) {
                    validationDetails.push(`maxbytes='${field.fieldValidateRulesMaxbytes}'`);
                }
            }
            this.log(
                chalk.red(field.fieldName) +
                    chalk.white(` (${field.fieldType}${field.fieldTypeBlobContent ? ` ${field.fieldTypeBlobContent}` : ''}) `) +
                    chalk.cyan(validationDetails.join(' '))
            );
        });
        this.log();
    }
    if (context.relationships.length > 0) {
        this.log(chalk.white('Relationships'));
        context.relationships.forEach(relationship => {
            const validationDetails = [];
            if (relationship.relationshipValidateRules && relationship.relationshipValidateRules.includes('required')) {
                validationDetails.push('required');
            }
            this.log(
                `${chalk.red(relationship.relationshipName)} ${chalk.white(`(${_.upperFirst(relationship.otherEntityName)})`)} ${chalk.cyan(
                    relationship.relationshipType
                )} ${chalk.cyan(validationDetails.join(' '))}`
            );
        });
        this.log();
    }
}
function logFieldsAndRelationships ( ) { const context = this . context ; if ( context . fields . length > 0 || context . relationships . length > 0 ) { this . log ( chalk . red ( chalk . white ( '\n================= ' ) + context . entityNameCapitalized + chalk . white ( ' =================' ) ) ) ; } if ( context . fields . length > 0 ) { this . log ( chalk . white ( 'Fields' ) ) ; context . fields . forEach ( field => { const validationDetails = [ ] ; const fieldValidate = _ . isArray ( field . fieldValidateRules ) && field . fieldValidateRules . length >= 1 ; if ( fieldValidate === true ) { if ( field . fieldValidateRules . includes ( 'required' ) ) { validationDetails . push ( 'required' ) ; } if ( field . fieldValidateRules . includes ( 'unique' ) ) { validationDetails . push ( 'unique' ) ; } if ( field . fieldValidateRules . includes ( 'minlength' ) ) { validationDetails . push ( ` ${ field . fieldValidateRulesMinlength } ` ) ; } if ( field . fieldValidateRules . includes ( 'maxlength' ) ) { validationDetails . push ( ` ${ field . fieldValidateRulesMaxlength } ` ) ; } if ( field . fieldValidateRules . includes ( 'pattern' ) ) { validationDetails . push ( ` ${ field . fieldValidateRulesPattern } ` ) ; } if ( field . fieldValidateRules . includes ( 'min' ) ) { validationDetails . push ( ` ${ field . fieldValidateRulesMin } ` ) ; } if ( field . fieldValidateRules . includes ( 'max' ) ) { validationDetails . push ( ` ${ field . fieldValidateRulesMax } ` ) ; } if ( field . fieldValidateRules . includes ( 'minbytes' ) ) { validationDetails . push ( ` ${ field . fieldValidateRulesMinbytes } ` ) ; } if ( field . fieldValidateRules . includes ( 'maxbytes' ) ) { validationDetails . push ( ` ${ field . fieldValidateRulesMaxbytes } ` ) ; } } this . log ( chalk . red ( field . fieldName ) + chalk . white ( ` ${ field . fieldType } ${ field . fieldTypeBlobContent ? ` ${ field . fieldTypeBlobContent } ` : '' } ` ) + chalk . cyan ( validationDetails . join ( ' ' ) ) ) ; } ) ; this . log ( ) ; } if ( context . relationships . length > 0 ) { this . log ( chalk . white ( 'Relationships' ) ) ; context . relationships . forEach ( relationship => { const validationDetails = [ ] ; if ( relationship . relationshipValidateRules && relationship . relationshipValidateRules . includes ( 'required' ) ) { validationDetails . push ( 'required' ) ; } this . log ( ` ${ chalk . red ( relationship . relationshipName ) } ${ chalk . white ( ` ${ _ . upperFirst ( relationship . otherEntityName ) } ` ) } ${ chalk . cyan ( relationship . relationshipType ) } ${ chalk . cyan ( validationDetails . join ( ' ' ) ) } ` ) ; } ) ; this . log ( ) ; } }
Show the entity and it's fields and relationships in console
Show the entity and it s fields and relationships in console