cocoapods-packageall 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 241f9755e89c822231b7ac8cfe7c0ecdc0a908c638a0c326ed95397fac4cd24c
4
+ data.tar.gz: f12f57701e741022c2279d8508debe6e02f67ee7549de6e635354c8fc6205aed
5
+ SHA512:
6
+ metadata.gz: 6eb1f573af4c9928c0e9c178fc0f4c7b32181988c71896e970241c869e44acdaac82385084729d47c463236eb0f73fed17e22aa8373901492fdd658e5fb7f90f
7
+ data.tar.gz: 52782716738cf3328b1f75a580ac31006f3a7597d680f1b38e48ebcb09ec88aef109f6b03e86640b968ef194491dfa66b96b00045f0b1f210a1a6d431aff7ec1
@@ -0,0 +1,2 @@
1
+ Frameworkrepo = 'frameworkrepo'
2
+ Frameworkspec = 'frameworkspec'
@@ -0,0 +1,32 @@
1
+ require_relative 'packageall'
2
+ require_relative 'package'
3
+ require_relative 'spec_generate'
4
+
5
+ module Hook
6
+
7
+ Pod::HooksManager.register('cocoapods-packageall', :source_provider) do |context|
8
+ p "cocoapods-packageall source_provider"
9
+ # Pod::PreferConfig.instance.prefer_sources().each { |e, source|
10
+ # context.add_source(source)
11
+ # }
12
+ # Package.new('hhhh')
13
+
14
+ # packageall = Pod::Packageall.new(spec_files)
15
+ end
16
+
17
+ Pod::HooksManager.register('cocoapods-packageall', :post_install) do |context|
18
+ p "cocoapods-packageall post_install"
19
+ Array
20
+ specs = context.umbrella_targets[0].specs.select {|spec| spec.parent.nil?}
21
+ specifications = specs.map {|spec| spec.instance_variable_get('@delegate_dc_obj').specification }
22
+ spec_sources = specs.map {|spec| spec.spec_source.url }.uniq
23
+ specifications.each do |specification|
24
+ Package.package(specification,spec_sources)
25
+ SpecGenerate.new(specification).generate
26
+ end
27
+ end
28
+
29
+ Pod::HooksManager.register('cocoapods-packageall', :post_update) do |context|
30
+ p "cocoapods-packageall post_update"
31
+ end
32
+ end
@@ -0,0 +1,39 @@
1
+ require_relative 'const'
2
+
3
+ class Package
4
+ def initialize(argv)
5
+ p argv
6
+ end
7
+ def self.package(specification,spec_source)
8
+ @@fwk_dir ||= create_fwk_dir(false)
9
+ Dir.chdir(@@fwk_dir)
10
+ command = "pod packagethk #{specification.defined_in_file} --exclude-deps --no-mangle --configuration=Debug --spec-sources=#{spec_source.join(',')}"
11
+ puts "start package ..."
12
+ puts command
13
+ output = Time.now.to_s
14
+ output << "\n"
15
+ output += `#{command}`
16
+ File.open("#{specification.name}_log.txt", 'w') { |file|
17
+ file.write(output)
18
+ }
19
+ end
20
+
21
+ def self.create_fwk_dir(force)
22
+ fwk_dir = (Dir.getwd + '/' + Frameworkrepo)
23
+ puts "current work dir : #{fwk_dir}"
24
+
25
+ if Dir.exist? (fwk_dir)
26
+ if force == true
27
+ `rm -rf #{fwk_dir}`
28
+ Dir.mkdir(fwk_dir,0777)
29
+ end
30
+ else
31
+ Dir.mkdir(fwk_dir,0777)
32
+ end
33
+
34
+ Dir.chdir(fwk_dir)
35
+ fwk_dir
36
+ end
37
+ end
38
+
39
+
@@ -0,0 +1,48 @@
1
+ require_relative 'hook'
2
+
3
+ module Pod
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
+ class Packageall < Command
23
+ self.summary = 'Short description of cocoapods-packageall.'
24
+
25
+ self.description = <<-DESC
26
+ Longer description of cocoapods-packageall.
27
+ DESC
28
+
29
+ self.arguments = 'NAME'
30
+
31
+ def initialize(argv)
32
+ @name = argv.shift_argument
33
+ super
34
+ end
35
+
36
+ def validate!
37
+ # super
38
+ # help! 'A Pod name is required.' unless @name
39
+ end
40
+
41
+ def run
42
+ UI.puts "Add your implementation for the cocoapods-packageall plugin in #{__FILE__}"
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+
@@ -0,0 +1,185 @@
1
+ module Pod
2
+ class SpecficationBuilder
3
+ def initialize(spec, source, embedded, dynamic, generate_spec)
4
+ @spec = spec
5
+ @source = source.nil? ? '{ :path => \'.\' }' : source
6
+ @embedded = embedded
7
+ @dynamic = dynamic
8
+ @is_generate_spec = generate_spec
9
+ @generate_spec = ""
10
+ end
11
+
12
+ def set_has_resource(has)
13
+ if has
14
+ @has_resource = true
15
+ end
16
+ end
17
+
18
+ def framework_path
19
+ if @embedded
20
+ @spec.name + '.embeddedframework' + '/' + @spec.name + '.framework'
21
+ else
22
+ @spec.name + '.framework'
23
+ end
24
+ end
25
+
26
+ def spec_platform(platform)
27
+ fwk_base = platform.name.to_s + '/' + framework_path
28
+ spec = <<RB
29
+ s.#{platform.name}.deployment_target = '#{platform.deployment_target}'
30
+ s.#{platform.name}.vendored_framework = '#{fwk_base}'
31
+ RB
32
+
33
+ %w(frameworks weak_frameworks libraries requires_arc xcconfig).each do |attribute|
34
+ attributes_hash = @spec.attributes_hash[platform.name.to_s]
35
+ next if attributes_hash.nil?
36
+ value = attributes_hash[attribute]
37
+ next if value.nil?
38
+
39
+ value = "'#{value}'" if value.class == String
40
+ spec += " s.#{platform.name}.#{attribute} = #{value}\n"
41
+ end
42
+ spec
43
+
44
+
45
+ end
46
+
47
+ def spec_sources_pattern(generate_spec)
48
+ # 添加Source Pattern
49
+ spec = <<RB
50
+ if ENV['IS_SOURCE'] || ENV["\#{s.name}_SOURCE"]
51
+ RB
52
+
53
+ set_has_resource(@spec.attributes_hash['resource_bundles'])
54
+ if @spec.attributes_hash['source']['tag']
55
+ spec += <<RB
56
+ s.source = { :git => '#{@spec.attributes_hash['source']['git']}', :tag => "#{@spec.attributes_hash['source']['tag']}" }
57
+ RB
58
+ elsif @spec.attributes_hash['source']['commit']
59
+ spec += <<RB
60
+ s.source = { :git => '#{@spec.attributes_hash['source']['git']}', :commit => "#{@spec.attributes_hash['source']['commit']}" }
61
+ RB
62
+ else
63
+ spec += <<RB
64
+ s.source = { :git => '#{@spec.attributes_hash['source']}'}
65
+ RB
66
+ end
67
+
68
+
69
+ %w(source_files public_header_files resources frameworks resource_bundles dependencies).each do |attribute|
70
+ value = @spec.attributes_hash[attribute]
71
+ next if value.nil?
72
+ if attribute == 'dependencies'
73
+ value.each { |key,hashvalue|
74
+ if hashvalue.empty?
75
+ spec += " s.dependency \'#{key}\'\n"
76
+ else
77
+ spec += " s.dependency \'#{key}\', \'#{hashvalue[0]}\'\n"
78
+ end
79
+ }
80
+ else
81
+ value = value.dump if value.class == String
82
+ spec += " s.#{attribute} = #{value}\n"
83
+ end
84
+ end
85
+ #添加subspec (递归添加)
86
+ @generate_spec = spec
87
+ @spec.subspecs.each do |subspec|
88
+ spec_sources_pattern_subpsec(subspec)
89
+ end
90
+ spec = @generate_spec
91
+
92
+ # 添加Framwork Pattern
93
+ spec += <<RB
94
+ else
95
+ s.source = { :git => 'git@repo.we.com:iosfeaturelibraries/frameworkrepo.git', :commit => '6fd6924'}
96
+ s.ios.deployment_target = '9.0'
97
+ s.ios.vendored_framework = '#{@spec.name}-#{@spec.version.to_s}/ios/#{@spec.name}.framework'
98
+ RB
99
+ if @has_resource
100
+ spec += <<RB
101
+ s.resources = ["#{@spec.name}-#{@spec.version.to_s}/ios/#{@spec.name}.framework/Resources/*.bundle"]
102
+ RB
103
+ end
104
+
105
+ spec += <<RB
106
+ end
107
+ RB
108
+
109
+
110
+ spec
111
+ end
112
+
113
+ def spec_sources_pattern_subpsec(subspec)
114
+ name = subspec.attributes_hash['name']
115
+ level = subspec.name.split('/').count
116
+ curSpec = "s" * (level - 1)
117
+ space = " " * (level - 2)
118
+ nextSpec = curSpec + "s"
119
+ @generate_spec += space
120
+ @generate_spec += " #{curSpec}.subspec \'#{name}\' do |#{nextSpec}|\n"
121
+
122
+ set_has_resource(subspec.attributes_hash['resource_bundles'])
123
+
124
+ %w(source_files public_header_files resources frameworks resource_bundles dependencies).each do |attribute|
125
+ value = subspec.attributes_hash[attribute]
126
+ next if value.nil?
127
+ @generate_spec += space
128
+ if attribute == 'dependencies'
129
+ value.each { |key,hashvalue|
130
+ if hashvalue.empty?
131
+ @generate_spec += " #{nextSpec}.dependency \'#{key}\'\n"
132
+ else
133
+ @generate_spec += " #{nextSpec}.dependency \'#{key}\', \'#{hashvalue[0]}\'\n"
134
+ end
135
+ }
136
+ else
137
+ value = value.dump if value.class == String
138
+ @generate_spec += " #{nextSpec}.#{attribute} = #{value}\n"
139
+ end
140
+ end
141
+
142
+ if subspec.subspecs.empty?
143
+ @generate_spec += space
144
+ @generate_spec += " end\n"
145
+ else
146
+ #添加subspec
147
+ subspec.subspecs.each do |subsubspec|
148
+ spec_sources_pattern_subpsec(subsubspec)
149
+ end
150
+ @generate_spec += " end\n"
151
+ end
152
+ end
153
+
154
+ def spec_metadata
155
+ spec = spec_header
156
+ spec
157
+ end
158
+
159
+ def spec_close
160
+ "end\n"
161
+ end
162
+
163
+ private
164
+
165
+ def spec_header
166
+ spec = "Pod::Spec.new do |s|\n"
167
+
168
+ %w(name version summary license authors homepage description social_media_url
169
+ docset_url documentation_url screenshots frameworks weak_frameworks libraries requires_arc
170
+ deployment_target xcconfig).each do |attribute|
171
+ value = @spec.attributes_hash[attribute]
172
+ next if value.nil?
173
+ value = value.dump if value.class == String
174
+ spec += " s.#{attribute} = #{value}\n"
175
+ end
176
+ if @is_generate_spec
177
+ source = spec_sources_pattern(true)
178
+ spec += "#{source}"
179
+ else
180
+ spec += " s.source = #{@source}\n\n"
181
+ end
182
+ spec
183
+ end
184
+ end
185
+ end
@@ -0,0 +1,67 @@
1
+ require_relative 'spec_builder'
2
+ require_relative 'const'
3
+
4
+ class SpecGenerate
5
+ def initialize(specfication)
6
+ file_path = fwk_spec_file(specfication)
7
+ file_path.mkpath unless file_path.exist?
8
+ @specfication = specfication
9
+ @file_path = file_path
10
+ @black_list = black_list
11
+ end
12
+
13
+ def black_list
14
+ path = Pathname.new(Dir.getwd) + 'blacklist.txt'
15
+ if path.exist?
16
+ return path.readlines.map { |line| line.chomp }
17
+ end
18
+ []
19
+ end
20
+
21
+ def fwk_spec_file(specfication)
22
+ cache_root + specfication.name + specfication.version.to_s
23
+ end
24
+
25
+ def cache_root
26
+ @cache_root = Pathname.new(Dir.getwd) + Frameworkspec
27
+ @cache_root.mkpath unless @cache_root.exist?
28
+ @cache_root
29
+ end
30
+
31
+ def write_spec(spec, path)
32
+ path.dirname.mkpath
33
+ if @black_list.include? spec.name
34
+ write_black_spec(spec,path)
35
+ else
36
+ write_white_spec(spec,path)
37
+ end
38
+ end
39
+
40
+ def write_black_spec(spec, path)
41
+ file = path + "#{spec.name}.podspec.json"
42
+ file.open('w') { |f| f.write spec.to_pretty_json }
43
+ end
44
+
45
+ def write_white_spec(spec, path)
46
+ file = path + "#{spec.name}.podspec"
47
+ generate_spec = true
48
+ builder = Pod::SpecficationBuilder.new(spec,false,false,false,generate_spec)
49
+ podspec = builder.spec_metadata
50
+
51
+ spec.available_platforms.each do |platform|
52
+ # build_in_sandbox(platform)
53
+
54
+ if generate_spec == false
55
+ podspec += builder.spec_platform(platform)
56
+ end
57
+ end
58
+
59
+ podspec += builder.spec_close
60
+
61
+ file.open('w') { |f| f.write podspec }
62
+ end
63
+
64
+ def generate
65
+ write_spec(@specfication,@file_path)
66
+ end
67
+ end
@@ -0,0 +1,2 @@
1
+ require 'cocoapods-packageall/command/packageall'
2
+
@@ -0,0 +1,3 @@
1
+ module CocoapodsPackageall
2
+ VERSION = "0.0.3"
3
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-packageall/gem_version'
@@ -0,0 +1 @@
1
+ require 'cocoapods-packageall/command'
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-packageall
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Joe.cheng
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-03-20 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: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
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-packageall.
42
+ email:
43
+ - joe.cheng@corp.to8to.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - lib/cocoapods-packageall.rb
49
+ - lib/cocoapods-packageall/command.rb
50
+ - lib/cocoapods-packageall/command/const.rb
51
+ - lib/cocoapods-packageall/command/hook.rb
52
+ - lib/cocoapods-packageall/command/package.rb
53
+ - lib/cocoapods-packageall/command/packageall.rb
54
+ - lib/cocoapods-packageall/command/spec_builder.rb
55
+ - lib/cocoapods-packageall/command/spec_generate.rb
56
+ - lib/cocoapods-packageall/gem_version.rb
57
+ - lib/cocoapods_plugin.rb
58
+ homepage: https://github.com/EXAMPLE/cocoapods-packageall
59
+ licenses:
60
+ - MIT
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubygems_version: 3.4.7
78
+ signing_key:
79
+ specification_version: 4
80
+ summary: A longer description of cocoapods-packageall.
81
+ test_files: []