/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/generator-jhipster-grpc@0.22.0/generators/app/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
const chalk=require("chalk"),packagejs=require("../../package.json"),semver=require("semver"),BaseGenerator=require("generator-jhipster/generators/generator-base"),jhipsterConstants=require("generator-jhipster/generators/generator-constants");module.exports=class extends BaseGenerator{get initializing(){return{init(){this.option("all-entities",{desc:"Apply grpc to all entities",type:Boolean,defaults:!1})},readConfig(){this.jhipsterAppConfig=this.getAllJhipsterConfig(),this.jhipsterAppConfig||this.error("Can't read .yo-rc.json")},displayLogo:function(){this.log("Welcome to the "+chalk.red("JHipster grpc")+" generator! "+chalk.yellow("v"+packagejs.version+"\n"))},checkJhipster(){const e=this.jhipsterAppConfig.jhipsterVersion,t=packagejs.dependencies["generator-jhipster"];semver.satisfies(e,t)||this.warning(`\nYour generated project used an old JHipster version (${e})... you need at least (${t})\n`)},checkAuthentication(){"oauth2"===this.jhipsterAppConfig.authenticationType&&(this.log(chalk.red("OIDC/Oauth authentication is not supported at the moment")),this.abort=!0)}}}prompting(){if(this.abort)return;if(this.entities=[],this.existingEntitiesNames=this.getExistingEntities().filter((e=>"serviceClass"===e.definition.service||"serviceImpl"===e.definition.service)).map((e=>e.name)),0===this.existingEntitiesNames.length)return void this.log(chalk.yellow("No existing entities with a service layer found."));if(this.options.allEntities)return void(this.entities=this.existingEntitiesNames);const e=this.async(),t=[{type:"checkbox",name:"entities",message:"Select existing entities for which you want to add gRPC endpoints",choices:this.existingEntitiesNames}];this.prompt(t).then((t=>{this.entities=t.entities,e()}))}get writing(){return{writeCommonFiles(){if(this.abort)return;this.template=function(e,t){this.fs.copyTpl(this.templatePath(e),this.destinationPath(t),this)},this.addCompileDependency=function(e,t,i,a){"gradle"===a?this.addGradleDependency("implementation",e,t,i):this.addMavenDependency(e,t,i)},this.baseName=this.jhipsterAppConfig.baseName,this.mainClass=this.getMainClassName(),this.packageFolder=this.jhipsterAppConfig.packageFolder,this.packageName=this.jhipsterAppConfig.packageName,this.applicationType=this.jhipsterAppConfig.applicationType,this.authenticationType=this.jhipsterAppConfig.authenticationType,this.databaseType=this.jhipsterAppConfig.databaseType,this.searchEngine=this.jhipsterAppConfig.searchEngine,this.skipUserManagement=this.jhipsterAppConfig.skipUserManagement,"gateway"===this.applicationType&&"uaa"===this.authenticationType&&(this.skipUserManagement=!0),this.buildTool=this.jhipsterAppConfig.buildTool,this.cacheManagerIsAvailable=["ehcache","caffeine","hazelcast","infinispan","memcached","redis"].includes(this.jhipsterAppConfig.cacheProvider)||"gateway"===this.applicationType,this.cacheProvider=this.jhipsterAppConfig.cacheProvider||this.jhipsterAppConfig.hibernateCache||"no",this.messageBroker=this.jhipsterAppConfig.messageBroker;const e=`${jhipsterConstants.SERVER_MAIN_SRC_DIR+this.packageFolder}/`,t=`${jhipsterConstants.SERVER_TEST_SRC_DIR+this.packageFolder}/`,i=jhipsterConstants.MAIN_DIR+"proto/",a=i+this.packageFolder+"/";"sql"===this.databaseType&&"oauth2"!==this.authenticationType?(this.idProtoType="int64",this.idProtoWrappedType="Int64Value"):(this.idProtoType="string",this.idProtoWrappedType="StringValue"),this.template("_date.proto",i+"util/date.proto"),this.template("_decimal.proto",i+"util/decimal.proto"),this.template("_pagination.proto",i+"util/pagination.proto"),this.template("_queryfilters.proto",i+"util/queryfilters.proto"),this.template("_AuthenticationInterceptor.java",e+"grpc/AuthenticationInterceptor.java"),this.template("_AuthenticationInterceptorIntTest.java",t+"grpc/AuthenticationInterceptorIntTest.java"),this.template("_ProtobufMappers.java",e+"grpc/ProtobufMappers.java"),this.template("_configprops.proto",a+"configprops.proto"),this.template("_ConfigurationPropertiesReportService.java",e+"grpc/ConfigurationPropertiesReportService.java"),this.template("_ConfigurationPropertiesReportServiceIntTest.java",t+"grpc/ConfigurationPropertiesReportServiceIntTest.java"),this.template("_environment.proto",a+"environment.proto"),this.template("_EnvironmentService.java",e+"grpc/EnvironmentService.java"),this.template("_EnvironmentServiceIntTest.java",t+"grpc/EnvironmentServiceIntTest.java"),this.template("_health.proto",a+"health.proto"),this.template("_HealthService.java",e+"grpc/HealthService.java"),this.template("_HealthServiceIntTest.java",t+"grpc/HealthServiceIntTest.java"),this.template("_loggers.proto",a+"loggers.proto"),this.template("_LoggersService.java",e+"grpc/LoggersService.java"),this.template("_LoggersServiceIntTest.java",t+"grpc/LoggersServiceIntTest.java"),this.template("_info.proto",a+"info.proto"),this.template("_InfoService.java",e+"grpc/InfoService.java"),this.template("_InfoServiceIntTest.java",t+"grpc/InfoServiceIntTest.java"),this.grpcVersion="1.25.0",this.protocVersion="3.9.0",this.reactiveGrpcVersion="1.0.0",this.addCompileDependency("io.github.lognet","grpc-spring-boot-starter","3.5.0",this.buildTool),this.addCompileDependency("com.google.protobuf","protobuf-java",this.protocVersion,this.buildTool),this.addCompileDependency("io.grpc","grpc-protobuf",this.grpcVersion,this.buildTool),this.addCompileDependency("io.grpc","grpc-stub",this.grpcVersion,this.buildTool),this.addCompileDependency("com.salesforce.servicelibs","reactor-grpc-stub",this.reactiveGrpcVersion,this.buildTool),"maven"===this.buildTool?(this.addMavenPlugin("org.xolstice.maven.plugins","protobuf-maven-plugin","0.5.0","                <configuration>\n                    <protocArtifact>com.google.protobuf:protoc:"+this.protocVersion+":exe:${os.detected.classifier}</protocArtifact>\n                    <pluginId>grpc-java</pluginId>\n                    <pluginArtifact>io.grpc:protoc-gen-grpc-java:"+this.grpcVersion+":exe:${os.detected.classifier}</pluginArtifact>\n                </configuration>\n                <executions>\n                    <execution>\n                        <goals>\n                            <goal>compile</goal>\n                            <goal>compile-custom</goal>\n                        </goals>\n                        <configuration>\n                            <protocPlugins>\n                                <protocPlugin>\n                                    <id>reactor-grpc</id>\n                                    <groupId>com.salesforce.servicelibs</groupId>\n                                    <artifactId>reactor-grpc</artifactId>\n                                    <version>"+this.reactiveGrpcVersion+"</version>\n                                    <mainClass>com.salesforce.reactorgrpc.ReactorGrpcGenerator</mainClass>\n                                </protocPlugin>\n                            </protocPlugins>\n                        </configuration>\n                    </execution>\n                </executions>"),this.replaceContent("pom.xml","<build>\n        <defaultGoal>","<build>\n        <extensions>\n            <extension>\n                <groupId>kr.motd.maven</groupId>\n                <artifactId>os-maven-plugin</artifactId>\n                <version>1.4.1.Final</version>\n            </extension>\n        </extensions>\n        <defaultGoal>")):(this.template("_grpc.gradle","gradle/grpc.gradle"),this.addGradlePlugin("com.google.protobuf","protobuf-gradle-plugin","0.8.10"),this.addGradlePluginToPluginsBlock("com.google.protobuf","0.8.10"),this.applyFromGradleScript("gradle/grpc")),this.skipUserManagement&&"oauth2"!==this.authenticationType||(this.template("_account.proto",a+"account.proto"),this.template("_user.proto",a+"user.proto"),this.template("_UserProtoMapper.java",e+"grpc/UserProtoMapper.java"),this.template("_UserGrpcService.java",e+"grpc/UserGrpcService.java"),this.template("_UserGrpcServiceIntTest.java",t+"grpc/UserGrpcServiceIntTest.java"),"sql"!==this.databaseType&&"mongodb"!==this.databaseType||(this.template("_audit.proto",a+"audit.proto"),this.template("_AuditGrpcService.java",e+"grpc/AuditGrpcService.java"),this.template("_AuditGrpcServiceIntTest.java",t+"grpc/AuditGrpcServiceIntTest.java")),"jwt"===this.authenticationType&&(this.template("_jwt.proto",a+"jwt.proto"),this.template("_JWTService.java",e+"grpc/JWTService.java"),this.template("_JWTServiceIntTest.java",t+"grpc/JWTServiceIntTest.java"))),(!this.skipUserManagement||"oauth2"===this.authenticationType&&["monolith","gateway"].includes(this.applicationType))&&(this.template("_AccountService.java",e+"grpc/AccountService.java"),this.template("_AccountServiceIntTest.java",t+"grpc/AccountServiceIntTest.java"))},updateExistinfEntities(){this.abort||this.entities.forEach((e=>{this.updateEntityConfig(".jhipster/"+e+".json","grpcService",!0)}))},registering:function(){if(!this.abort)try{this.registerModule("generator-jhipster-grpc","entity","post","entity","Adds support for gRPC and generates gRPC CRUD services")}catch(e){this.log(chalk.red.bold("WARN!")+" Could not register as a jhipster entity post creation hook...\n")}},regenerateEntities:function(){this.abort||(0!==this.entities.length&&this.log(chalk.green("Regenerating entities with gRPC service")),this.entities.forEach((e=>{this.composeWith("jhipster:entity",{regenerate:!0,"skip-install":!0,force:this.options.force,"skip-server":!0,"skip-client":!0,arguments:[e]})})))}}}end(){this.abort||this.log("End of grpc generator")}};
//# sourceMappingURL=/sm/e57cd8a2023f789815a710331a425b9aeb7dc1a9ea58ac83a0e90f81545675f5.map