Skip to content

Commit

Permalink
run seed after wp install
Browse files Browse the repository at this point in the history
  • Loading branch information
villepietarinen committed Apr 11, 2017
1 parent ce3ccad commit 39adbc7
Showing 1 changed file with 34 additions and 30 deletions.
64 changes: 34 additions & 30 deletions bin/gdev
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,8 @@ HEREDOC

#puts args.inspect

themename=args['sitename'].tr('-','');

case args['type']
when "wordpress"
# setup wordpress project
Expand All @@ -483,9 +485,9 @@ HEREDOC
puts `git clone [email protected]:devgeniem/wp-project.git #{args['sitename']}`
if args['theme']
puts "Cloning theme from #{args['theme']}..."
puts `git clone #{args['theme']} #{args['sitename']}/web/app/themes/#{args['sitename']}`
puts `git clone #{args['theme']} #{args['sitename']}/web/app/themes/#{themename}`
puts "Removing .git directory from theme..."
`rm -rf #{args['sitename']}/web/app/themes/#{args['sitename']}/.git`
`rm -rf #{args['sitename']}/web/app/themes/#{themename}/.git`
puts ""
else
# TODO: get default theme url from ~/.gdev/gdevconf.yml
Expand All @@ -507,27 +509,28 @@ HEREDOC
end
}
end
# replace all THEMENAME and PROJECTNAME references from all files from this project to your project name
# replace all THEMENAME (namespace) references from all files from this project to your project name
puts "Replacing 'THEMENAME' strings from all project files with '#{args['sitename']}'..."
themename_file_names = [
"#{args['sitename']}/.drone.yml",
"#{args['sitename']}/config/application.php",
"#{args['sitename']}/docker-compose.yml",
"#{args['sitename']}/web/app/themes/#{args['sitename']}/lib/extras.php",
"#{args['sitename']}/web/app/themes/#{args['sitename']}/lib/images.php",
"#{args['sitename']}/web/app/themes/#{args['sitename']}/lib/setup.php",
"#{args['sitename']}/web/app/themes/#{args['sitename']}/package.json",
"#{args['sitename']}/web/app/themes/#{args['sitename']}/style.css"
"#{args['sitename']}/web/app/themes/#{themename}/lib/extras.php",
"#{args['sitename']}/web/app/themes/#{themename}/lib/images.php",
"#{args['sitename']}/web/app/themes/#{themename}/lib/setup.php",
"#{args['sitename']}/web/app/themes/#{themename}/package.json",
"#{args['sitename']}/web/app/themes/#{themename}/style.css"
]
themename_file_names.each do |file_name|
text = File.read(file_name)
new_contents = text.gsub(/THEMENAME/, "#{args['sitename']}")
# remove dashes from namespace strings
new_contents = text.gsub(/THEMENAME/, "#{args['sitename'].tr('-','')}")
File.open(file_name, "w") {|file| file.puts new_contents }
end
puts "Replacing 'themename-textdomain' strings from all project files with '#{args['sitename'].downcase}-td'..."
textdomain_file_names = [
"#{args['sitename']}/web/app/themes/#{args['sitename']}/lib/setup.php",
"#{args['sitename']}/web/app/themes/#{args['sitename']}/style.css"
"#{args['sitename']}/web/app/themes/#{themename}/lib/setup.php",
"#{args['sitename']}/web/app/themes/#{themename}/style.css"
]
textdomain_file_names.each do |file_name|
text = File.read(file_name)
Expand Down Expand Up @@ -562,28 +565,10 @@ HEREDOC
# install theme npm modules
if args['npm_install']
puts "Installing theme node modules..."
puts `cd #{args["sitename"]}/web/app/themes/#{args["sitename"]}; npm install`
puts `cd #{args["sitename"]}/web/app/themes/#{themename}; npm install`
puts ""
end

# TODO: seed (install wp)
#puts "Waiting for 10 seconds to be sure that docker instances are up and running..."
#sleep(10)
#puts "Running scripts/seed.sh..."
#puts `cd #{args["sitename"]}; gdev run web ./scripts/seed.sh`
#puts ""

# temporary fix for redis-cache plugin, remove this when plugin works
#puts "Copying object-cache.php in place (temporary fix for redis-cache plugin)..."
#`cp #{args["sitename"]}/web/app/object-cache.php #{args["sitename"]}/web/app/plugins/redis-cache/includes`
#puts ""


# gdev reload
#puts "Reloading gdev..."
#puts `cd #{args["sitename"]}; gdev reload`
#puts ""

# set git repository
if args['git'] == ""
puts "NO GIT REPOSITORY GIVEN!"
Expand All @@ -599,6 +584,16 @@ HEREDOC
puts `cd #{args["sitename"]}; gdev up`
puts ""

# running seed
if args['run_seed']
puts "Waiting for 10 seconds to be sure that docker instances are up and running..."
sleep(10)
puts ""
puts "Running seed (Installing WordPress)..."
puts `cd #{args["sitename"]}; gdev exec scripts/seed.sh`
puts ""
end

puts "Point your browser to https://#{args['sitename'].downcase}.test/wp-admin and log in"

# TODO: help for setting up stage and production
Expand Down Expand Up @@ -711,6 +706,15 @@ HEREDOC
project['npm_install']=false
end
puts ""
# run seed after setup?
puts "Run seed after installation? (Y/N)"
run_seed=gets.chomp
if ['Y','y'].include?(run_seed)
project['run_seed']=true
else
project['run_seed']=false
end
puts ""
# set stage cluster domain
if defaults['stage']
puts "Flynn stage cloud address ("+defaults['stage']+default_marker+"):"
Expand Down

0 comments on commit 39adbc7

Please sign in to comment.