lhj-tools 0.1.6 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lhj/action/sh_helper.rb +138 -0
- data/lib/lhj/command/config/info.rb +67 -0
- data/lib/lhj/command/config.rb +11 -0
- data/lib/lhj/command/file_path.rb +20 -0
- data/lib/lhj/command/head_import.rb +19 -3
- data/lib/lhj/command/http.rb +14 -0
- data/lib/lhj/command/init.rb +38 -16
- data/lib/lhj/command/local/fetch.rb +1 -1
- data/lib/lhj/command/local/filter.rb +1 -1
- data/lib/lhj/command/local/local.rb +1 -1
- data/lib/lhj/command/local/local_upload.rb +1 -1
- data/lib/lhj/command/local/micro_service.rb +1 -1
- data/lib/lhj/command/oss/del.rb +1 -1
- data/lib/lhj/command/oss/list.rb +1 -1
- data/lib/lhj/command/oss/upload.rb +1 -1
- data/lib/lhj/command/refactor_rename.rb +1 -1
- data/lib/lhj/command/rename_image.rb +1 -1
- data/lib/lhj/command/sync_pod_repo.rb +153 -0
- data/lib/lhj/command/trans.rb +1 -1
- data/lib/lhj/command/yapi/formatters/base.rb +15 -0
- data/lib/lhj/command/yapi/formatters/command_context.rb +23 -0
- data/lib/lhj/command/yapi/formatters/service.rb +23 -0
- data/lib/lhj/command/yapi.rb +136 -98
- data/lib/lhj/command.rb +27 -5
- data/lib/lhj/tools/version.rb +1 -1
- data/lib/lhj/tools.rb +1 -0
- data/lib/lhj/tree/hash_walker.rb +1 -1
- data/lib/lhj/tree/path_walker.rb +1 -2
- data/lib/lhj/tree/tree.rb +5 -5
- data/lib/lhj/ui/errors/lhj_common_error.rb +19 -0
- data/lib/lhj/ui/errors/lhj_crash.rb +11 -0
- data/lib/lhj/ui/errors/lhj_error.rb +25 -0
- data/lib/lhj/ui/errors/lhj_exception.rb +19 -0
- data/lib/lhj/ui/errors/lhj_shell_error.rb +11 -0
- data/lib/lhj/ui/errors.rb +1 -0
- data/lib/lhj/ui/implementations/shell.rb +148 -0
- data/lib/lhj/ui/interface.rb +205 -0
- data/lib/lhj/ui/ui.rb +26 -0
- metadata +54 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1d71c98366bbad8074af38f9c4381db08fb138457a61cd119ff3f3405ac9ba7
|
4
|
+
data.tar.gz: 37d5b49a7403e202dea0c557bcbe17e35e4d3483b2e4a8fa4868d58527d5d545
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a190d0b7d8adf62726401fac4c550acf6b70eb08c0a1775e18df2a724e2156b0c9b4a0b04bd009a8c9b2a3be2b44bb571344058ad5590115088203e13b4f417
|
7
|
+
data.tar.gz: dc1ac168f906f8a0db1675ae3dc6ec93dbec6424a7edcfbabe80c3308031f969f4db91057e0783057e4d1e04922fbb70bf3aa326ceec210a75eab3fc23d1f9e1
|
@@ -0,0 +1,138 @@
|
|
1
|
+
require "open3"
|
2
|
+
|
3
|
+
module Lhj
|
4
|
+
module Actions
|
5
|
+
# Execute a shell command
|
6
|
+
# This method will output the string and execute it
|
7
|
+
# Just an alias for sh_no_action
|
8
|
+
# When running this in tests, it will return the actual command instead of executing it
|
9
|
+
# @param log [Boolean] should fastlane print out the executed command
|
10
|
+
# @param error_callback [Block] a callback invoked with the command output if there is a non-zero exit status
|
11
|
+
def self.sh(*command, log: true, error_callback: nil, &b)
|
12
|
+
sh_control_output(*command, print_command: log, print_command_output: log, error_callback: error_callback, &b)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.sh_no_action(*command, log: true, error_callback: nil, &b)
|
16
|
+
sh_control_output(*command, print_command: log, print_command_output: log, error_callback: error_callback, &b)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.sh_enabled?
|
20
|
+
true
|
21
|
+
end
|
22
|
+
|
23
|
+
# @param command The command to be executed (variadic)
|
24
|
+
# @param print_command [Boolean] Should we print the command that's being executed
|
25
|
+
# @param print_command_output [Boolean] Should we print the command output during execution
|
26
|
+
# @param error_callback [Block] A block that's called if the command exits with a non-zero status
|
27
|
+
# @yield [status, result, cmd] The return status of the command, all output from the command and an equivalent shell command
|
28
|
+
# @yieldparam [Process::Status] status A Process::Status indicating the status of the completed command
|
29
|
+
# @yieldparam [String] result The complete output to stdout and stderr of the completed command
|
30
|
+
# @yieldparam [String] cmd A shell command equivalent to the arguments passed
|
31
|
+
# rubocop: disable Metrics/PerceivedComplexity
|
32
|
+
def self.sh_control_output(*command, print_command: true, print_command_output: true, error_callback: nil)
|
33
|
+
print_command = print_command_output = true if $troubleshoot
|
34
|
+
# Set the encoding first, the user might have set it wrong
|
35
|
+
previous_encoding = [Encoding.default_external, Encoding.default_internal]
|
36
|
+
Encoding.default_external = Encoding::UTF_8
|
37
|
+
Encoding.default_internal = Encoding::UTF_8
|
38
|
+
|
39
|
+
# Workaround to support previous Fastlane syntax.
|
40
|
+
# This has some limitations. For example, it requires the caller to shell escape
|
41
|
+
# everything because of usages like ["ls -la", "/tmp"] instead of ["ls", "-la", "/tmp"].
|
42
|
+
command = [command.first.join(" ")] if command.length == 1 && command.first.kind_of?(Array)
|
43
|
+
|
44
|
+
shell_command = shell_command_from_args(*command)
|
45
|
+
UI.command(shell_command) if print_command
|
46
|
+
|
47
|
+
result = ''
|
48
|
+
exit_status = nil
|
49
|
+
if sh_enabled?
|
50
|
+
# The argument list is passed directly to Open3.popen2e, which
|
51
|
+
# handles the variadic argument list in the same way as Kernel#spawn.
|
52
|
+
# (http://ruby-doc.org/core-2.4.2/Kernel.html#method-i-spawn) or
|
53
|
+
# Process.spawn (http://ruby-doc.org/core-2.4.2/Process.html#method-c-spawn).
|
54
|
+
#
|
55
|
+
# sh "ls -la /Applications/Xcode\ 7.3.1.app"
|
56
|
+
# sh "ls", "-la", "/Applications/Xcode 7.3.1.app"
|
57
|
+
# sh({ "FOO" => "Hello" }, "echo $FOO")
|
58
|
+
Open3.popen2e(*command) do |stdin, io, thread|
|
59
|
+
io.sync = true
|
60
|
+
io.each do |line|
|
61
|
+
UI.command_output(line.strip) if print_command_output
|
62
|
+
result << line
|
63
|
+
end
|
64
|
+
exit_status = thread.value
|
65
|
+
end
|
66
|
+
|
67
|
+
# Checking Process::Status#exitstatus instead of #success? makes for more
|
68
|
+
# testable code. (Tests mock exitstatus only.) This is also consistent
|
69
|
+
# with previous implementations of sh and... probably portable to all
|
70
|
+
# relevant platforms.
|
71
|
+
if exit_status.exitstatus != 0
|
72
|
+
message = if print_command
|
73
|
+
"Exit status of command '#{shell_command}' was #{exit_status.exitstatus} instead of 0."
|
74
|
+
else
|
75
|
+
"Shell command exited with exit status #{exit_status.exitstatus} instead of 0."
|
76
|
+
end
|
77
|
+
message += "\n#{result}" if print_command_output
|
78
|
+
|
79
|
+
if error_callback || block_given?
|
80
|
+
UI.error(message)
|
81
|
+
# block notified below, on success or failure
|
82
|
+
error_callback && error_callback.call(result)
|
83
|
+
else
|
84
|
+
UI.shell_error!(message)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
else
|
88
|
+
result << shell_command # only for the tests
|
89
|
+
end
|
90
|
+
|
91
|
+
if block_given?
|
92
|
+
# Avoid yielding nil in tests. $? will be meaningless, but calls to
|
93
|
+
# it will not crash. There is no Process::Status.new. The alternative
|
94
|
+
# is to move this inside the sh_enabled? check and not yield in tests.
|
95
|
+
return yield(exit_status || $?, result, shell_command)
|
96
|
+
end
|
97
|
+
result
|
98
|
+
rescue => ex
|
99
|
+
raise ex
|
100
|
+
ensure
|
101
|
+
Encoding.default_external = previous_encoding.first
|
102
|
+
Encoding.default_internal = previous_encoding.last
|
103
|
+
end
|
104
|
+
# rubocop: enable Metrics/PerceivedComplexity
|
105
|
+
|
106
|
+
# Used to produce a shell command string from a list of arguments that may
|
107
|
+
# be passed to methods such as Kernel#system, Kernel#spawn and Open3.popen2e
|
108
|
+
# in order to print the command to the terminal. The same *args are passed
|
109
|
+
# directly to a system call (Open3.popen2e). This interpretation is not
|
110
|
+
# used when executing a command.
|
111
|
+
#
|
112
|
+
# @param args Any number of arguments used to construct a command
|
113
|
+
# @raise [ArgumentError] If no arguments passed
|
114
|
+
# @return [String] A shell command representing the arguments passed in
|
115
|
+
def self.shell_command_from_args(*args)
|
116
|
+
raise ArgumentError, "sh requires at least one argument" unless args.count > 0
|
117
|
+
|
118
|
+
command = ""
|
119
|
+
|
120
|
+
# Optional initial environment Hash
|
121
|
+
if args.first.kind_of?(Hash)
|
122
|
+
command = args.shift.map { |k, v| "#{k}=#{v.shellescape}" }.join(" ") + " "
|
123
|
+
end
|
124
|
+
|
125
|
+
# Support [ "/usr/local/bin/foo", "foo" ], "-x", ...
|
126
|
+
if args.first.kind_of?(Array)
|
127
|
+
command += args.shift.first.shellescape + " " + args.shelljoin
|
128
|
+
command.chomp!(" ")
|
129
|
+
elsif args.count == 1 && args.first.kind_of?(String)
|
130
|
+
command += args.first
|
131
|
+
else
|
132
|
+
command += args.shelljoin
|
133
|
+
end
|
134
|
+
|
135
|
+
command
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'highline'
|
2
|
+
require 'lhj/config'
|
3
|
+
|
4
|
+
module Lhj
|
5
|
+
class Command
|
6
|
+
class Config < Command
|
7
|
+
# show config info
|
8
|
+
class Info < Config
|
9
|
+
self.summary = '查看配置信息'
|
10
|
+
|
11
|
+
def initialize(argv)
|
12
|
+
@cli = HighLine.new
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
def handle
|
17
|
+
show_config
|
18
|
+
end
|
19
|
+
|
20
|
+
def show_config
|
21
|
+
config_arr = Dir.glob("#{config_dir}/**/*.yml")
|
22
|
+
config_arr.each_index { |i| puts "#{i}.#{File.basename(config_arr[i])}".yellow }
|
23
|
+
idx = ask_which_one
|
24
|
+
config_file = config_arr[idx]
|
25
|
+
show_yaml(config_file)
|
26
|
+
end
|
27
|
+
|
28
|
+
def show_yaml(file)
|
29
|
+
table_rows = []
|
30
|
+
content = YAML.load_file(file)
|
31
|
+
|
32
|
+
case content
|
33
|
+
when Array
|
34
|
+
content.each do |row|
|
35
|
+
next unless row.is_a?(Hash)
|
36
|
+
|
37
|
+
row.each do |key, value|
|
38
|
+
table_rows << [key, value]
|
39
|
+
end
|
40
|
+
table_rows << :separator
|
41
|
+
end
|
42
|
+
when Hash
|
43
|
+
content.each do |key, value|
|
44
|
+
table_rows << [key, value]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
title = File.basename(file).to_s
|
49
|
+
print_table(title, table_rows) if table_rows.count.positive?
|
50
|
+
end
|
51
|
+
|
52
|
+
def print_table(title, table_rows)
|
53
|
+
table = Terminal::Table.new title: title, headings: %w[键 值], rows: table_rows
|
54
|
+
puts table
|
55
|
+
end
|
56
|
+
|
57
|
+
def ask_which_one
|
58
|
+
@cli.ask('查看哪个配置: '.green).strip.to_i
|
59
|
+
end
|
60
|
+
|
61
|
+
def config_dir
|
62
|
+
Lhj::Config.instance.home_dir
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'lhj/tree/tree'
|
2
|
+
|
3
|
+
module Lhj
|
4
|
+
class Command
|
5
|
+
# show file path
|
6
|
+
class Filepath < Command
|
7
|
+
self.summary = '显示文件目录'
|
8
|
+
|
9
|
+
def initialize(argv)
|
10
|
+
@current_path = argv.shift_argument || Dir.pwd
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
def handle
|
15
|
+
tree = Lhj::Tree.new(@current_path)
|
16
|
+
puts tree.render
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -5,7 +5,8 @@ require 'fileutils'
|
|
5
5
|
|
6
6
|
module Lhj
|
7
7
|
class Command
|
8
|
-
|
8
|
+
# modify header
|
9
|
+
class HeaderImport < Command
|
9
10
|
self.summary = '更改头文件引入'
|
10
11
|
|
11
12
|
def initialize(argv)
|
@@ -13,14 +14,16 @@ module Lhj
|
|
13
14
|
@framework = argv.option('framework')
|
14
15
|
@header_map = {}
|
15
16
|
@header_folder_map = {}
|
17
|
+
@modify_files = []
|
16
18
|
super
|
17
19
|
end
|
18
20
|
|
19
|
-
def
|
21
|
+
def handle
|
20
22
|
generate_header_map
|
21
23
|
# say_header_map
|
22
24
|
# find_all_sub_folder
|
23
25
|
update_source_header
|
26
|
+
# print_modify_info
|
24
27
|
end
|
25
28
|
|
26
29
|
# @return [@header_map]
|
@@ -109,7 +112,10 @@ module Lhj
|
|
109
112
|
result = line
|
110
113
|
if line =~ /#import/
|
111
114
|
ma = find_head_key(line)
|
112
|
-
|
115
|
+
if ma && !exist_in_file(file, ma[0])
|
116
|
+
result = line.gsub(ma[0], @header_map[ma[0].to_sym] || ma[0])
|
117
|
+
# @modify_files << file unless @modify_files.include?(file)
|
118
|
+
end
|
113
119
|
end
|
114
120
|
result
|
115
121
|
end
|
@@ -123,6 +129,16 @@ module Lhj
|
|
123
129
|
header_reg = /"\D*.h"/
|
124
130
|
line.match(header_reg)
|
125
131
|
end
|
132
|
+
|
133
|
+
def print_modify_info
|
134
|
+
rows = []
|
135
|
+
@modify_files.each do |file|
|
136
|
+
rows << [File.basename(file), File.absolute_path(file)]
|
137
|
+
end
|
138
|
+
title = "修改了#{rows.count}个文件"
|
139
|
+
table = Terminal::Table.new title: title, headings: %w[文件 路径], rows: rows
|
140
|
+
puts table
|
141
|
+
end
|
126
142
|
end
|
127
143
|
end
|
128
144
|
end
|
data/lib/lhj/command/init.rb
CHANGED
@@ -9,20 +9,34 @@ module Lhj
|
|
9
9
|
# sync config
|
10
10
|
class Init < Command
|
11
11
|
self.summary = '初始化控件'
|
12
|
-
self.description = '使用工具前先执行`lhj init`'
|
12
|
+
self.description = '使用工具前先执行`lhj init --url=http://xxx`'
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
self.arguments = [
|
15
|
+
CLAide::Argument.new('url', true)
|
16
|
+
]
|
17
|
+
|
18
|
+
def self.options
|
19
|
+
[
|
20
|
+
%w[--url 配置文件的url]
|
21
|
+
]
|
22
|
+
end
|
23
|
+
|
24
|
+
def validate!
|
25
|
+
super
|
26
|
+
help! '配置url必须输入' unless @url
|
19
27
|
end
|
20
28
|
|
21
|
-
def
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
29
|
+
def initialize(argv)
|
30
|
+
@url = argv.option('url')
|
31
|
+
super
|
32
|
+
end
|
33
|
+
|
34
|
+
def handle
|
35
|
+
FileUtils.mkdir_p(target_folder) unless File.exist?(target_folder)
|
36
|
+
file_path = file_name_from_url(@url)
|
37
|
+
save_url_to_file(@url, file_path)
|
38
|
+
content = YAML.load_file(file_path)
|
39
|
+
download_file(content) if content.is_a?(Array)
|
26
40
|
end
|
27
41
|
|
28
42
|
def target_folder
|
@@ -41,14 +55,22 @@ module Lhj
|
|
41
55
|
url.scan(%r{/([^/]+)}).flatten.last
|
42
56
|
end
|
43
57
|
|
44
|
-
def download_file
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
save_file(url, file_path) unless File.exist?(file_path)
|
58
|
+
def download_file(urls)
|
59
|
+
urls.each do |url|
|
60
|
+
file_path = file_name_from_url(url)
|
61
|
+
save_url_to_file(url, file_path)
|
49
62
|
end
|
50
63
|
puts "工具初始化完成 \n"
|
51
64
|
end
|
65
|
+
|
66
|
+
def save_url_to_file(url, file_path)
|
67
|
+
save_file(url, file_path) unless File.exist?(file_path)
|
68
|
+
end
|
69
|
+
|
70
|
+
def file_name_from_url(url)
|
71
|
+
file_name = file_name_with_url(url)
|
72
|
+
File.join(target_folder, file_name)
|
73
|
+
end
|
52
74
|
end
|
53
75
|
end
|
54
76
|
end
|
data/lib/lhj/command/oss/del.rb
CHANGED
data/lib/lhj/command/oss/list.rb
CHANGED
@@ -0,0 +1,153 @@
|
|
1
|
+
require 'lhj/config'
|
2
|
+
require 'highline'
|
3
|
+
|
4
|
+
module Lhj
|
5
|
+
class Command
|
6
|
+
# sync code to pod
|
7
|
+
class SyncPod < Command
|
8
|
+
self.summary = '同步代码到私用仓库'
|
9
|
+
|
10
|
+
def initialize(argv)
|
11
|
+
@cli = HighLine.new
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
def begin_title
|
16
|
+
'读取映射文件~/.lhj/pod_config.yml'
|
17
|
+
end
|
18
|
+
|
19
|
+
def handle
|
20
|
+
sync
|
21
|
+
end
|
22
|
+
|
23
|
+
def sync
|
24
|
+
config_file = File.join(Lhj::Config.instance.home_dir, 'pod_config.yml')
|
25
|
+
arr = YAML.load_file(config_file)
|
26
|
+
arr.each_index { |i| puts "#{i}.#{arr[i]['pod']}".yellow }
|
27
|
+
idx = @cli.ask('请选择哪一个库同步: '.green).strip.to_i
|
28
|
+
pod_name = arr[idx]['pod']
|
29
|
+
src = arr[idx]['main_path']
|
30
|
+
dest = arr[idx]['pod_path']
|
31
|
+
FileUtils.cp_r(src, dest, remove_destination: true)
|
32
|
+
puts '1.从主工程复制代码到pod库成功'.green
|
33
|
+
|
34
|
+
ma = nil
|
35
|
+
Dir.chdir(dest) do
|
36
|
+
Dir.glob('*.podspec').each do |p|
|
37
|
+
update_podspec_version(p)
|
38
|
+
version_line = IO.readlines(p).find{ |line| (/\.version/ =~ line) && (version_regex =~ line) }
|
39
|
+
ma = version_line.match(version_regex)
|
40
|
+
end
|
41
|
+
puts '2.更新版本号成功'.green
|
42
|
+
|
43
|
+
Actions.sh('git add .')
|
44
|
+
puts '3.git add成功'.green
|
45
|
+
|
46
|
+
Actions.sh("git commit -m '使用工具同步主工程代码'")
|
47
|
+
puts '4.git 提交成功'.green
|
48
|
+
|
49
|
+
Actions.sh('git push')
|
50
|
+
puts '5.git 推送成功'.green
|
51
|
+
|
52
|
+
add_tag(ma[0]) if ma
|
53
|
+
puts "6.设置tag成功! tag号:#{ma[0]}".green
|
54
|
+
|
55
|
+
push_tag
|
56
|
+
puts '7.推送tag成功'.green
|
57
|
+
|
58
|
+
update_pod_repo
|
59
|
+
puts "8.#{pod_name}推送pod repo成功".green
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
# find src root dir
|
64
|
+
src_root_dir = find_src_root_dir(src)
|
65
|
+
Dir.chdir(src_root_dir) do
|
66
|
+
if ma
|
67
|
+
pod_version = ma[0]
|
68
|
+
update_all_pod_dependency(pod_name, pod_version)
|
69
|
+
puts '9.更新主工程引用pod版本号成功'.green
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
puts '10.手动执行`pod update --verbose --no-repo-update`更新pod'.green
|
74
|
+
end
|
75
|
+
|
76
|
+
def find_src_root_dir(src)
|
77
|
+
ps = []
|
78
|
+
src.scan(%r{(/[^/]*)}).flatten.each do |path|
|
79
|
+
path =~ /Code/ ? break : ps << path
|
80
|
+
end
|
81
|
+
File.join(ps)
|
82
|
+
end
|
83
|
+
|
84
|
+
def version_regex
|
85
|
+
/\d+\.\d+\.(\d+)/
|
86
|
+
end
|
87
|
+
|
88
|
+
def update_podspec_version(path)
|
89
|
+
str = ''
|
90
|
+
File.readlines(path).each do |l|
|
91
|
+
if (/\.version/ =~ l) && (version_regex =~ l)
|
92
|
+
last_version = l.scan(version_regex).flatten.first
|
93
|
+
next_version = last_version.to_i + 1
|
94
|
+
next_version_str = next_version.to_s
|
95
|
+
str += l.gsub(/(\d+\.\d+\.)(\d+)/, '\1' + next_version_str)
|
96
|
+
else
|
97
|
+
str += l.dup
|
98
|
+
end
|
99
|
+
end
|
100
|
+
File.write(path, str)
|
101
|
+
end
|
102
|
+
|
103
|
+
def add_tag(tag)
|
104
|
+
cmd = ['git tag']
|
105
|
+
cmd << '--force'
|
106
|
+
cmd << tag
|
107
|
+
Actions.sh(cmd.join(' '))
|
108
|
+
end
|
109
|
+
|
110
|
+
def push_tag
|
111
|
+
cmd = ['git push --tags']
|
112
|
+
Actions.sh(cmd.join(' '))
|
113
|
+
end
|
114
|
+
|
115
|
+
def update_pod_repo
|
116
|
+
# pod repo push miguatech-aomi_ios-mlspecs *.podspec --sources=miguatech-aomi_ios-mlspecs,aliyun,trunk --allow-warnings --use-libraries --verbose
|
117
|
+
cmd = ['pod repo push']
|
118
|
+
pod_repo_name = 'miguatech-aomi_ios-mlspecs'
|
119
|
+
cmd << pod_repo_name
|
120
|
+
cmd << '*.podspec'
|
121
|
+
cmd << "--sources=#{pod_repo_name},aliyun,trunk"
|
122
|
+
cmd << '--allow-warnings'
|
123
|
+
cmd << '--use-libraries'
|
124
|
+
cmd << '--verbose'
|
125
|
+
Actions.sh(cmd.join(' '), log: true, error_callback: nil)
|
126
|
+
end
|
127
|
+
|
128
|
+
def update_all_pod_dependency(pod_name, pod_version)
|
129
|
+
Dir.glob(%w[./**/*.podspec ./**/Podfile]).each do |p|
|
130
|
+
next if /Example/ =~ p || /temp/ =~ p
|
131
|
+
|
132
|
+
update_main_version(p, pod_name, pod_version)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def update_main_version(file, pod_name, pod_version)
|
137
|
+
cont = ''
|
138
|
+
File.readlines(file).each do |l|
|
139
|
+
if (/#{pod_name}/ =~ l) && (/\d+\.\d+\.\d+/ =~ l)
|
140
|
+
path = File.absolute_path(file)
|
141
|
+
puts "更新文件:#{path}".magenta
|
142
|
+
l.scan(/\d+\.\d+\.\d+/).each do |key|
|
143
|
+
cont += l.gsub(key, pod_version)
|
144
|
+
end
|
145
|
+
else
|
146
|
+
cont += l.dup
|
147
|
+
end
|
148
|
+
end
|
149
|
+
File.write(file, cont)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
data/lib/lhj/command/trans.rb
CHANGED