class Shopifly::CLI

Public Instance Methods

apps() click to toggle source
# File lib/shopifly/cli.rb, line 43
def apps
  config = Shopifly::Config.new
  site = config.store_url
  `open "https://#{site}/admin/apps"`
end
init() click to toggle source
# File lib/shopifly/cli.rb, line 50
def init
  unless system "theme version"
    puts "Error: 'theme' command not found path. See " \
          "https://shopify.github.io/themekit/".red
    return
  end

  command = ask(
    "Command you use to deploy theme code to Shopify:",
    default: "theme deploy"
  )

  puts
  puts "Writing " + "sample.config.stores.yml".green

  write_sample_config(command)

  puts "Done."
  puts

  puts "Writing " + ".current_store".green

  write_current_store

  puts "Done."
  puts

  puts "To complete setup, configure " + "sample.config.stores.yml".green +
       " and rename to " + "config.stores.yml".green
  puts

  puts "Change the store that you sync to by editing " +
       ".current_store".green
  puts
end
open() click to toggle source
# File lib/shopifly/cli.rb, line 31
def open
  `theme open`
end
sync() click to toggle source
# File lib/shopifly/cli.rb, line 16
def sync
  unless File.exist? "config.stores.yml"
    puts "file not found: config.stores.yml".red
    return
  end

  unless File.exist? ".current_store"
    puts "file not found: .current_store".red
    return
  end

  Shopifly::Syncer.new.sync
end
themes() click to toggle source
# File lib/shopifly/cli.rb, line 36
def themes
  config = Shopifly::Config.new
  site = config.store_url
  `open "https://#{site}/admin/themes"`
end

Private Instance Methods

write_current_store() click to toggle source
# File lib/shopifly/cli.rb, line 88
    def write_current_store
      File.open(".current_store", "w") do |file|
        file.write <<~CONFIG
          development
        CONFIG
      end
    end
write_sample_config(command) click to toggle source
# File lib/shopifly/cli.rb, line 96
    def write_sample_config(command)
      File.open("sample.config.stores.yml", "w") do |file|
        file.write <<~CONFIG
          defaults:
            branch: "master"

          shared_config:
            deploy_command: "#{command}"
            directory: "shopify/"
            ignore_files:
              - "config/settings_data.json"

          stores:
            development:
              api_key: ""
              password: ""
              store: "my-site-dev"
            qa:
              api_key: ""
              password: ""
              store: "my-site-staging"
            production:
              api_key: ""
              password: ""
              store: "my-site-production"
        CONFIG
      end

    end