cocoapods-mPaaS 1.0.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 +7 -0
- data/lib/cocoapods-mPaaS/baselineTools.rb +493 -0
- data/lib/cocoapods-mPaaS/checkUpdateTools.rb +42 -0
- data/lib/cocoapods-mPaaS/cocoapods_hook.rb +929 -0
- data/lib/cocoapods-mPaaS/command/mPaaS.rb +44 -0
- data/lib/cocoapods-mPaaS/command/mpaas/dev.rb +17 -0
- data/lib/cocoapods-mPaaS/command/mpaas/info.rb +170 -0
- data/lib/cocoapods-mPaaS/command/mpaas/init.rb +112 -0
- data/lib/cocoapods-mPaaS/command/mpaas/local_command.rb +49 -0
- data/lib/cocoapods-mPaaS/command/mpaas/open.rb +17 -0
- data/lib/cocoapods-mPaaS/command/mpaas/update.rb +223 -0
- data/lib/cocoapods-mPaaS/command/mpaas/version.rb +32 -0
- data/lib/cocoapods-mPaaS/command.rb +1 -0
- data/lib/cocoapods-mPaaS/dsl.rb +498 -0
- data/lib/cocoapods-mPaaS/gem_version.rb +5 -0
- data/lib/cocoapods-mPaaS/installNew.rb +303 -0
- data/lib/cocoapods-mPaaS/locales/en.yml +140 -0
- data/lib/cocoapods-mPaaS/locales/zh-Hans.yml +144 -0
- data/lib/cocoapods-mPaaS/localization.rb +238 -0
- data/lib/cocoapods-mPaaS/logTools.rb +67 -0
- data/lib/cocoapods-mPaaS/mPaaSPodfile.rb +117 -0
- data/lib/cocoapods-mPaaS/module_config.rb +298 -0
- data/lib/cocoapods-mPaaS/podfileTools.rb +48 -0
- data/lib/cocoapods-mPaaS/post_install_hook_processor.rb +61 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/DemoViewController.h +13 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/DemoViewController.m +43 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/Contents.json +6 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Discovery.imageset/Contents.json +22 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Discovery.imageset/TabBar_Discovery@2x.png +0 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Discovery.imageset/TabBar_Discovery@3x.png +0 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Discovery_Sel.imageset/Contents.json +22 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Discovery_Sel.imageset/TabBar_Discovery_Sel@2x.png +0 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Discovery_Sel.imageset/TabBar_Discovery_Sel@3x.png +0 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Friends.imageset/Contents.json +22 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Friends.imageset/TabBar_Friends@2x.png +0 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Friends.imageset/TabBar_Friends@3x.png +0 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Friends_Sel.imageset/Contents.json +22 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Friends_Sel.imageset/TabBar_Friends_Sel@2x.png +0 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Friends_Sel.imageset/TabBar_Friends_Sel@3x.png +0 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_HomeBar.imageset/Contents.json +22 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_HomeBar.imageset/icon30-line@2x.png +0 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_HomeBar.imageset/icon30-line@3x.png +0 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_HomeBar_Sel.imageset/Contents.json +22 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_HomeBar_Sel.imageset/icon30@2x.png +0 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_HomeBar_Sel.imageset/icon30@3x.png +0 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_PublicService.imageset/Contents.json +22 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_PublicService.imageset/TabBar_PublicService@2x.png +0 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_PublicService.imageset/TabBar_PublicService@3x.png +0 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_PublicService_Sel.imageset/Contents.json +22 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_PublicService_Sel.imageset/TabBar_PublicService_Sel@2x.png +0 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_PublicService_Sel.imageset/TabBar_PublicService_Sel@3x.png +0 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPAppDelegate.h +10 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPAppDelegate.m +43 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerController.h +8 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerController.m +135 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerLauncherAppDelegate.h +10 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerLauncherAppDelegate.m +43 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerLeftView.h +16 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerLeftView.m +86 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerMainViewController.h +21 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerMainViewController.m +104 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPLauncherAppDelegate.h +10 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPLauncherAppDelegate.m +91 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPNavigationController.h +8 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPNavigationController.m +25 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPNavigationLauncherAppDelegate.h +10 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPNavigationLauncherAppDelegate.m +43 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPTabBarController.h +8 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPTabBarController.m +27 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPViewController.h +8 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPViewController.m +19 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MobileRuntime.plist +26 -0
- data/lib/cocoapods-mPaaS/write_info_list_mPaaSApp.rb +125 -0
- data/lib/cocoapods-mPaaS/xcode_helper.rb +334 -0
- data/lib/cocoapods-mPaaS.rb +41 -0
- data/lib/cocoapods_plugin.rb +15 -0
- metadata +160 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: d8ec368239f62bb978ee36b7a67d27a115436705bf08d85e063b230b9eb4e5cd
|
|
4
|
+
data.tar.gz: 372a65e6f4b420839e850d601e891306a1cc3696073e90d29ce16d70ab7996f3
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: d80bc338646683eee320e9d1223e77391c30bafa49cc4ab291d01e93e80e5a04394b3f992f53bdc578943923583d28682c38e6a0053ae9cb9a43a1843f538e66
|
|
7
|
+
data.tar.gz: d0c43b1c60c0dea86cd33872be13da0e0b2919873eed8cdfd5d1b2d1b445e01572760451691d2865b245314f8a21a965e0790b39bab1592fa43c37724f3c7579
|
|
@@ -0,0 +1,493 @@
|
|
|
1
|
+
require "open-uri"
|
|
2
|
+
require "json"
|
|
3
|
+
|
|
4
|
+
class BaselineTools
|
|
5
|
+
@@baseline_hash_all = {}
|
|
6
|
+
@@libs_array_all = []
|
|
7
|
+
@@component_hash = {}
|
|
8
|
+
|
|
9
|
+
def self.getContentFileByVersion(version, raise_if_missing = false)
|
|
10
|
+
unless @@baseline_hash_all[version]
|
|
11
|
+
content_json_path, allow_fallback = getLocalContentJsonConfig
|
|
12
|
+
if content_json_path
|
|
13
|
+
abs_path = File.expand_path(content_json_path, Dir::pwd)
|
|
14
|
+
if File::exist?(abs_path)
|
|
15
|
+
baseline_hash = JSON.parse(File.read(abs_path))
|
|
16
|
+
@@baseline_hash_all[version] = baseline_hash
|
|
17
|
+
return baseline_hash
|
|
18
|
+
end
|
|
19
|
+
unless allow_fallback
|
|
20
|
+
if raise_if_missing
|
|
21
|
+
info = "content.json not found at: #{abs_path}\n" \
|
|
22
|
+
"Please run 'pod mpaas update' first to generate it.\n" \
|
|
23
|
+
"Or set fallback: mPaaS_local_content_json '#{content_json_path}', true"
|
|
24
|
+
raise Pod::Informative, info
|
|
25
|
+
end
|
|
26
|
+
return {}
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
baseline_file_path = File.join(CocoapodsmPaaS::MPAAS_LOCAL_PATH, "baseline", version, "content.json")
|
|
31
|
+
if File::exist?(baseline_file_path)
|
|
32
|
+
baseline_hash = JSON.parse(File.read(baseline_file_path))
|
|
33
|
+
@@baseline_hash_all[version] = baseline_hash
|
|
34
|
+
return baseline_hash
|
|
35
|
+
else
|
|
36
|
+
if raise_if_missing
|
|
37
|
+
info = "content.json not found for baseline #{version} !\n" \
|
|
38
|
+
"Please run 'pod mpaas update #{version}' first to generate it.\n" \
|
|
39
|
+
"Or configure in Podfile: mPaaS_local_content_json 'path/to/content.json'"
|
|
40
|
+
raise Pod::Informative, info
|
|
41
|
+
end
|
|
42
|
+
return {}
|
|
43
|
+
end
|
|
44
|
+
else
|
|
45
|
+
return @@baseline_hash_all[version]
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def self.getLocalContentJsonConfig
|
|
50
|
+
podfile_path = File.join(Dir::pwd, "Podfile")
|
|
51
|
+
return [nil, true] unless File::exist?(podfile_path)
|
|
52
|
+
mpaas_podfile = MPaaSPodfile.new
|
|
53
|
+
mpaas_podfile.run(podfile_path)
|
|
54
|
+
[mpaas_podfile.localContentJsonPath, mpaas_podfile.localContentJsonFallback]
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def self.getLocalContentJsonPath
|
|
58
|
+
config = getLocalContentJsonConfig
|
|
59
|
+
config[0]
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def self.getBaselineByVersion(version, raise_if_missing = false)
|
|
63
|
+
content_hash = getContentFileByVersion(version, raise_if_missing)
|
|
64
|
+
|
|
65
|
+
if content_hash["modules"]
|
|
66
|
+
return content_hash["modules"]
|
|
67
|
+
elsif content_hash
|
|
68
|
+
return content_hash
|
|
69
|
+
else
|
|
70
|
+
return {}
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def self.getmPaaSlibs
|
|
75
|
+
if @@libs_array_all.empty?
|
|
76
|
+
baseline_dir_path = File.join(CocoapodsmPaaS::MPAAS_LOCAL_PATH, "baseline")
|
|
77
|
+
Dir::foreach(baseline_dir_path) do |dir_name|
|
|
78
|
+
baseline_file_path = File.join(baseline_dir_path, dir_name, "content.json")
|
|
79
|
+
if File::exist?(baseline_file_path)
|
|
80
|
+
baseline_hash = JSON.parse(File.read(baseline_file_path))
|
|
81
|
+
|
|
82
|
+
# 兼容历史结构
|
|
83
|
+
modules_hash = baseline_hash["modules"] ? baseline_hash["modules"] : baseline_hash
|
|
84
|
+
|
|
85
|
+
modules_hash && modules_hash.each do |name, libs_hash|
|
|
86
|
+
libs_array = libs_hash.keys
|
|
87
|
+
if libs_array
|
|
88
|
+
libs_array.each do |lib|
|
|
89
|
+
unless @@libs_array_all.include?(lib)
|
|
90
|
+
@@libs_array_all << lib
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
else
|
|
96
|
+
LogTools.v "No baseline file found ... version : #{dir_name}"
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
return @@libs_array_all
|
|
101
|
+
else
|
|
102
|
+
return @@libs_array_all
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def self.checkBaseline?(baseline, name, version)
|
|
107
|
+
baseline_hash = getBaselineByVersion(baseline)
|
|
108
|
+
baseline_hash.values.each do |eachHash|
|
|
109
|
+
if eachHash[name] == version
|
|
110
|
+
return true
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
return false
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def self.requestComponentOnline(baseline, isPre, isDev = false)
|
|
117
|
+
begin
|
|
118
|
+
# 判断输入的 baseline 是否是个url
|
|
119
|
+
isUrl = baseline.start_with?("http")
|
|
120
|
+
|
|
121
|
+
if isUrl
|
|
122
|
+
url = baseline
|
|
123
|
+
else
|
|
124
|
+
if isDev
|
|
125
|
+
url = "#{CocoapodsmPaaS::MPAAS_IOS_TEST_PATH_PREFIX_DEV}/mPaaS-Baseline/#{baseline}/Component.json"
|
|
126
|
+
elsif isPre
|
|
127
|
+
url = "#{CocoapodsmPaaS::MPAAS_IOS_TEST_PATH_PREFIX}/mPaaS-Baseline/#{baseline}/Component.json"
|
|
128
|
+
else
|
|
129
|
+
url = "#{CocoapodsmPaaS::MPAAS_IOS_PATH_PREFIX}/mPaaS-Baseline/#{baseline}/Component.json"
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
text = URI.open(url).read
|
|
133
|
+
final_baseline = isUrl ? text["baseline"] : baseline
|
|
134
|
+
@@component_hash[final_baseline] = JSON.parse(text)
|
|
135
|
+
return final_baseline
|
|
136
|
+
rescue => exception
|
|
137
|
+
LogTools.p_red exception.to_s
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def self.getCurrentBaselineOnline
|
|
142
|
+
baseline_array = []
|
|
143
|
+
begin
|
|
144
|
+
url = "#{CocoapodsmPaaS::MPAAS_IOS_PATH_PREFIX}/mPaaS-Baseline/manifest.json"
|
|
145
|
+
text = URI.open(url).read
|
|
146
|
+
baseline_array = JSON.parse(text)["versions2"]
|
|
147
|
+
rescue => exception
|
|
148
|
+
LogTools.p_red exception.to_s
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
return baseline_array
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
def self.getComponentHashByBaseline(baseline, isPre, isDev = false)
|
|
155
|
+
final_baseline = baseline
|
|
156
|
+
unless @@component_hash[baseline]
|
|
157
|
+
final_baseline = requestComponentOnline(baseline, isPre, isDev)
|
|
158
|
+
end
|
|
159
|
+
return @@component_hash[final_baseline]
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def self.getModuleInfoByName(name, baseline)
|
|
163
|
+
content_hash = getContentFileByVersion(baseline)
|
|
164
|
+
if content_hash["module_info"] && content_hash["module_info"][name]
|
|
165
|
+
info = content_hash["module_info"][name]
|
|
166
|
+
return "#{info["title"]};#{info["description"]};#{info["releaseNote"]}"
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
unless @@component_hash[baseline]
|
|
170
|
+
requestComponentOnline(baseline, false)
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
if @@component_hash[baseline]
|
|
174
|
+
@@component_hash[baseline]["modules"].each do |module_|
|
|
175
|
+
if module_["name"] == name
|
|
176
|
+
return "#{module_["title"]};#{module_["description"]};#{module_["releaseNote"]}"
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
return "N/A"
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def self.getPodVersionOnlineByName(name, baseline)
|
|
185
|
+
unless @@component_hash[baseline]
|
|
186
|
+
requestComponentOnline(baseline, false)
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
if @@component_hash[baseline]
|
|
190
|
+
@@component_hash[baseline]["frameworks"].each do |framework|
|
|
191
|
+
if framework["name"] == name
|
|
192
|
+
return framework["version"]
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
return ""
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
def self.getBaselineMatched(podfile_path)
|
|
201
|
+
mPaaSPodfile = MPaaSPodfile.new
|
|
202
|
+
mPaaSPodfile.run(podfile_path)
|
|
203
|
+
|
|
204
|
+
if mPaaSPodfile.mPaaSBaseline
|
|
205
|
+
return filterVerison(mPaaSPodfile.mPaaSBaseline)
|
|
206
|
+
elsif mPaaSPodfile.mPaaSPodVersion
|
|
207
|
+
return filterVerison(mPaaSPodfile.mPaaSPodVersion)
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
return ""
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
def self.getVersionCodeInLocalByBaseline(baseline)
|
|
214
|
+
content_hash = getContentFileByVersion(baseline)
|
|
215
|
+
return content_hash["version_code"]
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
def self.getOptionsInLocalByBaseline(baseline)
|
|
219
|
+
content_hash = getContentFileByVersion(baseline)
|
|
220
|
+
return content_hash["options"]
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
def self.filterVerison(version)
|
|
224
|
+
s = version
|
|
225
|
+
s.gsub!("-beta", "")
|
|
226
|
+
return s
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
def self.diffBaselineFile(old_content_hash, new_content_hash, only4Show)
|
|
230
|
+
hasChanged = false
|
|
231
|
+
frameworks_changed = []
|
|
232
|
+
|
|
233
|
+
old_content_hash.each do |module_name, old_libs_hash|
|
|
234
|
+
new_libs_hash = new_content_hash[module_name]
|
|
235
|
+
# 判断 module 删除
|
|
236
|
+
if new_libs_hash
|
|
237
|
+
old_libs_hash.each do |lib_name, lib_version|
|
|
238
|
+
new_lib_version = new_libs_hash[lib_name]
|
|
239
|
+
# 判断 framework 删除
|
|
240
|
+
if new_lib_version
|
|
241
|
+
# 判断版本号变化
|
|
242
|
+
if lib_version != new_lib_version
|
|
243
|
+
LogTools.p_yellow "#{module_name} : #{lib_name} changed ( from #{lib_version} to #{new_lib_version} )" unless only4Show
|
|
244
|
+
hasChanged = true
|
|
245
|
+
frameworks_changed << "#{lib_name} : #{new_lib_version}"
|
|
246
|
+
end
|
|
247
|
+
else
|
|
248
|
+
LogTools.p_yellow "#{module_name} : #{lib_name} deleted" unless only4Show
|
|
249
|
+
hasChanged = true
|
|
250
|
+
frameworks_changed << "#{lib_name} deleted"
|
|
251
|
+
end
|
|
252
|
+
end
|
|
253
|
+
else
|
|
254
|
+
LogTools.p_yellow "#{module_name} deleted" unless only4Show
|
|
255
|
+
hasChanged = true
|
|
256
|
+
frameworks_changed << "#{module_name} deleted"
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
# 判断新增
|
|
261
|
+
new_content_hash.each do |module_name, new_libs_hash|
|
|
262
|
+
old_libs_hash = old_content_hash[module_name]
|
|
263
|
+
# 判断 module 新增
|
|
264
|
+
if old_libs_hash
|
|
265
|
+
new_libs_hash.each do |lib_name, lib_version|
|
|
266
|
+
old_lib_version = old_libs_hash[lib_name]
|
|
267
|
+
# 判断 framework 新增
|
|
268
|
+
unless old_lib_version
|
|
269
|
+
LogTools.p_yellow "#{module_name} : #{lib_name} added" unless only4Show
|
|
270
|
+
hasChanged = true
|
|
271
|
+
frameworks_changed << "#{lib_name} : #{lib_version} added"
|
|
272
|
+
end
|
|
273
|
+
end
|
|
274
|
+
else
|
|
275
|
+
LogTools.p_yellow "#{module_name} : new" unless only4Show
|
|
276
|
+
hasChanged = true
|
|
277
|
+
frameworks_changed << "#{module_name} : new"
|
|
278
|
+
end
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
LogTools.p_yellow "The baseline has no change ..." unless hasChanged unless only4Show
|
|
282
|
+
|
|
283
|
+
frameworks_changed.uniq!
|
|
284
|
+
LogTools.p_red frameworks_changed.to_s if only4Show && !frameworks_changed.empty?
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
def self.updateContentFileByComponent(version, only4Show, isPre, isDev = false, content_output_path = nil)
|
|
288
|
+
component_hash_ = getComponentHashByBaseline(version, isPre, isDev)
|
|
289
|
+
version = component_hash_["baseline"]
|
|
290
|
+
|
|
291
|
+
unless component_hash_
|
|
292
|
+
LogTools.p_red "#{version} baseline file unfound !"
|
|
293
|
+
return
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
output_path = content_output_path || File.join(CocoapodsmPaaS::MPAAS_LOCAL_PATH, "baseline", version, "content.json")
|
|
297
|
+
buildAndWriteContentJson(component_hash_, version, output_path, only4Show)
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
def self.updateContentFileFromLocal(component_json_path, content_json_path, version)
|
|
301
|
+
unless File::exist?(component_json_path)
|
|
302
|
+
LogTools.p_red "Component JSON not found: #{component_json_path}"
|
|
303
|
+
return
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
component_hash_ = JSON.parse(File.read(component_json_path))
|
|
307
|
+
version = component_hash_["baseline"] if component_hash_["baseline"]
|
|
308
|
+
|
|
309
|
+
buildAndWriteContentJson(component_hash_, version, content_json_path, false)
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
def self.buildAndWriteContentJson(component_hash_, version, content_output_path, only4Show)
|
|
313
|
+
|
|
314
|
+
# 先取哪些是 option module
|
|
315
|
+
options = []
|
|
316
|
+
|
|
317
|
+
# 写入本地基线
|
|
318
|
+
options_hash = {}
|
|
319
|
+
|
|
320
|
+
component_hash_["modules"].each do |module_|
|
|
321
|
+
if module_["options"]
|
|
322
|
+
options = options | module_["options"].map { |option| option["name"] }
|
|
323
|
+
|
|
324
|
+
# 保存 module 与 option 的对应关系(全部,给 remove_pod 用)
|
|
325
|
+
options_hash[module_["name"]] = module_["options"].map { |option| option["name"] }
|
|
326
|
+
end
|
|
327
|
+
end
|
|
328
|
+
# p options
|
|
329
|
+
content_hash = {}
|
|
330
|
+
|
|
331
|
+
# 记录每个可选模块的直接 frameworks(展开依赖前)
|
|
332
|
+
option_direct_frameworks = {}
|
|
333
|
+
|
|
334
|
+
component_hash_["modules"].each do |module_|
|
|
335
|
+
module_name = module_["name"]
|
|
336
|
+
module_frameworks = module_["frameworks"]
|
|
337
|
+
content_hash[module_name] = []
|
|
338
|
+
|
|
339
|
+
if options.include?(module_name)
|
|
340
|
+
option_direct_frameworks[module_name] = module_frameworks.dup
|
|
341
|
+
end
|
|
342
|
+
|
|
343
|
+
module_frameworks.each do |framework|
|
|
344
|
+
content_hash[module_name] << framework
|
|
345
|
+
addDependencies(content_hash[module_name], framework, module_name, component_hash_)
|
|
346
|
+
end
|
|
347
|
+
end
|
|
348
|
+
|
|
349
|
+
final_content_hash = {}
|
|
350
|
+
content_hash.each do |key, value|
|
|
351
|
+
hash_ = {}
|
|
352
|
+
value.each do |framework|
|
|
353
|
+
hash_[framework] = getVersion(framework, key, component_hash_)
|
|
354
|
+
end
|
|
355
|
+
final_content_hash[key] = hash_
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
# 构建可选模块的直接 frameworks 映射,只记录直接声明的 frameworks(不含间接依赖)
|
|
359
|
+
optional_frameworks_hash = {}
|
|
360
|
+
options.each do |opt_module_name|
|
|
361
|
+
if option_direct_frameworks[opt_module_name]
|
|
362
|
+
optional_frameworks_hash[opt_module_name] = option_direct_frameworks[opt_module_name]
|
|
363
|
+
end
|
|
364
|
+
end
|
|
365
|
+
|
|
366
|
+
# 输出下component更新时间
|
|
367
|
+
LogTools.p_yellow "updateTime : " + Time.at(component_hash_["updateTime"]).to_s unless only4Show
|
|
368
|
+
|
|
369
|
+
begin
|
|
370
|
+
# 先输出下产品集版本号
|
|
371
|
+
content_hash_for_version = getContentFileByVersion(version)
|
|
372
|
+
version_code_local = content_hash_for_version["version_code"]
|
|
373
|
+
version_code_online = component_hash_["version_code"]
|
|
374
|
+
LogTools.p_yellow "The current verison is #{version}.#{version_code_local}" if version_code_local && only4Show
|
|
375
|
+
LogTools.p_yellow "The newest verison is #{version}.#{version_code_online}" if version_code_online && only4Show
|
|
376
|
+
|
|
377
|
+
old_content_hash = getBaselineByVersion(version)
|
|
378
|
+
diffBaselineFile(old_content_hash, final_content_hash, only4Show)
|
|
379
|
+
|
|
380
|
+
# update命令时输出
|
|
381
|
+
LogTools.p_red "The current verison is updated to #{version}.#{version_code_online}" if version_code_online && !only4Show
|
|
382
|
+
|
|
383
|
+
# 检查更新时输出
|
|
384
|
+
LogTools.p_red "updateTime : " + Time.at(component_hash_["updateTime"]).to_s if only4Show
|
|
385
|
+
rescue => exception
|
|
386
|
+
LogTools.p_red exception.to_s
|
|
387
|
+
LogTools.p_yellow "#{version} will create ifneeded"
|
|
388
|
+
end
|
|
389
|
+
|
|
390
|
+
# 只是给更新提示用,不真正更新文件
|
|
391
|
+
return if only4Show
|
|
392
|
+
|
|
393
|
+
# 可能的创建目录
|
|
394
|
+
safe_create_directory_tt(File.dirname(content_output_path))
|
|
395
|
+
|
|
396
|
+
# 保存文件
|
|
397
|
+
# 新版数据结构
|
|
398
|
+
final_content_hash_new = {}
|
|
399
|
+
final_content_hash_new["baseline"] = component_hash_["baseline"]
|
|
400
|
+
final_content_hash_new["updateTime"] = component_hash_["updateTime"]
|
|
401
|
+
final_content_hash_new["version_code"] = component_hash_["version_code"]
|
|
402
|
+
final_content_hash_new["modules"] = final_content_hash
|
|
403
|
+
final_content_hash_new["options"] = options_hash
|
|
404
|
+
final_content_hash_new["optional_frameworks"] = optional_frameworks_hash
|
|
405
|
+
|
|
406
|
+
# 保存每个模块的可移除子模块(所有 options)
|
|
407
|
+
removable_options_hash = {}
|
|
408
|
+
component_hash_["modules"].each do |module_|
|
|
409
|
+
if module_["options"] && !module_["options"].empty?
|
|
410
|
+
removable_options_hash[module_["name"]] = module_["options"].map { |opt| opt["name"] }
|
|
411
|
+
end
|
|
412
|
+
end
|
|
413
|
+
final_content_hash_new["removable_options"] = removable_options_hash
|
|
414
|
+
|
|
415
|
+
module_info_hash = {}
|
|
416
|
+
component_hash_["modules"].each do |module_|
|
|
417
|
+
module_info_hash[module_["name"]] = {
|
|
418
|
+
"title" => module_["title"],
|
|
419
|
+
"description" => module_["description"],
|
|
420
|
+
"releaseNote" => module_["releaseNote"]
|
|
421
|
+
}
|
|
422
|
+
end
|
|
423
|
+
final_content_hash_new["module_info"] = module_info_hash
|
|
424
|
+
|
|
425
|
+
File::open(content_output_path, "w") do |f|
|
|
426
|
+
f.write(final_content_hash_new.to_json)
|
|
427
|
+
end
|
|
428
|
+
end
|
|
429
|
+
|
|
430
|
+
def self.getDependencies(name, component_hash_)
|
|
431
|
+
component_hash_["frameworks"].each do |framework|
|
|
432
|
+
if framework["name"] == name
|
|
433
|
+
return framework["dependencies"]
|
|
434
|
+
end
|
|
435
|
+
end
|
|
436
|
+
|
|
437
|
+
return []
|
|
438
|
+
end
|
|
439
|
+
|
|
440
|
+
def self.getVersion(name, module_name, component_hash_)
|
|
441
|
+
# 先匹配 differences
|
|
442
|
+
component_hash_["differences"] && component_hash_["differences"].each do |framework|
|
|
443
|
+
if framework["name"] == name
|
|
444
|
+
framework["info"].each do |info|
|
|
445
|
+
if info["module"] == module_name
|
|
446
|
+
if info["framework"]["version"]
|
|
447
|
+
return info["framework"]["version"]
|
|
448
|
+
end
|
|
449
|
+
end
|
|
450
|
+
end
|
|
451
|
+
end
|
|
452
|
+
end
|
|
453
|
+
|
|
454
|
+
component_hash_["frameworks"].each do |framework|
|
|
455
|
+
if framework["name"] == name
|
|
456
|
+
return framework["version"]
|
|
457
|
+
end
|
|
458
|
+
end
|
|
459
|
+
|
|
460
|
+
return ""
|
|
461
|
+
end
|
|
462
|
+
|
|
463
|
+
def self.addDependencies(array, name, module_name, component_hash_)
|
|
464
|
+
component_hash_["frameworks"].each do |framework|
|
|
465
|
+
if framework["name"] == name
|
|
466
|
+
dependencies_array = []
|
|
467
|
+
|
|
468
|
+
# 先处理下 differences
|
|
469
|
+
component_hash_["differences"] && component_hash_["differences"].each do |framework|
|
|
470
|
+
if framework["name"] == name
|
|
471
|
+
framework["info"].each do |info|
|
|
472
|
+
if info["module"] == module_name
|
|
473
|
+
if info["framework"]["dependencies"]
|
|
474
|
+
dependencies_array = info["framework"]["dependencies"]
|
|
475
|
+
end
|
|
476
|
+
end
|
|
477
|
+
end
|
|
478
|
+
end
|
|
479
|
+
end
|
|
480
|
+
|
|
481
|
+
dependencies_array = framework["dependencies"] if dependencies_array.empty?
|
|
482
|
+
|
|
483
|
+
dependencies_array && dependencies_array.each do |dependency|
|
|
484
|
+
unless array.include?(dependency)
|
|
485
|
+
array << dependency
|
|
486
|
+
|
|
487
|
+
addDependencies(array, dependency, module_name, component_hash_) unless getDependencies(dependency, component_hash_).empty?
|
|
488
|
+
end
|
|
489
|
+
end
|
|
490
|
+
end
|
|
491
|
+
end
|
|
492
|
+
end
|
|
493
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require 'cocoapods-mPaaS/localization'
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class CheckUpdateTools
|
|
5
|
+
def self.checkNew(version)
|
|
6
|
+
# 先判断本地
|
|
7
|
+
content_hash = BaselineTools.getContentFileByVersion(version)
|
|
8
|
+
|
|
9
|
+
unless content_hash["updateTime"]
|
|
10
|
+
hasNewVerison(version)
|
|
11
|
+
return
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# 取远程
|
|
15
|
+
component_hash = BaselineTools.getComponentHashByBaseline(version, false)
|
|
16
|
+
if component_hash
|
|
17
|
+
component_hash["updateTime"].to_i > content_hash["updateTime"].to_i ? hasNewVerison(version) : hasNoUpdate(version, content_hash["version_code"])
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# 对外隐藏 ?
|
|
23
|
+
def self.hasNewVerison(version)
|
|
24
|
+
LogTools.p_yellow Pod::MPAAS::Localization.t('mpaas.update_check.start_check')
|
|
25
|
+
LogTools.p_red "The baseline #{version} has new version !"
|
|
26
|
+
|
|
27
|
+
begin
|
|
28
|
+
BaselineTools.updateContentFileByComponent(version, true, false)
|
|
29
|
+
rescue => exception
|
|
30
|
+
LogTools.p_red exception.to_s
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
LogTools.p_red ""
|
|
34
|
+
LogTools.p_red "you can run 'pod mpaas update #{version}' to update it, then run 'pod install' again"
|
|
35
|
+
LogTools.p_yellow Pod::MPAAS::Localization.t('mpaas.update_check.check_finished')
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def self.hasNoUpdate(version, version_code)
|
|
39
|
+
last_version = version_code ? ("." + version_code.to_s) : "";
|
|
40
|
+
LogTools.p_yellow "The baseline #{version}#{last_version} is the latest version ..."
|
|
41
|
+
end
|
|
42
|
+
end
|