Class: BooticCli::Commands::Themes
- Inherits:
-
BooticCli::Command
- Object
- Thor
- BooticCli::Command
- BooticCli::Commands::Themes
- 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
- #clone(dir = nil) ⇒ Object
- #compare ⇒ Object
- #open ⇒ Object
- #pair ⇒ Object
- #publish ⇒ Object
- #pull ⇒ Object
- #push ⇒ Object
- #sync ⇒ Object
- #watch ⇒ Object
Methods inherited from BooticCli::Command
Instance Method Details
#clone(dir = nil) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/bootic_cli/commands/themes.rb', line 20 def clone(dir = nil) logged_in_action do local_theme, remote_theme = theme_selector.setup_theme_pair(['shop'], dir, ['public'], ['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 |
#compare ⇒ Object
70 71 72 73 74 75 |
# File 'lib/bootic_cli/commands/themes.rb', line 70 def compare within_theme do local_theme, remote_theme = theme_selector.select_theme_pair(default_subdomain, current_dir, ['public']) workflows.compare(local_theme, remote_theme) end end |
#open ⇒ Object
125 126 127 128 129 130 |
# File 'lib/bootic_cli/commands/themes.rb', line 125 def open within_theme do _, remote_theme = theme_selector.select_theme_pair(default_subdomain, current_dir, ['public']) Launchy.open remote_theme.path end end |
#pair ⇒ Object
134 135 136 137 138 139 |
# File 'lib/bootic_cli/commands/themes.rb', line 134 def pair within_theme do local_theme = theme_selector.pair(['shop'], current_dir) prompt.say "Directory #{local_theme.path} paired with shop #{['shop']}", :green end end |
#publish ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/bootic_cli/commands/themes.rb', line 88 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 # check if there are any differences between the dev and public themes local_theme, public_theme = theme_selector.select_theme_pair(default_subdomain, current_dir, true) diff = BooticCli::Themes::ThemeDiff.new(source: remote_theme, target: public_theme) unless diff.any? unless prompt.yes_or_no?("Your public and development themes seem to be in sync (no differences). Publish anyway?", false) prompt.say "Okeysay. Bye." exit 1 end end # say("Publishing means all your public theme's templates and assets will be replaced and lost.") if prompt.yes_or_no?("Would you like to make a local copy of your current public theme before publishing?", diff.any?) # default to true if changes exist backup_path = File.join(local_theme.path, "public-theme-backup-#{Time.now.to_i}") backup_theme = theme_selector.select_local_theme(backup_path, local_theme.subdomain) say("Gotcha. Backing up your public theme into #{prompt.highlight(backup_theme.path)}") workflows.pull(backup_theme, public_theme) prompt.say "Done! Existing public theme was saved to #{prompt.highlight(File.basename(backup_theme.path))}", :cyan end workflows.publish(local_theme, remote_theme) end end end |
#pull ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/bootic_cli/commands/themes.rb', line 37 def pull within_theme do local_theme, remote_theme = theme_selector.select_theme_pair(default_subdomain, current_dir, ['public']) workflows.pull(local_theme, remote_theme, delete: ['delete'] || true) prompt.say "Done! Preview this theme at #{remote_theme.path}", :cyan end end |
#push ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/bootic_cli/commands/themes.rb', line 48 def push within_theme do local_theme, remote_theme = theme_selector.select_theme_pair(default_subdomain, current_dir, ['public']) warn_user if remote_theme.public? and ['public'].nil? workflows.push(local_theme, remote_theme, delete: ['delete'] || true) prompt.say "Done! View updated version at #{remote_theme.path}", :cyan end end |
#sync ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/bootic_cli/commands/themes.rb', line 59 def sync within_theme do local_theme, remote_theme = theme_selector.select_theme_pair(default_subdomain, current_dir, ['public']) warn_user if remote_theme.public? and ['public'].nil? workflows.sync(local_theme, remote_theme) prompt.say "Synced! Preview this theme at #{remote_theme.path}", :cyan end end |
#watch ⇒ Object
79 80 81 82 83 84 85 |
# File 'lib/bootic_cli/commands/themes.rb', line 79 def watch within_theme do _, remote_theme = theme_selector.select_theme_pair(default_subdomain, current_dir, ['public']) warn_user if remote_theme.public? and ['public'].nil? workflows.watch(current_dir, remote_theme) end end |