fastlane-plugin-google_drive 0.3.0 → 0.7.0

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: 98e80910c3c134ed316765f0a4bdcf2a4915010afdcf52eab33f6a84b6243731
4
- data.tar.gz: 51e457c7f9188d4609920a4cab910085b8447fc02577075222b6b129bca680b3
3
+ metadata.gz: 44942219aaa17b4d9a44c506c0384ac196d809842b708837845e5e610681580a
4
+ data.tar.gz: fdbef59ccb0f057d38e6799e5162d3d3cb0cdbd62df044887c926cb10b49b6da
5
5
  SHA512:
6
- metadata.gz: 1eefa32898e4441139bcd4ee703cad60deb0563af1dea62cff04405636082511eccba7c9d8ede7e09e32343841d24be0da4534aa3eeff6344ed6dd6c4144dd75
7
- data.tar.gz: 7bcf83c2ed587f7333aa54f2a14af39c9d41ccf057cc7dee39f8ac8129ddb73372a4d497346f1f86cb9f0fa65e35d05c0947860f14fa4bf67cfd1d258cc50304
6
+ metadata.gz: 7c582fc5b94bb250aa5bb07eb44a161612055865e1b3b39a2d34c2242f25cf8e54a9e5836c9d4abbf663533fb6fa94b5042cb6ecc42e3293e1513f6041878713
7
+ data.tar.gz: 6545338ab81664c5c05990f7449a400d76acebac6b4908a77a397113521611b02dd88426fa7a4377ed8842a7b71fdecc9d958dece7a644350777864c4344a135
data/README.md CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-google_drive)
4
4
  [![Gem Version Badge](https://badge.fury.io/rb/fastlane-plugin-google_drive.svg)](https://badge.fury.io/rb/fastlane-plugin-google_drive)
5
- [![Build Status](https://travis-ci.org/bskim45/fastlane-plugin-google_drive.svg?branch=master)](https://travis-ci.org/bskim45/fastlane-plugin-google_drive)
5
+ [![Build Status](https://travis-ci.com/bskim45/fastlane-plugin-google_drive.svg?branch=master)](https://travis-ci.com/bskim45/fastlane-plugin-google_drive)
6
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/681ab1f5c19ca029dff4/test_coverage)](https://codeclimate.com/github/bskim45/fastlane-plugin-google_drive/test_coverage)
7
+ [![security](https://hakiri.io/github/bskim45/fastlane-plugin-google_drive/master.svg)](https://hakiri.io/github/bskim45/fastlane-plugin-google_drive/master)
6
8
 
7
9
  ## Getting Started
8
10
 
@@ -14,6 +16,11 @@ fastlane add_plugin google_drive
14
16
 
15
17
  ## About google_drive
16
18
 
19
+ > Please refer to [this guide](https://github.com/gimite/google-drive-ruby/blob/master/doc/authorization.md) to create an Google Drive credential.
20
+
21
+ Upload files to Google Drive folder.
22
+ > Aliases for this action - `google_drive_upload` and `upload_google_drive` are both removed in `v0.6.0`.
23
+
17
24
  ```ruby
18
25
  upload_to_google_drive(
19
26
  drive_keyfile: 'drive_key.json',
@@ -23,8 +30,7 @@ upload_to_google_drive(
23
30
  )
24
31
  ```
25
32
 
26
- Upload files to Google Drive folder.
27
- You can also use `google_drive_upload` or `upload_google_drive` as aliases.
33
+ Create new Google Drive folder:
28
34
 
29
35
  ```ruby
30
36
  create_google_drive_folder(
@@ -34,7 +40,15 @@ create_google_drive_folder(
34
40
  )
35
41
  ```
36
42
 
37
- Create new Google Drive folder
43
+ Update the content of existing Google Drive file:
44
+
45
+ ```ruby
46
+ update_google_drive_file(
47
+ drive_keyfile: 'drive_key.json',
48
+ file_id: 'file_id',
49
+ upload_file: 'path/to/file.txt'
50
+ )
51
+ ```
38
52
 
39
53
  Download feature is not implemented yet. PR is always welcome.
40
54
 
@@ -76,4 +90,4 @@ _fastlane_ is the easiest way to automate beta deployments and releases for your
76
90
 
77
91
  The MIT License (MIT)
78
92
 
79
- Copyright (c) 2018 Bumsoo Kim (<https://bsk.im>)
93
+ Copyright (c) 2019 Bumsoo Kim (<https://bsk.im>)
@@ -67,7 +67,7 @@ module Fastlane
67
67
  optional: false,
68
68
  type: String,
69
69
  verify_block: proc do |value|
70
- UI.user_error!("No target folder id given, pass using `folder_id: 'some_id'`") unless value and !value.empty?
70
+ UI.user_error!("No target folder_id given, pass using `folder_id: 'some_id'`") unless value and !value.empty?
71
71
  end),
72
72
  FastlaneCore::ConfigItem.new(key: :folder_title,
73
73
  env_name: "GDRIVE_FOLDER_NAME",
@@ -0,0 +1,103 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/google_drive_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ module SharedValues
7
+ GDRIVE_UPDATED_FILE_NAME = :GDRIVE_UPDATED_FILE_NAME
8
+ GDRIVE_UPDATED_FILE_URL = :GDRIVE_UPDATED_FILE_URL
9
+ end
10
+ class UpdateGoogleDriveFileAction < Action
11
+ def self.run(params)
12
+ UI.message("Using config file: #{params[:drive_keyfile]}")
13
+
14
+ session = Helper::GoogleDriveHelper.setup(
15
+ keyfile: params[:drive_keyfile],
16
+ service_account: params[:service_account]
17
+ )
18
+
19
+ file = Helper::GoogleDriveHelper.file_by_id(
20
+ session: session, fid: params[:file_id]
21
+ )
22
+
23
+ upload_file = params[:upload_file]
24
+ UI.abort_with_message!("No file to upload") if upload_file.nil? or upload_file.empty?
25
+
26
+ UI.message('------------------')
27
+ UI.important("Uploading #{upload_file}")
28
+ Helper::GoogleDriveHelper.update_file(file: file, file_name: upload_file)
29
+ UI.success('Success')
30
+ UI.message('------------------')
31
+
32
+ Actions.lane_context[SharedValues::GDRIVE_UPDATED_FILE_NAME] = file.title
33
+ Actions.lane_context[SharedValues::GDRIVE_UPDATED_FILE_URL] = file.human_url
34
+ end
35
+
36
+ def self.description
37
+ 'Update a Google Drive file'
38
+ end
39
+
40
+ def self.details
41
+ [
42
+ 'Update a Google Drive file',
43
+ 'See https://github.com/gimite/google-drive-ruby/blob/master/doc/authorization.md to get a keyfile'
44
+ ].join("\n")
45
+ end
46
+
47
+ def self.available_options
48
+ [
49
+ FastlaneCore::ConfigItem.new(key: :drive_keyfile,
50
+ env_name: 'GDRIVE_KEY_FILE',
51
+ description: 'Json config file',
52
+ type: String,
53
+ default_value: 'drive_key.json',
54
+ verify_block: proc do |value|
55
+ UI.user_error!("Couldn't find config keyfile at path '#{value}'") unless File.exist?(value)
56
+ end),
57
+ FastlaneCore::ConfigItem.new(key: :service_account,
58
+ env_name: 'GDRIVE_SERVICE_ACCOUNT',
59
+ description: 'Credential is service account',
60
+ optional: true,
61
+ is_string: false,
62
+ default_value: false),
63
+ FastlaneCore::ConfigItem.new(key: :file_id,
64
+ env_name: "GDRIVE_UPDATE_FILE_ID",
65
+ description: "Target file id to update the content",
66
+ optional: false,
67
+ type: String,
68
+ verify_block: proc do |value|
69
+ UI.user_error!("No target file id given, pass using `file_id: 'some_id'`") unless value and !value.empty?
70
+ end),
71
+ FastlaneCore::ConfigItem.new(key: :upload_file,
72
+ env_name: "GDRIVE_UPLOAD_FILE",
73
+ description: "Path to a file to be uploaded",
74
+ optional: false,
75
+ is_string: false,
76
+ verify_block: proc do |value|
77
+ UI.user_error!("No upload file is given, pass using `upload_file: 'some/path/a.txt'`") unless value and !value.empty?
78
+ UI.user_error!("Couldn't find upload file at path '#{value}'") unless File.exist?(value)
79
+ end)
80
+ ]
81
+ end
82
+
83
+ def self.output
84
+ [
85
+ ['GDRIVE_UPDATED_FILE_NAME', 'The name of the uploaded file'],
86
+ ['GDRIVE_UPDATED_FILE_URL', 'The link to the uploaded file']
87
+ ]
88
+ end
89
+
90
+ def self.return_value
91
+ # nothing
92
+ end
93
+
94
+ def self.authors
95
+ ['Bumsoo Kim (@bskim45)']
96
+ end
97
+
98
+ def self.is_supported?(platform)
99
+ true
100
+ end
101
+ end
102
+ end
103
+ end
@@ -22,6 +22,7 @@ module Fastlane
22
22
 
23
23
  uploaded_files = []
24
24
  assets = params[:upload_files]
25
+ generate_public_links = params[:public_links]
25
26
 
26
27
  UI.abort_with_message!("No files to upload") if assets.nil? or assets.empty?
27
28
 
@@ -34,7 +35,12 @@ module Fastlane
34
35
  end
35
36
 
36
37
  Actions.lane_context[SharedValues::GDRIVE_UPLOADED_FILE_NAMES] = uploaded_files.map(&:title)
37
- Actions.lane_context[SharedValues::GDRIVE_UPLOADED_FILE_URLS] = uploaded_files.map(&:human_url)
38
+ Actions.lane_context[SharedValues::GDRIVE_UPLOADED_FILE_URLS] =
39
+ if generate_public_links
40
+ uploaded_files.map(&Helper::GoogleDriveHelper.method(:create_public_url))
41
+ else
42
+ uploaded_files.map(&:human_url)
43
+ end
38
44
  end
39
45
 
40
46
  def self.description
@@ -83,7 +89,13 @@ module Fastlane
83
89
  value.each do |path|
84
90
  UI.user_error!("Couldn't find upload file at path '#{path}'") unless File.exist?(path)
85
91
  end
86
- end)
92
+ end),
93
+ FastlaneCore::ConfigItem.new(key: :public_links,
94
+ env_name: 'GDRIVE_PUBLIC_LINKS',
95
+ description: 'Uploaded file links should be public',
96
+ optional: true,
97
+ default_value: false,
98
+ is_string: false)
87
99
  ]
88
100
  end
89
101
 
@@ -28,7 +28,7 @@ module Fastlane
28
28
  raise "Not Google Drive file" unless file.kind_of?(::GoogleDrive::File)
29
29
 
30
30
  begin
31
- file = file.upload_from_file(file_name, title)
31
+ file = file.upload_from_file(file_name, title, convert: false)
32
32
  file
33
33
  rescue Exception => e
34
34
  UI.error(e.message)
@@ -36,12 +36,37 @@ module Fastlane
36
36
  end
37
37
  end
38
38
 
39
+ def self.create_public_url(file)
40
+ raise "Not Google Drive file" unless file.kind_of?(::GoogleDrive::File)
41
+
42
+ begin
43
+ file.acl.push(type: "anyone", role: "reader")
44
+ file.reload_metadata
45
+ file.human_url
46
+ rescue Exception => e
47
+ UI.error(e.message)
48
+ UI.user_error!("Create public link for '#{file.resource_id}' failed")
49
+ end
50
+ end
51
+
39
52
  def self.create_subcollection(root_folder:, title:)
40
53
  root_folder.create_subcollection(title)
41
54
  rescue Exception => e
42
55
  UI.error(e.message)
43
56
  UI.user_error!("Create '#{title}' failed")
44
57
  end
58
+
59
+ def self.update_file(file: nil, file_name: nil)
60
+ raise "Not a Google Drive file" unless file.kind_of?(::GoogleDrive::File)
61
+
62
+ begin
63
+ file = file.update_from_file(file_name)
64
+ file
65
+ rescue Exception => e
66
+ UI.error(e.message)
67
+ UI.user_error!("Upload '#{file_name}' failed")
68
+ end
69
+ end
45
70
  end
46
71
  end
47
72
  end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module GoogleDrive
3
- VERSION = "0.3.0"
3
+ VERSION = "0.7.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-google_drive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bumsoo Kim
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-03 00:00:00.000000000 Z
11
+ date: 2021-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google_drive
@@ -16,14 +16,60 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
19
+ version: '3'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 3.0.7
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - "~>"
25
28
  - !ruby/object:Gem::Version
26
- version: '2.0'
29
+ version: '3'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 3.0.7
33
+ - !ruby/object:Gem::Dependency
34
+ name: google-apis-drive_v3
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 0.5.0
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: 1.0.0
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 0.5.0
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: 1.0.0
53
+ - !ruby/object:Gem::Dependency
54
+ name: google-apis-sheets_v4
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 0.4.0
60
+ - - "<"
61
+ - !ruby/object:Gem::Version
62
+ version: 1.0.0
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 0.4.0
70
+ - - "<"
71
+ - !ruby/object:Gem::Version
72
+ version: 1.0.0
27
73
  - !ruby/object:Gem::Dependency
28
74
  name: pry
29
75
  requirement: !ruby/object:Gem::Requirement
@@ -142,14 +188,14 @@ dependencies:
142
188
  requirements:
143
189
  - - ">="
144
190
  - !ruby/object:Gem::Version
145
- version: 2.80.0
191
+ version: 2.140.0
146
192
  type: :development
147
193
  prerelease: false
148
194
  version_requirements: !ruby/object:Gem::Requirement
149
195
  requirements:
150
196
  - - ">="
151
197
  - !ruby/object:Gem::Version
152
- version: 2.80.0
198
+ version: 2.140.0
153
199
  description:
154
200
  email: bskim45@gmail.com
155
201
  executables: []
@@ -160,8 +206,7 @@ files:
160
206
  - README.md
161
207
  - lib/fastlane/plugin/google_drive.rb
162
208
  - lib/fastlane/plugin/google_drive/actions/create_google_drive_folder_action.rb
163
- - lib/fastlane/plugin/google_drive/actions/google_drive_upload_action.rb
164
- - lib/fastlane/plugin/google_drive/actions/upload_google_drive_action.rb
209
+ - lib/fastlane/plugin/google_drive/actions/update_google_drive_file_action.rb
165
210
  - lib/fastlane/plugin/google_drive/actions/upload_to_google_drive_action.rb
166
211
  - lib/fastlane/plugin/google_drive/helper/google_drive_helper.rb
167
212
  - lib/fastlane/plugin/google_drive/version.rb
@@ -184,8 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
229
  - !ruby/object:Gem::Version
185
230
  version: '0'
186
231
  requirements: []
187
- rubyforge_project:
188
- rubygems_version: 2.7.6
232
+ rubygems_version: 3.0.8
189
233
  signing_key:
190
234
  specification_version: 4
191
235
  summary: Upload files to Google Drive
@@ -1,14 +0,0 @@
1
- module Fastlane
2
- module Actions
3
- require 'fastlane/plugin/google_drive/actions/upload_to_google_drive_action'
4
- class GoogleDriveUploadAction < UploadToGoogleDriveAction
5
- #####################################################
6
- # @!group Documentation
7
- #####################################################
8
-
9
- def self.description
10
- "Alias for the `upload_to_google_drive` action"
11
- end
12
- end
13
- end
14
- end
@@ -1,14 +0,0 @@
1
- module Fastlane
2
- module Actions
3
- require 'fastlane/plugin/google_drive/actions/upload_to_google_drive_action'
4
- class UploadGoogleDriveAction < UploadToGoogleDriveAction
5
- #####################################################
6
- # @!group Documentation
7
- #####################################################
8
-
9
- def self.description
10
- "Alias for the `upload_to_google_drive` action"
11
- end
12
- end
13
- end
14
- end