fastlane-plugin-google_drive 0.1.0 → 0.2.0

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: f69b7bc30ac28e0475fb4ee43332ee5dccb610401afa983c0b51149d361846b5
4
- data.tar.gz: 85267e5222259dce3f093bdf680edbbe6f0ad0dfcdb52e8e53fc71a36794dcc1
3
+ metadata.gz: 25c7b2e3b658ca2ab433146073bfd0da8f5acdc865b1d8ab5a7981927e087c13
4
+ data.tar.gz: 42cce7a465a1955e902c9522c754694733309f9aaff5d5797e76a4a142c3d03a
5
5
  SHA512:
6
- metadata.gz: 11a321c10bb1f5627caffa9d939c7993368c35358a48eb21ad18c64ca25538e858676a1436d65cd3dba8ee06e84ca1c9eec5754e6b8d1d1a34a177342977d838
7
- data.tar.gz: 440c4b18e80b521e6e99f3d3c6b4869dc7bef61adcb1a389ab1a6ae96bf41c52f2495f677b97a3f28aba9513ae7789312db7d27fcb14ce86c7ab1915362190e2
6
+ metadata.gz: 4f694a5b1e75ca345133e4759598ec7b93f8cab3bef73f60ca2c2cfa76451ade3404ae845535d5240dd46f7927a16b17bd94cfd2e907875cdd58d89c146c4594
7
+ data.tar.gz: 036e78a81ee5d63dc0cacc106be9c6e472befb71addfd45564993b5d9c3d04258735155edbd8d6c1691c378c9680ab426ae9fb6a1b03a0795ba012808c427347
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
- # google_drive plugin
1
+ # google_drive `fastlane` plugin
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
+ [![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)
4
6
 
5
7
  ## Getting Started
6
8
 
@@ -12,26 +14,44 @@ fastlane add_plugin google_drive
12
14
 
13
15
  ## About google_drive
14
16
 
15
- Upload files to Google Drive
17
+ ```ruby
18
+ upload_google_drive(
19
+ drive_keyfile: 'drive_key.json',
20
+ service_account: true,
21
+ folder_id: 'folder_id',
22
+ upload_files: ['file_to_upload', 'another_file_to_upload']
23
+ )
24
+ ```
25
+
26
+ Upload files to Google Drive folder.
27
+
28
+ ```ruby
29
+ create_google_drive_folder(
30
+ drive_keyfile: 'drive_key.json',
31
+ folder_id: '#{folder_id}',
32
+ folder_title: 'new_folder'
33
+ )
34
+ ```
16
35
 
17
- **Note to author:** Add a more detailed description about this plugin here. If your plugin contains multiple actions, make sure to mention them here.
36
+ Create new Google Drive folder
37
+
38
+ Download feature is not implemented yet. PR is always welcome.
18
39
 
19
40
  ## Example
20
41
 
21
42
  Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane test`.
22
43
 
23
- **Note to author:** Please set up a sample project to make it easy for users to explore what your plugin does. Provide everything that is necessary to try out the plugin in this project (including a sample Xcode/Android project if necessary)
24
-
25
44
  ## Run tests for this plugin
26
45
 
27
46
  To run both the tests, and code style validation, run
28
47
 
29
- ```
48
+ ```bash
30
49
  rake
31
50
  ```
32
51
 
33
52
  To automatically fix many of the styling issues, use
34
- ```
53
+
54
+ ```bash
35
55
  rubocop -a
36
56
  ```
37
57
 
@@ -50,3 +70,9 @@ For more information about how the `fastlane` plugin system works, check out the
50
70
  ## About _fastlane_
51
71
 
52
72
  _fastlane_ is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).
73
+
74
+ ## License
75
+
76
+ The MIT License (MIT)
77
+
78
+ Copyright (c) 2018 Bumsoo Kim (<https://bsk.im>)
@@ -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_CREATED_FOLDER_ID = :GDRIVE_CREATED_FOLDER_ID
8
+ GDRIVE_CREATED_FOLDER_URL = :GDRIVE_CREATED_FOLDER_URL
9
+ end
10
+ class CreateGoogleDriveFolderAction < 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
+ folder = Helper::GoogleDriveHelper.file_by_id(
20
+ session: session, fid: params[:folder_id]
21
+ )
22
+
23
+ title = params[:folder_title]
24
+ UI.message('------------------')
25
+ UI.important("Creating #{title}")
26
+ new_folder = Helper::GoogleDriveHelper.create_subcollection(root_folder: folder, title: title)
27
+ UI.success('Success')
28
+ UI.message('------------------')
29
+
30
+ folder_id = new_folder.resource_id.split(':').last
31
+ Actions.lane_context[SharedValues::GDRIVE_CREATED_FOLDER_ID] = folder_id
32
+ Actions.lane_context[SharedValues::GDRIVE_CREATED_FOLDER_URL] = new_folder.human_url
33
+
34
+ new_folder
35
+ end
36
+
37
+ def self.description
38
+ 'Create new folder on Google Drive'
39
+ end
40
+
41
+ def self.details
42
+ [
43
+ 'Create new folder on Google Drive',
44
+ 'See https://github.com/gimite/google-drive-ruby/blob/master/doc/authorization.md to get a keyfile'
45
+ ].join("\n")
46
+ end
47
+
48
+ def self.available_options
49
+ [
50
+ FastlaneCore::ConfigItem.new(key: :drive_keyfile,
51
+ env_name: 'GDRIVE_KEY_FILE',
52
+ description: 'Json config file',
53
+ type: String,
54
+ default_value: 'drive_key.json',
55
+ verify_block: proc do |value|
56
+ UI.user_error!("Couldn't find config keyfile at path '#{value}'") unless File.exist?(value)
57
+ end),
58
+ FastlaneCore::ConfigItem.new(key: :service_account,
59
+ env_name: 'GDRIVE_SERVICE_ACCOUNT',
60
+ description: 'Credential is service account',
61
+ optional: true,
62
+ is_string: false,
63
+ default_value: false),
64
+ FastlaneCore::ConfigItem.new(key: :folder_id,
65
+ env_name: "GDRIVE_UPLOAD_FOLDER_ID",
66
+ description: "Upload target folder id",
67
+ optional: false,
68
+ type: String,
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?
71
+ end),
72
+ FastlaneCore::ConfigItem.new(key: :folder_title,
73
+ env_name: "GDRIVE_FOLDER_NAME",
74
+ description: "Folder title of new one",
75
+ optional: false,
76
+ type: String,
77
+ verify_block: proc do |value|
78
+ UI.user_error!("No folder title given") if value.nil? || value.empty?
79
+ end)
80
+ ]
81
+ end
82
+
83
+ def self.output
84
+ [
85
+ ['GDRIVE_CREATED_FOLDER_ID', 'ID of the created folder'],
86
+ ['GDRIVE_CREATED_FOLDER_URL', 'Link to the created folder']
87
+ ]
88
+ end
89
+
90
+ def self.return_value
91
+ '`GoogleDrive::Collection` object which indicates the created folder.'
92
+ end
93
+
94
+ def self.authors
95
+ ['Kohki Miki (@giginet)']
96
+ end
97
+
98
+ def self.is_supported?(platform)
99
+ true
100
+ end
101
+ end
102
+ end
103
+ end
@@ -105,6 +105,15 @@ module Fastlane
105
105
  def self.is_supported?(platform)
106
106
  true
107
107
  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
108
117
  end
109
118
  end
110
119
  end
@@ -0,0 +1,110 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/google_drive_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ module SharedValues
7
+ GDRIVE_UPLOADED_FILE_NAMES = :GDRIVE_UPLOADED_FILE_NAMES
8
+ GDRIVE_UPLOADED_FILE_URLS = :GDRIVE_UPLOADED_FILE_URLS
9
+ end
10
+ class UploadGoogleDriveAction < 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
+ folder = Helper::GoogleDriveHelper.file_by_id(
20
+ session: session, fid: params[:folder_id]
21
+ )
22
+
23
+ uploaded_files = []
24
+ assets = params[:upload_files]
25
+
26
+ UI.abort_with_message!("No files to upload") if assets.nil? or assets.empty?
27
+
28
+ assets.each do |asset|
29
+ UI.message('------------------')
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)
38
+ end
39
+
40
+ def self.description
41
+ 'Upload files to Google Drive'
42
+ end
43
+
44
+ def self.details
45
+ [
46
+ 'Upload files to Google Drive',
47
+ 'See https://github.com/gimite/google-drive-ruby/blob/master/doc/authorization.md to get a keyfile'
48
+ ].join("\n")
49
+ end
50
+
51
+ def self.available_options
52
+ [
53
+ FastlaneCore::ConfigItem.new(key: :drive_keyfile,
54
+ env_name: 'GDRIVE_KEY_FILE',
55
+ description: 'Json config file',
56
+ type: String,
57
+ default_value: 'drive_key.json',
58
+ verify_block: proc do |value|
59
+ UI.user_error!("Couldn't find config keyfile at path '#{value}'") unless File.exist?(value)
60
+ end),
61
+ FastlaneCore::ConfigItem.new(key: :service_account,
62
+ env_name: 'GDRIVE_SERVICE_ACCOUNT',
63
+ description: 'Credential is service account',
64
+ optional: true,
65
+ is_string: false,
66
+ default_value: false),
67
+ FastlaneCore::ConfigItem.new(key: :folder_id,
68
+ env_name: "GDRIVE_UPLOAD_FOLDER_ID",
69
+ description: "Upload target folder id",
70
+ optional: false,
71
+ type: String,
72
+ verify_block: proc do |value|
73
+ UI.user_error!("No target folder id given, pass using `folder_id: 'some_id'`") unless value and !value.empty?
74
+ end),
75
+ FastlaneCore::ConfigItem.new(key: :upload_files,
76
+ env_name: "GDRIVE_UPLOAD_FILES",
77
+ description: "Path to files to be uploaded",
78
+ optional: false,
79
+ is_string: false,
80
+ verify_block: proc do |value|
81
+ UI.user_error!("upload_files must be an Array of paths to files") unless value.kind_of?(Array)
82
+ UI.user_error!("No upload file is given, pass using `upload_files: ['a', 'b']`") unless value and !value.empty?
83
+ value.each do |path|
84
+ UI.user_error!("Couldn't find upload file at path '#{path}'") unless File.exist?(path)
85
+ end
86
+ end)
87
+ ]
88
+ end
89
+
90
+ def self.output
91
+ [
92
+ ['GDRIVE_UPLOADED_FILE_NAMES', 'The array of names of uploaded files'],
93
+ ['GDRIVE_UPLOADED_FILE_URLS', 'The array of links to uploaded files']
94
+ ]
95
+ end
96
+
97
+ def self.return_value
98
+ # nothing
99
+ end
100
+
101
+ def self.authors
102
+ ['Bumsoo Kim (@bskim45)']
103
+ end
104
+
105
+ def self.is_supported?(platform)
106
+ true
107
+ end
108
+ end
109
+ end
110
+ end
@@ -1,6 +1,5 @@
1
1
  require 'fastlane_core/ui/ui'
2
2
  require 'google_drive'
3
-
4
3
  module Fastlane
5
4
  UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
6
5
 
@@ -36,6 +35,13 @@ module Fastlane
36
35
  UI.user_error!("Upload '#{file_name}' failed")
37
36
  end
38
37
  end
38
+
39
+ def self.create_subcollection(root_folder:, title:)
40
+ root_folder.create_subcollection(title)
41
+ rescue Exception => e
42
+ UI.error(e.message)
43
+ UI.user_error!("Create '#{title}' failed")
44
+ end
39
45
  end
40
46
  end
41
47
  end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module GoogleDrive
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.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.1.0
4
+ version: 0.2.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-02-09 00:00:00.000000000 Z
11
+ date: 2018-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google_drive
@@ -159,7 +159,9 @@ files:
159
159
  - LICENSE
160
160
  - README.md
161
161
  - lib/fastlane/plugin/google_drive.rb
162
+ - lib/fastlane/plugin/google_drive/actions/create_google_drive_folder_action.rb
162
163
  - lib/fastlane/plugin/google_drive/actions/google_drive_upload_action.rb
164
+ - lib/fastlane/plugin/google_drive/actions/upload_google_drive_action.rb
163
165
  - lib/fastlane/plugin/google_drive/helper/google_drive_helper.rb
164
166
  - lib/fastlane/plugin/google_drive/version.rb
165
167
  homepage: https://github.com/bskim45/fastlane-plugin-google_drive
@@ -182,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
184
  version: '0'
183
185
  requirements: []
184
186
  rubyforge_project:
185
- rubygems_version: 2.7.4
187
+ rubygems_version: 2.7.6
186
188
  signing_key:
187
189
  specification_version: 4
188
190
  summary: Upload files to Google Drive