cocoapods-hooks 0.0.9 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c3c0176c56d71c7d256123546d113a4f0740b8507ca254cf390f5d8264f85d1b
4
- data.tar.gz: 3bec9eb2e299274641294082667bb02a33bddd4d7bd3d33f2c5f91e83dee01a2
3
+ metadata.gz: 8affd8bf4ae957991daa45b59263f506190970264371ee38b68eb6f7b8e24aa6
4
+ data.tar.gz: cdb7f21eee96f0aae4225a3c29d6100a93863c2ae8c8a854a32c80a6cb86dcab
5
5
  SHA512:
6
- metadata.gz: f8154255f33e368846b6d3e31de254e661952417f89c10266ef563ff00a84dc211e0a63a299f8cd212e02c895db101fa012fb43a739cb2805d696a6990758e9e
7
- data.tar.gz: f3d394c48a29ef77f1975e918dc3ed01f716d412cebd523d4a639e5f1f35b720960bc88cfa6e26d5bf49e8dd798388d52b6e859b9a0c18990ce9b53e771aa57c
6
+ metadata.gz: 1ac2b4f8f0f6c32c5cf1b50abdbcc972e0d5e38dbae02d1a3456e2b9704f2760601e7832f877cb906297d2d5b67f361486a2ede38e83d3b64e9af410620d4048
7
+ data.tar.gz: 61397e6ae3e49e429da9c507f568ab51d5b50125c1656cdb76425f1e6b2d9fab12bf01bea98032a54e08e6fa3121d9b233c25dfb0b96cb4cad3199077dc55bdd
@@ -70,15 +70,15 @@ module Pod
70
70
  end
71
71
  home_user_dir = Dir.pwd + "/ios_project_config/#{tenant_id}/resource/HomeUser/."
72
72
  if File.exist?(home_user_dir)
73
- FileUtils.cp_r(Dir.pwd + "/ios_project_config/#{tenant_id}/resource/HomeUser/.", Dir.pwd + '/AddxAi/Classes/A4xBaseSDK/Resources/Assets.xcassets/HomePage')
73
+ FileUtils.cp_r(Dir.pwd + "/ios_project_config/#{tenant_id}/resource/HomeUser/.", Dir.pwd + '/BaseUI/Resources/Assets.xcassets/HomePage')
74
74
  end
75
75
  account_logo_dir = Dir.pwd + "/ios_project_config/#{tenant_id}/resource/Account/account_logo.imageset"
76
76
  if File.exist?(account_logo_dir)
77
- FileUtils.cp_r(Dir.pwd + "/ios_project_config/#{tenant_id}/resource/Account/account_logo.imageset", Dir.pwd + '/AddxAi/Classes/A4xBaseSDK/Resources/Assets.xcassets/Account')
77
+ FileUtils.cp_r(Dir.pwd + "/ios_project_config/#{tenant_id}/resource/Account/account_logo.imageset", Dir.pwd + '/BaseUI/Resources/Assets.xcassets/Account')
78
78
  end
79
79
  user_login_bg = Dir.pwd + "/ios_project_config/#{tenant_id}/resource/Account/user_login_bg.png"
80
80
  if File.exist?(user_login_bg)
81
- FileUtils.cp(Dir.pwd + "/ios_project_config/#{tenant_id}/resource/Account/user_login_bg.png", Dir.pwd + '/AddxAi/Classes/A4xBaseSDK/Resources/other/Resource/user_login_bg.png')
81
+ FileUtils.cp(Dir.pwd + "/ios_project_config/#{tenant_id}/resource/Account/user_login_bg.png", Dir.pwd + '/BaseUI/Resources/other/Resource/user_login_bg.png')
82
82
  end
83
83
  # 拷贝完成后,删除本地的配置文件夹
84
84
  FileUtils.rm_r('ios_project_config')
@@ -1,3 +1,3 @@
1
1
  module CocoapodsHooks
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.11"
3
3
  end
@@ -2,14 +2,38 @@ require 'cocoapods-hooks/command'
2
2
  require 'cocoapods'
