zendesk_apps_support 4.3.0 → 4.4.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 +4 -4
- data/config/locales/en.yml +2 -0
- data/lib/zendesk_apps_support/validations/translations.rb +63 -10
- 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: e72293eff17b81b124a52b13846a4fa5960d0f09
|
4
|
+
data.tar.gz: 4187e6abb5b4d2f8c1d2c923c91e5b18ae3d8029
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0debb87a845b756dd8baa4610d29d06b0cc0aef16b2a8623a1cfc0134c32f45d0b2432d76cf2d7d0439b73107c91ad2be1e436c5cce6d3fd9088b349d4207ad1
|
7
|
+
data.tar.gz: 912cd57cc7ce6e5448a0b28124038760ae9d98a700edd0ebfc49f935f4d255128cb4233f1bac6ac656855be291cbeac0989aa3883d8f767cd20bd8fbce684e2d
|
data/config/locales/en.yml
CHANGED
@@ -94,6 +94,8 @@ en:
|
|
94
94
|
not_json: "%{file} is not valid JSON. %{errors}"
|
95
95
|
not_json_object: "%{file} is not a JSON object."
|
96
96
|
missing_required_key: 'Missing required key from %{file}: %{missing_key}'
|
97
|
+
missing_required_key_for_product: 'Missing required key from %{file} for %{product}: %{missing_key}'
|
98
|
+
products_do_not_match_manifest_products: 'Products in manifest (%{manifest_products}) do not match products in translations (%{translation_products}).'
|
97
99
|
stylesheet_error: 'Sass error: %{sass_error}'
|
98
100
|
invalid_type_parameter:
|
99
101
|
one: "%{invalid_types} is an invalid parameter type."
|
@@ -15,10 +15,10 @@ module ZendeskAppsSupport
|
|
15
15
|
def call(package)
|
16
16
|
package.files.each_with_object([]) do |file, errors|
|
17
17
|
path_match = TRANSLATIONS_PATH.match(file.relative_path)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
next unless path_match
|
19
|
+
errors << locale_error(file, path_match[1]) << json_error(file)
|
20
|
+
next unless errors.compact.empty?
|
21
|
+
errors.push(*validate_marketplace_content(file, package)) if file.relative_path == 'translations/en.json'
|
22
22
|
end.compact
|
23
23
|
end
|
24
24
|
|
@@ -48,14 +48,54 @@ module ZendeskAppsSupport
|
|
48
48
|
ValidationError.new('translation.not_json', file: file.relative_path, errors: e)
|
49
49
|
end
|
50
50
|
|
51
|
-
def
|
52
|
-
|
51
|
+
def validate_marketplace_content(file, package)
|
52
|
+
errors = []
|
53
53
|
json = JSON.parse(file.read)
|
54
|
-
|
54
|
+
product_names = Product::PRODUCTS_AVAILABLE.map(&:name)
|
55
|
+
present_product_keys = json['app'].is_a?(Hash) ? json['app'].keys & product_names : []
|
56
|
+
|
57
|
+
if present_product_keys.empty?
|
58
|
+
errors << validate_top_level_required_keys(json, package, file.relative_path)
|
59
|
+
else
|
60
|
+
errors << validate_products_match_manifest_products(present_product_keys, package, file.relative_path)
|
61
|
+
errors << validate_products_have_required_keys(json, package, present_product_keys, file.relative_path)
|
62
|
+
end
|
63
|
+
errors.compact
|
64
|
+
end
|
65
|
+
|
66
|
+
def validate_top_level_required_keys(json, package, file_path)
|
67
|
+
missing_keys = get_missing_keys(package, json['app'].keys)
|
68
|
+
return if missing_keys.empty?
|
69
|
+
ValidationError.new(
|
70
|
+
'translation.missing_required_key',
|
71
|
+
file: file_path,
|
72
|
+
missing_key: missing_keys.join(', ')
|
73
|
+
)
|
74
|
+
end
|
55
75
|
|
56
|
-
|
57
|
-
|
58
|
-
|
76
|
+
def validate_products_have_required_keys(json, package, products, file_path)
|
77
|
+
products.each do |product|
|
78
|
+
missing_keys = get_missing_keys(package, json['app'][product].keys)
|
79
|
+
next if missing_keys.empty?
|
80
|
+
return ValidationError.new(
|
81
|
+
'translation.missing_required_key_for_product',
|
82
|
+
file: file_path,
|
83
|
+
product: product,
|
84
|
+
missing_key: missing_keys.join(', ')
|
85
|
+
)
|
86
|
+
end
|
87
|
+
nil
|
88
|
+
end
|
89
|
+
|
90
|
+
def validate_products_match_manifest_products(products, package, file_path)
|
91
|
+
manifest_products = package.manifest.products.map(&:name)
|
92
|
+
return if (products - manifest_products).empty?
|
93
|
+
ValidationError.new(
|
94
|
+
'translation.products_do_not_match_manifest_products',
|
95
|
+
file: file_path,
|
96
|
+
translation_products: products.join(', '),
|
97
|
+
manifest_products: manifest_products.join(', ')
|
98
|
+
)
|
59
99
|
end
|
60
100
|
|
61
101
|
def validate_translation_format(json)
|
@@ -71,6 +111,19 @@ module ZendeskAppsSupport
|
|
71
111
|
end
|
72
112
|
end
|
73
113
|
end
|
114
|
+
|
115
|
+
def get_missing_keys(package, keys)
|
116
|
+
public_app_keys = %w(name short_description installation_instructions long_description)
|
117
|
+
mandatory_keys = package.manifest.private? ? ['name'] : public_app_keys
|
118
|
+
|
119
|
+
# since we support description as well as short_description for backwards compatibility,
|
120
|
+
# validate keys as if description == short_description
|
121
|
+
keys_to_validate = keys.map do |key|
|
122
|
+
key == 'description' ? 'short_description' : key
|
123
|
+
end
|
124
|
+
|
125
|
+
mandatory_keys - keys_to_validate
|
126
|
+
end
|
74
127
|
end
|
75
128
|
end
|
76
129
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zendesk_apps_support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.4.0
|
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: 2017-09-
|
14
|
+
date: 2017-09-25 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: i18n
|