cocoapods-fy-bin 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.
Files changed (62) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +22 -0
  3. data/README.md +1 -0
  4. data/lib/cocoapods-fy-bin/command/bin/archive.rb +202 -0
  5. data/lib/cocoapods-fy-bin/command/bin/auto.rb +204 -0
  6. data/lib/cocoapods-fy-bin/command/bin/code.rb +232 -0
  7. data/lib/cocoapods-fy-bin/command/bin/imy.rb +46 -0
  8. data/lib/cocoapods-fy-bin/command/bin/init.rb +69 -0
  9. data/lib/cocoapods-fy-bin/command/bin/initHotKey.rb +70 -0
  10. data/lib/cocoapods-fy-bin/command/bin/install.rb +44 -0
  11. data/lib/cocoapods-fy-bin/command/bin/lib/lint.rb +69 -0
  12. data/lib/cocoapods-fy-bin/command/bin/repo/update.rb +43 -0
  13. data/lib/cocoapods-fy-bin/command/bin/spec/create.rb +73 -0
  14. data/lib/cocoapods-fy-bin/command/bin/spec/push.rb +114 -0
  15. data/lib/cocoapods-fy-bin/command/bin/update.rb +154 -0
  16. data/lib/cocoapods-fy-bin/command/bin.rb +59 -0
  17. data/lib/cocoapods-fy-bin/command.rb +2 -0
  18. data/lib/cocoapods-fy-bin/config/config.rb +137 -0
  19. data/lib/cocoapods-fy-bin/config/config_asker.rb +57 -0
  20. data/lib/cocoapods-fy-bin/config/config_builder.rb +228 -0
  21. data/lib/cocoapods-fy-bin/config/config_hot_key.rb +103 -0
  22. data/lib/cocoapods-fy-bin/config/config_hot_key_asker.rb +57 -0
  23. data/lib/cocoapods-fy-bin/gem_version.rb +10 -0
  24. data/lib/cocoapods-fy-bin/helpers/build_helper.rb +164 -0
  25. data/lib/cocoapods-fy-bin/helpers/build_utils.rb +63 -0
  26. data/lib/cocoapods-fy-bin/helpers/framework.rb +94 -0
  27. data/lib/cocoapods-fy-bin/helpers/framework_builder.rb +419 -0
  28. data/lib/cocoapods-fy-bin/helpers/library.rb +54 -0
  29. data/lib/cocoapods-fy-bin/helpers/library_builder.rb +91 -0
  30. data/lib/cocoapods-fy-bin/helpers/sources_helper.rb +36 -0
  31. data/lib/cocoapods-fy-bin/helpers/spec_creator.rb +170 -0
  32. data/lib/cocoapods-fy-bin/helpers/spec_files_helper.rb +77 -0
  33. data/lib/cocoapods-fy-bin/helpers/spec_source_creator.rb +229 -0
  34. data/lib/cocoapods-fy-bin/helpers/upload_helper.rb +97 -0
  35. data/lib/cocoapods-fy-bin/helpers.rb +5 -0
  36. data/lib/cocoapods-fy-bin/native/acknowledgements.rb +27 -0
  37. data/lib/cocoapods-fy-bin/native/analyzer.rb +55 -0
  38. data/lib/cocoapods-fy-bin/native/file_accessor.rb +28 -0
  39. data/lib/cocoapods-fy-bin/native/installation_options.rb +25 -0
  40. data/lib/cocoapods-fy-bin/native/installer.rb +204 -0
  41. data/lib/cocoapods-fy-bin/native/linter.rb +26 -0
  42. data/lib/cocoapods-fy-bin/native/path_source.rb +33 -0
  43. data/lib/cocoapods-fy-bin/native/pod_source_installer.rb +19 -0
  44. data/lib/cocoapods-fy-bin/native/pod_target_installer.rb +94 -0
  45. data/lib/cocoapods-fy-bin/native/podfile.rb +91 -0
  46. data/lib/cocoapods-fy-bin/native/podfile_env.rb +37 -0
  47. data/lib/cocoapods-fy-bin/native/podfile_generator.rb +199 -0
  48. data/lib/cocoapods-fy-bin/native/podspec_finder.rb +25 -0
  49. data/lib/cocoapods-fy-bin/native/resolver.rb +238 -0
  50. data/lib/cocoapods-fy-bin/native/sandbox_analyzer.rb +34 -0
  51. data/lib/cocoapods-fy-bin/native/source.rb +35 -0
  52. data/lib/cocoapods-fy-bin/native/sources_manager.rb +20 -0
  53. data/lib/cocoapods-fy-bin/native/specification.rb +31 -0
  54. data/lib/cocoapods-fy-bin/native/target_validator.rb +41 -0
  55. data/lib/cocoapods-fy-bin/native/validator.rb +40 -0
  56. data/lib/cocoapods-fy-bin/native.rb +23 -0
  57. data/lib/cocoapods-fy-bin/source_provider_hook.rb +55 -0
  58. data/lib/cocoapods-fy-bin.rb +2 -0
  59. data/lib/cocoapods_plugin.rb +3 -0
  60. data/spec/command/bin_spec.rb +12 -0
  61. data/spec/spec_helper.rb +50 -0
  62. metadata +177 -0