3
3
 
4
4
  module CocoapodsHooks
5
+
5
6
  # 注册 pod install 钩子
6
7
  Pod::HooksManager.register('cocoapods-hooks', :pre_install) do |installer|
7
8
  p "cocoapods-plugin-hooks, hooks pre_install"
9
+ podfile_directory = File.dirname(Pod::Config.instance.podfile_path)
10
+ p "当前Podfile的路径: #{podfile_directory}"
11
+
12
+ # 检查Podfile内容
13
+ podfile_path = File.join(podfile_directory, "Podfile")
14
+ podfile_content = File.read(podfile_path)
15
+
16
+ if podfile_content.match(/pod 'SmartDeviceCoreSDK', '[\w.-]+', :subspecs => \[.*'Source.*'\]/) || podfile_content.include?("pod 'SmartDeviceCoreSDK/Source'")
17
+ puts "源码依赖"
18
+ find_and_replace_podspec_files(podfile_directory, :pre_install)
19
+ else
20
+ puts "二进制依赖,直接进行pod install"
21
+ end
8
22
  end
9
23
 
10
24
 
11
25
  Pod::HooksManager.register('cocoapods-hooks', :post_install) do |installer|
12
26
  p "cocoapods-plugin-hooks, hooks post_install"
27
+ podfile_directory = File.dirname(Pod::Config.instance.podfile_path)
28
+
29
+ # 检查Podfile内容
30
+ podfile_path = File.join(podfile_directory, "Podfile")
31
+ podfile_content = File.read(podfile_path)
32
+
33
+ if podfile_content.match(/pod 'SmartDeviceCoreSDK', '[\w.-]+', :subspecs => \[.*'Source.*'\]/) ||
34
+ podfile_content.include?("pod 'SmartDeviceCoreSDK/Source'")
35
+ find_and_replace_podspec_files(podfile_directory, :post_install)
36
+ end
13
37
  end
14
38
 
15
39
  Pod::HooksManager.register('cocoapods-hooks', :source_provider) do |context|
@@ -24,4 +48,44 @@ module CocoapodsHooks
24
48
  p "cocoapods-plugin-hooks, hooks post_integrate"
25
49
  end
26
50
 
51
+ def self.find_and_replace_podspec_files(directory, stage)
52
+ Dir.foreach(directory) do |file|
53
+ next if file == '.' || file == '..'
54
+
55
+ file_path = File.join(directory, file)
56
+
57
+ if File.directory?(file_path)
58
+ # 如果是目录,递归遍历子目录
59
+ find_and_replace_podspec_files(file_path, stage)
60
+ elsif file.end_with?(".podspec")
61
+ # puts "找到.podspec文件: #{file_path}"
62
+ replace_text_in_podspec(file_path, stage)
63
+ end
64
+ end
65
+ end
66
+
67
+ def self.replace_text_in_podspec(podspec_file_path, stage)
68
+ podspec_content = File.read(podspec_file_path)
69
+
70
+ if stage == :pre_install
71
+ # 在pre_install阶段执行替换操作
72
+ modified_podspec_content = podspec_content.gsub("'SmartDeviceCoreSDK'", "'SmartDeviceCoreSDK/Source'")
73
+ File.open(podspec_file_path, "w") {|file| file.puts modified_podspec_content}
74
+
75
+ elsif stage == :post_install
76
+ # 在post_install阶段执行还原操作
77
+ modified_podspec_content = podspec_content.gsub("'SmartDeviceCoreSDK/Source'", "'SmartDeviceCoreSDK'")
78
+ File.open(podspec_file_path, "w") {|file| file.puts modified_podspec_content}
79
+
80
+ else
81
+ return
82
+ end
83
+
84
+
85
+ File.open(podspec_file_path, "w") do |file|
86
+ file.puts modified_podspec_content
87
+ end
88
+ end
89
+
90
+
27
91
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-hooks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - huafeng
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-06 00:00:00.000000000 Z
11
+ date: 2023-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler