cocoapods-dongjia 1.0.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5dfc12406ccf455caff9872718d6232b31dd307edf285deb3db7300c04cd0eb5
4
+ data.tar.gz: b2dc7168c84132d9d2e5672feae570fbdf5fee8e0284609be2155723aed16362
5
+ SHA512:
6
+ metadata.gz: 19aa24af73395918ea42bd312cb0e761e18c9ccf7bf1f73c57557797626bbcfa6b9ace46ae4153ea68dbcee381145bae553c57657e743d1c7631e2c65de94dc9
7
+ data.tar.gz: a208806a65968c9fa265373db9396274dd9b952a3c1893819c997bfcedffcdd24b634f79d8fac30a02d13705025b0e59e8c791aff866c6d5e01117310276717b
@@ -0,0 +1 @@
1
+ require 'cocoapods-dongjia/gem_version'
@@ -0,0 +1 @@
1
+ require 'cocoapods-dongjia/command/dongjia'
@@ -0,0 +1,61 @@
1
+ require 'cocoapods'
2
+
3
+ module Pod
4
+
5
+ class Command
6
+
7
+ class Reinstall < Command
8
+ include RepoUpdate
9
+ include ProjectDirectory
10
+
11
+ self.summary = '删除 Pods 目录再 install'
12
+
13
+ self.description = <<-DESC
14
+ 删除 Pods 目录再 install
15
+ DESC
16
+
17
+ self.arguments = [
18
+ CLAide::Argument.new('XCODE_PROJECT', false),
19
+ ]
20
+
21
+ def initialize(argv)
22
+ path = argv.shift_argument
23
+ @project_path = Pathname.new(path) if path
24
+ super
25
+ end
26
+
27
+ def validate!
28
+ super
29
+
30
+ unless @project_path
31
+ xcodeprojs = Pathname.glob('*.xcodeproj')
32
+ @project_path = xcodeprojs.first if xcodeprojs.size == 1
33
+ end
34
+
35
+ help! 'A valid Xcode project file is required.' unless @project_path
36
+ help! "#{@project_path} does not exist." unless @project_path.exist?
37
+ unless @project_path.directory? && (@project_path + 'project.pbxproj').exist?
38
+ help! "#{@project_path} is not a valid Xcode project."
39
+ end
40
+
41
+ @project = Xcodeproj::Project.open(@project_path)
42
+ end
43
+
44
+ def run
45
+
46
+ deintegrator = Deintegrator.new
47
+ deintegrator.deintegrate_project(@project)
48
+ @project.save
49
+
50
+ verify_podfile_exists!
51
+ installer = installer_for_config
52
+ installer.repo_update = repo_update?(:default => false)
53
+ installer.update = false
54
+ installer.deployment = @deployment
55
+ installer.clean_install = @clean_install
56
+ installer.install!
57
+
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,3 @@
1
+ module CocoapodsDongjia
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,28 @@
1
+ require 'cocoapods-dongjia/command'
2
+ require_relative 'dongjia_source'
3
+ require_relative 'dongjia_inspector'
4
+ require_relative 'dongjia_import_helper'
5
+ require_relative 'dongjia_warning_manager'
6
+
7
+ module Dongjia
8
+
9
+ Pod::HooksManager.register('cocoapods-dongjia', :pre_install) do |ctx, params|
10
+
11
+ podfile = ctx.podfile
12
+
13
+ # 禁用集成完后的反馈
14
+ ENV['COCOAPODS_DISABLE_STATS'] = 'true'
15
+
16
+ # 设置是否使用私有源 [http://code.kaipao.cc/ios-team/DJSpecs]
17
+ DongjiaSource.import(params[:use_private_source], podfile)
18
+
19
+ end
20
+
21
+ Pod::HooksManager.register('cocoapods-dongjia', :post_install) do |ctx|
22
+
23
+ # 关闭一些警告
24
+ DongjiaWarningManager.turn_off_warnings(true, ctx.sandbox_root)
25
+
26
+ end
27
+
28
+ end
@@ -0,0 +1,80 @@
1
+ #
2
+ # 辅助导入第三方或本地的 pod
3
+ #
4
+ module Pod
5
+
6
+ class Podfile
7
+
8
+ $IS_WRAPED = false
9
+ $REMOTE_PATH = nil
10
+ # 导入 gitlab 上的远程 pod
11
+ def import_wrapper(path = 'components')
12
+ $IS_WRAPED = true
13
+ $REMOTE_PATH = path
14
+ yield if block_given?
15
+ $IS_WRAPED = false
16
+ end
17
+
18
+ # 导入本地 Components 目录下的 pod
19
+ $IS_IMPORTING_LOCAL_SPEC = false
20
+ def import_from_local_spec
21
+ $IS_IMPORTING_LOCAL_SPEC = true
22
+ yield if block_given?
23
+ $IS_IMPORTING_LOCAL_SPEC = false
24
+ end
25
+
26
+ # Hook
27
+ alias_method :pod_alias_by_import, :pod
28
+ def pod(name = nil, *requirements)
29
+
30
+ if $IS_WRAPED
31
+
32
+ local_path = nil
33
+ if requirements.include?(:local)
34
+ local_root = ENV['POD_LOCAL_ROOT']
35
+ if !local_root
36
+ UI.warn '环境变量中未发现 POD_LOCAL_ROOT 定义'
37
+ elsif local_root.length
38
+ local_path = File.join(local_root, repo_name(name))
39
+ end
40
+ end
41
+
42
+ if local_path
43
+ requirements = [{:path => local_path}]
44
+ end
45
+
46
+ elsif $IS_IMPORTING_LOCAL_SPEC
47
+
48
+ if requirements.length == 0
49
+ requirements = [{ :path => "Components/#{repo_name(name)}" }]
50
+ end
51
+
52
+ end
53
+
54
+ pod_alias_by_import(name, *requirements)
55
+ end
56
+
57
+ def repo_name(name)
58
+ pos = name.index('/')
59
+ ret = pos == nil ? name : name[0, pos]
60
+ if ret == 'ProtocolBuffers'
61
+ ret = 'protobuf-objc'
62
+ end
63
+ ret
64
+ end
65
+
66
+ end
67
+
68
+ # 针对自己的 pod,关闭安全警告
69
+ class Installer
70
+ class PodSourceInstaller
71
+ alias_method :verify_source_is_secure_alias_by_import, :verify_source_is_secure
72
+ def verify_source_is_secure(root_spec)
73
+ url = root_spec.source[:http]
74
+ if url != nil && !url.start_with?('http://code.kaipao.cc')
75
+ verify_source_is_secure_alias_by_import(root_spec)
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,38 @@
1
+ require 'cocoapods'
2
+
3
+ module Pod
4
+
5
+ class Podfile
6
+
7
+ # 获取当前分支,仅对 dev 和 master 进行校验
8
+ branch = `git symbolic-ref --short -q HEAD`.strip
9
+ if branch == 'dev' or branch == 'master'
10
+
11
+ # Hook pod 方法
12
+ alias_method :original_pod, :pod
13
+
14
+ def pod(name = nil, *requirements, &block)
15
+
16
+ if name.start_with?('DJ') && requirements.count > 0
17
+ req = requirements.first
18
+ if req[:branch] && req[:branch] != 'master'
19
+ UI.warn "检测到 #{name} 指向了分支 #{req[:branch]}\n"
20
+ exit -1
21
+ elsif req[:tag]
22
+ UI.warn "检测到 #{name} 指向了标签 #{req[:tag]}\n"
23
+ exit -1
24
+ elsif req[:commit]
25
+ UI.warn "检测到 #{name} 指向了节点 #{req[:commit]}\n"
26
+ exit -1
27
+ end
28
+ end
29
+
30
+ original_pod(name, *requirements, &block)
31
+ end
32
+
33
+ end
34
+
35
+ end
36
+
37
+ end
38
+
@@ -0,0 +1,27 @@
1
+ require 'cocoapods'
2
+
3
+ module Dongjia
4
+
5
+ class DongjiaSource
6
+
7
+ def self.import(use_private_source, podfile)
8
+
9
+ return if use_private_source == nil
10
+
11
+ if use_private_source
12
+ source_url = 'git@code.kaipao.cc:ios-team/DJSpecs.git'
13
+ unless File.exist?(File.expand_path('~/.cocoapods/repos/djspecs'))
14
+ # 克隆私有源,并命名为 djspecs
15
+ system "pod repo add djspecs #{source_url}"
16
+ else
17
+ system "pod repo update djspecs"
18
+ end
19
+ podfile.source source_url
20
+ end
21
+
22
+ end
23
+
24
+ end
25
+
26
+ end
27
+
@@ -0,0 +1,65 @@
1
+ require 'xcodeproj'
2
+
3
+ module Dongjia
4
+
5
+ class DongjiaWarningManager
6
+
7
+ def self.turn_off_warnings(turn_off, sandbox_root)
8
+
9
+ return if !turn_off
10
+
11
+ Dir.foreach(sandbox_root).select{|f| f.end_with?('xcodeproj')}.each do |name|
12
+
13
+ proj = Xcodeproj::Project.open(File.join(sandbox_root, name))
14
+
15
+ if name != 'Pods.xcodeproj'
16
+ proj.build_configurations.each do | config |
17
+ # 强制设置 deployment 版本为 8.0
18
+ if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < 8.0
19
+ config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = "8.0"
20
+ end
21
+ end
22
+ end
23
+
24
+ # project 的每个 target 配置
25
+ proj.targets.each do | target |
26
+
27
+ next if target.name.start_with?('Pods')
28
+
29
+ target.build_configurations.each do | config |
30
+
31
+ # 禁用非 DJ 开头 Pod 的警告
32
+ config.build_settings['GCC_WARN_INHIBIT_ALL_WARNINGS'] = "YES" unless target.name.start_with?('DJ')
33
+
34
+ # 不检测 block 中的隐式 self 调用
35
+ config.build_settings['CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF'] = "NO"
36
+
37
+ # 不检测已废弃的方法
38
+ config.build_settings['GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS'] = "NO"
39
+
40
+ # 允许 objc_msgSend
41
+ config.build_settings['ENABLE_STRICT_OBJC_MSGSEND'] = "NO"
42
+
43
+ # 不检测注释
44
+ config.build_settings['CLANG_WARN_DOCUMENTATION_COMMENTS'] = "NO"
45
+
46
+ # 不严格的原型校验
47
+ config.build_settings['CLANG_WARN_STRICT_PROTOTYPES'] = "NO"
48
+
49
+ # 强制设置 deployment 版本为 8.0
50
+ if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < 8.0
51
+ config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = "8.0"
52
+ end
53
+ end
54
+
55
+ end
56
+
57
+ proj.save
58
+
59
+ end
60
+
61
+ end
62
+
63
+ end
64
+
65
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-dongjia
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - jiangzhuoyi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-10-18 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: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
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-dongjia.
42
+ email:
43
+ - jiangzhuoyi@idongjia.cn
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - lib/cocoapods-dongjia.rb
49
+ - lib/cocoapods-dongjia/command.rb
50
+ - lib/cocoapods-dongjia/command/dongjia.rb
51
+ - lib/cocoapods-dongjia/gem_version.rb
52
+ - lib/cocoapods_plugin.rb
53
+ - lib/dongjia_import_helper.rb
54
+ - lib/dongjia_inspector.rb
55
+ - lib/dongjia_source.rb
56
+ - lib/dongjia_warning_manager.rb
57
+ homepage: https://github.com/EXAMPLE/cocoapods-dongjia
58
+ licenses:
59
+ - MIT
60
+ metadata: {}
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubygems_version: 3.0.4
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: A longer description of cocoapods-dongjia.
80
+ test_files: []