zendesk_apps_tools 2.12.2 → 2.12.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 +5 -5
- data/README.md +1 -1
- data/lib/zendesk_apps_tools/api_connection.rb +3 -4
- data/lib/zendesk_apps_tools/command.rb +3 -2
- data/lib/zendesk_apps_tools/common.rb +2 -2
- data/lib/zendesk_apps_tools/deploy.rb +41 -27
- data/lib/zendesk_apps_tools/theme.rb +1 -1
- data/lib/zendesk_apps_tools/theming/common.rb +1 -1
- data/lib/zendesk_apps_tools/translate.rb +4 -4
- data/lib/zendesk_apps_tools/version.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 74674fe4161270694ce0357838a66ffeb431ea51577db11e323a559de1430160
|
4
|
+
data.tar.gz: cf485b548d4ee0d0e46c23b6101466794287fca0a0731e00122c478f30099922
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d53fb13befc32158c5bd83f68a152c044f96a4f8557f2b5bbe524f213f71bb16a756bb8e0145eb8f085f0ddc9afc764d83d49b79c60bf64bf8983002acf25c8
|
7
|
+
data.tar.gz: 76a32b9a948d65a74143514178037c1fb2650bd0d0a64c07387e702e9c38249276c3cbc8616a79f1494cc68ba8bdd8b04e16ae0129275a01622d564ffb75153d
|
data/README.md
CHANGED
@@ -13,7 +13,7 @@ To install, run `gem install zendesk_apps_tools`.
|
|
13
13
|
|
14
14
|
To get the latest version, run `gem update zendesk_apps_tools`.
|
15
15
|
|
16
|
-
For information on using the tools, see [Zendesk App Tools](https://developer.zendesk.com/apps/docs/
|
16
|
+
For information on using the tools, see [Zendesk App Tools](https://developer.zendesk.com/apps/docs/developer-guide/zat) on developer.zendesk.com.
|
17
17
|
|
18
18
|
## Work on ZAT
|
19
19
|
If you want to help **develop** this tool, clone this repo and run `bundle install`.
|
@@ -10,7 +10,7 @@ module ZendeskAppsTools
|
|
10
10
|
PROMPT_FOR_URL = 'Enter your Zendesk subdomain or full URL (including protocol):'
|
11
11
|
URL_ERROR_MSG = [
|
12
12
|
'URL error. Example URL: https://mysubdomain.zendesk.com',
|
13
|
-
'If you are using a full URL, follow the
|
13
|
+
'If you are using a full URL, follow the example format shown above.',
|
14
14
|
'If you are using a subdomain, ensure that it contains only valid characters (a-z, A-Z, 0-9, and hyphens).'
|
15
15
|
].join('\n')
|
16
16
|
|
@@ -22,14 +22,13 @@ module ZendeskAppsTools
|
|
22
22
|
say_error_and_exit EMAIL_ERROR_MSG unless valid_email?
|
23
23
|
|
24
24
|
@password ||= cache.fetch('password', @subdomain) || get_password_from_stdin('Enter your password:')
|
25
|
-
|
26
|
-
cache.save 'subdomain' => @subdomain, 'username' => @username
|
27
25
|
end
|
28
26
|
|
29
27
|
def get_connection(encoding = :url_encoded)
|
30
28
|
require 'net/http'
|
31
29
|
require 'faraday'
|
32
|
-
prepare_api_auth
|
30
|
+
prepare_api_auth unless @subdomain && @username && @password
|
31
|
+
|
33
32
|
Faraday.new full_url do |f|
|
34
33
|
f.request encoding if encoding
|
35
34
|
f.adapter :net_http
|
@@ -208,10 +208,11 @@ module ZendeskAppsTools
|
|
208
208
|
setup_path(options[:path])
|
209
209
|
@command = 'Update'
|
210
210
|
|
211
|
-
|
211
|
+
product_name = product_names(manifest).first
|
212
|
+
app_id = cache.fetch('app_id') || find_app_id(product_name)
|
212
213
|
app_url = "/api/v2/apps/#{app_id}.json"
|
213
214
|
unless /\d+/ =~ app_id.to_s && app_exists?(app_id)
|
214
|
-
say_error_and_exit "App
|
215
|
+
say_error_and_exit "App ID not found. Please try running command with --clean or check your internet connection."
|
215
216
|
end
|
216
217
|
|
217
218
|
deploy_app(:put, app_url, {})
|
@@ -69,7 +69,7 @@ module ZendeskAppsTools
|
|
69
69
|
require 'json'
|
70
70
|
JSON.parse(value)
|
71
71
|
rescue JSON::ParserError
|
72
|
-
say_error_and_exit "\"#{value}\" is an invalid JSON"
|
72
|
+
say_error_and_exit "\"#{value}\" is an invalid JSON."
|
73
73
|
end
|
74
74
|
|
75
75
|
private
|
@@ -77,7 +77,7 @@ module ZendeskAppsTools
|
|
77
77
|
def error_or_default_if_unattended(prompt, opts = {})
|
78
78
|
if options[:unattended]
|
79
79
|
return opts[:default] if opts.key? :default
|
80
|
-
say_error 'Would have prompted for a value interactively, but
|
80
|
+
say_error 'Would have prompted for a value interactively, but ZAT is not listening to keyboard input.'
|
81
81
|
say_error_and_exit prompt
|
82
82
|
else
|
83
83
|
yield
|
@@ -6,13 +6,12 @@ module ZendeskAppsTools
|
|
6
6
|
module Deploy
|
7
7
|
include ZendeskAppsTools::Common
|
8
8
|
include ZendeskAppsTools::APIConnection
|
9
|
-
alias_method :connection, :get_connection
|
10
9
|
|
11
10
|
def deploy_app(connection_method, url, body)
|
12
11
|
body[:upload_id] = upload(options[:path]).to_s
|
13
12
|
sleep 2 # Because the DB needs time to replicate
|
14
13
|
|
15
|
-
response =
|
14
|
+
response = cached_connection.send(connection_method) do |req|
|
16
15
|
req.url url
|
17
16
|
req.headers[:content_type] = 'application/json'
|
18
17
|
req.body = JSON.generate body
|
@@ -26,7 +25,7 @@ module ZendeskAppsTools
|
|
26
25
|
|
27
26
|
def app_exists?(app_id)
|
28
27
|
url = "/api/v2/apps/#{app_id}.json"
|
29
|
-
response =
|
28
|
+
response = cached_connection.send(:get) do |req|
|
30
29
|
req.url url
|
31
30
|
end
|
32
31
|
|
@@ -34,7 +33,7 @@ module ZendeskAppsTools
|
|
34
33
|
end
|
35
34
|
|
36
35
|
def install_app(poll_job, product_name, installation)
|
37
|
-
response =
|
36
|
+
response = cached_connection.post do |req|
|
38
37
|
req.url "api/#{product_name}/apps/installations.json"
|
39
38
|
req.headers[:content_type] = 'application/json'
|
40
39
|
req.body = JSON.generate(installation)
|
@@ -56,33 +55,35 @@ module ZendeskAppsTools
|
|
56
55
|
uploaded_data: Faraday::UploadIO.new(package_path, 'application/zip')
|
57
56
|
}
|
58
57
|
|
59
|
-
response =
|
58
|
+
response = cached_connection(:multipart).post('/api/v2/apps/uploads.json', payload)
|
60
59
|
json_or_die(response.body)['id']
|
61
60
|
|
62
61
|
rescue Faraday::Error::ClientError => e
|
63
62
|
say_error_and_exit e.message
|
64
63
|
end
|
65
64
|
|
66
|
-
def find_app_id
|
65
|
+
def find_app_id(product_name = 'v2') # use the v2 endpoint if no product name is provided
|
67
66
|
say_status 'Update', 'app ID is missing, searching...'
|
68
|
-
app_name = get_value_from_stdin('Enter the name of the app:')
|
67
|
+
app_name = get_value_from_stdin('Enter the name of the installed app:')
|
69
68
|
|
70
|
-
|
69
|
+
response = cached_connection.get("/api/#{product_name}/apps/installations.json")
|
70
|
+
installations_json = json_or_die(response.body)
|
71
71
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
72
|
+
unless response.success? && installations_json.has_key?('installations')
|
73
|
+
say_error_and_exit "Unable to retrieve installations. Please check your credentials and internet connection."
|
74
|
+
else
|
75
|
+
installation = installations_json['installations'].find {
|
76
|
+
|i| i['settings'] && i['settings']['name'] == app_name
|
77
|
+
}
|
78
|
+
end
|
76
79
|
|
77
|
-
unless
|
78
|
-
say_error_and_exit
|
79
|
-
"App not found. " \
|
80
|
-
"Please verify that your credentials, subdomain, and app name are correct."
|
81
|
-
)
|
80
|
+
unless installation
|
81
|
+
say_error_and_exit "App not found. Please check that your app name is correct."
|
82
82
|
end
|
83
83
|
|
84
|
-
|
85
|
-
|
84
|
+
app_id = installation['app_id']
|
85
|
+
cache.save 'app_id' => app_id
|
86
|
+
app_id
|
86
87
|
|
87
88
|
rescue Faraday::Error::ClientError => e
|
88
89
|
say_error_and_exit e.message
|
@@ -100,21 +101,18 @@ module ZendeskAppsTools
|
|
100
101
|
end
|
101
102
|
|
102
103
|
def check_job(job_id)
|
103
|
-
http_client = connection
|
104
|
-
|
105
104
|
loop do
|
106
|
-
|
107
|
-
|
108
|
-
status =
|
105
|
+
request = cached_connection.get("/api/v2/apps/job_statuses/#{job_id}")
|
106
|
+
response = json_or_die(request.body)
|
107
|
+
status = response['status']
|
109
108
|
|
110
109
|
if %w(completed failed).include? status
|
111
110
|
case status
|
112
111
|
when 'completed'
|
113
|
-
|
114
|
-
cache.save 'app_id' => app_id if app_id
|
112
|
+
cache.save zat_contents(response)
|
115
113
|
say_status @command, 'OK'
|
116
114
|
when 'failed'
|
117
|
-
say_status @command,
|
115
|
+
say_status @command, response['message'], :red
|
118
116
|
exit 1
|
119
117
|
end
|
120
118
|
break
|
@@ -126,5 +124,21 @@ module ZendeskAppsTools
|
|
126
124
|
rescue Faraday::Error::ClientError => e
|
127
125
|
say_error_and_exit e.message
|
128
126
|
end
|
127
|
+
|
128
|
+
private
|
129
|
+
|
130
|
+
def zat_contents(response)
|
131
|
+
zat = {}
|
132
|
+
zat['subdomain'] = @subdomain
|
133
|
+
zat['username'] = @username
|
134
|
+
zat['app_id'] = response['app_id'] if response['app_id']
|
135
|
+
|
136
|
+
zat
|
137
|
+
end
|
138
|
+
|
139
|
+
def cached_connection(encoding = :url_encoded)
|
140
|
+
@connection ||= {}
|
141
|
+
@connection[encoding] ||= get_connection(encoding)
|
142
|
+
end
|
129
143
|
end
|
130
144
|
end
|
@@ -34,7 +34,7 @@ module ZendeskAppsTools
|
|
34
34
|
full_manifest_path = theme_package_path('manifest.json')
|
35
35
|
JSON.parse(File.read(full_manifest_path))
|
36
36
|
rescue Errno::ENOENT
|
37
|
-
say_error_and_exit "There
|
37
|
+
say_error_and_exit "There is no manifest file in #{full_manifest_path}"
|
38
38
|
rescue JSON::ParserError
|
39
39
|
say_error_and_exit "The manifest file is invalid at #{full_manifest_path}"
|
40
40
|
end
|
@@ -176,9 +176,9 @@ module ZendeskAppsTools
|
|
176
176
|
|
177
177
|
return json_or_die(locale_response.body)['locales'] if locale_response.status == 200
|
178
178
|
if locale_response.status == 401
|
179
|
-
say_error_and_exit 'Authentication failed'
|
179
|
+
say_error_and_exit 'Authentication failed.'
|
180
180
|
else
|
181
|
-
say_error_and_exit "Failed to download locales, got HTTP status #{locale_response.status}"
|
181
|
+
say_error_and_exit "Failed to download locales, got HTTP status #{locale_response.status}."
|
182
182
|
end
|
183
183
|
end
|
184
184
|
|
@@ -228,13 +228,13 @@ module ZendeskAppsTools
|
|
228
228
|
def package_name_from_json(error_out: false)
|
229
229
|
package = en_json && en_json['app']['package']
|
230
230
|
return package if package
|
231
|
-
say_error_and_exit 'No package defined inside en.json
|
231
|
+
say_error_and_exit 'No package defined inside en.json.' if error_out
|
232
232
|
end
|
233
233
|
|
234
234
|
def package_name(error_out: false)
|
235
235
|
package = en_hash && en_hash['app']['package']
|
236
236
|
return package if package
|
237
|
-
say_error_and_exit 'No package defined inside en.yml
|
237
|
+
say_error_and_exit 'No package defined inside en.yml.' if error_out
|
238
238
|
end
|
239
239
|
end
|
240
240
|
end
|
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: 2.12.
|
4
|
+
version: 2.12.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:
|
14
|
+
date: 2019-01-08 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: thor
|
@@ -321,18 +321,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
321
321
|
version: 1.3.6
|
322
322
|
requirements: []
|
323
323
|
rubyforge_project:
|
324
|
-
rubygems_version: 2.6
|
324
|
+
rubygems_version: 2.7.6
|
325
325
|
signing_key:
|
326
326
|
specification_version: 4
|
327
327
|
summary: Tools to help you develop Zendesk Apps.
|
328
328
|
test_files:
|
329
|
-
- features/clean.feature
|
330
329
|
- features/create.feature
|
331
|
-
- features/
|
330
|
+
- features/validate.feature
|
332
331
|
- features/new.feature
|
333
|
-
- features/
|
334
|
-
- features/step_definitions/app_steps.rb
|
335
|
-
- features/support/env.rb
|
332
|
+
- features/clean.feature
|
336
333
|
- features/support/helpers.rb
|
337
334
|
- features/support/webmock.rb
|
338
|
-
- features/
|
335
|
+
- features/support/env.rb
|
336
|
+
- features/step_definitions/app_steps.rb
|
337
|
+
- features/fixtures/quote_character_translation.json
|
338
|
+
- features/package.feature
|