From 60c891efd7fb32206ff1c5d6af3752682c2d7e66 Mon Sep 17 00:00:00 2001 From: Agustin Gomez Date: Fri, 26 Feb 2021 10:32:14 -0300 Subject: [PATCH] feat(heroku): add '-environment' to app names --- lib/potassium/recipes/heroku.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/potassium/recipes/heroku.rb b/lib/potassium/recipes/heroku.rb index 7de75e20..4fe8a91c 100644 --- a/lib/potassium/recipes/heroku.rb +++ b/lib/potassium/recipes/heroku.rb @@ -65,7 +65,7 @@ def puts_not_logged_in_msg end def heroku_pipeline_name - @heroku_pipeline_name ||= valid_heroku_name(app_name.dasherize, 'pipeline') + @heroku_pipeline_name ||= valid_heroku_name(app_name.dasherize, 'pipeline', false) end def set_app_name_for(environment) @@ -133,10 +133,16 @@ def run_toolbelt_command(command, app_env_name = nil) end end - def valid_heroku_name(name, element) + def valid_heroku_name(name, element, force_suffix = true) + suffix = "-#{element}" while name.length > HEROKU_NAMES_MAX_CHARS puts "Heroku names must be shorter than #{HEROKU_NAMES_MAX_CHARS} chars." + if force_suffix + puts "Potassium uses the heroku-stage gem, because of that '#{suffix}' will be "\ + "added to your app name. The suffix, #{suffix}, counts towards the app name length." + end name = Ask.input("Please enter a valid name for #{element}:") + name += suffix if force_suffix && !name.end_with?(suffix) end name end