cocoapods-hooks 0.0.10 → 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: 944d06ff39edef31a02642541403e28285f6f207baea78a31ad139683b9e88af
4
- data.tar.gz: 3b18ef35d10125364fb8054a7cc419c7379da2e4427e590c304de057279216e5
3
+ metadata.gz: 8affd8bf4ae957991daa45b59263f506190970264371ee38b68eb6f7b8e24aa6
4
+ data.tar.gz: cdb7f21eee96f0aae4225a3c29d6100a93863c2ae8c8a854a32c80a6cb86dcab
5
5
  SHA512:
6
- metadata.gz: 0ec0d8f75f98de2013e0761558a6d94b7752bef8add157773312d3fa1e8df0b4f2bc66cf9aebc5fe8593c584d1b58466a7304f253ead38d0dfe2f14d32a3a080
7
- data.tar.gz: 897ef05445a6a25b3dc78897b7e60d0593a2e4833c5b2568909985bb7e8774710398502993cdc37ab67700cd9d15336663532ac72a0b2a52382a0f7d2972fe4d
6
+ metadata.gz: 1ac2b4f8f0f6c32c5cf1b50abdbcc972e0d5e38dbae02d1a3456e2b9704f2760601e7832f877cb906297d2d5b67f361486a2ede38e83d3b64e9af410620d4048
7
+ data.tar.gz: 61397e6ae3e49e429da9c507f568ab51d5b50125c1656cdb76425f1e6b2d9fab12bf01bea98032a54e08e6fa3121d9b233c25dfb0b96cb4cad3199077dc55bdd
@@ -1,3 +1,3 @@
1
1
  module CocoapodsHooks
2
- VERSION = "0.0.10"
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.10
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-07-25 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