fastlane-plugin-translate_gpt_release_notes 0.0.1 → 0.0.3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e5e5cfee5b1c78507a3b0c829c956f537cb9e9784d9e22ffdaa762ecd30b56f
|
4
|
+
data.tar.gz: 898ad55b73808069d4de2375f4f61c5aeb804731cbe66e99f57900286953cc7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5d85556a92c9fed40830d0606f3e31beb351afcb04591aa14dbbc046fbdb7f877067c8f4e88377fbeb39e43d8f9dd2cf64349d828c2761dd46269d53e9125a2
|
7
|
+
data.tar.gz: 6c0ff8dea0fc998107998d2c798d4b056e8181fc4d1cf68d8196c9aa19a480a17332e883e0665346efae5bb341a02087bcbc505d6a60bc1d7cbf986789553419
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
![logo](images/logo.png)
|
2
2
|
|
3
3
|
# translate-gpt-release-notes plugin
|
4
|
+
[![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-translate_gpt_release_notes)
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/fastlane-plugin-translate_gpt_release_notes.svg)](https://badge.fury.io/rb/fastlane-plugin-translate_gpt_release_notes)
|
4
6
|
|
5
7
|
## Getting Started
|
6
8
|
|
data/lib/fastlane/plugin/translate_gpt_release_notes/actions/translate_gpt_release_notes_action.rb
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
require 'fastlane/action'
|
2
2
|
require 'openai'
|
3
3
|
require_relative '../helper/translate_gpt_release_notes_helper'
|
4
|
+
require 'fileutils'
|
4
5
|
|
5
6
|
module Fastlane
|
6
7
|
module Actions
|
7
8
|
class TranslateGptReleaseNotesAction < Action
|
8
9
|
def self.run(params)
|
10
|
+
# Define the path for the last run time file
|
11
|
+
last_run_file = "last_successful_run.txt"
|
12
|
+
|
9
13
|
# Determine if iOS or Android based on the platform
|
10
14
|
is_ios = params[:platform] == 'ios'
|
11
15
|
base_directory = is_ios ? 'fastlane/metadata' : 'fastlane/metadata/android'
|
@@ -17,7 +21,23 @@ module Fastlane
|
|
17
21
|
end
|
18
22
|
|
19
23
|
locales = list_locales(base_directory)
|
20
|
-
master_texts = fetch_master_texts(base_directory, params[:master_locale], is_ios)
|
24
|
+
master_texts, master_file_path = fetch_master_texts(base_directory, params[:master_locale], is_ios)
|
25
|
+
|
26
|
+
# Skip translation if master texts are not found
|
27
|
+
unless master_texts && master_file_path
|
28
|
+
UI.message("Master file not found, skipping translation.")
|
29
|
+
return
|
30
|
+
end
|
31
|
+
|
32
|
+
# Compare last modification time with the last run time
|
33
|
+
if File.exist?(last_run_file) && File.exist?(master_file_path)
|
34
|
+
last_run_time = File.read(last_run_file).to_i
|
35
|
+
file_mod_time = File.mtime(master_file_path).to_i
|
36
|
+
if file_mod_time <= last_run_time
|
37
|
+
UI.message("No changes in source file detected, translation skipped.")
|
38
|
+
return
|
39
|
+
end
|
40
|
+
end
|
21
41
|
|
22
42
|
helper = Helper::TranslateGptReleaseNotesHelper.new(params)
|
23
43
|
translated_texts = locales.each_with_object({}) do |locale, translations|
|
@@ -26,6 +46,9 @@ module Fastlane
|
|
26
46
|
end
|
27
47
|
|
28
48
|
update_translated_texts(base_directory, translated_texts, is_ios, params)
|
49
|
+
|
50
|
+
# Store the current time as the last run time
|
51
|
+
File.write(last_run_file, Time.now.to_i)
|
29
52
|
end
|
30
53
|
|
31
54
|
def self.list_locales(base_directory)
|
@@ -38,20 +61,21 @@ module Fastlane
|
|
38
61
|
# Check if the master path exists
|
39
62
|
unless Dir.exist?(master_path)
|
40
63
|
UI.error("Master path does not exist: #{master_path}")
|
41
|
-
return nil
|
64
|
+
return [nil, nil]
|
42
65
|
end
|
43
66
|
|
44
67
|
filename = is_ios ? 'release_notes.txt' : highest_numbered_file(master_path)
|
68
|
+
file_path = File.join(master_path, filename)
|
45
69
|
|
46
70
|
# Check if the file exists before reading
|
47
|
-
file_path = File.join(master_path, filename)
|
48
71
|
unless File.exist?(file_path)
|
49
72
|
UI.error("File does not exist: #{file_path}")
|
50
|
-
return nil
|
73
|
+
return [nil, nil]
|
51
74
|
end
|
52
75
|
|
53
|
-
File.read(file_path)
|
54
|
-
end
|
76
|
+
[File.read(file_path), file_path]
|
77
|
+
end
|
78
|
+
|
55
79
|
|
56
80
|
def self.highest_numbered_file(directory)
|
57
81
|
Dir[File.join(directory, '*.txt')].max_by { |f| File.basename(f, '.txt').to_i }.split('/').last
|
@@ -72,7 +96,6 @@ module Fastlane
|
|
72
96
|
File.write(File.join(target_path, filename), text)
|
73
97
|
end
|
74
98
|
end
|
75
|
-
|
76
99
|
|
77
100
|
def self.description
|
78
101
|
"Translate release notes or changelogs for iOS and Android apps using OpenAI's GPT API"
|
@@ -92,7 +115,7 @@ module Fastlane
|
|
92
115
|
key: :model_name,
|
93
116
|
env_name: "GPT_MODEL_NAME",
|
94
117
|
description: "Name of the ChatGPT model to use",
|
95
|
-
default_value: "gpt-4-
|
118
|
+
default_value: "gpt-4-turbo-preview"
|
96
119
|
),
|
97
120
|
FastlaneCore::ConfigItem.new(
|
98
121
|
key: :request_timeout,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-translate_gpt_release_notes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Karliner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-openai
|