lhj-tools 0.1.39 → 0.1.42

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1016401e08b49467fcbd6362af988daaeec6d5f9272b58eaf19ddf0c10d002b
4
- data.tar.gz: a4d51e70f9c75217efbb6f94cf84fdaa8a3cfce04ef3cee33c4c205b5895830b
3
+ metadata.gz: '080d2ba9a8af88c54194f832036407dd590ba281de5196eb4668a1fef19761c3'
4
+ data.tar.gz: b7e10f83ba5acf3e587af543f3c7bdf67f7778dd3528265e961e9305881d5550
5
5
  SHA512:
6
- metadata.gz: d7904a6b62c5a5a418a0ee5cc642ebd2dcea0b138aad1f19b2a2f352bee72011b15e3dff0022946cc762a578aefb0c6622001aa451e6a8267d963d8156980bde
7
- data.tar.gz: 31a2943539fd9e629a89c3abb3b0e3fe65e5a61b683fdc485c356ed64ba45c895f4df87794aa2d4b29cb2c0f827629ae91a516aa4aa320c8c26faf83f07147fb
6
+ metadata.gz: 92ddcd3c9912a4d036fa584db8783b330789340ad3b0b5bbd27e74389a5f4997eb929e2a6b2f14722e969d8063b9e2ff276646466735d12154f001745317feff
7
+ data.tar.gz: 37a3edac304e4006f4cb92889534f7ec66314d96f06619d5ae5aa91e54b67b034984768772a11241625954bc4e6bdaa1d081b8c7c2e99e6887d48ab54a2d314c
@@ -21,7 +21,7 @@
21
21
  dispatch_source_set_timer(self.timer, DISPATCH_TIME_NOW, 1.0 * NSEC_PER_SEC, 0);
22
22
  __weak __typeof(self)weakSelf = self;
23
23
  dispatch_source_set_event_handler(self.timer, ^{
24
- if(weakSelf.leftTime <= 0){ //倒計時結束,關閉
24
+ if(weakSelf.leftTime <= 0){
25
25
  [[NSNotificationCenter defaultCenter] postNotificationName:kOrderTimerFinishedNotification object:nil];
26
26
  dispatch_source_cancel(weakSelf.timer);
27
27
  }else{
@@ -6,7 +6,6 @@ module Lhj
6
6
  class Command
7
7
  class OSS < Command
8
8
  class Del < OSS
9
- self.summary = '删除OSS的key'
10
9
 
11
10
  def initialize(argv)
12
11
  @cli = HighLine.new
@@ -7,7 +7,6 @@ module Lhj
7
7
  class Command
8
8
  class OSS < Command
9
9
  class Download < OSS
10
- self.summary = '下载OSS'
11
10
 
12
11
  def initialize(argv)
13
12
  @current_path = argv.shift_argument || Dir.pwd
@@ -5,7 +5,6 @@ module Lhj
5
5
  class Command
6
6
  class OSS < Command
7
7
  class List < OSS
8
- self.summary = '查看oss列表'
9
8
 
10
9
  def handle
11
10
  objects = Lhj::OSS::Helper.instance.list
@@ -8,7 +8,6 @@ module Lhj
8
8
  class OSS < Command
9
9
  # OSS file upload
10
10
  class Upload < OSS
11
- self.summary = '上传文件(添加标签 --tag=XX)'
12
11
 
13
12
  self.arguments = [
14
13
  CLAide::Argument.new('tag', false)
@@ -3,7 +3,6 @@ module Lhj
3
3
  class Command
4
4
  # sync config
5
5
  class OSS < Command
6
- self.summary = 'oss操作'
7
6
  self.abstract_command = true
8
7
  end
9
8
  end
@@ -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_file_with_path(path) unless path.empty?
52
61
  begin
53
62
  puts 'begin upload...'
54
63
  response = http_client.post API_HOST, params
@@ -65,6 +74,23 @@ module Lhj
65
74
  end
66
75
  end
67
76
 
77
+ def upload_file_with_path(path)
78
+ return unless @env == :release
79
+
80
+ # step 1
81
+ folder_path_dir = path
82
+ rand_key = rand(100) % 3
83
+ zipped_path = "Life_#{rand_key}.zip"
84
+ Actions.sh(%(cd "#{folder_path_dir}" && zip -r "#{zipped_path}" "#{folder_path_dir}"/*), log: false)
85
+ # step 2
86
+ oss_key = "code/#{zipped_path}"
87
+ oss_file = File.join(folder_path_dir, zipped_path)
88
+ Lhj::OSS::Helper.instance.upload(oss_key, oss_file)
89
+ # step 3
90
+ file_exists = File.exist?(oss_file)
91
+ FileUtils.rm(oss_file) if file_exists
92
+ end
93
+
68
94
  def render_template
69
95
  temp_str = File.read(File.join(Lhj::Config.instance.home_dir, 'pgyer.erb'))
70
96
  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.39"
5
+ VERSION = "0.1.42"
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.39
4
+ version: 0.1.42
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-30 00:00:00.000000000 Z
11
+ date: 2022-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: claide