pindo 4.6.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/pindo +35 -0
- data/lib/pindo/base/aeshelper.rb +31 -0
- data/lib/pindo/base/deviceinfo.rb +90 -0
- data/lib/pindo/base/executable.rb +224 -0
- data/lib/pindo/base/githelper.rb +489 -0
- data/lib/pindo/base/hashhelper.rb +134 -0
- data/lib/pindo/base/plaininformative.rb +15 -0
- data/lib/pindo/base/plistbuddyexecutable.rb +121 -0
- data/lib/pindo/base/standarderror.rb +14 -0
- data/lib/pindo/client/applovinclient.rb +156 -0
- data/lib/pindo/client/aws3sclient.rb +183 -0
- data/lib/pindo/client/bossclient.rb +229 -0
- data/lib/pindo/client/bossconfigclient.rb +175 -0
- data/lib/pindo/client/giteeclient.rb +65 -0
- data/lib/pindo/client/httpclient.rb +40 -0
- data/lib/pindo/client/pgyerclient.rb +439 -0
- data/lib/pindo/client/tgateclient.rb +103 -0
- data/lib/pindo/command.rb +101 -0
- data/lib/pindo/config/pindoconfig.rb +439 -0
- data/lib/pindo/config/pindouserlocalconfig.rb +81 -0
- data/lib/pindo/deploy/Fastfile +233 -0
- data/lib/pindo/deploy/build.rb +167 -0
- data/lib/pindo/deploy/bundleid.rb +245 -0
- data/lib/pindo/deploy/cert.rb +508 -0
- data/lib/pindo/deploy/check.rb +79 -0
- data/lib/pindo/deploy/configproj.rb +89 -0
- data/lib/pindo/deploy/confusecode.rb +248 -0
- data/lib/pindo/deploy/confuseproj.rb +112 -0
- data/lib/pindo/deploy/fabric.rb +58 -0
- data/lib/pindo/deploy/getitcinfo.rb +248 -0
- data/lib/pindo/deploy/iap.rb +796 -0
- data/lib/pindo/deploy/initconfig.rb +128 -0
- data/lib/pindo/deploy/itcapp.rb +147 -0
- data/lib/pindo/deploy/itcinfo.rb +369 -0
- data/lib/pindo/deploy/pem.rb +55 -0
- data/lib/pindo/deploy/pullconfig.rb +46 -0
- data/lib/pindo/deploy/pushconfig.rb +83 -0
- data/lib/pindo/deploy/quswark.rb +146 -0
- data/lib/pindo/deploy/quswauth.rb +67 -0
- data/lib/pindo/deploy/reportbug.rb +135 -0
- data/lib/pindo/deploy/resign.rb +338 -0
- data/lib/pindo/deploy/tag.rb +108 -0
- data/lib/pindo/deploy/updateconfig.rb +129 -0
- data/lib/pindo/deploy/uploadipa.rb +63 -0
- data/lib/pindo/deploy.rb +44 -0
- data/lib/pindo/dev/autobuild.rb +204 -0
- data/lib/pindo/dev/autoresign.rb +186 -0
- data/lib/pindo/dev/confusecode.rb +127 -0
- data/lib/pindo/dev/confuseproj.rb +111 -0
- data/lib/pindo/dev/createbuild.rb +159 -0
- data/lib/pindo/dev/debug.rb +141 -0
- data/lib/pindo/dev/pub.rb +171 -0
- data/lib/pindo/dev/renewcert.rb +142 -0
- data/lib/pindo/dev.rb +23 -0
- data/lib/pindo/env/dreamstudio.rb +53 -0
- data/lib/pindo/env/flutter.rb +59 -0
- data/lib/pindo/env/flutter.sh +116 -0
- data/lib/pindo/env/quarkenv.rb +58 -0
- data/lib/pindo/env/swarkenv.rb +62 -0
- data/lib/pindo/env/workhard.rb +56 -0
- data/lib/pindo/env.rb +17 -0
- data/lib/pindo/ipa/autoresign.rb +188 -0
- data/lib/pindo/ipa/import.rb +261 -0
- data/lib/pindo/ipa/output.rb +396 -0
- data/lib/pindo/ipa.rb +22 -0
- data/lib/pindo/lib/forcepush.rb +159 -0
- data/lib/pindo/lib/lint.rb +115 -0
- data/lib/pindo/lib/push.rb +143 -0
- data/lib/pindo/lib/update.rb +75 -0
- data/lib/pindo/lib.rb +18 -0
- data/lib/pindo/module/appselect.rb +200 -0
- data/lib/pindo/module/appstore_in_app_purchase.rb +1803 -0
- data/lib/pindo/module/appstore_metadata_connect_api_helper.rb +12 -0
- data/lib/pindo/module/appstore_metadata_fastlane_helper.rb +922 -0
- data/lib/pindo/module/buildconfighelper.rb +13 -0
- data/lib/pindo/module/buildhelper.rb +76 -0
- data/lib/pindo/module/commonconfuseproj.rb +271 -0
- data/lib/pindo/module/config_project.sh +143 -0
- data/lib/pindo/module/configprojhelper.rb +631 -0
- data/lib/pindo/module/iap_tier.json +813 -0
- data/lib/pindo/module/icon_contents.json +116 -0
- data/lib/pindo/module/imessage_icon.json +91 -0
- data/lib/pindo/module/imgset_contents.json +21 -0
- data/lib/pindo/module/launchimg_contents.json +21 -0
- data/lib/pindo/module/pemcreate.rb +63 -0
- data/lib/pindo/module/pgyerhelper.rb +339 -0
- data/lib/pindo/module/xcodebuildpre.rb +258 -0
- data/lib/pindo/module/xcodehelper.rb +521 -0
- data/lib/pindo/options/appconfigoptions.rb +23 -0
- data/lib/pindo/options/deployoptions.rb +363 -0
- data/lib/pindo/pgyer/apptest.rb +104 -0
- data/lib/pindo/pgyer/comment.rb +95 -0
- data/lib/pindo/pgyer/download.rb +105 -0
- data/lib/pindo/pgyer/login.rb +61 -0
- data/lib/pindo/pgyer/upload.rb +234 -0
- data/lib/pindo/pgyer.rb +17 -0
- data/lib/pindo/repo/clone.rb +78 -0
- data/lib/pindo/repo/create.rb +55 -0
- data/lib/pindo/repo/login.rb +64 -0
- data/lib/pindo/repo/search.rb +60 -0
- data/lib/pindo/repo.rb +16 -0
- data/lib/pindo/setup.rb +60 -0
- data/lib/pindo/upgrade.rb +56 -0
- data/lib/pindo/utils/applovin.rb +213 -0
- data/lib/pindo/utils/boss.rb +209 -0
- data/lib/pindo/utils/clearcert.rb +60 -0
- data/lib/pindo/utils/device.rb +279 -0
- data/lib/pindo/utils/icon.rb +91 -0
- data/lib/pindo/utils/icon.sh +133 -0
- data/lib/pindo/utils/podindex.rb +56 -0
- data/lib/pindo/utils/podindex.sh +30 -0
- data/lib/pindo/utils/renewproj.rb +146 -0
- data/lib/pindo/utils/tgate.rb +159 -0
- data/lib/pindo/utils/xcassets.rb +46 -0
- data/lib/pindo/utils/xcassets.sh +88 -0
- data/lib/pindo/utils.rb +29 -0
- data/lib/pindo/version.rb +110 -0
- data/lib/pindo.rb +34 -0
- metadata +364 -0
@@ -0,0 +1,121 @@
|
|
1
|
+
module Pindo
|
2
|
+
|
3
|
+
module Plistbuddyexecutable
|
4
|
+
|
5
|
+
def plistbuddyexecutable(name)
|
6
|
+
define_method(name) do |*command|
|
7
|
+
Plistbuddyexecutable.plistbuddy_execute_command(name, Array(command).flatten, false)
|
8
|
+
end
|
9
|
+
|
10
|
+
define_method(name.to_s + '!') do |*command|
|
11
|
+
Plistbuddyexecutable.plistbuddy_execute_command(name, Array(command).flatten, true)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
def self.plistbuddy_execute_command(executable, command, raise_on_failure = true)
|
17
|
+
bin = '/usr/libexec/PlistBuddy'
|
18
|
+
|
19
|
+
command = command.map(&:to_s)
|
20
|
+
full_command = "#{bin} #{command.join(' ')}"
|
21
|
+
|
22
|
+
|
23
|
+
puts "$ #{full_command}"
|
24
|
+
stdout = Plistbuddyindenter.new(STDOUT)
|
25
|
+
stderr = Plistbuddyindenter.new(STDERR)
|
26
|
+
|
27
|
+
|
28
|
+
status = plistbuddy_popen3(bin, command, stdout, stderr)
|
29
|
+
stdout = stdout.join
|
30
|
+
stderr = stderr.join
|
31
|
+
output = stdout + stderr
|
32
|
+
unless status.success?
|
33
|
+
if raise_on_failure
|
34
|
+
raise Informative, "#{full_command}\n\n#{output}"
|
35
|
+
else
|
36
|
+
puts "[!] Failed: #{full_command}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
output
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def self.plistbuddy_popen3(bin, command, stdout, stderr)
|
46
|
+
puts "plistbuddy_popen3 ++++1"
|
47
|
+
puts bin
|
48
|
+
require 'open3'
|
49
|
+
Open3.popen3(bin, *command) do |i, o, e, t|
|
50
|
+
plistbuddy_reader(o, stdout)
|
51
|
+
plistbuddy_reader(e, stderr)
|
52
|
+
i.close
|
53
|
+
|
54
|
+
status = t.value
|
55
|
+
|
56
|
+
o.flush
|
57
|
+
e.flush
|
58
|
+
sleep(0.01)
|
59
|
+
|
60
|
+
status
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.plistbuddy_reader(input, output)
|
65
|
+
Thread.new do
|
66
|
+
buf = ''
|
67
|
+
begin
|
68
|
+
loop do
|
69
|
+
buf << input.readpartial(4096)
|
70
|
+
loop do
|
71
|
+
string, separator, buf = buf.partition(/[\r\n]/)
|
72
|
+
if separator.empty?
|
73
|
+
buf = string
|
74
|
+
break
|
75
|
+
end
|
76
|
+
output << (string << separator)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
rescue EOFError
|
80
|
+
output << (buf << $/) unless buf.empty?
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
#-------------------------------------------------------------------------#
|
86
|
+
|
87
|
+
# Helper class that allows to write to an {IO} instance taking into account
|
88
|
+
# the UI indentation level.
|
89
|
+
#
|
90
|
+
class Plistbuddyindenter < ::Array
|
91
|
+
# @return [Fixnum] The indentation level of the UI.
|
92
|
+
#
|
93
|
+
attr_reader :indent
|
94
|
+
|
95
|
+
# @return [IO] the {IO} to which the output should be printed.
|
96
|
+
#
|
97
|
+
attr_reader :io
|
98
|
+
|
99
|
+
# Init a new Indenter
|
100
|
+
#
|
101
|
+
# @param [IO] io @see io
|
102
|
+
#
|
103
|
+
def initialize(io = nil)
|
104
|
+
@io = io
|
105
|
+
@indent = ' '
|
106
|
+
end
|
107
|
+
|
108
|
+
# Stores a portion of the output and prints it to the {IO} instance.
|
109
|
+
#
|
110
|
+
# @param [String] value
|
111
|
+
# the output to print.
|
112
|
+
#
|
113
|
+
# @return [void]
|
114
|
+
#
|
115
|
+
def <<(value)
|
116
|
+
super
|
117
|
+
io << "#{indent}#{value}" if io
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,156 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'faraday'
|
3
|
+
|
4
|
+
module Pindo
|
5
|
+
|
6
|
+
class ApplovinClient
|
7
|
+
|
8
|
+
attr_accessor :applovin_management_key
|
9
|
+
attr_accessor :applovin_base_url
|
10
|
+
attr_accessor :request_config
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
def self.ad_unit_type()
|
17
|
+
ad_format_array = [
|
18
|
+
"INTER",
|
19
|
+
"BANNER",
|
20
|
+
"REWARD",
|
21
|
+
"MREC",
|
22
|
+
"NATIVE",
|
23
|
+
"APPOPEN"
|
24
|
+
]
|
25
|
+
return ad_format_array
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.ad_unit_template_size()
|
29
|
+
ad_format_array = [
|
30
|
+
"small_template_1",
|
31
|
+
"medium_template_1",
|
32
|
+
"custom_template_1"
|
33
|
+
]
|
34
|
+
return ad_format_array
|
35
|
+
end
|
36
|
+
|
37
|
+
def initialize()
|
38
|
+
|
39
|
+
# begin
|
40
|
+
|
41
|
+
config_file = File.join(File::expand_path(Pindoconfig.instance.pindo_common_configdir), "applovin_client_config.json")
|
42
|
+
config_json = JSON.parse(File.read(config_file))
|
43
|
+
|
44
|
+
@applovin_management_key = config_json["applovin_management_key"]
|
45
|
+
@applovin_base_url = config_json["applovin_base_url"]
|
46
|
+
@requests_config = config_json["applovin_req_config"]
|
47
|
+
|
48
|
+
|
49
|
+
# rescue => error
|
50
|
+
# puts error
|
51
|
+
# raise Informative, "加载applovi配置文件失败, 需要执行 pindo setup 或者pindo env dreamstudio"
|
52
|
+
# end
|
53
|
+
end
|
54
|
+
|
55
|
+
def get_ad_unit_info(ad_unit_id:nil)
|
56
|
+
req_path = @requests_config["get_ad_unit_info"]["path"]
|
57
|
+
req_url = @applovin_base_url + req_path
|
58
|
+
|
59
|
+
|
60
|
+
req_url = req_url + "/" + ad_unit_id.to_s
|
61
|
+
|
62
|
+
|
63
|
+
params = {
|
64
|
+
fields:"ad_network_settings,disabled_ad_network_settings,frequency_capping_settings,bid_floors,banner_refresh_settings,segments"
|
65
|
+
}
|
66
|
+
|
67
|
+
puts "req_url: #{req_url}"
|
68
|
+
|
69
|
+
con = Faraday.new
|
70
|
+
res = con.get do |req|
|
71
|
+
req.url req_url
|
72
|
+
req.headers['Content-Type'] = 'application/json'
|
73
|
+
req.headers['Api-Key'] = @applovin_management_key
|
74
|
+
req.params = params
|
75
|
+
end
|
76
|
+
|
77
|
+
result_data = nil
|
78
|
+
puts res.body
|
79
|
+
puts res.status
|
80
|
+
if !res.body.nil?
|
81
|
+
result_data = JSON.parse(res.body)
|
82
|
+
end
|
83
|
+
puts JSON.pretty_generate(result_data)
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
def get_all_ad_unit_info(limit:50, offset:0)
|
89
|
+
req_path = @requests_config["get_all_ad_unit_info"]["path"]
|
90
|
+
req_url = @applovin_base_url + req_path
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
puts "req_url: #{req_url}"
|
95
|
+
|
96
|
+
params = {
|
97
|
+
limit:limit,
|
98
|
+
offset:offset
|
99
|
+
}
|
100
|
+
|
101
|
+
con = Faraday.new
|
102
|
+
res = con.get do |req|
|
103
|
+
req.url req_url
|
104
|
+
req.headers['Content-Type'] = 'application/json'
|
105
|
+
req.headers['Api-Key'] = @applovin_management_key
|
106
|
+
req.params = params
|
107
|
+
end
|
108
|
+
|
109
|
+
result_data = nil
|
110
|
+
puts res.body
|
111
|
+
puts res.status
|
112
|
+
if !res.body.nil?
|
113
|
+
result_data = JSON.parse(res.body)
|
114
|
+
|
115
|
+
end
|
116
|
+
puts JSON.pretty_generate(result_data)
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
|
121
|
+
def create_ad_unit(ad_unit_name:nil, platform:nil, package_name:nil, ad_format:nil, template_size:nil)
|
122
|
+
|
123
|
+
req_path = @requests_config["create_ad_unit"]["path"]
|
124
|
+
req_url = @applovin_base_url + req_path
|
125
|
+
|
126
|
+
body_params = {
|
127
|
+
name:ad_unit_name,
|
128
|
+
platform:platform,
|
129
|
+
package_name:package_name,
|
130
|
+
ad_format:ad_format,
|
131
|
+
template_size:template_size
|
132
|
+
}
|
133
|
+
|
134
|
+
con = Faraday.new
|
135
|
+
res = con.post do |req|
|
136
|
+
req.url req_url
|
137
|
+
req.headers['Content-Type'] = 'application/json'
|
138
|
+
req.headers['Api-Key'] = @applovin_management_key
|
139
|
+
req.body = body_params.to_json
|
140
|
+
end
|
141
|
+
result_data = nil
|
142
|
+
puts res.body
|
143
|
+
puts res.status
|
144
|
+
if !res.body.nil?
|
145
|
+
result_data = JSON.parse(res.body)
|
146
|
+
end
|
147
|
+
puts JSON.pretty_generate(result_data)
|
148
|
+
|
149
|
+
return result_data
|
150
|
+
|
151
|
+
end
|
152
|
+
|
153
|
+
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
@@ -0,0 +1,183 @@
|
|
1
|
+
|
2
|
+
require 'uri'
|
3
|
+
require 'json'
|
4
|
+
require 'faraday'
|
5
|
+
require 'pindo/base/aeshelper'
|
6
|
+
require "aws-sdk-s3"
|
7
|
+
require 'securerandom'
|
8
|
+
|
9
|
+
module Pindo
|
10
|
+
|
11
|
+
|
12
|
+
class AWSS3Client
|
13
|
+
|
14
|
+
|
15
|
+
attr_accessor :region
|
16
|
+
attr_accessor :bucket_name
|
17
|
+
|
18
|
+
attr_accessor :access_key_id
|
19
|
+
attr_accessor :access_key_secret
|
20
|
+
|
21
|
+
attr_accessor :default_url
|
22
|
+
attr_accessor :attach_url
|
23
|
+
|
24
|
+
attr_accessor :asw_s3_object
|
25
|
+
|
26
|
+
|
27
|
+
def initialize()
|
28
|
+
|
29
|
+
|
30
|
+
begin
|
31
|
+
|
32
|
+
config_file = File.join(File::expand_path(Pindoconfig.instance.pindo_common_configdir), "pgyer_client_config.json")
|
33
|
+
config_json = JSON.parse(File.read(config_file))
|
34
|
+
|
35
|
+
@region = config_json["region"]
|
36
|
+
@bucket_name = config_json["bucket_name"]
|
37
|
+
@access_key_id = config_json["access_key_id"]
|
38
|
+
@access_key_secret = config_json["access_key_secret"]
|
39
|
+
@default_url = config_json["default_url"]
|
40
|
+
@attach_url = config_json["attach_url"]
|
41
|
+
|
42
|
+
rescue => error
|
43
|
+
raise Informative, "加载pgyer配置文件失败, 需要执行 pindo setup 或者pindo env dreamstudio"
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
http_proxy = ENV['http_proxy'] || ENV['https_proxy']
|
48
|
+
|
49
|
+
if http_proxy
|
50
|
+
puts "正在使用代理 : #{http_proxy}"
|
51
|
+
Aws.config.update(
|
52
|
+
http_proxy: http_proxy,
|
53
|
+
credentials: Aws::Credentials.new(@access_key_id, @access_key_secret),
|
54
|
+
region: @region
|
55
|
+
)
|
56
|
+
else
|
57
|
+
Aws.config.update(
|
58
|
+
credentials: Aws::Credentials.new(@access_key_id, @access_key_secret),
|
59
|
+
region: @region
|
60
|
+
)
|
61
|
+
end
|
62
|
+
|
63
|
+
@s3_client ||= Aws::S3::Client.new(
|
64
|
+
{
|
65
|
+
http_proxy: http_proxy,
|
66
|
+
region: @region,
|
67
|
+
credentials: Aws::Credentials.new(@access_key_id, @access_key_secret)
|
68
|
+
}.compact.compact
|
69
|
+
)
|
70
|
+
|
71
|
+
|
72
|
+
# S3Client = Aws::S3::Client.new(
|
73
|
+
# access_key_id: 'ACCESS_KEY_ID',
|
74
|
+
# secret_access_key: 'SECRET_ACCESS_KEY',
|
75
|
+
# region: 'REGION'
|
76
|
+
# )
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
def find_bucket!( )
|
81
|
+
bucket = Aws::S3::Bucket.new(@bucket_name, client: @s3_client)
|
82
|
+
raise "Bucket '#{bucket_name}' not found" unless bucket.exists?
|
83
|
+
|
84
|
+
return bucket
|
85
|
+
end
|
86
|
+
|
87
|
+
def delete_file(file_name)
|
88
|
+
bucket = find_bucket!()
|
89
|
+
file = bucket.object(file_name)
|
90
|
+
file.delete
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
def upload_file(binary_file:nil, isAttach:false)
|
95
|
+
|
96
|
+
extension = File.extname(binary_file)
|
97
|
+
filename = File.basename(binary_file)
|
98
|
+
filesize = File.size(binary_file)
|
99
|
+
size_level = 1024 * 1024
|
100
|
+
bytes = File.binread(binary_file)
|
101
|
+
checksum = Digest::MD5.hexdigest(bytes)
|
102
|
+
file_uuid = SecureRandom.uuid
|
103
|
+
total_m = sprintf("%.2f", 1.00 * filesize / 1024 /1024 )
|
104
|
+
|
105
|
+
|
106
|
+
puts "文件路径: #{binary_file}"
|
107
|
+
puts "文件大小: #{total_m}M"
|
108
|
+
upload_path = @default_url
|
109
|
+
content_disposition = nil
|
110
|
+
if isAttach
|
111
|
+
upload_path = @default_url + @attach_url
|
112
|
+
content_disposition = "attachment; filename=#{filename}"
|
113
|
+
end
|
114
|
+
|
115
|
+
object_key = upload_path + file_uuid + extension
|
116
|
+
|
117
|
+
puts "上传路径: #{object_key}"
|
118
|
+
|
119
|
+
upload_result = nil
|
120
|
+
begin
|
121
|
+
|
122
|
+
|
123
|
+
obj = Aws::S3::Object.new(@bucket_name, object_key)
|
124
|
+
|
125
|
+
progress = Proc.new do |bytes, totals|
|
126
|
+
set_progress(bytes.sum, totals.sum)
|
127
|
+
end
|
128
|
+
|
129
|
+
|
130
|
+
if isAttach
|
131
|
+
puts
|
132
|
+
puts "正在上传附件..."
|
133
|
+
obj.upload_file(binary_file, progress_callback: progress, content_disposition:content_disposition)
|
134
|
+
else
|
135
|
+
puts
|
136
|
+
puts "正在上传安装包..."
|
137
|
+
obj.upload_file(binary_file, progress_callback: progress)
|
138
|
+
end
|
139
|
+
|
140
|
+
upload_result = object_key
|
141
|
+
|
142
|
+
# bucket = find_bucket!()
|
143
|
+
# details = {
|
144
|
+
# # acl: 'private'
|
145
|
+
# key: object_key,
|
146
|
+
# body: bytes
|
147
|
+
# }
|
148
|
+
# obj = bucket.put_object(details)
|
149
|
+
# # When you enable versioning on a S3 bucket,
|
150
|
+
# # writing to an object will create an object version
|
151
|
+
# # instead of replacing the existing object.
|
152
|
+
# # http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/S3/ObjectVersion.html
|
153
|
+
# if obj.kind_of?(Aws::S3::ObjectVersion)
|
154
|
+
# obj = obj.object
|
155
|
+
# end
|
156
|
+
|
157
|
+
# # Return public url
|
158
|
+
# puts obj.public_url.to_s
|
159
|
+
# upload_result = object_key
|
160
|
+
rescue => ex
|
161
|
+
puts ex.to_s
|
162
|
+
puts "Upload S3 failed !!!"
|
163
|
+
end
|
164
|
+
|
165
|
+
return upload_result
|
166
|
+
end
|
167
|
+
|
168
|
+
|
169
|
+
def set_progress(index_num, total_num, char = '=')
|
170
|
+
progress_str = sprintf("%.2f", 100.0 * index_num / total_num )
|
171
|
+
total_size = sprintf("%.2f", 1.00 * total_num / 1024 /1024 )
|
172
|
+
index = 100.0 * index_num / total_num
|
173
|
+
|
174
|
+
$stdout.print " 已上传: #{progress_str} \% ", (char * (index/1).floor).ljust(100, ' '), " Total: #{total_size} M \r"
|
175
|
+
$stdout.flush
|
176
|
+
# print " 已上传: #{progress_str} \% ", (char * (index/1).floor).ljust(100, ' '), " Total: #{total_size} M \r"
|
177
|
+
# $stdout.flush
|
178
|
+
end
|
179
|
+
|
180
|
+
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
@@ -0,0 +1,229 @@
|
|
1
|
+
|
2
|
+
require 'uri'
|
3
|
+
require 'json'
|
4
|
+
require 'faraday'
|
5
|
+
require 'pindo/base/aeshelper'
|
6
|
+
require 'pindo/base/deviceinfo'
|
7
|
+
|
8
|
+
|
9
|
+
module Pindo
|
10
|
+
|
11
|
+
|
12
|
+
class BossClient
|
13
|
+
|
14
|
+
attr_accessor :device_info_config
|
15
|
+
attr_accessor :base_url_config
|
16
|
+
attr_accessor :boss_default_platform
|
17
|
+
attr_accessor :salts_config
|
18
|
+
attr_accessor :requests_config
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
attr_accessor :app_type
|
23
|
+
attr_accessor :is_dev
|
24
|
+
attr_accessor :base_url
|
25
|
+
|
26
|
+
|
27
|
+
def initialize(app_type:"FancyApp", is_dev:true, base_url:nil)
|
28
|
+
|
29
|
+
#
|
30
|
+
@app_type = app_type
|
31
|
+
@is_dev = is_dev
|
32
|
+
|
33
|
+
begin
|
34
|
+
|
35
|
+
boss_config_file = File.join(File::expand_path(Pindoconfig.instance.pindo_common_configdir), "boss_client_config.json")
|
36
|
+
@boss_config_json = JSON.parse(File.read(boss_config_file))
|
37
|
+
|
38
|
+
@device_info_config = @boss_config_json["default_device_info"]
|
39
|
+
@base_url_config = @boss_config_json["base_url_config"]
|
40
|
+
@salts_config = @boss_config_json["salts"]
|
41
|
+
@requests_config = @boss_config_json["boss_req_config"]
|
42
|
+
|
43
|
+
rescue => error
|
44
|
+
raise Informative, "加载boss 配置文件失败, 需要执行 pindo setup 或者pindo env dreamstudio"
|
45
|
+
end
|
46
|
+
|
47
|
+
app_type_base_url_config = @base_url_config[@app_type]
|
48
|
+
|
49
|
+
@base_url = nil
|
50
|
+
|
51
|
+
if base_url.nil?
|
52
|
+
if @is_dev
|
53
|
+
@base_url = app_type_base_url_config["dev"]
|
54
|
+
else
|
55
|
+
@base_url = app_type_base_url_config["prod"]
|
56
|
+
end
|
57
|
+
else
|
58
|
+
@base_url = base_url
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.is_in_review_status_with_confirm_key(confirm_key:nil)
|
66
|
+
|
67
|
+
if confirm_key.nil?
|
68
|
+
raise Informative, "confirm_key 是空,判断in review 状态失败!"
|
69
|
+
end
|
70
|
+
is_in_review_status = false
|
71
|
+
|
72
|
+
confirm_array = confirm_key.bytes || []
|
73
|
+
confirm_value = 0
|
74
|
+
confirm_array.each do |char_value|
|
75
|
+
confirm_value += char_value
|
76
|
+
end
|
77
|
+
|
78
|
+
if confirm_value % 2 == 0
|
79
|
+
is_in_review_status = false
|
80
|
+
else
|
81
|
+
is_in_review_status = true
|
82
|
+
end
|
83
|
+
|
84
|
+
return is_in_review_status
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
def get_default_device_info( )
|
90
|
+
|
91
|
+
device_info = DeviceInfo.new
|
92
|
+
device_info.reset_with_config(device_config:@device_info_config)
|
93
|
+
|
94
|
+
return device_info
|
95
|
+
end
|
96
|
+
|
97
|
+
def get_default_apps_flyer_info( )
|
98
|
+
|
99
|
+
apps_flyer_info = {
|
100
|
+
conversion_info:{
|
101
|
+
is_first_launch:true,
|
102
|
+
af_status:"Organic",
|
103
|
+
af_message:"organic install",
|
104
|
+
install_time:"nil"
|
105
|
+
},
|
106
|
+
apps_flyer_uid:nil
|
107
|
+
}
|
108
|
+
|
109
|
+
|
110
|
+
apps_flyer_info[:apps_flyer_uid] = @boss_config_json["apps_flyer_uid"] || "1686395365581-9548642"
|
111
|
+
time_install = Time.now - 5 * 60
|
112
|
+
time_install_str = time_install.strftime("%Y-%m-%d %H:%M:%S")
|
113
|
+
apps_flyer_info[:conversion_info][:install_time] = time_install_str
|
114
|
+
return apps_flyer_info
|
115
|
+
end
|
116
|
+
|
117
|
+
# app_info_dict = {
|
118
|
+
# login_device_id: "294D0303-6692-47F2-8EF2-DF6A1847D1CD",
|
119
|
+
# app_version:"3.2023.07",
|
120
|
+
# bundle_id:"com.heroneverdie101.fancyapptest",
|
121
|
+
# api_version:"1.0",
|
122
|
+
# platform:"iOS_Funny_Release",
|
123
|
+
# apps_flyer_info:{
|
124
|
+
# conversion_info:{
|
125
|
+
# is_first_launch:true,
|
126
|
+
# af_status:"Organic",
|
127
|
+
# af_message:"organic install",
|
128
|
+
# install_time:"2023-06-12 08:54:52"
|
129
|
+
# },
|
130
|
+
# apps_flyer_uid: "1686395365581-9548642"
|
131
|
+
# },
|
132
|
+
# device_info:@device_info
|
133
|
+
# }
|
134
|
+
|
135
|
+
def refresh_setting(app_info_dict:nil)
|
136
|
+
# puts app_info_dict
|
137
|
+
|
138
|
+
qerry_dict = {
|
139
|
+
app_info:[
|
140
|
+
app_info_dict.to_json
|
141
|
+
]
|
142
|
+
}
|
143
|
+
|
144
|
+
data_dict = {
|
145
|
+
path: "",
|
146
|
+
query:"",
|
147
|
+
method:"GET",
|
148
|
+
response_key:"result",
|
149
|
+
response_data:{
|
150
|
+
status:"success"
|
151
|
+
}
|
152
|
+
}
|
153
|
+
|
154
|
+
req_config_item = @requests_config.find { |item| item["name"].eql?("get_settings_refresh")}
|
155
|
+
data_dict[:path] = req_config_item["path"]
|
156
|
+
data_dict[:query] = URI.encode_www_form(qerry_dict)
|
157
|
+
|
158
|
+
encrypt_string = req_data_aes_encrypt(data_dict:data_dict)
|
159
|
+
|
160
|
+
setting_params = {
|
161
|
+
app_version: app_info_dict[:app_version],
|
162
|
+
content: encrypt_string
|
163
|
+
}
|
164
|
+
|
165
|
+
data_json = do_request(boss_url:@base_url, params:setting_params)
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
# puts JSON.pretty_generate(data_json)
|
170
|
+
return data_json
|
171
|
+
|
172
|
+
end
|
173
|
+
|
174
|
+
def do_request(boss_url:nil, params:nil)
|
175
|
+
|
176
|
+
# puts JSON.pretty_generate(params)
|
177
|
+
|
178
|
+
con = Faraday.new
|
179
|
+
res = con.get do |req|
|
180
|
+
req.url boss_url
|
181
|
+
req.headers['Content-Type'] = 'application/json'
|
182
|
+
req.params = params
|
183
|
+
end
|
184
|
+
|
185
|
+
|
186
|
+
res_json = JSON.parse(res.body)
|
187
|
+
data_json = nil
|
188
|
+
if !res_json.nil? && !res_json["result"].nil?
|
189
|
+
data_json = req_data_aes_decrypt(encrypt_string:res_json["result"])
|
190
|
+
end
|
191
|
+
|
192
|
+
return data_json
|
193
|
+
|
194
|
+
end
|
195
|
+
|
196
|
+
|
197
|
+
def req_data_aes_encrypt(data_dict:nil)
|
198
|
+
|
199
|
+
aes_origin_data = data_dict.to_json
|
200
|
+
req_aes_key_nane = @salts_config.keys.sample
|
201
|
+
req_aes_key_value = @salts_config[req_aes_key_nane]
|
202
|
+
content = AESHelper::aes_128_ecb_encrypt(req_aes_key_value, aes_origin_data)
|
203
|
+
|
204
|
+
front_rand_str = (0...16).map{65.+(rand(26)).chr}.join
|
205
|
+
back_rand_str = (0...15).map{65.+(rand(26)).chr}.join
|
206
|
+
|
207
|
+
encrypt_string = front_rand_str + content + req_aes_key_nane + back_rand_str
|
208
|
+
return encrypt_string
|
209
|
+
end
|
210
|
+
|
211
|
+
def req_data_aes_decrypt(encrypt_string:nil)
|
212
|
+
|
213
|
+
|
214
|
+
response_data = encrypt_string
|
215
|
+
response_data = response_data[16..-1]
|
216
|
+
response_data = response_data[0..-16]
|
217
|
+
result_aes_key_name = response_data.slice(response_data.length-1)
|
218
|
+
result_aes_key_value = @salts_config[result_aes_key_name]
|
219
|
+
origin_result_data = response_data[0..-2]
|
220
|
+
|
221
|
+
data = AESHelper::aes_128_ecb_decrypt(result_aes_key_value, origin_result_data)
|
222
|
+
data_json = JSON.parse(data)
|
223
|
+
|
224
|
+
return data_json
|
225
|
+
end
|
226
|
+
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|