fir-cli 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f73f5c29991452ef8c835d92282a6d729c1e1fe2
4
- data.tar.gz: 62e0112cce079963c4bddb9282bbf92fa2974a7d
3
+ metadata.gz: 7542e6029327b193019ad292029cda16611bb3df
4
+ data.tar.gz: a8211154ff64bd79f1111a4530bcf304a8a3516a
5
5
  SHA512:
6
- metadata.gz: e2b25998a5c0e87bb5015854f48cc42999c317fb3a70a1504778451106b0a3260a124009e7b1d1a659d269b8384519a08f80d17f4b108bfe589a932607c2999f
7
- data.tar.gz: ec57a6453ebe8db965d5e764e22a5853166364af25adebdc13690f2c4fdefca8eb21e6df2e774a04b856db6a6135cf39b1125e08167047ff5a8f6554e16dd58e
6
+ metadata.gz: 594509c71c4ef5933ceb9e80bbfed36dcb03971ece925301256da6a370e445d10728de088d6a8cc41255a68e5a4265b9b9d978182f0e1c0e84d6e0cb206440f0
7
+ data.tar.gz: ad35e24c12be9f02ee2335c4639736e85dd09be297192b4d42c0f01c951b4d6d372d44284643e2d1ccbec582b960b0bfde7c8ad0614ab31c82717848016dfb92
data/lib/fir-cli.rb CHANGED
@@ -10,6 +10,7 @@ require 'pngdefry'
10
10
  require 'user_config'
11
11
  require 'rest_client'
12
12
  require 'lagunitas'
13
+ require 'lagunitas.patch'
13
14
  require 'lagunitas.ext'
14
15
 
15
16
  # p Lagunitas::App.new('').respond_to? :mobileprovision
@@ -34,7 +35,7 @@ class FirCli < Thor
34
35
  end
35
36
 
36
37
  desc 'config', '配置全局设置'
37
- option :resign, :aliases => '-r', :desc => '是否以企业签名发布,默认为否', :type => :boolean, :default => false
38
+ option :resign, :aliases => '-r', :desc => '是否以企业签名发布', :type => :boolean
38
39
  option :token, :aliases => '-t', :desc => '用户令牌'
39
40
  option :email, :aliases => '-e', :desc => '邮件地址'
40
41
  option :verbose, :aliases => '-v', :desc => '输出配置项', :type => :boolean
@@ -54,8 +55,8 @@ class FirCli < Thor
54
55
  option :short, :aliases => '-s', :desc => '自定义短地址'
55
56
  option :token, :aliases => '-t', :desc => '用户令牌,不写则使用已经登陆信息'
56
57
  def update(path)
57
- app = info path, false, true
58
- fir_app = fir_info app[:identifier]
58
+ app = _info path, false, true
59
+ fir_app = _fir_info app[:identifier]
59
60
  opt_short = options[:short]
60
61
  post = {}
61
62
  post[:public] = options[:public] != nil ? options[:public] : @ipa_config['public']
@@ -64,9 +65,9 @@ class FirCli < Thor
64
65
  post.each { |i| if i[1] == fir_app[i[0]] then post.delete i[0] end }
65
66
 
66
67
  if post.length == 0 then puts '> 没有可以更新的项目'; return end
67
- fir_put fir_app[:id], post
68
+ _fir_put fir_app[:id], post
68
69
 
69
- fir_app = fir_info app[:identifier]
70
+ fir_app = _fir_info app[:identifier]
70
71
  if opt_short && opt_short != fir_app[:short]
71
72
  puts "> 短地址 #{ opt_short } 被占用,FIR.im 自动更新短地址为 #{ fir_app[:short] }"
72
73
  end
@@ -79,13 +80,13 @@ class FirCli < Thor
79
80
  option :token, :aliases => '-t', :desc => '用户令牌,不写则使用已经登陆信息'
80
81
  option :changelog, :aliases => '-c', :desc => '修改纪录,默认为空字符串', :default => ''
81
82
  def publish(path)
82
- if opt_resign
83
+ if _opt_resign
83
84
  tfile = Tempfile.new SecureRandom.hex
84
85
  resign path, tfile.path
85
86
  path = tfile.path
86
87
  end
87
- app = info path
88
- fir_app = fir_info app[:identifier]
88
+ app = _info path
89
+ fir_app = _fir_info app[:identifier]
89
90
 
90
91
  id = fir_app[:id]
91
92
  short = fir_app[:short]
@@ -115,13 +116,13 @@ class FirCli < Thor
115
116
  puts '上传图标成功'
116
117
  end
117
118
 
118
- fir_put fir_app[:id],
119
+ _fir_put fir_app[:id],
119
120
  :name => app[:display_name] || app[:name],
120
121
  :short => options[:short] || fir_app[:short],
121
122
  :version => app[:version],
122
123
  :versionShort => app[:short_version]
123
124
 
124
- fir_vput upload_res[:versionOid],
125
+ _fir_vput upload_res[:versionOid],
125
126
  :version => app[:version],
126
127
  :versionShort => app[:short_version],
127
128
  :devices => app[:devices],
@@ -132,14 +133,14 @@ class FirCli < Thor
132
133
  puts "> http://fir.im/#{short}"
133
134
  end
134
135
 
135
- desc 'digg IPA_FILE_PATH', '获取 .ipa 文件的信息'
136
+ desc 'info IPA_FILE_PATH', '获取 .ipa 文件的信息'
136
137
  option 'verbose', :aliases => '-v', :desc => '显示更多信息', :type => :boolean
137
138
  option 'fir', :aliases => '-f', :desc => '显示托管在 fir.im 的信息', :type => :boolean
138
- def digg(path)
139
- app = info path, false, options['verbose']
139
+ def info(path)
140
+ app = _info path, false, options['verbose']
140
141
  app.each { |i| puts "#{ Paint[i[0].to_s.rjust(15), :blue] } #{ i[1] }" }
141
142
  if options[:fir]
142
- fir_app = fir_info app[:identifier]
143
+ fir_app = _fir_info app[:identifier]
143
144
  fir_app.each { |i| puts "#{ Paint[i[0].to_s.rjust(15), :blue] } #{ i[1] }" }
144
145
  end
145
146
  end
@@ -154,7 +155,7 @@ class FirCli < Thor
154
155
  puts "! 用分发,请注意:#{ Paint['当证书失效后,所有安装以失效证', :red ] }"
155
156
  puts "! #{ Paint['书签名的的用户都会无法正常运行应用;同时托管在', :red ] }"
156
157
  puts "! #{ Paint['fir.im 的应用将无法正常安装。', :red ] }"
157
- if opt_email == nil
158
+ if _opt_email == nil
158
159
  puts Paint['! 您需要提供邮件地址才能使用 resign.tapbeta.com 的签名服务', :red]
159
160
  puts Paint['! 使用 fir config --email=EMAIL 进行设置', :green]
160
161
  exit
@@ -198,7 +199,7 @@ class FirCli < Thor
198
199
  end
199
200
 
200
201
  private
201
- def info(path, quiet = false, more = false)
202
+ def _info(path, quiet = false, more = false)
202
203
  path = Pathname.new(Dir.pwd).join(path).cleanpath
203
204
  ipa = Lagunitas::IPA.new path
204
205
  if !quiet then puts '> 正在解析 ipa 文件...' end
@@ -214,17 +215,14 @@ class FirCli < Thor
214
215
  # :distribution_name => app.distribution_name
215
216
  }
216
217
  if more
217
- begin
218
- info[:icons] = app.icons
219
- rescue
220
- end
218
+ info[:icons] = app.icons
221
219
  info[:plist] = app.info
222
220
  end
223
221
  ipa.cleanup
224
222
  info
225
223
  end
226
- def fir_info(identifier, quiet = false)
227
- if !opt_token
224
+ def _fir_info(identifier, quiet = false)
225
+ if !_opt_token
228
226
  puts Paint['! 您还没有登录', :red]
229
227
  puts Paint['! 请 fir login USER_TOKEN 登录', :green]
230
228
  exit
@@ -234,8 +232,8 @@ class FirCli < Thor
234
232
  res = RestClient.get "http://fir.im/api/v2/app/info/#{identifier}?#{URI.encode_www_form body}"
235
233
  JSON.parse res.body, :symbolize_names => true
236
234
  end
237
- def fir_put(id, body, quiet = false)
238
- if !opt_token
235
+ def _fir_put(id, body, quiet = false)
236
+ if !_opt_token
239
237
  puts Paint['! 您还没有登录', :red]
240
238
  puts Paint['! 请 fir login USER_TOKEN 登录', :green]
241
239
  exit
@@ -245,8 +243,8 @@ class FirCli < Thor
245
243
  RestClient.put "http://fir.im/api/v2/app/#{id}?#{URI.encode_www_form body}", body
246
244
  puts '> 更新成功'
247
245
  end
248
- def fir_vput(id, body, quiet = false)
249
- if !opt_token
246
+ def _fir_vput(id, body, quiet = false)
247
+ if !_opt_token
250
248
  puts Paint['! 您还没有登录', :red]
251
249
  puts Paint['! 请 fir login USER_TOKEN 登录', :green]
252
250
  exit
@@ -256,13 +254,13 @@ class FirCli < Thor
256
254
  RestClient.put "http://fir.im/api/v2/appVersion/#{id}/complete?#{URI.encode_www_form body}", body
257
255
  puts '> 更新成功'
258
256
  end
259
- def opt_token
257
+ def _opt_token
260
258
  @token = options[:token] || @ipa_config['token'] || nil
261
259
  end
262
- def opt_email
260
+ def _opt_email
263
261
  @email = options[:email] || @ipa_config['email'] || nil
264
262
  end
265
- def opt_resign
263
+ def _opt_resign
266
264
  @resign = options[:resign] || @ipa_config['resign'] || nil
267
265
  end
268
266
  end
data/lib/lagunitas.ext.rb CHANGED
@@ -2,25 +2,54 @@ require 'cfpropertylist'
2
2
  require 'lagunitas'
3
3
  module Lagunitas
4
4
  class App
5
- def name
6
- @info['CFBundleName']
7
- end
8
- def mobileprovision
9
- @mobileprovision = CFPropertyList.native_types CFPropertyList::List.new(:data => `security cms -D -i #{File.join @path, 'embedded.mobileprovision'}`).value
10
- end
11
- def devices
12
- mobileprovision['ProvisionedDevices']
13
- end
5
+ def initialize(path, root)
6
+ @path = path
7
+ @root = root
8
+ end
9
+ def name
10
+ @info['CFBundleName']
11
+ end
12
+ def mobileprovision
13
+ return if !mobileprovision?
14
+ @mobileprovision ||= CFPropertyList.native_types CFPropertyList::List.new(:data => `security cms -D -i #{File.join @path, 'embedded.mobileprovision'}`).value
15
+ end
16
+ def mobileprovision?
17
+ return true if @mobileprovision
18
+ File.exists? File.join @path, 'embedded.mobileprovision'
19
+ end
20
+ def devices
21
+ mobileprovision['ProvisionedDevices'] if mobileprovision
22
+ end
14
23
  def distribution_name
15
- mobileprovision['DeveloperCertificates']
16
- end
17
- def release_type
18
- if devices == nil
19
- 'inhouse'
20
- else
21
- 'adhoc'
22
- end
23
- end
24
-
24
+ mobileprovision['DeveloperCertificates'] if mobileprovision
25
+ end
26
+ def metadata
27
+ return if !metadata?
28
+ @metadata ||= CFPropertyList.native_types(CFPropertyList::List.new(file: File.join(@root, 'iTunesMetadata.plist')).value)
29
+ end
30
+ def metadata?
31
+ return true if @metadata
32
+ File.exists? File.join @root, 'iTunesMetadata.plist'
33
+ end
34
+ def release_type
35
+ @release_type ||= begin
36
+ if mobileprovision?
37
+ if devices
38
+ 'adhoc'
39
+ else
40
+ 'inhouse'
41
+ end
42
+ elsif metadata?
43
+ 'store'
44
+ else
45
+ 'adhoc'
46
+ end
47
+ end
48
+ end
49
+ end
50
+ class IPA
51
+ def root_path
52
+ contents
53
+ end
25
54
  end
26
55
  end
@@ -0,0 +1,40 @@
1
+ require 'lagunitas'
2
+ module Lagunitas
3
+ class App
4
+ def initialize(path, root)
5
+ @path = path
6
+ @root = root
7
+ end
8
+ def icons
9
+ @icons ||= begin
10
+ icons = []
11
+ info['CFBundleIcons']['CFBundlePrimaryIcon']['CFBundleIconFiles'].each do |name|
12
+ icons << get_image(name)
13
+ icons << get_image("#{name}@2x")
14
+ end
15
+ icons.delete_if { |i| !i }
16
+ rescue
17
+ # info['CFBundleIcons'] might be nil
18
+ nil
19
+ end
20
+ end
21
+ end
22
+ class IPA
23
+ def app
24
+ @app ||= App.new app_path, root_path
25
+ end
26
+ def contents
27
+ @contents ||= begin
28
+ tmp_path = "tmp/lagunitas-#{SecureRandom.hex}"
29
+ Zip::ZipFile.open @path do |zip_file|
30
+ zip_file.each do |f|
31
+ f_path = File.join tmp_path, f.name
32
+ FileUtils.mkdir_p File.dirname f_path
33
+ zip_file.extract f, f_path unless File.exist? f_path
34
+ end
35
+ end
36
+ tmp_path
37
+ end
38
+ end
39
+ end
40
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fir-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yan
@@ -103,6 +103,7 @@ extra_rdoc_files: []
103
103
  files:
104
104
  - lib/fir-cli.rb
105
105
  - lib/lagunitas.ext.rb
106
+ - lib/lagunitas.patch.rb
106
107
  - bin/fir
107
108
  homepage: https://github.com/idy/fir-cli
108
109
  licenses: