Skip to content

Commit

Permalink
refactor bin/setup_heroku so button users get admin accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
cantino committed Sep 23, 2014
1 parent ab82683 commit ca0234b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 22 deletions.
6 changes: 3 additions & 3 deletions app/views/devise/registrations/new.html.erb
Expand Up @@ -15,7 +15,7 @@
<ul>
<li>Read <a href="https://github.com/cantino/huginn/wiki/Run-Huginn-for-free-on-Heroku" target="_target">this document</a> carefully if you are going to try out Huginn for free on <a href="https://id.heroku.com/" target="_target">Heroku</a>.</li>

<li>Install the <a href="https://toolbelt.heroku.com/" target="_target">Heroku Toolbelt</a> and run <kbd>heroku login</kbd> if you haven't already.</li>
<li>Install the <a href="https://toolbelt.heroku.com/" target="_target">Heroku Toolbelt</a> and run <kbd>heroku login</kbd>, if you haven't already.</li>

<li>Run the following commands:<br />
<%= content_tag :pre do -%>
Expand All @@ -25,7 +25,7 @@ bundle
bin/setup_heroku
<%- end %>

<li>Get back to this page and sign up with the invitation code shown by the last command.</li>
<li>This command will create an admin account for you.</li>
</ul>
</div>
<% end %>
Expand Down Expand Up @@ -78,4 +78,4 @@ bin/setup_heroku
</div>
</div>
</div>
</div>
</div>
48 changes: 29 additions & 19 deletions bin/setup_heroku
Expand Up @@ -138,41 +138,51 @@ unless $config['SMTP_DOMAIN'] && $config['SMTP_USER_NAME'] && $config['SMTP_PASS
end
end

if first_time
puts "Restarting..."
puts capture("heroku restart")

puts "Done!"
puts
puts "Visit https://#{app_name}.herokuapp.com/users/sign_up and use the invitation code shown below:"
puts
puts "\t#{$config['INVITATION_CODE']}"

exit
end

branch = capture("git rev-parse --abbrev-ref HEAD")
if yes?("Should I push your current branch (#{branch}) to heroku?")
puts "This may take a moment..."
puts capture("git push heroku #{branch}:master -f")

puts "Running database migrations..."
puts capture("heroku run rake db:migrate")
end

if first_time
puts "Restarting..."
puts capture("heroku restart")
puts "Done!"
puts
puts
puts "I can make an admin user on your new Huginn instance and setup some example Agents."
if yes?("Should I create a new admin user and some example Agents?")
seed_email = nag "Okay, what is your email address?"
seed_username = nag "And what username would you like to login as?"
seed_password = nag "Finally, what password would you like to use?", noecho: true
puts "\nJust a moment..."

capture("heroku run rake db:seed SEED_EMAIL=#{seed_email} SEED_USERNAME=#{seed_username} SEED_PASSWORD=#{seed_password}")
done = false
while !done
seed_email = nag "Okay, what is your email address?"
seed_username = nag "And what username would you like to login as?"
seed_password = nag "Finally, what password would you like to use?", noecho: true
puts "\nJust a moment..."

result = capture("heroku run rake db:seed SEED_EMAIL=#{seed_email} SEED_USERNAME=#{seed_username} SEED_PASSWORD=#{seed_password}")
if result =~ /Validation failed/
puts "ERROR:"
puts
puts result
puts
else
done = true
end
end
puts
puts
puts "Okay, you should be all set! Visit https://#{app_name}.herokuapp.com and login as '#{seed_username}' with your password."
puts
puts "If you'd like to make more users, you can visit https://#{app_name}.herokuapp.com/users/sign_up and use the invitation code:"
else
puts
puts "Visit https://#{app_name}.herokuapp.com/users/sign_up and use the invitation code shown below:"
end
puts
puts "\t#{$config['INVITATION_CODE']}"
end

puts
Expand Down

0 comments on commit ca0234b

Please sign in to comment.