fastlane-plugin-google_drive 0.2.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +20 -5
- data/lib/fastlane/plugin/google_drive/actions/create_google_drive_folder_action.rb +1 -1
- data/lib/fastlane/plugin/google_drive/actions/{upload_google_drive_action.rb → update_google_drive_file_action.rb} +27 -34
- data/lib/fastlane/plugin/google_drive/actions/{google_drive_upload_action.rb → upload_to_google_drive_action.rb} +15 -12
- data/lib/fastlane/plugin/google_drive/helper/google_drive_helper.rb +26 -1
- data/lib/fastlane/plugin/google_drive/version.rb +1 -1
- metadata +29 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b34d7897969c1e344ea4b8d9a6c6e00f04ea31c168f269c42235dfe05e5efad8
|
4
|
+
data.tar.gz: 19bfe0fb1bbe86dc31bba4925f7e1810c1969bdfeb8c544cec4eb0d09800070d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2c24ec4756413f9213ae79c132b09b0b60560e25b6ecfd2a86d47af06b50c1f6b7a06caeb7fcf3021ef0cb47c835c3b43451b0a5509e01753692499e82d1d61
|
7
|
+
data.tar.gz: dfa063b0605a717e4af7ee7bc483550e0650f3b028463a2390f02485979af978dbb3cbb33c14956694811b3a3ecf8a14fbfbb8d5efbf8c1291d21f5a6534439a
|
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.
|
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,8 +16,13 @@ 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',
|
20
27
|
service_account: true,
|
21
28
|
folder_id: 'folder_id',
|
@@ -23,7 +30,7 @@ upload_google_drive(
|
|
23
30
|
)
|
24
31
|
```
|
25
32
|
|
26
|
-
|
33
|
+
Create new Google Drive folder:
|
27
34
|
|
28
35
|
```ruby
|
29
36
|
create_google_drive_folder(
|
@@ -33,7 +40,15 @@ create_google_drive_folder(
|
|
33
40
|
)
|
34
41
|
```
|
35
42
|
|
36
|
-
|
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
|
+
```
|
37
52
|
|
38
53
|
Download feature is not implemented yet. PR is always welcome.
|
39
54
|
|
@@ -75,4 +90,4 @@ _fastlane_ is the easiest way to automate beta deployments and releases for your
|
|
75
90
|
|
76
91
|
The MIT License (MIT)
|
77
92
|
|
78
|
-
Copyright (c)
|
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
|
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",
|
@@ -4,10 +4,10 @@ require_relative '../helper/google_drive_helper'
|
|
4
4
|
module Fastlane
|
5
5
|
module Actions
|
6
6
|
module SharedValues
|
7
|
-
|
8
|
-
|
7
|
+
GDRIVE_UPDATED_FILE_NAME = :GDRIVE_UPDATED_FILE_NAME
|
8
|
+
GDRIVE_UPDATED_FILE_URL = :GDRIVE_UPDATED_FILE_URL
|
9
9
|
end
|
10
|
-
class
|
10
|
+
class UpdateGoogleDriveFileAction < Action
|
11
11
|
def self.run(params)
|
12
12
|
UI.message("Using config file: #{params[:drive_keyfile]}")
|
13
13
|
|
@@ -16,34 +16,30 @@ module Fastlane
|
|
16
16
|
service_account: params[:service_account]
|
17
17
|
)
|
18
18
|
|
19
|
-
|
20
|
-
session: session, fid: params[:
|
19
|
+
file = Helper::GoogleDriveHelper.file_by_id(
|
20
|
+
session: session, fid: params[:file_id]
|
21
21
|
)
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
upload_file = params[:upload_file]
|
24
|
+
UI.abort_with_message!("No file to upload") if upload_file.nil? or upload_file.empty?
|
25
25
|
|
26
|
-
UI.
|
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('------------------')
|
27
31
|
|
28
|
-
|
29
|
-
|
30
|
-
UI.important("Uploading #{asset}")
|
31
|
-
uploaded_files.push(Helper::GoogleDriveHelper.upload_file(file: folder, file_name: asset))
|
32
|
-
UI.success('Success')
|
33
|
-
UI.message('------------------')
|
34
|
-
end
|
35
|
-
|
36
|
-
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)
|
32
|
+
Actions.lane_context[SharedValues::GDRIVE_UPDATED_FILE_NAME] = file.title
|
33
|
+
Actions.lane_context[SharedValues::GDRIVE_UPDATED_FILE_URL] = file.human_url
|
38
34
|
end
|
39
35
|
|
40
36
|
def self.description
|
41
|
-
'
|
37
|
+
'Update a Google Drive file'
|
42
38
|
end
|
43
39
|
|
44
40
|
def self.details
|
45
41
|
[
|
46
|
-
'
|
42
|
+
'Update a Google Drive file',
|
47
43
|
'See https://github.com/gimite/google-drive-ruby/blob/master/doc/authorization.md to get a keyfile'
|
48
44
|
].join("\n")
|
49
45
|
end
|
@@ -64,33 +60,30 @@ module Fastlane
|
|
64
60
|
optional: true,
|
65
61
|
is_string: false,
|
66
62
|
default_value: false),
|
67
|
-
FastlaneCore::ConfigItem.new(key: :
|
68
|
-
env_name: "
|
69
|
-
description: "
|
63
|
+
FastlaneCore::ConfigItem.new(key: :file_id,
|
64
|
+
env_name: "GDRIVE_UPDATE_FILE_ID",
|
65
|
+
description: "Target file id to update the content",
|
70
66
|
optional: false,
|
71
67
|
type: String,
|
72
68
|
verify_block: proc do |value|
|
73
|
-
UI.user_error!("No target
|
69
|
+
UI.user_error!("No target file id given, pass using `file_id: 'some_id'`") unless value and !value.empty?
|
74
70
|
end),
|
75
|
-
FastlaneCore::ConfigItem.new(key: :
|
76
|
-
env_name: "
|
77
|
-
description: "Path to
|
71
|
+
FastlaneCore::ConfigItem.new(key: :upload_file,
|
72
|
+
env_name: "GDRIVE_UPLOAD_FILE",
|
73
|
+
description: "Path to a file to be uploaded",
|
78
74
|
optional: false,
|
79
75
|
is_string: false,
|
80
76
|
verify_block: proc do |value|
|
81
|
-
UI.user_error!("
|
82
|
-
UI.user_error!("
|
83
|
-
value.each do |path|
|
84
|
-
UI.user_error!("Couldn't find upload file at path '#{path}'") unless File.exist?(path)
|
85
|
-
end
|
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)
|
86
79
|
end)
|
87
80
|
]
|
88
81
|
end
|
89
82
|
|
90
83
|
def self.output
|
91
84
|
[
|
92
|
-
['
|
93
|
-
['
|
85
|
+
['GDRIVE_UPDATED_FILE_NAME', 'The name of the uploaded file'],
|
86
|
+
['GDRIVE_UPDATED_FILE_URL', 'The link to the uploaded file']
|
94
87
|
]
|
95
88
|
end
|
96
89
|
|
@@ -7,7 +7,7 @@ module Fastlane
|
|
7
7
|
GDRIVE_UPLOADED_FILE_NAMES = :GDRIVE_UPLOADED_FILE_NAMES
|
8
8
|
GDRIVE_UPLOADED_FILE_URLS = :GDRIVE_UPLOADED_FILE_URLS
|
9
9
|
end
|
10
|
-
class
|
10
|
+
class UploadToGoogleDriveAction < Action
|
11
11
|
def self.run(params)
|
12
12
|
UI.message("Using config file: #{params[:drive_keyfile]}")
|
13
13
|
|
@@ -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] =
|
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
|
|
@@ -105,15 +117,6 @@ module Fastlane
|
|
105
117
|
def self.is_supported?(platform)
|
106
118
|
true
|
107
119
|
end
|
108
|
-
|
109
|
-
def self.category
|
110
|
-
:deprecated
|
111
|
-
end
|
112
|
-
|
113
|
-
def self.deprecated_notes
|
114
|
-
"`google_drive_upload(...)` is renamed to `upload_google_drive(...)`\n" \
|
115
|
-
"It will be removed in next release."
|
116
|
-
end
|
117
120
|
end
|
118
121
|
end
|
119
122
|
end
|
@@ -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
|
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.
|
4
|
+
version: 0.6.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:
|
11
|
+
date: 2021-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google_drive
|
@@ -16,14 +16,34 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '3'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 3.0.5
|
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: '
|
29
|
+
version: '3'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.0.5
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: google-api-client
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 0.37.0
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.37.0
|
27
47
|
- !ruby/object:Gem::Dependency
|
28
48
|
name: pry
|
29
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,14 +162,14 @@ dependencies:
|
|
142
162
|
requirements:
|
143
163
|
- - ">="
|
144
164
|
- !ruby/object:Gem::Version
|
145
|
-
version: 2.
|
165
|
+
version: 2.140.0
|
146
166
|
type: :development
|
147
167
|
prerelease: false
|
148
168
|
version_requirements: !ruby/object:Gem::Requirement
|
149
169
|
requirements:
|
150
170
|
- - ">="
|
151
171
|
- !ruby/object:Gem::Version
|
152
|
-
version: 2.
|
172
|
+
version: 2.140.0
|
153
173
|
description:
|
154
174
|
email: bskim45@gmail.com
|
155
175
|
executables: []
|
@@ -160,8 +180,8 @@ files:
|
|
160
180
|
- README.md
|
161
181
|
- lib/fastlane/plugin/google_drive.rb
|
162
182
|
- lib/fastlane/plugin/google_drive/actions/create_google_drive_folder_action.rb
|
163
|
-
- lib/fastlane/plugin/google_drive/actions/
|
164
|
-
- lib/fastlane/plugin/google_drive/actions/
|
183
|
+
- lib/fastlane/plugin/google_drive/actions/update_google_drive_file_action.rb
|
184
|
+
- lib/fastlane/plugin/google_drive/actions/upload_to_google_drive_action.rb
|
165
185
|
- lib/fastlane/plugin/google_drive/helper/google_drive_helper.rb
|
166
186
|
- lib/fastlane/plugin/google_drive/version.rb
|
167
187
|
homepage: https://github.com/bskim45/fastlane-plugin-google_drive
|
@@ -183,8 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
203
|
- !ruby/object:Gem::Version
|
184
204
|
version: '0'
|
185
205
|
requirements: []
|
186
|
-
|
187
|
-
rubygems_version: 2.7.6
|
206
|
+
rubygems_version: 3.0.8
|
188
207
|
signing_key:
|
189
208
|
specification_version: 4
|
190
209
|
summary: Upload files to Google Drive
|