omt-cli 1.6.3 → 1.6.4

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.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +8 -0
  3. data/.gitignore +24 -0
  4. data/.travis.yml +31 -0
  5. data/CHANGELOG +188 -0
  6. data/Gemfile +11 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +35 -0
  9. data/Rakefile +10 -0
  10. data/bin/console +11 -0
  11. data/bin/fir +14 -0
  12. data/bin/setup +7 -0
  13. data/doc/build_apk.md +42 -0
  14. data/doc/build_ipa.md +66 -0
  15. data/doc/help.md +34 -0
  16. data/doc/info.md +44 -0
  17. data/doc/install.md +65 -0
  18. data/doc/login.md +19 -0
  19. data/doc/mapping.md +22 -0
  20. data/doc/publish.md +35 -0
  21. data/doc/upgrade.md +7 -0
  22. data/lib/fir.rb +28 -0
  23. data/lib/fir/api.yml +13 -0
  24. data/lib/fir/api.yml.bak +13 -0
  25. data/lib/fir/cli.rb +195 -0
  26. data/lib/fir/patches.rb +10 -0
  27. data/lib/fir/patches/blank.rb +131 -0
  28. data/lib/fir/patches/concern.rb +146 -0
  29. data/lib/fir/patches/default_headers.rb +9 -0
  30. data/lib/fir/patches/hash.rb +79 -0
  31. data/lib/fir/patches/instance_variables.rb +30 -0
  32. data/lib/fir/patches/native_patch.rb +28 -0
  33. data/lib/fir/patches/os_patch.rb +28 -0
  34. data/lib/fir/patches/try.rb +102 -0
  35. data/lib/fir/util.rb +87 -0
  36. data/lib/fir/util/build_apk.rb +76 -0
  37. data/lib/fir/util/build_common.rb +93 -0
  38. data/lib/fir/util/build_ipa.rb +240 -0
  39. data/lib/fir/util/config.rb +42 -0
  40. data/lib/fir/util/http.rb +30 -0
  41. data/lib/fir/util/info.rb +39 -0
  42. data/lib/fir/util/login.rb +18 -0
  43. data/lib/fir/util/mapping.rb +98 -0
  44. data/lib/fir/util/me.rb +19 -0
  45. data/lib/fir/util/parser/apk.rb +43 -0
  46. data/lib/fir/util/parser/bin/pngcrush +0 -0
  47. data/lib/fir/util/parser/common.rb +24 -0
  48. data/lib/fir/util/parser/ipa.rb +188 -0
  49. data/lib/fir/util/parser/pngcrush.rb +23 -0
  50. data/lib/fir/util/publish.rb +106 -0
  51. data/lib/fir/util/publish.rb.bak +185 -0
  52. data/lib/fir/version.rb +5 -0
  53. data/lib/fir/xcode_wrapper.sh +29 -0
  54. data/lib/omt-cli.rb +3 -0
  55. data/lib/omt_cli.rb +3 -0
  56. data/omt-cli.gemspec +48 -0
  57. data/test/build_ipa_test.rb +17 -0
  58. data/test/cases/test_apk.apk +0 -0
  59. data/test/cases/test_apk_txt +1 -0
  60. data/test/cases/test_ipa.ipa +0 -0
  61. data/test/cases/test_ipa_dsym +0 -0
  62. data/test/info_test.rb +36 -0
  63. data/test/login_test.rb +12 -0
  64. data/test/mapping_test.rb +18 -0
  65. data/test/me_test.rb +17 -0
  66. data/test/publish_test.rb +44 -0
  67. data/test/test_helper.rb +98 -0
  68. metadata +84 -4
