From e60fddb368cdf8bfd4bcf3573baf6f7770f544d3 Mon Sep 17 00:00:00 2001 From: Frederik Hahne Date: Thu, 11 Jun 2020 13:56:30 +0200 Subject: [PATCH] correct procfile --- generators/heroku/index.js | 46 ++++++++++++++++++- generators/heroku/templates/Procfile.ejs | 2 +- .../heroku/templates/bootstrap-heroku.yml.ejs | 29 ------------ 3 files changed, 45 insertions(+), 32 deletions(-) delete mode 100644 generators/heroku/templates/bootstrap-heroku.yml.ejs diff --git a/generators/heroku/index.js b/generators/heroku/index.js index 88811968..c5d966f1 100644 --- a/generators/heroku/index.js +++ b/generators/heroku/index.js @@ -1,9 +1,12 @@ /* eslint-disable consistent-return */ const chalk = require('chalk'); const fs = require('fs'); +const ChildProcess = require('child_process'); const HerokuGenerator = require('generator-jhipster/generators/heroku'); const constants = require('generator-jhipster/generators/generator-constants'); +const execCmd = util.promisify(ChildProcess.exec); + module.exports = class extends HerokuGenerator { constructor(args, opts) { super(args, { fromBlueprint: true, ...opts }); // fromBlueprint variable is important @@ -18,7 +21,47 @@ module.exports = class extends HerokuGenerator { } get initializing() { - return super._initializing(); + return { + validateFromCli() { + this.checkInvocationFromCLI(); + }, + + async checkInstallation() { + try { + await execCmd('heroku --version'); + } catch (err) { + this.log.error("You don't have the Heroku CLI installed. Download it from https://cli.heroku.com/"); + } + }, + + + initializing() { + this.log(chalk.bold('Heroku configuration is starting')); + const configuration = this.getAllJhipsterConfig(this, true); + this.env.options.appPath = configuration.get('appPath') || constants.CLIENT_MAIN_SRC_DIR; + this.baseName = configuration.get('baseName'); + this.packageName = configuration.get('packageName'); + this.packageFolder = configuration.get('packageFolder'); + this.cacheProvider = configuration.get('cacheProvider') || configuration.get('hibernateCache') || 'no'; + this.enableHibernateCache = configuration.get('enableHibernateCache') && !['no', 'memcached'].includes(this.cacheProvider); + this.databaseType = configuration.get('databaseType'); + this.prodDatabaseType = configuration.get('prodDatabaseType'); + this.searchEngine = configuration.get('searchEngine'); + this.angularAppName = this.getAngularAppName(); + this.buildTool = configuration.get('buildTool'); + this.applicationType = configuration.get('applicationType'); + this.reactive = configuration.get('reactive') || false; + this.serviceDiscoveryType = configuration.get('serviceDiscoveryType'); + this.authenticationType = configuration.get('authenticationType'); + this.herokuAppName = configuration.get('herokuAppName'); + this.dynoSize = 'Free'; + this.herokuDeployType = configuration.get('herokuDeployType'); + this.herokuJavaVersion = configuration.get('herokuJavaVersion'); + this.useOkta = configuration.get('useOkta'); + this.oktaAdminLogin = configuration.get('oktaAdminLogin'); + this.oktaAdminPassword = configuration.get('oktaAdminPassword'); + }, + } } get prompting() { @@ -39,7 +82,6 @@ module.exports = class extends HerokuGenerator { const done = this.async(); this.log(chalk.bold('\nCreating Heroku deployment files')); - // this.template('bootstrap-heroku.yml.ejs', `${constants.SERVER_MAIN_RES_DIR}/config/bootstrap-heroku.yml`); this.template('application-heroku.yml.ejs', `${constants.SERVER_MAIN_RES_DIR}/application-heroku.yml`); this.template('Procfile.ejs', 'Procfile'); this.template('system.properties.ejs', 'system.properties'); diff --git a/generators/heroku/templates/Procfile.ejs b/generators/heroku/templates/Procfile.ejs index a29796c5..72b4042f 100644 --- a/generators/heroku/templates/Procfile.ejs +++ b/generators/heroku/templates/Procfile.ejs @@ -16,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. -%> -web: java $JAVA_OPTS <% if (applicationType === 'gateway' || dynoSize === 'Free') { %>-Xmx256m<% } %> -jar <% if (buildTool === 'maven') { %>target<% } %><% if (buildTool === 'gradle') { %>build/libs<% } %>/*.jar --spring.profiles.active=prod,heroku<% if (buildTool == 'maven' && herokuDeployType == 'git') { %>,no-liquibase<% } %> --micronaut.server.port=$PORT +web: java $JAVA_OPTS -Dmicronaut.environments=prod,heroku <% if (applicationType === 'gateway' || dynoSize === 'Free') { %>-Xmx128m<% } %> -jar <% if (buildTool === 'maven') { %>target<% } %><% if (buildTool === 'gradle') { %>build/libs<% } %>/*-all.jar<% if (buildTool == 'maven' && herokuDeployType == 'git') { %>,no-liquibase<% } %> --micronaut.server.port=$PORT <%_ if (buildTool == 'maven' && herokuDeployType == 'git' && (prodDatabaseType === 'postgresql' || prodDatabaseType === 'mysql' || prodDatabaseType === 'mariadb')) { _%> release: cp -R src/main/resources/config config && ./mvnw -ntp liquibase:update -Pprod,heroku <%_ } _%> diff --git a/generators/heroku/templates/bootstrap-heroku.yml.ejs b/generators/heroku/templates/bootstrap-heroku.yml.ejs deleted file mode 100644 index e1566bec..00000000 --- a/generators/heroku/templates/bootstrap-heroku.yml.ejs +++ /dev/null @@ -1,29 +0,0 @@ -<%# - Copyright 2013-2020 the original author or authors from the JHipster project. - - This file is part of the JHipster project, see https://www.jhipster.tech/ - for more information. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. --%> -# =================================================================== -# Spring Cloud Config bootstrap configuration for the "heroku" profile -# =================================================================== - -<%_ if (serviceDiscoveryType === 'eureka') { _%> -spring: - cloud: - config: - fail-fast: true - uri: ${JHIPSTER_REGISTRY_URL}/config -<%_ } _%>