9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/wslave_new.rb', line 9
def initialize(path, version = '', wspath = '', wppath = '')
puts '⚙ Initializing Toolchain・・・'
if (wspath != '')
manual_path = true
if ((Pathname.new(wspath)).absolute?)
base_path = File.expand_path "#{wspath}/base/"
template_path = File.expand_path "#{wspath}/templates/"
else
base_path = File.expand_path "#{path}/#{wspath}/base/"
template_path = File.expand_path "#{path}/#{wspath}/templates/"
end
else
manual_path = false
wspath = "#{__dir__}/.."
base_path = File.expand_path "#{wspath}/base/"
template_path = File.expand_path "#{wspath}/templates/"
end
FileUtils.mkdir_p path
Dir.chdir path
puts " > Setting up WordPress WSlave setup in: #{path}"
FileUtils.cp_r Dir.glob("#{base_path}/*"), path
FileUtils.cp_r Dir.glob("#{template_path}/*"), path
add_path_to_Gemspec(wspath, path) if manual_path
spec = Gem::Specification::load("#{wspath}/wslave.gemspec")
File.open("#{path}/config/.wslave", 'w') {|f| f.write(spec.version)}
`cd #{path} && git init && git add --all && git commit -am "initial commit by wslave"`
if (wppath != '')
wppath = File.expand_path(wppath)
puts " >> Checking wppath (#{wppath}) ..."
if (File.directory? wppath)
puts " >> wppath is a folder. Copying..."
Dir.chdir path
FileUtils.cp_r wppath, "public/wordpress"
Dir.chdir "public/wordpress"
`git clean -fdx; git stash`
`git checkout master`
`git pull`
end
end
`cd #{path} && git submodule add https://github.com/WordPress/WordPress.git public/wordpress`
`cd #{path} && git submodule update --init --recursive public/wordpress`
if (version == 'edge' || version == 'master')
`cd #{path}/public/wordpress && git checkout master`
elsif version != ''
`cd #{path}/public/wordpress && git checkout #{version}`
else
`cd #{path}/public/wordpress && git checkout #{get_stable_branch_version("#{path}/public/wordpress")}-branch`
end
puts " > Preparing detached content directory"
FileUtils.cp_r("#{path}/public/wordpress/wp-content", "#{path}/public/wp-content")
FileUtils.mkdir("#{path}/public/wp-content/uploads") unless Dir.exist?("#{path}/public/wp-content/uploads")
FileUtils.touch("#{path}/public/wp-content/uploads/.gitkeep")
FileUtils.mkdir("#{path}/public/wp-content/upgrade") unless Dir.exist?("#{path}/public/wp-content/upgrade")
FileUtils.touch("#{path}/public/wp-content/upgrade/.gitkeep")
Dir.chdir path
puts " > Preparing static data directory"
FileUtils.mkdir("#{path}/public/data") unless Dir.exist?("#{path}/public/data")
puts " > Setting permissions"
WSlaveTools.set_dev_perms
`cd #{path} && git add --all && git commit -am "Add and initialize WordPress#{version}"`
puts " > Done!"
end
|