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.21'
- @@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
128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 128 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
196 197 198 199 200 201 202 203 204 205 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 196 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
102 103 104 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 102 def self.component_file_path "#{root_path}/devops/component.json" end |
.component_user_file_path ⇒ Object
106 107 108 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 106 def self.component_user_file_path "#{root_path}/devops/component_user.json" end |
.components ⇒ Object
65 66 67 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 65 def self.components @@components end |
.generateComponents ⇒ Object
142 143 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 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 142 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) dependency_user = obj_user['dependencies'] end if @@import_dependency.length.positive? import_json = JSON.parse(self.import_dependency) dependency_import = import_json['dependencies'] 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 dependency_user && dependency_user[component.name] component.local = dependency_user[component.name]['local'] if dependency_user[component.name]['local'] component.submodule = dependency_user[component.name]['submodule'] if dependency_user[component.name]['submodule'] component.version = dependency_user[component.name]['version'] component.git = dependency_user[component.name]['git'] if dependency_user[component.name]['git'] component.branch = dependency_user[component.name]['branch'] component.path = dependency_user[component.name]['path'] component.commit = dependency_user[component.name]['commit'] Pod::UI.puts "使用用户配置覆盖。参数:#{component.to_hash}".green end if dependency_import && dependency_import[component.name] component.local = dependency_import[component.name]['local'] if dependency_import[component.name]['local'] component.submodule = dependency_import[component.name]['submodule'] if dependency_import[component.name]['submodule'] component.version = dependency_import[component.name]['version'] component.git = dependency_import[component.name]['git'] if dependency_import[component.name]['git'] component.branch = dependency_import[component.name]['branch'] component.path = dependency_import[component.name]['path'] component.commit = dependency_import[component.name]['commit'] Pod::UI.puts "使用导入配置覆盖。参数:#{component.to_hash}".green end 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
61 62 63 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 61 def self.import_dependency @@import_dependency end |
.import_dependency=(t_import_dependency) ⇒ Object
57 58 59 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 57 def self.import_dependency=(t_import_dependency) @@import_dependency = t_import_dependency end |
.podfile_path ⇒ Object
98 99 100 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 98 def self.podfile_path "#{root_path}/Podfile" end |
.post_run ⇒ Object
120 121 122 123 124 125 126 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 120 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
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 207 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
94 95 96 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 94 def self.root_path Pod::Config.instance.installation_root.to_s end |
.use_components ⇒ Object
90 91 92 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 90 def self.use_components File.exist?(component_file_path) end |
.use_source ⇒ Object
53 54 55 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 53 def self.use_source @@use_source end |
.use_source=(t_use_source) ⇒ Object
49 50 51 |
# File 'lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb', line 49 def self.use_source=(t_use_source) @@use_source = t_use_source end |