cocoapods-soul-component-plugin 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 24aa6d2448dc5362d2ec71c94daf983af1a1dc0366227fba5cc4d6fa1a4fc951
4
+ data.tar.gz: 5e5aa65f21596eed99334dd70bf9283ef19931b8567f10e9ad897247ee41071b
5
+ SHA512:
6
+ metadata.gz: d87e5846bd4b006abbc670a010bc6c9e8786340a6cf8ddaf0440abbf99abe54d08ee83a38699b1f02f0a3b81d6b6666c5ce8cbda76ac684cd42cdf9083b37a41
7
+ data.tar.gz: d416ed16ed61fa6cebe7c3274d96b57fc0170f9cd6ab6ae81ffd925c931647b9fe61d59ba760fd0fdb9d30684bd0cc37bb595e400b00772278aeb2c24672e1bf
@@ -0,0 +1,163 @@
1
+ require 'cocoapods'
2
+ require 'fileutils'
3
+ require 'json'
4
+ require 'xcodeproj'
5
+ require 'cocoapods-downloader'
6
+
7
+ module Pod
8
+ class Command
9
+ class Devops < Command
10
+ self.summary = <<-SUMMARY
11
+ Install components through devops/components.json
12
+ SUMMARY
13
+ self.description = <<-DESC
14
+ Install components through devops/components.json
15
+ DESC
16
+ self.arguments = []
17
+
18
+ def run
19
+ # do nothing
20
+ Pod::UI.puts '插件生效'
21
+ end
22
+ end
23
+ end
24
+ end
25
+
26
+ module CocoapodsSoulComponentPlugin
27
+ $components = []
28
+
29
+ class Soul_Component
30
+ attr_accessor :name, :local, :submodule, :version, :git, :branch, :path, :commit
31
+
32
+ def initialize(name, local, submodule, version, git, branch, path)
33
+ @name = name
34
+ @local = local
35
+ @submodule = submodule
36
+ @version = version
37
+ @git = git
38
+ @branch = branch
39
+ @path = path
40
+ @commit = commit
41
+ end
42
+ end
43
+
44
+ def self.use_components
45
+ File.exist?(component_file_path)
46
+ end
47
+
48
+ def self.root_path
49
+ Pod::Config.instance.installation_root.to_s
50
+ end
51
+
52
+ def self.podfile_path
53
+ root_path + '/Podfile'
54
+ end
55
+
56
+ def self.component_file_path
57
+ root_path + '/devops/component.json'
58
+ end
59
+
60
+ Pod::HooksManager.register('cocoapods-soul-component-plugin', :pre_install) do |_context|
61
+ Pod::UI.puts '插件 pre_install'
62
+ end
63
+ Pod::HooksManager.register('cocoapods-soul-component-plugin', :post_install) do |_context|
64
+ Pod::UI.puts '插件 post_install'
65
+ end
66
+ Pod::HooksManager.register('cocoapods-soul-component-plugin', :source_provider) do |_context, _|
67
+ Pod::UI.puts '插件 source_provider'
68
+ end
69
+
70
+ def self.post_run
71
+ return if use_components == false
72
+
73
+ Pod::UI.puts '添加component.json文件引用'
74
+ project = Xcodeproj::Project.open(Pod::Config.instance.sandbox.project_path)
75
+ # 获取主group
76
+ group = project.main_group
77
+ group.set_source_tree('SOURCE_ROOT')
78
+ # 向group中添加 文件引用
79
+ file_ref = group.new_reference(Pod::Config.instance.sandbox.root + '../devops/component.json')
80
+ # podfile_local排序
81
+ podfile_local_group = group.children.last
82
+ group.children.pop
83
+ group.children.unshift(podfile_local_group)
84
+ project.save
85
+ end
86
+
87
+ def self.pre_run
88
+ time = Time.now.to_i
89
+
90
+ json = File.read(self.component_file_path)
91
+ obj = JSON.parse(json)
92
+ dependencies = obj['dependencies']
93
+
94
+ dependencies.each do |each|
95
+ $components.push(Soul_Component.new(each[0], each[1]['local'], each[1]['submodule'], each[1]['version'], each[1]['git'], each[1]['branch'], each[1]['path']))
96
+ end
97
+
98
+ $components.each do |each|
99
+ if each.path == nil
100
+ if each.submodule == false
101
+ if each.local == true
102
+ local_path = each.name + each.branch.to_s + each.commit.to_s
103
+ target_path = './local_dependencies/' + local_path
104
+ each.path = target_path
105
+
106
+ if File.exist?(target_path) == false
107
+ options = { git: each.git, commit: each.commit, branch: each.branch }
108
+ options = Pod::Downloader.preprocess_options(options)
109
+ downloader = Pod::Downloader.for_target(target_path, options)
110
+ downloader.download
111
+ downloader.checkout_options #=> { :git => 'example.com', :commit => 'd7f410490dabf7a6bde665ba22da102c3acf1bd9' }
112
+ end
113
+ end
114
+ else
115
+ if each.local == true
116
+ each.path = "SOPods/#{each.name}"
117
+ end
118
+ end
119
+ end
120
+ end
121
+ end
122
+ end
123
+
124
+ # 对install进行hook
125
+ module Pod
126
+ class Command
127
+ class Install < Command
128
+ alias old_run run
129
+ def run
130
+ CocoapodsSoulComponentPlugin.pre_run if CocoapodsSoulComponentPlugin.use_components
131
+ old_run
132
+ CocoapodsSoulComponentPlugin.post_run if CocoapodsSoulComponentPlugin.use_components
133
+ end
134
+ end
135
+ end
136
+
137
+ class Dependency
138
+ alias old_initialize initialize
139
+
140
+ def initialize(name = nil, *requirements)
141
+ if requirements == nil
142
+ old_initialize(name)
143
+ return
144
+ end
145
+
146
+ # if name == "SLog"
147
+ # puts name, requirements
148
+ # end
149
+
150
+ $components.each do |each|
151
+ if each.name == name
152
+ if each.local == true
153
+ requirements = [{ :name => each.name, :path => each.path }]
154
+ else
155
+ requirements = [each.version]
156
+ end
157
+ end
158
+ end
159
+
160
+ old_initialize(name, *requirements)
161
+ end
162
+ end
163
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-soul-component-plugin/command/soul-component-plugin'
@@ -0,0 +1,3 @@
1
+ module CocoapodsSoulComponentPlugin
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-soul-component-plugin/gem_version'
@@ -0,0 +1 @@
1
+ require 'cocoapods-soul-component-plugin/command'
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-soul-component-plugin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - fang
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-09-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: A short description of cocoapods-soul-component-plugin.
42
+ email:
43
+ - fang@soulapp.cn
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - lib/cocoapods-soul-component-plugin.rb
49
+ - lib/cocoapods-soul-component-plugin/command.rb
50
+ - lib/cocoapods-soul-component-plugin/command/soul-component-plugin.rb
51
+ - lib/cocoapods-soul-component-plugin/gem_version.rb
52
+ - lib/cocoapods_plugin.rb
53
+ homepage: https://github.com/EXAMPLE/cocoapods-soul-component-plugin
54
+ licenses:
55
+ - MIT
56
+ metadata: {}
57
+ post_install_message:
58
+ rdoc_options: []
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirements: []
72
+ rubygems_version: 3.0.3
73
+ signing_key:
74
+ specification_version: 4
75
+ summary: A longer description of cocoapods-soul-component-plugin.
76
+ test_files: []