@@ -0,0 +1,34 @@
1
+ ### 相关指令帮助
2
+
3
+ `fir help` 命令不仅可以运行在 `fir` 主命令上, 还可以运行在相应子命令上查看相关的帮助.
4
+
5
+ ```sh
6
+ $ fir help
7
+ Commands:
8
+ fir build_apk BUILD_DIR # Build Android app (alias: `ba`).
9
+ fir build_ipa BUILD_DIR [options] [settings] # Build iOS app (alias: `bi`).
10
+ fir help # Describe available commands or one specific command (aliases: `h`).
11
+ fir info APP_FILE_PATH # Show iOS/Android app info, support ipa/apk file (aliases: `i`).
12
+ fir login # Login fir.im (aliases: `l`).
13
+ fir mapping MAPPING_FILE_PATH # Upload app mapping file to BugHD.com (aliases: `m`).
14
+ fir me # Show current user info if user is logined.
15
+ fir publish APP_FILE_PATH # Publish iOS/Android app to fir.im, support ipa/apk file (aliases: `...
16
+ fir upgrade # Upgrade fir-cli and quit (aliases: `u`).
17
+ fir version # Show fir-cli version number and quit (aliases: `v`).
18
+
19
+ Options:
20
+ -T, [--token=TOKEN] # User's API Token at fir.im
21
+ -L, [--logfile=LOGFILE] # Path to writable logfile
22
+ -V, [--verbose], [--no-verbose] # Show verbose
23
+ # Default: true
24
+ -q, [--quiet], [--no-quiet] # Silence commands
25
+ -h, [--help], [--no-help] # Show this help message and quit
26
+ ```
27
+ #### 全局参数说明
28
+
29
+ - `alias <short command>` 意味着可以用 alias 别名来代替该指令, 例如 `fir b`
30
+ - `-T` 用户在 fir.im 上的 api_token
31
+ - `-L` 指定 fir-cli 的输出 log, 默认为 STDOUT
32
+ - `-V` Verbose, 默认为输出所有信息( INFO 和 ERROR), 如果设置 `--no-verbose`, 则只输出 ERROR 信息
33
+ - `-q` 静默模式, 默认关闭
34
+ - `-h` 查看相关命令帮助
@@ -0,0 +1,44 @@
1
+ ### fir info
2
+
3
+ `fir info` 命令用于查看当前 ipa/apk 相关信息.
4
+
5
+ ```sh
6
+ $ fir info --help
7
+ Usage:
8
+ fir info APP_FILE_PATH
9
+
10
+ Show iOS/Android app info, support ipa/apk file (aliases: `i`).
11
+ ```
12
+
13
+ #### 查看 ipa 相关信息
14
+
15
+ ```sh
16
+ $ fir info ./build_ipa.ipa
17
+
18
+ I, [2016-03-08T12:28:29.310846 #11961] INFO -- : Analyzing ipa file......
19
+ I, [2016-03-08T12:28:29.310932 #11961] INFO -- : ✈ -------------------------------------------- ✈
20
+ I, [2016-03-08T12:28:29.395706 #11961] INFO -- : type: ios
21
+ I, [2016-03-08T12:28:29.395775 #11961] INFO -- : identifier: xx.xxx.build-ipa
22
+ I, [2016-03-08T12:28:29.395793 #11961] INFO -- : name: build_ipa
23
+ I, [2016-03-08T12:28:29.395805 #11961] INFO -- : display_name: build_ipa
24
+ I, [2016-03-08T12:28:29.395817 #11961] INFO -- : build: 1
25
+ I, [2016-03-08T12:28:29.395829 #11961] INFO -- : version: 1.0
26
+ I, [2016-03-08T12:28:29.396007 #11961] INFO -- : devices: ["fasdfafaf3f4xxxxxxx78aecbc1234567"]
27
+ I, [2016-03-08T12:28:29.396057 #11961] INFO -- : release_type: adhoc
28
+ I, [2016-03-08T12:28:29.396086 #11961] INFO -- : distribution_name: iOSTeam Provisioning Profile: xx.xxx.* - xxx xx xxxxxx LLC.
29
+ I, [2016-03-08T12:28:29.396111 #11961] INFO -- :
30
+ ```
31
+
32
+ #### 查看 apk 相关信息
33
+
34
+ ```sh
35
+ $ fir info ./test_apk.apk
36
+ I, [2016-03-08T12:30:25.241278 #12073] INFO -- : Analyzing apk file......
37
+ I, [2016-03-08T12:30:25.241363 #12073] INFO -- : ✈ -------------------------------------------- ✈
38
+ I, [2016-03-08T12:30:25.250430 #12073] INFO -- : type: android
39
+ I, [2016-03-08T12:30:25.250477 #12073] INFO -- : identifier: com.xxx.myapplication
40
+ I, [2016-03-08T12:30:25.250496 #12073] INFO -- : name: My Application
41
+ I, [2016-03-08T12:30:25.250509 #12073] INFO -- : build: 1
42
+ I, [2016-03-08T12:30:25.250520 #12073] INFO -- : version: 1.0
43
+ I, [2016-03-08T12:30:25.250532 #12073] INFO -- :
44
+ ```
@@ -0,0 +1,65 @@
1
+ ### 安装
2
+
3
+ fir-cli 使用 Ruby 构建, 无需编译, 只要安装相应 gem 即可.
4
+
5
+ ```sh
6
+ $ ruby -v # > 1.9.3
7
+ $ gem install fir-cli
8
+ ```
9
+
10
+ #### 常见的安装问题
11
+
12
+ - 使用系统自带的 Ruby 安装, 需确保 ruby-dev 已被正确的安装:
13
+
14
+ ```sh
15
+ $ xcode-select --install # OS X 系统
16
+ $ sudo apt-get install ruby-dev # Linux 系统
17
+ ```
18
+
19
+ - 出现 `Permission denied` 相关错误:
20
+
21
+ 在命令前加上 `sudo`
22
+
23
+ - 出现 `Gem::RemoteFetcher::FetchError` 相关错误:
24
+
25
+ 更换 Ruby 的淘宝源(由于国内网络原因, 你懂的), 并升级下系统自带的 gem
26
+
27
+ ```sh
28
+ $ gem sources --remove https://rubygems.org/
29
+ $ gem sources -a https://ruby.taobao.org/
30
+ $ gem sources -l
31
+ *** CURRENT SOURCES ***
32
+
33
+ https://ruby.taobao.org
34
+ # 请确保只有 ruby.taobao.org, 如果有其他的源, 请 remove 掉
35
+
36
+ gem update --system
37
+ gem install fir-cli
38
+ ```
39
+
40
+ - Mac OS X 10.11 以后的版本, 由于10.11引入了 `rootless`, 无法直接安装 fir-cli, 有以下三种解决办法:
41
+
42
+ 1\. 使用 [Homebrew](http://brew.sh/) 及 [RVM](https://rvm.io/) 安装 Ruby, 再安装 fir-cli(推荐)
43
+
44
+ ```sh
45
+ # Install Homebrew:
46
+ $ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
47
+
48
+ # Install RVM:
49
+ $ \curl -sSL https://get.rvm.io | bash -s stable --ruby
50
+
51
+ $ gem install fir-cli
52
+ ```
53
+
54
+ 2\. 指定 fir-cli 中 bin 文件的 PATH
55
+
56
+ ```sh
57
+ $ export PATH=/usr/local/bin:$PATH;gem install -n /usr/local/bin fir-cli
58
+ ```
59
+
60
+ 3\. 重写 Ruby Gem 的 bindir
61
+
62
+ ```sh
63
+ $ echo 'gem: --bindir /usr/local/bin' >> ~/.gemrc
64
+ $ gem install fir-cli
65
+ ```
@@ -0,0 +1,19 @@
1
+ ### fir login & fir me
2
+
3
+ `fir login` 命令用于使用 API token 登录 fir.im, 并使用发布应用等相关命令.
4
+
5
+ `fir me` 命令用于查看当前登录用户信息.
6
+
7
+ 用户的 API token 可在 **[这里](http://fir.im/apps/apitoken)** 查看, 当使用 fir login 登录了之后, 后续命令都不需要加上 `-T` 参数, 会默认使用 **当前用户的 token** 进行相关操作.
8
+
9
+ ```sh
10
+ $ fir login XXX_YOUR_API_TOKEN_XXX
11
+ I, [2016-03-08T12:48:56.499435 #13043] INFO -- : Login succeed, previous user's email: xxx@fir.im
12
+ I, [2016-03-08T12:48:56.507044 #13043] INFO -- : Login succeed, current user's email: xxx@fir.im
13
+ I, [2016-03-08T12:48:56.507147 #13043] INFO -- :
14
+
15
+ $ fir me
16
+ I, [2016-03-08T12:48:14.175488 #12986] INFO -- : Login succeed, current user's email: xxx@fir.im
17
+ I, [2016-03-08T12:48:14.175687 #12986] INFO -- : Login succeed, current user's name: xxx
18
+ I, [2016-03-08T12:48:14.175765 #12986] INFO -- :
19
+ ```
@@ -0,0 +1,22 @@
1
+ ### fir mapping
2
+
3
+ `fir mapping` 指令用于将符号表上传至 [BugHD.com](http://bughd.com) 所对应的项目, 目前已经支持 dSYM 和 txt 两种格式的符号表文件上传, 有以下三种方法上传:
4
+
5
+ - 指定 version 和 build 上传:
6
+
7
+ ```sh
8
+ $ fir m <mapping file path> -P <bughd project id> -v <app version> -b <app build> -T <your api token>
9
+ ```
10
+
11
+ - 在 publish 的时候自动上传:
12
+
13
+ ```sh
14
+ $ fir p <app file path> -m <mapping file path> -P <bughd project id> -T <your api token>
15
+ ```
16
+ - 在 build_ipa 的时候自动上传:
17
+
18
+ ```sh
19
+ $ fir b <project dir> -P <bughd project id> -M -p -T <your api token>
20
+ ```
21
+
22
+ 更详细的使用说明, 可以使用 `fir mapping -h`查看相应的帮助.
@@ -0,0 +1,35 @@
1
+ ### fir publish
2
+
3
+ `fir publish` 命令用于可以发布应用到 fir.im, 支持 ipa 和 apk 文件.
4
+
5
+ ```sh
6
+ $ fir publish --help
7
+ Usage:
8
+ fir publish APP_FILE_PATH
9
+
10
+ Options:
11
+ -s, [--short=SHORT] # Set custom short link
12
+ -c, [--changelog=CHANGELOG] # Set changelog
13
+ -Q, [--qrcode], [--no-qrcode] # Generate qrcode
14
+ -m, [--mappingfile=MAPPINGFILE] # App mapping file
15
+ -P, [--proj=PROJ] # Project id in BugHD.com if upload app mapping file
16
+ [--open], [--no-open] # true/false if open for everyone
17
+ [--password=PASSWORD] # Set password for app
18
+ -T, [--token=TOKEN] # User's API Token at fir.im
19
+ -L, [--logfile=LOGFILE] # Path to writable logfile
20
+ -V, [--verbose], [--no-verbose] # Show verbose
21
+ # Default: true
22
+ -q, [--quiet], [--no-quiet] # Silence commands
23
+ -h, [--help], [--no-help] # Show this help message and quit
24
+ ```
25
+
26
+ 相关参数详解:
27
+
28
+ - `-s` 参数, 自定义发布后的短链接地址.
29
+ - `-c` 参数, 自定义发布时的 changelog, 支持字符串与文件两种方式, 即 `--changelog='this is changelog'` 和 `--changelog='/Users/fir-cli/changelog'`.
30
+ - `-Q` 参数, 是否生成发布后二维码, 默认为不生成, 加上 `-Q` 参数后会在当前目录生成一张二维码图片, 扫描该图片即可下载该应用.
31
+ - `-m` 参数, 上传当前应用的符号表文件, 配合 `-P` 参数使用.
32
+ - `-P` 参数, [BugHD.com](http://bughd.com) 上相对应的 Project id.
33
+ - `--open` 参数, 设置发布后的应用是否开放给所有人下载, 关闭开放使用 `--no-open` 参数.
34
+ - `--password` 参数, 设置发布后的应用密码
35
+
@@ -0,0 +1,7 @@
1
+ #### fir upgrade
2
+
3
+ `fir upgrade` 指令用于升级最新版本的 fir-cli
4
+
5
+ ```sh
6
+ $ fir upgrade
7
+ ```
@@ -0,0 +1,28 @@
1
+ # encoding: utf-8
2
+
3
+ require 'thor'
4
+ require 'logger'
5
+ require 'yaml'
6
+ require 'rest-client'
7
+ require 'json'
8
+ require 'securerandom'
9
+ require 'fileutils'
10
+ require 'cfpropertylist'
11
+ require 'tempfile'
12
+ require 'rqrcode'
13
+
14
+ # TODO: remove rescue when https://github.com/tajchert/ruby_apk/pull/4 merged
15
+ begin
16
+ require 'ruby_android'
17
+ rescue LoadError
18
+ require 'ruby_apk'
19
+ end
20
+
21
+ require 'fir/patches'
22
+ require 'fir/util'
23
+ require 'fir/version'
24
+ require 'fir/cli'
25
+
26
+ module FIR
27
+ include Util
28
+ end
@@ -0,0 +1,13 @@
1
+ fir:
2
+ domain: 'http://fir.im'
3
+ base_url: 'http://api.fir.im'
4
+ user_url: 'http://api.fir.im/user'
5
+ app_url: 'http://api.fir.im/apps'
6
+ udids_url: 'http://api.fir.im/devices/multi_udid'
7
+ app_my_url: 'https://p.onemt.co/index.php?s=/Home/Api/index'
8
+ app_my_version: 'https://p.onemt.co/index.php?s=/Home/Api/version'
9
+ bughd:
10
+ domain: 'http://bughd.com'
11
+ base_url: 'http://api.bughd.com'
12
+ project_url: 'http://api.bughd.com/projects'
13
+ full_version_url: 'http://api.bughd.com/full_versions'
@@ -0,0 +1,13 @@
1
+ fir:
2
+ domain: 'http://fir.im'
3
+ base_url: 'http://api.fir.im'
4
+ user_url: 'http://api.fir.im/user'
5
+ app_url: 'http://api.fir.im/apps'
6
+ udids_url: 'http://api.fir.im/devices/multi_udid'
7
+ app_my_url: 'https://p.onemt.co/index.php?s=/Home/Api/index'
8
+ app_my_version: 'https://p.onemt.co/index.php?s=/Home/Api/version'
9
+ bughd:
10
+ domain: 'http://bughd.com'
11
+ base_url: 'http://api.bughd.com'
12
+ project_url: 'http://api.bughd.com/projects'
13
+ full_version_url: 'http://api.bughd.com/full_versions'
@@ -0,0 +1,195 @@
1
+ # encoding: utf-8
2
+
3
+ module FIR
4
+ class CLI < Thor
5
+ class_option :token, type: :string, aliases: '-T', desc: "User's API Token at fir.im"
6
+ class_option :logfile, type: :string, aliases: '-L', desc: 'Path to writable logfile'
7
+ class_option :verbose, type: :boolean, aliases: '-V', desc: 'Show verbose', default: true
8
+ class_option :quiet, type: :boolean, aliases: '-q', desc: 'Silence commands'
9
+ class_option :help, type: :boolean, aliases: '-h', desc: 'Show this help message and quit'
10
+
11
+ desc 'build_ipa BUILD_DIR [options] [settings]', 'Build iOS app (alias: `bi`).'
12
+ long_desc <<-LONGDESC
13
+ `build_ipa` command will auto build your project/workspace to an ipa package
14
+ and it also can auto publish your built ipa to fir.im if use `-p` option.
15
+ Internally, it use `xcodebuild` to accomplish these things, use `man xcodebuild` to get more information.
16
+
17
+ Example:
18
+
19
+ $ fir bi <project dir> [-C <configuration>] [-t <target name>] [-o <ipa output dir>] [settings] [-c <changelog>] [-p -Q -T <your api token>]
20
+
21
+ $ fir bi <project dir> [-c <changelog> -P <bughd project id> -M -p -Q -T <your api token>]
22
+
23
+ $ fir bi <git ssh url> [-B develop -c <changelog> -f <profile> -P <bughd project id> -M -p -Q -T <your api token>]
24
+
25
+ $ fir bi <workspace dir> -w -S <scheme name> [-C <configuration>] [-t <target name>] [-o <ipa output dir>] [settings] [-c <changelog>] [-p -Q -T <your api token>]
26
+ LONGDESC
27
+ map ['b', 'bi'] => :build_ipa
28
+ method_option :branch, type: :string, aliases: '-B', desc: 'Set branch if project is a git repo, the default is `master`'
29
+ method_option :workspace, type: :boolean, aliases: '-w', desc: 'true/false if build workspace'
30
+ method_option :scheme, type: :string, aliases: '-S', desc: 'Set the scheme NAME if build workspace'
31
+ method_option :configuration, type: :string, aliases: '-C', desc: 'Use the build configuration NAME for building each target'
32
+ method_option :destination, type: :string, aliases: '-d', desc: 'Set the destination specifier'
33
+ method_option :target, type: :string, aliases: '-t', desc: 'Build the target specified by target name'
34
+ method_option :export_method, type: :string, aliases: '-E', desc: 'for exportOptionsPlist method, ad-hoc as default'
35
+ method_option :optionPlistPath, type: :string, aliases: '-O', desc: 'User defined exportOptionsPlist path'
36
+ method_option :profile, type: :string, aliases: '-f', desc: 'Set the export provisioning profile'
37
+ method_option :output, type: :string, aliases: '-o', desc: 'IPA output path, the default is: BUILD_DIR/fir_build_ipa'
38
+ method_option :publish, type: :boolean, aliases: '-p', desc: 'true/false if publish to fir.im'
39
+ method_option :short, type: :string, aliases: '-s', desc: 'Set custom short link if publish to fir.im'
40
+ method_option :name, type: :string, aliases: '-n', desc: 'Set custom ipa name when built'
41
+ method_option :changelog, type: :string, aliases: '-c', desc: 'Set changelog if publish to fir.im'
42
+ method_option :qrcode, type: :boolean, aliases: '-Q', desc: 'Generate qrcode'
43
+ method_option :mapping, type: :boolean, aliases: '-M', desc: 'true/false if upload app mapping file to BugHD.com'
44
+ method_option :proj, type: :string, aliases: '-P', desc: 'Project id in BugHD.com if upload app mapping file'
45
+ method_option :open, type: :boolean, desc: 'true/false if open for everyone'
46
+ method_option :password, type: :string, desc: 'Set password for app'
47
+ def build_ipa(*args)
48
+ prepare :build_ipa
49
+
50
+ FIR.build_ipa(*args, options)
51
+ end
52
+
53
+ desc 'build_apk BUILD_DIR', 'Build Android app (alias: `ba`).'
54
+ long_desc <<-LONGDESC
55
+ `build_apk` command will auto build your project to an apk package
56
+ and it also can auto publish your built apk to fir.im if use `-p` option.
57
+ Internally, it use `gradle` to accomplish these things, use `gradle --help` to get more information.
58
+
59
+ Example:
60
+
61
+ $ fir ba <project dir> [-o <apk output dir> -c <changelog> -p -Q -T <your api token>]
62
+
63
+ $ fir ba <project dir> [-f <flavor> -o <apk output dir> -c <changelog> -p -Q -T <your api token>]
64
+
65
+ $ fir ba <git ssh url> [-B develop -o <apk output dir> -c <changelog> -p -Q -T <your api token>]
66
+ LONGDESC
67
+ map ['ba'] => :build_apk
68
+ method_option :branch, type: :string, aliases: '-B', desc: 'Set branch if project is a git repo, the default is `master`'
69
+ method_option :output, type: :string, aliases: '-o', desc: 'APK output path, the default is: BUILD_DIR/build/outputs/apk'
70
+ method_option :publish, type: :boolean, aliases: '-p', desc: 'true/false if publish to fir.im'
71
+ method_option :flavor, type: :string, aliases: '-f', desc: 'Set flavor if have productFlavors'
72
+ method_option :short, type: :string, aliases: '-s', desc: 'Set custom short link if publish to fir.im'
73
+ method_option :name, type: :string, aliases: '-n', desc: 'Set custom apk name when builded'
74
+ method_option :changelog, type: :string, aliases: '-c', desc: 'Set changelog if publish to fir.im, support string/file'
75
+ method_option :qrcode, type: :boolean, aliases: '-Q', desc: 'Generate qrcode'
76
+ method_option :open, type: :boolean, desc: 'true/false if open for everyone, the default is: true', default: true
77
+ method_option :password, type: :string, desc: 'Set password for app'
78
+ def build_apk(*args)
79
+ prepare :build_apk
80
+
81
+ FIR.build_apk(*args, options)
82
+ end
83
+
84
+ desc 'info APP_FILE_PATH', 'Show iOS/Android app info, support ipa/apk file (aliases: `i`).'
85
+ map 'i' => :info
86
+ method_option :all, type: :boolean, aliases: '-a', desc: 'Show all information in application'
87
+ def info(*args)
88
+ prepare :info
89
+
90
+ FIR.info(*args, options)
91
+ end
92
+
93
+ desc 'publish APP_FILE_PATH', 'Publish iOS/Android app to fir.im, support ipa/apk file (aliases: `p`).'
94
+ long_desc <<-LONGDESC
95
+ `publish` command will publish your app file to fir.im, also the command support to publish app's short & changelog.
96
+
97
+ Example:
98
+
99
+ $ fir p <app file path> [-c <changelog> -s <custom short link> -Q -T <your api token>]
100
+
101
+ $ fir p <app file path> [-c <changelog> -s <custom short link> --password=123456 --open=false -Q -T <your api token>]
102
+
103
+ $ fir p <app file path> [-c <changelog> -s <custom short link> -m <mapping file path> -P <bughd project id> -Q -T <your api token>]
104
+ LONGDESC
105
+ map 'p' => :publish
106
+ method_option :short, type: :string, aliases: '-s', desc: 'Set custom short link'
107
+ method_option :changelog, type: :string, aliases: '-c', desc: 'Set changelog'
108
+ method_option :qrcode, type: :boolean, aliases: '-Q', desc: 'Generate qrcode'
109
+ method_option :mappingfile, type: :string, aliases: '-m', desc: 'App mapping file'
110
+ method_option :proj, type: :string, aliases: '-P', desc: 'Project id in BugHD.com if upload app mapping file'
111
+ method_option :open, type: :boolean, desc: 'true/false if open for everyone'
112
+ method_option :password, type: :string, desc: 'Set password for app'
113
+ def publish(*args)
114
+ prepare :publish
115
+
116
+ FIR.publish(*args, options)
117
+ end
118
+
119
+ desc 'login', 'Login fir.im (aliases: `l`).'
120
+ map 'l' => :login
121
+ def login(*args)
122
+ prepare :login
123
+
124
+ token = options[:token] || args.first || ask('Please enter your fir.im API Token:', :white, echo: true)
125
+ FIR.login(token)
126
+ end
127
+
128
+ desc 'me', 'Show current user info if user is logined.'
129
+ def me
130
+ prepare :me
131
+
132
+ FIR.me
133
+ end
134
+
135
+ desc 'mapping MAPPING_FILE_PATH', 'Upload app mapping file to BugHD.com (aliases: `m`).'
136
+ long_desc <<-LONGDESC
137
+ `mapping` command will upload your app's mapping file to BugHD.com if you have the same app/project in BugHD.com.
138
+
139
+ Example:
140
+
141
+ $ fir m <mapping file path> -P <bughd project id> -v <app version> -b <app build> -T <your fir api token>
142
+ LONGDESC
143
+ map 'm' => :mapping
144
+ method_option :proj, type: :string, aliases: '-P', desc: 'Project id in BugHD.com'
145
+ method_option :version, type: :string, aliases: '-v', desc: 'App version'
146
+ method_option :build, type: :string, aliases: '-b', desc: 'App build'
147
+ def mapping(*args)
148
+ prepare :mapping
149
+
150
+ FIR.mapping(*args, options)
151
+ end
152
+
153
+ desc 'upgrade', 'Upgrade fir-cli and quit (aliases: `u`).'
154
+ map 'u' => :upgrade
155
+ def upgrade
156
+ prepare :upgrade
157
+
158
+ say '✈ Upgrade fir-cli (use `gem install fir-cli --no-ri --no-rdoc`)'
159
+ say `gem install fir-cli --no-ri --no-rdoc`
160
+ end
161
+
162
+ desc 'version', 'Show fir-cli version number and quit (aliases: `v`).'
163
+ map ['v', '-v', '--version'] => :version
164
+ def version
165
+ say "✈ fir-cli #{FIR::VERSION}"
166
+ end
167
+
168
+ desc 'help', 'Describe available commands or one specific command (aliases: `h`).'
169
+ map Thor::HELP_MAPPINGS => :help
170
+ def help(command = nil, subcommand = false)
171
+ super
172
+ end
173
+
174
+ no_commands do
175
+ def invoke_command(command, *args)
176
+ logfile = options[:logfile].blank? ? STDOUT : options[:logfile]
177
+ logfile = '/dev/null' if options[:quiet]
178
+
179
+ FIR.logger = Logger.new(logfile)
180
+ FIR.logger.level = options[:verbose] ? Logger::INFO : Logger::ERROR
181
+ super
182
+ end
183
+ end
184
+
185
+ private
186
+
187
+ def prepare(task)
188
+ if options.help?
189
+ help(task.to_s)
190
+ fail SystemExit
191
+ end
192
+ $DEBUG = true if ENV['DEBUG']
193
+ end
194
+ end
195
+ end