fastlane-plugin-csv_translation 0.2.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -2
- data/lib/fastlane/plugin/csv_translation/actions/create_csv_feature_branch.rb +75 -0
- data/lib/fastlane/plugin/csv_translation/actions/create_csv_translation_request.rb +14 -10
- data/lib/fastlane/plugin/csv_translation/actions/delete_csv_translation_request.rb +13 -13
- data/lib/fastlane/plugin/csv_translation/actions/fetch_csv_branch.rb +66 -0
- data/lib/fastlane/plugin/csv_translation/actions/get_csv_translation_requests.rb +3 -3
- data/lib/fastlane/plugin/csv_translation/actions/rebase_csv_translation_request.rb +148 -0
- data/lib/fastlane/plugin/csv_translation/helper/csv_translation_helper.rb +21 -10
- data/lib/fastlane/plugin/csv_translation/version.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4d048982fd2ec8146f7365d2374e0b3aac8e50c0b2ac515fe132a005c720527
|
4
|
+
data.tar.gz: d1778628a29f95e418d515a9ebb92e4179c7dcf9d95e98b24ecb3d168d26ff35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 824bbaf8367d2307a8c65a9c05990919ae160cc265cff26148987b5aa1b77323e6592f076fcb60d2b918b2fee8ead2bb4a53fe15579842220e3b8984ef418c0d
|
7
|
+
data.tar.gz: 345a9c164cc8b1ec7041907a4f7d7e6710287165e4e3ce1ad61bc9c1b262b89f5d5e8aa6f6f2056175634dd8b77308af27a3b2a5c0277ab631593781f0d1b19f
|
data/README.md
CHANGED
@@ -28,7 +28,7 @@ This plugin opens up an opportunity to automate reading from/writing of any `CSV
|
|
28
28
|
<img width="1476" alt="Example CSV" src="https://user-images.githubusercontent.com/5364500/81500222-fe912780-92d0-11ea-87a7-952a78b5cdf7.png">
|
29
29
|
|
30
30
|
## Actions
|
31
|
-
`fastlane-plugin-csv_translation` consists of
|
31
|
+
`fastlane-plugin-csv_translation` consists of 4 actions enabling you to manipulate `CSV` file from [`fastlane`](https://fastlane.tools).
|
32
32
|
|
33
33
|
### 📡 get_csv_translation_requests
|
34
34
|
Get all the translation info as hash from the CSV file, **print** the `translation_status` if translation_requests found.
|
@@ -55,7 +55,7 @@ get_csv_translation_requests(
|
|
55
55
|
Add a new translation request entry inside the CSV file. It will append a new row in CSV file and then git commit the CSV file changes.
|
56
56
|
|
57
57
|
``` ruby
|
58
|
-
example_csv_payload = {Ticket
|
58
|
+
example_csv_payload = { "Ticket" => "PRJ-3030", "Timeline" => "30 April" }
|
59
59
|
|
60
60
|
create_csv_translation_request(
|
61
61
|
repository_name: "crazymanish/example-csv-repo", # Specify the CSV git file repo
|
@@ -64,6 +64,19 @@ create_csv_translation_request(
|
|
64
64
|
)
|
65
65
|
```
|
66
66
|
|
67
|
+
### 🔝rebase_csv_translation_request
|
68
|
+
Rebase a translation request entry inside the CSV file. It will append a new row top of target branch in CSV file and then git commit the CSV file changes. Very useful in case of resolving conflicts.
|
69
|
+
|
70
|
+
``` ruby
|
71
|
+
rebase_csv_translation_request(
|
72
|
+
repository_name: "crazymanish/example-csv-repo", # Specify the CSV git file repo
|
73
|
+
branch_name: "master", #Specify the target branch (default: master)
|
74
|
+
feature_branch_name: "some_feature_branch", #Specify the feature branch name
|
75
|
+
file_path: "example.csv", # Specify the CSV file path under the git repo
|
76
|
+
identifier: "PRJ-3030" # Specify the CSV row identifier
|
77
|
+
)
|
78
|
+
```
|
79
|
+
|
67
80
|
### ✂️ delete_csv_translation_request
|
68
81
|
Delete a new translation request entry from the CSV file based on CSV row Identifier. It will delete the matched row from the CSV file and then git commit the CSV file changes.
|
69
82
|
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/csv_translation_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
CREATE_CSV_FEATURE_BRANCH_INFO = :CREATE_CSV_FEATURE_BRANCH_INFO
|
8
|
+
end
|
9
|
+
|
10
|
+
class CreateCsvFeatureBranchAction < Action
|
11
|
+
def self.run(params)
|
12
|
+
# fetching csv file
|
13
|
+
csv_file_folder = Helper::CsvTranslationHelper.create_feature_branch(
|
14
|
+
repository_name: params[:repository_name],
|
15
|
+
branch_name: params[:branch_name],
|
16
|
+
feature_branch_name: params[:feature_branch_name]
|
17
|
+
)
|
18
|
+
|
19
|
+
Actions.lane_context[SharedValues::CREATE_CSV_FEATURE_BRANCH_INFO] = csv_file_folder
|
20
|
+
return csv_file_folder
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.description
|
24
|
+
"Create a csv feature branch."
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.output
|
28
|
+
[
|
29
|
+
['CREATE_CSV_FEATURE_BRANCH_INFO', 'Created feature branch info']
|
30
|
+
]
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.available_options
|
34
|
+
[
|
35
|
+
FastlaneCore::ConfigItem.new(key: :repository_name,
|
36
|
+
env_name: "FL_CREATE_CSV_FEATURE_BRANCH_REPOSITORY_NAME",
|
37
|
+
description: "The name to your repository, e.g. 'fastlane/fastlane'",
|
38
|
+
verify_block: proc do |value|
|
39
|
+
UI.user_error!("No repository_name given in input param") unless (value and not value.empty?)
|
40
|
+
end),
|
41
|
+
FastlaneCore::ConfigItem.new(key: :branch_name,
|
42
|
+
env_name: "FL_CREATE_CSV_BASE_BRANCH_NAME",
|
43
|
+
description: "The branch name to your repository, (default main)",
|
44
|
+
is_string: true,
|
45
|
+
default_value: "main"),
|
46
|
+
FastlaneCore::ConfigItem.new(key: :feature_branch_name,
|
47
|
+
env_name: "FL_CREATE_CSV_FEATURE_BRANCH_NAME",
|
48
|
+
description: "The feature branch name for new translation request (Useful if no direct commit allowed in main)",
|
49
|
+
is_string: true,
|
50
|
+
optional: true)
|
51
|
+
]
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.authors
|
55
|
+
["crazymanish"]
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.example_code
|
59
|
+
[
|
60
|
+
'create_csv_feature_branch(
|
61
|
+
repository_name: "fastlane/fastlane",
|
62
|
+
feature_branch_name: "some_feature_branch_name")',
|
63
|
+
'create_csv_feature_branch(
|
64
|
+
repository_name: "fastlane/fastlane",
|
65
|
+
branch_name: "main",
|
66
|
+
feature_branch_name: "some_feature_branch_name")'
|
67
|
+
]
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.is_supported?(platform)
|
71
|
+
true
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -10,7 +10,7 @@ module Fastlane
|
|
10
10
|
class CreateCsvTranslationRequestAction < Action
|
11
11
|
def self.run(params)
|
12
12
|
# fetching csv file
|
13
|
-
csv_file_folder = Helper::CsvTranslationHelper.
|
13
|
+
csv_file_folder = Helper::CsvTranslationHelper.create_feature_branch(
|
14
14
|
repository_name: params[:repository_name],
|
15
15
|
branch_name: params[:branch_name],
|
16
16
|
feature_branch_name: params[:feature_branch_name]
|
@@ -19,14 +19,18 @@ module Fastlane
|
|
19
19
|
csv_file_path = "#{csv_file_folder}/#{params[:file_path]}"
|
20
20
|
csv_payload = params[:payload]
|
21
21
|
|
22
|
+
# add missing newline if not present, at the end of the file
|
23
|
+
Helper::CsvTranslationHelper.append_missing_eof(csv_file_path)
|
24
|
+
|
22
25
|
# adding new entry into csv file
|
23
26
|
require 'csv'
|
24
|
-
CSV.open(csv_file_path,
|
25
|
-
|
27
|
+
headers = CSV.open(csv_file_path, &:readline)
|
28
|
+
CSV.open(csv_file_path, 'a', headers: headers, force_quotes: true) do |csv|
|
29
|
+
csv << csv_payload
|
26
30
|
end
|
27
31
|
|
28
32
|
# creating csv translation request
|
29
|
-
git_message = "New translation request
|
33
|
+
git_message = "New translation request:\n#{csv_payload}"
|
30
34
|
git_commit_info = ""
|
31
35
|
Dir.chdir(csv_file_folder) do
|
32
36
|
GitCommitAction.run(path: ".", message: git_message)
|
@@ -64,12 +68,12 @@ module Fastlane
|
|
64
68
|
end),
|
65
69
|
FastlaneCore::ConfigItem.new(key: :branch_name,
|
66
70
|
env_name: "FL_CREATE_CSV_TRANSLATION_REQUEST_BRANCH_NAME",
|
67
|
-
description: "The branch name to your repository, (default
|
71
|
+
description: "The branch name to your repository, (default main)",
|
68
72
|
is_string: true,
|
69
|
-
default_value: "
|
73
|
+
default_value: "main"),
|
70
74
|
FastlaneCore::ConfigItem.new(key: :feature_branch_name,
|
71
75
|
env_name: "FL_CREATE_CSV_TRANSLATION_REQUEST_FEATURE_BRANCH_NAME",
|
72
|
-
description: "The feature branch name for new translation request (Useful if no direct commit allowed in
|
76
|
+
description: "The feature branch name for new translation request (Useful if no direct commit allowed in main)",
|
73
77
|
is_string: true,
|
74
78
|
optional: true),
|
75
79
|
FastlaneCore::ConfigItem.new(key: :file_path,
|
@@ -92,12 +96,12 @@ module Fastlane
|
|
92
96
|
'create_csv_translation_request(
|
93
97
|
repository_name: "fastlane/fastlane",
|
94
98
|
file_path: "translation/some_csv_name.csv",
|
95
|
-
payload: {header_name
|
99
|
+
payload: {"header_name" => "some_value"})',
|
96
100
|
'create_csv_translation_request(
|
97
101
|
repository_name: "fastlane/fastlane",
|
98
|
-
branch_name: "
|
102
|
+
branch_name: "main",
|
99
103
|
file_path: "translation/some_csv_name.csv",
|
100
|
-
payload: {header_name
|
104
|
+
payload: {"header_name" => "some_value"})'
|
101
105
|
]
|
102
106
|
end
|
103
107
|
|
@@ -10,7 +10,7 @@ module Fastlane
|
|
10
10
|
class DeleteCsvTranslationRequestAction < Action
|
11
11
|
def self.run(params)
|
12
12
|
# fetching csv file
|
13
|
-
csv_file_folder = Helper::CsvTranslationHelper.
|
13
|
+
csv_file_folder = Helper::CsvTranslationHelper.create_feature_branch(
|
14
14
|
repository_name: params[:repository_name],
|
15
15
|
branch_name: params[:branch_name],
|
16
16
|
feature_branch_name: params[:feature_branch_name]
|
@@ -26,7 +26,7 @@ module Fastlane
|
|
26
26
|
translation_requests = CSV.table(csv_file_path, headers: true)
|
27
27
|
translation_requests.delete_if { |row| row.map { |value| value.to_s }.join("").include?(csv_row_identifier) }
|
28
28
|
|
29
|
-
CSV.open(csv_file_path, "w", write_headers: true, headers: headers) do |csv|
|
29
|
+
CSV.open(csv_file_path, "w", write_headers: true, headers: headers, force_quotes: true) do |csv|
|
30
30
|
translation_requests.each { |translation_request| csv << translation_request }
|
31
31
|
end
|
32
32
|
|
@@ -40,14 +40,14 @@ module Fastlane
|
|
40
40
|
# log message if translation request not found.
|
41
41
|
if is_git_status_clean
|
42
42
|
UI.important("Please check \"#{csv_row_identifier}\", not found the translation request. ⁉️")
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
git_commit_info = Actions.last_git_commit_dict
|
43
|
+
else
|
44
|
+
git_message = "Deleted translation request: identifier: #{csv_row_identifier}"
|
45
|
+
GitCommitAction.run(path: ".", message: git_message)
|
46
|
+
PushToGitRemoteAction.run(remote: "origin")
|
47
|
+
git_commit_info = Actions.last_git_commit_dict
|
49
48
|
|
50
|
-
|
49
|
+
UI.success("Successfully #{git_message} 🚀")
|
50
|
+
end
|
51
51
|
end
|
52
52
|
|
53
53
|
# building deleted translation request info
|
@@ -79,12 +79,12 @@ module Fastlane
|
|
79
79
|
end),
|
80
80
|
FastlaneCore::ConfigItem.new(key: :branch_name,
|
81
81
|
env_name: "FL_DELETE_CSV_TRANSLATION_REQUEST_BRANCH_NAME",
|
82
|
-
description: "The branch name to your repository, (default
|
82
|
+
description: "The branch name to your repository, (default main)",
|
83
83
|
is_string: true,
|
84
|
-
default_value: "
|
84
|
+
default_value: "main"),
|
85
85
|
FastlaneCore::ConfigItem.new(key: :feature_branch_name,
|
86
86
|
env_name: "FL_DELETE_CSV_TRANSLATION_REQUEST_FEATURE_BRANCH_NAME",
|
87
|
-
description: "The feature branch name for new translation request (Useful if no direct commit allowed in
|
87
|
+
description: "The feature branch name for new translation request (Useful if no direct commit allowed in main)",
|
88
88
|
is_string: true,
|
89
89
|
optional: true),
|
90
90
|
FastlaneCore::ConfigItem.new(key: :file_path,
|
@@ -110,7 +110,7 @@ module Fastlane
|
|
110
110
|
identifier: "some_identifier_value")',
|
111
111
|
'delete_csv_translation_request(
|
112
112
|
repository_name: "fastlane/fastlane",
|
113
|
-
branch_name: "
|
113
|
+
branch_name: "main",
|
114
114
|
file_path: "translation/some_csv_name.csv",
|
115
115
|
identifier: "some_identifier_value")'
|
116
116
|
]
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/csv_translation_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
FETCH_CSV_BRANCH_INFO = :FETCH_CSV_BRANCH_INFO
|
8
|
+
end
|
9
|
+
|
10
|
+
class FetchCsvBranchAction < Action
|
11
|
+
def self.run(params)
|
12
|
+
# fetching csv file
|
13
|
+
csv_file_folder = Helper::CsvTranslationHelper.fetch_csv_file(
|
14
|
+
repository_name: repository_name,
|
15
|
+
branch_name: branch_name
|
16
|
+
)
|
17
|
+
|
18
|
+
Actions.lane_context[SharedValues::CREATE_CSV_FEATURE_BRANCH_INFO] = csv_file_folder
|
19
|
+
return csv_file_folder
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.description
|
23
|
+
"Fetch a csv file branch."
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.output
|
27
|
+
[
|
28
|
+
['FETCH_CSV_BRANCH_INFO', 'Fetched CSV file branch info']
|
29
|
+
]
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.available_options
|
33
|
+
[
|
34
|
+
FastlaneCore::ConfigItem.new(key: :repository_name,
|
35
|
+
env_name: "FL_FETCH_CSV_REPOSITORY_NAME",
|
36
|
+
description: "The name to your repository, e.g. 'fastlane/fastlane'",
|
37
|
+
verify_block: proc do |value|
|
38
|
+
UI.user_error!("No repository_name given in input param") unless (value and not value.empty?)
|
39
|
+
end),
|
40
|
+
FastlaneCore::ConfigItem.new(key: :branch_name,
|
41
|
+
env_name: "FL_FETCH_CSV_BRANCH_NAME",
|
42
|
+
description: "The branch name to your repository, (default main)",
|
43
|
+
is_string: true,
|
44
|
+
default_value: "main")
|
45
|
+
]
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.authors
|
49
|
+
["crazymanish"]
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.example_code
|
53
|
+
[
|
54
|
+
'fetch_csv_branch(repository_name: "fastlane/fastlane")',
|
55
|
+
'fetch_csv_branch(
|
56
|
+
repository_name: "fastlane/fastlane",
|
57
|
+
branch_name: "some_feature_branch_name")'
|
58
|
+
]
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.is_supported?(platform)
|
62
|
+
true
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -66,9 +66,9 @@ module Fastlane
|
|
66
66
|
end),
|
67
67
|
FastlaneCore::ConfigItem.new(key: :branch_name,
|
68
68
|
env_name: "FL_GET_CSV_TRANSLATION_REQUESTS_BRANCH_NAME",
|
69
|
-
description: "The branch name to your repository, (default
|
69
|
+
description: "The branch name to your repository, (default main)",
|
70
70
|
is_string: true,
|
71
|
-
default_value: "
|
71
|
+
default_value: "main"),
|
72
72
|
FastlaneCore::ConfigItem.new(key: :file_path,
|
73
73
|
env_name: "FL_GET_CSV_TRANSLATION_REQUESTS_FILE_PATH",
|
74
74
|
description: "The file path to your csv file",
|
@@ -104,7 +104,7 @@ module Fastlane
|
|
104
104
|
file_path: "translation/some_csv_name.csv")',
|
105
105
|
'get_csv_translation_requests(
|
106
106
|
repository_name: "fastlane/fastlane",
|
107
|
-
branch_name: "
|
107
|
+
branch_name: "main",
|
108
108
|
file_path: "translation/some_csv_name.csv")'
|
109
109
|
]
|
110
110
|
end
|
@@ -0,0 +1,148 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/csv_translation_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
REBASE_CSV_TRANSLATION_REQUEST_INFO = :REBASE_CSV_TRANSLATION_REQUEST_INFO
|
8
|
+
end
|
9
|
+
|
10
|
+
class RebaseCsvTranslationRequestAction < Action
|
11
|
+
def self.run(params)
|
12
|
+
# fetching csv file
|
13
|
+
csv_file_folder = Helper::CsvTranslationHelper.fetch_csv_file(
|
14
|
+
repository_name: params[:repository_name],
|
15
|
+
branch_name: params[:feature_branch_name]
|
16
|
+
)
|
17
|
+
|
18
|
+
csv_file_path = "#{csv_file_folder}/#{params[:file_path]}"
|
19
|
+
csv_row_identifier = params[:identifier]
|
20
|
+
|
21
|
+
require 'csv'
|
22
|
+
|
23
|
+
# picking translation request-identifier entry from the feature_branch csv file
|
24
|
+
feature_branch_translation_requests = CSV.table(csv_file_path, headers: true)
|
25
|
+
feature_branch_translation_requests = feature_branch_translation_requests.select { |row| row.map { |value| value.to_s }.join("").include?(csv_row_identifier) }
|
26
|
+
|
27
|
+
# rebasing CSV file
|
28
|
+
git_commit_info = {}
|
29
|
+
Dir.chdir(csv_file_folder) do
|
30
|
+
# Step1: Checkout the target branch csv file
|
31
|
+
sh("git fetch --all")
|
32
|
+
sh("git checkout #{params[:branch_name]} -- #{params[:file_path]}")
|
33
|
+
|
34
|
+
# Validate: Do we really need to perfoem `rebase` ?
|
35
|
+
repo_status = Actions::sh("git status --porcelain")
|
36
|
+
repo_clean = repo_status.empty?
|
37
|
+
|
38
|
+
if repo_clean
|
39
|
+
UI.important("Rebase is not required, CSV file is up to date! 💪")
|
40
|
+
else
|
41
|
+
git_commit_info = self.perform_rebase(params, csv_file_path, feature_branch_translation_requests)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# building deleted translation request info
|
46
|
+
rebase_translation_request_info = {
|
47
|
+
identifier: csv_row_identifier,
|
48
|
+
git_commit_info: git_commit_info}
|
49
|
+
|
50
|
+
Actions.lane_context[SharedValues::REBASE_CSV_TRANSLATION_REQUEST_INFO] = rebase_translation_request_info
|
51
|
+
return rebase_translation_request_info
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.perform_rebase(params, csv_file_path, feature_branch_translation_requests)
|
55
|
+
csv_row_identifier = params[:identifier]
|
56
|
+
|
57
|
+
# Step2: Commit csv file so rebase can be performed
|
58
|
+
git_message = "Rebase translation request: identifier:\n#{csv_row_identifier}"
|
59
|
+
GitCommitAction.run(path: ".", message: git_message)
|
60
|
+
|
61
|
+
# Step3: Perfoms rebasing, take all changes from target branch
|
62
|
+
sh("git rebase -X theirs " + params[:branch_name])
|
63
|
+
|
64
|
+
# Step4: Add missing newline if not present, at the end of the file
|
65
|
+
Helper::CsvTranslationHelper.append_missing_eof(csv_file_path)
|
66
|
+
|
67
|
+
# Step5: Append back feature branch translation_requests
|
68
|
+
all_translation_requests = CSV.table(csv_file_path, headers: true)
|
69
|
+
all_translation_requests.delete_if { |row| row.map { |value| value.to_s }.join("").include?(csv_row_identifier) }
|
70
|
+
|
71
|
+
headers = CSV.open(csv_file_path, &:readline)
|
72
|
+
CSV.open(csv_file_path, "w", write_headers: true, headers: headers, force_quotes: true) do |csv|
|
73
|
+
all_translation_requests.each { |translation_request| csv << translation_request }
|
74
|
+
feature_branch_translation_requests.each { |translation_request| csv << translation_request }
|
75
|
+
end
|
76
|
+
|
77
|
+
# Step6: Commit and push to remote
|
78
|
+
GitCommitAction.run(path: ".", message: git_message)
|
79
|
+
PushToGitRemoteAction.run(remote: "origin", force: true)
|
80
|
+
|
81
|
+
UI.success("Successfully #{git_message} 🚀")
|
82
|
+
Actions.last_git_commit_dict
|
83
|
+
end
|
84
|
+
|
85
|
+
def self.description
|
86
|
+
"Rebase a translation request based on identifier value."
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.output
|
90
|
+
[
|
91
|
+
['REBASE_CSV_TRANSLATION_REQUEST_INFO', 'Rebased translation request info i.e identifier, git_commit info']
|
92
|
+
]
|
93
|
+
end
|
94
|
+
|
95
|
+
def self.available_options
|
96
|
+
[
|
97
|
+
FastlaneCore::ConfigItem.new(key: :repository_name,
|
98
|
+
env_name: "FL_REBASE_CSV_TRANSLATION_REQUEST_REPOSITORY_NAME",
|
99
|
+
description: "The name to your repository, e.g. 'fastlane/fastlane'",
|
100
|
+
verify_block: proc do |value|
|
101
|
+
UI.user_error!("No repository_name given in input param") unless (value and not value.empty?)
|
102
|
+
end),
|
103
|
+
FastlaneCore::ConfigItem.new(key: :branch_name,
|
104
|
+
env_name: "FL_REBASE_CSV_TRANSLATION_REQUEST_BRANCH_NAME",
|
105
|
+
description: "The branch name to your repository, (default main)",
|
106
|
+
is_string: true,
|
107
|
+
default_value: "main"),
|
108
|
+
FastlaneCore::ConfigItem.new(key: :feature_branch_name,
|
109
|
+
env_name: "FL_REBASE_CSV_TRANSLATION_REQUEST_FEATURE_BRANCH_NAME",
|
110
|
+
description: "The feature branch name for new translation request (Useful if no direct commit allowed in main)",
|
111
|
+
is_string: true),
|
112
|
+
FastlaneCore::ConfigItem.new(key: :file_path,
|
113
|
+
env_name: "FL_REBASE_CSV_TRANSLATION_REQUEST_FILE_PATH",
|
114
|
+
description: "The file path to your csv file",
|
115
|
+
is_string: true),
|
116
|
+
FastlaneCore::ConfigItem.new(key: :identifier,
|
117
|
+
env_name: "FL_REBASE_CSV_TRANSLATION_REQUEST_IDENTIFIER",
|
118
|
+
description: "An identifier value of the CSV file row",
|
119
|
+
is_string: true)
|
120
|
+
]
|
121
|
+
end
|
122
|
+
|
123
|
+
def self.authors
|
124
|
+
["crazymanish"]
|
125
|
+
end
|
126
|
+
|
127
|
+
def self.example_code
|
128
|
+
[
|
129
|
+
'rebase_csv_translation_request(
|
130
|
+
repository_name: "fastlane/fastlane",
|
131
|
+
feature_branch_name: "some_feature_branch",
|
132
|
+
file_path: "translation/some_csv_name.csv",
|
133
|
+
identifier: "some_identifier_value")',
|
134
|
+
'rebase_csv_translation_request(
|
135
|
+
repository_name: "fastlane/fastlane",
|
136
|
+
branch_name: "main",
|
137
|
+
feature_branch_name: "some_feature_branch",
|
138
|
+
file_path: "translation/some_csv_name.csv",
|
139
|
+
identifier: "some_identifier_value")'
|
140
|
+
]
|
141
|
+
end
|
142
|
+
|
143
|
+
def self.is_supported?(platform)
|
144
|
+
true
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
@@ -6,12 +6,12 @@ module Fastlane
|
|
6
6
|
module Helper
|
7
7
|
class CsvTranslationHelper
|
8
8
|
|
9
|
-
def self.
|
9
|
+
def self.csv_file_directory_name
|
10
10
|
return ".fl_clone_csv_file"
|
11
11
|
end
|
12
12
|
|
13
|
-
def self.
|
14
|
-
return File.join(Dir.pwd, self.
|
13
|
+
def self.csv_file_directory_path
|
14
|
+
return File.join(Dir.pwd, self.csv_file_directory_name)
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.fetch_csv_file(params)
|
@@ -19,23 +19,20 @@ module Fastlane
|
|
19
19
|
branch_name = params[:branch_name]
|
20
20
|
|
21
21
|
# Setup csv_file folder for fresh git clone.
|
22
|
-
git_clone_folder = self.
|
22
|
+
git_clone_folder = self.csv_file_directory_path
|
23
23
|
FileUtils.rm_rf(git_clone_folder) if File.directory?(git_clone_folder)
|
24
|
-
Dir.mkdir(self.
|
24
|
+
Dir.mkdir(self.csv_file_directory_name)
|
25
25
|
|
26
26
|
UI.success("Fetching csv file from git repo... ⏳")
|
27
|
-
branch_option = "--branch #{branch_name}" if branch_name != 'HEAD'
|
28
27
|
git_url = "git@github.com:#{repository_name}"
|
29
|
-
Fastlane::Actions::sh("git clone #{git_url.shellescape} #{git_clone_folder.shellescape}
|
28
|
+
Fastlane::Actions::sh("git clone #{git_url.shellescape} #{git_clone_folder.shellescape}")
|
30
29
|
Fastlane::Actions::sh("cd #{git_clone_folder.shellescape} && git checkout #{branch_name}")
|
31
30
|
|
32
|
-
self.create_feature_branch(params) if params[:feature_branch_name]
|
33
|
-
|
34
31
|
return git_clone_folder
|
35
32
|
end
|
36
33
|
|
37
34
|
def self.create_feature_branch(params)
|
38
|
-
git_clone_folder = self.
|
35
|
+
git_clone_folder = self.fetch_csv_file(params)
|
39
36
|
|
40
37
|
# creating and checkout new branch
|
41
38
|
branch_name = params[:feature_branch_name]
|
@@ -43,6 +40,20 @@ module Fastlane
|
|
43
40
|
|
44
41
|
# pushing newly created branch
|
45
42
|
Fastlane::Actions::sh("cd #{git_clone_folder.shellescape} && git push -u origin #{branch_name}")
|
43
|
+
|
44
|
+
return git_clone_folder
|
45
|
+
end
|
46
|
+
|
47
|
+
# add missing newline if not present, at the end of the file
|
48
|
+
def self.append_missing_eof(file_path)
|
49
|
+
File.open(file_path, "r+") do |file|
|
50
|
+
file.seek(-1, 2)
|
51
|
+
|
52
|
+
if file.read(1) != "\n"
|
53
|
+
file.write("\n")
|
54
|
+
file.seek(0)
|
55
|
+
end
|
56
|
+
end
|
46
57
|
end
|
47
58
|
|
48
59
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-csv_translation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manish Rathi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -145,9 +145,12 @@ files:
|
|
145
145
|
- LICENSE
|
146
146
|
- README.md
|
147
147
|
- lib/fastlane/plugin/csv_translation.rb
|
148
|
+
- lib/fastlane/plugin/csv_translation/actions/create_csv_feature_branch.rb
|
148
149
|
- lib/fastlane/plugin/csv_translation/actions/create_csv_translation_request.rb
|
149
150
|
- lib/fastlane/plugin/csv_translation/actions/delete_csv_translation_request.rb
|
151
|
+
- lib/fastlane/plugin/csv_translation/actions/fetch_csv_branch.rb
|
150
152
|
- lib/fastlane/plugin/csv_translation/actions/get_csv_translation_requests.rb
|
153
|
+
- lib/fastlane/plugin/csv_translation/actions/rebase_csv_translation_request.rb
|
151
154
|
- lib/fastlane/plugin/csv_translation/helper/csv_translation_helper.rb
|
152
155
|
- lib/fastlane/plugin/csv_translation/version.rb
|
153
156
|
homepage: https://github.com/crazymanish/fastlane-plugin-csv_translation
|
@@ -169,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
169
172
|
- !ruby/object:Gem::Version
|
170
173
|
version: '0'
|
171
174
|
requirements: []
|
172
|
-
rubygems_version: 3.
|
175
|
+
rubygems_version: 3.1.4
|
173
176
|
signing_key:
|
174
177
|
specification_version: 4
|
175
178
|
summary: "A fastlane plugin to manage translation using a CSV file under git repository.
|