cocoapods-tt 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 (124) hide show
  1. checksums.yaml +7 -0
  2. data/lib/cocoapods-tt/command/native/install.rb +56 -0
  3. data/lib/cocoapods-tt/command/native/update.rb +157 -0
  4. data/lib/cocoapods-tt/command/tt/make.rb +92 -0
  5. data/lib/cocoapods-tt/command/tt.rb +115 -0
  6. data/lib/cocoapods-tt/command.rb +1 -0
  7. data/lib/cocoapods-tt/gem_version.rb +3 -0
  8. data/lib/cocoapods-tt/native/command.rb +185 -0
  9. data/lib/cocoapods-tt/native/config.rb +366 -0
  10. data/lib/cocoapods-tt/native/core_overrides.rb +1 -0
  11. data/lib/cocoapods-tt/native/downloader/cache.rb +322 -0
  12. data/lib/cocoapods-tt/native/downloader/request.rb +86 -0
  13. data/lib/cocoapods-tt/native/downloader/response.rb +16 -0
  14. data/lib/cocoapods-tt/native/downloader.rb +192 -0
  15. data/lib/cocoapods-tt/native/executable.rb +247 -0
  16. data/lib/cocoapods-tt/native/external_sources/abstract_external_source.rb +205 -0
  17. data/lib/cocoapods-tt/native/external_sources/downloader_source.rb +30 -0
  18. data/lib/cocoapods-tt/native/external_sources/path_source.rb +55 -0
  19. data/lib/cocoapods-tt/native/external_sources/podspec_source.rb +54 -0
  20. data/lib/cocoapods-tt/native/external_sources.rb +57 -0
  21. data/lib/cocoapods-tt/native/gem_version.rb +5 -0
  22. data/lib/cocoapods-tt/native/generator/acknowledgements/markdown.rb +44 -0
  23. data/lib/cocoapods-tt/native/generator/acknowledgements/plist.rb +94 -0
  24. data/lib/cocoapods-tt/native/generator/acknowledgements.rb +107 -0
  25. data/lib/cocoapods-tt/native/generator/app_target_helper.rb +363 -0
  26. data/lib/cocoapods-tt/native/generator/bridge_support.rb +22 -0
  27. data/lib/cocoapods-tt/native/generator/constant.rb +19 -0
  28. data/lib/cocoapods-tt/native/generator/copy_dsyms_script.rb +56 -0
  29. data/lib/cocoapods-tt/native/generator/copy_resources_script.rb +223 -0
  30. data/lib/cocoapods-tt/native/generator/copy_xcframework_script.rb +227 -0
  31. data/lib/cocoapods-tt/native/generator/dummy_source.rb +31 -0
  32. data/lib/cocoapods-tt/native/generator/embed_frameworks_script.rb +196 -0
  33. data/lib/cocoapods-tt/native/generator/file_list.rb +39 -0
  34. data/lib/cocoapods-tt/native/generator/header.rb +103 -0
  35. data/lib/cocoapods-tt/native/generator/info_plist_file.rb +128 -0
  36. data/lib/cocoapods-tt/native/generator/module_map.rb +99 -0
  37. data/lib/cocoapods-tt/native/generator/prefix_header.rb +60 -0
  38. data/lib/cocoapods-tt/native/generator/script_phase_constants.rb +100 -0
  39. data/lib/cocoapods-tt/native/generator/umbrella_header.rb +46 -0
  40. data/lib/cocoapods-tt/native/hooks_manager.rb +132 -0
  41. data/lib/cocoapods-tt/native/installer/analyzer/analysis_result.rb +87 -0
  42. data/lib/cocoapods-tt/native/installer/analyzer/locking_dependency_analyzer.rb +103 -0
  43. data/lib/cocoapods-tt/native/installer/analyzer/pod_variant.rb +87 -0
  44. data/lib/cocoapods-tt/native/installer/analyzer/pod_variant_set.rb +175 -0
  45. data/lib/cocoapods-tt/native/installer/analyzer/podfile_dependency_cache.rb +55 -0
  46. data/lib/cocoapods-tt/native/installer/analyzer/sandbox_analyzer.rb +268 -0
  47. data/lib/cocoapods-tt/native/installer/analyzer/specs_state.rb +108 -0
  48. data/lib/cocoapods-tt/native/installer/analyzer/target_inspection_result.rb +58 -0
  49. data/lib/cocoapods-tt/native/installer/analyzer/target_inspector.rb +258 -0
  50. data/lib/cocoapods-tt/native/installer/analyzer.rb +1204 -0
  51. data/lib/cocoapods-tt/native/installer/base_install_hooks_context.rb +135 -0
  52. data/lib/cocoapods-tt/native/installer/installation_options.rb +195 -0
  53. data/lib/cocoapods-tt/native/installer/pod_source_installer.rb +224 -0
  54. data/lib/cocoapods-tt/native/installer/pod_source_preparer.rb +77 -0
  55. data/lib/cocoapods-tt/native/installer/podfile_validator.rb +168 -0
  56. data/lib/cocoapods-tt/native/installer/post_install_hooks_context.rb +9 -0
  57. data/lib/cocoapods-tt/native/installer/post_integrate_hooks_context.rb +9 -0
  58. data/lib/cocoapods-tt/native/installer/pre_install_hooks_context.rb +51 -0
  59. data/lib/cocoapods-tt/native/installer/pre_integrate_hooks_context.rb +9 -0
  60. data/lib/cocoapods-tt/native/installer/project_cache/project_cache.rb +11 -0
  61. data/lib/cocoapods-tt/native/installer/project_cache/project_cache_analysis_result.rb +53 -0
  62. data/lib/cocoapods-tt/native/installer/project_cache/project_cache_analyzer.rb +200 -0
  63. data/lib/cocoapods-tt/native/installer/project_cache/project_cache_version.rb +43 -0
  64. data/lib/cocoapods-tt/native/installer/project_cache/project_installation_cache.rb +103 -0
  65. data/lib/cocoapods-tt/native/installer/project_cache/project_metadata_cache.rb +73 -0
  66. data/lib/cocoapods-tt/native/installer/project_cache/target_cache_key.rb +176 -0
  67. data/lib/cocoapods-tt/native/installer/project_cache/target_metadata.rb +74 -0
  68. data/lib/cocoapods-tt/native/installer/sandbox_dir_cleaner.rb +105 -0
  69. data/lib/cocoapods-tt/native/installer/sandbox_header_paths_installer.rb +45 -0
  70. data/lib/cocoapods-tt/native/installer/source_provider_hooks_context.rb +34 -0
  71. data/lib/cocoapods-tt/native/installer/target_uuid_generator.rb +34 -0
  72. data/lib/cocoapods-tt/native/installer/user_project_integrator/target_integrator/xcconfig_integrator.rb +179 -0
  73. data/lib/cocoapods-tt/native/installer/user_project_integrator/target_integrator.rb +815 -0
  74. data/lib/cocoapods-tt/native/installer/user_project_integrator.rb +280 -0
  75. data/lib/cocoapods-tt/native/installer/xcode/multi_pods_project_generator.rb +82 -0
  76. data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator/aggregate_target_dependency_installer.rb +66 -0
  77. data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator/aggregate_target_installer.rb +192 -0
  78. data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator/app_host_installer.rb +154 -0
  79. data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator/file_references_installer.rb +329 -0
  80. data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator/pod_target_dependency_installer.rb +195 -0
  81. data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator/pod_target_installer.rb +1239 -0
  82. data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator/pod_target_integrator.rb +312 -0
  83. data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator/pods_project_writer.rb +90 -0
  84. data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator/project_generator.rb +120 -0
  85. data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator/target_installation_result.rb +140 -0
  86. data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator/target_installer.rb +257 -0
  87. data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator/target_installer_helper.rb +110 -0
  88. data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator.rb +291 -0
  89. data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator_result.rb +54 -0
  90. data/lib/cocoapods-tt/native/installer/xcode/single_pods_project_generator.rb +38 -0
  91. data/lib/cocoapods-tt/native/installer/xcode/target_validator.rb +170 -0
  92. data/lib/cocoapods-tt/native/installer/xcode.rb +11 -0
  93. data/lib/cocoapods-tt/native/installer.rb +1044 -0
  94. data/lib/cocoapods-tt/native/native_target_extension.rb +60 -0
  95. data/lib/cocoapods-tt/native/open-uri.rb +33 -0
  96. data/lib/cocoapods-tt/native/podfile.rb +13 -0
  97. data/lib/cocoapods-tt/native/project.rb +544 -0
  98. data/lib/cocoapods-tt/native/resolver/lazy_specification.rb +88 -0
  99. data/lib/cocoapods-tt/native/resolver/resolver_specification.rb +41 -0
  100. data/lib/cocoapods-tt/native/resolver.rb +600 -0
  101. data/lib/cocoapods-tt/native/sandbox/file_accessor.rb +532 -0
  102. data/lib/cocoapods-tt/native/sandbox/headers_store.rb +163 -0
  103. data/lib/cocoapods-tt/native/sandbox/path_list.rb +242 -0
  104. data/lib/cocoapods-tt/native/sandbox/pod_dir_cleaner.rb +71 -0
  105. data/lib/cocoapods-tt/native/sandbox/podspec_finder.rb +23 -0
  106. data/lib/cocoapods-tt/native/sandbox.rb +470 -0
  107. data/lib/cocoapods-tt/native/sources_manager.rb +221 -0
  108. data/lib/cocoapods-tt/native/target/aggregate_target.rb +558 -0
  109. data/lib/cocoapods-tt/native/target/build_settings.rb +1385 -0
  110. data/lib/cocoapods-tt/native/target/pod_target.rb +1168 -0
  111. data/lib/cocoapods-tt/native/target.rb +378 -0
  112. data/lib/cocoapods-tt/native/user_interface/error_report.rb +204 -0
  113. data/lib/cocoapods-tt/native/user_interface/inspector_reporter.rb +102 -0
  114. data/lib/cocoapods-tt/native/user_interface.rb +463 -0
  115. data/lib/cocoapods-tt/native/validator.rb +1170 -0
  116. data/lib/cocoapods-tt/native/version_metadata.rb +26 -0
  117. data/lib/cocoapods-tt/native/xcode/framework_paths.rb +54 -0
  118. data/lib/cocoapods-tt/native/xcode/linkage_analyzer.rb +22 -0
  119. data/lib/cocoapods-tt/native/xcode/xcframework/xcframework_slice.rb +138 -0
  120. data/lib/cocoapods-tt/native/xcode/xcframework.rb +99 -0
  121. data/lib/cocoapods-tt/native/xcode.rb +7 -0
  122. data/lib/cocoapods-tt.rb +1 -0
  123. data/lib/cocoapods_plugin.rb +17 -0
  124. metadata +193 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1f83b010c86d335f27d204f0903698781b956af7aae5b81815025fc2374a7fc4
4
+ data.tar.gz: 41b3cc118e3ce05c2494e05630a53938155f110d1cbbbdefc77a209c0dd8e9db
5
+ SHA512:
6
+ metadata.gz: 3631ee3d453e66ccb7445c06eb07604aa0c8382ba559881fa42dc0029c23199ab9bdc8c59a54f4e347e62d3b783c9e32a39fbe8c10c94382310db1d4402f5c15
7
+ data.tar.gz: 6235c9dde0439a02264c0c6ccf3aa70e389b09febe249b91d2d6c243a8512cb7064a5df6d1f7f1a4977d2e21a968a1e6e50d03ad479367f7e77f4878bd67e517
@@ -0,0 +1,56 @@
1
+ module Pod
2
+ class Command
3
+ class Install < Command
4
+ include RepoUpdate
5
+ include ProjectDirectory
6
+
7
+ self.summary = 'Install project dependencies according to versions from a Podfile.lock'
8
+
9
+ self.description = <<-DESC
10
+ Downloads all dependencies defined in `Podfile` and creates an Xcode
11
+ Pods library project in `./Pods`.
12
+
13
+ The Xcode project file should be specified in your `Podfile` like this:
14
+
15
+ project 'path/to/XcodeProject.xcodeproj'
16
+
17
+ If no project is specified, then a search for an Xcode project will
18
+ be made. If more than one Xcode project is found, the command will
19
+ raise an error.
20
+
21
+ This will configure the project to reference the Pods static library,
22
+ add a build configuration file, and add a post build script to copy
23
+ Pod resources.
24
+
25
+ This may return one of several error codes if it encounters problems.
26
+ * `1` Generic error code
27
+ * `31` Spec not found (i.e out-of-date source repos, mistyped Pod name etc...)
28
+ DESC
29
+
30
+ def self.options
31
+ [
32
+ ['--repo-update', 'Force running `pod repo update` before install'],
33
+ ['--deployment', 'Disallow any changes to the Podfile or the Podfile.lock during installation'],
34
+ ['--clean-install', 'Ignore the contents of the project cache and force a full pod installation. This only ' \
35
+ 'applies to projects that have enabled incremental installation'],
36
+ ].concat(super).reject { |(name, _)| name == '--no-repo-update' }
37
+ end
38
+
39
+ def initialize(argv)
40
+ super
41
+ @deployment = argv.flag?('deployment', false)
42
+ @clean_install = argv.flag?('clean-install', false)
43
+ end
44
+
45
+ def run
46
+ verify_podfile_exists!
47
+ installer = installer_for_config
48
+ installer.repo_update = repo_update?(:default => false)
49
+ installer.update = false
50
+ installer.deployment = @deployment
51
+ installer.clean_install = @clean_install
52
+ installer.install!
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,157 @@
1
+
2
+ require 'cocoapods'
3
+ # require 'cocoapods-imy-bin/native/podfile_env'
4
+ # require 'cocoapods-imy-bin/native/podfile'
5
+
6
+ module Pod
7
+ class Command
8
+ class Bin < Command
9
+ class Update < Bin
10
+ include Pod
11
+ include Pod::Podfile::DSL
12
+
13
+ self.summary = 'pod update 拦截器,会加载本地Podfile_local文件,DSL加载到原始Podfile文件中。'
14
+
15
+ self.description = <<-DESC
16
+ pod update 拦截器,
17
+ 支持 pod 'xxx' 各种写法
18
+ 支持 post_install/pre_install钩子,采用覆盖做法
19
+ DESC
20
+ def self.options
21
+ [
22
+ ["--sources=#{Pod::TrunkSource::TRUNK_REPO_URL}", 'The sources from which to update dependent pods. ' \
23
+ 'Multiple sources must be comma-delimited'],
24
+ ['--exclude-pods=podName', 'Pods to exclude during update. Multiple pods must be comma-delimited'],
25
+ ['--clean-install', 'Ignore the contents of the project cache and force a full pod installation. This only ' \
26
+ 'applies to projects that have enabled incremental installation'],
27
+ ['--project-directory=/project/dir/', 'The path to the root of the project directory'],
28
+ ['--no-repo-update', 'Skip running `pod repo update` before install']
29
+ ].concat(super)
30
+ end
31
+
32
+ def initialize(argv)
33
+ puts "自定义的 update"
34
+ @update = argv.flag?('update')
35
+ super
36
+ @additional_args = argv.remainder!
37
+ end
38
+
39
+ def run
40
+ Update.load_local_podfile
41
+
42
+ argvs = [
43
+ *@additional_args
44
+ ]
45
+
46
+ gen = Pod::Command::Update.new(CLAide::ARGV.new(argvs))
47
+ gen.validate!
48
+ gen.run
49
+ end
50
+
51
+ def self.load_local_podfile
52
+ # 同步 Podfile_local 文件
53
+ project_root = Pod::Config.instance.project_root
54
+ path = File.join(project_root.to_s, 'Podfile_local')
55
+ unless File.exist?(path)
56
+ path = File.join(project_root.to_s, 'Podfile_local')
57
+ end
58
+
59
+ if File.exist?(path)
60
+ contents = File.open(path, 'r:utf-8', &:read)
61
+
62
+ podfile = Pod::Config.instance.podfile
63
+ local_podfile = Podfile.from_file(path)
64
+
65
+ if local_podfile
66
+ local_pre_install_callback = nil
67
+ local_post_install_callback = nil
68
+ local_podfile.instance_eval do
69
+ local_pre_install_callback = @pre_install_callback
70
+ local_post_install_callback = @post_install_callback
71
+ end
72
+ end
73
+
74
+ podfile.instance_eval do
75
+ begin
76
+
77
+ # podfile HASH_KEYS才有plugins字段,否则会被限制
78
+ if local_podfile.plugins.any?
79
+ hash_plugins = podfile.plugins || {}
80
+ hash_plugins = hash_plugins.merge(local_podfile.plugins)
81
+ set_hash_value(%w[plugins].first, hash_plugins)
82
+
83
+ # 加入源码白名单,避免本地库被二进制了
84
+ podfile.set_use_source_pods(local_podfile.use_source_pods) if local_podfile.use_source_pods
85
+ podfile.use_binaries!(local_podfile.use_binaries?)
86
+ end
87
+
88
+ # 在target把local-target中到dependencies值删除了,再设置
89
+ # 把本地和原始到dependencies 合并,设置dependencies
90
+ local_podfile&.target_definition_list&.each do |local_target|
91
+ next if local_target.name == 'Pods'
92
+
93
+ target_definition_list.each do |target|
94
+
95
+ unless target.name == local_target.name &&
96
+ (local_target.to_hash['dependencies'] &&local_target.to_hash['dependencies'].any?)
97
+ next
98
+ end
99
+
100
+
101
+
102
+ target.instance_exec do
103
+ # 在target把local-target中到dependencies值删除了,再设置
104
+
105
+ local_dependencies = local_target.to_hash['dependencies']
106
+ target_dependencies = target.to_hash['dependencies']
107
+
108
+ local_dependencies.each do |local_dependency|
109
+ unless local_dependency.is_a?(Hash) && local_dependency.keys.first
110
+ next
111
+ end
112
+
113
+ target_dependencies.each do |target_dependency|
114
+ dp_hash_equal = target_dependency.is_a?(Hash) &&
115
+ target_dependency.keys.first &&
116
+ target_dependency.keys.first == local_dependency.keys.first
117
+ dp_str_equal = target_dependency.is_a?(String) &&
118
+ target_dependency == local_dependency.keys.first
119
+ next unless dp_hash_equal || dp_str_equal
120
+
121
+ target_dependencies.delete target_dependency
122
+ break
123
+ end
124
+ end
125
+ # 把本地和原始到dependencies 合并,设置dependencies
126
+ local_dependencies.each do |d|
127
+ UI.message "Development Pod #{d.to_yaml}"
128
+ if podfile.plugins.keys.include?('cocoapods-imy-bin')
129
+ podfile.set_use_source_pods(d.keys.first) if (d.is_a?(Hash) && d.keys.first)
130
+ end
131
+ end
132
+ new_dependencies = target_dependencies + local_dependencies
133
+ set_hash_value(%w[dependencies].first, new_dependencies)
134
+
135
+ end
136
+ end
137
+
138
+ end
139
+
140
+ if local_pre_install_callback
141
+ @pre_install_callback = local_pre_install_callback
142
+ end
143
+ if local_post_install_callback
144
+ @post_install_callback = local_post_install_callback
145
+ end
146
+ rescue Exception => e
147
+ message = "Invalid `#{path}` file: #{e.message}"
148
+ raise Pod::DSLError.new(message, path, e, contents)
149
+ end
150
+ end
151
+
152
+ end
153
+ end
154
+ end
155
+ end
156
+ end
157
+ end
@@ -0,0 +1,92 @@
1
+ #!/usr/bin/ruby
2
+ require 'json'
3
+
4
+
5
+ #查找podspec
6
+ # spec_files = Pathname.glob("/Users/80374111/.cocoapods/repos/cocoapods/Specs/0/0/0/AMRAdapterMintegral-Beta/" + '{,*}.podspec{,.json}')
7
+ # spec_files.each do |file|
8
+ # puts file
9
+ # end
10
+
11
+ # module Pod
12
+ # class Command
13
+ # class Tt < Command
14
+ # class Make < Tt
15
+ # self.summary = '制作二进制文件和podspec文件'
16
+
17
+ # self.description = <<-DESC
18
+ # 制作二进制文件和podspec文件
19
+ # DESC
20
+
21
+ # def self.options
22
+
23
+ # end
24
+
25
+ # def initialize(argv)
26
+ # super
27
+
28
+ # end
29
+ # def run
30
+ # puts ("run")
31
+ # end
32
+ # end
33
+ # end
34
+ # end
35
+
36
+ $home_path = Dir.pwd.unicode_normalize(:nfkc)
37
+ $Binary_tool_path = $home_path + "/Binary"
38
+ def change_podspec(podspec_path)
39
+
40
+
41
+ json = File.read(podspec_path)
42
+ obj = JSON.parse(json)
43
+ version = obj["version"]
44
+ pod_name = obj["name"]
45
+ source_url = "https://ocs-cn-south1.heytapcs.com/cd-build-prod/ios-#{pod_name}-#{version}.zip" #依照约定
46
+
47
+ source = Hash["http" => source_url]
48
+
49
+
50
+ obj["source"]=source
51
+
52
+ obj["vendored_frameworks"] = "#{pod_name}.framework"
53
+ #上传framework 还是.a库
54
+ # obj["vendored_libraries"] = "KDFoundation/#{pod_name}"
55
+ # obj["source_files"]="**/*"
56
+
57
+
58
+ #上传podspec
59
+ upload_podspec_name = "ios-#{pod_name}-podspec.json" #依照约定
60
+ binary_podspec_path = "#$Binary_tool_path/binary_podspecs/binary_#{pod_name}.podspec.json"
61
+ version_upload_podspec_name = "ios-#{pod_name}-#{version}-podspec.json" #依照约定
62
+ upload_py_path = "#$Binary_tool_path/upload_ocs_client.py"
63
+
64
+
65
+ File.write(binary_podspec_path,JSON.pretty_generate(obj))#用obj.to_json 格式不好看
66
+ upload_command = "python3 #{upload_py_path} #{binary_podspec_path} #{upload_podspec_name}"
67
+ version_upload_command = "python3 #{upload_py_path} #{binary_podspec_path} #{version_upload_podspec_name}"
68
+
69
+ result = system upload_command
70
+ system version_upload_command
71
+ if result
72
+ File.delete(binary_podspec_path)
73
+ end
74
+
75
+
76
+ #制作和上传二进制
77
+ sh_path = "#$Binary_tool_path/binary_build.sh"
78
+ build_cmd = "sh #{sh_path} #$Binary_tool_path #{pod_name} #{version}"
79
+ puts build_cmd
80
+ system build_cmd
81
+
82
+ end
83
+
84
+
85
+ ori_podSpec_path = "#$Binary_tool_path/podspecs"
86
+ files = Dir::glob("#{ori_podSpec_path}/*.podspec.json")
87
+ puts ori_podSpec_path
88
+ files.each do |file|
89
+ puts "make file #{file}"
90
+ change_podspec(file)
91
+ end
92
+
@@ -0,0 +1,115 @@
1
+
2
+ module Pod
3
+ class Command
4
+
5
+ class Tt < Command
6
+ include RepoUpdate
7
+ include ProjectDirectory
8
+
9
+ $home_path = Dir.pwd.unicode_normalize(:nfkc)
10
+ $podfile_path = $home_path+ "/Podfile"
11
+ $podfile_backup_path = $home_path + "/Podfile_backup_temp"
12
+
13
+ self.summary = '添加tt自定义操作,其他与原生install 无差别'
14
+
15
+ self.description = <<-DESC
16
+ 在进行二进制podfile转换后,执行pod install,添加tt自定义操作,其他与原生install 无差别
17
+ DESC
18
+
19
+ def self.options
20
+ [
21
+ ['--repo-update', 'Force running `pod repo update` before install'],
22
+ ['--deployment', 'Disallow any changes to the Podfile or the Podfile.lock during installation'],
23
+ ['--clean-install', 'Ignore the contents of the project cache and force a full pod installation. This only ' \
24
+ 'applies to projects that have enabled incremental installation'],
25
+ ].concat(super).reject { |(name, _)| name == '--no-repo-update' }
26
+ end
27
+
28
+ def initialize(argv)
29
+ super
30
+ @deployment = argv.flag?('deployment', false)
31
+ @clean_install = argv.flag?('clean-install', false)
32
+ end
33
+
34
+ # ========================自定义操作 begin =========================
35
+ def backup_podfile
36
+ ori_path = $podfile_path
37
+ backup_path = $podfile_backup_path
38
+ suc = system "cp #{ori_path} #{backup_path}"
39
+ if suc
40
+ puts "podfile 备份成功"
41
+ else
42
+ puts "podfile 备份失败"
43
+ end
44
+ end
45
+
46
+ def recover_podfile
47
+ File.delete($podfile_path)
48
+ File.rename($podfile_backup_path,$podfile_path)
49
+ end
50
+
51
+
52
+ def change_pod_line(pod_name,podspec_url)
53
+
54
+ f = File.new($podfile_path, 'r+') #"r+" Read-write, starts at beginning of file.
55
+ target_line = ""
56
+ f.each do |line|
57
+ if line.include?("'#{pod_name}'")
58
+ if line.include?('pod')
59
+ target_line = line
60
+ puts "targeit_line"+target_line
61
+ end
62
+ end
63
+ end
64
+
65
+ if target_line.include?('pod ')
66
+ new_line= " pod '#{pod_name}', :podspec => '#{podspec_url}'\n"
67
+ #替换文本
68
+ File.open($podfile_path,"r:utf-8") do |lines|
69
+ buffer = lines.read.gsub(target_line,new_line)
70
+ File.open($podfile_path,"w"){|l|
71
+ l.write(buffer)
72
+ }
73
+ puts target_line + "转换成" + new_line
74
+ end
75
+ else
76
+ puts "#{pod_name} 不在podfile中"
77
+ end
78
+
79
+
80
+ end
81
+
82
+ def change_podfile
83
+ white_path= $home_path + "/Binary"+ "/tt_binary_white.txt"
84
+ white_list = File.open(white_path, "r+")
85
+ white_list.each do |line|
86
+ pod_name = line.lstrip.rstrip.chomp #去除空格、国行符号等
87
+ podspec_url = "https://ocs-cn-south1.heytapcs.com/cd-build-prod/ios-#{pod_name}-podspec.json"
88
+ change_pod_line(pod_name,podspec_url)
89
+ end
90
+ end
91
+
92
+
93
+ def tt_make
94
+ backup_podfile
95
+ change_podfile
96
+ end
97
+ # ========================自定义操作 end =========================
98
+
99
+
100
+ def run
101
+ puts "pod tt 会在自定义操作后执行pod install; pod install所有功能参数都可以使用,如:pod install --repo-update 相当于 pod install --repo-update "
102
+ tt_make
103
+ verify_podfile_exists!
104
+ installer = installer_for_config
105
+ installer.repo_update = repo_update?(:default => false)
106
+ installer.update = false
107
+ installer.deployment = @deployment
108
+ installer.clean_install = @clean_install
109
+ installer.install!
110
+ recover_podfile
111
+ end
112
+ end
113
+ end
114
+ end
115
+
@@ -0,0 +1 @@
1
+ require 'cocoapods-tt/command/tt'
@@ -0,0 +1,3 @@
1
+ module CocoapodsTt
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,185 @@
1
+ require 'colored2'
2
+ require 'claide'
3
+ require 'molinillo/errors'
4
+
5
+ module Molinillo
6
+ class ResolverError
7
+ include CLAide::InformativeError
8
+ end
9
+ end
10
+
11
+ module Pod
12
+ class PlainInformative
13
+ include CLAide::InformativeError
14
+ end
15
+
16
+ class Command < CLAide::Command
17
+ require 'cocoapods/command/options/repo_update'
18
+ require 'cocoapods/command/options/project_directory'
19
+ include Options
20
+
21
+ require 'cocoapods/command/cache'
22
+ require 'cocoapods/command/env'
23
+ require 'cocoapods/command/init'
24
+ require 'cocoapods/command/install'
25
+ require 'cocoapods/command/ipc'
26
+ require 'cocoapods/command/lib'
27
+ require 'cocoapods/command/list'
28
+ require 'cocoapods/command/outdated'
29
+ require 'cocoapods/command/repo'
30
+ require 'cocoapods/command/setup'
31
+ require 'cocoapods/command/spec'
32
+ require 'cocoapods/command/update'
33
+
34
+ self.abstract_command = true
35
+ self.command = 'pod'
36
+ self.version = VERSION
37
+ self.description = 'CocoaPods, the Cocoa library package manager.'
38
+ self.plugin_prefixes = %w(claide cocoapods)
39
+
40
+ def self.options
41
+ [
42
+ ['--allow-root', 'Allows CocoaPods to run as root'],
43
+ ['--silent', 'Show nothing'],
44
+ ].concat(super)
45
+ end
46
+
47
+ def self.run(argv)
48
+ ensure_not_root_or_allowed! argv
49
+ verify_minimum_git_version!
50
+ verify_xcode_license_approved!
51
+
52
+ super(argv)
53
+ ensure
54
+ UI.print_warnings
55
+ end
56
+
57
+ def self.report_error(exception)
58
+ case exception
59
+ when Interrupt
60
+ puts '[!] Cancelled'.red
61
+ Config.instance.verbose? ? raise : exit(1)
62
+ when SystemExit
63
+ raise
64
+ else
65
+ if ENV['COCOA_PODS_ENV'] != 'development'
66
+ puts UI::ErrorReport.report(exception)
67
+ UI::ErrorReport.search_for_exceptions(exception)
68
+ exit 1
69
+ else
70
+ raise exception
71
+ end
72
+ end
73
+ end
74
+
75
+ # @todo If a command is run inside another one some settings which where
76
+ # true might return false.
77
+ #
78
+ # @todo We should probably not even load colored unless needed.
79
+ #
80
+ # @todo Move silent flag to CLAide.
81
+ #
82
+ # @note It is important that the commands don't override the default
83
+ # settings if their flag is missing (i.e. their value is nil)
84
+ #
85
+ def initialize(argv)
86
+ super
87
+ config.silent = argv.flag?('silent', config.silent)
88
+ config.allow_root = argv.flag?('allow-root', config.allow_root)
89
+ config.verbose = self.verbose? unless verbose.nil?
90
+ unless self.ansi_output?
91
+ Colored2.disable!
92
+ String.send(:define_method, :colorize) { |string, _| string }
93
+ end
94
+ end
95
+
96
+ # Ensure root user
97
+ #
98
+ # @return [void]
99
+ #
100
+ def self.ensure_not_root_or_allowed!(argv, uid = Process.uid, is_windows = Gem.win_platform?)
101
+ root_allowed = argv.include?('--allow-root') || !ENV['COCOAPODS_ALLOW_ROOT'].nil?
102
+ help! 'You cannot run CocoaPods as root.' unless root_allowed || uid != 0 || is_windows
103
+ end
104
+
105
+ # Ensure that the master spec repo exists
106
+ #
107
+ # @return [void]
108
+ #
109
+ def ensure_master_spec_repo_exists!
110
+ unless config.sources_manager.master_repo_functional?
111
+ Setup.new(CLAide::ARGV.new([])).run
112
+ end
113
+ end
114
+
115
+ #-------------------------------------------------------------------------#
116
+
117
+ include Config::Mixin
118
+
119
+ private
120
+
121
+ # Returns a new {Gem::Version} based on the systems `git` version.
122
+ #
123
+ # @return [Gem::Version]
124
+ #
125
+ def self.git_version
126
+ raw_version = Executable.capture_command('git', ['--version']).first
127
+ unless match = raw_version.scan(/\d+\.\d+\.\d+/).first
128
+ raise "Failed to extract git version from `git --version` (#{raw_version.inspect})"
129
+ end
130
+ Gem::Version.new(match)
131
+ end
132
+
133
+ # Checks that the git version is at least 1.8.5
134
+ #
135
+ # @raise If the git version is older than 1.8.5
136
+ #
137
+ # @return [void]
138
+ #
139
+ def self.verify_minimum_git_version!
140
+ if git_version < Gem::Version.new('1.8.5')
141
+ raise Informative, 'You need at least git version 1.8.5 to use CocoaPods'
142
+ end
143
+ end
144
+
145
+ # Returns a new {Installer} parametrized from the {Config}.
146
+ #
147
+ # @return [Installer]
148
+ #
149
+ def installer_for_config
150
+ Installer.new(config.sandbox, config.podfile, config.lockfile)
151
+ end
152
+
153
+ # Checks that the podfile exists.
154
+ #
155
+ # @raise If the podfile does not exists.
156
+ #
157
+ # @return [void]
158
+ #
159
+ def verify_podfile_exists!
160
+ unless config.podfile
161
+ raise Informative, "No `Podfile' found in the project directory."
162
+ end
163
+ end
164
+
165
+ # Checks that the lockfile exists.
166
+ #
167
+ # @raise If the lockfile does not exists.
168
+ #
169
+ # @return [void]
170
+ #
171
+ def verify_lockfile_exists!
172
+ unless config.lockfile
173
+ raise Informative, "No `Podfile.lock' found in the project directory, run `pod install'."
174
+ end
175
+ end
176
+
177
+ def self.verify_xcode_license_approved!
178
+ if `/usr/bin/xcrun clang 2>&1` =~ /license/ && !$?.success?
179
+ raise Informative, 'You have not agreed to the Xcode license, which ' \
180
+ 'you must do to use CocoaPods. Agree to the license by running: ' \
181
+ '`xcodebuild -license`.'
182
+ end
183
+ end
184
+ end
185
+ end