@@ -0,0 +1,164 @@
1
+ # copy from https://github.com/CocoaPods/cocoapods-packager
2
+
3
+ require 'cocoapods-fy-bin/native/podfile'
4
+ require 'cocoapods/command/gen'
5
+ require 'cocoapods/generate'
6
+ require 'cocoapods-fy-bin/helpers/framework_builder'
7
+ require 'cocoapods-fy-bin/helpers/library_builder'
8
+ require 'cocoapods-fy-bin/config/config_builder'
9
+
10
+ module CBin
11
+ class Build
12
+ class Helper
13
+ include Pod
14
+ #class var
15
+ @@build_defines = ""
16
+ #Debug下还待完成
17
+ def initialize(spec,
18
+ platform,
19
+ framework_output,
20
+ zip,
21
+ rootSpec,
22
+ archs,
23
+ skip_archive = false,
24
+ build_model="Release")
25
+ @spec = spec
26
+ @platform = platform
27
+ @build_model = build_model
28
+ @rootSpec = rootSpec
29
+ @isRootSpec = rootSpec.name == spec.name
30
+ @archs = archs
31
+ @skip_archive = skip_archive
32
+ @framework_output = framework_output
33
+ @zip = zip
34
+
35
+ @framework_path
36
+ end
37
+
38
+ def build
39
+ UI.section("Building static framework #{@spec}") do
40
+
41
+ build_static_framework
42
+ unless @skip_archive
43
+ unless CBin::Build::Utils.is_framework(@spec)
44
+ build_static_library
45
+ zip_static_library
46
+ else
47
+ zip_static_framework
48
+ end
49
+ end
50
+
51
+ end
52
+
53
+ end
54
+
55
+ def build_static_framework
56
+ source_dir = Dir.pwd
57
+ file_accessor = Sandbox::FileAccessor.new(Pathname.new('.').expand_path, @spec.consumer(@platform))
58
+ Dir.chdir(workspace_directory) do
59
+ builder = CBin::Framework::Builder.new(@spec, file_accessor, @platform, source_dir, @archs, @isRootSpec, @build_model)
60
+ @@build_defines = builder.build if @isRootSpec
61
+ begin
62
+ @framework_path = builder.lipo_build(@@build_defines) unless @skip_archive
63
+ rescue
64
+ @skip_archive = true
65
+ end
66
+ end
67
+ end
68
+
69
+ def build_static_library
70
+ source_dir = zip_dir
71
+ file_accessor = Sandbox::FileAccessor.new(Pathname.new('.').expand_path, @spec.consumer(@platform))
72
+ Dir.chdir(workspace_directory) do
73
+ builder = CBin::Library::Builder.new(@spec, file_accessor, @platform, source_dir , @archs, @framework_path)
74
+ builder.build
75
+ end
76
+ end
77
+
78
+ def zip_static_framework
79
+ Dir.chdir(File.join(workspace_directory,@framework_path.root_path)) do
80
+ output_name = File.join(zip_dir, framework_name_zip)
81
+ unless File.exist?(framework_name)
82
+ UI.puts "没有需要压缩的 framework 文件:#{framework_name}"
83
+ return
84
+ end
85
+
86
+ UI.puts "Compressing #{framework_name} into #{output_name}"
87
+ `zip --symlinks -r #{output_name} ./*`
88
+ end
89
+ end
90
+
91
+ def zip_static_library
92
+ Dir.chdir(zip_dir) do
93
+ output_library = "#{library_name}.zip"
94
+ unless File.exist?(library_name)
95
+ raise Informative, "没有需要压缩的 library 文件:#{library_name}"
96
+ end
97
+
98
+ UI.puts "Compressing #{library_name} into #{output_library}"
99
+
100
+ `zip --symlinks -r #{output_library} #{library_name}`
101
+ end
102
+
103
+ end
104
+
105
+
106
+ def clean_workspace
107
+ UI.puts 'Cleaning workspace'
108
+
109
+ FileUtils.rm_rf(gen_name)
110
+ Dir.chdir(zip_dir) do
111
+ FileUtils.rm_rf(framework_name) if @zip
112
+ FileUtils.rm_rf(library_name)
113
+ FileUtils.rm_rf(framework_name) unless @framework_output
114
+ FileUtils.rm_rf("#{framework_name}.zip") unless @framework_output
115
+ end
116
+ end
117
+
118
+ def framework_name
119
+ CBin::Config::Builder.instance.framework_name(@spec)
120
+ end
121
+
122
+ def framework_dsym_name
123
+ CBin::Config::Builder.instance.framework_dsym_name(@spec)
124
+ end
125
+
126
+ def framework_name_zip
127
+ CBin::Config::Builder.instance.framework_name_version(@spec) + ".zip"
128
+ end
129
+
130
+ def library_name
131
+ CBin::Config::Builder.instance.library_name(@spec)
132
+ end
133
+
134
+ def workspace_directory
135
+ File.expand_path("#{gen_name}/#{@rootSpec.name}")
136
+ end
137
+
138
+ def zip_dir
139
+ CBin::Config::Builder.instance.zip_dir
140
+ end
141
+
142
+ def gen_name
143
+ CBin::Config::Builder.instance.gen_dir
144
+ end
145
+
146
+
147
+ def spec_file
148
+ @spec_file ||= begin
149
+ if @podspec
150
+ find_spec_file(@podspec)
151
+ else
152
+ if code_spec_files.empty?
153
+ raise Informative, '当前目录下没有找到可用源码 podspec.'
154
+ end
155
+
156
+ spec_file = code_spec_files.first
157
+ spec_file
158
+ end
159
+ end
160
+ end
161
+
162
+ end
163
+ end
164
+ end
@@ -0,0 +1,63 @@
1
+ require 'yaml'
2
+ require 'cocoapods-fy-bin/config/config'
3
+
4
+ module CBin
5
+ class Build
6
+
7
+ class Utils
8
+
9
+ def Utils.is_framework(spec)
10
+ # if Utils.uses_frameworks?
11
+ return true
12
+ # end
13
+ #
14
+ # return Utils.is_swift_module(spec)
15
+ end
16
+
17
+ def Utils.is_swift_module(spec)
18
+
19
+ is_framework = false
20
+ dir = File.join(CBin::Config::Builder.instance.gen_dir, CBin::Config::Builder.instance.target_name)
21
+ #auto 走这里
22
+ if File.exist?(dir)
23
+ Dir.chdir(dir) do
24
+ public_headers = Array.new
25
+ spec_header_dir = "./Headers/Public/#{spec.name}"
26
+
27
+ unless File.exist?(spec_header_dir)
28
+ spec_header_dir = "./Pods/Headers/Public/#{spec.name}"
29
+ end
30
+ return false unless File.exist?(spec_header_dir)
31
+
32
+ is_framework = File.exist?(File.join(spec_header_dir, "#{spec.name}-umbrella.h"))
33
+ end
34
+ end
35
+
36
+ if $ARGV[1] == "local"
37
+ is_framework = File.exist?(File.join(CBin::Config::Builder.instance.xcode_build_dir, "#{spec.name}.framework"))
38
+ unless is_framework
39
+ is_framework = File.exist?(File.join(CBin::Config::Builder.instance.xcode_BuildProductsPath_dir, "#{spec.name}","Swift Compatibility Header"))
40
+ end
41
+ end
42
+
43
+ is_framework
44
+ end
45
+
46
+ def Utils.uses_frameworks?
47
+ uses_frameworks = false
48
+ Pod::Config.instance.podfile.target_definitions.each do |key,value|
49
+ if key != "Pods"
50
+ uses_frameworks = value.uses_frameworks?
51
+ if uses_frameworks
52
+ break ;
53
+ end
54
+ end
55
+ end
56
+
57
+ return uses_frameworks
58
+ end
59
+
60
+ end
61
+
62
+ end
63
+ end
@@ -0,0 +1,94 @@
1
+ # copy from https://github.com/CocoaPods/cocoapods-packager
2
+
3
+ module CBin
4
+ class Framework
5
+ attr_reader :headers_path
6
+ attr_reader :private_headers_path
7
+ attr_reader :module_map_path
8
+ attr_reader :resources_path
9
+ attr_reader :root_path
10
+ attr_reader :versions_path
11
+ attr_reader :swift_module_path
12
+ attr_reader :fwk_path
13
+
14
+ def initialize(name, platform)
15
+ @name = name
16
+ @platform = platform
17
+ end
18
+
19
+ def make
20
+ # 创建平台根目录
21
+ make_root
22
+ # 创建framework目录树
23
+ make_framework
24
+ # 创建headers 目录
25
+ make_headers
26
+ make_resources
27
+ # make_current_version
28
+ end
29
+
30
+ def delete_resources
31
+ Pathname.new(@resources_path).rmtree if File.exist? (@resources_path)
32
+ (Pathname.new(@fwk_path) + Pathname.new('Resources')).delete if File.exist?(Pathname.new(@fwk_path) + Pathname.new('Resources'))
33
+ end
34
+
35
+ def remove_current_version
36
+ FileUtils.rm_f(File.join(@fwk_path,@name))
37
+ FileUtils.rm_f(File.join(@fwk_path,"Headers"))
38
+ FileUtils.rm_f(File.join(@fwk_path,"Resources"))
39
+
40
+ FileUtils.cp_r("#{@versions_path}/.", @fwk_path)
41
+ # FileUtils.remove_dir(@versions_path)
42
+ FileUtils.remove_dir("#{@fwk_path}/Versions")
43
+
44
+ # current_version_path = @versions_path + Pathname.new('../Current')
45
+ # `ln -sf A #{current_version_path}`
46
+ # `ln -sf Versions/Current/Headers #{@fwk_path}/`
47
+ # `ln -sf Versions/Current/Resources #{@fwk_path}/`
48
+ # `ln -sf Versions/Current/#{@name} #{@fwk_path}/`
49
+ end
50
+
51
+ private
52
+
53
+ def make_current_version
54
+ current_version_path = @versions_path + Pathname.new('../Current')
55
+ `ln -sf A #{current_version_path}`
56
+ `ln -sf Versions/Current/Headers #{@fwk_path}/`
57
+ `ln -sf Versions/Current/Resources #{@fwk_path}/`
58
+ `ln -sf Versions/Current/#{@name} #{@fwk_path}/`
59
+ end
60
+
61
+
62
+
63
+ def make_framework
64
+ @fwk_path = @root_path + Pathname.new(@name + '.framework')
65
+ @fwk_path.mkdir unless @fwk_path.exist?
66
+
67
+ @module_map_path = @fwk_path + Pathname.new('Modules')
68
+ @module_map_path.mkdir unless @module_map_path.exist?
69
+ @swift_module_path = @module_map_path + Pathname.new(@name + '.swiftmodule')
70
+ @swift_module_path.mkdir unless @swift_module_path.exist?
71
+
72
+ # @versions_path = @fwk_path + Pathname.new('Versions/A')
73
+ end
74
+
75
+ def make_headers
76
+ # @headers_path = @versions_path + Pathname.new('Headers')
77
+ @headers_path = @fwk_path + Pathname.new('Headers')
78
+ @private_headers_path = @fwk_path + Pathname.new('PrivateHeaders')
79
+ @headers_path.mkpath unless @headers_path.exist?
80
+ @private_headers_path.mkpath unless @private_headers_path.exist?
81
+ end
82
+
83
+ def make_resources
84
+ # @resources_path = @fwk_path + Pathname.new('Resources')
85
+ @resources_path = @fwk_path
86
+ @resources_path.mkpath unless @resources_path.exist?
87
+ end
88
+
89
+ def make_root
90
+ @root_path = Pathname.new(@platform)
91
+ @root_path.mkpath unless @root_path.exist?
92
+ end
93
+ end
94
+ end