cocoapods-aqarahome 0.0.13 → 0.0.15
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/Gemfile.lock +1 -1
- data/cocoapods-aqarahome.gemspec +7 -1
- data/lib/cocoapods-aqarahome/command/aqarahome.rb +14 -28
- data/lib/cocoapods-aqarahome/gem_version.rb +1 -1
- data/lib/cocoapods-aqarahome/post_install_patches.rb +36 -0
- data/lib/cocoapods-aqarahome/private_pod_sync.rb +296 -0
- data/lib/cocoapods-aqarahome.rb +4 -1
- data/lib/cocoapods_plugin.rb +7 -6
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9c32581436f708a55194449e96624ed0f69a09345db1578d554ceef32982abd9
|
|
4
|
+
data.tar.gz: f92712ff789e09eff7bc037c1de7451ce0870b321456a0c62968302efaaf1698
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d95550d49ad25422bb78428b7549aafc5a4e3b39eff0494e8dc28a7cbfd077f0cf95f7a9c737f57fc0c11eb9f5a51f3c5d3c4ba8ff3a0e8158a9e7e9cbd57bc6
|
|
7
|
+
data.tar.gz: c8b34570977bb9c5f245b8f19c263ff68812a8be66535ef46fc156e17e18803e28511a9631ec1a8956970c88184e3246979fe01ceb9349ca358860ea42a91696
|
data/Gemfile.lock
CHANGED
data/cocoapods-aqarahome.gemspec
CHANGED
|
@@ -13,7 +13,13 @@ Gem::Specification.new do |spec|
|
|
|
13
13
|
spec.homepage = 'https://github.com/LuckZXF/cocoapods-aqarahome'
|
|
14
14
|
spec.license = 'MIT'
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
# 不能只用 git ls-files:未提交的新文件(如 private_pod_sync.rb)会被漏打进 gem,
|
|
17
|
+
# 导致插件 require 失败后 CocoaPods 误报 “plugin be installed”。
|
|
18
|
+
spec.files = Dir.chdir(__dir__) do
|
|
19
|
+
tracked = `git ls-files -z`.split("\x0")
|
|
20
|
+
lib_files = Dir.glob('lib/**/*', File::FNM_DOTMATCH).reject { |f| File.directory?(f) }
|
|
21
|
+
(tracked + lib_files + %w[README.md LICENSE.txt cocoapods-aqarahome.gemspec]).uniq
|
|
22
|
+
end
|
|
17
23
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
24
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
25
|
spec.require_paths = ['lib']
|
|
@@ -1,46 +1,32 @@
|
|
|
1
|
-
|
|
2
1
|
require 'cocoapods-aqarahome/command/Podfile_Dev'
|
|
2
|
+
|
|
3
3
|
module CocoapodsAqarahome
|
|
4
4
|
class Command
|
|
5
|
-
# This is an example of a cocoapods plugin adding a top-level subcommand
|
|
6
|
-
# to the 'pod' command.
|
|
7
|
-
#
|
|
8
|
-
# You can also create subcommands of existing or new commands. Say you
|
|
9
|
-
# wanted to add a subcommand to `list` to show newly deprecated pods,
|
|
10
|
-
# (e.g. `pod list deprecated`), there are a few things that would need
|
|
11
|
-
# to change.
|
|
12
|
-
#
|
|
13
|
-
# - move this file to `lib/pod/command/list/deprecated.rb` and update
|
|
14
|
-
# the class to exist in the the Pod::Command::List namespace
|
|
15
|
-
# - change this class to extend from `List` instead of `Command`. This
|
|
16
|
-
# tells the plugin system that it is a subcommand of `list`.
|
|
17
|
-
# - edit `lib/cocoapods_plugins.rb` to require this file
|
|
18
|
-
#
|
|
19
|
-
# @todo Create a PR to add your plugin to CocoaPods/cocoapods.org
|
|
20
|
-
# in the `plugins.json` file, once your plugin is released.
|
|
21
|
-
#
|
|
22
5
|
class Gen < Command
|
|
23
|
-
|
|
24
|
-
self.summary = '删除Podfile.lock和Manifest.lock 的git commit相关'
|
|
6
|
+
self.summary = '按 Podfile 中 aqara_private_pod 声明同步本地 Aqara_private_pod 缓存'
|
|
25
7
|
|
|
26
8
|
self.description = <<-DESC
|
|
27
|
-
|
|
9
|
+
检查 plugin 配置的私有库目录(默认 ../Aqara_private_pod)。
|
|
10
|
+
本地已有缓存:暂存修改后切换到 Podfile 声明的 branch/tag/commit;分支再 pull 最新。
|
|
11
|
+
本地没有对应仓库:按 aqara_private_pod 的 :git 地址 clone,再切到指定节点。
|
|
28
12
|
DESC
|
|
29
13
|
|
|
30
|
-
# self.arguments = 'NAME'
|
|
31
|
-
|
|
32
14
|
def initialize(argv)
|
|
33
|
-
@
|
|
15
|
+
@path = argv.option('path')
|
|
34
16
|
super
|
|
35
17
|
end
|
|
36
18
|
|
|
37
|
-
def
|
|
38
|
-
|
|
39
|
-
|
|
19
|
+
def self.options
|
|
20
|
+
[
|
|
21
|
+
['--path=PATH', '本地私有库根目录(默认 ../Aqara_private_pod)']
|
|
22
|
+
].concat(super)
|
|
40
23
|
end
|
|
41
24
|
|
|
42
25
|
def run
|
|
43
|
-
|
|
26
|
+
options = Pod::Config.instance.podfile.plugins['cocoapods-aqarahome'] || {}
|
|
27
|
+
options = options.dup
|
|
28
|
+
options[:path] = @path if @path
|
|
29
|
+
CocoapodsAqarahome::PrivatePodSync.sync!(options)
|
|
44
30
|
end
|
|
45
31
|
end
|
|
46
32
|
end
|
|
@@ -166,6 +166,7 @@ module CocoapodsAqarahome
|
|
|
166
166
|
end
|
|
167
167
|
end
|
|
168
168
|
|
|
169
|
+
patch_testadhoc_rn_devtools_inspector(installer, config_name: testadhoc_config)
|
|
169
170
|
patch_fmt_base_header.call
|
|
170
171
|
|
|
171
172
|
wcdb_objc_support_files.each do |path|
|
|
@@ -348,6 +349,41 @@ module CocoapodsAqarahome
|
|
|
348
349
|
end
|
|
349
350
|
end
|
|
350
351
|
|
|
352
|
+
def patch_testadhoc_rn_devtools_inspector(installer, config_name:)
|
|
353
|
+
# RCT_DEV enables most DevSupport code, but DevTools target registration is
|
|
354
|
+
# also guarded by InspectorFlags in React-jsinspector.
|
|
355
|
+
rn_devtools_target_definitions = {
|
|
356
|
+
'React-Core' => ['RCT_ENABLE_INSPECTOR=1'],
|
|
357
|
+
'React-CoreModules' => ['RCT_ENABLE_INSPECTOR=1'],
|
|
358
|
+
'React-hermes' => ['HERMES_ENABLE_DEBUGGER=1'],
|
|
359
|
+
'React-RuntimeHermes' => ['HERMES_ENABLE_DEBUGGER=1'],
|
|
360
|
+
'React-jsinspector' => [
|
|
361
|
+
'REACT_NATIVE_DEBUGGER_ENABLED=1',
|
|
362
|
+
'REACT_NATIVE_DEBUGGER_ENABLED_DEVONLY=1'
|
|
363
|
+
]
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
rn_devtools_target_definitions.each do |target_name, required_definitions|
|
|
367
|
+
target = installer.pods_project.targets.find { |pod_target| pod_target.name == target_name }
|
|
368
|
+
next unless target
|
|
369
|
+
|
|
370
|
+
config = target.build_configurations.find { |build_config| build_config.name == config_name }
|
|
371
|
+
next unless config
|
|
372
|
+
|
|
373
|
+
definitions = config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] || '$(inherited)'
|
|
374
|
+
definitions = [definitions] unless definitions.is_a?(Array)
|
|
375
|
+
definitions = definitions.flat_map { |value| value.to_s.split(/\s+/) }.reject(&:empty?)
|
|
376
|
+
|
|
377
|
+
required_definitions.each do |required_definition|
|
|
378
|
+
key = required_definition.split('=').first
|
|
379
|
+
definitions.reject! { |value| value.start_with?("#{key}=") }
|
|
380
|
+
definitions << required_definition
|
|
381
|
+
end
|
|
382
|
+
|
|
383
|
+
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = definitions.uniq
|
|
384
|
+
end
|
|
385
|
+
end
|
|
386
|
+
|
|
351
387
|
def patch_awscore_unistd(installer)
|
|
352
388
|
awscore_source_fixes = {
|
|
353
389
|
File.join(installer.sandbox.root.to_s, 'AWSCore', 'AWSCore', 'FMDB', 'AWSFMDatabase.m') => [
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'fileutils'
|
|
4
|
+
|
|
5
|
+
module CocoapodsAqarahome
|
|
6
|
+
# Sync local clones under Aqara_private_pod to the refs declared by
|
|
7
|
+
# +aqara_private_pod+ in the Podfile (branch / tag / commit).
|
|
8
|
+
# Missing local caches are cloned from the declared :git URL.
|
|
9
|
+
module PrivatePodSync
|
|
10
|
+
module_function
|
|
11
|
+
|
|
12
|
+
DEFAULT_PATH = '../Aqara_private_pod'
|
|
13
|
+
STASH_MESSAGE = 'cocoapods-aqarahome: auto-stash before checkout'
|
|
14
|
+
|
|
15
|
+
def sync!(options = {})
|
|
16
|
+
options = normalize_options(options)
|
|
17
|
+
root = resolve_private_pod_root(options)
|
|
18
|
+
declarations = collect_declarations
|
|
19
|
+
if declarations.empty?
|
|
20
|
+
Pod::UI.puts '[cocoapods-aqarahome] 跳过私有库同步:Podfile 中未找到 aqara_private_pod 的 branch/tag/commit'.yellow
|
|
21
|
+
return
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
unless Dir.exist?(root)
|
|
25
|
+
Pod::UI.puts "[cocoapods-aqarahome] 私有库根目录不存在,创建:#{root}".green
|
|
26
|
+
FileUtils.mkdir_p(root)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
podspec_index = build_podspec_index(root)
|
|
30
|
+
remote_index = build_remote_index(root)
|
|
31
|
+
synced_repos = {}
|
|
32
|
+
|
|
33
|
+
declarations.each do |pod_name, decl|
|
|
34
|
+
repo_path = resolve_repo_path(root, pod_name, decl, podspec_index, remote_index)
|
|
35
|
+
|
|
36
|
+
unless repo_path
|
|
37
|
+
Pod::UI.puts "[cocoapods-aqarahome] #{pod_name} 本地无缓存且未声明 :git,跳过".yellow
|
|
38
|
+
next
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
if synced_repos.key?(repo_path)
|
|
42
|
+
previous = synced_repos[repo_path]
|
|
43
|
+
if previous[:ref] != decl[:ref]
|
|
44
|
+
Pod::UI.warn "[cocoapods-aqarahome] #{File.basename(repo_path)} 被多个 pod 引用且目标不一致:" \
|
|
45
|
+
"#{previous[:ref][:type]}=#{previous[:ref][:value]} vs " \
|
|
46
|
+
"#{decl[:ref][:type]}=#{decl[:ref][:value]},沿用首次结果"
|
|
47
|
+
end
|
|
48
|
+
next
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
unless Dir.exist?(repo_path)
|
|
52
|
+
clone_repo(decl[:git], repo_path, pod_name)
|
|
53
|
+
# clone 后刷新索引,供同仓库其它 pod 复用
|
|
54
|
+
remote_index[normalize_git_url(decl[:git])] = repo_path if decl[:git]
|
|
55
|
+
Dir.glob(File.join(repo_path, '*.podspec')).each do |podspec|
|
|
56
|
+
podspec_index[File.basename(podspec, '.podspec')] = repo_path
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
sync_repo(repo_path, pod_name, decl[:ref])
|
|
61
|
+
synced_repos[repo_path] = decl
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def normalize_options(options)
|
|
66
|
+
return {} unless options
|
|
67
|
+
|
|
68
|
+
if options.respond_to?(:to_h)
|
|
69
|
+
options.to_h
|
|
70
|
+
else
|
|
71
|
+
options
|
|
72
|
+
end.transform_keys(&:to_sym)
|
|
73
|
+
rescue StandardError
|
|
74
|
+
Hash[options.map { |k, v| [k.to_sym, v] }]
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def resolve_private_pod_root(options)
|
|
78
|
+
raw = options[:path] || options['path'] || DEFAULT_PATH
|
|
79
|
+
installation_root = Pod::Config.instance.installation_root
|
|
80
|
+
File.expand_path(raw.to_s, installation_root)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# Prefer parsing Podfile text: local/dev 模式会把 :git/:branch 等剥掉,
|
|
84
|
+
# 解析后的 Dependency 拿不到原始节点。
|
|
85
|
+
def collect_declarations
|
|
86
|
+
podfile_path = Pod::Config.instance.podfile_path
|
|
87
|
+
return {} unless podfile_path && podfile_path.exist?
|
|
88
|
+
|
|
89
|
+
content = File.read(podfile_path)
|
|
90
|
+
constants = extract_string_constants(content)
|
|
91
|
+
declarations = {}
|
|
92
|
+
|
|
93
|
+
content.each_line do |line|
|
|
94
|
+
next unless line =~ /\baqara_private_pod\b/
|
|
95
|
+
|
|
96
|
+
name = extract_pod_name(line)
|
|
97
|
+
next unless name
|
|
98
|
+
|
|
99
|
+
ref = extract_ref(line, constants)
|
|
100
|
+
next unless ref
|
|
101
|
+
|
|
102
|
+
declarations[name] = {
|
|
103
|
+
ref: ref,
|
|
104
|
+
git: extract_git_url(line, constants)
|
|
105
|
+
}
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
declarations
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def extract_string_constants(content)
|
|
112
|
+
constants = {}
|
|
113
|
+
content.scan(/^([A-Z][A-Za-z0-9_]*)\s*=\s*['"]([^'"]+)['"]/) do |name, value|
|
|
114
|
+
constants[name] = value
|
|
115
|
+
end
|
|
116
|
+
constants
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def extract_pod_name(line)
|
|
120
|
+
if (match = line.match(/\baqara_private_pod\s*\(?\s*['"]([^'"]+)['"]/))
|
|
121
|
+
match[1]
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def extract_ref(line, constants)
|
|
126
|
+
[:commit, :tag, :branch].each do |type|
|
|
127
|
+
pattern = /:#{type}\s*=>\s*(?:['"]([^'"]+)['"]|([A-Z][A-Za-z0-9_]*))/
|
|
128
|
+
match = line.match(pattern)
|
|
129
|
+
next unless match
|
|
130
|
+
|
|
131
|
+
value = match[1] || constants[match[2]]
|
|
132
|
+
return { type: type, value: value } if value && !value.empty?
|
|
133
|
+
end
|
|
134
|
+
nil
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def extract_git_url(line, constants)
|
|
138
|
+
match = line.match(/:git\s*=>\s*(?:['"]([^'"]+)['"]|([A-Z][A-Za-z0-9_]*))/)
|
|
139
|
+
return nil unless match
|
|
140
|
+
|
|
141
|
+
match[1] || constants[match[2]]
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def build_podspec_index(root)
|
|
145
|
+
index = {}
|
|
146
|
+
Dir.glob(File.join(root, '*', '*.podspec')).each do |podspec|
|
|
147
|
+
name = File.basename(podspec, '.podspec')
|
|
148
|
+
index[name] = File.dirname(podspec)
|
|
149
|
+
end
|
|
150
|
+
index
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def build_remote_index(root)
|
|
154
|
+
index = {}
|
|
155
|
+
return index unless Dir.exist?(root)
|
|
156
|
+
|
|
157
|
+
Dir.children(root).each do |entry|
|
|
158
|
+
path = File.join(root, entry)
|
|
159
|
+
next unless File.directory?(path) && git_repo?(path)
|
|
160
|
+
|
|
161
|
+
remote = IO.popen(['git', '-C', path, 'remote', 'get-url', 'origin'], err: File::NULL, &:read).to_s.strip
|
|
162
|
+
next if remote.empty?
|
|
163
|
+
|
|
164
|
+
index[normalize_git_url(remote)] = path
|
|
165
|
+
end
|
|
166
|
+
index
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
def resolve_repo_path(root, pod_name, decl, podspec_index, remote_index)
|
|
170
|
+
return podspec_index[pod_name] if podspec_index[pod_name]
|
|
171
|
+
|
|
172
|
+
git = decl[:git]
|
|
173
|
+
if git && !git.empty?
|
|
174
|
+
normalized = normalize_git_url(git)
|
|
175
|
+
return remote_index[normalized] if remote_index[normalized]
|
|
176
|
+
|
|
177
|
+
return File.join(root, repo_dirname(git))
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
nil
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
def repo_dirname(git_url)
|
|
184
|
+
File.basename(git_url.to_s.sub(/\.git\z/, ''))
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
def normalize_git_url(url)
|
|
188
|
+
url.to_s.strip
|
|
189
|
+
.sub(/\.git\z/i, '')
|
|
190
|
+
.sub(%r{\Ahttps?://}i, '')
|
|
191
|
+
.sub(%r{\Agit@}i, '')
|
|
192
|
+
.sub(%r{\Agit://}i, '')
|
|
193
|
+
.tr(':', '/')
|
|
194
|
+
.downcase
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
def clone_repo(git_url, dest, pod_name)
|
|
198
|
+
raise Pod::Informative, "[cocoapods-aqarahome] #{pod_name} 缺少 :git,无法 clone" if git_url.to_s.empty?
|
|
199
|
+
|
|
200
|
+
if Dir.exist?(dest) && !Dir.empty?(dest)
|
|
201
|
+
raise Pod::Informative,
|
|
202
|
+
"[cocoapods-aqarahome] #{pod_name} 目标目录已存在且非空,无法 clone:#{dest}"
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
FileUtils.rm_rf(dest) if Dir.exist?(dest)
|
|
206
|
+
FileUtils.mkdir_p(File.dirname(dest))
|
|
207
|
+
Pod::UI.puts "[cocoapods-aqarahome] 本地无缓存,clone #{pod_name} <- #{git_url}".green
|
|
208
|
+
run_git!(['clone', git_url, dest])
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
def sync_repo(repo_path, pod_name, ref)
|
|
212
|
+
unless git_repo?(repo_path)
|
|
213
|
+
Pod::UI.puts "[cocoapods-aqarahome] #{pod_name} 本地目录不是 git 仓库,跳过:#{repo_path}".yellow
|
|
214
|
+
return
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
Pod::UI.puts "[cocoapods-aqarahome] 同步 #{pod_name} -> #{ref[:type]} #{ref[:value]} (#{repo_path})".green
|
|
218
|
+
|
|
219
|
+
Dir.chdir(repo_path) do
|
|
220
|
+
stash_if_needed(pod_name)
|
|
221
|
+
# 不带 --tags,避免本地同名标签冲突导致整个 fetch 失败
|
|
222
|
+
run_git!(%w[fetch origin --prune], allow_failure: true)
|
|
223
|
+
|
|
224
|
+
case ref[:type]
|
|
225
|
+
when :branch
|
|
226
|
+
checkout_branch(ref[:value])
|
|
227
|
+
when :tag
|
|
228
|
+
run_git!(['fetch', 'origin', "refs/tags/#{ref[:value]}:refs/tags/#{ref[:value]}"], allow_failure: true) ||
|
|
229
|
+
run_git!(['fetch', 'origin', 'tag', ref[:value]], allow_failure: true)
|
|
230
|
+
checkout_ref(ref[:value], prefer_tag: true)
|
|
231
|
+
when :commit
|
|
232
|
+
run_git!(['fetch', 'origin', ref[:value]], allow_failure: true)
|
|
233
|
+
checkout_ref(ref[:value])
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
def git_repo?(path)
|
|
239
|
+
File.directory?(File.join(path, '.git')) ||
|
|
240
|
+
system('git', '-C', path, 'rev-parse', '--is-inside-work-tree', out: File::NULL, err: File::NULL)
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
def stash_if_needed(pod_name)
|
|
244
|
+
dirty = !`git status --porcelain`.strip.empty?
|
|
245
|
+
return unless dirty
|
|
246
|
+
|
|
247
|
+
Pod::UI.puts "[cocoapods-aqarahome] #{pod_name} 有本地修改,执行 git stash".yellow
|
|
248
|
+
run_git!(['stash', 'push', '-u', '-m', STASH_MESSAGE])
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
def checkout_branch(branch)
|
|
252
|
+
# 本地没有该分支时,从 origin/<branch> 创建并跟踪
|
|
253
|
+
unless system('git', 'show-ref', '--verify', '--quiet', "refs/heads/#{branch}")
|
|
254
|
+
run_git!(['fetch', 'origin', branch], allow_failure: true)
|
|
255
|
+
unless system('git', 'checkout', '-B', branch, '--track', "origin/#{branch}",
|
|
256
|
+
out: File::NULL, err: File::NULL)
|
|
257
|
+
run_git!(['checkout', '-B', branch, "origin/#{branch}"])
|
|
258
|
+
end
|
|
259
|
+
else
|
|
260
|
+
run_git!(['checkout', branch])
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
# 确保拉到远端分支最新节点;无 upstream 时显式 pull origin/<branch>
|
|
264
|
+
if system('git', 'rev-parse', '--abbrev-ref', '@{u}', out: File::NULL, err: File::NULL)
|
|
265
|
+
run_git!(%w[pull --ff-only])
|
|
266
|
+
else
|
|
267
|
+
run_git!(['pull', '--ff-only', 'origin', branch], allow_failure: true) ||
|
|
268
|
+
run_git!(['pull', 'origin', branch], allow_failure: true)
|
|
269
|
+
end
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
def checkout_ref(value, prefer_tag: false)
|
|
273
|
+
candidates = if prefer_tag
|
|
274
|
+
["refs/tags/#{value}", value, "tags/#{value}"]
|
|
275
|
+
else
|
|
276
|
+
[value]
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
candidates.each do |candidate|
|
|
280
|
+
return if system('git', 'checkout', '--detach', candidate, out: File::NULL, err: File::NULL)
|
|
281
|
+
return if system('git', 'checkout', candidate, out: File::NULL, err: File::NULL)
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
run_git!(['checkout', value])
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
def run_git!(args, allow_failure: false)
|
|
288
|
+
command = ['git', *args]
|
|
289
|
+
ok = system(*command)
|
|
290
|
+
return true if ok
|
|
291
|
+
return false if allow_failure
|
|
292
|
+
|
|
293
|
+
raise Pod::Informative, "[cocoapods-aqarahome] 命令失败: #{command.join(' ')} (cwd=#{Dir.pwd})"
|
|
294
|
+
end
|
|
295
|
+
end
|
|
296
|
+
end
|
data/lib/cocoapods-aqarahome.rb
CHANGED
|
@@ -11,6 +11,9 @@ module CocoapodsAqarahome
|
|
|
11
11
|
post_install_patches_path = File.expand_path('cocoapods-aqarahome/post_install_patches.rb', __dir__)
|
|
12
12
|
autoload :PostInstallPatches, post_install_patches_path
|
|
13
13
|
|
|
14
|
+
private_pod_sync_path = File.expand_path('cocoapods-aqarahome/private_pod_sync.rb', __dir__)
|
|
15
|
+
autoload :PrivatePodSync, private_pod_sync_path
|
|
16
|
+
|
|
14
17
|
autoload :Command, 'cocoapods-aqarahome/command'
|
|
15
18
|
# autoload :Podfile, 'cocoapods-aqarahome/command/Podfile_Dev'
|
|
16
|
-
end
|
|
19
|
+
end
|
data/lib/cocoapods_plugin.rb
CHANGED
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
# 会中止整个插件文件,导致 Pod::Command::Build 未注册,`pod build` 不可用。
|
|
3
3
|
require 'cocoapods-aqarahome/command/build'
|
|
4
4
|
require 'cocoapods-aqarahome'
|
|
5
|
+
|
|
5
6
|
module Pod
|
|
6
|
-
# hook
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
CocoapodsAqarahome::
|
|
7
|
+
# hook:在 install 前按 Podfile 声明同步本地 Aqara_private_pod 缓存。
|
|
8
|
+
# plugin options 示例:plugin 'cocoapods-aqarahome', :path => '../Aqara_private_pod'
|
|
9
|
+
# 注意:这里的 :path 是私有库目录,不是 gem 安装路径;gem 需单独 gem install。
|
|
10
|
+
HooksManager.register('cocoapods-aqarahome', :pre_install) do |_context, options|
|
|
11
|
+
CocoapodsAqarahome::PrivatePodSync.sync!(options)
|
|
11
12
|
end
|
|
12
|
-
end
|
|
13
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cocoapods-aqarahome
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.15
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- zhaoxifan
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-11-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -80,6 +80,7 @@ files:
|
|
|
80
80
|
- lib/cocoapods-aqarahome/command/build.rb
|
|
81
81
|
- lib/cocoapods-aqarahome/gem_version.rb
|
|
82
82
|
- lib/cocoapods-aqarahome/post_install_patches.rb
|
|
83
|
+
- lib/cocoapods-aqarahome/private_pod_sync.rb
|
|
83
84
|
- lib/cocoapods_plugin.rb
|
|
84
85
|
- spec/command/aqarahome_spec.rb
|
|
85
86
|
- spec/spec_helper.rb
|