ios_polyglot_cli 2.5.1 → 2.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +3 -9
- data/exe/polyglot +4 -5
- data/lib/ios_polyglot_cli/api/translation_key.rb +1 -2
- data/lib/ios_polyglot_cli/commands/login.rb +2 -34
- data/lib/ios_polyglot_cli/error_handler.rb +11 -12
- data/lib/ios_polyglot_cli/helpers/general.rb +11 -14
- data/lib/ios_polyglot_cli/helpers/terminal.rb +14 -0
- data/lib/ios_polyglot_cli/io/config.rb +1 -2
- data/lib/ios_polyglot_cli/io/token.rb +2 -21
- data/lib/ios_polyglot_cli/version.rb +1 -1
- 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: e5ef5b818b290d761b77c3f37edf48458999400543c94d5a9d4cc653da7f04dc
|
4
|
+
data.tar.gz: 0fe76569b75cab810db5f9d6b11b574849539dc9d97fb4d7c43ccf6bd31d7add
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0af9226f9c4a90f44e477c2709fa5911c1ae7db8fefbcd87f0bd37c62a1a9f08d3cd6732a872dc2dae17fbee4288af525616615491fd9f2c0ed5f695384cef29
|
7
|
+
data.tar.gz: 1758a78103cc0e357b766ba990bfffcdaa0af44e4ad54643def4b768dd2fa09f6811f6a643e5b757d3b7a1247229bb61f7cfa3710ea5dccdc92caa676672cf66
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -24,17 +24,11 @@ You should see the output with all commands and their description.
|
|
24
24
|
|
25
25
|
## Usage
|
26
26
|
|
27
|
-
### Login
|
27
|
+
### Login
|
28
28
|
|
29
|
-
> Login command
|
30
|
-
> To obtain a new token then, please visit https://infinum.polyglothq.com, generate a new token under Settings and store
|
31
|
-
> it in your environment variables under POLYGLOT_TOKEN environment variable (or whatever variable your project is using).
|
29
|
+
> Login command is removed!
|
32
30
|
|
33
|
-
|
34
|
-
|
35
|
-
polyglot login
|
36
|
-
|
37
|
-
If your login action is successful, polyglot will ask you to store your Polyglot token to local environment variables, so you don’t have to enter your credentials every time when you use `polyglot` command.
|
31
|
+
To generate an Auth Token please visit https://infinum.polyglothq.com, generate a new token under Settings -> Security and store it in your environment variables under POLYGLOT_TOKEN environment variable (or whatever variable your project is using).
|
38
32
|
|
39
33
|
### Setup
|
40
34
|
|
data/exe/polyglot
CHANGED
@@ -10,9 +10,8 @@ program :version, PolyglotIos::VERSION
|
|
10
10
|
program :description, 'An iOS client for managing polyglot\'s translations.'
|
11
11
|
|
12
12
|
command :login do |c|
|
13
|
-
c.syntax = 'polyglot login
|
14
|
-
c.description = '
|
15
|
-
c.option '--url STRING', String, "URL of the Polyglot API. If not provided, #{PolyglotIos::DEFAULT_API_URL} will be used."
|
13
|
+
c.syntax = 'polyglot login'
|
14
|
+
c.description = 'Removed!!! Please generate an Auth Token from the Polyglot web and store it to env variable'
|
16
15
|
c.action do |_args, options|
|
17
16
|
PolyglotIos::ErrorHandler.rescuable do
|
18
17
|
PolyglotIos::Command::Login.init(options)
|
@@ -22,7 +21,7 @@ end
|
|
22
21
|
|
23
22
|
command :init do |c|
|
24
23
|
c.syntax = 'polyglot init [options]'
|
25
|
-
c.description = 'Sets up a polyglot.yml config for selected project
|
24
|
+
c.description = 'Sets up a polyglot.yml config for selected project'
|
26
25
|
c.option '--query STRING', String, 'Only show projects which name matches query string.'
|
27
26
|
c.option '--url STRING', String, "URL of the Polyglot API. If not provided, #{PolyglotIos::DEFAULT_API_URL} will be used."
|
28
27
|
c.option '--token STRING', String, "Auth token. If not provided, #{PolyglotIos::DEFAULT_TOKEN_ENVIRONMENT_VARIABLE} environment variable value will be used."
|
@@ -35,7 +34,7 @@ end
|
|
35
34
|
|
36
35
|
command :projects do |c|
|
37
36
|
c.syntax = 'polyglot projects [options]'
|
38
|
-
c.description = 'Lists all available polyglot projects with their IDs
|
37
|
+
c.description = 'Lists all available polyglot projects with their IDs'
|
39
38
|
c.option '--query STRING', String, 'Only show projects which name matches query string.'
|
40
39
|
c.option '--url STRING', String, "URL of the Polyglot API. If not provided, #{PolyglotIos::DEFAULT_API_URL} will be used."
|
41
40
|
c.option '--token STRING', String, "Auth token. If not provided, #{PolyglotIos::DEFAULT_TOKEN_ENVIRONMENT_VARIABLE} environment variable value will be used."
|
@@ -4,7 +4,7 @@ module PolyglotIos
|
|
4
4
|
|
5
5
|
def clean_translation(language)
|
6
6
|
translation_value = name
|
7
|
-
translation = translations.find { |key| key.language.id == language.id }
|
7
|
+
translation = (translations || []).find { |key| key.language.id == language.id }
|
8
8
|
if translation && translation.value
|
9
9
|
translation_value = translation.value
|
10
10
|
end
|
@@ -19,7 +19,6 @@ module PolyglotIos
|
|
19
19
|
.gsub("%s", "%@")
|
20
20
|
.gsub(/(%\d+)(\$)(s)/, '\1\2@') # Positional parameter support, converts %1$s to %1$@ for example
|
21
21
|
end
|
22
|
-
|
23
22
|
end
|
24
23
|
end
|
25
24
|
end
|
@@ -12,41 +12,9 @@ module PolyglotIos
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def call
|
15
|
-
|
15
|
+
prompt.error("Login command removed!\n")
|
16
|
+
prompt.warn(generate_token_message())
|
16
17
|
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def token
|
21
|
-
prompt.warn(<<~WARN
|
22
|
-
Login command will be deprecated soon!
|
23
|
-
To obtain a token, please visit https://infinum.polyglothq.com, generate a new token under Settings and store
|
24
|
-
it in your environment variables under #{PolyglotIos::DEFAULT_TOKEN_ENVIRONMENT_VARIABLE} variable.
|
25
|
-
zsh:
|
26
|
-
echo '\\nexport #{PolyglotIos::DEFAULT_TOKEN_ENVIRONMENT_VARIABLE}=<YOUR_AUTH_TOKEN>' >> ~/.zshrc
|
27
|
-
source ~/.zshrc
|
28
|
-
bash:
|
29
|
-
echo '\\nexport #{PolyglotIos::DEFAULT_TOKEN_ENVIRONMENT_VARIABLE}=<YOUR_AUTH_TOKEN>' >> ~/.bashrc
|
30
|
-
source ~/.bashrc
|
31
|
-
WARN
|
32
|
-
)
|
33
|
-
prompt.say('Logging into API...')
|
34
|
-
@data = PolyglotIos::Resource::Session.api_url(option_site_url).create(email: email, password: password)
|
35
|
-
@data.token
|
36
|
-
end
|
37
|
-
|
38
|
-
def email
|
39
|
-
prompt.ask('Email:') { |value| value.validate :email }
|
40
|
-
end
|
41
|
-
|
42
|
-
def password
|
43
|
-
prompt.mask('Password:')
|
44
|
-
end
|
45
|
-
|
46
|
-
def option_site_url
|
47
|
-
@option_site_url = @options.__hash__.fetch(:url, PolyglotIos::DEFAULT_API_URL)
|
48
|
-
end
|
49
|
-
|
50
18
|
end
|
51
19
|
end
|
52
20
|
end
|
@@ -10,18 +10,17 @@ module PolyglotIos
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def handle(e)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
)
|
13
|
+
case e
|
14
|
+
when JsonApiClient::Errors::NotAuthorized
|
15
|
+
prompt.error("You are not authorized. Please check your token and its validity.")
|
16
|
+
prompt.warn(generate_token_message())
|
17
|
+
when JsonApiClient::Errors::AccessDenied
|
18
|
+
prompt.error("You don't have the permission to access requested project.")
|
19
|
+
when Errno::ENOENT
|
20
|
+
prompt.error("We could not find a file that we need:\n\n#{e.message}")
|
21
|
+
else
|
22
|
+
prompt.error("An error happened. This might help:\n\n#{e.message}")
|
23
|
+
end
|
25
24
|
end
|
26
25
|
end
|
27
26
|
end
|
@@ -2,29 +2,26 @@ module PolyglotIos
|
|
2
2
|
module Helper
|
3
3
|
module General
|
4
4
|
include Terminal
|
5
|
-
ESCAPE_KEYWORDS = ["associatedtype", "class", "deinit", "enum", "extension", "fileprivate", "func",
|
6
|
-
"import", "init", "inout", "internal", "let", "operator", "private", "protocol",
|
7
|
-
"public", "static", "struct", "subscript", "typealias", "var", "break", "case",
|
8
|
-
"continue", "default", "defer", "do", "else", "fallthrough", "for", "guard", "if",
|
9
|
-
"in", "repeat", "return", "switch", "where", "while", "as", "Any", "catch", "false",
|
5
|
+
ESCAPE_KEYWORDS = ["associatedtype", "class", "deinit", "enum", "extension", "fileprivate", "func",
|
6
|
+
"import", "init", "inout", "internal", "let", "operator", "private", "protocol",
|
7
|
+
"public", "static", "struct", "subscript", "typealias", "var", "break", "case",
|
8
|
+
"continue", "default", "defer", "do", "else", "fallthrough", "for", "guard", "if",
|
9
|
+
"in", "repeat", "return", "switch", "where", "while", "as", "Any", "catch", "false",
|
10
10
|
"is", "nil", "rethrows", "super", "self", "Self", "throw", "throws", "true", "try", "_"]
|
11
11
|
def token
|
12
12
|
@token ||= PolyglotIos::IO::Token.read(token_env_variable)
|
13
13
|
if @token.to_s.empty?
|
14
|
-
prompt.error(
|
15
|
-
|
16
|
-
Please add your token to the environemnt variables under #{token_env_variable} or pass it as an argument --token <YOUR_AUTH_TOKENb>
|
17
|
-
MESSAGE
|
18
|
-
)
|
14
|
+
prompt.error("No Auth Token provided!\n")
|
15
|
+
prompt.warn(generate_token_message(token_env_variable))
|
19
16
|
exit
|
20
17
|
end
|
21
18
|
@token
|
22
19
|
end
|
23
|
-
|
20
|
+
|
24
21
|
def config
|
25
22
|
@config ||= PolyglotIos::IO::Config.read.with_indifferent_access
|
26
23
|
end
|
27
|
-
|
24
|
+
|
28
25
|
def project_configs
|
29
26
|
@project_configs ||= config[:projects]
|
30
27
|
end
|
@@ -84,7 +81,7 @@ module PolyglotIos
|
|
84
81
|
escaped_underscore = escape_with_underscore_if_needed(clean_name)
|
85
82
|
escape_keyword_if_needed(escaped_underscore)
|
86
83
|
end
|
87
|
-
|
84
|
+
|
88
85
|
def escape_with_underscore_if_needed(name)
|
89
86
|
return name if name.match(/^[A-Za-z_]/)
|
90
87
|
"_" + name
|
@@ -97,4 +94,4 @@ module PolyglotIos
|
|
97
94
|
|
98
95
|
end
|
99
96
|
end
|
100
|
-
end
|
97
|
+
end
|
@@ -12,6 +12,20 @@ module PolyglotIos
|
|
12
12
|
@prompt ||= TTY::Prompt.new(interrupt: :exit)
|
13
13
|
end
|
14
14
|
|
15
|
+
def generate_token_message(token_env_variable = nil)
|
16
|
+
token_env_variable ||= PolyglotIos::DEFAULT_TOKEN_ENVIRONMENT_VARIABLE
|
17
|
+
return <<~MESSAGE
|
18
|
+
To generate an Auth Token, please visit Polyglot website ( for Infinum https://infinum.polyglothq.com ), generate a new token under Settings -> Security and store it in your environment variables under #{token_env_variable} variable.
|
19
|
+
|
20
|
+
zsh:
|
21
|
+
echo '\\nexport #{token_env_variable}=<YOUR_AUTH_TOKEN>' >> ~/.zshrc
|
22
|
+
source ~/.zshrc
|
23
|
+
bash:
|
24
|
+
echo '\\nexport #{token_env_variable}=<YOUR_AUTH_TOKEN>' >> ~/.bashrc
|
25
|
+
source ~/.bashrc
|
26
|
+
MESSAGE
|
27
|
+
end
|
28
|
+
|
15
29
|
end
|
16
30
|
end
|
17
31
|
end
|
@@ -3,33 +3,14 @@ module PolyglotIos
|
|
3
3
|
class Token
|
4
4
|
|
5
5
|
@@in_memory_token = nil
|
6
|
-
|
7
|
-
class << self
|
8
|
-
|
9
|
-
def write(token)
|
10
|
-
if @@in_memory_token.nil?
|
11
|
-
out = <<~HELLO
|
12
6
|
|
13
|
-
|
7
|
+
class << self
|
14
8
|
|
15
|
-
To stay logged in, add the Polyglot auth token to your local environment (.zshrc, .bashrc...).
|
16
|
-
zsh:
|
17
|
-
echo '\\nexport #{PolyglotIos::DEFAULT_TOKEN_ENVIRONMENT_VARIABLE}=#{token}' >> ~/.zshrc
|
18
|
-
source ~/.zshrc
|
19
|
-
bash:
|
20
|
-
echo '\\nexport #{PolyglotIos::DEFAULT_TOKEN_ENVIRONMENT_VARIABLE}=#{token}' >> ~/.bashrc
|
21
|
-
source ~/.bashrc
|
22
|
-
HELLO
|
23
|
-
puts out
|
24
|
-
end
|
25
|
-
@@in_memory_token = token
|
26
|
-
end
|
27
|
-
|
28
9
|
def read(token_env_variable)
|
29
10
|
@@in_memory_token ||= ENV[token_env_variable]
|
30
11
|
end
|
12
|
+
|
31
13
|
end
|
32
14
|
end
|
33
15
|
end
|
34
16
|
end
|
35
|
-
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ios_polyglot_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Filip Gulan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-03-
|
11
|
+
date: 2024-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|