podsorz 0.0.7 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,10 +6,10 @@ module PodsOrz
6
6
  attr_accessor :kx_pods_path, :orzconfig_parse
7
7
 
8
8
  def initialize(main_path)
9
- @kx_pods_path = File.expand_path("../kx_pods", main_path)
10
-
11
- detect_kx_pods(main_path)
9
+
12
10
  @orzconfig_parse = PodsOrz::PodOrzconfigParse.new(main_path)
11
+ @kx_pods_path = File.expand_path("../#{@orzconfig_parse.file_devpods_name}", main_path)
12
+ detect_kx_pods(main_path)
13
13
  end
14
14
 
15
15
  def check_directory(main_path)
@@ -26,8 +26,8 @@ module PodsOrz
26
26
  if result
27
27
  pods_result = File.directory?(@kx_pods_path)
28
28
  unless pods_result
29
- Logger.warning("kx_pods directory not exist, generate default 'kx_pods' directory")
30
- Dir.mkdir(@kx_pods_path)
29
+ Logger.warning("#{@orzconfig_parse.file_devpods_name} directory not exist, generate default directory")
30
+ FileUtils.mkdir_p(@kx_pods_path, :mode => 0777)
31
31
  end
32
32
  end
33
33
  end
@@ -63,7 +63,7 @@ module PodsOrz
63
63
  result = false if file_entries.empty?
64
64
  result = false unless file_entries.include?(".git")
65
65
 
66
- Logger.error("【#{pod}】 at #{pod_path} exist, but .git not work success, please manual check.") unless result
66
+ Logger.error("【#{pod}】 at #{pod_path} exist, but .git not work success, please manual check.") unless result
67
67
  else
68
68
  result = clone_orz_pod(pod)
69
69
  end
@@ -77,7 +77,8 @@ module PodsOrz
77
77
 
78
78
  Logger.default("Start clone 【#{pod}】 Project...")
79
79
  git_clone_content = ""
80
- IO.popen("git clone git@gitlab.91banban.com:ios_pods/Pods/#{pod}.git #{pod_directory}", :err=>[:child, :out]) {|io|
80
+ # 替换为config参数
81
+ IO.popen("git clone #{@orzconfig_parse.remote_url_sourcecode}/#{pod}.git #{pod_directory}", :err=>[:child, :out]) {|io|
81
82
  git_clone_content = io.read
82
83
  puts(git_clone_content)
83
84
  is_clone_success = false if git_clone_content.to_s.include? "fatal"
@@ -3,6 +3,7 @@ require "podsorz/core/PodsOrz/pods_git_operator"
3
3
  require "podsorz/core/PodFile/podfile_io"
4
4
  require "podsorz/core/PodsOrz/pods_version"
5
5
  require "podsorz/core/PodsOrz/pods_repo"
6
+ require "podsorz/core/PodsOrz/pods_sort"
6
7
  require 'open3'
7
8
 
8
9
  module PodsOrz
@@ -12,7 +13,7 @@ module PodsOrz
12
13
  def initialize(main_path)
13
14
  @orzconfig_parse = PodsOrz::PodOrzconfigParse.new(main_path)
14
15
 
15
- kx_pods_path = File.expand_path("../kx_pods", main_path)
16
+ kx_pods_path = File.expand_path("../#{@orzconfig_parse.file_devpods_name}", main_path)
16
17
  @pods_git_operator = PodsOrz::PodsGitOperator.new(kx_pods_path, @orzconfig_parse.app_release_version, @orzconfig_parse.branch_author_suffix)
17
18
 
18
19
  @podfile_io = PodsOrz::PodfileIO.new(main_path)
@@ -20,7 +21,7 @@ module PodsOrz
20
21
 
21
22
  @pods_version = PodsOrz::PodsVersion.new(main_path)
22
23
 
23
- @pods_repo = PodsOrz::PodsRepo.new()
24
+ @pods_repo = PodsOrz::PodsRepo.new(main_path)
24
25
  end
25
26
 
26
27
  #Switch Command --
@@ -199,8 +200,8 @@ module PodsOrz
199
200
  end
200
201
 
201
202
 
202
- #1.判断 release 是否存在新的commit内容
203
- newContent_pod_list = filter_newContent_pods()
203
+ #1.判断 release 和master 比较是否存在新的commit内容
204
+ newContent_pod_list = filter_master_newContent()
204
205
 
205
206
  if newContent_pod_list.empty?
206
207
  Logger.warning("All pods do not have new content to publish")
@@ -228,17 +229,37 @@ module PodsOrz
228
229
  #6.Update Podfile_orz
229
230
  update_publish_podfile_orz
230
231
 
231
- #7.Merge into develop
232
+ #7.diff content from develop branch
233
+ newContent_pod_list = filter_develop_newContent()
234
+
235
+ #8.Merge into develop
232
236
  publish_develop_branch(newContent_pod_list)
233
237
  end
234
238
 
235
- def filter_newContent_pods()
239
+ def filter_master_newContent()
240
+ newContent_pod_list = []
241
+ #filter action
242
+ pods_list = @orzconfig_parse.fix_pod_list
243
+ pods_list.each {|pod|
244
+ command = Thread.new do
245
+ is_new_publish = @pods_git_operator.has_new_publish(pod, "master")
246
+ newContent_pod_list << pod if is_new_publish
247
+ end
248
+
249
+ command.join
250
+ Logger.separator
251
+ }
252
+
253
+ newContent_pod_list
254
+ end
255
+
256
+ def filter_develop_newContent()
236
257
  newContent_pod_list = []
237
258
  #filter action
238
259
  pods_list = @orzconfig_parse.fix_pod_list
239
260
  pods_list.each {|pod|
240
261
  command = Thread.new do
241
- is_new_publish = @pods_git_operator.has_new_publish(pod)
262
+ is_new_publish = @pods_git_operator.has_new_publish(pod, "develop")
242
263
  newContent_pod_list << pod if is_new_publish
243
264
  end
244
265
 
@@ -355,8 +376,16 @@ module PodsOrz
355
376
 
356
377
  def pods_repo_push(is_swift)
357
378
  is_push_success = true
358
-
359
379
  pods_list = @orzconfig_parse.fix_pod_list
380
+
381
+ if pods_list.empty?
382
+ Logger.warning("fix_pods is empty nothing to do")
383
+ else
384
+ pods_sort = PodsOrz::PodsSort.new()
385
+ kx_pods_subPath = @pods_git_operator.get_pod_file_path("")
386
+ pods_list = pods_sort.sort(pods_list,kx_pods_subPath)
387
+ end
388
+
360
389
  pods_list.each {|pod|
361
390
  Logger.default("【#{pod}】check pod_version, git_tag, remote_version...")
362
391
 
@@ -448,7 +477,7 @@ module PodsOrz
448
477
  command.join
449
478
 
450
479
  command = Thread.new do
451
- Open3.popen3("cd #{main_path};pod update --no-repo-update --verbose") do |stdin , stdout , stderr, wait_thr|
480
+ Open3.popen3("cd #{main_path};pod update") do |stdin , stdout , stderr, wait_thr|
452
481
  while line = stdout.gets
453
482
  puts line
454
483
  end
@@ -425,7 +425,7 @@ module PodsOrz
425
425
 
426
426
  #Publish
427
427
 
428
- def has_new_publish(pod)
428
+ def has_new_publish(pod, branch_name)
429
429
  is_new_content = true
430
430
 
431
431
  is_new_content = is_publish_ready(pod)
@@ -437,7 +437,7 @@ module PodsOrz
437
437
 
438
438
  fetch_cmd_list = []
439
439
  fetch_cmd_list << "cd #{pod_file_path}"
440
- fetch_cmd_list << "git fetch origin master"
440
+ fetch_cmd_list << "git fetch origin #{branch_name}"
441
441
  IO.popen(fetch_cmd_list.join(";")) do |io|
442
442
  io.each do |line|
443
443
  puts line
@@ -446,16 +446,21 @@ module PodsOrz
446
446
  end
447
447
 
448
448
  diff_lines_list = []
449
- diff_lines_list = @git_operator.compare_branch(pod_file_path, current_branch, "origin/master")
449
+ diff_lines_list = @git_operator.compare_branch(pod_file_path, current_branch, "origin/#{branch_name}")
450
450
 
451
451
  if diff_lines_list.empty?
452
452
  is_new_content = false
453
453
  return is_new_content
454
454
  end
455
455
 
456
+ #filter Merge branch
457
+ diff_lines_list.delete_if {|item|
458
+ item.to_s.include? "Merge branch"
459
+ }
460
+
456
461
  is_new_content = false
457
462
 
458
- Logger.warning("#{pod} on branch:\'#{current_branch}\' -- compare branch:\'origin/master\'")
463
+ Logger.warning("#{pod} on branch:\'#{current_branch}\' -- compare branch:\'origin/#{branch_name}\'")
459
464
 
460
465
  should_show_detail = true
461
466
  limit_count = 10
@@ -1,13 +1,18 @@
1
1
  require "podsorz/util/logger"
2
2
  require 'open3'
3
+ require "podsorz/core/Config/pod_orzconfig_parse"
4
+
3
5
 
4
6
  module PodsOrz
5
7
  class PodsRepo
6
8
  attr_accessor :repo_name, :repo_url
7
9
 
8
- def initialize()
9
- @repo_name = "kuxiu_specs"
10
- @repo_url = "git@gitlab.91banban.com:ios_pods/Specs.git"
10
+ def initialize(main_path)
11
+ # @repo_name = "kuxiu_specs"
12
+ # 替换成config配置参数
13
+ @orzconfig_parse = PodsOrz::PodOrzconfigParse.new(main_path)
14
+ @repo_url = @orzconfig_parse.remote_url_codespec
15
+ @repo_name = @orzconfig_parse.file_coderepo_name
11
16
  end
12
17
 
13
18
  def check_repo_exist
@@ -190,9 +195,9 @@ module PodsOrz
190
195
  repo_push_cmd = []
191
196
  repo_push_cmd << "cd #{file_path}"
192
197
  if is_swift
193
- repo_push_cmd << "pod repo push #{@repo_name} #{pod}.podspec --sources=#{@repo_url} --allow-warnings --use-libraries --skip-import-validation --use-modular-headers --swift-version=5.0 --skip-tests --platforms=ios"
198
+ repo_push_cmd << "pod repo push #{@repo_name} #{pod}.podspec --sources=#{@repo_url} --allow-warnings --use-libraries --skip-import-validation --use-modular-headers --swift-version=5.0 --skip-tests"
194
199
  else
195
- repo_push_cmd << "pod repo push #{@repo_name} #{pod}.podspec --sources=#{@repo_url} --allow-warnings --use-libraries --skip-import-validation --skip-tests --platforms=ios"
200
+ repo_push_cmd << "pod repo push #{@repo_name} #{pod}.podspec --sources=#{@repo_url} --allow-warnings --use-libraries --skip-import-validation --skip-tests"
196
201
  end
197
202
 
198
203
 
@@ -212,10 +217,9 @@ module PodsOrz
212
217
  unless is_push_success
213
218
  puts error_info
214
219
  Logger.error("Fail: \'#{pod}\':#{pod_version} push repo remote fail")
215
- return is_push_success
220
+ else
221
+ Logger.highlight(%Q(#{pod}:#{pod_version} push repo success))
216
222
  end
217
-
218
- Logger.highlight(%Q(#{pod}:#{pod_version} push repo success))
219
223
  end
220
224
 
221
225
  command.join
@@ -0,0 +1,155 @@
1
+ require 'open3'
2
+ require 'pathname'
3
+
4
+ module PodsOrz
5
+
6
+ class PodsSort
7
+
8
+ def sort(pods_list,kx_pods_subPath)
9
+ # file priority 1 hash
10
+ @@fileHash = {}
11
+ # podspec hash
12
+ @@podspecHash = {}
13
+
14
+ @@filterHash = {}
15
+ pods_list.each { |fileName|
16
+ @@fileHash[fileName] = 1
17
+ }
18
+
19
+ pods_list.each { |fileName|
20
+ filePath = "#{kx_pods_subPath}/#{fileName}"
21
+ is_directory = File.directory?(filePath)
22
+ if is_directory
23
+ spec_with_path("#{filePath}/#{fileName}.podspec",fileName)
24
+ else
25
+ Logger.warning("#{filePath} is an empty file")
26
+ end
27
+ }
28
+ sort_with_hash()
29
+ @resultHash = {}
30
+
31
+ @@filterHash.each { |fileName,array|
32
+ # puts ("#{fileName},#{array}")
33
+ recursive_puts(fileName,array,[fileName])
34
+
35
+ }
36
+
37
+ @@fileHash.each {|file,priority|
38
+ # puts ("#{file} #{priority}")
39
+ if @resultHash.key?(priority)
40
+ array = @resultHash[priority]
41
+ array << file
42
+ @resultHash[priority] = array
43
+ else
44
+ @resultHash[priority] = [file]
45
+ end
46
+ }
47
+ sortList = []
48
+ checkHash = {}
49
+ # puts @resultHash
50
+ @resultHash.sort.sort!.each { |priority,array|
51
+ # puts ("#{priority},#{array}")
52
+ array.each { |line|
53
+ puts ("#{priority} -- #{line}")
54
+ checkHash[line] = priority
55
+ sortList << line
56
+ }
57
+ }
58
+
59
+ sortList.reverse!
60
+
61
+ end
62
+
63
+
64
+ def recursive_puts(key,array,pathArray)
65
+ # pathArray << key
66
+ totalArray = []
67
+ if array.empty?
68
+ # puts ("kong - #{key}")
69
+
70
+ else
71
+ array.each {|line|
72
+ pathArray << line
73
+ priority = @@fileHash[line] + 1
74
+ @@fileHash[line] = priority
75
+ tempArray = @@filterHash[line]
76
+ if tempArray.empty?
77
+ pathArray.pop
78
+ else
79
+
80
+ cycle = false
81
+ tempArray.each {|podsName|
82
+ if pathArray.include?(podsName)
83
+ cycle = true
84
+ Logger.error("path:#{pathArray} pod:#{podsName} has dependence cycle, please fix cycle")
85
+ exit()
86
+ end
87
+ # priorityN = @@fileHash[podsName] + 1
88
+ # puts("次数 podsName #{podsName} #{priorityN}")
89
+ # @@fileHash[podsName] = priorityN
90
+ }
91
+
92
+ if cycle
93
+ #包含
94
+ # puts pathArray
95
+
96
+ else
97
+ # puts ("#{key} #{line} #{pathArray}")
98
+ recursive_puts(line,tempArray,pathArray)
99
+ pathArray.pop
100
+ end
101
+
102
+ end
103
+
104
+ }
105
+
106
+ end
107
+
108
+
109
+ end
110
+
111
+ def sort_with_hash()
112
+
113
+ @@podspecHash.each { |fileName,specArray|
114
+ # puts "#{fileName} #{specArray}"
115
+ tempArray = []
116
+ @@fileHash.each {|file,priority|
117
+
118
+ specArray.each { |line|
119
+ if line.include? "dependency"
120
+
121
+ if line.include? file and file != fileName
122
+
123
+ priority += 1
124
+
125
+ # @@fileHash[file] = priority
126
+ tempArray << file
127
+ # puts "#{fileName},#{file},#{line}"
128
+
129
+ end
130
+ end
131
+ }
132
+
133
+ }
134
+ @@filterHash[fileName] = tempArray
135
+
136
+ }
137
+
138
+ end
139
+
140
+ def spec_with_path(path,fileName)
141
+ return if path.nil?
142
+ path = Pathname.new(path)
143
+ path = Pathname.new(Dir.pwd).join(path) unless path.absolute?
144
+ return unless path.exist?
145
+
146
+ @path = path.expand_path
147
+
148
+ arr = IO.readlines("#{@path}")
149
+ @@podspecHash[fileName] = arr
150
+
151
+ end
152
+
153
+ end
154
+
155
+ end
@@ -1,4 +1,5 @@
1
1
  require "podsorz/util/logger"
2
+ require "podsorz/core/Config/pod_orzconfig_parse"
2
3
 
3
4
 
4
5
  module PodsOrz
@@ -6,7 +7,8 @@ module PodsOrz
6
7
  attr_accessor :kx_pods_path
7
8
 
8
9
  def initialize(main_path)
9
- @kx_pods_path = File.expand_path("../kx_pods", main_path)
10
+ @orzconfig_parse = PodsOrz::PodOrzconfigParse.new(main_path)
11
+ @kx_pods_path = File.expand_path("../#{@orzconfig_parse.file_devpods_name}", main_path)
10
12
  end
11
13
 
12
14
  def increase_pod_version(pod)
@@ -1,7 +1,7 @@
1
1
  require 'colorize'
2
2
 
3
3
  module Logger
4
- def self.default(sentence)
4
+ def self.default(sentence)
5
5
  puts format_output(sentence).colorize(:default)
6
6
  end
7
7
 
@@ -1,3 +1,3 @@
1
1
  module PodsOrz
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.13"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: podsorz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xiangqi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-01 00:00:00.000000000 Z
11
+ date: 2021-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gli
@@ -76,7 +76,10 @@ executables:
76
76
  extensions: []
77
77
  extra_rdoc_files: []
78
78
  files:
79
+ - ".bundle/config"
79
80
  - ".gitignore"
81
+ - ".rspec"
82
+ - ".vscode/launch.json"
80
83
  - Gemfile
81
84
  - Gemfile.lock
82
85
  - LICENSE.txt
@@ -85,10 +88,12 @@ files:
85
88
  - bin/podsorz
86
89
  - lib/podsorz.rb
87
90
  - lib/podsorz/command/binary.rb
91
+ - lib/podsorz/command/check.rb
88
92
  - lib/podsorz/command/commit.rb
89
93
  - lib/podsorz/command/install.rb
90
94
  - lib/podsorz/command/publish.rb
91
95
  - lib/podsorz/command/setup.rb
96
+ - lib/podsorz/command/sort.rb
92
97
  - lib/podsorz/command/switch.rb
93
98
  - lib/podsorz/command/sync.rb
94
99
  - lib/podsorz/core/Binary/binary_builder.rb
@@ -100,16 +105,24 @@ files:
100
105
  - lib/podsorz/core/Config/pod_orzconfig_parse.rb
101
106
  - lib/podsorz/core/PodFile/podfile_io.rb
102
107
  - lib/podsorz/core/PodFile/podfile_model.rb
108
+ - lib/podsorz/core/PodsOrz/pods_check_merge.rb
103
109
  - lib/podsorz/core/PodsOrz/pods_detector.rb
104
110
  - lib/podsorz/core/PodsOrz/pods_git_manager.rb
105
111
  - lib/podsorz/core/PodsOrz/pods_git_operator.rb
106
112
  - lib/podsorz/core/PodsOrz/pods_repo.rb
113
+ - lib/podsorz/core/PodsOrz/pods_sort.rb
107
114
  - lib/podsorz/core/PodsOrz/pods_version.rb
108
115
  - lib/podsorz/core/Specs/podspec_model.rb
109
116
  - lib/podsorz/util/git_operator.rb
110
117
  - lib/podsorz/util/logger.rb
111
118
  - lib/podsorz/util/process_operator.rb
112
119
  - lib/podsorz/version.rb
120
+ - pkg/podsorz-0.0.10.gem
121
+ - pkg/podsorz-0.0.11.gem
122
+ - pkg/podsorz-0.0.12.gem
123
+ - pkg/podsorz-0.0.7.gem
124
+ - pkg/podsorz-0.0.8.gem
125
+ - pkg/podsorz-0.0.9.gem
113
126
  - podsorz.gemspec
114
127
  homepage: https://github.com/XiangqiTu
115
128
  licenses: