fir-cli 0.1.8 → 0.1.9

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: 9734a2a6211d82d058df273bd03c91cf9cc51f0a
4
- data.tar.gz: f58003855b7eb3e568ce73171f18163e57dc001c
3
+ metadata.gz: 9dbb82db6a565fb7b448b2dd8643b8991250b022
4
+ data.tar.gz: 8ebacaa4ee598e06fcdf645c0070cef5822f1205
5
5
  SHA512:
6
- metadata.gz: 6cc3a636a04a3c8adbe755803bc1ad55ca543b44cb430ab93c3f4610bf627ff05117f6c47919a093000bec9e76f10dbc5164cd0ae365e4924819ab944bb5ba6b
7
- data.tar.gz: 737c734728115877b142729fae596a9d1b036616a34013d7d06e83a972d8d16f7ff235bcad7c625b966ead6314e375303bdd178cdd9bed1a61a8de18d5cad5c9
6
+ metadata.gz: 8f53a74550bce7e5f7294f7f613b9db1e544b79cfb94fa1ef588590b8f7a92566d9589e56c2700d79c7ca38ce0cea37bcb3014ea9312b0e6a26d3eebc00ad0ab
7
+ data.tar.gz: 67616767e8c833f3d73c246d05a06580a364723c4757b71ace737ff6e1c1c189e2f3ac94eceb0210d32d8e90f75af68993b24e657b16ac30cd35af17a842fafa
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fir-cli (0.1.8)
4
+ fir-cli (0.1.9)
5
5
  highline (~> 1.6)
6
6
  lagunitas (= 0.0.1)
7
7
  paint (~> 0.9)
@@ -1,5 +1,5 @@
1
1
  module Fir
2
2
  class Cli
3
- VERSION = '0.1.8'
3
+ VERSION = '0.1.9'
4
4
  end
5
5
  end
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ module Fir
3
+ class Cli
4
+ def self.git_options
5
+ option :git, :desc => '设置 git 源'
6
+ option :origin, :desc => '设置 git clone 的 origin'
7
+ option :branch, :desc => '设置 git clone 的 branch'
8
+ end
9
+ no_commands do
10
+ def git(path)
11
+ arguments = '--depth 1'
12
+ %w(origin branch).each do |_m|
13
+ opt = method("_opt_#{_m}".to_sym).call
14
+ arguments += " --#{_m} #{opt}" if opt
15
+ end
16
+
17
+ Dir.mktmpdir do |dir|
18
+ _puts "> 克隆源代码 #{_opt_git}#{path}"
19
+ Dir.chdir(dir) do
20
+ _exec "git clone -q #{_opt_git}#{path} ./ #{arguments}"
21
+ yield dir if block_given?
22
+ end
23
+ end
24
+ end
25
+ end
26
+ private
27
+ def _opt_git
28
+ default = @config['git'] || 'git@github.com'
29
+ return default if options[:git] == 'git'
30
+ options[:git] || default
31
+ end
32
+ end
33
+ end
@@ -5,6 +5,8 @@ module Fir
5
5
  option :token, :aliases => '-t', :desc => '用户 token'
6
6
  option :email, :aliases => '-e', :desc => '邮件地址'
7
7
  option :resign, :aliases => '-r', :desc => '是否以企业签名发布 ios 应用', :type => :boolean
8
+ option :publish, :aliases => '-p', :desc => '编译打包自动发布至 FIR.im', :type => :boolean
9
+ git_options
8
10
  output_options
9
11
  def config
10
12
  if options.length > 0
@@ -19,8 +21,8 @@ module Fir
19
21
  @config.save
20
22
  end
21
23
  _puts '> 设置完成,您现在使用的设置是'
22
- @config.save
23
- @config.each { |conf| _puts "> #{Paint[conf[0].to_s.rjust(10), :blue]} => #{conf[1]}"}
24
+ @config.save
25
+ @config.each { |conf| _puts "> #{Paint[conf[0].to_s.rjust(10), :blue]} => #{conf[1]}" }
24
26
  end
