cocoapods-linkline 0.2.2 → 0.3.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 654e7f5b3c04dc3790c0283ace7db86995917189718b7ed36078fe779454fe30
4
- data.tar.gz: e5a8cafe6ad3c1ce8b614aa9ed6d823375629c049218dca734726d5b14c3fc2f
3
+ metadata.gz: dfaad3614b774f7f8090bbdfa2d473195e9d511df7961d4281bb4daea2fdb428
4
+ data.tar.gz: 70195a0667aa1831ed0f1f88aed4c23d86bebc28b54bafdde59334f59c4673dc
5
5
  SHA512:
6
- metadata.gz: 8941de679756cd8928ad127d5a632e5b0e30d385882398a610b9ac864f65aa04fb5c5cbe8d1f24bb4543f831045777562d710f674394f1c9097a5f7375244b13
7
- data.tar.gz: cf33d10fc395bde6592dd3fdf46ec4772a3485eef992dee7aa5aba8b6f8d0b2159d0c2b119196e6ec7bc20d5d1afaf0b762e9602dae003eb53cc3bb2d21b7c62
6
+ metadata.gz: 549f0fe3eacc95c91a4e67cef950187067776c2de6402d24a9e100c96d7e823ea2cc620d1d76bb9763667deeb6937cb3459ce5aed7f09661e1682dc1769f56a3
7
+ data.tar.gz: 287ae23888bb5a3cbb5c7fec3ee86133d56c295c7c10f9b5046578d8973955ee0bbed69b6eb934a8b41b9834cbe2abbabd169c13e575e927172ee055c237b720
@@ -0,0 +1,10 @@
1
+ module Pod
2
+ class Podfile
3
+ module DSL
4
+ def stable(source,spce_name)
5
+ $ll_stable_source = source
6
+ $ll_stable_lock_origin = spce_name
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,197 @@
1
+ module Pod
2
+ class Command
3
+ class Stable < Command
4
+ require 'fileutils'
5
+ require 'cocoapods/executable.rb'
6
+ extend Executable
7
+ executable :git
8
+
9
+ self.summary = 'a cocoapods plugin to fetch origin lock'
10
+
11
+ def initialize(argv)
12
+ super
13
+ end
14
+
15
+ def run
16
+ #1、first create stable_lock.rb if no exit, and input a template function for the podfile
17
+ ll_create_stable_lock_template
18
+
19
+ #2、load podfile to fetch ll_stable_source and ll_stable_lock_origin
20
+ verify_podfile_exists!
21
+
22
+ #3、clone module to cache dir
23
+ ll_cloneStable
24
+
25
+ #4、fetch newest code
26
+ git_reset
27
+ git_pull
28
+
29
+ require File.join(Pathname.pwd,"#{ll_stable_lock}.rb")
30
+ require File.join(env, "#{$ll_stable_lock_origin}.rb")
31
+ stable_lock_arr = eval("#{ll_stable_lock}")
32
+ stable_lock_origin_arr = eval("#{$ll_stable_lock_origin}")
33
+ #5、show origin_stable_lock diff with local_stable_lock
34
+ ll_show_lock_diff(stable_lock_arr, stable_lock_origin_arr)
35
+
36
+ #6、rewirte local_stable_lock with origin_stable_lock
37
+ ll_rewirte_stable_lock(stable_lock_origin_arr)
38
+ end
39
+
40
+ private
41
+ # API
42
+ def ll_cloneStable
43
+ unless Dir.exist?(File.join(env))
44
+ clonePath = File.dirname(env)
45
+ FileUtils.mkdir_p clonePath
46
+ git_clone($ll_stable_source,clonePath)
47
+ end
48
+ end
49
+
50
+ def ll_show_lock_diff(stable_lock_arr, stable_lock_origin_arr)
51
+ added, updated, rollbacked = ll_compare_specs(stable_lock_arr, stable_lock_origin_arr)
52
+
53
+ #31m: 红色 32m:绿色 33m:黄色 34m:蓝色
54
+ #puts "\e[34m#{string}\e[0m"
55
+ if added.any?
56
+ puts "\n新增了以下项目:".send(:green)
57
+ puts added.join("\n")
58
+ end
59
+
60
+ if updated.any?
61
+ puts "\n更新了以下项目:".send(:blue)
62
+ puts updated.join("\n")
63
+ end
64
+
65
+ if rollbacked.any?
66
+ puts "\n回滚了以下项目:".send(:red)
67
+ puts rollbacked.join("\n")
68
+ end
69
+
70
+ unless added.any? || updated.any? || added.any?
71
+ puts "\n已经是最新版本".send(:green)
72
+ end
73
+ end
74
+
75
+ def ll_rewirte_stable_lock(stable_lock_origin_arr)
76
+ File.open("#{ll_stable_lock}.rb", 'w') do |file|
77
+ file.puts "def #{ll_stable_lock}"
78
+ file.puts "["
79
+ stable_lock_origin_arr.each_with_index do |spec, index|
80
+ if index == stable_lock_origin_arr.length - 1
81
+ file.puts " #{spec.inspect}"
82
+ else
83
+ file.puts " #{spec.inspect},"
84
+ end
85
+ end
86
+ file.puts "]"
87
+ file.puts "end"
88
+ end
89
+ end
90
+
91
+ def ll_compare_specs(specs_1, specs_2)
92
+ added_projects = []
93
+ updated_projects = []
94
+ rollbacked_projects = []
95
+
96
+ specs_2.each do |project_2|
97
+ project_name_2, version_2 = project_2
98
+ matching_project_1 = specs_1.find { |project_1| project_1[0] == project_name_2 }
99
+
100
+ if matching_project_1.nil?
101
+ added_projects << "【#{project_name_2}】 (#{version_2.to_s.send(:green)})"
102
+ elsif matching_project_1[1] != version_2
103
+ if versionGreat(version_2,matching_project_1[1])
104
+ updated_projects << "【#{project_name_2}】 (#{matching_project_1[1]}) -> (#{version_2.to_s.send(:blue)})"
105
+ else
106
+ rollbacked_projects << "【#{project_name_2}】 (#{version_2.to_s.send(:red)}) <- (#{matching_project_1[1]})"
107
+ end
108
+ end
109
+ end
110
+
111
+ return added_projects, updated_projects, rollbacked_projects
112
+ end
113
+
114
+ def ll_create_stable_lock_template
115
+ unless File.exist?(File.join(Pathname.pwd,"#{ll_stable_lock}.rb"))
116
+ Dir.chdir(Pathname.pwd) {
117
+ File.open("#{ll_stable_lock}.rb", 'w') do |file|
118
+ file.puts "def #{ll_stable_lock}"
119
+ file.puts "["
120
+ file.puts "]"
121
+ file.puts "end"
122
+ end
123
+ }
124
+ end
125
+ end
126
+
127
+ #####help
128
+ # compare tags (>=)
129
+ def versionGreatOrEqual(tag1, tag2)
130
+ tags1 = tag1.split(".")
131
+ tags2 = tag2.split(".")
132
+
133
+ # Fill in the missing bits so that both tags have the same number of bits
134
+ max_length = [tags1.length, tags2.length].max
135
+ tags1 += ["0"] * (max_length - tags1.length)
136
+ tags2 += ["0"] * (max_length - tags2.length)
137
+
138
+ # Compare labels one by one from high to low
139
+ (0...max_length).each do |i|
140
+ if tags1[i].to_i > tags2[i].to_i
141
+ return true
142
+ elsif tags1[i].to_i < tags2[i].to_i
143
+ return false
144
+ end
145
+ end
146
+
147
+ # If all digits are equal, the labels are considered equal
148
+ return true
149
+ end
150
+
151
+ # compare tags (>)
152
+ def versionGreat(tag1, tag2)
153
+ result = versionGreatOrEqual(tag1,tag2)
154
+ if result == true && tag1 == tag2
155
+ return false
156
+ end
157
+ return result
158
+ end
159
+
160
+ ##### constant
161
+ def ll_stable_lock
162
+ "stable_lock"
163
+ end
164
+
165
+ ##### env
166
+ def env
167
+ File.join(File.expand_path('~/.cache'), 'cocoapods-linkline','stable',$ll_stable_source.split('/').last.chomp('.git').to_s)
168
+ end
169
+
170
+ def ll_stable_lock_fold
171
+ File.dirname(Pod::Config.instance.podfile_path)
172
+ end
173
+
174
+ ##### git command
175
+ def git(*args)
176
+ Dir.chdir(File.join(env)) {
177
+ return git! args
178
+ }
179
+ end
180
+
181
+ def git_reset
182
+ git('reset','--hard') #fommate git command
183
+ end
184
+
185
+ def git_pull
186
+ git('pull','origin','main','-f') #fommate git command
187
+ end
188
+
189
+ def git_clone(source, path)
190
+ UI.section("Cloning `#{source}` into `#{path}`.") do
191
+ Dir.chdir(path) { git! ['clone', source] } #origin git command
192
+ end
193
+ end
194
+
195
+ end
196
+ end
197
+ end
@@ -1,4 +1,8 @@
1
- require 'cocoapods-linkline/command/linkline'
2
- require 'cocoapods-linkline/command/target-linkline'
3
- require 'cocoapods-linkline/command/targetdefinition-linkline'
4
- require 'cocoapods-linkline/command/targetValidator-linkline'
1
+ #linkline
2
+ require 'cocoapods-linkline/command/linkline/linkline'
3
+ require 'cocoapods-linkline/command/linkline/target-linkline'
4
+ require 'cocoapods-linkline/command/linkline/targetdefinition-linkline'
5
+ require 'cocoapods-linkline/command/linkline/targetValidator-linkline'
6
+ #stable
7
+ require 'cocoapods-linkline/command/stable/stable'
8
+ require 'cocoapods-linkline/command/stable/podfile-linkline'
@@ -1,3 +1,3 @@
1
1
  module CocoapodsLinkline
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-linkline
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - youhui
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-30 00:00:00.000000000 Z
11
+ date: 2023-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -54,10 +54,12 @@ files:
54
54
  - cocoapods-linkline.gemspec
55
55
  - lib/cocoapods-linkline.rb
56
56
  - lib/cocoapods-linkline/command.rb
57
- - lib/cocoapods-linkline/command/linkline.rb
58
- - lib/cocoapods-linkline/command/target-linkline.rb
59
- - lib/cocoapods-linkline/command/targetValidator-linkline.rb
60
- - lib/cocoapods-linkline/command/targetdefinition-linkline.rb
57
+ - lib/cocoapods-linkline/command/linkline/linkline.rb
58
+ - lib/cocoapods-linkline/command/linkline/target-linkline.rb
59
+ - lib/cocoapods-linkline/command/linkline/targetValidator-linkline.rb
60
+ - lib/cocoapods-linkline/command/linkline/targetdefinition-linkline.rb
61
+ - lib/cocoapods-linkline/command/stable/podfile-linkline.rb
62
+ - lib/cocoapods-linkline/command/stable/stable.rb
61
63
  - lib/cocoapods-linkline/gem_version.rb
62
64
  - lib/cocoapods_plugin.rb
63
65
  - spec/command/linkline_spec.rb
@@ -81,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
83
  - !ruby/object:Gem::Version
82
84
  version: '0'
83
85
  requirements: []
84
- rubygems_version: 3.1.2
86
+ rubygems_version: 3.4.19
85
87
  signing_key:
86
88
  specification_version: 4
87
89
  summary: Build the component and all child inherit dependencies with dynamic framework pod