Class: WSlaveNew

Inherits:
Object
  • Object
show all
Defined in:
lib/wslave_new.rb

Instance Method Summary collapse

Constructor Details

#initialize(path, version) ⇒ WSlaveNew

Returns a new instance of WSlaveNew.



6
7
8
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
# File 'lib/wslave_new.rb', line 6

def initialize(path, version)
  puts '⚙ Initializing Toolchain・・・'

  base_path = File.expand_path "#{__dir__}/../base/"
  template_path = File.expand_path "#{__dir__}/../templates/"

  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

  spec = Gem::Specification::load("#{__dir__}/../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"`

  `cd #{path} && git submodule add git://github.com/WordPress/WordPress.git public/wordpress`
  `cd #{path}/public/wordpress && git checkout #{version}-branch` if version != ''
  `cd #{path} && git submodule update --init --recursive public/wordpress`

  puts "  > Preparing detached content directory"
  FileUtils.cp_r("#{path}/public/wordpress/wp-content", "#{path}/public/wp-content")
  FileUtils.mkdir("#{path}/public/wp-content/uploads")
  FileUtils.touch("#{path}/public/wp-content/uploads/.gitkeep")
  FileUtils.mkdir("#{path}/public/wp-content/upgrade")
  FileUtils.touch("#{path}/public/wp-content/upgrade/.gitkeep")
  Dir.chdir path

  puts "  > Setting permissions"
  WSlaveTools.set_dev_perms
  
  `cd #{path} && git add --all && git commit -am "Add and initialize WordPress#{version}"`
  puts "  > Done!"
end