neeto-translate-cli 0.2.10 → 0.2.12
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 83c227188a56374d81c9533aacf6048bfc1b295c0bad6b246b496c178b760ee4
|
|
4
|
+
data.tar.gz: b95569f743070b4e20904700979c4d40fa249cf4479f4bcd9f41795621ed7cbe
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e684b415ef03bb05561185112590103264dbd700133c70417102c478e5cf4287284d75e112e01a7dcdf454d64c05fc1feaec18ae64564c5d33e7999af2b76c1d
|
|
7
|
+
data.tar.gz: 40c6964c2266f962445d14524f1ec339ea5876f3896a8eafee6eba5e233e8610d82e7e240317fdeab489b8e448e7601564592de9abdb86ae759bba30f18de49c
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module NeetoTranslateCli
|
|
4
|
+
module GitHelper
|
|
5
|
+
def self.find_neeto_translate_commit
|
|
6
|
+
result = `git log --grep="[neeto-translate]" --fixed-strings -n 1 --pretty=format:"%H"`.strip
|
|
7
|
+
|
|
8
|
+
if result.empty?
|
|
9
|
+
result = progressive_fetch
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
result
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
private
|
|
16
|
+
|
|
17
|
+
def self.progressive_fetch
|
|
18
|
+
puts "No neeto-translate commits found, fetching depth 50..."
|
|
19
|
+
`git fetch --depth=50 2>/dev/null`
|
|
20
|
+
result = `git log --grep="[neeto-translate]" --fixed-strings -n 1 --pretty=format:"%H"`.strip
|
|
21
|
+
|
|
22
|
+
return result unless result.empty?
|
|
23
|
+
|
|
24
|
+
puts "Still no commits found, fetching depth 100..."
|
|
25
|
+
`git fetch --depth=100 2>/dev/null`
|
|
26
|
+
result = `git log --grep="[neeto-translate]" --fixed-strings -n 1 --pretty=format:"%H"`.strip
|
|
27
|
+
|
|
28
|
+
return result unless result.empty?
|
|
29
|
+
|
|
30
|
+
puts "Still no commits found, fetching depth 500..."
|
|
31
|
+
`git fetch --depth=500 2>/dev/null`
|
|
32
|
+
result = `git log --grep="[neeto-translate]" --fixed-strings -n 1 --pretty=format:"%H"`.strip
|
|
33
|
+
|
|
34
|
+
return result unless result.empty?
|
|
35
|
+
|
|
36
|
+
puts "Still no commits found, fetching full history..."
|
|
37
|
+
`git fetch --unshallow 2>/dev/null`
|
|
38
|
+
`git log --grep="[neeto-translate]" --fixed-strings -n 1 --pretty=format:"%H"`.strip
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "pathname"
|
|
4
|
+
require_relative "../git_helper"
|
|
4
5
|
|
|
5
6
|
module NeetoTranslateCli
|
|
6
7
|
module NextI18next
|
|
@@ -35,66 +36,15 @@ module NeetoTranslateCli
|
|
|
35
36
|
private
|
|
36
37
|
|
|
37
38
|
def git_commit_id
|
|
38
|
-
|
|
39
|
-
puts "DEBUG: Git repository root: #{`git rev-parse --show-toplevel`.strip}"
|
|
40
|
-
puts "DEBUG: Current branch: #{`git branch --show-current`.strip}"
|
|
41
|
-
puts "DEBUG: Recent commits:"
|
|
42
|
-
puts `git log --oneline -5`
|
|
43
|
-
puts "DEBUG: Searching for commits with '[neeto-translate]' in message..."
|
|
44
|
-
|
|
45
|
-
# Try different variations of the grep pattern
|
|
46
|
-
puts "DEBUG: Trying exact match:"
|
|
47
|
-
result1 = `git log --grep="[neeto-translate]" --fixed-strings -n 1 --pretty=format:"%H"`.strip
|
|
48
|
-
puts "DEBUG: Result 1 (exact): '#{result1}'"
|
|
49
|
-
|
|
50
|
-
puts "DEBUG: Trying without fixed-strings:"
|
|
51
|
-
result2 = `git log --grep="neeto-translate" -n 1 --pretty=format:"%H"`.strip
|
|
52
|
-
puts "DEBUG: Result 2 (without fixed-strings): '#{result2}'"
|
|
53
|
-
|
|
54
|
-
puts "DEBUG: Trying with case insensitive:"
|
|
55
|
-
result3 = `git log --grep="neeto-translate" -i -n 1 --pretty=format:"%H"`.strip
|
|
56
|
-
puts "DEBUG: Result 3 (case insensitive): '#{result3}'"
|
|
57
|
-
|
|
58
|
-
puts "DEBUG: All commits with 'neeto' in message:"
|
|
59
|
-
puts `git log --grep="neeto" --oneline`
|
|
60
|
-
|
|
61
|
-
puts "DEBUG: All commits with 'translate' in message:"
|
|
62
|
-
puts `git log --grep="translate" --oneline`
|
|
63
|
-
|
|
64
|
-
# Return the first non-empty result
|
|
65
|
-
final_result = result1.empty? ? (result2.empty? ? result3 : result2) : result1
|
|
66
|
-
puts "DEBUG: Final commit id: '#{final_result}'"
|
|
67
|
-
final_result
|
|
39
|
+
GitHelper.find_neeto_translate_commit
|
|
68
40
|
end
|
|
69
41
|
|
|
70
42
|
def find_updated_keys(commit_id)
|
|
71
43
|
updated_frontend_keys = []
|
|
72
|
-
|
|
73
|
-
# Debug: Log the commit_id and current working directory
|
|
74
|
-
puts "DEBUG: commit_id = '#{commit_id}'"
|
|
75
|
-
puts "DEBUG: current working directory = '#{Dir.pwd}'"
|
|
76
|
-
puts "DEBUG: frontend path = '#{options[:frontend]}'"
|
|
77
|
-
|
|
78
44
|
frontend_translations[:en].each do |file_path, content|
|
|
79
45
|
lang_file_path = "#{options[:frontend]}/en/#{file_path}.json"
|
|
80
46
|
relative_path_from_pwd = Pathname.new(lang_file_path).to_s
|
|
81
|
-
|
|
82
|
-
# Debug: Log the paths being used
|
|
83
|
-
puts "DEBUG: file_path = '#{file_path}'"
|
|
84
|
-
puts "DEBUG: lang_file_path = '#{lang_file_path}'"
|
|
85
|
-
puts "DEBUG: relative_path_from_pwd = '#{relative_path_from_pwd}'"
|
|
86
|
-
|
|
87
|
-
# Debug: Check if file exists
|
|
88
|
-
puts "DEBUG: file exists? #{File.exist?(relative_path_from_pwd)}"
|
|
89
|
-
|
|
90
|
-
# Debug: Try the git show command and log the result
|
|
91
|
-
git_command = "git show #{commit_id}:#{relative_path_from_pwd}"
|
|
92
|
-
puts "DEBUG: running git command: #{git_command}"
|
|
93
|
-
|
|
94
|
-
previous_content = `#{git_command}`
|
|
95
|
-
puts "DEBUG: git show result length = #{previous_content.length}"
|
|
96
|
-
puts "DEBUG: git show result (first 100 chars) = '#{previous_content[0..99]}'"
|
|
97
|
-
|
|
47
|
+
previous_content = `git show #{commit_id}:#{relative_path_from_pwd}`
|
|
98
48
|
next if previous_content.empty?
|
|
99
49
|
|
|
100
50
|
previous_json = JSON.parse(previous_content)
|
|
@@ -105,14 +55,11 @@ module NeetoTranslateCli
|
|
|
105
55
|
flat_previous_json.key?(key) && flat_current_json[key] != flat_previous_json[key]
|
|
106
56
|
end
|
|
107
57
|
|
|
108
|
-
puts "DEBUG: updated_keys_for_file = #{updated_keys_for_file}"
|
|
109
|
-
|
|
110
58
|
next if updated_keys_for_file.empty?
|
|
111
59
|
|
|
112
60
|
updated_frontend_keys.concat(updated_keys_for_file.map { |key| "#{file_path}::#{key}" })
|
|
113
61
|
end
|
|
114
62
|
|
|
115
|
-
puts "DEBUG: final updated_frontend_keys = #{updated_frontend_keys}"
|
|
116
63
|
updated_frontend_keys
|
|
117
64
|
end
|
|
118
65
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require "json"
|
|
2
2
|
require "yaml"
|
|
3
|
+
require_relative "git_helper"
|
|
3
4
|
|
|
4
5
|
module NeetoTranslateCli
|
|
5
6
|
class PayloadBuilder
|
|
@@ -7,7 +8,7 @@ module NeetoTranslateCli
|
|
|
7
8
|
|
|
8
9
|
def initialize(options)
|
|
9
10
|
@options = options
|
|
10
|
-
commit_id =
|
|
11
|
+
commit_id = ""
|
|
11
12
|
@updated_keys = commit_id.empty? ? { frontend: [], backend: [] } : find_updated_keys(commit_id)
|
|
12
13
|
end
|
|
13
14
|
|
|
@@ -31,7 +32,7 @@ module NeetoTranslateCli
|
|
|
31
32
|
private
|
|
32
33
|
|
|
33
34
|
def git_commit_id
|
|
34
|
-
|
|
35
|
+
GitHelper.find_neeto_translate_commit
|
|
35
36
|
end
|
|
36
37
|
|
|
37
38
|
def en_json_flattened
|
|
@@ -70,7 +71,20 @@ module NeetoTranslateCli
|
|
|
70
71
|
{ frontend: updated_frontend_keys, backend: updated_backend_keys }
|
|
71
72
|
end
|
|
72
73
|
|
|
74
|
+
|
|
75
|
+
def find_updated_keys_for_language(lang, ext, dir)
|
|
76
|
+
first_commit = `git log --diff-filter=A --follow --pretty=format:"%H" -- "#{dir}/#{lang}.#{ext}" | tail -1`.strip
|
|
77
|
+
return [] if first_commit.empty?
|
|
78
|
+
|
|
79
|
+
modified_keys = find_updated_keys(first_commit)
|
|
80
|
+
return [] if modified_keys.empty?
|
|
81
|
+
|
|
82
|
+
ext == "json" ? modified_keys[:frontend] : modified_keys[:backend]
|
|
83
|
+
end
|
|
84
|
+
|
|
73
85
|
def find_missing_keys_for(type)
|
|
86
|
+
`git fetch --unshallow 2>/dev/null`
|
|
87
|
+
|
|
74
88
|
dir = options[type]
|
|
75
89
|
if type == :frontend
|
|
76
90
|
ext = "json"
|
|
@@ -89,7 +103,8 @@ module NeetoTranslateCli
|
|
|
89
103
|
mk = base_keys
|
|
90
104
|
end
|
|
91
105
|
|
|
92
|
-
|
|
106
|
+
updated_keys_for_lang = find_updated_keys_for_language(lang, ext, dir)
|
|
107
|
+
missing[lang] = (mk + updated_keys_for_lang).uniq
|
|
93
108
|
end
|
|
94
109
|
end
|
|
95
110
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: neeto-translate-cli
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.12
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Abhay V Ashokan
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-10-
|
|
11
|
+
date: 2025-10-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|
|
@@ -40,6 +40,7 @@ files:
|
|
|
40
40
|
- exe/neeto-translate-cli
|
|
41
41
|
- lib/neeto_translate_cli/api.rb
|
|
42
42
|
- lib/neeto_translate_cli/cli.rb
|
|
43
|
+
- lib/neeto_translate_cli/git_helper.rb
|
|
43
44
|
- lib/neeto_translate_cli/next_i18next/payload_builder.rb
|
|
44
45
|
- lib/neeto_translate_cli/payload_builder.rb
|
|
45
46
|
- lib/neeto_translate_cli/translator.rb
|