zendesk_apps_tools 1.35.2 → 1.35.3
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 +4 -4
- data/lib/zendesk_apps_tools/api_connection.rb +4 -4
- data/lib/zendesk_apps_tools/cache.rb +44 -11
- data/lib/zendesk_apps_tools/command.rb +3 -3
- data/lib/zendesk_apps_tools/command_helpers.rb +7 -2
- data/lib/zendesk_apps_tools/deploy.rb +2 -2
- data/lib/zendesk_apps_tools/server.rb +5 -0
- data/lib/zendesk_apps_tools/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 343966d2380b3c6d32c9fc42d96267f3206b7006
|
4
|
+
data.tar.gz: 7d71b9491415e36fc335ab2a1d2b47b33756ecda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b59451499cb844d058bbafc5009b72c1e07a12e53ed6f9cfc3f1fe1c121dd9ddd1b10f062ede756d143b6b58f395427be46b42cc01f72a94d7e624a91da1070
|
7
|
+
data.tar.gz: 2da8f6270e4fb93e0f5b895dfec71152fab50939c614f716eb7c2b54b7b9c075a202805e503370c8af5dc356476349e21ff98b807cf299905332e342ee2d6fea
|
@@ -4,11 +4,11 @@ module ZendeskAppsTools
|
|
4
4
|
URL_TEMPLATE = 'https://%s.zendesk.com/'
|
5
5
|
|
6
6
|
def prepare_api_auth
|
7
|
-
@subdomain ||=
|
8
|
-
@username ||=
|
9
|
-
@password ||=
|
7
|
+
@subdomain ||= cache.fetch('subdomain') || get_value_from_stdin('Enter your Zendesk subdomain or full Zendesk URL:')
|
8
|
+
@username ||= cache.fetch('username', @subdomain) || get_value_from_stdin('Enter your username:')
|
9
|
+
@password ||= cache.fetch('password', @subdomain) || get_password_from_stdin('Enter your password:')
|
10
10
|
|
11
|
-
|
11
|
+
cache.save 'subdomain' => @subdomain, 'username' => @username
|
12
12
|
end
|
13
13
|
|
14
14
|
def get_connection(encoding = :url_encoded)
|
@@ -1,25 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'json'
|
3
|
+
|
1
4
|
module ZendeskAppsTools
|
2
|
-
|
5
|
+
class Cache
|
3
6
|
CACHE_FILE_NAME = '.zat'
|
4
7
|
|
5
|
-
|
8
|
+
attr_reader :options
|
9
|
+
|
10
|
+
def initialize(options)
|
11
|
+
@options = options
|
12
|
+
end
|
13
|
+
|
14
|
+
def save(hash)
|
6
15
|
return if options[:zipfile]
|
7
16
|
|
8
|
-
|
9
|
-
File.open(
|
17
|
+
local_cache.update(hash)
|
18
|
+
File.open(local_cache_path, 'w') { |f| f.write JSON.pretty_generate(local_cache) }
|
19
|
+
end
|
20
|
+
|
21
|
+
def fetch(key, subdomain = nil)
|
22
|
+
# drop the default_proc and replace with Hash#dig if older Ruby versions are unsupported
|
23
|
+
local_cache[key] || global_cache[subdomain][key] || global_cache['default'][key]
|
24
|
+
end
|
25
|
+
|
26
|
+
def clear
|
27
|
+
File.delete local_cache_path if options[:clean] && File.exist?(local_cache_path)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def local_cache
|
33
|
+
@local_cache ||= File.exist?(local_cache_path) ? JSON.parse(File.read(local_cache_path)) : {}
|
10
34
|
end
|
11
35
|
|
12
|
-
def
|
13
|
-
@
|
14
|
-
|
36
|
+
def global_cache
|
37
|
+
@global_cache ||= begin
|
38
|
+
if File.exist?(global_cache_path)
|
39
|
+
JSON.parse(File.read(global_cache_path)).tap do |cache|
|
40
|
+
cache.default_proc = proc do |_hash, _key|
|
41
|
+
{}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
else
|
45
|
+
Hash.new({})
|
46
|
+
end
|
47
|
+
end
|
15
48
|
end
|
16
49
|
|
17
|
-
def
|
18
|
-
|
50
|
+
def global_cache_path
|
51
|
+
@global_cache_path ||= File.join(Dir.home, CACHE_FILE_NAME)
|
19
52
|
end
|
20
53
|
|
21
|
-
def
|
22
|
-
@
|
54
|
+
def local_cache_path
|
55
|
+
@local_cache_path ||= File.join(options[:path], CACHE_FILE_NAME)
|
23
56
|
end
|
24
57
|
end
|
25
58
|
end
|
@@ -155,7 +155,7 @@ module ZendeskAppsTools
|
|
155
155
|
method_options SHARED_OPTIONS
|
156
156
|
method_option :zipfile, default: nil, required: false, type: :string
|
157
157
|
def create
|
158
|
-
|
158
|
+
cache.clear
|
159
159
|
@command = 'Create'
|
160
160
|
|
161
161
|
unless options[:zipfile]
|
@@ -169,10 +169,10 @@ module ZendeskAppsTools
|
|
169
169
|
method_options SHARED_OPTIONS
|
170
170
|
method_option :zipfile, default: nil, required: false, type: :string
|
171
171
|
def update
|
172
|
-
|
172
|
+
cache.clear
|
173
173
|
@command = 'Update'
|
174
174
|
|
175
|
-
app_id =
|
175
|
+
app_id = cache.fetch('app_id') || find_app_id
|
176
176
|
unless /\d+/ =~ app_id.to_s
|
177
177
|
say_error_and_exit "App id not found\nPlease try running command with --clean or check your internet connection"
|
178
178
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'zendesk_apps_tools/cache'
|
2
1
|
require 'zendesk_apps_tools/common'
|
3
2
|
require 'zendesk_apps_tools/api_connection'
|
4
3
|
require 'zendesk_apps_tools/deploy'
|
@@ -9,11 +8,17 @@ require 'zendesk_apps_tools/bump'
|
|
9
8
|
|
10
9
|
module ZendeskAppsTools
|
11
10
|
module CommandHelpers
|
12
|
-
include ZendeskAppsTools::Cache
|
13
11
|
include ZendeskAppsTools::Common
|
14
12
|
include ZendeskAppsTools::APIConnection
|
15
13
|
include ZendeskAppsTools::Deploy
|
16
14
|
include ZendeskAppsTools::Directory
|
17
15
|
include ZendeskAppsTools::PackageHelper
|
16
|
+
|
17
|
+
def cache
|
18
|
+
@cache ||= begin
|
19
|
+
require 'zendesk_apps_tools/cache'
|
20
|
+
Cache.new(options)
|
21
|
+
end
|
22
|
+
end
|
18
23
|
end
|
19
24
|
end
|
@@ -48,7 +48,7 @@ module ZendeskAppsTools
|
|
48
48
|
say_error_and_exit('The app was not found. Please verify your credentials, subdomain, and app name are correct.') unless app_json
|
49
49
|
app_id = app_json['id']
|
50
50
|
|
51
|
-
|
51
|
+
cache.save 'app_id' => app_id
|
52
52
|
app_id
|
53
53
|
rescue Faraday::Error::ClientError => e
|
54
54
|
say_error_and_exit e.message
|
@@ -76,7 +76,7 @@ module ZendeskAppsTools
|
|
76
76
|
if %w(completed failed).include? status
|
77
77
|
case status
|
78
78
|
when 'completed'
|
79
|
-
|
79
|
+
cache.save 'app_id' => app_id
|
80
80
|
say_status @command, 'OK'
|
81
81
|
when 'failed'
|
82
82
|
say_status @command, message, :red
|
@@ -39,6 +39,11 @@ module ZendeskAppsTools
|
|
39
39
|
|
40
40
|
enable :cross_origin
|
41
41
|
|
42
|
+
def send_file(*args)
|
43
|
+
access_control_allow_origin
|
44
|
+
super(*args)
|
45
|
+
end
|
46
|
+
|
42
47
|
# This is for any preflight request
|
43
48
|
# It reads 'Access-Control-Request-Headers' to set 'Access-Control-Allow-Headers'
|
44
49
|
# And also sets 'Access-Control-Allow-Origin' header
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zendesk_apps_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.35.
|
4
|
+
version: 1.35.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James A. Rosen
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2016-09-
|
14
|
+
date: 2016-09-27 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: thor
|