25
27
  end
26
28
  end
@@ -1,8 +1,11 @@
1
1
  # coding: utf-8
2
2
  module Fir
3
3
  class Cli
4
+ def self.resign_options
5
+ option :email, :aliases => '-e', :desc => '邮件地址'
6
+ end
4
7
  desc 'resign IPA_FILE_PATH OUTPUT_PATH', '使用 resign.tapbeta.com 进行企业签名'
5
- option :email, :aliases => '-e', :desc => '邮件地址'
8
+ resign_options
6
9
  output_options
7
10
  def resign(ipath, opath)
8
11
  _puts "! #{Paint['resign.tapbeta.com 签名服务风险提示', :red]}"
@@ -2,11 +2,14 @@
2
2
  module Fir
3
3
  class Cli
4
4
  desc 'publish APP_FILE_PATH', '将应用文件发布至 FIR.im(支持 ipa 文件和 apk 文件)'
5
- option :resign, :aliases => '-r', :desc => '进行企业签名', :type => :boolean
6
- option :email, :aliases => '-e', :desc => '企业签名所需的邮件地址'
7
- option :short, :aliases => '-s', :desc => '自定义短地址'
8
- option :token, :aliases => '-t', :desc => '用户 token'
9
- option :changelog, :aliases => '-c', :desc => '修改纪录,默认为空字符串', :default => ''
5
+ def self.publish_options
6
+ option :resign, :aliases => '-r', :desc => '设置是否进行企业签名', :type => :boolean
7
+ option :token, :aliases => '-t', :desc => '用户 token'
8
+ option :short, :aliases => '-s', :desc => '自定义短地址'
9
+ option :changelog, :aliases => '-c', :desc => '修改纪录,默认为空字符串', :default => ''
10
+ end
11
+ publish_options
12
+ resign_options
10
13
  output_options
11
14
  def publish(path)
12
15
  if _opt_resign && _is_ipa(path)
@@ -0,0 +1,98 @@
1
+ # coding: utf-8
2
+ module Fir
3
+ class Cli
4
+ def self.build_ipa_options
5
+ option :x_project, :desc => '选择编译的项目文件'
6
+ option :x_scheme, :desc => '选择使用的 Scheme'
7
+ option :x_target, :desc => '选择编译的 Target'
8
+ option :x_alltarget, :desc => '编译全部 Target', :type => :boolean
9
+ option :x_configuration, :desc => '选择编译使用的配置'
10
+ option :output_ipa, :aliases => '-o', :desc => '指定 ipa 的输出路径'
11
+ option :output_app, :desc => '指定 app 的输出路径'
12
+ option :publish, :aliases => '-p', :desc => '设置是否直接发布到 FIR.im', :type => :boolean
13
+ end
14
+ desc 'build_ipa PATH [options] [settings]', '编译 ios app 项目,输出至 ODIR'
15
+ build_ipa_options
16
+ publish_options
17
+ output_options
18
+ def build_ipa(path, *settings)
19
+ if _os != 'mac'
20
+ _puts "! #{Paint['不支持在非 mac 系统上编译打包', :red]}"
21
+ exit 1
22
+ end
23
+ settings = _convert_settings *settings
24
+ ipa_path = _path options[:output_ipa] if options[:output_ipa]
25
+ if !ipa_path
26
+ use_tmpfile = true
27
+ ipa_path = Tempfile.new(["#{SecureRandom.hex}", '.ipa']).path
28
+ end
29
+ app_path = _path options[:output_app] if options[:output_app]
30
+ mp_path = _path options[:mobileprovision] if options[:mobileprovision]
31
+
32
+ vars = {
33
+ :ipa_path => ipa_path,
34
+ :app_path => app_path
35
+ }
36
+ # TODO: pull from a git repo
37
+ # if options[:git] != nil
38
+ # git(path) { |_d| _build_ipa _d, settings, vars }
39
+ # else
40
+ # end
41
+
42
+ path = _path path
43
+ project_dir = (Dir.exist? path) ? path : (File.dirname path)
44
+ _build_ipa project_dir, settings, vars
45
+
46
+ return if !_opt_publish
47
+ publish ipa_path.to_s
48
+ end
49
+
50
+ private
51
+ def _build_ipa(project_dir, *args)
52
+ settings = {}
53
+ vars = {}
54
+ if args.length == 1
55
+ args[0].each { |_k, _v| if _k.match /^[A-Z]+$/ then settings[_k] = _v else vars[_k] = _v end }
56
+ else
57
+ settings, vars = args[0..1]
58
+ end
59
+
60
+ settings = settings.select { |_k| _k != 'TARGET_BUILD_DIR' }
61
+ .map { |_k, _v| "#{_k}=\"#{_v}\"" }
62
+ .join(' ')
63
+ arguments = '-sdk iphoneos'
64
+ options.each do |_k, _v|
65
+ break if !_k.start_with? 'x_'
66
+ arguments += " -#{_k[2..-1]}" if _v
67
+ arguments += " #{_v}" if _v.class == String
68
+ end
69
+ Dir.mktmpdir do |_d|
70
+ settings += " TARGET_BUILD_DIR=#{_d}"
71
+ Dir.chdir(project_dir) do
72
+ _puts '> 正在清除缓存'
73
+ _exec "xcodebuild clean 2>&1"
74
+ _puts '> 正在编译'
75
+ _exec "xcodebuild build #{arguments} #{settings} 2>&1"
76
+ end
77
+ Dir.chdir(_d) do
78
+ ipa_path = vars[:ipa_path]
79
+ if ipa_path
80
+ basename = File.basename Dir['*.app'][0], '.app'
81
+ ipa_path = File.join(ipa_path, 'build_ipa.ipa') if Dir.exist? ipa_path
82
+ _puts '> 正在打包'
83
+ _exec 'mkdir Payload'
84
+ _exec 'mv *.app ./Payload'
85
+ _exec "rm #{ipa_path}" if File.exist? ipa_path
86
+ _exec "zip -qr #{ipa_path} Payload"
87
+ end
88
+
89
+ if vars[:app_path]
90
+ _puts '> 正在复制 app 文件'
91
+ _exec "mv ./Payload/*.app #{vars[:app_path]}"
92
+ end
93
+ end
94
+ _puts '> 完成'
95
+ end
96
+ end
97
+ end
98
+ end
@@ -45,7 +45,7 @@ module Fir
45
45
  path = Pathname.new(Dir.pwd).join(path).cleanpath
46
46
  end
47
47
  no_commands do
48
- %w(token email verbose).each do |_m|
48
+ %w(token email verbose origin branch).each do |_m|
49
49
  define_method "_opt_#{_m}" do
50
50
  unless instance_variable_get("@#{_m}")
51
51
  instance_variable_set("@#{_m}", options[_m.to_sym] || @config[_m] )
@@ -54,7 +54,7 @@ module Fir
54
54
  end
55
55
  private "_opt_#{_m}".to_sym
56
56
  end
57
- %w(resign quiet color trim).each do |_m|
57
+ %w(publish resign quiet color trim).each do |_m|
58
58
  define_method "_opt_#{_m}" do
59
59
  return false if options[_m.to_sym] == false
60
60
  unless instance_variable_get("@#{_m}")
@@ -131,6 +131,7 @@ module Fir
131
131
  _apk_info path, more
132
132
  else
133
133
  _puts "! #{Paint['只能支持后缀为 ipa 和 apk 的文件', :red]}"
134
+ exit 1
134
135
  end
135
136
  end
136
137
  def _apk_info(path, more = false)
@@ -202,5 +203,24 @@ module Fir
202
203
  end
203
204
  end
204
205
  end
