fastlane-plugin-translate_gpt_release_notes 0.0.1 → 0.0.2

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: acf57fd59e42c6a303f3351aa8b77e3b0218f1cdee9182651c93b60d88919cf5
4
- data.tar.gz: cf64458515ae18c2f4df33cd10eb6105aa258bb3e5a3b72c653397e3de4a5325
3
+ metadata.gz: 3193c57746e75d7e71a9c24f93f56c227218772f5b21e8a515b7856a631599eb
4
+ data.tar.gz: f83c7fe3f8b61f5dadb6534f4c5829e91f2f9068d2c15d86e57c0a0f5b6a0c5b
5
5
  SHA512:
6
- metadata.gz: 8db4147388d59f649f8eddfdec8fbe099e06243aab5e90f07c8a4b6a860955cb386f09a9151272b8a66863fa179cc632eb321eb909b3b4bb65a87a8db4a1767f
7
- data.tar.gz: e1a8558527d3feefdad58fac9e6d165335d1c8e32b8802022da8a25e4be025b5197b8361424bb9a61693ec0a251ee4526e82706240bd9d1258d3b5b47fa30520
6
+ metadata.gz: 12a6a3be6f8888d37d676edf2dbb21029c3c3f0c3a0f6dd0bfd673ca3c60600addde46d2703b44a3a16bc2ac50a963b4a8f05446356b6ecbcefb218723b8d48f
7
+ data.tar.gz: a47b46476071f32f1398507e0b757bebf1305530d6f1a3d2f79b5636ef04d691a3ff448d63c352a9b0b9b749fc8e55a47e0d7a1eb48b6816713adcdd86c23475
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
 
@@ -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"
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.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Karliner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-26 00:00:00.000000000 Z
11
+ date: 2023-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-openai