toptranslation_cli 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/tests.yml +22 -0
- data/.gitignore +57 -0
- data/.rspec +2 -0
- data/.rubocop.yml +5 -0
- data/CHANGELOG.md +60 -0
- data/Gemfile +5 -0
- data/LICENSE +21 -0
- data/README.md +154 -0
- data/Rakefile +10 -0
- data/exe/tt +67 -0
- data/lib/toptranslation_cli.rb +34 -0
- data/lib/toptranslation_cli/check.rb +101 -0
- data/lib/toptranslation_cli/configuration.rb +52 -0
- data/lib/toptranslation_cli/file_finder.rb +57 -0
- data/lib/toptranslation_cli/info.rb +28 -0
- data/lib/toptranslation_cli/initializer.rb +125 -0
- data/lib/toptranslation_cli/placeholder_path.rb +40 -0
- data/lib/toptranslation_cli/pull.rb +101 -0
- data/lib/toptranslation_cli/push.rb +139 -0
- data/lib/toptranslation_cli/status.rb +62 -0
- data/lib/toptranslation_cli/threaded.rb +25 -0
- data/lib/toptranslation_cli/version.rb +5 -0
- data/toptranslation_cli.gemspec +37 -0
- metadata +221 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: defb641490501211a681e34f71c9f977d19829c3d9cb806d5a862ac34ea2a51f
|
4
|
+
data.tar.gz: 9f09c3b6f69b06edc69e2bb9a68f5e8033d996395e52998769ebe817ad5db2fb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 45521958d418d25fd2c6b4064835c58c8a7d21ee48fd9adc752c8157066a83d9d2dc538cf4014730c0c1b8b987081aac05d7a247e66917c0e2f48f5b5161cb24
|
7
|
+
data.tar.gz: a9db0159effc82e260e9abe6ce288e332cc93a980ccbb320b5a1c1bf250ae771ef94945c1298b8503b422f3d07ec40ba39c3ace5aab7b3a73d6b17b4f5db3acb
|
@@ -0,0 +1,22 @@
|
|
1
|
+
name: Tests
|
2
|
+
|
3
|
+
on: [push]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
|
9
|
+
steps:
|
10
|
+
- uses: actions/checkout@v1
|
11
|
+
- name: Set up Ruby 2.6
|
12
|
+
uses: actions/setup-ruby@v1
|
13
|
+
with:
|
14
|
+
ruby-version: 2.6.x
|
15
|
+
|
16
|
+
- name: Bundle install
|
17
|
+
run: |
|
18
|
+
gem install bundler
|
19
|
+
bundle install --jobs 4 --retry 3
|
20
|
+
|
21
|
+
- name: Run RSpec and Rubocop
|
22
|
+
run: bundle exec rake
|
data/.gitignore
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
## Specific to RubyMotion:
|
17
|
+
.dat*
|
18
|
+
.repl_history
|
19
|
+
build/
|
20
|
+
*.bridgesupport
|
21
|
+
build-iPhoneOS/
|
22
|
+
build-iPhoneSimulator/
|
23
|
+
|
24
|
+
## Specific to RubyMotion (use of CocoaPods):
|
25
|
+
#
|
26
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
27
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
28
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
29
|
+
#
|
30
|
+
# vendor/Pods/
|
31
|
+
|
32
|
+
## Documentation cache and generated files:
|
33
|
+
/.yardoc/
|
34
|
+
/_yardoc/
|
35
|
+
/doc/
|
36
|
+
/rdoc/
|
37
|
+
|
38
|
+
## Environment normalization:
|
39
|
+
/.bundle/
|
40
|
+
/vendor/bundle
|
41
|
+
/lib/bundler/man/
|
42
|
+
|
43
|
+
# for a library or gem, you might want to ignore these files since the code is
|
44
|
+
# intended to run in multiple environments; otherwise, check them in:
|
45
|
+
# Gemfile.lock
|
46
|
+
# .ruby-version
|
47
|
+
# .ruby-gemset
|
48
|
+
|
49
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
50
|
+
.rvmrc
|
51
|
+
|
52
|
+
.toptranslation.yml
|
53
|
+
|
54
|
+
# Rubocop remote config
|
55
|
+
.rubocop-*
|
56
|
+
|
57
|
+
Gemfile.lock
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
<a name="1.0.0"></a>
|
2
|
+
### 1.0.0 (2019-10-08)
|
3
|
+
|
4
|
+
#### Features
|
5
|
+
|
6
|
+
* show spinners for tt pull ([f798e74](/../commit/f798e74))
|
7
|
+
* show spinners for tt push ([65b4386](/../commit/65b4386))
|
8
|
+
* show spinner while fetching projects ([a30b512](/../commit/a30b512))
|
9
|
+
* preselect project guessed from pwd in tt init ([ecefdd6](/../commit/ecefdd6))
|
10
|
+
* show spinner while signing in from tt init ([1ed6da3](/../commit/1ed6da3))
|
11
|
+
* make tt init interactive ([01ce165](/../commit/01ce165))
|
12
|
+
* show progress bar for tt push ([9bb8369](/../commit/9bb8369))
|
13
|
+
* show progressbar for tt pull ([05bba1c](/../commit/05bba1c))
|
14
|
+
* add tt status command ([f265e64](/../commit/f265e64))
|
15
|
+
* use .toptranslation.yml as config file ([7a2ea17](/../commit/7a2ea17))
|
16
|
+
* don't swallow errors silently ([a31ed4a](/../commit/a31ed4a))
|
17
|
+
* show help message when no command is given ([0363b3e](/../commit/0363b3e))
|
18
|
+
|
19
|
+
#### Bug Fixes
|
20
|
+
|
21
|
+
* upload translations for the same document sequentially ([3183693](/../commit/3183693))
|
22
|
+
* fix deadlock issue by fetching all documents beforehand ([f713136](/../commit/f713136))
|
23
|
+
* correctly specify file format when downloading document ([c58fbba](/../commit/c58fbba))
|
24
|
+
* get identifier from created document ([15f0e45](/../commit/15f0e45))
|
25
|
+
* make sure help works with a subcommand ([af75810](/../commit/af75810))
|
26
|
+
* fix configuration spec ([e3d9c8d](/../commit/e3d9c8d))
|
27
|
+
* load gemspec from Gemfile ([7ff98a4](/../commit/7ff98a4))
|
28
|
+
|
29
|
+
#### maintain
|
30
|
+
|
31
|
+
* use github actions instead of travis-ci ([fb0763f](/../commit/fb0763f))
|
32
|
+
* list projects in tt init in alphabetical order ([bfd7a63](/../commit/bfd7a63))
|
33
|
+
* update .rubocop-todo.yml ([feab797](/../commit/feab797))
|
34
|
+
* remove paint and use pastel everywhere ([60e364c](/../commit/60e364c))
|
35
|
+
* calculate sha1 sums of local files before uploading ([5c70218](/../commit/5c70218))
|
36
|
+
* update toptranslation_api to 2.3 ([1de342c](/../commit/1de342c))
|
37
|
+
* don't set file_type when pulling ([918cb9d](/../commit/918cb9d))
|
38
|
+
* use toptranslation_api ~> 2.2 ([ffe9159](/../commit/ffe9159))
|
39
|
+
* use Thor to handle command line options ([b29c729](/../commit/b29c729))
|
40
|
+
* set required ruby version to >= 2.3 ([e980f2e](/../commit/e980f2e))
|
41
|
+
* run non-verbose by default to avoid leaking access tokens ([f1a1348](/../commit/f1a1348))
|
42
|
+
* use some sensible rspec settings from bundlers default config ([92ed15c](/../commit/92ed15c))
|
43
|
+
* use pry ([e0b200c](/../commit/e0b200c))
|
44
|
+
* update to toptranslation_api ~> 2.0 ([e3960c3](/../commit/e3960c3))
|
45
|
+
* add rubocop to default rake task ([11de902](/../commit/11de902))
|
46
|
+
* specify rubocop and rubocop-rspec version ([c513de0](/../commit/c513de0))
|
47
|
+
* update MIT license Copyright ([e6f03cc](/../commit/e6f03cc))
|
48
|
+
* remote Gemfile.lock ([17cfaa5](/../commit/17cfaa5))
|
49
|
+
* use travis-ci ([90c4ffd](/../commit/90c4ffd))
|
50
|
+
* add .ruby-version file ([0bbf497](/../commit/0bbf497))
|
51
|
+
* change toptranslation_api git url to github ([b2fa1d5](/../commit/b2fa1d5))
|
52
|
+
|
53
|
+
#### formatting, missing semi colons, …
|
54
|
+
|
55
|
+
* fix rubocop offenses from .rubocop_todoy.yml ([f1fb401](/../commit/f1fb401))
|
56
|
+
* satisfy rubocop ([608186c](/../commit/608186c))
|
57
|
+
* change rubocop target ruby version to 2.3 ([1826381](/../commit/1826381))
|
58
|
+
* use rubocop ([68af8ce](/../commit/68af8ce))
|
59
|
+
* some refactoring based on the output of `bundle gem` ([1177161](/../commit/1177161))
|
60
|
+
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 Toptranslation GmbH
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
# toptranslation_cli
|
2
|
+
Gem to provide a command line tool for synching documents with the Toptranslation translations service.
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
Install `toptranslation_cli` via `gem install`
|
7
|
+
|
8
|
+
```
|
9
|
+
$ gem install toptranslation_cli
|
10
|
+
```
|
11
|
+
|
12
|
+
or add it as a dependency to your project's Gemfile
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'toptranslation_cli', group: :development
|
16
|
+
```
|
17
|
+
|
18
|
+
## Configuration
|
19
|
+
|
20
|
+
Configuration is stored in `.toptranslation.yml`. A configuration can be created with [`$ tt init`](#initialization). The configuration can be checked with [`$ tt check`](#check-configuration).
|
21
|
+
|
22
|
+
### Example configuration
|
23
|
+
|
24
|
+
An example configuration file `.toptranslation.yml:
|
25
|
+
|
26
|
+
```yaml
|
27
|
+
project_identifier: "<PROJECT_IDENTIFIER>"
|
28
|
+
access_token: "<YOUR_ACCESS_TOKEN>"
|
29
|
+
files:
|
30
|
+
- config/locales/{locale_code}/**/*.yml # matches config/locales/en/foo.yml
|
31
|
+
- config/locales/**/*.{locale_code}.yml # matches config/locales/foo.en.yml
|
32
|
+
```
|
33
|
+
|
34
|
+
#### Used attributes:
|
35
|
+
+ **project_identifier** - Identifier of the synched project (see project settings in Toptranslation dashboard)
|
36
|
+
+ **access_token** - An access token used for authentication (see project settings in Toptranslation dashboard)
|
37
|
+
+ **files** - An array of paths that will be used to find documents to be synched. The path attribute may use wildcards like `/**/` or `*.yml` and placeholders (see below).
|
38
|
+
|
39
|
+
#### Placeholders in paths
|
40
|
+
|
41
|
+
+ **{locale_code}** - Will be replaced with the locale code of project locales
|
42
|
+
|
43
|
+
## Usage
|
44
|
+
|
45
|
+
### Initialization
|
46
|
+
|
47
|
+
Starts an interactive configuration dialog that will generate a `.toptranslation.yml` configuration.
|
48
|
+
|
49
|
+
```
|
50
|
+
tt init
|
51
|
+
```
|
52
|
+
|
53
|
+
[![asciicast](https://asciinema.org/a/3wFSWXz5Z7YCDQB1necBXsSoc.png)](https://asciinema.org/a/3wFSWXz5Z7YCDQB1necBXsSoc)
|
54
|
+
|
55
|
+
### Check configuration
|
56
|
+
|
57
|
+
Checks configuration settings in `.toptranslation.yml` and counts files matching the file path definitions (see configuration).
|
58
|
+
|
59
|
+
```bash
|
60
|
+
$ tt check
|
61
|
+
Toptranslation command line client, version 1.0.0 - Configuration check
|
62
|
+
|
63
|
+
Configuration file present: ok
|
64
|
+
* includes access_token: ok
|
65
|
+
* includes project_identifier: ok
|
66
|
+
* includes files: ok
|
67
|
+
|
68
|
+
Matching files:
|
69
|
+
* config/locales/{locale_code}/**/*.yml: 3 matching files
|
70
|
+
```
|
71
|
+
|
72
|
+
### Status
|
73
|
+
|
74
|
+
Shows which files differ or exist only locally/remotely.
|
75
|
+
|
76
|
+
```bash
|
77
|
+
$ tt status
|
78
|
+
Local: These documents exist only locally
|
79
|
+
|
80
|
+
config/locales/de/new.yml
|
81
|
+
|
82
|
+
Changed: These documents exist both locally and remotely but differ
|
83
|
+
|
84
|
+
config/locales/en/changed.yml
|
85
|
+
|
86
|
+
Remote: These documents exist only remotely
|
87
|
+
|
88
|
+
config/locales/fr/foo.yml
|
89
|
+
```
|
90
|
+
|
91
|
+
### Push local documents
|
92
|
+
|
93
|
+
Pushes locals translations to Toptranslation.
|
94
|
+
|
95
|
+
```bash
|
96
|
+
$ tt push
|
97
|
+
```
|
98
|
+
|
99
|
+
[![asciicast](https://asciinema.org/a/3HT7WtvkQG3Zs3XO3orBeOdb3.svg)](https://asciinema.org/a/3HT7WtvkQG3Zs3XO3orBeOdb3)
|
100
|
+
|
101
|
+
### Pull remote translations
|
102
|
+
|
103
|
+
Pulls translations from Toptranslation and overwrites local translations.
|
104
|
+
|
105
|
+
```bash
|
106
|
+
$ tt pull
|
107
|
+
```
|
108
|
+
|
109
|
+
[![asciicast](https://asciinema.org/a/MrW1FGaAgljvWO3r9V6mCa3Pi.svg)](https://asciinema.org/a/MrW1FGaAgljvWO3r9V6mCa3Pi)
|
110
|
+
|
111
|
+
### Help
|
112
|
+
|
113
|
+
Display help page with usage instructions, examples and contact options.
|
114
|
+
|
115
|
+
```
|
116
|
+
$ tt help
|
117
|
+
Toptranslation command line client, version 0.2.0
|
118
|
+
|
119
|
+
tt commands:
|
120
|
+
tt check # Check current configuration
|
121
|
+
tt help # Print usage information
|
122
|
+
tt init # Create a .toptranslation.yml configuration
|
123
|
+
tt pull # Download remote translations, overwriting local documents
|
124
|
+
tt push # Upload local documents
|
125
|
+
tt status # Show local documents that differ from remote documents
|
126
|
+
tt version # Print version
|
127
|
+
|
128
|
+
twitter:
|
129
|
+
@tt_developers (https://twitter.com/tt_developers)
|
130
|
+
|
131
|
+
websites:
|
132
|
+
https://www.toptranslation.com
|
133
|
+
https://developer.toptranslation.com
|
134
|
+
https://github.com/Toptranslation/tt_cli
|
135
|
+
```
|
136
|
+
|
137
|
+
### Version
|
138
|
+
|
139
|
+
Displays the current version of this software.
|
140
|
+
|
141
|
+
```
|
142
|
+
$ tt version
|
143
|
+
Toptranslation command line client, version 0.2.0
|
144
|
+
```
|
145
|
+
|
146
|
+
## Contact
|
147
|
+
Web: [https://developer.toptranslation.com](https://developer.toptranslation.com) or
|
148
|
+
[https://www.toptranslation.com](https://www.toptranslation.com)
|
149
|
+
|
150
|
+
Github: [https://www.github.com/toptranslation](https://www.github.com/toptranslation)
|
151
|
+
|
152
|
+
Twitter: [@tt_developers](http://www.twitter.com/tt_developers) or [@toptranslation](http://www.twitter.com/toptranslation)
|
153
|
+
|
154
|
+
Mail: tech@toptranslation.com
|
data/Rakefile
ADDED
data/exe/tt
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'toptranslation_cli'
|
5
|
+
require 'thor'
|
6
|
+
|
7
|
+
class Tt < Thor
|
8
|
+
package_name :tt
|
9
|
+
|
10
|
+
desc :check, 'Check current configuration'
|
11
|
+
def check
|
12
|
+
ToptranslationCli::Check.run
|
13
|
+
end
|
14
|
+
|
15
|
+
desc :help, 'Print usage information'
|
16
|
+
def help(*args, **kwargs)
|
17
|
+
return super(*args, **kwargs) if !args.empty? || !kwargs.empty?
|
18
|
+
|
19
|
+
version
|
20
|
+
|
21
|
+
# We need to call super without arguments
|
22
|
+
super()
|
23
|
+
|
24
|
+
puts <<~URLS
|
25
|
+
twitter:
|
26
|
+
@tt_developers (https://twitter.com/tt_developers)
|
27
|
+
|
28
|
+
websites:
|
29
|
+
https://www.toptranslation.com
|
30
|
+
https://developer.toptranslation.com
|
31
|
+
https://github.com/Toptranslation/tt_cli
|
32
|
+
URLS
|
33
|
+
end
|
34
|
+
|
35
|
+
desc :init, "Create a #{ToptranslationCli::Configuration::FILENAME} configuration"
|
36
|
+
def init
|
37
|
+
ToptranslationCli::Initializer.run
|
38
|
+
end
|
39
|
+
|
40
|
+
desc :push, 'Upload local documents'
|
41
|
+
def push
|
42
|
+
ToptranslationCli::Push.run
|
43
|
+
end
|
44
|
+
|
45
|
+
desc :pull, 'Download remote translations, overwriting local documents'
|
46
|
+
def pull
|
47
|
+
ToptranslationCli::Pull.run
|
48
|
+
end
|
49
|
+
|
50
|
+
desc :status, 'Show local documents that differ from remote documents'
|
51
|
+
method_option :exit_code,
|
52
|
+
type: :boolean,
|
53
|
+
default: false,
|
54
|
+
desc: 'Set the return code to the total number of changed files'
|
55
|
+
def status
|
56
|
+
changed_documents_amount = ToptranslationCli::Status.run
|
57
|
+
exit changed_documents_amount if options[:exit_code]
|
58
|
+
end
|
59
|
+
|
60
|
+
desc :version, 'Print version'
|
61
|
+
def version
|
62
|
+
puts "Toptranslation command line client, version #{ToptranslationCli::VERSION}"
|
63
|
+
puts ''
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
Tt.start(ARGV)
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'psych'
|
4
|
+
require 'toptranslation_api'
|
5
|
+
|
6
|
+
require 'toptranslation_cli/threaded'
|
7
|
+
|
8
|
+
require 'toptranslation_cli/check'
|
9
|
+
require 'toptranslation_cli/configuration'
|
10
|
+
require 'toptranslation_cli/file_finder'
|
11
|
+
require 'toptranslation_cli/info'
|
12
|
+
require 'toptranslation_cli/initializer'
|
13
|
+
require 'toptranslation_cli/placeholder_path'
|
14
|
+
require 'toptranslation_cli/pull'
|
15
|
+
require 'toptranslation_cli/push'
|
16
|
+
require 'toptranslation_cli/status'
|
17
|
+
require 'toptranslation_cli/version'
|
18
|
+
|
19
|
+
module ToptranslationCli
|
20
|
+
class << self
|
21
|
+
attr_writer :configuration
|
22
|
+
|
23
|
+
def configuration
|
24
|
+
@configuration ||= Configuration.new
|
25
|
+
end
|
26
|
+
|
27
|
+
def connection
|
28
|
+
@connection ||= Toptranslation.new(access_token: configuration.access_token,
|
29
|
+
base_url: configuration.api_base_url,
|
30
|
+
files_url: configuration.files_base_url,
|
31
|
+
verbose: configuration.verbose)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|