fastlane-plugin-csv_translation 0.4.0 β 1.2.0
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 +4 -4
- data/README.md +2 -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 +5 -12
- data/lib/fastlane/plugin/csv_translation/actions/delete_csv_translation_request.rb +4 -4
- 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 +52 -30
- data/lib/fastlane/plugin/csv_translation/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a79a9e06809c88e824a6d9da65409418b31f66d113b3bd80fc5d1eb7d1c51e1
|
4
|
+
data.tar.gz: 15049ca17c4f1b44c0ad2ef4ff0e3550748a8e4b34772917a6ef53cf9b70f7ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85f22b21beeb5ce6e453eac34a00d2079cba1a47595a666b520dd77f36637de20667271b2dd4122e77c8090e68fb1f52d2b8fc18a181c13940dcd6b9c1529bce
|
7
|
+
data.tar.gz: d7972e07d8789b8336123e80f04c9ceb6d55ee7101dbe8e97db387d1714a84c3d916c6e0de14c924a88c399d7513094a5f77cb9fd91a85afa7add365c23b7f07
|
data/README.md
CHANGED
@@ -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
|
@@ -65,7 +65,7 @@ create_csv_translation_request(
|
|
65
65
|
```
|
66
66
|
|
67
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.
|
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
69
|
|
70
70
|
``` ruby
|
71
71
|
rebase_csv_translation_request(
|
@@ -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
|
@@ -20,14 +20,7 @@ module Fastlane
|
|
20
20
|
csv_payload = params[:payload]
|
21
21
|
|
22
22
|
# add missing newline if not present, at the end of the file
|
23
|
-
|
24
|
-
csv.seek(-1, 2)
|
25
|
-
|
26
|
-
if csv.read(1) != "\n"
|
27
|
-
csv.write("\n")
|
28
|
-
csv.seek(0)
|
29
|
-
end
|
30
|
-
end
|
23
|
+
Helper::CsvTranslationHelper.append_missing_eof(csv_file_path)
|
31
24
|
|
32
25
|
# adding new entry into csv file
|
33
26
|
require 'csv'
|
@@ -75,12 +68,12 @@ module Fastlane
|
|
75
68
|
end),
|
76
69
|
FastlaneCore::ConfigItem.new(key: :branch_name,
|
77
70
|
env_name: "FL_CREATE_CSV_TRANSLATION_REQUEST_BRANCH_NAME",
|
78
|
-
description: "The branch name to your repository, (default
|
71
|
+
description: "The branch name to your repository, (default main)",
|
79
72
|
is_string: true,
|
80
|
-
default_value: "
|
73
|
+
default_value: "main"),
|
81
74
|
FastlaneCore::ConfigItem.new(key: :feature_branch_name,
|
82
75
|
env_name: "FL_CREATE_CSV_TRANSLATION_REQUEST_FEATURE_BRANCH_NAME",
|
83
|
-
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)",
|
84
77
|
is_string: true,
|
85
78
|
optional: true),
|
86
79
|
FastlaneCore::ConfigItem.new(key: :file_path,
|
@@ -106,7 +99,7 @@ module Fastlane
|
|
106
99
|
payload: {"header_name" => "some_value"})',
|
107
100
|
'create_csv_translation_request(
|
108
101
|
repository_name: "fastlane/fastlane",
|
109
|
-
branch_name: "
|
102
|
+
branch_name: "main",
|
110
103
|
file_path: "translation/some_csv_name.csv",
|
111
104
|
payload: {"header_name" => "some_value"})'
|
112
105
|
]
|
@@ -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: params[:repository_name],
|
15
|
+
branch_name: params[: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
|
@@ -17,12 +17,15 @@ module Fastlane
|
|
17
17
|
|
18
18
|
csv_file_path = "#{csv_file_folder}/#{params[:file_path]}"
|
19
19
|
csv_row_identifier = params[:identifier]
|
20
|
+
csv_row_identifier_header = params[:identifier_header]
|
20
21
|
|
21
22
|
require 'csv'
|
22
23
|
|
23
24
|
# picking translation request-identifier entry from the feature_branch csv file
|
24
|
-
feature_branch_translation_requests = CSV.
|
25
|
-
feature_branch_translation_requests = feature_branch_translation_requests.select
|
25
|
+
feature_branch_translation_requests = CSV.foreach(csv_file_path, headers: true).map { |row| row.to_h }
|
26
|
+
feature_branch_translation_requests = feature_branch_translation_requests.select do |translation_request|
|
27
|
+
translation_request[csv_row_identifier_header].eql?(csv_row_identifier)
|
28
|
+
end
|
26
29
|
|
27
30
|
# rebasing CSV file
|
28
31
|
git_commit_info = {}
|
@@ -31,32 +34,15 @@ module Fastlane
|
|
31
34
|
sh("git fetch --all")
|
32
35
|
sh("git checkout #{params[:branch_name]} -- #{params[:file_path]}")
|
33
36
|
|
34
|
-
#
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
# Step3: Perfoms rebasing, take all changes from target branch
|
39
|
-
sh("git rebase -X theirs " + params[:branch_name])
|
40
|
-
|
41
|
-
# Step4: Add missing newline if not present, at the end of the file
|
42
|
-
Helper::CsvTranslationHelper.append_missing_eof(csv_file_path)
|
37
|
+
# Validate: Do we really need to perfoem `rebase` ?
|
38
|
+
repo_status = Actions::sh("git status --porcelain")
|
39
|
+
repo_clean = repo_status.empty?
|
43
40
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
headers = CSV.open(csv_file_path, &:readline)
|
49
|
-
CSV.open(csv_file_path, "w", write_headers: true, headers: headers, force_quotes: true) do |csv|
|
50
|
-
all_translation_requests.each { |translation_request| csv << translation_request }
|
51
|
-
feature_branch_translation_requests.each { |translation_request| csv << translation_request }
|
41
|
+
if repo_clean
|
42
|
+
UI.important("Rebase is not required, CSV file is up to date! πͺ")
|
43
|
+
else
|
44
|
+
git_commit_info = self.perform_rebase(params, csv_file_path, feature_branch_translation_requests)
|
52
45
|
end
|
53
|
-
|
54
|
-
# Step6: Commit and push to remote
|
55
|
-
GitCommitAction.run(path: ".", message: git_message)
|
56
|
-
PushToGitRemoteAction.run(remote: "origin", force: true)
|
57
|
-
|
58
|
-
git_commit_info = Actions.last_git_commit_dict
|
59
|
-
UI.success("Successfully #{git_message} π")
|
60
46
|
end
|
61
47
|
|
62
48
|
# building deleted translation request info
|
@@ -68,6 +54,36 @@ module Fastlane
|
|
68
54
|
return rebase_translation_request_info
|
69
55
|
end
|
70
56
|
|
57
|
+
def self.perform_rebase(params, csv_file_path, feature_branch_translation_requests)
|
58
|
+
csv_row_identifier = params[:identifier]
|
59
|
+
|
60
|
+
# Step2: Commit csv file so rebase can be performed
|
61
|
+
git_message = "Rebase translation request: identifier:\n#{csv_row_identifier}"
|
62
|
+
GitCommitAction.run(path: ".", message: git_message)
|
63
|
+
|
64
|
+
# Step3: Perfoms rebasing, take all changes from target branch
|
65
|
+
sh("git rebase -X theirs " + params[:branch_name])
|
66
|
+
|
67
|
+
# Step4: Add missing newline if not present, at the end of the file
|
68
|
+
Helper::CsvTranslationHelper.append_missing_eof(csv_file_path)
|
69
|
+
|
70
|
+
# Step5: Append back feature branch translation_requests
|
71
|
+
all_translation_requests = CSV.table(csv_file_path, headers: true)
|
72
|
+
|
73
|
+
headers = CSV.open(csv_file_path, &:readline)
|
74
|
+
CSV.open(csv_file_path, "w", write_headers: true, headers: headers, force_quotes: true) do |csv|
|
75
|
+
all_translation_requests.each { |translation_request| csv << translation_request }
|
76
|
+
feature_branch_translation_requests.each { |translation_request| csv << translation_request }
|
77
|
+
end
|
78
|
+
|
79
|
+
# Step6: Commit and push to remote
|
80
|
+
GitCommitAction.run(path: ".", message: git_message)
|
81
|
+
PushToGitRemoteAction.run(remote: "origin", force: true)
|
82
|
+
|
83
|
+
UI.success("Successfully #{git_message} π")
|
84
|
+
Actions.last_git_commit_dict
|
85
|
+
end
|
86
|
+
|
71
87
|
def self.description
|
72
88
|
"Rebase a translation request based on identifier value."
|
73
89
|
end
|
@@ -88,17 +104,23 @@ module Fastlane
|
|
88
104
|
end),
|
89
105
|
FastlaneCore::ConfigItem.new(key: :branch_name,
|
90
106
|
env_name: "FL_REBASE_CSV_TRANSLATION_REQUEST_BRANCH_NAME",
|
91
|
-
description: "The branch name to your repository, (default
|
107
|
+
description: "The branch name to your repository, (default main)",
|
92
108
|
is_string: true,
|
93
|
-
default_value: "
|
109
|
+
default_value: "main"),
|
94
110
|
FastlaneCore::ConfigItem.new(key: :feature_branch_name,
|
95
111
|
env_name: "FL_REBASE_CSV_TRANSLATION_REQUEST_FEATURE_BRANCH_NAME",
|
96
|
-
description: "The feature branch name for new translation request (Useful if no direct commit allowed in
|
112
|
+
description: "The feature branch name for new translation request (Useful if no direct commit allowed in main)",
|
97
113
|
is_string: true),
|
98
114
|
FastlaneCore::ConfigItem.new(key: :file_path,
|
99
115
|
env_name: "FL_REBASE_CSV_TRANSLATION_REQUEST_FILE_PATH",
|
100
116
|
description: "The file path to your csv file",
|
101
117
|
is_string: true),
|
118
|
+
FastlaneCore::ConfigItem.new(key: :identifier_header,
|
119
|
+
env_name: "FL_REBASE_CSV_TRANSLATION_REQUEST_IDENTIFIER_HEADER",
|
120
|
+
description: "An identifier header(column name) of the CSV file",
|
121
|
+
is_string: true,
|
122
|
+
optional: true,
|
123
|
+
default_value: "Ticket"),
|
102
124
|
FastlaneCore::ConfigItem.new(key: :identifier,
|
103
125
|
env_name: "FL_REBASE_CSV_TRANSLATION_REQUEST_IDENTIFIER",
|
104
126
|
description: "An identifier value of the CSV file row",
|
@@ -119,7 +141,7 @@ module Fastlane
|
|
119
141
|
identifier: "some_identifier_value")',
|
120
142
|
'rebase_csv_translation_request(
|
121
143
|
repository_name: "fastlane/fastlane",
|
122
|
-
branch_name: "
|
144
|
+
branch_name: "main",
|
123
145
|
feature_branch_name: "some_feature_branch",
|
124
146
|
file_path: "translation/some_csv_name.csv",
|
125
147
|
identifier: "some_identifier_value")'
|
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:
|
4
|
+
version: 1.2.0
|
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-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -145,8 +145,10 @@ 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
|
151
153
|
- lib/fastlane/plugin/csv_translation/actions/rebase_csv_translation_request.rb
|
152
154
|
- lib/fastlane/plugin/csv_translation/helper/csv_translation_helper.rb
|
@@ -170,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
172
|
- !ruby/object:Gem::Version
|
171
173
|
version: '0'
|
172
174
|
requirements: []
|
173
|
-
rubygems_version: 3.
|
175
|
+
rubygems_version: 3.1.4
|
174
176
|
signing_key:
|
175
177
|
specification_version: 4
|
176
178
|
summary: "A fastlane plugin to manage translation using a CSV file under git repository.
|