206
+ def _os
207
+ return 'mac' if /darwin/ =~ RUBY_PLATFORM
208
+ return 'windows' if /cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM
209
+ return 'linux'
210
+ end
211
+ def _exec(cmd, code=1)
212
+ output = `#{cmd}`
213
+ if $?.exitstatus != 0
214
+ puts output
215
+ exit code
216
+ end
217
+ end
218
+ def _convert_settings(*settings)
219
+ settings.reduce({}) do |hash, setting|
220
+ key,val = setting.split('=', 2).map(&:strip)
221
+ hash[key.to_sym] = val
222
+ hash
223
+ end
224
+ end
205
225
  end
206
226
  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.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - FIR.im
@@ -56,98 +56,98 @@ dependencies:
56
56
  name: rest_client
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '1.8'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.8'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: paint
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0.9'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0.9'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: thor
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0.19'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0.19'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: ruby_apk
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ~>
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0.7'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ~>
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0.7'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: highline
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ~>
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
117
  version: '1.6'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ~>
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '1.6'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: bundler
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ~>
129
+ - - "~>"
130
130
  - !ruby/object:Gem::Version
131
131
  version: '1.7'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ~>
136
+ - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '1.7'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: rake
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ~>
143
+ - - "~>"
144
144
  - !ruby/object:Gem::Version
145
145
  version: '10.0'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - ~>
150
+ - - "~>"
151
151
  - !ruby/object:Gem::Version
152
152
  version: '10.0'
153
153
  description: FIR.im 命令行工具,支持 ios 和 android
@@ -157,7 +157,7 @@ executables:
157
157
  extensions: []
158
158
  extra_rdoc_files: []
159
159
  files:
160
- - .gitignore
160
+ - ".gitignore"
161
161
  - Gemfile
162
162
  - Gemfile.lock
163
163
  - LICENSE.txt
@@ -165,14 +165,16 @@ files:
165
165
  - bin/fir
166
166
  - fir-cli.gemspec
167
167
  - fir-cli.rb
168
- - lib/fir-cli-commands/config.rb
169
- - lib/fir-cli-commands/info.rb
170
- - lib/fir-cli-commands/login.rb
171
- - lib/fir-cli-commands/profile.rb
172
- - lib/fir-cli-commands/publish.rb
173
- - lib/fir-cli-commands/resign.rb
174
- - lib/fir-cli-commands/upgrade.rb
175
- - lib/fir-cli-commands/version.rb
168
+ - lib/fir-cli-commands/00-git.rb
169
+ - lib/fir-cli-commands/00-info.rb
170
+ - lib/fir-cli-commands/00-login.rb
171
+ - lib/fir-cli-commands/00-profile.rb
172
+ - lib/fir-cli-commands/00-upgrade.rb
173
+ - lib/fir-cli-commands/00-version.rb
174
+ - lib/fir-cli-commands/01-config.rb
175
+ - lib/fir-cli-commands/10-resign.rb
176
+ - lib/fir-cli-commands/11-publish.rb
177
+ - lib/fir-cli-commands/12-build_ipa.rb
176
178
  - lib/fir-cli.core.ext.rb
177
179
  - lib/fir-cli.utils.ext.rb
178
180
  - lib/fir-cli/version.rb
@@ -187,15 +189,15 @@ post_install_message:
187
189
  rdoc_options: []
188
190
  require_paths:
189
191
  - lib
190
- - ./
192
+ - "./"
191
193
  required_ruby_version: !ruby/object:Gem::Requirement
192
194
  requirements:
193
- - - '>='
195
+ - - ">="
194
196
  - !ruby/object:Gem::Version
195
197
  version: '0'
196
198
  required_rubygems_version: !ruby/object:Gem::Requirement
197
199
  requirements:
198
- - - '>='
200
+ - - ">="
199
201
  - !ruby/object:Gem::Version
200
202
  version: '0'
201
203
  requirements: []
File without changes
File without changes
File without changes
File without changes
File without changes