zci 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/README.md +23 -6
- data/bin/zci +7 -12
- data/lib/zci/commands/02_import.rb +10 -1
- data/lib/zci/commands/04_export.rb +17 -8
- data/lib/zci/commands/06_info.rb +25 -9
- data/lib/zci/helpers.rb +17 -0
- data/lib/zci/init.rb +5 -5
- data/lib/zci/version.rb +1 -1
- data/lib/zci.rb +1 -1
- data/zci.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 288b8d33f051846608ed93e937598a6fdcae07058c92c27001c79d12dbe03fa5
|
4
|
+
data.tar.gz: 1aede6fa10bee8a04c5e3430430774260c21caed7b9533e4c826280df5df7fc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 589dfda55c4d68b9c115279535bc0e292104521e8ccbcf337e1fef2b2a7968300c2788dcef12ce928eeda5e9af85ca3e8a550a87bae2a7f188fe2d753ee8760c
|
7
|
+
data.tar.gz: 53ae293ac3bf6683f701d80a6c8465f9536489c494c270213acc100ae8d8e6950f2b19a0a96207d1845010e47c9acb89d7cb28ee7aafedb2980758738d1ce8fa
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -49,7 +49,7 @@ SYNOPSIS
|
|
49
49
|
zci [global options] command [command options] [arguments...]
|
50
50
|
|
51
51
|
VERSION
|
52
|
-
0.6.
|
52
|
+
0.6.1
|
53
53
|
|
54
54
|
GLOBAL OPTIONS
|
55
55
|
-c, --config=<s> - Project-specific configuration file (default: /home/crowdin/zci.yml)
|
@@ -88,21 +88,38 @@ categories:
|
|
88
88
|
- zendesk_category: '<%zendesk-category-id%>'
|
89
89
|
translations:
|
90
90
|
-
|
91
|
-
crowdin_language_code: '<%crowdin-
|
92
|
-
zendesk_locale: '<%zendesk-locale%>'
|
91
|
+
crowdin_language_code: '<%crowdin-language-code%>' #the full list of language codes: https://support.crowdin.com/api/language-codes/
|
92
|
+
zendesk_locale: '<%zendesk-locale%>' #the full list of language codes: https://support.zendesk.com/hc/en-us/articles/203761906-Language-codes-for-Zendesk-supported-languages
|
93
93
|
-
|
94
|
-
crowdin_language_code: '<%crowdin-
|
94
|
+
crowdin_language_code: '<%crowdin-language-code%>'
|
95
95
|
zendesk_locale: '<%zendesk-locale%>'
|
96
96
|
- zendesk_category: '<%zendesk-category-id%>'
|
97
97
|
translations:
|
98
98
|
-
|
99
|
-
crowdin_language_code: '<%crowdin-
|
99
|
+
crowdin_language_code: '<%crowdin-language-code%>'
|
100
100
|
zendesk_locale: '<%zendesk-locale%>'
|
101
101
|
-
|
102
|
-
crowdin_language_code: '<%crowdin-
|
102
|
+
crowdin_language_code: '<%crowdin-language-code%>'
|
103
103
|
zendesk_locale: '<%zendesk-locale%>'
|
104
104
|
```
|
105
105
|
|
106
|
+
## Advance Usage
|
107
|
+
|
108
|
+
This section covers some of `zci` more advanced features.
|
109
|
+
|
110
|
+
### Brands
|
111
|
+
|
112
|
+
To make changes and updates via the `Help Center API` in your branded `Help Centers` you will use the URL of the specific brand.
|
113
|
+
|
114
|
+
For more information, see [Managing multiple brands](https://support.zendesk.com/hc/en-us/articles/204577973-Managing-multiple-brands-Professional-Add-on-and-Enterprise-).
|
115
|
+
|
116
|
+
```yaml
|
117
|
+
---
|
118
|
+
categories:
|
119
|
+
- zendesk_category: '<%zendesk-category-id%>'
|
120
|
+
brand_url: '<%zendesk-brand-url%>/api/v2/'
|
121
|
+
```
|
122
|
+
|
106
123
|
## Supported Rubies
|
107
124
|
|
108
125
|
Tested with the following Ruby versions:
|
data/bin/zci
CHANGED
@@ -47,18 +47,13 @@ pre do |global, command, options, args|
|
|
47
47
|
EOS
|
48
48
|
end
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
config.logger = Logger.new(STDOUT)
|
58
|
-
end
|
59
|
-
|
60
|
-
config.client_options = {ssl: {verify: false}}
|
61
|
-
end
|
50
|
+
# Global Zendesk Client
|
51
|
+
@zendesk = ZCI.initialize_zendesk_client(
|
52
|
+
@cli_config['zendesk_base_url'],
|
53
|
+
@cli_config['zendesk_username'],
|
54
|
+
@cli_config['zendesk_password'],
|
55
|
+
global[:verbose]
|
56
|
+
)
|
62
57
|
|
63
58
|
if global[:verbose]
|
64
59
|
Crowdin::API.log = Logger.new(STDOUT) if global[:verbose]
|
@@ -16,11 +16,20 @@ command :'import:sources' do |c|
|
|
16
16
|
end
|
17
17
|
|
18
18
|
@cli_config['categories'].each do |category|
|
19
|
+
zendesk_url = category.fetch('brand_url', @cli_config['zendesk_base_url'])
|
20
|
+
|
21
|
+
zendesk_client = ZCI.initialize_zendesk_client(
|
22
|
+
zendesk_url,
|
23
|
+
@cli_config['zendesk_username'],
|
24
|
+
@cli_config['zendesk_password'],
|
25
|
+
global_options[:verbose]
|
26
|
+
)
|
27
|
+
|
19
28
|
# Source Category
|
20
29
|
source_category_id = category['zendesk_category'].to_i
|
21
30
|
|
22
31
|
# Check if Category exists in Zendesk
|
23
|
-
source_category =
|
32
|
+
source_category = zendesk_client.hc_categories.find(id: source_category_id)
|
24
33
|
|
25
34
|
if source_category.nil? || source_category.id != source_category_id
|
26
35
|
puts "[Zendesk] No category with id #{source_category_id}"
|
@@ -19,13 +19,22 @@ command :'export:translations' do |c|
|
|
19
19
|
|
20
20
|
crowdin_supported_languages = @crowdin.supported_languages
|
21
21
|
|
22
|
-
if language == 'all'
|
23
|
-
zendesk_locales = @zendesk.locales
|
24
|
-
else
|
25
|
-
zendesk_locales = @zendesk.locales.select { |locale| locale.locale == language }
|
26
|
-
end
|
27
|
-
|
28
22
|
@cli_config['categories'].each do |category_section|
|
23
|
+
zendesk_url = category.fetch('brand_url', @cli_config['zendesk_base_url'])
|
24
|
+
|
25
|
+
zendesk_client = ZCI.initialize_zendesk_client(
|
26
|
+
zendesk_url,
|
27
|
+
@cli_config['zendesk_username'],
|
28
|
+
@cli_config['zendesk_password'],
|
29
|
+
global_options[:verbose]
|
30
|
+
)
|
31
|
+
|
32
|
+
if language == 'all'
|
33
|
+
zendesk_locales = zendesk_client.locales
|
34
|
+
else
|
35
|
+
zendesk_locales = zendesk_client.locales.select { |locale| locale.locale == language }
|
36
|
+
end
|
37
|
+
|
29
38
|
zendesk_locales.select { |locale| !locale.default? }.each do |locale|
|
30
39
|
if lang = category_section['translations'].detect { |tr| tr['zendesk_locale'].casecmp(locale.locale) == 0 }
|
31
40
|
crowdin_locale = crowdin_supported_languages.detect { |l| l['crowdin_code'] == lang['crowdin_language_code'] }['locale']
|
@@ -61,7 +70,7 @@ command :'export:translations' do |c|
|
|
61
70
|
|
62
71
|
### Categories
|
63
72
|
#
|
64
|
-
categories =
|
73
|
+
categories = zendesk_client.hc_categories
|
65
74
|
all_categories.each do |category_hash|
|
66
75
|
if category = categories.find(id: category_hash[:id])
|
67
76
|
if category_tr = category.translations.detect { |tr| tr.locale.casecmp(locale.locale) == 0 }
|
@@ -80,7 +89,7 @@ command :'export:translations' do |c|
|
|
80
89
|
|
81
90
|
### Sections
|
82
91
|
#
|
83
|
-
sections =
|
92
|
+
sections = zendesk_client.sections
|
84
93
|
all_sections.each do |section_hash|
|
85
94
|
if section = sections.find(id: section_hash[:id])
|
86
95
|
if section_tr = section.translations.detect { |tr| tr.locale.casecmp(locale.locale) == 0 }
|
data/lib/zci/commands/06_info.rb
CHANGED
@@ -21,19 +21,35 @@ command :'project:info' do |c|
|
|
21
21
|
# Zendesk
|
22
22
|
if @zendesk.current_user.id
|
23
23
|
puts "Zendesk: authentication successful."
|
24
|
-
|
24
|
+
brands = @zendesk.brands
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
brands.each do |brand|
|
27
|
+
puts "Zendesk URL: #{brand.brand_url}"
|
28
|
+
|
29
|
+
zendesk_url = brand.brand_url + "/api/v2"
|
30
|
+
|
31
|
+
zendesk_client = ZCI.initialize_zendesk_client(
|
32
|
+
zendesk_url,
|
33
|
+
@cli_config['zendesk_username'],
|
34
|
+
@cli_config['zendesk_password'],
|
35
|
+
global_options[:verbose]
|
36
|
+
)
|
30
37
|
|
31
|
-
|
38
|
+
locales = zendesk_client.locales
|
39
|
+
categories = zendesk_client.hc_categories
|
32
40
|
|
33
|
-
|
34
|
-
|
35
|
-
|
41
|
+
puts " available categories:"
|
42
|
+
categories.each do |category|
|
43
|
+
puts " - #{category.id}: #{category.name}"
|
44
|
+
end
|
45
|
+
|
46
|
+
puts " available locales:"
|
47
|
+
locales.each do |locale|
|
48
|
+
puts " - #{locale.locale}"
|
49
|
+
end
|
50
|
+
puts
|
36
51
|
end
|
52
|
+
|
37
53
|
else
|
38
54
|
puts "Zendesk: login and/or password is incorect"
|
39
55
|
end
|
data/lib/zci/helpers.rb
CHANGED
@@ -5,6 +5,23 @@ class String
|
|
5
5
|
end
|
6
6
|
end
|
7
7
|
|
8
|
+
module ZCI
|
9
|
+
def initialize_zendesk_client(base_url, username, password, verbose)
|
10
|
+
ZendeskAPI::Client.new do |config|
|
11
|
+
config.url = base_url
|
12
|
+
config.username = username
|
13
|
+
config.password = password
|
14
|
+
|
15
|
+
if verbose
|
16
|
+
require 'logger'
|
17
|
+
config.logger = Logger.new(STDOUT)
|
18
|
+
end
|
19
|
+
|
20
|
+
config.client_options = {ssl: {verify: false}}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
8
25
|
# Return +hierarchy+ of directories and files in Crowdin project
|
9
26
|
#
|
10
27
|
# +files+ - basically, it's project files details from API method `project_info`
|
data/lib/zci/init.rb
CHANGED
@@ -47,18 +47,18 @@ module ZCI
|
|
47
47
|
- zendesk_category: '<%zendesk-category-id%>'
|
48
48
|
translations:
|
49
49
|
-
|
50
|
-
crowdin_language_code: '<%crowdin-
|
51
|
-
zendesk_locale: '<%zendesk-locale%>'
|
50
|
+
crowdin_language_code: '<%crowdin-language-code%>' # the full list: https://support.crowdin.com/api/language-codes/
|
51
|
+
zendesk_locale: '<%zendesk-locale%>' # the full list: https://support.zendesk.com/hc/en-us/articles/203761906-Language-codes-for-Zendesk-supported-languages
|
52
52
|
-
|
53
|
-
crowdin_language_code: '<%crowdin-
|
53
|
+
crowdin_language_code: '<%crowdin-language-code%%>'
|
54
54
|
zendesk_locale: '<%zendesk-locale%>'
|
55
55
|
- zendesk_category: '<%zendesk-category-id%>'
|
56
56
|
translations:
|
57
57
|
-
|
58
|
-
crowdin_language_code: '<%crowdin-
|
58
|
+
crowdin_language_code: '<%crowdin-language-code%%>'
|
59
59
|
zendesk_locale: '<%zendesk-locale%>'
|
60
60
|
-
|
61
|
-
crowdin_language_code: '<%crowdin-
|
61
|
+
crowdin_language_code: '<%crowdin-language-code%%>'
|
62
62
|
zendesk_locale: '<%zendesk-locale%>'
|
63
63
|
EOS
|
64
64
|
|
data/lib/zci/version.rb
CHANGED
data/lib/zci.rb
CHANGED
data/zci.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zci
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Maminov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0.14'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: pry
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 0.12.2
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 0.12.2
|
125
139
|
description:
|
126
140
|
email: anton.maminov@gmail.com
|
127
141
|
executables:
|