cocoapods-hooks 0.0.10 → 0.0.11
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/cocoapods-hooks/gem_version.rb +1 -1
- data/lib/cocoapods_plugin.rb +64 -0
- 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: 8affd8bf4ae957991daa45b59263f506190970264371ee38b68eb6f7b8e24aa6
|
4
|
+
data.tar.gz: cdb7f21eee96f0aae4225a3c29d6100a93863c2ae8c8a854a32c80a6cb86dcab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ac2b4f8f0f6c32c5cf1b50abdbcc972e0d5e38dbae02d1a3456e2b9704f2760601e7832f877cb906297d2d5b67f361486a2ede38e83d3b64e9af410620d4048
|
7
|
+
data.tar.gz: 61397e6ae3e49e429da9c507f568ab51d5b50125c1656cdb76425f1e6b2d9fab12bf01bea98032a54e08e6fa3121d9b233c25dfb0b96cb4cad3199077dc55bdd
|
data/lib/cocoapods_plugin.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2023-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|