cocoapods-linkline 0.2.2 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 654e7f5b3c04dc3790c0283ace7db86995917189718b7ed36078fe779454fe30
4
- data.tar.gz: e5a8cafe6ad3c1ce8b614aa9ed6d823375629c049218dca734726d5b14c3fc2f
3
+ metadata.gz: 060556e0e88328405394bbe9ad9156393fa3a58bb87cfb12055d63d6a4d86ed7
4
+ data.tar.gz: bac7256d626bf4cca1c43c30b60e1c68f4cd2d8e08198213c2790a9ac058f3a7
5
5
  SHA512:
6
- metadata.gz: 8941de679756cd8928ad127d5a632e5b0e30d385882398a610b9ac864f65aa04fb5c5cbe8d1f24bb4543f831045777562d710f674394f1c9097a5f7375244b13
7
- data.tar.gz: cf33d10fc395bde6592dd3fdf46ec4772a3485eef992dee7aa5aba8b6f8d0b2159d0c2b119196e6ec7bc20d5d1afaf0b762e9602dae003eb53cc3bb2d21b7c62
6
+ metadata.gz: 12cb2fe72e0f31e22741c281f033098545235fc0ce3bb99d37c55c8a1ded8904af52396c4b9d45ae276e8ad6cf71e35ee77f8536db474f25528860e20fea1e9c
7
+ data.tar.gz: 65b2e15fca457df86d1af02d7a83f674c9c695d774815d0c9f43f4c2c6d89975360d7919f0022c0b6baeb36d20de04172320a4d9c35bf630a36e437612d1d672
@@ -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,188 @@
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_fetch
27
+
28
+ require File.join(Pathname.pwd,"#{ll_stable_lock}.rb")
29
+ require File.join(env, "#{$ll_stable_lock_origin}.rb")
30
+ stable_lock_arr = eval("#{ll_stable_lock}")
31
+ stable_lock_origin_arr = eval("#{$ll_stable_lock_origin}")
32
+ #5、show origin_stable_lock diff with local_stable_lock
33
+ ll_show_lock_diff(stable_lock_arr, stable_lock_origin_arr)
34
+
35
+ #6、rewirte local_stable_lock with origin_stable_lock
36
+ ll_rewirte_stable_lock(stable_lock_origin_arr)
37
+ end
38
+
39
+ private
40
+ # API
41
+ def ll_cloneStable
42
+ unless Dir.exist?(File.join(env))
43
+ clonePath = File.dirname(env)
44
+ FileUtils.mkdir_p clonePath
45
+ git_clone($ll_stable_source,clonePath)
46
+ end
47
+ end
48
+
49
+ def ll_show_lock_diff(stable_lock_arr, stable_lock_origin_arr)
50
+ added, updated, rollbacked = ll_compare_specs(stable_lock_arr, stable_lock_origin_arr)
51
+
52
+ if added.any?
53
+ puts "新增了以下项目:"
54
+ puts added.join("\n")
55
+ end
56
+
57
+ if updated.any?
58
+ puts "\n更新了以下项目:"
59
+ puts updated.join("\n")
60
+ end
61
+
62
+ if rollbacked.any?
63
+ puts "\n回滚了以下项目:"
64
+ puts rollbacked.join("\n")
65
+ end
66
+
67
+ unless added.any? || updated.any? || added.any?
68
+ puts "\n已经是最新版本"
69
+ end
70
+ end
71
+
72
+ def ll_rewirte_stable_lock(stable_lock_origin_arr)
73
+ File.open("#{ll_stable_lock}.rb", 'w') do |file|
74
+ file.puts "def #{ll_stable_lock}"
75
+ file.puts "["
76
+ stable_lock_origin_arr.each_with_index do |spec, index|
77
+ if index == stable_lock_origin_arr.length - 1
78
+ file.puts " #{spec.inspect}"
79
+ else
80
+ file.puts " #{spec.inspect},"
81
+ end
82
+ end
83
+ file.puts "]"
84
+ file.puts "end"
85
+ end
86
+ end
87
+
88
+ def ll_compare_specs(specs_1, specs_2)
89
+ added_projects = []
90
+ updated_projects = []
91
+ rollbacked_projects = []
92
+
93
+ specs_2.each do |project_2|
94
+ project_name_2, version_2 = project_2
95
+ matching_project_1 = specs_1.find { |project_1| project_1[0] == project_name_2 }
96
+
97
+ if matching_project_1.nil?
98
+ added_projects << "【#{project_name_2}】 (#{version_2.to_s.send(:red)})"
99
+ elsif matching_project_1[1] != version_2
100
+ if versionGreat(version_2,matching_project_1[1])
101
+ updated_projects << "【#{project_name_2}】 (#{matching_project_1[1]}) -> (#{version_2.to_s.send(:red)})"
102
+ else
103
+ rollbacked_projects << "【#{project_name_2}】 (#{version_2.to_s.send(:red)}) <- (#{matching_project_1[1]})"
104
+ end
105
+ end
106
+ end
107
+
108
+ return added_projects, updated_projects, rollbacked_projects
109
+ end
110
+
111
+ def ll_create_stable_lock_template
112
+ unless File.exist?(File.join(Pathname.pwd,"#{ll_stable_lock}.rb"))
113
+ Dir.chdir(Pathname.pwd) {
114
+ File.open("#{ll_stable_lock}.rb", 'w') do |file|
115
+ file.puts "def #{ll_stable_lock}"
116
+ file.puts "["
117
+ file.puts "]"
118
+ file.puts "end"
119
+ end
120
+ }
121
+ end
122
+ end
123
+
124
+ #####help
125
+ # compare tags (>=)
126
+ def versionGreatOrEqual(tag1, tag2)
127
+ tags1 = tag1.split(".")
128
+ tags2 = tag2.split(".")
129
+
130
+ # Fill in the missing bits so that both tags have the same number of bits
131
+ max_length = [tags1.length, tags2.length].max
132
+ tags1 += ["0"] * (max_length - tags1.length)
133
+ tags2 += ["0"] * (max_length - tags2.length)
134
+
135
+ # Compare labels one by one from high to low
136
+ (0...max_length).each do |i|
137
+ if tags1[i].to_i > tags2[i].to_i
138
+ return true
139
+ elsif tags1[i].to_i < tags2[i].to_i
140
+ return false
141
+ end
142
+ end
143
+
144
+ # If all digits are equal, the labels are considered equal
145
+ return true
146
+ end
147
+
148
+ # compare tags (>)
149
+ def versionGreat(tag1, tag2)
150
+ result = versionGreatOrEqual(tag1,tag2)
151
+ if result == true && tag1 == tag2
152
+ return false
153
+ end
154
+ return result
155
+ end
156
+
157
+ ##### constant
158
+ def ll_stable_lock
159
+ "stable_lock"
160
+ end
161
+
162
+ ##### env
163
+ def env
164
+ File.join(File.expand_path('~/.cache'), 'cocoapods-linkline','stable',$ll_stable_source.split('/').last.chomp('.git').to_s)
165
+ end
166
+
167
+ def ll_stable_lock_fold
168
+ File.dirname(Pod::Config.instance.podfile_path)
169
+ end
170
+
171
+ ##### git command
172
+ def git(*args)
173
+ Dir.chdir(File.join(env)) { return git! args }
174
+ end
175
+
176
+ def git_fetch
177
+ git('fetch') #fommate git command
178
+ end
179
+
180
+ def git_clone(source, path)
181
+ UI.section("Cloning `#{source}` into `#{path}`.") do
182
+ Dir.chdir(path) { git! ['clone', source] } #origin git command
183
+ end
184
+ end
185
+
186
+ end
187
+ end
188
+ 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.0"
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.0
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-19 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