ios_polyglot_cli 2.5.0 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d9c1b88f95d9b4f4c33dece658b01a6c7e2d2ffbc461869a3819839aac429b3
4
- data.tar.gz: 61f1542565c028960d8019ab038fb4b5059990f4260830440a320f21c1e7d2cc
3
+ metadata.gz: 64f6cf0ba34d7cb3a80d4b025b20117ae9c84e8c8c4c24c0bc16fdc378330df4
4
+ data.tar.gz: 316eff6f025db95ff716800a305f624ce2e199b210dfe4275f87a46f3d2c9bec
5
5
  SHA512:
6
- metadata.gz: c3d367f02210d83a4275830d7291648e355440d574f4aac6b0309a97ca944289d19d9e4a665f927489d5dd8738938cf92c5ff8133a43602be1dfab41add6ae07
7
- data.tar.gz: e9a6f661ff7569af162bda8a6ee3289e1afa036ddc924ef74c844b7d2c6c389a80137ecb1c4e6e1eae2d08c8443a5dae81f91070bfc6680608ae30c6cc3a67bd
6
+ metadata.gz: cd2106d3dfacd97b4ac947376f96e91c4cdc64082cc8d3f17ae54fb0b2ae9e521189360dd0f0689976cdb76d8a2f9982fb9b90806624a5771a525e29679d5bd5
7
+ data.tar.gz: c6bfcd2189e1258e4821f73b35680b458658f2752563980ba27cb956de3991386671ca723f918d186ba1f052273dd66c4f51ae1508a145ee75f4de47372eb705
data/.gitignore CHANGED
@@ -126,4 +126,4 @@ DerivedData/
126
126
  /*.gcno
127
127
  **/xcshareddata/WorkspaceSettings.xcsettings
128
128
 
129
- # End of https://www.gitignore.io/api/ruby,xcode,macos,visualstudiocode
129
+ polyglot.yml
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ios_polyglot_cli (2.5.0)
4
+ ios_polyglot_cli (2.6.0)
5
5
  activesupport
6
6
  commander
7
7
  json_api_client
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 - soon to be deprecated!
27
+ ### Login
28
28
 
29
- > Login command will be deprecated in the near future!
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
- You will have to log in with your Infinum ID if you want to use polyglot:
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 [options]'
14
- c.description = 'Login to Polyglot and fetches the token using the email and password you provide.'
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."
@@ -3,7 +3,7 @@ module PolyglotIos
3
3
  class Base < JsonApiClient::Resource
4
4
  extend PolyglotIos::Helper::Depaginate
5
5
 
6
- def self.site(url)
6
+ def self.api_url(url)
7
7
  self.site = url
8
8
  self
9
9
  end
@@ -19,4 +19,3 @@ module PolyglotIos
19
19
  end
20
20
  end
21
21
  end
22
-
@@ -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
@@ -6,47 +6,15 @@ module PolyglotIos
6
6
  def self.init(options = Commander::Command::Options.new)
7
7
  new(options).call
8
8
  end
9
-
9
+
10
10
  def initialize(options = Commander::Command::Options.new)
11
11
  @options = options
12
12
  end
13
13
 
14
14
  def call
15
- PolyglotIos::IO::Token.write(token)
16
- 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.site(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 }
15
+ prompt.error("Login command removed!\n")
16
+ prompt.warn(generate_token_message())
40
17
  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
@@ -30,7 +30,7 @@ module PolyglotIos
30
30
 
31
31
  def projects
32
32
  prompt.say('Getting projects...')
33
- PolyglotIos::Resource::Project.site(option_site_url).token(option_token).depaginate.each_with_object({}) do |r, hash|
33
+ PolyglotIos::Resource::Project.api_url(option_site_url).token(option_token).depaginate.each_with_object({}) do |r, hash|
34
34
  hash[r.name] = r.id
35
35
  end
36
36
  end
@@ -80,14 +80,14 @@ module PolyglotIos
80
80
 
81
81
  def pull_languages(project_id)
82
82
  PolyglotIos::Resource::Language
83
- .site(option_site_url)
83
+ .api_url(option_site_url)
84
84
  .token(option_token)
85
85
  .depaginate(project_id: project_id)
86
86
  end
87
87
 
88
88
  def pull_translation_keys(project_id)
89
89
  PolyglotIos::Resource::TranslationKey
90
- .site(option_site_url)
90
+ .api_url(option_site_url)
91
91
  .token(option_token)
92
92
  .depaginate(project_id: project_id)
93
93
  .sort_by { |key| key.name.downcase }
@@ -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(<<~MESSAGE
15
- No Auth Token found under #{token_env_variable} environment variable.
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
@@ -13,8 +13,7 @@ module PolyglotIos
13
13
  YAML.load_file(CONFIG_FILE_PATH)
14
14
  end
15
15
  end
16
-
16
+
17
17
  end
18
18
  end
19
19
  end
20
-
@@ -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
- #{PolyglotIos::DEFAULT_TOKEN_ENVIRONMENT_VARIABLE}=#{token}
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
-
@@ -1,3 +1,3 @@
1
1
  module PolyglotIos
2
- VERSION = '2.5.0'
2
+ VERSION = '2.6.0'
3
3
  end
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.5.0
4
+ version: 2.6.0
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-14 00:00:00.000000000 Z
11
+ date: 2024-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler