fir-cli-x 1.7.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +7 -0
  2. data/.codeclimate.yml +8 -0
  3. data/.dockerignore +2 -0
  4. data/.flow-plugin.yml +14 -0
  5. data/.gitignore +27 -0
  6. data/.travis.yml +23 -0
  7. data/CHANGELOG +194 -0
  8. data/Dockerfile +12 -0
  9. data/Gemfile +10 -0
  10. data/LICENSE.txt +22 -0
  11. data/README.md +63 -0
  12. data/Rakefile +10 -0
  13. data/bin/console +11 -0
  14. data/bin/fir +14 -0
  15. data/bin/setup +7 -0
  16. data/doc/help.md +34 -0
  17. data/doc/info.md +44 -0
  18. data/doc/install.md +67 -0
  19. data/doc/login.md +19 -0
  20. data/doc/publish.md +35 -0
  21. data/doc/upgrade.md +7 -0
  22. data/fir-cli.gemspec +52 -0
  23. data/fir.sh +46 -0
  24. data/install.sh +210 -0
  25. data/lib/fir-cli.rb +3 -0
  26. data/lib/fir.rb +28 -0
  27. data/lib/fir/api.yml +7 -0
  28. data/lib/fir/cli.rb +181 -0
  29. data/lib/fir/patches.rb +10 -0
  30. data/lib/fir/patches/blank.rb +131 -0
  31. data/lib/fir/patches/concern.rb +146 -0
  32. data/lib/fir/patches/default_headers.rb +9 -0
  33. data/lib/fir/patches/hash.rb +79 -0
  34. data/lib/fir/patches/instance_variables.rb +30 -0
  35. data/lib/fir/patches/native_patch.rb +28 -0
  36. data/lib/fir/patches/os_patch.rb +28 -0
  37. data/lib/fir/patches/try.rb +102 -0
  38. data/lib/fir/util.rb +86 -0
  39. data/lib/fir/util/build_apk.rb +77 -0
  40. data/lib/fir/util/build_common.rb +93 -0
  41. data/lib/fir/util/build_ipa.rb +11 -0
  42. data/lib/fir/util/config.rb +43 -0
  43. data/lib/fir/util/http.rb +23 -0
  44. data/lib/fir/util/info.rb +38 -0
  45. data/lib/fir/util/login.rb +17 -0
  46. data/lib/fir/util/mapping.rb +98 -0
  47. data/lib/fir/util/me.rb +19 -0
  48. data/lib/fir/util/parser/apk.rb +46 -0
  49. data/lib/fir/util/parser/bin/pngcrush +0 -0
  50. data/lib/fir/util/parser/common.rb +24 -0
  51. data/lib/fir/util/parser/ipa.rb +188 -0
  52. data/lib/fir/util/parser/pngcrush.rb +23 -0
  53. data/lib/fir/util/publish.rb +253 -0
  54. data/lib/fir/version.rb +5 -0
  55. data/lib/fir/xcode_wrapper.sh +29 -0
  56. data/lib/fir_cli.rb +3 -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 +273 -0
