Module: CocoapodsSoulComponentPlugin
- Defined in:
- lib/cocoapods-soul-component-plugin/gem_version.rb,
lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb
Defined Under Namespace
Classes: Soul_Component
Constant Summary collapse
- VERSION =
'0.0.23'- @@components =
[]
- @@use_source =
false- @@import_dependency =
''
Class Method Summary collapse
- .add_refrence(file_path) ⇒ Object
- .checkValidComponents ⇒ Object
- .component_file_path ⇒ Object
- .component_user_file_path ⇒ Object
- .components ⇒ Object
- .generateComponents ⇒ Object
- .import_dependency ⇒ Object
- .import_dependency=(t_import_dependency) ⇒ Object
- .podfile_path ⇒ Object
- .post_run ⇒ Object
- .pre_run ⇒ Object
- .root_path ⇒ Object
- .use_components ⇒ Object
- .use_source ⇒ Object
- .use_source=(t_use_source) ⇒ Object
Class Method Details
.add_refrence(file_path) ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 129 def self.add_refrence(file_path) project = Xcodeproj::Project.open(Pod::Config.instance.sandbox.project_path) # 获取主group group = project.main_group group.set_source_tree('SOURCE_ROOT') # 向group中添加 文件引用 file_ref = group.new_reference(file_path) # podfile_local排序 podfile_local_group = group.children.last group.children.pop group.children.unshift(podfile_local_group) project.save end |
.checkValidComponents ⇒ Object
181 182 183 184 185 186 187 188 189 190 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 181 def self.checkValidComponents isValid = true @@components.each do |each| if each.name.nil? || each.git.nil? || each.local.nil? || each.submodule.nil? Pod::UI.puts "缺少必要参数,name/git/local/submodule为必要参数:#{each.to_hash}".red isValid = false end end isValid end |
.component_file_path ⇒ Object
103 104 105 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 103 def self.component_file_path "#{root_path}/devops/component.json" end |
.component_user_file_path ⇒ Object
107 108 109 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 107 def self.component_user_file_path "#{root_path}/devops/component_user.json" end |
.components ⇒ Object
66 67 68 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 66 def self.components @@components end |
.generateComponents ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 144 def self.generateComponents components = [] json = File.read(component_file_path) obj = JSON.parse(json) dependency_user = nil dependency_import = nil if File.exist?(component_user_file_path) json_user = File.read(component_user_file_path) obj_user = JSON.parse(json_user) obj = obj.deep_merge!(obj_user) puts "混入用户配置,结果为:#{obj}" end if @@import_dependency.length.positive? import_json = JSON.parse(self.import_dependency) obj = obj.deep_merge!(import_json) puts "混入导入配置,结果为:#{obj}" end dependencies = obj['dependencies'] dependencies.each do |each| component = Soul_Component.new(each[0], each[1]['local'], each[1]['submodule'], each[1]['version'], each[1]['git'], each[1]['branch'], each[1]['path'], each[1]['commit']) if @@use_source component.local = true if Pod::Downloader::Git.check_if_has_auth_clone(component.git) == false component.local = false Pod::UI.puts "本地依赖 #{component.name} 切换失败,使用 binary 。参数:#{component.to_hash}".red end end components.push(component) end components end |
.import_dependency ⇒ Object
62 63 64 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 62 def self.import_dependency @@import_dependency end |
.import_dependency=(t_import_dependency) ⇒ Object
58 59 60 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 58 def self.import_dependency=(t_import_dependency) @@import_dependency = t_import_dependency end |
.podfile_path ⇒ Object
99 100 101 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 99 def self.podfile_path "#{root_path}/Podfile" end |
.post_run ⇒ Object
121 122 123 124 125 126 127 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 121 def self.post_run Pod::UI.puts '添加component.json文件引用' if File.exist?(component_user_file_path) add_refrence(component_user_file_path) end add_refrence(component_file_path) end |
.pre_run ⇒ Object
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 192 def self.pre_run @@components = generateComponents if checkValidComponents == false Pod::UI.puts '参数异常,退出'.red exit(1) end @@components.each do |each| if each.path.nil? if each.local == true local_path = each.name if !each.commit.nil? local_path += '-' local_path += each.commit.to_s elsif !each.branch.nil? local_path += '-' local_path += each.branch.to_s.gsub('/','-') elsif !each.version.nil? local_path += '-' local_path += each.version.to_s.gsub('/','-') end target_path = "#{root_path}/LocalPods/#{local_path}" each.path = target_path if File.exist?(target_path) == false = { git: each.git, commit: each.commit, tag: each.version, branch: each.branch } # 这行代码会自动清空branch并且设置commit # options = Pod::Downloader.preprocess_options(options) downloader = Pod::Downloader.for_target(target_path, ) Pod::UI.puts "本地依赖 #{each.name} 不存在,即将进行下载 。参数:#{}".green downloader.download_deep else Pod::UI.puts "本地依赖 #{each.name} 已存在,不进行变更,如需更新请删除重新 install。位置:#{target_path}".yellow end end end end end |
.root_path ⇒ Object
95 96 97 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 95 def self.root_path Pod::Config.instance.installation_root.to_s end |
.use_components ⇒ Object
91 92 93 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 91 def self.use_components File.exist?(component_file_path) end |
.use_source ⇒ Object
54 55 56 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 54 def self.use_source @@use_source end |
.use_source=(t_use_source) ⇒ Object
50 51 52 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 50 def self.use_source=(t_use_source) @@use_source = t_use_source end |