phraseapp_updater 3.0.0 → 3.1.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/bin/phraseapp_updater +21 -2
- data/lib/phraseapp_updater/phraseapp_api.rb +1 -1
- data/lib/phraseapp_updater/version.rb +1 -1
- data/lib/phraseapp_updater.rb +12 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f010eea4d5b1504c18facc0756b88021d87d207b7942ad66b30aee3800fbb82f
|
4
|
+
data.tar.gz: c1e0d6146fbadda3d36bcc622e8889de17072be9c5172e71c3a9545854f956be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aac0c0be65646c83f608fca0ab7f5b45cdc0d7c0f58cf11eab1efbe714b709557a76de7082062c213d415f7153482fbeca3311c3a6a3152e0e6c10d012781c3d
|
7
|
+
data.tar.gz: 29fd576ce2a3fb249689a01f3d648b5e7f80992f7a55f702ed802054d5b8419ae4b8bb0ae4d1bd1d4782c7c031d9e72d5a2cdb70e17051b8dbc896c666ba95f3
|
data/bin/phraseapp_updater
CHANGED
@@ -14,6 +14,7 @@ class PhraseAppUpdaterCLI < Thor
|
|
14
14
|
method_option :phraseapp_api_key, type: :string, required: true, desc: 'PhraseApp API key.'
|
15
15
|
method_option :phraseapp_project_name, type: :string, required: true, desc: 'Name for new PhraseApp project.'
|
16
16
|
method_option :parent_commit, type: :string, required: true, desc: 'git commit hash of initial locales'
|
17
|
+
method_option :remove_orphans, type: :boolean, default: true, desc: 'Remove keys not in the uploaded default locale'
|
17
18
|
|
18
19
|
def setup(locales_path)
|
19
20
|
validate_readable_path!('locales', locales_path)
|
@@ -26,7 +27,7 @@ class PhraseAppUpdaterCLI < Thor
|
|
26
27
|
options[:parent_commit],
|
27
28
|
verbose: options[:verbose])
|
28
29
|
|
29
|
-
updater.upload_directory(locales_path)
|
30
|
+
updater.upload_directory(locales_path, remove_orphans: options[:remove_orphans])
|
30
31
|
|
31
32
|
puts project_id
|
32
33
|
end
|
@@ -104,6 +105,7 @@ class PhraseAppUpdaterCLI < Thor
|
|
104
105
|
method_option :phraseapp_api_key, type: :string, required: true, desc: 'PhraseApp API key.'
|
105
106
|
method_option :phraseapp_project_id, type: :string, required: true, desc: 'PhraseApp project ID.'
|
106
107
|
method_option :parent_commit, type: :string, required: true, desc: 'git commit hash of locales being uploaded'
|
108
|
+
method_option :remove_orphans, type: :boolean, default: true, desc: 'Remove keys not in the uploaded default locale'
|
107
109
|
|
108
110
|
def upload(source_path)
|
109
111
|
validate_readable_path!('source path', source_path)
|
@@ -115,7 +117,7 @@ class PhraseAppUpdaterCLI < Thor
|
|
115
117
|
options[:file_format],
|
116
118
|
verbose: options[:verbose])
|
117
119
|
|
118
|
-
updater.upload_directory(source_path)
|
120
|
+
updater.upload_directory(source_path, remove_orphans: options[:remove_orphans])
|
119
121
|
updater.update_parent_commit(options[:parent_commit])
|
120
122
|
end
|
121
123
|
end
|
@@ -162,6 +164,23 @@ class PhraseAppUpdaterCLI < Thor
|
|
162
164
|
end
|
163
165
|
end
|
164
166
|
|
167
|
+
desc 'normalize <source_path> <destination_path>',
|
168
|
+
'Normalize the locale directory at <source_path> into <destination_path>.'
|
169
|
+
|
170
|
+
long_desc <<-LONGDESC
|
171
|
+
Read, normalize, then write out the locales in <source_path> into <destination_path>.
|
172
|
+
LONGDESC
|
173
|
+
|
174
|
+
def normalize(source_path, destination_path)
|
175
|
+
validate_readable_path!('source_path', source_path)
|
176
|
+
validate_writable_path!('destination_path', destination_path)
|
177
|
+
|
178
|
+
handle_errors do
|
179
|
+
updater = PhraseAppUpdater.new(nil, nil, options[:file_format], verbose: options[:verbose])
|
180
|
+
updater.normalize_directory(source_path, destination_path)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
165
184
|
desc 'merge <ancestor_path> <our_path> <their_path>',
|
166
185
|
'3-way merge locale file directories <ancestor_path>, <our_path>, <their_path> into TO.'
|
167
186
|
|
@@ -41,7 +41,7 @@ class PhraseAppUpdater
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def lookup_project_id(name)
|
44
|
-
result, = paginated_request(Phrase::ProjectsApi, :projects_list,
|
44
|
+
result, = paginated_request(Phrase::ProjectsApi, :projects_list, per_page: PAGE_SIZE, limit: 1) { |p| p.name == name }
|
45
45
|
|
46
46
|
raise ProjectNotFoundError.new(name) if result.nil?
|
47
47
|
|
data/lib/phraseapp_updater.rb
CHANGED
@@ -52,9 +52,9 @@ class PhraseAppUpdater
|
|
52
52
|
write_locale_file(result, result_file)
|
53
53
|
end
|
54
54
|
|
55
|
-
def upload_directory(path)
|
55
|
+
def upload_directory(path, remove_orphans: true)
|
56
56
|
locales = load_locale_directory(path)
|
57
|
-
upload_locale_files(locales)
|
57
|
+
upload_locale_files(locales, remove_orphans: remove_orphans)
|
58
58
|
end
|
59
59
|
|
60
60
|
def download_to_directory(path)
|
@@ -62,6 +62,11 @@ class PhraseAppUpdater
|
|
62
62
|
write_locale_directory(path, locale_files)
|
63
63
|
end
|
64
64
|
|
65
|
+
def normalize_directory(source, destination)
|
66
|
+
locales = load_locale_directory(source)
|
67
|
+
write_locale_directory(destination, locales)
|
68
|
+
end
|
69
|
+
|
65
70
|
def update_parent_commit(parent_commit)
|
66
71
|
@phraseapp_api.update_parent_commit(parent_commit)
|
67
72
|
end
|
@@ -98,7 +103,7 @@ class PhraseAppUpdater
|
|
98
103
|
end
|
99
104
|
end
|
100
105
|
|
101
|
-
def upload_locale_files(locale_files)
|
106
|
+
def upload_locale_files(locale_files, remove_orphans: true)
|
102
107
|
# We assert that the default locale contains all legitimate strings, and so
|
103
108
|
# we clean up orphaned content on PhraseApp post-upload by removing keys not
|
104
109
|
# in the default locale.
|
@@ -109,8 +114,10 @@ class PhraseAppUpdater
|
|
109
114
|
upload_ids = @phraseapp_api.upload_files(locale_files, default_locale: @default_locale)
|
110
115
|
default_upload_id = upload_ids.fetch(@default_locale)
|
111
116
|
|
112
|
-
|
113
|
-
|
117
|
+
if remove_orphans
|
118
|
+
STDERR.puts "Removing keys not in default locale '#{@default_locale}' upload '#{default_upload_id}'"
|
119
|
+
@phraseapp_api.remove_keys_not_in_upload(default_upload_id)
|
120
|
+
end
|
114
121
|
end
|
115
122
|
|
116
123
|
def download_locale_files
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phraseapp_updater
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- iKnow Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|