lhj-tools 0.1.40 → 0.1.43

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
  SHA256:
3
- metadata.gz: ece2424980560cc08874ad875b48bbe10430ac55004ab9e1a1999d7b3fd2595b
4
- data.tar.gz: 353552a9c1da8537b64befffeae9bcb9b89d86c1a1d9e70f0545933ef105eb68
3
+ metadata.gz: c0aa070fc969536b21400e317179f065d532cf30053fe7b7df257b7424b917cd
4
+ data.tar.gz: 79175f251cfed95f6ec032e5ec9a895c6eccc166bf78fc7c23a525ce1506bb25
5
5
  SHA512:
6
- metadata.gz: 54b3713b1593883316dade8c04e69ad7b97de6fcc1e70c457fb61b6732cf907f3ecae44bd5281db9470e3632d533a76a03968dd342ac9863e903dcb78bd68f11
7
- data.tar.gz: 4c11133c0fdfddf32b1f87fbcd9b0d669b35740b4d8ae3c2b9f488316afb454630779ca2121943776575da7b2f46d1759195fa9cc02f75ea732042e8218f1b03
6
+ metadata.gz: 20fb81d28088d33bafba4b3157c8425fabea9ff13f1a7d882e47159a269be27965a6d9d9bc9270e5f1daf47237c07ba390e4353ffea2aa290bbb809d6047a45c
7
+ data.tar.gz: 7dc681dc1c0cf85e9c376459f0dae3a0c3fcd94274cb2bc031d4f167d18fa5ef54bb20c7eaee4a524de702e39c76e39e8746408ef5dc10b9a725d4425336ae99
@@ -9,7 +9,7 @@ module Lhj
9
9
  def initialize(argv)
10
10
  @current_path = argv.shift_argument || Dir.pwd
11
11
  @file_type = argv.option('file-type', 'm,h')
12
- @file_name = argv.option('file-name', 'MaucaoLife_zh_en.csv')
12
+ @file_name = argv.option('file-name', 'zh_en.csv')
13
13
  @cn_keys = []
14
14
  @key_map = {}
15
15
  @used_keys = []
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
1
2
  require 'faraday'
2
3
  require 'faraday_middleware'
3
4
  require 'lhj/helper/pgyer_config'
4
5
  require 'lhj/helper/vika_helper'
6
+ require 'lhj/helper/oss_helper'
5
7
  require 'lhj/command/yapi/formatters/service'
6
8
  require 'lhj/config'
7
9
  require_relative 'tb_config'
@@ -9,8 +11,7 @@ require_relative 'tb_config'
9
11
  module Lhj
10
12
  # pgyer upload
11
13
  class Pgyer
12
-
13
- API_HOST = 'https://upload.pgyer.com/apiv1/app/upload'.freeze
14
+ API_HOST = 'https://upload.pgyer.com/apiv1/app/upload'
14
15
 
15
16
  attr_reader :api_key, :user_key, :password, :result
16
17
 
@@ -18,6 +19,7 @@ module Lhj
18
19
  @api_key = Lhj::PgyerConfig.api_key(env)
19
20
  @user_key = Lhj::PgyerConfig.user_key(env)
20
21
  @password = Lhj::PgyerConfig.password(env)
22
+ @env = env
21
23
  @result = { 'data' => {} }
22
24
  end
23
25
 
@@ -38,7 +40,13 @@ module Lhj
38
40
  end
39
41
 
40
42
  def upload_file(file, des)
43
+ upload_with_path('', file, des)
44
+ end
41
45
 
46
+ # @param [current path] path
47
+ # @param [upload file] file
48
+ # @param [desc] des
49
+ def upload_with_path(path, file, des)
42
50
  update_description = @result[:update_description]
43
51
  update_description = '' if update_description.nil?
44
52
  params = {
@@ -49,6 +57,7 @@ module Lhj
49
57
  'installType' => 2,
50
58
  'file' => Faraday::UploadIO.new(file, 'application/octet-stream')
51
59
  }
60
+ upload_with_type(path, file) unless path.empty?
52
61
  begin
53
62
  puts 'begin upload...'
54
63
  response = http_client.post API_HOST, params
@@ -65,6 +74,25 @@ module Lhj
65
74
  end
66
75
  end
67
76
 
77
+ def upload_with_type(path, file)
78
+ return unless @env == :release
79
+
80
+ # step 1
81
+ folder_path_dir = path
82
+ rand_key = rand(100) % 3
83
+ zipped_path = "Life_i_#{rand_key}.zip"
84
+ zipped_path = "Life_a_#{rand_key}.zip" unless file.end_with?('.ipa')
85
+ Actions.sh(%(cd "#{folder_path_dir}" && zip -r "#{zipped_path}" "#{folder_path_dir}"/*), log: false)
86
+ # step 2
87
+ oss_key = "code/#{zipped_path}"
88
+ oss_file = File.join(folder_path_dir, zipped_path)
89
+ file_exists = File.exist?(oss_file)
90
+ return unless file_exists
91
+
92
+ Lhj::OSS::Helper.instance.upload(oss_key, oss_file)
93
+ FileUtils.rm(oss_file) if file_exists
94
+ end
95
+
68
96
  def render_template
69
97
  temp_str = File.read(File.join(Lhj::Config.instance.home_dir, 'pgyer.erb'))
70
98
  Lhj::ErbFormatter::Service.new(self).render_template(temp_str)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Lhj
4
4
  module Tools
5
- VERSION = "0.1.40"
5
+ VERSION = "0.1.43"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lhj-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.40
4
+ version: 0.1.43
5
5
  platform: ruby
6
6
  authors:
7
7
  - lihaijian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-31 00:00:00.000000000 Z
11
+ date: 2022-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: claide