Class: KajabiTheme::CLI

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/kajabi_theme/cli.rb

Constant Summary collapse

FOLDERS =
%w[config templates layouts sections snippets assets].freeze
ACCOUNT_SETTINGS_URL =
"https://app.kajabi.com/admin/settings/account"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#created_atObject (readonly)

Returns the value of attribute created_at.



19
20
21
# File 'lib/kajabi_theme/cli.rb', line 19

def created_at
  @created_at
end

#nameObject (readonly)

Returns the value of attribute name.



17
18
19
# File 'lib/kajabi_theme/cli.rb', line 17

def name
  @name
end

#presigned_postObject (readonly)

Returns the value of attribute presigned_post.



20
21
22
# File 'lib/kajabi_theme/cli.rb', line 20

def presigned_post
  @presigned_post
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



18
19
20
# File 'lib/kajabi_theme/cli.rb', line 18

def updated_at
  @updated_at
end

Instance Method Details

#configureObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/kajabi_theme/cli.rb', line 48

def configure
  theme_id = ask("Kajabi Theme ID:")
  api_key = ask("API Key (#{ACCOUNT_SETTINGS_URL}):")
  api_secret = ask("API Secret (#{ACCOUNT_SETTINGS_URL}):")
  cainfo = ask("CA Cert File (leave blank if you're unsure):")

  if !cainfo.empty? && !File.exist?(File.expand_path(cainfo))
    say "Unable to find '#{cainfo}' (skipping)", :yellow
    cainfo = ""
  end

  create_file "config.yml" do
    {
      theme_id: theme_id,
      api_key: api_key,
      api_secret: api_secret,
      cainfo: cainfo,
      ssl_verifypeer: true
    }.to_yaml
  end
end

#sync(force = true) ⇒ Object



24
25
26
27
28
29
# File 'lib/kajabi_theme/cli.rb', line 24

def sync(force=true)
  self.concurrency = options[:concurrency]
  refresh!
  (force ? files : changed_files).each {|f| send_file(f)}
  hydra.run
end

#watchObject



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/kajabi_theme/cli.rb', line 33

def watch
  self.concurrency = options[:concurrency]
  refresh!
  sync(false)

  say "Watching for file changes..."

  FileWatcher.new(FOLDERS).watch do |filename|
    say "Change detected: #{filename}"
    send_file(filename)
    hydra.run
  end
end