ios_double_source 0.1.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.
@@ -0,0 +1,101 @@
1
+ # frozen_string_literal: true
2
+ require 'yaml'
3
+ require_relative 'build_item'
4
+ require_relative 'repo_xcode'
5
+ require_relative 'repo_module_source'
6
+ module Build
7
+ class RepoXCodeShell < RepoXCode
8
+ def publish_shell(repo_module_source)
9
+ puts "\n⏩ (#{File.basename(self.path)})发布版本到壳工程中"
10
+ unless repo_module_source.build_item.publish_shell
11
+ puts "本次构建 publish_shell = false 不执行发布到壳工程中"
12
+ return
13
+ end
14
+ current = FileUtils.pwd
15
+ Dir.chdir(self.path)
16
+ discard_pull
17
+ update_shell_yaml(repo_module_source)
18
+ change = git_status
19
+ if change
20
+ git_add_stag
21
+ commit_msg = "#ignore_scan# [Update] #{repo_module_source.pod_name} #{repo_module_source.pod_version_final}"
22
+ git_commit(commit_msg)
23
+ git_push
24
+ end
25
+ Dir.chdir(current)
26
+ text = change ? "【✅ 组件发布到壳工程成功】" : "【✅ 当前组件已在到壳工程中】"
27
+ pusher.push(text)
28
+ end
29
+ private
30
+ def update_shell_yaml(repo_module_source)
31
+ puts "更新yaml文件"
32
+ pod_name = repo_module_source.pod_name
33
+ pod_version = repo_module_source.pod_version_final
34
+ binary = (repo_module_source.build_item.real_device or repo_module_source.build_item.simulator)
35
+ third = repo_module_source.third
36
+ yaml_file = third ? "PodfileThirdParty.yaml" : "PodfileModule.yaml"
37
+ yaml_path = "#{(self.path)}/#{yaml_file}"
38
+ did_update = false
39
+ yaml_content = YAML.load_file(yaml_path)
40
+ yaml_content['PODS'].select { |item|
41
+ if item['pod'] == pod_name
42
+ item["version"] = pod_version
43
+ item["binary"] = binary
44
+ did_update = true
45
+ end
46
+ }
47
+ unless did_update
48
+ item = {}
49
+ item["pod"] = pod_name
50
+ item["version"] = pod_version
51
+ item["binary"] = binary
52
+ yaml_content['PODS'] << item
53
+ end
54
+ yaml_content['PODS'].select { |item|
55
+ item.delete("module")
56
+ if item["git"] == nil
57
+ item.delete("git")
58
+ end
59
+ if item["tag"] == nil
60
+ item.delete("tag")
61
+ end
62
+ if item["branch"] == nil
63
+ item.delete("branch")
64
+ end
65
+ if item["source"] == nil
66
+ item.delete("source")
67
+ end
68
+ item["blank"] = true
69
+ }
70
+ line = third ? "# 第三方维护组件\n" : "# 企业内部组件\n"
71
+ line += "# 1、优先级:path > podspec > version > tag > branch)\n"
72
+ line += "# 2、path字段就是直接从对应的路径读取依赖\n"
73
+ line += "# 3、podspec字段就是直接从对应的路径读取podspec文件加载依赖\n"
74
+ line += "# 4、当version不为空时,会取source字段的repo获取组件,如果source字段为空,那么就取文件顶部配置的默认SOURCE\n"
75
+ line += "# 5、当tag字段或branch字段不为空时,会取git字段的地址获取代码\n"
76
+ line += "\n"
77
+ line += "# 完整示例字段如下\n"
78
+ line += "#- module: YYModel\n"
79
+ line += "# pod: YYModel\n"
80
+ line += "# podspec:\n"
81
+ line += "# version: 1.0.4\n"
82
+ line += "# git:\n"
83
+ line += "# tag:\n"
84
+ line += "# branch:\n"
85
+ line += "# configurations:\n"
86
+ line += "# inhibit_warnings: true\n"
87
+ line += "# source: git@gitlab.xx.com:xx/xx/xxx.git\n"
88
+ line += "# binary: true\n"
89
+ line += "\n"
90
+ line += "# 如果 source = null && binary = false 则source默认使用SOURCE\n"
91
+ line += "# 如果 source = null && binary = true 则source默认使用BINARY_SOURCE\n"
92
+ File.open(yaml_path, 'w') { |file|
93
+ file.write(line)
94
+ file.write(yaml_content.to_yaml)
95
+ }
96
+ content = File.read(yaml_path)
97
+ new_content = content.gsub('blank: true', '')
98
+ File.write(yaml_path, new_content)
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+ require 'fileutils'
3
+ class FileHelper
4
+ def FileHelper.cp_rf_exclude_git(path1, path2)
5
+ Dir.foreach(path2) do |file_name|
6
+ if file_name == "." or file_name == ".." or file_name == ".git"
7
+ next
8
+ end
9
+ sub_path = "#{path2}/#{file_name}"
10
+ FileUtils.rm_rf(sub_path)
11
+ end
12
+ Dir.foreach(path1) do |file_name|
13
+ if file_name == "." or file_name == ".." or file_name == ".git"
14
+ next
15
+ end
16
+ sub_path = "#{path1}/#{file_name}"
17
+ FileUtils.cp_r(sub_path, path2)
18
+ end
19
+ end
20
+ def FileHelper.recursion_find(des_path, find, result_array)
21
+ if not result_array or not result_array.is_a?(Array)
22
+ return
23
+ end
24
+ find_path = "#{des_path}/#{find}"
25
+ if File.exist?(find_path)
26
+ result_array << find_path
27
+ else
28
+ Dir.foreach(des_path) { |file_name|
29
+ sub_path = "#{des_path}/#{file_name}"
30
+ if File.directory?(sub_path) and not file_name.start_with?(".")
31
+ FileHelper.recursion_find(sub_path, find, result_array)
32
+ end
33
+ }
34
+ end
35
+ end
36
+ def FileHelper.recursion_files(des_path, result_array)
37
+ if not result_array or not result_array.is_a?(Array)
38
+ return
39
+ end
40
+ if File.file?(des_path)
41
+ result_array << des_path
42
+ else
43
+ Dir.foreach(des_path) { |file_name|
44
+ sub_path = "#{des_path}/#{file_name}"
45
+ unless file_name.start_with?(".")
46
+ FileHelper.recursion_files(sub_path, result_array)
47
+ end
48
+ }
49
+ end
50
+ end
51
+ def FileHelper.have_implementation_files(path)
52
+ files = Dir[path]
53
+ extends = %w[.m .mm .c .cc .cpp .swift]
54
+ files.each do |file_path_str|
55
+ extend_name = Pathname(file_path_str).extname
56
+ if extends.include?(extend_name)
57
+ return true
58
+ end
59
+ end
60
+ false
61
+ end
62
+ end
@@ -0,0 +1,50 @@
1
+ require 'json'
2
+ require 'net/http'
3
+ require "httparty"
4
+ require 'net/https'
5
+ require 'open-uri'
6
+ require 'digest/md5'
7
+ module Request
8
+ def Request.post(url, params)
9
+ uri = URI(url)
10
+ http = Net::HTTP.new(uri.host, uri.port)
11
+ if uri.scheme == "https"
12
+ http.use_ssl = true
13
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
14
+ end
15
+ header = {'content-type':'application/json'}
16
+ response = http.post(uri, params.to_json, header)
17
+ puts response.body
18
+ response.body
19
+ end
20
+ def Request.get(proxy_ip, proxy_port, url)
21
+ headers = {
22
+ "User-Agent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36",
23
+ "Accept-Encoding" => "gzip"
24
+ }
25
+ options = {
26
+ :headers => headers,
27
+ :http_proxyaddr => proxy_ip,
28
+ :http_proxyport => proxy_port
29
+ }
30
+ begin
31
+ response = HTTParty.get(url, options)
32
+ puts "响应状态码:#{response.code}"
33
+ if response.body.nil? || response.body.empty?
34
+ puts "page content: #{response.body}"
35
+ error = "请求失败,status code: #{response.code.to_s}"
36
+ puts "❌ #{error}"
37
+ Process.exit(-1)
38
+ else
39
+ return response
40
+ end
41
+ rescue => exception
42
+ puts "\n"
43
+ puts caller
44
+ puts "调用堆栈如上\n\n"
45
+ error = "请求失败, 请检查网络或参数是否正确:#{exception}"
46
+ puts "❌ #{error}"
47
+ Process.exit(-1)
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,37 @@
1
+ class String
2
+ def ssh_to_http
3
+ if self.start_with?("git@") and self.end_with?(".git")
4
+ temp = self.gsub(":","/")
5
+ temp = temp.gsub("git@","http://")
6
+ temp.gsub(".git","")
7
+ else
8
+ self
9
+ end
10
+ end
11
+ def http_to_ssh
12
+ if self.start_with?("http://") or self.start_with?("https://")
13
+ temp = self.gsub("https://","git@")
14
+ temp = temp.gsub("http://","git@")
15
+ url = URI(self)
16
+ host = "#{url.host}:"
17
+ temp = temp.gsub(url.host, host)
18
+ temp = temp.gsub(":/", ":")
19
+ unless temp.end_with?(".git")
20
+ temp = "#{temp}.git"
21
+ end
22
+ temp
23
+ else
24
+ self
25
+ end
26
+ end
27
+ def is_gitlab_url
28
+ self.start_with?("git@gitlab") or
29
+ self.start_with?("http://gitlab") or
30
+ self.start_with?("https://gitlab")
31
+ end
32
+ def is_number?
33
+ !!Kernel.Float(self)
34
+ rescue TypeError, ArgumentError
35
+ false
36
+ end
37
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+ require_relative "version"
3
+ module IosDoubleSource
4
+ class Error < StandardError; end
5
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+ module IosDoubleSource
3
+ VERSION = "0.1.0"
4
+ end
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ios_double_source
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - wangshuaipeng
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2025-03-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: gitlab
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 4.19.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 4.19.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 2.6.3
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 2.6.3
41
+ - !ruby/object:Gem::Dependency
42
+ name: git
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.19.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.19.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: cocoapods
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 1.15.2
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 1.15.2
69
+ - !ruby/object:Gem::Dependency
70
+ name: podfileDep
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 2.7.7
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 2.7.7
83
+ description: iOS双私有源组件打包核心功能
84
+ email:
85
+ - wangshuaipeng@163.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - LICENSE.txt
91
+ - README.md
92
+ - bin/console
93
+ - bin/setup
94
+ - lib_blur/core/auto_build.rb
95
+ - lib_blur/core/build_item.rb
96
+ - lib_blur/core/commit.rb
97
+ - lib_blur/core/config.rb
98
+ - lib_blur/core/cost.rb
99
+ - lib_blur/core/git_helper.rb
100
+ - lib_blur/core/github_fork.rb
101
+ - lib_blur/core/github_helper.rb
102
+ - lib_blur/core/gitlab_helper.rb
103
+ - lib_blur/core/hook_manager.rb
104
+ - lib_blur/core/podspec.rb
105
+ - lib_blur/core/push.rb
106
+ - lib_blur/core/repo.rb
107
+ - lib_blur/core/repo_cocoapods.rb
108
+ - lib_blur/core/repo_module.rb
109
+ - lib_blur/core/repo_module_binary.rb
110
+ - lib_blur/core/repo_module_source.rb
111
+ - lib_blur/core/repo_xcode.rb
112
+ - lib_blur/core/repo_xcode_package.rb
113
+ - lib_blur/core/repo_xcode_shell.rb
114
+ - lib_blur/core/util/file_helper.rb
115
+ - lib_blur/core/util/request.rb
116
+ - lib_blur/core/util/string.rb
117
+ - lib_blur/ios_double_source.rb
118
+ - lib_blur/version.rb
119
+ homepage: https://gitee.com/sourceiOS/ios_double_source
120
+ licenses:
121
+ - MIT
122
+ metadata:
123
+ homepage_uri: https://gitee.com/sourceiOS/ios_double_source
124
+ source_code_uri: https://gitee.com/sourceiOS/ios_double_source
125
+ changelog_uri: https://gitee.com/sourceiOS/ios_double_source
126
+ post_install_message:
127
+ rdoc_options: []
128
+ require_paths:
129
+ - lib_blur
130
+ required_ruby_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: 2.6.0
135
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ requirements: []
141
+ rubygems_version: 3.4.1
142
+ signing_key:
143
+ specification_version: 4
144
+ summary: iOS双私有源组件打包
145
+ test_files: []