ykcitool 0.4.9

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.
@@ -0,0 +1,84 @@
1
+ require 'yaml'
2
+ require 'json'
3
+ require 'ykfastlane/tools'
4
+ require 'ykfastlane/version'
5
+ module YKFastlane
6
+ module Helper
7
+ include YKFastlane::Tools
8
+ '' '脚本当前工作路径' ''
9
+ YKRUNING_PATH = File.expand_path(Dir.pwd)
10
+ '' '配置文件放置路径' ''
11
+ YKCONFIG_PATH = File.expand_path(File.join(YKFastlane::YKFASTLANE_ENV_PATH, 'evnConfig.yml'))
12
+
13
+ '' 'fastlane脚本放置路径' ''
14
+ YKFastlne_SCRIPT_PATH = File.expand_path(File.join(YKFastlane::YKFASTLANE_ENV_PATH, 'ykfastlane_script'))
15
+
16
+ def self.load_config_yml()
17
+ Tools.load_yml(Helper::YKCONFIG_PATH)
18
+ end
19
+
20
+ def self.display_config_yml()
21
+ Tools.display_yml(Helper::YKCONFIG_PATH)
22
+ end
23
+
24
+ def self.load_config_value(key)
25
+ Tools.load_yml_value(Helper::YKCONFIG_PATH, key)
26
+ end
27
+
28
+ def self.update_config(qustion, key, value)
29
+ Tools.update_yml(qustion, Helper::YKCONFIG_PATH, key, value)
30
+ end
31
+
32
+ def self.default_git_domain()
33
+ p0 = "http://gitlab."
34
+ p1 = "y"
35
+ p2 = 'ea'
36
+ p3 = "h"
37
+ p4 = "ka"
38
+ p5 = ".com"
39
+ p0 + p1 + p2 + p3 + p4 + p5
40
+ end
41
+
42
+ def self.default_fast_file_remote()
43
+ url1 = "#{self.default_git_domain}/App/iOS/ykfastlane.git"
44
+ url2 = "https://github.com/stephen5652/ykfastlane_scrip.git"
45
+ "" "
46
+ \033[0;32m#{url1}\e[0m or \033[0;32m#{url2}\e[0m
47
+ " ""
48
+ end
49
+
50
+ def self.default_certificate_git_remote()
51
+ url = "#{self.default_git_domain}/App/iOS/certificates/YKCertificateProfiles.git"
52
+ "" "
53
+ \033[0;32m#{url}\e[0m
54
+ " ""
55
+ end
56
+
57
+ '' ' 配置文件key-fastfile_remote' ''
58
+ K_fastfile_remote = :fastfile_remote
59
+
60
+ '' ' 配置文件key-wx_access_token' ''
61
+ K_wx_access_token = :wx_access_token
62
+
63
+ '' '企业微信CI机器人' ''
64
+ YKWECHAT_ROBOT_TOKEN = Helper.load_config_value(Helper::K_wx_access_token)
65
+
66
+ '' 'fastlane脚本路径' ''
67
+ K_YK_CONFIG_FASTLANE_SCRIPT = :fast_file
68
+ '' 'fastlane debug开关' ''
69
+ K_YK_CONFIG_FASTLANE_DEBUG = :fast_file_debug
70
+
71
+ def self.fastlane_script
72
+ path = Helper.load_config_value(K_YK_CONFIG_FASTLANE_SCRIPT)
73
+ debug = Helper.load_config_value(K_YK_CONFIG_FASTLANE_DEBUG)
74
+ puts "path:#{path}"
75
+ puts "debug flag[#{debug.class}]:#{debug}"
76
+ if path.blank? || debug.blank? || debug != "1"
77
+ path = YKFastlne_SCRIPT_PATH
78
+ end
79
+ puts "fastlane file path:#{path}"
80
+ path
81
+ end
82
+
83
+ end
84
+ end
@@ -0,0 +1,172 @@
1
+ require 'yaml'
2
+ require 'json'
3
+
4
+ module YKFastlane
5
+
6
+ module Tools
7
+ def self.green(string)
8
+ "\033[0;32m#{string}\e[0m"
9
+ end
10
+
11
+ def self.UI(string)
12
+ puts(self.green(string))
13
+ end
14
+
15
+ def self.show_prompt
16
+ print green(">")
17
+ end
18
+
19
+ def self.yk_ask(question)
20
+ answer = ""
21
+ loop do
22
+ puts "\n#{question}?"
23
+ show_prompt()
24
+ answer = STDIN.gets.chomp
25
+
26
+ break if answer.length > 0
27
+
28
+ print "\nYou need to provide an answer."
29
+ end
30
+ puts "answier:#{answer}"
31
+ answer
32
+ end
33
+
34
+ def self.yk_ask_with_answers(question, possible_answers)
35
+ print "\n#{question}? ["
36
+ print_info = Proc.new {
37
+ possible_answers_string = possible_answers.each_with_index do |answer, i|
38
+ _answer = (i == 0) ? answer.underlined : answer
39
+ print " " + _answer
40
+ print(" /") if i != possible_answers.length - 1
41
+ end
42
+ print " ]\n"
43
+ }
44
+ print_info.call
45
+
46
+ answer = ""
47
+ loop do
48
+ show_prompt()
49
+ answer = STDIN.gets.chomp
50
+
51
+ answer = "yes" if answer == "y"
52
+ answer = "no" if answer == "n"
53
+
54
+ # default to first answer
55
+ if answer == ""
56
+ answer = possible_answers[0].downcase
57
+ print answer.yellow
58
+ end
59
+
60
+ break if possible_answers.map { |a| a.downcase }.include? answer
61
+
62
+ print "\nPossible answers are ["
63
+ print_info.call
64
+ end
65
+
66
+ answer
67
+ end
68
+
69
+ def self.load_yml(path)
70
+ if File.exist?(path) == false
71
+ FileUtils.makedirs(File.dirname(path))
72
+ File.new(path, 'w+')
73
+ end
74
+
75
+ f = File.open(path)
76
+ yml = YAML.load(f, symbolize_names: false)
77
+ f.close
78
+ yml = {} if yml == false #空yml的时候, yml = false
79
+ yml
80
+ end
81
+
82
+ def self.display_yml(path)
83
+ puts Tools::green(JSON.pretty_generate(load_yml(path)))
84
+ end
85
+
86
+ def self.load_yml_value(path, key)
87
+ yml = load_yml(path)
88
+ yml = {} if yml == false #空yml的时候, yml = false
89
+ re = yml[key].blank? ? nil : yml[key]
90
+ re
91
+ end
92
+
93
+ def self.update_yml(question, path, key, value)
94
+ yml = load_yml(path)
95
+
96
+ updateFlag = :yes
97
+ if value.blank? #外部未传该参数需要通过问答形式,获取该参数
98
+ value = Tools.yk_ask("please input #{Tools::green(question)}")
99
+
100
+ if yml[key].blank? == false #需要确认修改
101
+ puts "#{key} existed:#{yml[key]}"
102
+ updateFlag = Tools.yk_ask_with_answers("Are you sure to update #{self.green(question)}", ["Yes", "No"]).to_sym
103
+ end
104
+ end
105
+ yml[key] = value unless updateFlag != :yes
106
+ c_path = Helper::YKCONFIG_PATH
107
+ f = File.open(path, "w+")
108
+ YAML.dump(yml, f, symbolize_names: false)
109
+ f.close
110
+ end
111
+
112
+ def self.over_write_yml_dict(path, dict)
113
+ f = File.open(path, "w+")
114
+ YAML.dump(dict, f, symbolize_names: false)
115
+ f.close
116
+ end
117
+
118
+ def self.clone_git_repository(remote, destinationPath)
119
+ begin
120
+ puts "start clone:#{remote}"
121
+ cloneResult = Git::clone(remote, destinationPath, :log => Logger.new(Logger::Severity::INFO))
122
+ puts "clone_result:#{cloneResult}"
123
+ rescue Git::GitExecuteError => e
124
+ puts "clone failed:#{e}"
125
+ return 1 #任务失败
126
+ end
127
+ return 0
128
+ end
129
+
130
+ def self.git_pull(path)
131
+ begin
132
+ git = Git::open(path)
133
+ git.add()
134
+ git.reset_hard()
135
+ curbranch = git.current_branch
136
+ git.pull('origin', curbranch)
137
+ rescue Git::GitExecuteError => e
138
+ puts "pull remote failed:#{e}"
139
+ return 1 #任务失败
140
+ end
141
+
142
+ return 0
143
+ end
144
+
145
+ def self.git_commit(path, msg)
146
+ git = Git::open(path)
147
+ git.add()
148
+ cur_branch = git.current_branch
149
+ begin
150
+ git.commit("update:#{msg}")
151
+ rescue Git::GitExecuteError => e
152
+ puts "commit update exception:#{e}"
153
+ end
154
+
155
+ status = git.status()
156
+ if status.untracked.count != 0 || status.changed.count != 0
157
+ puts "git not clean, work failed"
158
+ return 1
159
+ else
160
+ puts "git clean, work success"
161
+ git.push('origin', cur_branch)
162
+ return 0
163
+ end
164
+ end
165
+
166
+ def self.notify_message_to_enterprise_wechat(msg, status)
167
+ puts "should send failed message to enterprise wechat:\"#{self.green(msg)}\""
168
+ exit!(status) unless status == 0
169
+ end
170
+
171
+ end
172
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YKFastlane
4
+ VERSION = "0.4.9"
5
+ YKFASTLANE_ENV_PATH = File.expand_path(File.join(Dir.home, '.ykfastlane_config'))
6
+ end
metadata ADDED
@@ -0,0 +1,189 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ykcitool
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.9
5
+ platform: ruby
6
+ authors:
7
+ - stephen.chen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-11-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: git
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: thor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: yaml
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: security
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: openssl
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: json
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: plist
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: public_suffix
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "<"
130
+ - !ruby/object:Gem::Version
131
+ version: 5.0.0
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "<"
137
+ - !ruby/object:Gem::Version
138
+ version: 5.0.0
139
+ description: 基于fastlane的 iOS 打包工具.
140
+ email:
141
+ - stephen5652@126.com
142
+ executables:
143
+ - ykcitool
144
+ extensions: []
145
+ extra_rdoc_files: []
146
+ files:
147
+ - LICENSE.txt
148
+ - README.md
149
+ - bin/ykcitool
150
+ - lib/GitTools/git_analysis.rb
151
+ - lib/HttpService/HttpServiceHelper.rb
152
+ - lib/HttpService/git_tag_analysis_handler.rb
153
+ - lib/actions/YKFastlaneExecute.rb
154
+ - lib/actions/archive.rb
155
+ - lib/actions/archiveHelper.rb
156
+ - lib/actions/certificate.rb
157
+ - lib/actions/git.rb
158
+ - lib/actions/init.rb
159
+ - lib/actions/pod.rb
160
+ - lib/actions/ykgit.rb
161
+ - lib/actions/ykservice_http.rb
162
+ - lib/interface.rb
163
+ - lib/ykfastlane/helper.rb
164
+ - lib/ykfastlane/tools.rb
165
+ - lib/ykfastlane/version.rb
166
+ homepage: https://github.com/stephen5652/ykcitool.git
167
+ licenses:
168
+ - MIT
169
+ metadata: {}
170
+ post_install_message:
171
+ rdoc_options: []
172
+ require_paths:
173
+ - lib
174
+ required_ruby_version: !ruby/object:Gem::Requirement
175
+ requirements:
176
+ - - ">="
177
+ - !ruby/object:Gem::Version
178
+ version: 2.6.0
179
+ required_rubygems_version: !ruby/object:Gem::Requirement
180
+ requirements:
181
+ - - ">="
182
+ - !ruby/object:Gem::Version
183
+ version: '0'
184
+ requirements: []
185
+ rubygems_version: 3.1.6
186
+ signing_key:
187
+ specification_version: 4
188
+ summary: iOS 打包工具.
189
+ test_files: []