cocoapods-imy-bin 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +22 -0
  3. data/README.md +541 -0
  4. data/lib/cocoapods-imy-bin.rb +2 -0
  5. data/lib/cocoapods-imy-bin/command.rb +2 -0
  6. data/lib/cocoapods-imy-bin/command/bin.rb +60 -0
  7. data/lib/cocoapods-imy-bin/command/bin/archive.rb +184 -0
  8. data/lib/cocoapods-imy-bin/command/bin/auto.rb +188 -0
  9. data/lib/cocoapods-imy-bin/command/bin/code.rb +237 -0
  10. data/lib/cocoapods-imy-bin/command/bin/imy.rb +46 -0
  11. data/lib/cocoapods-imy-bin/command/bin/init.rb +69 -0
  12. data/lib/cocoapods-imy-bin/command/bin/initHotKey.rb +70 -0
  13. data/lib/cocoapods-imy-bin/command/bin/install.rb +44 -0
  14. data/lib/cocoapods-imy-bin/command/bin/lib/lint.rb +69 -0
  15. data/lib/cocoapods-imy-bin/command/bin/local.rb +156 -0
  16. data/lib/cocoapods-imy-bin/command/bin/repo/update.rb +43 -0
  17. data/lib/cocoapods-imy-bin/command/bin/spec/create.rb +73 -0
  18. data/lib/cocoapods-imy-bin/command/bin/spec/push.rb +114 -0
  19. data/lib/cocoapods-imy-bin/command/bin/update.rb +148 -0
  20. data/lib/cocoapods-imy-bin/config/config.rb +137 -0
  21. data/lib/cocoapods-imy-bin/config/config_asker.rb +57 -0
  22. data/lib/cocoapods-imy-bin/config/config_builder.rb +179 -0
  23. data/lib/cocoapods-imy-bin/config/config_hot_key.rb +103 -0
  24. data/lib/cocoapods-imy-bin/config/config_hot_key_asker.rb +57 -0
  25. data/lib/cocoapods-imy-bin/gem_version.rb +10 -0
  26. data/lib/cocoapods-imy-bin/helpers.rb +4 -0
  27. data/lib/cocoapods-imy-bin/helpers/build_helper.rb +150 -0
  28. data/lib/cocoapods-imy-bin/helpers/framework.rb +62 -0
  29. data/lib/cocoapods-imy-bin/helpers/framework_builder.rb +307 -0
  30. data/lib/cocoapods-imy-bin/helpers/library.rb +54 -0
  31. data/lib/cocoapods-imy-bin/helpers/library_builder.rb +90 -0
  32. data/lib/cocoapods-imy-bin/helpers/local/loca_llibrary.rb +57 -0
  33. data/lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb +146 -0
  34. data/lib/cocoapods-imy-bin/helpers/local/local_framework.rb +65 -0
  35. data/lib/cocoapods-imy-bin/helpers/local/local_framework_builder.rb +174 -0
  36. data/lib/cocoapods-imy-bin/helpers/local/local_library_builder.rb +92 -0
  37. data/lib/cocoapods-imy-bin/helpers/sources_helper.rb +33 -0
  38. data/lib/cocoapods-imy-bin/helpers/spec_creator.rb +170 -0
  39. data/lib/cocoapods-imy-bin/helpers/spec_files_helper.rb +77 -0
  40. data/lib/cocoapods-imy-bin/helpers/spec_source_creator.rb +171 -0
  41. data/lib/cocoapods-imy-bin/helpers/upload_helper.rb +84 -0
  42. data/lib/cocoapods-imy-bin/native.rb +19 -0
  43. data/lib/cocoapods-imy-bin/native/acknowledgements.rb +27 -0
  44. data/lib/cocoapods-imy-bin/native/analyzer.rb +53 -0
  45. data/lib/cocoapods-imy-bin/native/installation_options.rb +25 -0
  46. data/lib/cocoapods-imy-bin/native/installer.rb +115 -0
  47. data/lib/cocoapods-imy-bin/native/linter.rb +26 -0
  48. data/lib/cocoapods-imy-bin/native/path_source.rb +33 -0
  49. data/lib/cocoapods-imy-bin/native/pod_source_installer.rb +19 -0
  50. data/lib/cocoapods-imy-bin/native/podfile.rb +91 -0
  51. data/lib/cocoapods-imy-bin/native/podfile_env.rb +37 -0
  52. data/lib/cocoapods-imy-bin/native/podfile_generator.rb +190 -0
  53. data/lib/cocoapods-imy-bin/native/podspec_finder.rb +25 -0
  54. data/lib/cocoapods-imy-bin/native/resolver.rb +230 -0
  55. data/lib/cocoapods-imy-bin/native/sandbox_analyzer.rb +34 -0
  56. data/lib/cocoapods-imy-bin/native/source.rb +35 -0
  57. data/lib/cocoapods-imy-bin/native/sources_manager.rb +20 -0
  58. data/lib/cocoapods-imy-bin/native/specification.rb +31 -0
  59. data/lib/cocoapods-imy-bin/native/validator.rb +77 -0
  60. data/lib/cocoapods-imy-bin/source_provider_hook.rb +54 -0
  61. data/lib/cocoapods_plugin.rb +3 -0
  62. data/spec/command/bin_spec.rb +12 -0
  63. data/spec/spec_helper.rb +50 -0
  64. metadata +180 -0
@@ -0,0 +1,57 @@
1
+
2
+
3
+ # copy from https://github.com/CocoaPods/cocoapods-packager
4
+ require 'cocoapods-imy-bin/config/config_builder'
5
+
6
+ module CBin
7
+ class LocalLibrary
8
+ attr_reader :headers_path
9
+ attr_reader :resources_path
10
+ attr_reader :root_path
11
+ attr_reader :versions_path
12
+ attr_reader :name_path
13
+
14
+ def initialize(name, platform, version)
15
+ @name = name
16
+ @platform = platform
17
+ @version = version
18
+ end
19
+
20
+ def make
21
+ make_root
22
+ make_library
23
+ make_headers
24
+ make_resources
25
+ end
26
+
27
+ def delete_resources
28
+ Pathname.new(@resources_path).rmtree
29
+ (Pathname.new(@fwk_path) + Pathname.new('Resources')).delete
30
+ end
31
+
32
+ private
33
+
34
+ def make_library
35
+ @name_path = CBin::Config::Builder.instance.library_name_version(@name, @version)
36
+ @fwk_path = @root_path + Pathname.new(@name_path)
37
+ @fwk_path.mkdir unless @fwk_path.exist?
38
+
39
+ @versions_path = @fwk_path
40
+ end
41
+
42
+ def make_headers
43
+ @headers_path = @versions_path + Pathname.new('Headers')
44
+ # @headers_path.mkpath unless @headers_path.exist?
45
+ end
46
+
47
+ def make_resources
48
+ @resources_path = @versions_path + Pathname.new('Resources')
49
+ # @resources_path.mkpath unless @resources_path.exist?
50
+ end
51
+
52
+ def make_root
53
+ @root_path = Pathname.new(@platform)
54
+ @root_path.mkpath unless @root_path.exist?
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,146 @@
1
+
2
+
3
+ # copy from https://github.com/CocoaPods/cocoapods-packager
4
+
5
+ require 'cocoapods-imy-bin/native/podfile'
6
+ require 'cocoapods/command/gen'
7
+ require 'cocoapods/generate'
8
+ require 'cocoapods-imy-bin/helpers/framework_builder'
9
+ require 'cocoapods-imy-bin/helpers/library_builder'
10
+ require 'cocoapods-imy-bin/config/config_builder'
11
+
12
+ module CBin
13
+ class LocalBuild
14
+ class Helper
15
+ include Pod
16
+ #class var
17
+ @@build_defines = ""
18
+ #Debug下还待完成
19
+ def initialize(spec,
20
+ platform,
21
+ framework_output,
22
+ zip,
23
+ clean,
24
+ target_name,
25
+ local_build_dir_name,
26
+ local_build_dir)
27
+ @spec = spec
28
+ @target_name = target_name
29
+ @platform = platform
30
+
31
+ @framework_output = framework_output
32
+ @zip = zip
33
+ @local_build_dir_name = local_build_dir_name
34
+ @local_build_dir = local_build_dir
35
+ @clean = clean
36
+ @framework_path
37
+ end
38
+
39
+ def build
40
+ UI.section("Building static framework #{@spec}") do
41
+
42
+ build_static_framework
43
+ build_static_library
44
+ zip_static_framework if @zip &&= @framework_output
45
+ zip_static_library
46
+
47
+ clean_workspace if @clean
48
+ end
49
+
50
+ end
51
+
52
+ def build_static_framework
53
+ file_accessor = Sandbox::FileAccessor.new(Pathname.new('.').expand_path, @spec.consumer(@platform))
54
+ Dir.chdir(workspace_directory) do
55
+ builder = CBin::LocalFramework::Builder.new(@spec, file_accessor, @platform, @local_build_dir_name,@local_build_dir)
56
+ @framework_path = builder.create
57
+ end
58
+ end
59
+
60
+ def build_static_library
61
+ source_dir = zip_dir
62
+ file_accessor = Sandbox::FileAccessor.new(Pathname.new('.').expand_path, @spec.consumer(@platform))
63
+ Dir.chdir(workspace_directory) do
64
+ builder = CBin::LocalLibrary::Builder.new(@spec, file_accessor, @platform, source_dir,@framework_path)
65
+ builder.build
66
+ end
67
+ end
68
+
69
+ def zip_static_framework
70
+ Dir.chdir(zip_dir) do
71
+ output_name = "#{framework_name}.zip"
72
+ unless File.exist?(framework_name)
73
+ raise Informative, "没有需要压缩的 framework 文件:#{framework_name}"
74
+ end
75
+
76
+ UI.puts "Compressing #{framework_name} into #{output_name}"
77
+ `zip --symlinks -r #{output_name} #{framework_name}`
78
+
79
+ end
80
+ end
81
+
82
+ def zip_static_library
83
+ Dir.chdir(zip_dir) do
84
+ output_library = "#{library_name}.zip"
85
+ unless File.exist?(library_name)
86
+ raise Informative, "没有需要压缩的 library 文件:#{library_name}"
87
+ end
88
+
89
+ UI.puts "Compressing #{library_name} into #{output_library}"
90
+
91
+ `zip --symlinks -r #{output_library} #{library_name}`
92
+ end
93
+
94
+ end
95
+
96
+
97
+ def clean_workspace
98
+ UI.puts 'Cleaning workspace'
99
+
100
+ FileUtils.rm_rf(gen_name)
101
+ Dir.chdir(zip_dir) do
102
+ FileUtils.rm_rf(framework_name) if @zip
103
+ FileUtils.rm_rf(library_name)
104
+ FileUtils.rm_rf(framework_name) unless @framework_output
105
+ FileUtils.rm_rf("#{framework_name}.zip") unless @framework_output
106
+ end
107
+ end
108
+
109
+ def framework_name
110
+ CBin::Config::Builder.instance.framework_name(@spec)
111
+ end
112
+
113
+ def library_name
114
+ CBin::Config::Builder.instance.library_name(@spec)
115
+ end
116
+
117
+ def workspace_directory
118
+ @local_build_dir
119
+ end
120
+
121
+ def zip_dir
122
+ CBin::Config::Builder.instance.zip_dir
123
+ end
124
+
125
+ def gen_name
126
+ CBin::Config::Builder.instance.gen_name
127
+ end
128
+
129
+ def spec_file
130
+ @spec_file ||= begin
131
+ if @podspec
132
+ find_spec_file(@podspec)
133
+ else
134
+ if code_spec_files.empty?
135
+ raise Informative, '当前目录下没有找到可用源码 podspec.'
136
+ end
137
+
138
+ spec_file = code_spec_files.first
139
+ spec_file
140
+ end
141
+ end
142
+ end
143
+
144
+ end
145
+ end
146
+ end
@@ -0,0 +1,65 @@
1
+
2
+
3
+ # copy from https://github.com/CocoaPods/cocoapods-packager
4
+
5
+ module CBin
6
+ class LocalFramework
7
+ attr_reader :headers_path
8
+ attr_reader :module_map_path
9
+ attr_reader :resources_path
10
+ attr_reader :root_path
11
+ attr_reader :versions_path
12
+
13
+ def initialize(name, platform, local_build_dir)
14
+ @name = name
15
+ @platform = platform
16
+ @local_build_dir = local_build_dir
17
+ end
18
+
19
+ def make
20
+ make_root
21
+ make_framework
22
+ make_headers
23
+ make_resources
24
+ make_current_version
25
+ end
26
+
27
+ def delete_resources
28
+ Pathname.new(@resources_path).rmtree
29
+ (Pathname.new(@fwk_path) + Pathname.new('Resources')).delete
30
+ end
31
+
32
+ private
33
+
34
+ def make_current_version
35
+ current_version_path = @versions_path + Pathname.new('../Current')
36
+ `ln -sf A #{current_version_path}`
37
+ `ln -sf Versions/Current/Headers #{@fwk_path}/`
38
+ `ln -sf Versions/Current/Resources #{@fwk_path}/`
39
+ `ln -sf Versions/Current/#{@name} #{@fwk_path}/`
40
+ end
41
+
42
+ def make_framework
43
+ @fwk_path = @root_path + Pathname.new(@name + '.framework')
44
+ @fwk_path.mkdir unless @fwk_path.exist?
45
+
46
+ @module_map_path = @fwk_path + Pathname.new('Modules')
47
+ @versions_path = @fwk_path + Pathname.new('Versions/A')
48
+ end
49
+
50
+ def make_headers
51
+ @headers_path = @versions_path + Pathname.new('Headers')
52
+ @headers_path.mkpath unless @headers_path.exist?
53
+ end
54
+
55
+ def make_resources
56
+ @resources_path = @versions_path + Pathname.new('Resources')
57
+ @resources_path.mkpath unless @resources_path.exist?
58
+ end
59
+
60
+ def make_root
61
+ @root_path = Pathname.new(File.join(@local_build_dir, @platform))
62
+ @root_path.mkpath unless @root_path.exist?
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,174 @@
1
+
2
+
3
+ # copy from https://github.com/CocoaPods/cocoapods-packager
4
+
5
+ require 'cocoapods-imy-bin/helpers/local/local_framework'
6
+ require 'English'
7
+ require 'cocoapods-imy-bin/config/config_builder'
8
+ require 'shellwords'
9
+
10
+ module CBin
11
+ class LocalFramework
12
+ class Builder
13
+ include Pod
14
+ #Debug下还待完成
15
+ def initialize(spec, file_accessor, platform, local_build_dir_name, local_build_dir)
16
+ @spec = spec
17
+ @file_accessor = file_accessor
18
+ @platform = platform
19
+ @local_build_dir_name = local_build_dir_name
20
+ @local_build_dir = local_build_dir
21
+ end
22
+
23
+ def create
24
+ UI.section("Building static framework #{@spec}") do
25
+ output = framework.versions_path + Pathname.new(@spec.name)
26
+
27
+ build_static_library_for_ios(output)
28
+
29
+ copy_headers
30
+ copy_resources
31
+
32
+ cp_to_source_dir
33
+ end
34
+ framework
35
+ end
36
+
37
+ private
38
+
39
+ def cp_to_source_dir
40
+ target_dir = File.join(CBin::Config::Builder.instance.root_dir,CBin::Config::Builder.instance.framework_file(@spec))
41
+ FileUtils.rm_rf(target_dir) if File.exist?(target_dir)
42
+
43
+ zip_dir = CBin::Config::Builder.instance.zip_dir
44
+ FileUtils.mkdir_p(zip_dir) unless File.exist?(zip_dir)
45
+
46
+ `cp -fa #{@platform}/#{CBin::Config::Builder.instance.framework_name(@spec)} #{target_dir}`
47
+ end
48
+
49
+ def copy_headers
50
+ #by slj 如果没有头文件,去 "Headers/Public"拿
51
+ # if public_headers.empty?
52
+ Dir.chdir(File.join(Pod::Config.instance.installation_root,'Pods')) do
53
+
54
+ #走 podsepc中的public_headers
55
+ public_headers = Array.new
56
+ Dir.chdir("./Headers/Public/#{@spec.name}") do
57
+ headers = Dir.glob('*.h')
58
+ headers.each do |h|
59
+ public_headers << Pathname.new(File.join(Dir.pwd,h))
60
+ end
61
+ end
62
+
63
+ UI.message "Copying public headers #{public_headers.map(&:basename).map(&:to_s)}"
64
+
65
+ public_headers.each do |h|
66
+ `ditto #{h} #{framework.headers_path}/#{h.basename}`
67
+ end
68
+
69
+ # If custom 'module_map' is specified add it to the framework distribution
70
+ # otherwise check if a header exists that is equal to 'spec.name', if so
71
+ # create a default 'module_map' one using it.
72
+ if !@spec.module_map.nil?
73
+ module_map_file = @file_accessor.module_map
74
+ if Pathname(module_map_file).exist?
75
+ module_map = File.read(module_map_file)
76
+ end
77
+ elsif public_headers.map(&:basename).map(&:to_s).include?("#{@spec.name}.h")
78
+ module_map = <<-MAP
79
+ framework module #{@spec.name} {
80
+ umbrella header "#{@spec.name}.h"
81
+
82
+ export *
83
+ module * { export * }
84
+ }
85
+ MAP
86
+ end
87
+
88
+ unless module_map.nil?
89
+ UI.message "Writing module map #{module_map}"
90
+ unless framework.module_map_path.exist?
91
+ framework.module_map_path.mkpath
92
+ end
93
+ File.write("#{framework.module_map_path}/module.modulemap", module_map)
94
+ end
95
+
96
+ end
97
+ end
98
+
99
+ def copy_resources
100
+
101
+ Dir.chdir(Pod::Config.instance.sandbox_root) do
102
+
103
+ bundles = Dir.glob('./build/*.bundle')
104
+
105
+ bundle_names = [@spec, *@spec.recursive_subspecs].flat_map do |spec|
106
+ consumer = spec.consumer(@platform)
107
+ consumer.resource_bundles.keys +
108
+ consumer.resources.map do |r|
109
+ File.basename(r, '.bundle') if File.extname(r) == 'bundle'
110
+ end
111
+ end.compact.uniq
112
+
113
+ bundles.select! do |bundle|
114
+ bundle_name = File.basename(bundle, '.bundle')
115
+ bundle_names.include?(bundle_name)
116
+ end
117
+
118
+ if bundles.count > 0
119
+ UI.message "Copying bundle files #{bundles}"
120
+ bundle_files = bundles.join(' ')
121
+ `cp -rp #{bundle_files} #{framework.resources_path} 2>&1`
122
+ end
123
+
124
+ real_source_dir = @spec.name
125
+ resources = [@spec, *@spec.recursive_subspecs].flat_map do |spec|
126
+ expand_paths(real_source_dir, spec.consumer(@platform).resources)
127
+ end.compact.uniq
128
+
129
+ if resources.count == 0 && bundles.count == 0
130
+ framework.delete_resources
131
+ return
132
+ end
133
+
134
+ if resources.count > 0
135
+ #把 路径转义。 避免空格情况下拷贝失败
136
+ escape_resource = []
137
+ resources.each do |source|
138
+ escape_resource << Shellwords.join(source)
139
+ end
140
+ UI.message "Copying resources #{escape_resource}"
141
+ `cp -rp #{escape_resource.join(' ')} #{framework.resources_path}`
142
+ end
143
+
144
+ end
145
+
146
+ end
147
+
148
+
149
+ def build_static_library_for_ios(output)
150
+ `cp -rp #{library_name} #{output}`
151
+ end
152
+
153
+ def library_name
154
+ File.join(@local_build_dir, "lib#{@spec.name}.a")
155
+ end
156
+
157
+
158
+ def expand_paths(source_dir, path_specs)
159
+ path_specs.map do |path_spec|
160
+ Dir.glob(File.join(source_dir, path_spec))
161
+ end
162
+ end
163
+
164
+ def framework
165
+ @framework ||= begin
166
+ framework = CBin::LocalFramework.new(@spec.name, @platform.name.to_s,@local_build_dir)
167
+ framework.make
168
+ framework
169
+ end
170
+ end
171
+
172
+ end
173
+ end
174
+ end
@@ -0,0 +1,92 @@
1
+
2
+
3
+
4
+ # copy from https://github.com/CocoaPods/cocoapods-packager
5
+
6
+ require 'cocoapods-imy-bin/helpers/framework.rb'
7
+ require 'cocoapods-imy-bin/helpers/library.rb'
8
+
9
+ require 'English'
10
+
11
+ module CBin
12
+ class LocalLibrary
13
+ class Builder
14
+ include Pod
15
+
16
+ def initialize(spec, file_accessor, platform, source_dir,framework_path)
17
+ @spec = spec
18
+ @source_dir = source_dir
19
+ @file_accessor = file_accessor
20
+ @platform = platform
21
+ @framework = framework_path
22
+ @source_files = "#{@source_dir}/#{library.name_path}"
23
+ @source_zip_file = "#{@source_files}.zip"
24
+ end
25
+
26
+ def build
27
+ UI.section("Building static library #{@spec}") do
28
+
29
+ clean_source_dir
30
+
31
+ copy_headers
32
+ copy_library
33
+ copy_resources
34
+
35
+ cp_to_source_dir
36
+ end
37
+ end
38
+
39
+ private
40
+
41
+ def clean_source_dir
42
+ FileUtils.rm_rf(@source_files) if File.exist?(@source_files)
43
+ FileUtils.rm_rf(@source_zip_file) if File.exist?(@source_zip_file)
44
+ end
45
+
46
+ def cp_to_source_dir
47
+ target_dir = library.versions_path
48
+ dest_file = "#{@source_dir}/#{library.name_path}"
49
+ FileUtils.rm_rf(dest_file) if File.exist?(dest_file)
50
+
51
+ `cp -fa #{target_dir} #{dest_file}/`
52
+ end
53
+
54
+ def copy_headers
55
+ FileUtils.cp_r(framework.headers_path,library.versions_path) if File.exist?(framework.headers_path)
56
+ end
57
+
58
+ def copy_library
59
+ src_file = "#{framework.versions_path}/#{@spec.name}"
60
+ unless File.exist?(src_file)
61
+ raise Informative, "framework没有文件:#{src_file}"
62
+ end
63
+
64
+ dest_file = "#{library.versions_path}/#{@spec.name}"
65
+ rename_dest_file = "#{library.versions_path}/lib#{@spec.name}.a"
66
+ FileUtils.cp_r(src_file,dest_file)
67
+ File.rename(dest_file, rename_dest_file ) if File.exist?(dest_file)
68
+ end
69
+
70
+ def copy_resources
71
+ FileUtils.cp_r(framework.resources_path,library.versions_path) if File.exist?(framework.resources_path)
72
+ end
73
+
74
+
75
+ def framework
76
+ @framework ||= begin
77
+ framework = Framework.new(@spec.name, @platform.name.to_s)
78
+ framework.make
79
+ framework
80
+ end
81
+ end
82
+
83
+ def library
84
+ @library ||= begin
85
+ library = Library.new(@spec.name, @platform.name.to_s,@spec.version)
86
+ library.make
87
+ library
88
+ end
89
+ end
90
+ end
91
+ end
92
+ end