Class: BooticCli::Commands::Themes

Inherits:
BooticCli::Command show all
Defined in:
lib/bootic_cli/commands/themes.rb

Defined Under Namespace

Classes: Prompt

Constant Summary

Constants included from BooticCli::Connectivity

BooticCli::Connectivity::DEFAULT_ENV

Instance Method Summary collapse

Methods inherited from BooticCli::Command

declare, #help

Instance Method Details

#clone(dir = nil) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/bootic_cli/commands/themes.rb', line 19

def clone(dir = nil)
  logged_in_action do
    local_theme, remote_theme = theme_selector.setup_theme_pair(options['shop'], dir, options['public'], options['dev'])

    if File.exist?(local_theme.path)
      prompt.say "Directory already exists! (#{local_theme.path})", :red
    else
      prompt.say "Cloning theme files into #{local_theme.path}"
      workflows.pull(local_theme, remote_theme)
      local_theme.write_subdomain
    end
  end
end

#compareObject



66
67
68
69
70
71
# File 'lib/bootic_cli/commands/themes.rb', line 66

def compare
  within_theme do
    local_theme, remote_theme = theme_selector.select_theme_pair(default_subdomain, current_dir, options['public'])
    workflows.compare(local_theme, remote_theme)
  end
end

#openObject



107
108
109
110
111
112
# File 'lib/bootic_cli/commands/themes.rb', line 107

def open
  within_theme do
    _, remote_theme = theme_selector.select_theme_pair(default_subdomain, current_dir, options['public'])
    Launchy.open remote_theme.path
  end
end

#pairObject



116
117
118
119
120
121
# File 'lib/bootic_cli/commands/themes.rb', line 116

def pair
  within_theme do
    local_theme = theme_selector.pair(options['shop'], current_dir)
    prompt.say "Directory #{local_theme.path} paired with shop #{options['shop']}", :green
  end
end

#publishObject



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/bootic_cli/commands/themes.rb', line 84

def publish
  within_theme do
    local_theme, remote_theme = theme_selector.select_theme_pair(default_subdomain, current_dir)
    if remote_theme.public?
      say "You don't seem to have a development theme set up, so there's nothing to publish!", :red
    else
      say("Publishing means all your public theme's templates and assets will be lost.")
      if prompt.yes_or_no?("Would you like to make a local copy of your current public theme before publishing?", false)

        backup_path = File.join(local_theme.path, "public-theme-backup-#{Time.now.to_i}")
        backup_theme, public_theme = theme_selector.select_theme_pair(local_theme.subdomain, backup_path, true)

        say("Gotcha. Backing up your public theme into #{backup_theme.path}")
        workflows.pull(backup_theme, public_theme)
      end

      workflows.publish(local_theme, remote_theme)
    end
  end
end

#pullObject



36
37
38
39
40
41
# File 'lib/bootic_cli/commands/themes.rb', line 36

def pull
  within_theme do
    local_theme, remote_theme = theme_selector.select_theme_pair(default_subdomain, current_dir, options['public'])
    workflows.pull(local_theme, remote_theme, delete: options['delete'] || true)
  end
end

#pushObject



46
47
48
49
50
51
52
# File 'lib/bootic_cli/commands/themes.rb', line 46

def push
  within_theme do
    local_theme, remote_theme = theme_selector.select_theme_pair(default_subdomain, current_dir, options['public'])
    warn_user if remote_theme.public? and options['public'].nil?
    workflows.push(local_theme, remote_theme, delete: options['delete'] || true)
  end
end

#syncObject



56
57
58
59
60
61
62
# File 'lib/bootic_cli/commands/themes.rb', line 56

def sync
  within_theme do
    local_theme, remote_theme = theme_selector.select_theme_pair(default_subdomain, current_dir, options['public'])
    warn_user if remote_theme.public? and options['public'].nil?
    workflows.sync(local_theme, remote_theme)
  end
end

#watchObject



75
76
77
78
79
80
81
# File 'lib/bootic_cli/commands/themes.rb', line 75

def watch
  within_theme do
    _, remote_theme = theme_selector.select_theme_pair(default_subdomain, current_dir, options['public'])
    warn_user if remote_theme.public? and options['public'].nil?
    workflows.watch(current_dir, remote_theme)
  end
end