zapnito-cli 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 63373cd6200e8b040420c5e49bf0bfe8ed2c1c70
4
- data.tar.gz: 7e8345df5ea324bbb2bbe52bc0ca11a5fbea2f60
3
+ metadata.gz: f1df975bf83ac9b353ff15a52da5e9640b5d61b1
4
+ data.tar.gz: 2384fe2b3a648593099f3b8dc5ba5e5b5dcefaef
5
5
  SHA512:
6
- metadata.gz: 75b39804f624702913356f2853b0f132cdbadae7634e489831b9f46aa33b10b4454ba89f326e56db0f69047c1ef8dce88ab03b3983294d701f57f4e180695d4a
7
- data.tar.gz: 8ed213185b3f0c9c7c6b37ed3f54f37e2db667ceb5120ab20cafde048a9850b44bbeb01ba67eafa4edabe2fa17c1c913e13e996fa666a2d26b5287ce67f655b3
6
+ metadata.gz: 6009e072865c6b6b3c589cac4de45f6d1eff86ad653565c77d2b26c243b224ad94d42ec2862bf784d6b61629d37dc6fd4bfbd1841ad7fd923c274065de2d4f50
7
+ data.tar.gz: c71b9d5e3fd55f4827ae2a583d89b1b579e470da6832b8287281fd3052d2301532c4b51dda46debce14d22adf5cca0dd42efa7e367727b5d1576526f3d1d8677
@@ -13,12 +13,21 @@ require "zapnito/cli/services"
13
13
  require "zapnito/cli/questions"
14
14
  require "thor"
15
15
  require "zapnito/cli/commands/theme"
16
+ require "zapnito/cli/commands/development_theme"
17
+ require "zapnito/cli/commands/stage_theme"
18
+ require "zapnito/cli/commands/production_theme"
16
19
 
17
20
  module Zapnito
18
21
  module Cli
19
22
  class Main < Thor
20
- desc "theme COMMANDS", "Theme control"
21
- subcommand "theme", Zapnito::Cli::Commands::Theme
23
+ desc "development:theme COMMANDS", "Development Theme control"
24
+ subcommand "development:theme", Zapnito::Cli::Commands::DevelopmentTheme
25
+
26
+ desc "stage:theme COMMANDS", "Stage theme control"
27
+ subcommand "stage:theme", Zapnito::Cli::Commands::StageTheme
28
+
29
+ desc "production:theme COMMANDS", "Production Theme control"
30
+ subcommand "production:theme", Zapnito::Cli::Commands::ProductionTheme
22
31
  end
23
32
  end
24
33
  end
@@ -0,0 +1,16 @@
1
+ require "rest-client"
2
+ require "json"
3
+ require "launchy"
4
+ require "highline"
5
+
6
+ module Zapnito
7
+ module Cli
8
+ module Commands
9
+ class DevelopmentTheme < Theme
10
+ def environment
11
+ :development
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ require "rest-client"
2
+ require "json"
3
+ require "launchy"
4
+ require "highline"
5
+
6
+ module Zapnito
7
+ module Cli
8
+ module Commands
9
+ class ProductionTheme < Theme
10
+ def environment
11
+ :production
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ require "rest-client"
2
+ require "json"
3
+ require "launchy"
4
+ require "highline"
5
+
6
+ module Zapnito
7
+ module Cli
8
+ module Commands
9
+ class StageTheme < Theme
10
+ def environment
11
+ :stage
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -9,7 +9,7 @@ module Zapnito
9
9
  class Theme < Thor
10
10
  desc "add", "add a new tenant"
11
11
  def add
12
- tenant_slug = Questions.which_slug?
12
+ tenant_slug = Questions.which_slug?(api_token)
13
13
  Services.local.create_theme!(tenant_slug)
14
14
  end
15
15
 
@@ -18,9 +18,9 @@ module Zapnito
18
18
  theme = Services.local.load
19
19
  puts "---> Publishing #{theme.tenant_slug}"
20
20
 
21
- release_config = Services.zapnito.s3_upload_urls_for_theme(theme)
21
+ release_config = zapnito.s3_upload_urls_for_theme(theme)
22
22
  Services.s3.upload_theme(theme, release_config)
23
- Services.zapnito.build_release(theme)
23
+ zapnito.build_release(theme)
24
24
 
25
25
  puts "---> Published #{theme.tenant_slug}/#{theme.revision}"
26
26
  rescue Exception => e
@@ -34,25 +34,42 @@ module Zapnito
34
34
  desc "preview_link", "show preview link for current theme"
35
35
  def preview_link
36
36
  theme = Services.local.load
37
- link = Services.zapnito.preview_link(theme)
37
+ link = zapnito.preview_link(theme)
38
38
  puts "---> #{link}"
39
39
  end
40
40
 
41
41
  desc "preview", "preview current theme in browser"
42
42
  def preview
43
43
  theme = Services.local.load
