cocoapods-swordfish 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +35 -0
- data/lib/cocoapods_plugin.rb +86 -0
- data/lib/gem_version.rb +11 -0
- data/lib/swordfish/command/archive.rb +187 -0
- data/lib/swordfish/command/auto.rb +192 -0
- data/lib/swordfish/command/config.rb +70 -0
- data/lib/swordfish/command/repo/update.rb +42 -0
- data/lib/swordfish/command/spec/create.rb +78 -0
- data/lib/swordfish/command/spec/push.rb +114 -0
- data/lib/swordfish/command/swordfish.rb +41 -0
- data/lib/swordfish/command.rb +2 -0
- data/lib/swordfish/config/config.rb +137 -0
- data/lib/swordfish/config/config_asker.rb +57 -0
- data/lib/swordfish/config/config_builder.rb +216 -0
- data/lib/swordfish/helpers/build_helper.rb +160 -0
- data/lib/swordfish/helpers/build_utils.rb +94 -0
- data/lib/swordfish/helpers/framework.rb +85 -0
- data/lib/swordfish/helpers/framework_builder.rb +451 -0
- data/lib/swordfish/helpers/library.rb +54 -0
- data/lib/swordfish/helpers/library_builder.rb +90 -0
- data/lib/swordfish/helpers/sources_helper.rb +38 -0
- data/lib/swordfish/helpers/spec_creator.rb +167 -0
- data/lib/swordfish/helpers/spec_files_helper.rb +76 -0
- data/lib/swordfish/helpers/spec_source_creator.rb +266 -0
- data/lib/swordfish/helpers/upload_helper.rb +94 -0
- data/lib/swordfish/hmap/hmap_generator.rb +59 -0
- data/lib/swordfish/hmap/pod_target.rb +92 -0
- data/lib/swordfish/hmap/podfile_dsl.rb +36 -0
- data/lib/swordfish/hmap/post_install_hook_context.rb +41 -0
- data/lib/swordfish/hmap/xcconfig.rb +99 -0
- data/lib/swordfish/hmap.rb +4 -0
- data/lib/swordfish/native/acknowledgements.rb +27 -0
- data/lib/swordfish/native/analyzer.rb +55 -0
- data/lib/swordfish/native/file_accessor.rb +28 -0
- data/lib/swordfish/native/installation_options.rb +25 -0
- data/lib/swordfish/native/installer.rb +135 -0
- data/lib/swordfish/native/linter.rb +25 -0
- data/lib/swordfish/native/path_source.rb +33 -0
- data/lib/swordfish/native/pod_source_installer.rb +19 -0
- data/lib/swordfish/native/pod_target_installer.rb +94 -0
- data/lib/swordfish/native/podfile.rb +105 -0
- data/lib/swordfish/native/podfile_env.rb +36 -0
- data/lib/swordfish/native/podfile_generator.rb +195 -0
- data/lib/swordfish/native/podspec_finder.rb +24 -0
- data/lib/swordfish/native/resolver.rb +223 -0
- data/lib/swordfish/native/source.rb +35 -0
- data/lib/swordfish/native/sources_manager.rb +19 -0
- data/lib/swordfish/native/specification.rb +31 -0
- data/lib/swordfish/native/target_architectures.rb +79 -0
- data/lib/swordfish/native/target_validator.rb +41 -0
- data/lib/swordfish/native/validator.rb +39 -0
- data/lib/swordfish/native.rb +16 -0
- data/lib/swordfish.rb +2 -0
- metadata +167 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 57b12c066f1f8c611833c661a0e4d26337683fcd4180246778ff89fcd8ef4810
|
4
|
+
data.tar.gz: ed0062fba56cb0793344b55c2e444b708ac29d4ac5178977bc2a37d342ab48f1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a54b2de10e9013e6c6054b16ccae2e5a490d649a2470e06ea71e59f8d9b716b907b0f0918c987c7726381fe4fa578261dc606ce34a7bc45aa7a2a3fc0bd2ff6e
|
7
|
+
data.tar.gz: 6aa3061312ccf2794eb3d28e0a7102ca587e9bd1c8338567cc305745eb30ca8e5bb1e5d7b7aa9544b2a538a0936e2d62d9f8f2a230630e2175c41ac12505a92c
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Cocoapods::Swordfish
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/cocoapods/swordfish`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'cocoapods-swordfish'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install cocoapods-swordfish
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/cocoapods-swordfish.
|
@@ -0,0 +1,86 @@
|
|
1
|
+
|
2
|
+
require 'swordfish/command'
|
3
|
+
require 'swordfish/hmap'
|
4
|
+
require 'swordfish/native/target_architectures'
|
5
|
+
|
6
|
+
module Ocean
|
7
|
+
Pod::HooksManager.register('cocoapods-swordfish', :post_install) do |post_context, user_options|
|
8
|
+
if $hmap_enable
|
9
|
+
generate_type = $strict_mode ? HmapGenerator::ANGLE_BRACKET : HmapGenerator::BOTH
|
10
|
+
post_context.aggregate_targets.each do |one|
|
11
|
+
pods_hmap = HmapGenerator.new
|
12
|
+
Pod::UI.message "- hanlding headers of aggregate target :#{one.name}"
|
13
|
+
one.pod_targets.each do |target|
|
14
|
+
target.generate_hmap(pods_hmap, generate_type, true, false)
|
15
|
+
target_hmap = HmapGenerator.new
|
16
|
+
target.generate_hmap(target_hmap, HmapGenerator::BOTH, false, true)
|
17
|
+
target.save_hmap(target_hmap)
|
18
|
+
one.concat_prebuilt_hmap_targets(target.prebuilt_hmap_target_names)
|
19
|
+
end
|
20
|
+
one.save_hmap(pods_hmap)
|
21
|
+
end
|
22
|
+
# arm64
|
23
|
+
Xcodeproj::Project.set_archs_arm64(post_context, $archs_only_arm64)
|
24
|
+
# m1 EXCLUDED_ARCHS
|
25
|
+
Pod::Target.excluded_archs_simulator(post_context, $excluded_archs_simulator)
|
26
|
+
else
|
27
|
+
# arm64
|
28
|
+
Xcodeproj::Project.set_archs_arm64(post_context, $archs_only_arm64)
|
29
|
+
# m1 EXCLUDED_ARCHS
|
30
|
+
Pod::Target.excluded_archs_simulator(post_context, $excluded_archs_simulator)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
Pod::HooksManager.register('cocoapods-swordfish', :pre_install) do |_context, _|
|
35
|
+
require 'swordfish/native'
|
36
|
+
|
37
|
+
# pod bin repo update 更新二进制私有源
|
38
|
+
Pod::Command::Swordfish::Repo::Update.new(CLAide::ARGV.new([])).run
|
39
|
+
|
40
|
+
# 有插件/本地库 且是dev环境下,默认进入源码白名单 过滤 archive命令
|
41
|
+
if _context.podfile.plugins.keys.include?('cocoapods-swordfish') && _context.podfile.configuration_env == 'dev'
|
42
|
+
dependencies = _context.podfile.dependencies
|
43
|
+
dependencies.each do |d|
|
44
|
+
next unless d.respond_to?(:external_source) &&
|
45
|
+
d.external_source.is_a?(Hash) &&
|
46
|
+
!d.external_source[:path].nil? &&
|
47
|
+
$ARGV[1] != 'archive'
|
48
|
+
_context.podfile.set_use_source_pods d.name
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# 同步 BinPodfile 文件
|
53
|
+
project_root = Pod::Config.instance.project_root
|
54
|
+
path = File.join(project_root.to_s, 'BinPodfile')
|
55
|
+
|
56
|
+
next unless File.exist?(path)
|
57
|
+
|
58
|
+
contents = File.open(path, 'r:utf-8', &:read)
|
59
|
+
podfile = Pod::Config.instance.podfile
|
60
|
+
podfile.instance_eval do
|
61
|
+
begin
|
62
|
+
eval(contents, nil, path)
|
63
|
+
rescue Exception => e
|
64
|
+
message = "Invalid `#{path}` file: #{e.message}"
|
65
|
+
raise Pod::DSLError.new(message, path, e, contents)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
Pod::HooksManager.register('cocoapods-swordfish', :source_provider) do |context, _|
|
71
|
+
sources_manager = Pod::Config.instance.sources_manager
|
72
|
+
podfile = Pod::Config.instance.podfile
|
73
|
+
|
74
|
+
if podfile
|
75
|
+
# 添加源码私有源 && 二进制私有源
|
76
|
+
# added_sources = [sources_manager.code_source]
|
77
|
+
added_sources = []
|
78
|
+
if podfile.use_binaries? || podfile.use_binaries_selector
|
79
|
+
added_sources << sources_manager.binary_source
|
80
|
+
added_sources.reverse!
|
81
|
+
end
|
82
|
+
added_sources.each { |source| context.add_source(source) }
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
data/lib/gem_version.rb
ADDED
@@ -0,0 +1,187 @@
|
|
1
|
+
|
2
|
+
require 'cocoapods/generate'
|
3
|
+
require 'cocoapods/command/gen'
|
4
|
+
|
5
|
+
require 'swordfish/command/swordfish'
|
6
|
+
require 'swordfish/config/config_builder'
|
7
|
+
require 'swordfish/helpers/build_helper'
|
8
|
+
|
9
|
+
module Pod
|
10
|
+
class Command
|
11
|
+
class Swordfish < Command
|
12
|
+
class Archive < Swordfish
|
13
|
+
|
14
|
+
@@missing_binary_specs = []
|
15
|
+
|
16
|
+
self.summary = '将组件归档为静态库 .a.'
|
17
|
+
self.description = <<-DESC
|
18
|
+
将组件归档为静态库 framework,仅支持 iOS 平台
|
19
|
+
此静态 framework 不包含依赖组件的 symbol
|
20
|
+
DESC
|
21
|
+
|
22
|
+
def self.options
|
23
|
+
[
|
24
|
+
['--all-make', '对该组件的依赖库,全部制作为二进制组件'],
|
25
|
+
['--sources', '私有源地址,多个用分号区分'],
|
26
|
+
['--framework-output', '输出framework文件'],
|
27
|
+
['--configuration', 'Build the specified configuration (e.g. Debug). Defaults to Release'],
|
28
|
+
['--env', "该组件上传的环境 %w[dev debug_iphoneos release_iphoneos]"]
|
29
|
+
].concat(Pod::Command::Gen.options).concat(super).uniq
|
30
|
+
end
|
31
|
+
|
32
|
+
self.arguments = [
|
33
|
+
CLAide::Argument.new('NAME.podspec', false)
|
34
|
+
]
|
35
|
+
|
36
|
+
def initialize(argv)
|
37
|
+
@env = argv.option('env') || 'dev'
|
38
|
+
Ocean.config.set_configuration_env(@env)
|
39
|
+
UI.warn "====== cocoapods-swordfish #{Ocean::VERSION} 版本 ======== "
|
40
|
+
UI.warn "====== #{@env} 环境 ======== "
|
41
|
+
|
42
|
+
@code_dependencies = argv.flag?('code-dependencies')
|
43
|
+
@framework_output = argv.flag?('framework-output', false )
|
44
|
+
@all_make = argv.flag?('all-make', false )
|
45
|
+
@sources = argv.option('sources') || []
|
46
|
+
@platform = Platform.new(:ios)
|
47
|
+
@config = argv.option('configuration', 'Release')
|
48
|
+
|
49
|
+
super
|
50
|
+
|
51
|
+
@additional_args = argv.remainder!
|
52
|
+
@build_finshed = false
|
53
|
+
end
|
54
|
+
|
55
|
+
def run
|
56
|
+
#清除之前的缓存
|
57
|
+
zip_dir = Ocean::Config::Builder.instance.zip_dir
|
58
|
+
FileUtils.rm_rf(zip_dir) if File.exist?(zip_dir)
|
59
|
+
|
60
|
+
@spec = Specification.from_file(spec_file)
|
61
|
+
generate_project
|
62
|
+
|
63
|
+
source_specs = []
|
64
|
+
source_specs.concat(build_root_spec)
|
65
|
+
source_specs.concat(build_dependencies) if @all_make
|
66
|
+
|
67
|
+
source_specs
|
68
|
+
end
|
69
|
+
|
70
|
+
def build_root_spec
|
71
|
+
source_specs = []
|
72
|
+
builder = Ocean::Build::Helper.new(@spec,
|
73
|
+
@platform,
|
74
|
+
@framework_output,
|
75
|
+
@zip,
|
76
|
+
@spec,
|
77
|
+
Ocean::Config::Builder.instance.white_pod_list.include?(@spec.name),
|
78
|
+
@config)
|
79
|
+
builder.build
|
80
|
+
builder.clean_workspace if @clean && !@all_make
|
81
|
+
source_specs << @spec unless Ocean::Config::Builder.instance.white_pod_list.include?(@spec.name)
|
82
|
+
|
83
|
+
source_specs
|
84
|
+
end
|
85
|
+
|
86
|
+
def build_dependencies
|
87
|
+
@build_finshed = true
|
88
|
+
#如果没要求,就清空依赖库数据
|
89
|
+
source_specs = []
|
90
|
+
@@missing_binary_specs.uniq.each do |spec|
|
91
|
+
next if spec.name.include?('/')
|
92
|
+
next if spec.name == @spec.name
|
93
|
+
#过滤白名单
|
94
|
+
next if Ocean::Config::Builder.instance.white_pod_list.include?(spec.name)
|
95
|
+
# #过滤 git (没有,dependency不支持git和path)
|
96
|
+
# if spec.source[:git] && spec.source[:git]
|
97
|
+
# spec_git = spec.source[:git]
|
98
|
+
# spec_git_res = false
|
99
|
+
# Ocean::Config::Builder.instance.ignore_git_list.each do |ignore_git|
|
100
|
+
# spec_git_res = spec_git.include?(ignore_git)
|
101
|
+
# break if spec_git_res
|
102
|
+
# end
|
103
|
+
# next if spec_git_res
|
104
|
+
# end
|
105
|
+
UI.warn "#{spec.name}.podspec 带有 vendored_frameworks 字段,请检查是否有效!!!" if spec.attributes_hash['vendored_frameworks']
|
106
|
+
next if spec.attributes_hash['vendored_frameworks'] && @spec.name != spec.name #过滤带有vendored_frameworks的
|
107
|
+
next if spec.attributes_hash['ios.vendored_frameworks'] && @spec.name != spec.name #过滤带有vendored_frameworks的
|
108
|
+
#获取没有制作二进制版本的spec集合
|
109
|
+
source_specs << spec
|
110
|
+
end
|
111
|
+
|
112
|
+
fail_build_specs = []
|
113
|
+
source_specs.uniq.each do |spec|
|
114
|
+
begin
|
115
|
+
builder = Ocean::Build::Helper.new(spec,
|
116
|
+
@platform,
|
117
|
+
@framework_output,
|
118
|
+
@zip,
|
119
|
+
@spec,
|
120
|
+
false ,
|
121
|
+
@config)
|
122
|
+
builder.build
|
123
|
+
rescue Object => exception
|
124
|
+
UI.puts exception
|
125
|
+
fail_build_specs << spec
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
if fail_build_specs.any?
|
130
|
+
fail_build_specs.uniq.each do |spec|
|
131
|
+
UI.warn "【#{spec.name} | #{spec.version}】组件二进制版本编译失败 ."
|
132
|
+
end
|
133
|
+
end
|
134
|
+
source_specs - fail_build_specs
|
135
|
+
end
|
136
|
+
|
137
|
+
# 解析器传过来的
|
138
|
+
def self.missing_binary_specs(missing_binary_specs)
|
139
|
+
@@missing_binary_specs = missing_binary_specs unless @build_finshed
|
140
|
+
end
|
141
|
+
|
142
|
+
private
|
143
|
+
|
144
|
+
def generate_project
|
145
|
+
Podfile.execute_with_bin_plugin do
|
146
|
+
Podfile.execute_with_use_binaries(!@code_dependencies) do
|
147
|
+
argvs = [
|
148
|
+
"--sources=#{@sources}",
|
149
|
+
"--gen-directory=#{Ocean::Config::Builder.instance.gen_dir}",
|
150
|
+
'--clean',
|
151
|
+
*@additional_args
|
152
|
+
]
|
153
|
+
|
154
|
+
podfile= File.join(Pathname.pwd, "Podfile")
|
155
|
+
if File.exist?(podfile)
|
156
|
+
argvs += ['--use-podfile']
|
157
|
+
end
|
158
|
+
|
159
|
+
argvs << spec_file if spec_file
|
160
|
+
|
161
|
+
gen = Pod::Command::Gen.new(CLAide::ARGV.new(argvs))
|
162
|
+
gen.validate!
|
163
|
+
gen.run
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
|
169
|
+
def spec_file
|
170
|
+
@spec_file ||= begin
|
171
|
+
if @podspec
|
172
|
+
find_spec_file(@podspec)
|
173
|
+
else
|
174
|
+
if code_spec_files.empty?
|
175
|
+
raise Informative, '当前目录下没有找到可用源码 podspec.'
|
176
|
+
end
|
177
|
+
|
178
|
+
spec_file = code_spec_files.first
|
179
|
+
spec_file
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
@@ -0,0 +1,192 @@
|
|
1
|
+
|
2
|
+
require 'swordfish/command/swordfish'
|
3
|
+
require 'swordfish/helpers/upload_helper'
|
4
|
+
|
5
|
+
module Pod
|
6
|
+
class Command
|
7
|
+
class Swordfish < Command
|
8
|
+
class Auto < Swordfish
|
9
|
+
self.summary = '打开 workspace 工程.'
|
10
|
+
|
11
|
+
self.arguments = [
|
12
|
+
CLAide::Argument.new('NAME.podspec', false)
|
13
|
+
]
|
14
|
+
def self.options
|
15
|
+
[
|
16
|
+
['--framework-output', "输出framework文件"],
|
17
|
+
['--all-make', "对该组件的依赖库,全部制作为二进制组件"],
|
18
|
+
['--configuration', "Build the specified configuration (e.g. Release ). Defaults to Debug"],
|
19
|
+
['--env', "该组件上传的环境 %w[dev debug_iphoneos release_iphoneos]"]
|
20
|
+
].concat(Pod::Command::Gen.options).concat(super).uniq
|
21
|
+
end
|
22
|
+
|
23
|
+
def initialize(argv)
|
24
|
+
@env = argv.option('env') || 'dev'
|
25
|
+
Ocean.config.set_configuration_env(@env)
|
26
|
+
|
27
|
+
@podspec = argv.shift_argument || find_podspec
|
28
|
+
|
29
|
+
@specification = Specification.from_file(@podspec)
|
30
|
+
|
31
|
+
@framework_output = argv.flag?('framework-output', false )
|
32
|
+
|
33
|
+
@all_make = argv.flag?('all-make', false )
|
34
|
+
|
35
|
+
@verbose = argv.flag?('verbose',true)
|
36
|
+
|
37
|
+
@config = argv.option('configuration', 'Debug')
|
38
|
+
|
39
|
+
@additional_args = argv.remainder!
|
40
|
+
|
41
|
+
super
|
42
|
+
end
|
43
|
+
|
44
|
+
def validate!
|
45
|
+
super
|
46
|
+
help! "未找到 podspec文件" unless @podspec
|
47
|
+
end
|
48
|
+
|
49
|
+
def run
|
50
|
+
@specification = Specification.from_file(@podspec)
|
51
|
+
|
52
|
+
source_specs = run_archive
|
53
|
+
|
54
|
+
fail_push_specs = []
|
55
|
+
source_specs.uniq.each do |spec|
|
56
|
+
begin
|
57
|
+
fail_push_specs << spec unless Ocean::Upload::Helper.new(spec,@code_dependencies,@sources).upload(@framework_output)
|
58
|
+
rescue Object => exception
|
59
|
+
UI.puts exception
|
60
|
+
fail_push_specs << spec
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
if fail_push_specs.any?
|
65
|
+
fail_push_specs.uniq.each do |spec|
|
66
|
+
UI.warn "【#{spec.name} | #{spec.version}】组件spec push失败 ."
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
success_specs = source_specs - fail_push_specs
|
71
|
+
if success_specs.any?
|
72
|
+
auto_success = ""
|
73
|
+
success_specs.uniq.each do |spec|
|
74
|
+
auto_success += "#{spec.name} | #{spec.version}\n"
|
75
|
+
UI.warn "===【 #{spec.name} | #{spec.version} 】二进制组件制作完成 !!! "
|
76
|
+
end
|
77
|
+
puts "============== auto_success"
|
78
|
+
puts auto_success
|
79
|
+
ENV['auto_success'] = auto_success
|
80
|
+
end
|
81
|
+
#pod repo update
|
82
|
+
UI.section("\nUpdating Spec Repositories\n".yellow) do
|
83
|
+
Pod::Command::Swordfish::Repo::Update.new(CLAide::ARGV.new([])).run
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
#制作二进制包
|
89
|
+
def run_archive
|
90
|
+
_sources = Ocean::Config::Builder.instance.pod_source_list
|
91
|
+
|
92
|
+
argvs = [
|
93
|
+
"--sources=#{sources_option(@code_dependencies, _sources)}",
|
94
|
+
@additional_args
|
95
|
+
]
|
96
|
+
|
97
|
+
argvs << spec_file if spec_file
|
98
|
+
argvs.delete(Array.new)
|
99
|
+
|
100
|
+
if @code_dependencies
|
101
|
+
argvs += ['--code-dependencies']
|
102
|
+
end
|
103
|
+
|
104
|
+
if @verbose
|
105
|
+
argvs += ['--verbose']
|
106
|
+
end
|
107
|
+
|
108
|
+
if @framework_output
|
109
|
+
argvs += ['--framework-output']
|
110
|
+
end
|
111
|
+
|
112
|
+
if @all_make
|
113
|
+
argvs += ['--all-make']
|
114
|
+
end
|
115
|
+
|
116
|
+
if @env
|
117
|
+
argvs += ["--env=#{@env}"]
|
118
|
+
end
|
119
|
+
argvs += ["--configuration=#{@config}"]
|
120
|
+
|
121
|
+
archive = Pod::Command::Swordfish::Archive.new(CLAide::ARGV.new(argvs))
|
122
|
+
archive.validate!
|
123
|
+
source_specs = archive.run
|
124
|
+
source_specs
|
125
|
+
end
|
126
|
+
|
127
|
+
|
128
|
+
def code_podsepc_extname
|
129
|
+
'.podsepc'
|
130
|
+
end
|
131
|
+
|
132
|
+
def binary_podsepc_json
|
133
|
+
"#{@specification.name}.binary.podspec.json"
|
134
|
+
end
|
135
|
+
|
136
|
+
def binary_template_podsepc
|
137
|
+
"#{@specification.name}.binary-template.podspec"
|
138
|
+
end
|
139
|
+
|
140
|
+
def template_spec_file
|
141
|
+
@template_spec_file ||= begin
|
142
|
+
if @template_podspec
|
143
|
+
find_spec_file(@template_podspec)
|
144
|
+
else
|
145
|
+
binary_template_spec_file
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
def spec_file
|
151
|
+
@spec_file ||= begin
|
152
|
+
if @podspec
|
153
|
+
find_spec_file(@podspec) || @podspec
|
154
|
+
else
|
155
|
+
if code_spec_files.empty?
|
156
|
+
raise Informative, '当前目录下没有找到可用源码 podspec.'
|
157
|
+
end
|
158
|
+
|
159
|
+
spec_file = if @binary
|
160
|
+
code_spec = Pod::Specification.from_file(code_spec_files.first)
|
161
|
+
if template_spec_file
|
162
|
+
template_spec = Pod::Specification.from_file(template_spec_file)
|
163
|
+
end
|
164
|
+
create_binary_spec_file(code_spec, template_spec)
|
165
|
+
else
|
166
|
+
code_spec_files.first
|
167
|
+
end
|
168
|
+
spec_file
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
#Dir.glob 可替代
|
174
|
+
def find_podspec
|
175
|
+
name = nil
|
176
|
+
Pathname.pwd.children.each do |child|
|
177
|
+
puts child
|
178
|
+
if File.file?(child)
|
179
|
+
if child.extname == '.podspec'
|
180
|
+
name = File.basename(child)
|
181
|
+
unless name.include?("binary-template")
|
182
|
+
return name
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
return name
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
|
2
|
+
require 'swordfish/command/swordfish'
|
3
|
+
require 'swordfish/config/config_asker'
|
4
|
+
|
5
|
+
module Pod
|
6
|
+
class Command
|
7
|
+
class Swordfish < Command
|
8
|
+
class Config < Swordfish
|
9
|
+
self.summary = '插件初始化.'
|
10
|
+
self.description = <<-DESC
|
11
|
+
配置信息
|
12
|
+
DESC
|
13
|
+
|
14
|
+
def self.options
|
15
|
+
[
|
16
|
+
['--config-url=URL', '配置文件地址,直接从此地址下载配置文件']
|
17
|
+
].concat(super)
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize(argv)
|
21
|
+
@config_url = argv.option('config-url')
|
22
|
+
super
|
23
|
+
end
|
24
|
+
|
25
|
+
def run
|
26
|
+
if @config_url.nil?
|
27
|
+
config_with_asker
|
28
|
+
else
|
29
|
+
config_with_url(@config_url)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def config_with_url(url)
|
36
|
+
require 'open-uri'
|
37
|
+
|
38
|
+
UI.puts "开始下载配置文件...\n"
|
39
|
+
file = open(url)
|
40
|
+
contents = YAML.safe_load(file.read)
|
41
|
+
|
42
|
+
UI.puts "开始同步配置文件...\n"
|
43
|
+
Ocean.config.sync_config(contents.to_hash)
|
44
|
+
UI.puts "设置完成.\n".green
|
45
|
+
rescue Errno::ENOENT => e
|
46
|
+
raise Informative, "配置文件路径 #{url} 无效,请确认后重试."
|
47
|
+
end
|
48
|
+
|
49
|
+
def config_with_asker
|
50
|
+
asker = Ocean::Config::Asker.new
|
51
|
+
asker.wellcome_message
|
52
|
+
|
53
|
+
config = {}
|
54
|
+
template_hash = Ocean.config.template_hash
|
55
|
+
template_hash.each do |k, v|
|
56
|
+
default = begin
|
57
|
+
Ocean.config.send(k)
|
58
|
+
rescue StandardError
|
59
|
+
nil
|
60
|
+
end
|
61
|
+
config[k] = asker.ask_with_answer(v[:description], default, v[:selection])
|
62
|
+
end
|
63
|
+
|
64
|
+
Ocean.config.sync_config(config)
|
65
|
+
asker.done_message
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'parallel'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Command
|
5
|
+
class Swordfish < Command
|
6
|
+
class Repo < Swordfish
|
7
|
+
class Update < Repo
|
8
|
+
self.summary = '更新私有源'
|
9
|
+
|
10
|
+
self.arguments = [
|
11
|
+
CLAide::Argument.new('NAME', false)
|
12
|
+
]
|
13
|
+
|
14
|
+
def self.options
|
15
|
+
[
|
16
|
+
['--all', '更新所有私有源,默认只更新二进制相关私有源']
|
17
|
+
].concat(super)
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize(argv)
|
21
|
+
@all = argv.flag?('all')
|
22
|
+
@name = argv.shift_argument
|
23
|
+
super
|
24
|
+
end
|
25
|
+
|
26
|
+
def run
|
27
|
+
show_output = !config.silent?
|
28
|
+
if @name || @all
|
29
|
+
config.sources_manager.update(@name, show_output)
|
30
|
+
else
|
31
|
+
Parallel.each(valid_sources, in_threads: 4) do |source|
|
32
|
+
UI.puts "更新私有源仓库 #{source.to_s}".yellow
|
33
|
+
source.update(show_output)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|