diff --git a/CHANGELOG b/CHANGELOG index 6a3fc98..42342e8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ ## 更新记录 +### fir-cli 1.5.0 +- 取消 --open 默认值 + ### fir-cli 1.4.9 - 修正 --password 与 --open 冲突的问题 diff --git a/doc/publish.md b/doc/publish.md index c2e860b..c467ec6 100644 --- a/doc/publish.md +++ b/doc/publish.md @@ -13,8 +13,7 @@ Options: -Q, [--qrcode], [--no-qrcode] # Generate qrcode -m, [--mappingfile=MAPPINGFILE] # App mapping file -P, [--proj=PROJ] # Project id in BugHD.com if upload app mapping file - [--open], [--no-open] # true/false if open for everyone, the default is: true - # Default: true + [--open], [--no-open] # true/false if open for everyone [--password=PASSWORD] # Set password for app -T, [--token=TOKEN] # User's API Token at fir.im -L, [--logfile=LOGFILE] # Path to writable logfile @@ -31,6 +30,6 @@ Options: - `-Q` 参数, 是否生成发布后二维码, 默认为不生成, 加上 `-Q` 参数后会在当前目录生成一张二维码图片, 扫描该图片即可下载该应用. - `-m` 参数, 上传当前应用的符号表文件, 配合 `-P` 参数使用. - `-P` 参数, [BugHD.com](http://bughd.com) 上相对应的 Project id. -- `--open` 参数, 设置发布后的应用是否开放给所有人下载, 默认为开放, 关闭开放使用 `--no-open` 参数. +- `--open` 参数, 设置发布后的应用是否开放给所有人下载, 关闭开放使用 `--no-open` 参数. - `--password` 参数, 设置发布后的应用密码 diff --git a/fir-cli.gemspec b/fir-cli.gemspec index c77a2eb..f161bc9 100644 --- a/fir-cli.gemspec +++ b/fir-cli.gemspec @@ -27,7 +27,7 @@ Gem::Specification.new do |spec| /_/ /___/_/ |_| \____/_____/___/ ## 更新记录 - ### fir-cli 1.4.9 + ### fir-cli 1.5.0 - 修正 build 后直接 -p 发布的权限错误 - 增加上传时候设置密码及公开访问权限 - 增加 build_ipa 中的 destination 参数 diff --git a/lib/fir/cli.rb b/lib/fir/cli.rb index c92a845..5434e74 100644 --- a/lib/fir/cli.rb +++ b/lib/fir/cli.rb @@ -40,7 +40,7 @@ module FIR method_option :qrcode, type: :boolean, aliases: '-Q', desc: 'Generate qrcode' method_option :mapping, type: :boolean, aliases: '-M', desc: 'true/false if upload app mapping file to BugHD.com' method_option :proj, type: :string, aliases: '-P', desc: 'Project id in BugHD.com if upload app mapping file' - method_option :open, type: :boolean, desc: 'true/false if open for everyone, the default is: true', default: true + method_option :open, type: :boolean, desc: 'true/false if open for everyone' method_option :password, type: :string, desc: 'Set password for app' def build_ipa(*args) prepare :build_ipa @@ -106,7 +106,7 @@ module FIR method_option :qrcode, type: :boolean, aliases: '-Q', desc: 'Generate qrcode' method_option :mappingfile, type: :string, aliases: '-m', desc: 'App mapping file' method_option :proj, type: :string, aliases: '-P', desc: 'Project id in BugHD.com if upload app mapping file' - method_option :open, type: :boolean, desc: 'true/false if open for everyone, the default is: true', default: true + method_option :open, type: :boolean, desc: 'true/false if open for everyone' method_option :password, type: :string, desc: 'Set password for app' def publish(*args) prepare :publish diff --git a/lib/fir/util/build_common.rb b/lib/fir/util/build_common.rb index 002df76..644f1d1 100644 --- a/lib/fir/util/build_common.rb +++ b/lib/fir/util/build_common.rb @@ -47,7 +47,11 @@ module FIR FileUtils.mkdir_p(output_path) unless File.exist?(output_path) output_path else - File.absolute_path(options[:output].to_s) + output_path = options[:output].to_s + unless File.exist?(output_path) + logger.warn "The output path not exist and fir-cli will autocreate it..." + end + File.absolute_path(output_path) end end diff --git a/lib/fir/util/config.rb b/lib/fir/util/config.rb index 2e7782d..01b958f 100644 --- a/lib/fir/util/config.rb +++ b/lib/fir/util/config.rb @@ -3,6 +3,7 @@ module FIR module Config CONFIG_PATH = "#{ENV['HOME']}/.fir-cli" + APP_INFO_PATH = "#{ENV['HOME']}/.fir-cli-app" API_YML_PATH = File.expand_path('../../', __FILE__) + '/api.yml' APP_FILE_TYPE = %w(.ipa .apk).freeze @@ -27,6 +28,10 @@ module FIR File.open(CONFIG_PATH, 'w+') { |f| f << YAML.dump(hash) } end + def write_app_info(hash) + File.open(APP_INFO_PATH, 'w+') { |f| f << YAML.dump(hash) } + end + def current_token @token ||= config[:token] if config end diff --git a/lib/fir/util/parser/apk.rb b/lib/fir/util/parser/apk.rb index f69816b..d04ff94 100644 --- a/lib/fir/util/parser/apk.rb +++ b/lib/fir/util/parser/apk.rb @@ -31,7 +31,11 @@ module FIR # @apk.icon is a hash, { icon_name: icon_binary_data } def tmp_icons - @apk.icon.map { |_, data| generate_tmp_icon(data, :apk) } + begin + @apk.icon.map { |_, data| generate_tmp_icon(data, :apk) } + rescue + [] + end end end end diff --git a/lib/fir/util/publish.rb b/lib/fir/util/publish.rb index 64fc611..c775fd9 100644 --- a/lib/fir/util/publish.rb +++ b/lib/fir/util/publish.rb @@ -40,6 +40,7 @@ module FIR upload_app_binary upload_device_info update_app_info + fetch_app_info end def upload_app_icon @@ -123,7 +124,9 @@ module FIR def fetch_app_info logger.info 'Fetch app info from fir.im' - get fir_api[:app_url] + "/#{@app_id}", api_token: @token + @fir_app_info = get(fir_api[:app_url] + "/#{@app_id}", api_token: @token) + write_app_info(id: @fir_app_info[:id], short: @fir_app_info[:short], name: @fir_app_info[:name]) + @fir_app_info end def upload_mapping_file_with_publish(options) @@ -138,7 +141,7 @@ module FIR end def logger_info_app_short_and_qrcode - short = "#{fir_api[:domain]}/#{fetch_app_info[:short]}" + short = "#{fir_api[:domain]}/#{@fir_app_info[:short]}" logger.info "Published succeed: #{short}" @@ -159,7 +162,7 @@ module FIR @changelog = read_changelog(options[:changelog]).to_s.to_utf8 @short = options[:short].to_s @passwd = options[:password].to_s - @is_opened = @passwd.blank? ? !!options[:open] : false + @is_opened = @passwd.blank? ? options[:open] : false @export_qrcode = !!options[:qrcode] end diff --git a/lib/fir/version.rb b/lib/fir/version.rb index 2eb2e29..ee38bda 100644 --- a/lib/fir/version.rb +++ b/lib/fir/version.rb @@ -1,5 +1,5 @@ # encoding: utf-8 module FIR - VERSION = '1.4.9' + VERSION = '1.5.0' end