Class: Middlesite::Cli

Inherits:
Thor
  • Object
show all
Defined in:
lib/middlesite/cli.rb

Instance Method Summary collapse

Instance Method Details

#buildObject



19
20
21
22
23
24
25
# File 'lib/middlesite/cli.rb', line 19

def build
  if options[:verbose]
    system "bundle exec middleman build --verbose"
  else
    system "bundle exec middleman build"
  end
end

#bump(type = "patch") ⇒ Object

Raises:

  • (Thor::Error)


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
# File 'lib/middlesite/cli.rb', line 38

def bump(type="patch")
  # Get latest git tag
  raise Thor::Error, "Not a git repository!" unless Dir.exists?(".git")
  g = ::Git.open(".")
  raise Thor::Error, "Uncommitted git changes!" unless g.status.changed.empty?
  tags = g.tags
  raise Thor::Error, "No tag found!" if tags.empty?
  tag = tags.pop().name

  # Bump version
  case type
  when "major"
    version = bump_major(tag)
  when "minor"
    version = bump_minor(tag)
  when "patch"
    version = bump_patch(tag)
  end
  puts "Bumping version to: #{version}"

  # update config
  puts "Updating site config..."
  config = get_config()
  config["version"] = version
  set_config(config)

  # commit & add tag
  g.commit_all("release v#{version}")
  puts "Adding tag..."
  g.add_tag("v#{version}")
  g.repack

  # push
  puts "Pushing files..."
  g.push("origin", "master", true)
end

#deployObject



33
34
35
# File 'lib/middlesite/cli.rb', line 33

def deploy
  system "bundle exec middleman deploy"
end

#initObject



9
10
11
12
13
14
15
# File 'lib/middlesite/cli.rb', line 9

def init
  puts "Installing gems..."
  system "bundle install"
  puts ""
  puts "Installing bower packages..."
  system "bower install"
end

#serverObject



28
29
30
# File 'lib/middlesite/cli.rb', line 28

def server
  system "bundle exec middleman server"
end