yamlfish 0.1.0.alpha1 → 0.1.0.rc1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5aa65ba0ad01cac58be18f2ff437609fa1c7009e586be2bf16e9a2828b80f8fa
4
- data.tar.gz: 550c2d63e56849b9efa83e05f73b84f983026233f378beab1287096939c88480
3
+ metadata.gz: 49157d9d4bd38be7815795f988ec8b7029099a624c461ddd0b10e56f901e1ca5
4
+ data.tar.gz: 761f1992eb5676261ca80a84a7b1b5b69690052f16ddb5b3445146738232ffd3
5
5
  SHA512:
6
- metadata.gz: bef480f8b6fed17353e2b1e46f7894b54f0b16eca8c37e379f4b805fc804c042bfe4b33338edf454adc0e3c3cfc167b1637ff59a1821730c7b492c41fc292060
7
- data.tar.gz: 3dc0cfed2cf7b244b924a3a4485aa081b3f640e5f232393da93db46e2aa38ac200d02a8c7bab416b6cdd06c1b3e5ffabbe0d61c0af230516fed7a9c7bde99f7e
6
+ metadata.gz: 4cf03873a81a812551491e8bee607b0a0beefb4000a57de94f789b81cd66fbb76e1b221376e65c2380fa19b35eb56850b4f6c8ffa2313a8289d8d0b09204370d
7
+ data.tar.gz: 8b5ca3a399a3bed89c3edc87b001c886b6690cd3955ab6b8bd334a0aae155220d085236b858b3ebc892f1d7bc7c0d8203d7ee7d51516b7a0de6e003a96f6b8c7
data/Gemfile.lock CHANGED
@@ -1,64 +1,67 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- yamlfish (0.1.0.alpha1)
4
+ yamlfish (0.1.0.rc1)
5
5
  activesupport (>= 6)
6
6
  faraday (~> 2.0)
7
+ rainbow (~> 3.1)
7
8
  thor (~> 1.2)
8
9
 
9
10
  GEM
10
11
  remote: https://rubygems.org/
11
12
  specs:
12
- activesupport (7.1.3)
13
+ activesupport (7.2.1)
13
14
  base64
14
15
  bigdecimal
15
- concurrent-ruby (~> 1.0, >= 1.0.2)
16
+ concurrent-ruby (~> 1.0, >= 1.3.1)
16
17
  connection_pool (>= 2.2.5)
17
18
  drb
18
19
  i18n (>= 1.6, < 2)
20
+ logger (>= 1.4.2)
19
21
  minitest (>= 5.1)
20
- mutex_m
21
- tzinfo (~> 2.0)
22
+ securerandom (>= 0.3)
23
+ tzinfo (~> 2.0, >= 2.0.5)
22
24
  base64 (0.2.0)
23
- bigdecimal (3.1.6)
24
- concurrent-ruby (1.2.3)
25
+ bigdecimal (3.1.8)
26
+ concurrent-ruby (1.3.4)
25
27
  connection_pool (2.4.1)
26
- diff-lcs (1.5.0)
27
- drb (2.2.0)
28
- ruby2_keywords
29
- faraday (2.9.0)
30
- faraday-net_http (>= 2.0, < 3.2)
31
- faraday-net_http (3.1.0)
28
+ diff-lcs (1.5.1)
29
+ drb (2.2.1)
30
+ faraday (2.11.0)
31
+ faraday-net_http (>= 2.0, < 3.4)
32
+ logger
33
+ faraday-net_http (3.3.0)
32
34
  net-http
33
- i18n (1.14.1)
35
+ i18n (1.14.5)
34
36
  concurrent-ruby (~> 1.0)
35
- minitest (5.22.2)
36
- mutex_m (0.2.0)
37
+ logger (1.6.0)
38
+ minitest (5.25.1)
37
39
  net-http (0.4.1)
38
40
  uri
39
- rake (13.0.6)
40
- rspec (3.12.0)
41
- rspec-core (~> 3.12.0)
42
- rspec-expectations (~> 3.12.0)
43
- rspec-mocks (~> 3.12.0)
44
- rspec-core (3.12.2)
45
- rspec-support (~> 3.12.0)
46
- rspec-expectations (3.12.3)
41
+ rainbow (3.1.1)
42
+ rake (13.2.1)
43
+ rspec (3.13.0)
44
+ rspec-core (~> 3.13.0)
45
+ rspec-expectations (~> 3.13.0)
46
+ rspec-mocks (~> 3.13.0)
47
+ rspec-core (3.13.0)
48
+ rspec-support (~> 3.13.0)
49
+ rspec-expectations (3.13.2)
47
50
  diff-lcs (>= 1.2.0, < 2.0)
48
- rspec-support (~> 3.12.0)
49
- rspec-mocks (3.12.6)
51
+ rspec-support (~> 3.13.0)
52
+ rspec-mocks (3.13.1)
50
53
  diff-lcs (>= 1.2.0, < 2.0)
51
- rspec-support (~> 3.12.0)
52
- rspec-support (3.12.1)
53
- ruby2_keywords (0.0.5)
54
- thor (1.3.0)
54
+ rspec-support (~> 3.13.0)
55
+ rspec-support (3.13.1)
56
+ securerandom (0.3.1)
57
+ thor (1.3.1)
55
58
  tzinfo (2.0.6)
56
59
  concurrent-ruby (~> 1.0)
57
- uri (0.13.0)
60
+ uri (0.13.1)
58
61
 
59
62
  PLATFORMS
60
- x86_64-darwin-21
61
- x86_64-darwin-22
63
+ arm64-darwin-23
64
+ ruby
62
65
 
63
66
  DEPENDENCIES
64
67
  rake (~> 13.0)
@@ -66,4 +69,4 @@ DEPENDENCIES
66
69
  yamlfish!
67
70
 
68
71
  BUNDLED WITH
69
- 2.2.32
72
+ 2.5.18
data/exe/yamlfish CHANGED
@@ -9,6 +9,9 @@ class YamlfishExe < Thor
9
9
  option :branch, type: :string, default: "main"
10
10
  def push(locale)
11
11
  Yamlfish::Cli::Push.new(locale, branch: options[:branch]).call
12
+ rescue Errno::ENOENT => e
13
+ puts Rainbow("Could not push: #{e.message}").red.bright
14
+ exit 1
12
15
  end
13
16
 
14
17
  desc "pull", "Pulls translations from yamlfish"
@@ -17,6 +20,14 @@ class YamlfishExe < Thor
17
20
  option :branch, type: :string, default: "main"
18
21
  def pull(locale)
19
22
  Yamlfish::Cli::Pull.new(locale, inplace: options[:inplace], force_update: options[:force_update], branch: options[:branch]).call
23
+ rescue Errno::ENOENT => e
24
+ puts Rainbow("Could not pull: #{e.message}").red.bright
25
+ exit 1
26
+ end
27
+
28
+ desc "version", "Prints the version"
29
+ def version
30
+ puts Yamlfish::Cli::VERSION
20
31
  end
21
32
  end
22
33
 
@@ -25,19 +25,27 @@ module Yamlfish
25
25
  "Authorization": "Bearer #{Yamlfish::Cli.configuration.api_key}"
26
26
  }
27
27
  )
28
+
29
+ if response.status != 200
30
+ puts Rainbow("Failed to pull, unexpected HTTP status #{response.status}").red.bright
31
+ exit 1
32
+ end
33
+
28
34
  translations = JSON.parse(response.body)
29
35
 
30
36
  if @inplace
31
37
  replace_inplace(translations)
38
+ puts "Fetched translations in-place for locale #{Rainbow(@locale_identifier).magenta.bright}"
32
39
  else
33
40
  dump_translations(translations)
41
+ puts "Downloaded new translations for locale #{Rainbow(@locale_identifier).magenta.bright}"
34
42
  end
35
43
  end
36
44
 
37
45
  private
38
46
 
39
47
  def replace_inplace(translations)