44
- link = Services.zapnito.preview_link(theme)
44
+ link = zapnito.preview_link(theme)
45
+ puts "link: #{link}"
45
46
  Launchy.open(link)
46
47
  end
47
48
 
48
49
  private
49
50
 
51
+ def zapnito
52
+ Services.zapnito(api_token, basepath)
53
+ end
54
+
50
55
  def show_sass_error(e)
51
56
  error = JSON.parse(e.response)["error"]
52
57
  puts "---! #{error["message"]}"
53
58
  puts "=========================="
54
59
  puts "---! #{error["sass_backtrace"]}"
55
60
  end
61
+
62
+ def api_token
63
+ configatron.environments[environment].api_token!
64
+ end
65
+
66
+ def basepath
67
+ configatron.environments[environment].basepath!
68
+ end
69
+
70
+ def environment
71
+ raise "not implemented"
72
+ end
56
73
  end
57
74
  end
58
75
  end
@@ -1,23 +1,15 @@
1
1
  require "configatron"
2
2
  require "json"
3
3
 
4
- missing_token_warning = """
5
- Add your apiToken to ~/.zapnito
6
- {
7
- \"apiToken\": \"your_zapnito_api_token\"
8
- }
9
-
10
- """
11
-
12
4
  begin
13
5
  config = JSON.parse(File.read(File.expand_path("~/.zapnito")))
14
6
 
15
- configatron.api_token = config["apiToken"] || begin
16
- puts missing_token_warning
17
- exit
18
- end
19
-
20
- configatron.basepath = config["basepath"] || "https://zapnito.com"
7
+ configatron.environments.development.basepath = config["environments"]["development"]["basepath"]
8
+ configatron.environments.development.api_token = config["environments"]["development"]["apiToken"]
9
+ configatron.environments.stage.basepath = config["environments"]["stage"]["basepath"]
10
+ configatron.environments.stage.api_token = config["environments"]["stage"]["apiToken"]
11
+ configatron.environments.production.basepath = config["environments"]["production"]["basepath"]
12
+ configatron.environments.production.api_token = config["environments"]["production"]["apiToken"]
21
13
 
22
14
  configatron.working_dir = begin
23
15
  dir_name = Dir.getwd
@@ -3,11 +3,11 @@ module Zapnito
3
3
  module Questions
4
4
  extend self
5
5
 
6
- def which_slug?
6
+ def which_slug?(api_token, basepath)
7
7
  puts
8
8
  HighLine.new.choose do |menu|
9
9
  menu.prompt = "Which tenant do you want to add? "
10
- available_slugs.each do |tenant_slug|
10
+ available_slugs(api_token, basepath).each do |tenant_slug|
11
11
  menu.choice(tenant_slug) { tenant_slug }
12
12
  end
13
13
  end
@@ -15,8 +15,8 @@ module Zapnito
15
15
 
16
16
  private
17
17
 
18
- def available_slugs
19
- tenant_slugs = Services.zapnito.tenant_slugs
18
+ def available_slugs(api_token, basepath)
19
+ tenant_slugs = Services.zapnito(api_token, basepath).tenant_slugs
20
20
  existing_slugs = Services.local.tenant_slugs
21
21
  tenant_slugs - existing_slugs
22
22
  end
@@ -7,8 +7,8 @@ module Zapnito
7
7
  @local ||= Local.new
8
8
  end
9
9
 
10
- def zapnito
11
- @zapnito ||= Zapnito.new(configatron.api_token)
10
+ def zapnito(api_token, basepath)
11
+ Zapnito.new(api_token, basepath)
12
12
  end
13
13
 
14
14
  def s3
@@ -2,8 +2,9 @@ module Zapnito
2
2
  module Cli
3
3
  module Services
4
4
  class Zapnito
5
- def initialize(api_token)
5
+ def initialize(api_token, basepath)
6
6
  @api_token = api_token
7
+ @basepath = basepath
7
8
  end
8
9
 
9
10
  def tenant_slugs
@@ -72,7 +73,7 @@ module Zapnito
72
73
  end
73
74
 
74
75
  def url(path)
75
- "#{configatron.basepath}#{path}"
76
+ "#{@basepath}#{path}"
76
77
  end
77
78
  end
78
79
  end
@@ -1,5 +1,5 @@
1
1
  module Zapnito
2
2
  module Cli
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zapnito-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - opsb
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-03 00:00:00.000000000 Z
11
+ date: 2017-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -280,6 +280,9 @@ files:
280
280
  - bin/setup
281
281
  - exe/zapnito
282
282
  - lib/zapnito/cli.rb
283
+ - lib/zapnito/cli/commands/development_theme.rb
284
+ - lib/zapnito/cli/commands/production_theme.rb
285
+ - lib/zapnito/cli/commands/stage_theme.rb
283
286
  - lib/zapnito/cli/commands/theme.rb
284
287
  - lib/zapnito/cli/initializers/configatron.rb
285
288
  - lib/zapnito/cli/initializers/mime_types.rb