xat 1.32.0 → 1.32.2
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/README.md +1 -1
- data/lib/zendesk_apps_tools/command.rb +29 -15
- data/lib/zendesk_apps_tools/common.rb +1 -0
- data/lib/zendesk_apps_tools/manifest_handler.rb +1 -1
- data/lib/zendesk_apps_tools/package_helper.rb +1 -1
- data/lib/zendesk_apps_tools/server.rb +45 -26
- data/lib/zendesk_apps_tools/settings.rb +17 -5
- data/lib/zendesk_apps_tools/translate.rb +3 -3
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd865fadb1fb87c9ca9ebf22de22b0a33e28b90b
|
4
|
+
data.tar.gz: e97539670628a197039b0ddcf23e57f988790cb8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4565eedc34863bea5fb17feea20096c87cf9c71dfb020a1d5e33587fce32ca5ec7f3c1074172df7f1d5966e7f45631c71f7c740b80d3043a385b250bb267de61
|
7
|
+
data.tar.gz: 610a048e8e3ac6c3f9ef72a578b460c5195122f0ee14cc30ed5e8181c92b37c73a2055df00d4bee48fb0021538343e6de825aa9a8ed198df126a0a0977bb157e
|
data/README.md
CHANGED
@@ -12,7 +12,7 @@ If you want to **use** this tool, all you need to do is `gem install zendesk_app
|
|
12
12
|
## Getting Started To **Develop** ZAT
|
13
13
|
When you want to help **develop** this tool, you will need to clone this repo and run `bundle install` to get it going.
|
14
14
|
|
15
|
-
|
15
|
+
XAT uses a gem called [XAS](https://github.com/ocke/xat_support/). In the case you are developing ZAT, it is likely you want to edit code in ZAS too, which means you will need to clone the ZAS repo and change the `Gemfile` (in the ZAT project) to say `gem 'zendesk_apps_support', path: '../zendesk_apps_support'`. The path should point to your local ZAS directory. This way your clone of ZAT will use a local version of ZAS which is very helpful for development. Run a `bundle install` after changing the Gemfile.
|
16
16
|
|
17
17
|
## Testing
|
18
18
|
This project uses rspec, which can be run with `bundle exec rake`.
|
@@ -5,7 +5,7 @@ require 'net/http'
|
|
5
5
|
require 'json'
|
6
6
|
require 'faraday'
|
7
7
|
require 'io/console'
|
8
|
-
require '
|
8
|
+
require 'xat_support'
|
9
9
|
|
10
10
|
require 'zendesk_apps_tools/command_helpers'
|
11
11
|
|
@@ -115,33 +115,47 @@ module ZendeskAppsTools
|
|
115
115
|
DEFAULT_SERVER_PATH = './'
|
116
116
|
DEFAULT_CONFIG_PATH = './settings.yml'
|
117
117
|
DEFAULT_SERVER_PORT = 4567
|
118
|
-
DEFAULT_APP_ID = 0
|
119
118
|
|
120
119
|
desc 'server', 'Run a http server to serve the local app'
|
121
120
|
method_option :path, default: DEFAULT_SERVER_PATH, required: false, aliases: '-p'
|
122
121
|
method_option :config, default: DEFAULT_CONFIG_PATH, required: false, aliases: '-c'
|
123
122
|
method_option :port, default: DEFAULT_SERVER_PORT, required: false
|
124
|
-
method_option :app_id,
|
125
|
-
def server
|
126
|
-
|
127
|
-
|
123
|
+
method_option :app_id, required: false
|
124
|
+
def server(*app_paths)
|
125
|
+
if !app_paths.empty?
|
126
|
+
if options[:path] != DEFAULT_SERVER_PATH
|
127
|
+
say_error_and_exit "please either use -p or list the directory structure directly"
|
128
|
+
end
|
129
|
+
|
130
|
+
if options[:config] != DEFAULT_CONFIG_PATH
|
131
|
+
say_error_and_exit "cannot use -c in combination with multiple apps"
|
132
|
+
end
|
133
|
+
|
134
|
+
if !options[:app_id].nil?
|
135
|
+
say_error_and_exit "cannot set app_id in combination with multiple apps"
|
136
|
+
end
|
137
|
+
else
|
138
|
+
app_paths << options[:path]
|
139
|
+
end
|
128
140
|
|
129
|
-
|
141
|
+
apps = app_paths.map do | path |
|
142
|
+
package = ZendeskAppsSupport::Package.new(path)
|
143
|
+
settings_helper = ZendeskAppsTools::Settings.new
|
130
144
|
|
131
|
-
|
145
|
+
settings_file_path = settings_helper.find_settings_file(path)
|
146
|
+
settings = settings_file_path ? {} : settings_helper.get_settings_from_user_input(self, package.manifest_json['parameters'])
|
132
147
|
|
133
|
-
|
134
|
-
|
148
|
+
{
|
149
|
+
package: package,
|
150
|
+
settings_file_path: settings_file_path,
|
151
|
+
settings: settings
|
152
|
+
}
|
135
153
|
end
|
136
154
|
|
137
155
|
require 'zendesk_apps_tools/server'
|
138
156
|
ZendeskAppsTools::Server.tap do |server|
|
139
157
|
server.set :port, options[:port]
|
140
|
-
server.set :
|
141
|
-
server.set :parameters, settings
|
142
|
-
server.set :manifest, manifest['parameters']
|
143
|
-
server.set :config, options[:config]
|
144
|
-
server.set :app_id, options[:app_id]
|
158
|
+
server.set :apps, apps
|
145
159
|
server.run!
|
146
160
|
end
|
147
161
|
end
|
@@ -6,41 +6,60 @@ module ZendeskAppsTools
|
|
6
6
|
set :protection, :except => :frame_options
|
7
7
|
last_mtime = Time.new(0)
|
8
8
|
ZENDESK_DOMAINS_REGEX = /^http(?:s)?:\/\/[a-z0-9-]+\.(?:zendesk|zopim|zd-(?:dev|master|staging))\.com$/
|
9
|
+
last_domain = nil
|
9
10
|
|
10
11
|
get '/app.js' do
|
11
12
|
access_control_allow_origin
|
12
13
|
content_type 'text/javascript'
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
settings_helper = ZendeskAppsTools::Settings.new
|
16
|
+
|
17
|
+
appsjs = []
|
18
|
+
installations = []
|
19
|
+
order = {}
|
20
|
+
|
21
|
+
settings.apps.each_with_index do |app, index|
|
22
|
+
package = app[:package]
|
23
|
+
app_id = installation_id = -(index+1)
|
24
|
+
app_name = package.manifest_json['name'] || 'Local App'
|
25
|
+
|
26
|
+
appsjs << package.compile_js(
|
27
|
+
app_name: app_name,
|
28
|
+
app_id: app_id,
|
29
|
+
assets_dir: "http://localhost:#{settings.port}/#{app_id}/",
|
30
|
+
locale: params['locale']
|
31
|
+
)
|
32
|
+
|
33
|
+
if app[:settings_file_path]
|
34
|
+
curr_mtime = File.stat(app[:settings_file_path]).mtime
|
35
|
+
curr_domain = params['subdomain']
|
36
|
+
if (curr_mtime > last_mtime || curr_domain != last_domain)
|
37
|
+
app[:settings] = settings_helper.get_settings_from_file(app[:settings_file_path], app[:package].manifest_json['parameters'], params['subdomain'])
|
38
|
+
last_mtime = File.stat(app[:settings_file_path]).mtime
|
39
|
+
last_domain = curr_domain
|
40
|
+
end
|
20
41
|
end
|
21
|
-
end
|
22
42
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
)
|
43
|
+
installations << ZendeskAppsSupport::Installation.new(
|
44
|
+
id: installation_id,
|
45
|
+
app_id: app_id,
|
46
|
+
app_name: app_name,
|
47
|
+
enabled: true,
|
48
|
+
requirements: package.requirements_json,
|
49
|
+
settings: app[:settings].merge({title: app_name}),
|
50
|
+
updated_at: Time.now.iso8601,
|
51
|
+
created_at: Time.now.iso8601
|
52
|
+
)
|
53
|
+
end
|
35
54
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
assets_dir: "http://localhost:#{settings.port}/",
|
40
|
-
locale: params['locale']
|
41
|
-
)
|
55
|
+
installed = ZendeskAppsSupport::Installed.new(appsjs, installations)
|
56
|
+
installed.compile_js()
|
57
|
+
end
|
42
58
|
|
43
|
-
|
59
|
+
get "/:app_id/:file" do |app_id, file|
|
60
|
+
# convert to postive and substract 1. So -1 => 0, -3 => 2, etc
|
61
|
+
index = (-app_id.to_i)-1
|
62
|
+
send_file File.join(settings.apps[index][:package].root, 'assets', file)
|
44
63
|
end
|
45
64
|
|
46
65
|
get "/:file" do |file|
|
@@ -14,6 +14,7 @@ module ZendeskAppsTools
|
|
14
14
|
input = user_input.get_value_from_stdin("Enter a value for required parameter '#{param['name']}':\n")
|
15
15
|
else
|
16
16
|
input = user_input.get_value_from_stdin("Enter a value for optional parameter '#{param['name']}' or press 'Return' to skip:\n", allow_empty: true)
|
17
|
+
input = nil if input.empty?
|
17
18
|
end
|
18
19
|
|
19
20
|
if param['type'] == 'checkbox'
|
@@ -25,7 +26,16 @@ module ZendeskAppsTools
|
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
28
|
-
def
|
29
|
+
def find_settings_file(path)
|
30
|
+
['./settings.yml', './settings.json'].reduce([]) do | memo, try_file |
|
31
|
+
memo << File.join(path, try_file)
|
32
|
+
memo << File.join(path, try_file)
|
33
|
+
end.find do |settings_file|
|
34
|
+
File.exist?(settings_file)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def get_settings_from_file(filepath, parameters, domain = nil)
|
29
39
|
return {} if parameters.nil?
|
30
40
|
return nil unless File.exist? filepath
|
31
41
|
|
@@ -38,14 +48,16 @@ module ZendeskAppsTools
|
|
38
48
|
settings_data = YAML.load(settings_file)
|
39
49
|
end
|
40
50
|
|
51
|
+
settings_data = settings_data[domain] if settings_data[domain]
|
52
|
+
|
41
53
|
settings_data.each do |index, setting|
|
42
54
|
if setting.is_a?(Hash) || setting.is_a?(Array)
|
43
55
|
settings_data[index] = JSON.dump(setting)
|
44
56
|
end
|
45
57
|
end
|
46
58
|
rescue => err
|
47
|
-
puts "
|
48
|
-
puts err.message
|
59
|
+
puts "\e[0;31mFailed to load #{filepath}\e[0m\n"
|
60
|
+
puts "\e[0;31m#{err.message}\e[0m\n"
|
49
61
|
return nil
|
50
62
|
end
|
51
63
|
|
@@ -57,8 +69,8 @@ module ZendeskAppsTools
|
|
57
69
|
end
|
58
70
|
|
59
71
|
if !input && param['required']
|
60
|
-
puts "'#{param['name']}' is required but not specified in the config file.\n"
|
61
|
-
|
72
|
+
puts "\e[0;31m'#{param['name']}' is required but not specified in the config file.\e[0m\n"
|
73
|
+
input = nil
|
62
74
|
end
|
63
75
|
|
64
76
|
if param['type'] == 'checkbox'
|
@@ -2,7 +2,7 @@ require 'thor'
|
|
2
2
|
require 'json'
|
3
3
|
require 'zendesk_apps_tools/common'
|
4
4
|
require 'zendesk_apps_tools/locale_identifier'
|
5
|
-
require '
|
5
|
+
require 'xat_support'
|
6
6
|
require 'yaml'
|
7
7
|
|
8
8
|
module ZendeskAppsTools
|
@@ -28,7 +28,7 @@ module ZendeskAppsTools
|
|
28
28
|
en_json = JSON.parse(File.open("#{destination_root}/translations/en.json").read)
|
29
29
|
|
30
30
|
package = en_json['app']['package']
|
31
|
-
|
31
|
+
say_error_and_exit('No package defined inside en.json! Abort.') unless package
|
32
32
|
en_json['app'].delete('package')
|
33
33
|
|
34
34
|
write_yml(en_json, app_name, package)
|
@@ -84,7 +84,7 @@ module ZendeskAppsTools
|
|
84
84
|
en_json = JSON.parse(File.open("#{destination_root}/translations/en.json").read)
|
85
85
|
|
86
86
|
package = en_json['app']['package']
|
87
|
-
|
87
|
+
say_error_and_exit('No package defined inside en.json! Abort.') unless package
|
88
88
|
|
89
89
|
pseudo = build_pseudotranslation(en_json, package)
|
90
90
|
write_json("translations/fr.json", pseudo)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.32.
|
4
|
+
version: 1.32.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Olaf Kwant
|
@@ -67,19 +67,19 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 0.9.2
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: xat_support
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 1.29.3
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 1.29.3
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: cucumber
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|