40
- Dir.glob("./config/locales/**/*.yml").each do |filename|
48
+ Dir.glob("./#{Yamlfish::Cli.configuration.locales_path}/**/*.yml").each do |filename|
41
49
  file = YAML.load_file(filename).dot_flatten
42
50
  update = false
43
51
 
@@ -53,7 +61,7 @@ module Yamlfish
53
61
  end
54
62
 
55
63
  def dump_translations(translations)
56
- File.write("./config/locales/#{@locale_identifier}.yml", Yamlfish::Cli::YamlDumper.dump(translations.dot_unflatten))
64
+ File.write("./#{Yamlfish::Cli.configuration.locales_path}/#{@locale_identifier}.yml", Yamlfish::Cli::YamlDumper.dump(translations.dot_unflatten))
57
65
  end
58
66
  end
59
67
  end
@@ -12,7 +12,7 @@ module Yamlfish
12
12
  end
13
13
 
14
14
  def call
15
- translations = Dir.glob("./config/locales/**/*.yml").each_with_object({}) do |filename, translations|
15
+ translations = Dir.glob("./#{Yamlfish::Cli.configuration.locales_path}/**/*.yml").each_with_object({}) do |filename, translations|
16
16
  translations.deep_merge!(YAML.load_file(filename))
17
17
  end
18
18
 
@@ -27,7 +27,12 @@ module Yamlfish
27
27
  "Authorization": "Bearer #{Yamlfish::Cli.configuration.api_key}"
28
28
  }
29
29
  )
30
- puts response.status
30
+ if response.status == 201
31
+ puts "Successfully pushed translations for locale #{Rainbow(@locale_identifier).magenta.bright} on branch #{Rainbow(@branch).magenta.bright}"
32
+ else
33
+ puts Rainbow("Failed to push, unexpected HTTP status #{response.status}").red.bright
34
+ exit 1
35
+ end
31
36
  end
32
37
  end
33
38
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Yamlfish
4
4
  module Cli
5
- VERSION = "0.1.0.alpha1"
5
+ VERSION = "0.1.0.rc1"
6
6
  end
7
7
  end
data/lib/yamlfish/cli.rb CHANGED
@@ -4,6 +4,7 @@ require_relative "cli/version"
4
4
  require_relative "cli/push"
5
5
  require_relative "cli/pull"
6
6
  require "yaml"
7
+ require "rainbow"
7
8
 
8
9
  module Yamlfish
9
10
  module Cli
@@ -15,9 +16,10 @@ module Yamlfish
15
16
  end
16
17
 
17
18
  class Configuration
18
- attr_accessor :api_key, :project_token, :base_url
19
+ attr_accessor :api_key, :project_token, :base_url, :locales_path
19
20
 
20
21
  DEFAULT_BASE_URL = "https://yamlfish.dev/api/v1"
22
+ DEFAULT_LOCALES_PATH = "config/locales"
21
23
 
22
24
  def initialize
23
25
  configuration = begin
@@ -29,6 +31,7 @@ module Yamlfish
29
31
  @api_key = configuration["api_key"]
30
32
  @project_token = configuration["project_token"]
31
33
  @base_url = configuration["base_url"] || DEFAULT_BASE_URL
34
+ @locales_path = configuration["locales_path"] || DEFAULT_LOCALES_PATH
32
35
  end
33
36
  end
34
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yamlfish
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.alpha1
4
+ version: 0.1.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrien Siami
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-02-18 00:00:00.000000000 Z
11
+ date: 2024-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rainbow
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.1'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.1'
55
69
  description:
56
70
  email:
57
71
  - adrien@siami.fr
@@ -92,11 +106,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
92
106
  version: 2.6.0
93
107
  required_rubygems_version: !ruby/object:Gem::Requirement
94
108
  requirements:
95
- - - ">"
109
+ - - ">="
96
110
  - !ruby/object:Gem::Version
97
- version: 1.3.1
111
+ version: '0'
98
112
  requirements: []
99
- rubygems_version: 3.4.21
113
+ rubygems_version: 3.5.10
100
114
  signing_key:
101
115
  specification_version: 4
102
116
  summary: Easily manage your translations with yamlfish