fastlane-plugin-zhuixi_build_app 1.0.7 → 1.1.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 +4 -4
- data/lib/fastlane/plugin/zhuixi_build_app/actions/download_resources_action.rb +11 -7
- data/lib/fastlane/plugin/zhuixi_build_app/actions/xcodeproj_merge_action.rb +107 -22
- data/lib/fastlane/plugin/zhuixi_build_app/actions/zhuixi_build_app_action.rb +0 -2
- data/lib/fastlane/plugin/zhuixi_build_app/helper/zhuixi_build_app_helper.rb +16 -1
- data/lib/fastlane/plugin/zhuixi_build_app/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0f34b6bcfccf78451954690a761669d3be0715cfd2bab6789c4887a61362436
|
4
|
+
data.tar.gz: 934901b3247745591c0c8338df2b232a266fe3793992a5577431413930a48535
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85b9e8e2e0af33e25cd886c1180babbaa525421717d0b1bc2e815ece3b2ae8b189198ad52deca8329067a18671d3df78fd37a7dccf313cdaaa7b073aae434644
|
7
|
+
data.tar.gz: fa32530a18643952328dd317b49c35af414f94b27231df770880ef6cda23a216b3e837d7a60fa12378c630455d39e9d9641d02eb83debab026c12da063480daf
|
@@ -5,21 +5,25 @@ module Fastlane
|
|
5
5
|
module Actions
|
6
6
|
class DownloadResourcesAction < BaseAction
|
7
7
|
def self.run(params)
|
8
|
-
#下载渠道资源
|
9
|
-
download_resource(params[:resourcesUrl])
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.download_resource(resourcesUrl)
|
13
8
|
|
14
9
|
#创建zhuixi
|
15
10
|
parent_path = File.dirname(lane_context[:ori_xcodeproj_path])
|
16
11
|
lane_context[:zhuixi_path] = File.join(parent_path, "zhuixi", lane_context[:platform_id].to_s)
|
17
|
-
|
12
|
+
channel_resources_folder = File.join(lane_context[:zhuixi_path], "resources")
|
13
|
+
filepath = File.join(channel_resources_folder, "ConfigInfo.plist")
|
18
14
|
if File.exist?(lane_context[:zhuixi_path].to_s)
|
15
|
+
return
|
19
16
|
FileUtils.rm_rf(lane_context[:zhuixi_path])
|
17
|
+
# if get_info_plist_value(path: filepath, key: "channelVersion")
|
18
|
+
# end
|
19
|
+
FileUtils.mkdir_p(lane_context[:zhuixi_path])
|
20
20
|
end
|
21
|
-
|
21
|
+
#下载渠道资源
|
22
|
+
download_resource(params[:resourcesUrl], parent_path)
|
23
|
+
end
|
22
24
|
|
25
|
+
def self.download_resource(resourcesUrl, parent_path)
|
26
|
+
FileUtils.mkdir_p(lane_context[:zhuixi_path])
|
23
27
|
# 下载资源包到root_folder下
|
24
28
|
destination_path = File.join(parent_path, "resource.zip")
|
25
29
|
File.open(destination_path, "wb") do |file|
|
@@ -1,5 +1,7 @@
|
|
1
1
|
require "fastlane/action"
|
2
2
|
require_relative "../actions/base_action"
|
3
|
+
require_relative "../helper/zhuixi_build_app_helper"
|
4
|
+
require "mini_magick"
|
3
5
|
|
4
6
|
module Fastlane
|
5
7
|
module Actions
|
@@ -15,7 +17,7 @@ module Fastlane
|
|
15
17
|
lane_context[:group] = lane_context[:project].main_group.find_subpath(File.join("zhuixi"), true)
|
16
18
|
lane_context[:group].set_source_tree("SOURCE_ROOT") # 把group的source_tree设置成 'SOURCE_ROOT'
|
17
19
|
getDesgroup(lane_context[:project].main_group)
|
18
|
-
FileUtils.rm_rf(Dir.glob(File.join(lane_context[:cha_resources_path], "*")))
|
20
|
+
# FileUtils.rm_rf(Dir.glob(File.join(lane_context[:cha_resources_path], "*")))
|
19
21
|
add_channel_sdk_resources()
|
20
22
|
end
|
21
23
|
|
@@ -31,6 +33,7 @@ module Fastlane
|
|
31
33
|
Dir::mkdir(lane_context[:cha_project_path], mode = 0777)
|
32
34
|
Dir.glob(File.join(lane_context[:ori_xcodeproj_path], "*")) do |file|
|
33
35
|
unless File.basename(file) == "xcshareddata"
|
36
|
+
# 检查是否在 Copy Bundle Resources 目录中
|
34
37
|
dest = File.join(lane_context[:cha_project_path], File.basename(file))
|
35
38
|
FileUtils.cp_r(file, dest)
|
36
39
|
end
|
@@ -80,6 +83,13 @@ module Fastlane
|
|
80
83
|
if group.display_name == "resources"
|
81
84
|
lane_context[:cha_resources_path] = group.real_path
|
82
85
|
removeBuildPhaseFilesRecursively(group)
|
86
|
+
|
87
|
+
relative_path = group.real_path.to_s.sub(lane_context[:project].project_dir.to_s, "")
|
88
|
+
puts "ZHUIXI---relative_path: #{relative_path}"
|
89
|
+
# 调用
|
90
|
+
clean_search_paths("FRAMEWORK_SEARCH_PATHS", relative_path)
|
91
|
+
clean_search_paths("LIBRARY_SEARCH_PATHS", relative_path)
|
92
|
+
clean_search_paths("HEADER_SEARCH_PATHS", relative_path)
|
83
93
|
group.clear
|
84
94
|
else
|
85
95
|
getDesgroup(group)
|
@@ -87,6 +97,24 @@ module Fastlane
|
|
87
97
|
end
|
88
98
|
end
|
89
99
|
|
100
|
+
# 封装通用处理逻辑
|
101
|
+
def self.clean_search_paths(setting_name, relative_path)
|
102
|
+
search_paths = lane_context[:target].build_configuration_list.get_setting(setting_name)
|
103
|
+
|
104
|
+
search_paths.each do |config, paths|
|
105
|
+
if paths.is_a?(String)
|
106
|
+
paths = [paths]
|
107
|
+
end
|
108
|
+
|
109
|
+
paths.delete_if { |path| path.include?(relative_path) }
|
110
|
+
|
111
|
+
# 保存设置
|
112
|
+
lane_context[:target].build_configuration_list.set_setting(setting_name, paths)
|
113
|
+
|
114
|
+
puts "Cleaned #{setting_name}: #{paths}"
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
90
118
|
def self.add_channel_sdk_resources()
|
91
119
|
|
92
120
|
# 设置DEBUG_INFORMATION_FORMAT
|
@@ -111,6 +139,7 @@ module Fastlane
|
|
111
139
|
# 修改 Bundle Identifier 和 Display Name
|
112
140
|
info_plist_data["CFBundleIdentifier"] = lane_context[:configParams]["gamePackageName"]
|
113
141
|
info_plist_data["CFBundleDisplayName"] = lane_context[:configParams]["gamename"]
|
142
|
+
info_plist_data["UILaunchStoryboardName"] = "LaunchScreen"
|
114
143
|
# 3. 读取 TempInfo.plist 文件
|
115
144
|
temp_info_plist_data = Plist.parse_xml(File.join(lane_context[:zhuixi_path], "TempInfo.plist"))
|
116
145
|
|
@@ -202,25 +231,26 @@ module Fastlane
|
|
202
231
|
|
203
232
|
def self.add_channel_sdk_library()
|
204
233
|
channel_resources_folder = File.join(lane_context[:zhuixi_path], "resources")
|
205
|
-
|
206
|
-
search_paths = lane_context[:target].build_configuration_list.get_setting("FRAMEWORK_SEARCH_PATHS")
|
207
|
-
library_search_paths = lane_context[:target].build_configuration_list.get_setting("LIBRARY_SEARCH_PATHS")
|
234
|
+
add_channel_badge(channel_resources_folder)
|
208
235
|
|
209
236
|
merge_nygameinfo()
|
237
|
+
lane_context[:project].save
|
210
238
|
getAllRes(channel_resources_folder)
|
211
|
-
|
212
239
|
build_app_action()
|
213
240
|
end
|
241
|
+
|
214
242
|
# 查询所有文件
|
215
243
|
def self.getAllRes(rootDir)
|
216
|
-
isfile = rootDir.to_s.end_with?(".framework", ".bundle")
|
244
|
+
isfile = rootDir.to_s.end_with?(".framework", ".bundle", ".png", ".storyboard")
|
245
|
+
launchimage_path = lane_context[:configParams]["channel_orientation"] == "portrait" ? "launchimage-landscape" : "launchimage-portrait"
|
217
246
|
if File.directory?(rootDir) and !isfile
|
218
247
|
Dir.foreach(rootDir) do |filepath|
|
219
|
-
if filepath != "." and filepath != ".." and filepath != ".DS_Store"
|
248
|
+
if filepath != "." and filepath != ".." and filepath != ".DS_Store" and filepath != launchimage_path
|
220
249
|
getAllRes(rootDir + "/" + filepath)
|
221
250
|
end
|
222
251
|
end
|
223
252
|
else
|
253
|
+
puts "ZHUIXI---文件路径:\n" + rootDir
|
224
254
|
addFileToTarget(rootDir)
|
225
255
|
end
|
226
256
|
end
|
@@ -275,7 +305,7 @@ module Fastlane
|
|
275
305
|
end
|
276
306
|
end
|
277
307
|
lane_context[:target].frameworks_build_phase.add_file_reference(file_ref, true)
|
278
|
-
elsif filename.to_s.end_with?(".plist", ".bundle")
|
308
|
+
elsif filename.to_s.end_with?(".plist", ".bundle", ".png", ".storyboard")
|
279
309
|
lane_context[:target].resources_build_phase.add_file_reference(file_ref, true)
|
280
310
|
elsif filename.to_s.end_with?(".m", ".mm", ".cpp")
|
281
311
|
lane_context[:target].source_build_phase.add_file_reference(file_ref, true)
|
@@ -288,6 +318,8 @@ module Fastlane
|
|
288
318
|
def self.merge_nygameinfo()
|
289
319
|
channel_resources_folder = File.join(lane_context[:zhuixi_path], "resources")
|
290
320
|
filepath = File.join(channel_resources_folder, "nygameinfo.plist")
|
321
|
+
# channel_storyboard_path = File.join(channel_resources_folder, "LaunchScreen.storyboard")
|
322
|
+
# Fastlane::Helper::ZhuixiBuildAppHelper.clean_storyboard_cache(channel_storyboard_path, lane_context[:selectPlatformName])
|
291
323
|
|
292
324
|
puts lane_context[:configParams]
|
293
325
|
other_action.update_plist(
|
@@ -314,6 +346,70 @@ module Fastlane
|
|
314
346
|
)
|
315
347
|
end
|
316
348
|
|
349
|
+
def self.add_channel_badge(folder_path)
|
350
|
+
xcassets_ref = nil
|
351
|
+
storyboard_ref = nil
|
352
|
+
appiconset_path = nil
|
353
|
+
channel_icon_path = nil
|
354
|
+
launch_image = nil
|
355
|
+
lane_context[:target].resources_build_phase.files.each do |item|
|
356
|
+
if item.file_ref.path.end_with?(".xcassets")
|
357
|
+
appiconset_path = File.join(item.file_ref.real_path.to_s)
|
358
|
+
puts "ZHUIXI---appiconset_path: #{appiconset_path}"
|
359
|
+
FileUtils.cp_r(appiconset_path, File.join(lane_context[:zhuixi_path]))
|
360
|
+
channel_icon_path = File.join(lane_context[:zhuixi_path], File.basename(appiconset_path))
|
361
|
+
xcassets_ref = item.file_ref
|
362
|
+
end
|
363
|
+
if item.file_ref.path.end_with?(".storyboard")
|
364
|
+
launch_screen_path = File.join(item.file_ref.real_path.to_s)
|
365
|
+
puts "ZHUIXI---launch_screen_path: #{launch_screen_path}"
|
366
|
+
storyboard_ref = item.file_ref
|
367
|
+
end
|
368
|
+
if item.file_ref.path.include?("LaunchImage.png")
|
369
|
+
puts "ZHUIXI---LaunchImage: #{item.file_ref.path}"
|
370
|
+
launch_image = item.file_ref
|
371
|
+
end
|
372
|
+
end
|
373
|
+
isLaunchImageIncluded = false
|
374
|
+
subfolders = Dir.glob("#{folder_path}/*").select { |f|
|
375
|
+
File.directory?(f)
|
376
|
+
}
|
377
|
+
is_launch_image_folder = subfolders.any? { |f|
|
378
|
+
if f.include?("launchimage")
|
379
|
+
isLaunchImageIncluded = true
|
380
|
+
end
|
381
|
+
}
|
382
|
+
|
383
|
+
# Fastlane::Helper::ZhuixiBuildAppHelper.clean_storyboard_cache(storyboard_ref.real_path.to_s, lane_context[:selectPlatformName])
|
384
|
+
|
385
|
+
lane_context[:target].resources_build_phase.remove_file_reference(xcassets_ref) if xcassets_ref
|
386
|
+
lane_context[:target].resources_build_phase.remove_file_reference(storyboard_ref) if storyboard_ref && isLaunchImageIncluded
|
387
|
+
lane_context[:target].resources_build_phase.remove_file_reference(launch_image) if launch_image && isLaunchImageIncluded
|
388
|
+
# 删除文件引用对应的文件
|
389
|
+
# xcassets_ref.remove_from_project if xcassets_ref
|
390
|
+
storyboard_ref.remove_from_project if storyboard_ref && isLaunchImageIncluded
|
391
|
+
launch_image.remove_from_project if launch_image && isLaunchImageIncluded
|
392
|
+
|
393
|
+
channel_icon_ref = lane_context[:group].new_file(channel_icon_path)
|
394
|
+
lane_context[:target].resources_build_phase.add_file_reference(channel_icon_ref) if channel_icon_ref
|
395
|
+
|
396
|
+
badge_path = Fastlane::Helper::ZhuixiBuildAppHelper.get_badge_path(lane_context[:selectPlatformName])
|
397
|
+
puts "ZHUIXI---角标路径:\n" + badge_path
|
398
|
+
badge = MiniMagick::Image.open(badge_path)
|
399
|
+
Dir.glob("#{channel_icon_path}/**/*.png").each do |image_path|
|
400
|
+
puts "image_path: #{image_path}"
|
401
|
+
image = MiniMagick::Image.open(image_path)
|
402
|
+
height = image.height
|
403
|
+
width = image.width
|
404
|
+
result = image.composite(badge) do |c|
|
405
|
+
c.compose "Over"
|
406
|
+
c.gravity "SouthEast"
|
407
|
+
c.resize "#{width}x#{height}" # 调整为原图大小
|
408
|
+
end
|
409
|
+
result.write(image_path)
|
410
|
+
end
|
411
|
+
end
|
412
|
+
|
317
413
|
def self.build_app_action()
|
318
414
|
other_action.recreate_schemes(project: lane_context[:cha_project_path])
|
319
415
|
schemefile = ""
|
@@ -324,20 +420,7 @@ module Fastlane
|
|
324
420
|
schemefile = File.basename(new_schemefilepath, ".xcscheme")
|
325
421
|
end
|
326
422
|
end
|
327
|
-
|
328
|
-
# Find.find(File.join(lane_context[:cha_project_path], "xcuserdata")) do |schemefilepath|
|
329
|
-
# if schemefilepath.include? ".xcscheme"
|
330
|
-
# schemefile = schemefilepath
|
331
|
-
# end
|
332
|
-
# end
|
333
|
-
# 执行 fastlane gym
|
334
|
-
# other_action.update_plist( # Updates the CLIENT_ID and GOOGLE_APP_ID string entries in the plist-file
|
335
|
-
# plist_path: File.join(lane_context[:zhuixi_path], "Info.plist"),
|
336
|
-
# block: proc do |plist|
|
337
|
-
# plist["CFBundleDisplayName"] = lane_context[:configParams]["gamename"]
|
338
|
-
# plist["CFBundleIdentifier"] = lane_context[:configParams]["gamePackageName"]
|
339
|
-
# end,
|
340
|
-
# )
|
423
|
+
|
341
424
|
lane_context[:project].save()
|
342
425
|
puts lane_context[:configParams]
|
343
426
|
timestamp = Time.now.strftime("%Y%m%d%H%M%S")
|
@@ -346,6 +429,8 @@ module Fastlane
|
|
346
429
|
project: lane_context[:cha_project_path],
|
347
430
|
output_name: output_name,
|
348
431
|
export_method: lane_context[:export_method],
|
432
|
+
# clean: true,
|
433
|
+
silent: true,
|
349
434
|
export_options: {
|
350
435
|
provisioningProfiles: {
|
351
436
|
lane_context[:configParams]["gamePackageName"] => lane_context[:provisioning_profile_name],
|
@@ -14,8 +14,6 @@ module Fastlane
|
|
14
14
|
resourcesUrl = other_action.get_pack_config(game_id: game_id.to_s)
|
15
15
|
other_action.download_resources(resourcesUrl: resourcesUrl)
|
16
16
|
other_action.xcodeproj_merge
|
17
|
-
current_directory = Dir.pwd
|
18
|
-
puts "当前工作目录:#{current_directory}"
|
19
17
|
end
|
20
18
|
def self.return_value
|
21
19
|
# If your method provides a return value, you can describe here what it does
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "fastlane_core/ui/ui"
|
2
2
|
|
3
3
|
module Fastlane
|
4
4
|
UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
|
@@ -11,6 +11,21 @@ module Fastlane
|
|
11
11
|
def self.show_message
|
12
12
|
UI.message("Hello from the zhuixi_build_app plugin helper!")
|
13
13
|
end
|
14
|
+
# 返回对应渠道的角标图片路径
|
15
|
+
def self.get_badge_path(channel)
|
16
|
+
root_path = Dir.pwd
|
17
|
+
File.join(root_path, "resources", "#{channel}_badge.png")
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.clean_storyboard_cache(channel_storyboard_path, channel)
|
21
|
+
if File.exists?(channel_storyboard_path)
|
22
|
+
str = File.read(channel_storyboard_path)
|
23
|
+
File.write(channel_storyboard_path, str + "<!-- Channel: " + channel + " -->")
|
24
|
+
puts "LaunchScreen.storyboard file 已修改!"
|
25
|
+
else
|
26
|
+
puts "LaunchScreen.storyboard file not found!"
|
27
|
+
end
|
28
|
+
end
|
14
29
|
end
|
15
30
|
end
|
16
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-zhuixi_build_app
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RedSevenMale
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-08-
|
11
|
+
date: 2023-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|