data/doc/help.md ADDED
@@ -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` 查看相关命令帮助
data/doc/info.md ADDED
@@ -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
+ ```
data/doc/install.md ADDED
@@ -0,0 +1,67 @@
1
+ ### 安装
2
+
3
+ fir-cli 使用 Ruby 构建, 无需编译, 只要安装相应 gem 即可.
4
+
5
+ ```sh
6
+ $ ruby -v # > 2.6.1
7
+ $ gem install fir-cli
8
+ ```
9
+
10
+ #### 常见的安装问题
11
+
12
+ - ruby 要求最低版本为 2.3
13
+
14
+ - 使用系统自带的 Ruby 安装, 需确保 ruby-dev 已被正确的安装:
15
+
16
+ ```sh
17
+ $ xcode-select --install # OS X 系统
18
+ $ sudo apt-get install ruby-dev # Linux 系统
19
+ ```
20
+
21
+ - 出现 `Permission denied` 相关错误:
22
+
23
+ 在命令前加上 `sudo`
24
+
25
+ - 出现 `Gem::RemoteFetcher::FetchError` 相关错误:
26
+
27
+ 更换 Ruby 的源(由于国内网络原因, 你懂的), 并升级下系统自带的 gem
28
+
29
+ ```sh
30
+ $ gem sources --remove https://rubygems.org/
31
+ $ gem sources -a https://gems.ruby-china.com/
32
+ $ gem sources -l
33
+ *** CURRENT SOURCES ***
34
+
35
+ https://gems.ruby-china.com
36
+ # 请确保只有 gems.ruby-china.com, 如果有其他的源, 请 remove 掉
37
+
38
+ gem update --system
39
+ gem install fir-cli
40
+ ```
41
+
42
+ - Mac OS X 10.11 以后的版本, 由于10.11引入了 `rootless`, 无法直接安装 fir-cli, 有以下三种解决办法:
43
+
44
+ 1\. 使用 [Homebrew](http://brew.sh/) 及 [RVM](https://rvm.io/) 安装 Ruby, 再安装 fir-cli(推荐)
45
+
46
+ ```sh
47
+ # Install Homebrew:
48
+ $ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
49
+
50
+ # Install RVM:
51
+ $ \curl -sSL https://get.rvm.io | bash -s stable --ruby
52
+
53
+ $ gem install fir-cli
54
+ ```
55
+
56
+ 2\. 指定 fir-cli 中 bin 文件的 PATH
57
+
58
+ ```sh
59
+ $ export PATH=/usr/local/bin:$PATH;gem install -n /usr/local/bin fir-cli
60
+ ```
61
+
62
+ 3\. 重写 Ruby Gem 的 bindir
63
+
64
+ ```sh
65
+ $ echo 'gem: --bindir /usr/local/bin' >> ~/.gemrc
66
+ $ gem install fir-cli
67
+ ```
data/doc/login.md ADDED
@@ -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
+ ```
data/doc/publish.md ADDED
@@ -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
+ [--open], [--no-open] # true/false if open for everyone
15
+ [--password=PASSWORD] # Set password for app
16
+ -T, [--token=TOKEN] # User's API Token at fir.im
17
+ -L, [--logfile=LOGFILE] # Path to writable logfile
18
+ -R, [--need_release_id] # show release_id in download_url
19
+ -D, [--dingtalk_accesss_token=DINGTALK_ACCESS_TOKEN] # dingtalk notification
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
+ - `-R` 参数, 显示具体版本, 会在发布结束后的下载地址中生成指定的版本
32
+ - `-D` 参数, 钉钉机器人的access_token, 填写后当上传完毕, 会发送至钉钉机器人
33
+ - `--open` 参数, 设置发布后的应用是否开放给所有人下载, 关闭开放使用 `--no-open` 参数.
34
+ - `--password` 参数, 设置发布后的应用密码
35
+
data/doc/upgrade.md ADDED
@@ -0,0 +1,7 @@
1
+ #### fir upgrade
2
+
3
+ `fir upgrade` 指令用于升级最新版本的 fir-cli
4
+
5
+ ```sh
6
+ $ fir upgrade
7
+ ```
data/fir-cli.gemspec ADDED
@@ -0,0 +1,52 @@
1
+ # coding: utf-8
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'fir/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'fir-cli-x'
9
+ spec.version = FIR::VERSION
10
+ spec.authors = ['sparkrico','NaixSpirit', 'atpking']
11
+ spec.email = ['sparkrico@gmail.com']
12
+ spec.date = Time.now.strftime('%Y-%m-%d')
13
+ spec.summary = 'fir.im command tool'
14
+ spec.description = 'fir.im command tool, support iOS and Android'
15
+ spec.homepage = 'https://github.com/sparkrico/fir-cli'
16
+ spec.license = 'MIT'
17
+ spec.files = `git ls-files -z`.split("\x0")
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.post_install_message = %q(
23
+ ______________ ________ ____
24
+ / ____/ _/ __ \ / ____/ / / _/
25
+ / /_ / // /_/ /_____/ / / / / /
26
+ / __/ _/ // _, _/_____/ /___/ /____/ /
27
+ /_/ /___/_/ |_| \____/_____/___/
28
+
29
+ ## 更新记录
30
+ - (1.7.2.1) 修复label nil 的问题,更新了ruby_android_apk库
31
+ - (1.7.2) 修正了无论是否加参数都固定出现二维码图片的bug
32
+ - (1.7.1) 增加了 钉钉推送 , 增加了返回指定版本下载地址
33
+ - (1.7.0) 过期了ipa_build 功能, 增加了对 android manifest instant run 的兼容
34
+ - (1.6.13) 上传图标逻辑修改
35
+ - (1.6.12) 修复了部分机器没有默认安装 byebug 的问题
36
+ - (1.6.11) 变化了 ruby gem 仓库地址
37
+ - [fir-cli](https://github.com/firhq/fir-cli) 已经开源
38
+ - 欢迎 fork, issue 和 pull request
39
+ )
40
+
41
+ spec.add_development_dependency 'bundler'
42
+ spec.add_development_dependency 'rake'
43
+ spec.add_development_dependency 'minitest', '~> 5.7'
44
+ spec.add_development_dependency 'pry', '~> 0.10'
45
+
46
+ spec.add_dependency 'thor', '~> 0.19'
47
+ spec.add_dependency 'rest-client', '~> 2.0'
48
+ spec.add_dependency 'ruby_android_apk', '~> 0.7.7.1'
49
+ spec.add_dependency 'rqrcode', '~> 0.7'
50
+ spec.add_dependency 'CFPropertyList'
51
+ spec.add_dependency 'api_tools', '~> 0.1.0'
52
+ end
data/fir.sh ADDED
@@ -0,0 +1,46 @@
1
+ #!/bin/sh
2
+ # because fir-cli dependent ruby enviroment, this shell is dependent ruby docker
3
+ # so xcode and gradle not use
4
+ # this shell only use to publish apk or ipa , build is not run
5
+ # fir publish **.apk
6
+ # echo $(curl https://raw.githubusercontent.com/FIRHQ/fir-cli/master/fir.sh) > /usr/local/bin/fir
7
+
8
+ mountFolder=$HOME/fir-cli/data
9
+ destFolder=/fir-cli
10
+
11
+ mkdir -p $mountFolder
12
+
13
+ # find path file name
14
+ function findFileName() {
15
+ echo ${1##*/}
16
+ }
17
+
18
+ # move file to mount folder
19
+ tmpFiles=()
20
+ cmds=()
21
+ for i in $@; do
22
+ if [ -d $i ];then
23
+ cp -r $i $mountFolder
24
+ elif [ -f $i ];then
25
+ cp $i $mountFolder
26
+ else
27
+ cmds+=($i)
28
+ continue
29
+ fi
30
+ destFile=$destFolder/$(findFileName $i)
31
+ cmds+=($destFile)
32
+ tmpFiles+=($mountFolder/$(findFileName $i))
33
+ done
34
+
35
+ # start docker to run fir cmd
36
+ docker run -v $HOME/fir-cli/data:/fir-cli flowci/fir-cli fir ${cmds[@]}
37
+
38
+ # clean folder
39
+ for i in ${tmpFiles}; do
40
+ if [ -d $i ];then
41
+ rm -rf $i
42
+ elif [ -f $i ];then
43
+ rm $i
44
+ fi
45
+ done
46
+
data/install.sh ADDED
@@ -0,0 +1,210 @@
1
+ #!/usr/bin/env bash
2
+ #
3
+ # Copy from: ruby-bootstrap.sh
4
+ # Description: This script bootstraps rvm, Ruby
5
+
6
+ RVM_FRESH_INSTALL=0 # 0=false, 1=true
7
+ MIRROR_CHINA_INSTALL=1 # 0=false, 1=true
8
+
9
+
10
+ ###
11
+ ### Helper variables and functions
12
+ ###
13
+
14
+ # Make the operating system of this host available as $OS.
15
+ OS_UNKNOWN="os-unknown"
16
+ OS_MAC="mac"
17
+ OS_LINUX="linux"
18
+ case `uname` in
19
+ Linux*)
20
+ OS=$OS_LINUX
21
+ ;;
22
+ Darwin*)
23
+ OS=$OS_MAC
24
+ ;;
25
+ *)
26
+ OS=$OS_UNKNOWN
27
+ ;;
28
+ esac
29
+
30
+ # Colors for shell output
31
+ if [ "$OS" = "$OS_MAC" ]; then
32
+ red='\x1B[1;31m'
33
+ green='\x1B[1;32m'
34
+ yellow='\x1B[1;33m'
35
+ blue='\x1B[1;34m'
36
+ nocolor='\x1B[0m'
37
+ else
38
+ red='\e[1;31m'
39
+ green='\e[1;32m'
40
+ yellow='\e[1;33m'
41
+ blue='\e[1;34m'
42
+ nocolor='\e[0m'
43
+ fi
44
+
45
+ function puts() {
46
+ local opts=''
47
+ if [ "$1" = "-n" ]; then
48
+ opts='-n'
49
+ shift
50
+ fi
51
+ msg="$@"
52
+ echo -e $opts "${blue}${msg}${nocolor}"
53
+ }
54
+
55
+ function warn() {
56
+ local opts=''
57
+ if [ "$1" = "-n" ]; then
58
+ opts='-n'
59
+ shift
60
+ fi
61
+ msg="$@"
62
+ echo -e $opts "${yellow}${msg}${nocolor}"
63
+ }
64
+
65
+ function error() {
66
+ local opts=''
67
+ if [ "$1" = "-n" ]; then
68
+ opts='-n'
69
+ shift
70
+ fi
71
+ msg="$@"
72
+ echo -e $opts "${red}${msg}${nocolor}"
73
+ }
74
+
75
+ function success() {
76
+ local opts=''
77
+ if [ "$1" = "-n" ]; then
78
+ opts='-n'
79
+ shift
80
+ fi
81
+ msg="$@"
82
+ echo -e $opts "${green}${msg}${nocolor}"
83
+ }
84
+
85
+ function rvm_post_install_message() {
86
+ warn "Important: We performed a fresh install of rvm for you."
87
+ warn " This means you manually perform two tasks now."
88
+ warn
89
+ warn "Task 1 of 2:"
90
+ warn "------------"
91
+ warn "Please run the following command in all your open shell windows to"
92
+ warn "start using rvm. In rare cases you need to reopen all shell windows."
93
+ warn
94
+ warn " source ~/.rvm/scripts/rvm"
95
+ warn
96
+ warn
97
+ warn "Task 2 of 2:"
98
+ warn "------------"
99
+ warn "Permanently update your shell environment to source/add rvm."
100
+ warn "The example below shows how to do this for Bash."
101
+ warn
102
+ warn "Add the following two lines to your ~/.bashrc:"
103
+ warn
104
+ warn " PATH=\$PATH:\$HOME/.rvm/bin # Add RVM to PATH for scripting"
105
+ warn " [[ -s \"\$HOME/.rvm/scripts/rvm\" ]] && source \"\$HOME/.rvm/scripts/rvm\" # Load RVM into a shell session *as a function*"
106
+ warn
107
+ warn "That's it! Sorry for the extra work but this is the safest"
108
+ warn "way to update your environment without breaking anything."
109
+ }
110
+
111
+ function find_ruby_version_file() {
112
+ local filename=".ruby-version"
113
+ local curr_dir=$1
114
+ curr_dir=`cd "$curr_dir"; pwd`
115
+ local candidate_file="$curr_dir/$filename"
116
+ while [ ! -f "$candidate_file" ]; do
117
+ parent_dir=`cd ..; pwd`
118
+ if [ "$parent_dir" = "$curr_dir" ]; then
119
+ # We have reached /, we can't go up any further.
120
+ candidate_file=""
121
+ break
122
+ else
123
+ curr_dir="$parent_dir"
124
+ candidate_file="$curr_dir/$filename"
125
+ fi
126
+ done
127
+ echo $candidate_file
128
+ }
129
+
130
+ function detect_desired_ruby_version() {
131
+ local desired_ruby_version=""
132
+ ruby_version_file=`find_ruby_version_file $(pwd)`
133
+ if [ -n "$ruby_version_file" ]; then
134
+ desired_ruby_version=`head -n 1 $ruby_version_file`
135
+ fi
136
+ echo $desired_ruby_version
137
+ }
138
+
139
+ # We must detect the desired Ruby version before rvm "manipulates" the shell environment for its own purposes.
140
+ # I assume the cause of the problem is rvm's variant of the 'cd' command (~/.rvm/scripts/cd), which may alter the
141
+ # normal behavior of 'cd' in a way that breaks our usage of 'cd' in the function 'find_ruby_version_file' above.
142
+ puts -n "Detecting desired Ruby version: "
143
+
144
+ RUBY_VERSION=`detect_desired_ruby_version`
145
+
146
+ if [ -z "$RUBY_VERSION" ]; then
147
+ warn "FAILED (could not find .ruby-version) -- falling back to latest stable Ruby version"
148
+ RUBY_VERSION="ruby" # 'ruby' defaults to latest stable version
149
+ else
150
+ success "OK ($RUBY_VERSION)"
151
+ fi
152
+
153
+
154
+ ###
155
+ ### Bootstrap RVM
156
+ ###
157
+ puts -n "Checking for rvm: "
158
+ which rvm &>/dev/null
159
+ if [ $? -ne 0 ]; then
160
+ error "NOT FOUND (If you already ran ruby-bootstrap: have you performed the post-installation steps?)"
161
+ puts "Installing latest stable version of rvm..."
162
+ RVM_FRESH_INSTALL=1
163
+ curl -L https://get.rvm.io | bash -s stable --autolibs=enable --ignore-dotfiles || exit 1
164
+ else
165
+ success "OK"
166
+ fi
167
+
168
+ if [ -d ~/.rvm/bin ]; then
169
+ PATH=$PATH:~/.rvm/bin
170
+ fi
171
+
172
+ source ~/.rvm/scripts/rvm
173
+
174
+ if [ $MIRROR_CHINA_INSTALL -eq 1 ]; then
175
+ echo "ruby_url=https://cache.ruby-china.org/pub/ruby" > ~/.rvm/user/db
176
+ fi
177
+ ###
178
+ ### Install Ruby
179
+ ###
180
+ puts "Installing Ruby version ${RUBY_VERSION}..."
181
+
182
+ rvm install $RUBY_VERSION
183
+
184
+ if [ $? -ne 0 -a $RVM_FRESH_INSTALL -eq 1 ]; then
185
+ rvm_post_install_message
186
+ exit 2
187
+ fi
188
+ if [ $MIRROR_CHINA_INSTALL -eq 1 ]; then
189
+ gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/
190
+ fi
191
+
192
+ ###
193
+ ### Install Bundler
194
+ ###
195
+ puts "Installing bundler..."
196
+ gem install bundler
197
+ if [ $? -ne 0 -a $RVM_FRESH_INSTALL -eq 1 ]; then
198
+ rvm_post_install_message
199
+ exit 3
200
+ fi
201
+
202
+ puts "Installing fir-cli gem"
203
+ gem install fir-cli --no-rdoc --no-ri
204
+ if [ $? -ne 0 -a $RVM_FRESH_INSTALL -eq 1 ]; then
205
+ rvm_post_install_message
206
+ exit 4
207
+ fi
208
+
209
+
210
+ puts "run fir -v to check"