dropbox-deployment 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/dropbox-deployment +6 -6
- data/lib/dropbox-deployment.rb +73 -78
- metadata +25 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73b2fe55c7ac8b63490b72f9edad059392cce68d
|
4
|
+
data.tar.gz: 2c7c5fcc20519dceab71e883e5e23dd7864e87c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2747aaa4bd06a05afd1562dd3cfabfdf6e434766e6aa3594ba87903515bdb8f29d87d58f5643b19c92bc3c665727544b8d660d133d87e0e8922001fa3fdbabd8
|
7
|
+
data.tar.gz: 0df1c98307f984e82a4966250bfa1db7ae389a6dd6d5e6ee95107b80c1577c0578d78536eee56e3d550cb59fc6fe5e3d00c88f740c3a2824ba71d6ac7484c0fe
|
data/bin/dropbox-deployment
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'dropbox-deployment'
|
4
|
-
|
5
|
-
deployer = DropboxDeployment::Deployer.new
|
6
|
-
deployer.deploy
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'dropbox-deployment'
|
4
|
+
|
5
|
+
deployer = DropboxDeployment::Deployer.new
|
6
|
+
deployer.deploy
|
data/lib/dropbox-deployment.rb
CHANGED
@@ -1,78 +1,73 @@
|
|
1
|
-
require 'dropbox_api'
|
2
|
-
require 'yaml'
|
3
|
-
require 'logger'
|
4
|
-
require 'find'
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
51
|
-
|
52
|
-
if
|
53
|
-
|
54
|
-
|
55
|
-
end
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
end
|
75
|
-
@@logger.debug("Uploading complete")
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
1
|
+
require 'dropbox_api'
|
2
|
+
require 'yaml'
|
3
|
+
require 'logger'
|
4
|
+
require 'find'
|
5
|
+
require 'dotenv'
|
6
|
+
Dotenv.load
|
7
|
+
|
8
|
+
module DropboxDeployment
|
9
|
+
class Deployer
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@@logger = Logger.new(STDOUT)
|
13
|
+
@@logger.level = Logger::WARN
|
14
|
+
end
|
15
|
+
|
16
|
+
def uploadFile(dropboxClient, file, dropboxPath)
|
17
|
+
fileName = File.basename(file)
|
18
|
+
content = IO.read(file)
|
19
|
+
dropboxClient.upload dropboxPath + "/" + fileName, content, :mode => :overwrite
|
20
|
+
end
|
21
|
+
|
22
|
+
def uploadDirectory(dropboxClient, directoryPath, dropboxPath)
|
23
|
+
Find.find(directoryPath) do |file|
|
24
|
+
# TODO need to have the path of the parent as part of the dropbox path
|
25
|
+
# so that we keep the hierarchy we want
|
26
|
+
if !File.directory?(file)
|
27
|
+
uploadFile(dropboxClient, file, dropboxPath)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def deploy()
|
33
|
+
# Validation
|
34
|
+
if !File.file?("dropbox-deployment.yml")
|
35
|
+
puts "\nNo config file found. You need a file called `dropbox-deployment.yml` with the configuration. See the README for details\n\n"
|
36
|
+
exit(1)
|
37
|
+
end
|
38
|
+
config = YAML.load_file("dropbox-deployment.yml")
|
39
|
+
testing = false
|
40
|
+
if !config.has_key?("deploy")
|
41
|
+
puts "\nError in config file! Build file must contain a `deploy` object.\n\n"
|
42
|
+
exit(1)
|
43
|
+
end
|
44
|
+
artifactPath = config["deploy"]["artifacts_path"]
|
45
|
+
dropboxPath = config["deploy"]["dropbox_path"]
|
46
|
+
|
47
|
+
if ENV["DROPBOX_OAUTH_BEARER"].nil?
|
48
|
+
puts "\nYou must have an environment variable of `DROPBOX_OAUTH_BEARER` in order to deploy to Dropbox\n\n"
|
49
|
+
exit(1)
|
50
|
+
end
|
51
|
+
|
52
|
+
if config["deploy"]["debug"]
|
53
|
+
@@logger.level = Logger::DEBUG
|
54
|
+
@@logger.debug("We are in debug mode")
|
55
|
+
end
|
56
|
+
|
57
|
+
dropboxClient = DropboxApi::Client.new
|
58
|
+
|
59
|
+
# Upload all files
|
60
|
+
@@logger.debug("Artifact Path: " + artifactPath)
|
61
|
+
@@logger.debug("Dropbox Path: " + dropboxPath)
|
62
|
+
isDirectory = File.directory?(artifactPath)
|
63
|
+
@@logger.debug("Is directory: " + "#{isDirectory}")
|
64
|
+
if isDirectory
|
65
|
+
uploadDirectory(dropboxClient, artifactPath, dropboxPath)
|
66
|
+
else
|
67
|
+
artifactFile = File.open(artifactPath)
|
68
|
+
uploadFile(dropboxClient, artifactFile, dropboxPath)
|
69
|
+
end
|
70
|
+
@@logger.debug("Uploading complete")
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dropbox-deployment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Carlson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dropbox_api
|
@@ -24,6 +24,26 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.1.5
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: dotenv
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.2'
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 2.2.0
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '2.2'
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 2.2.0
|
27
47
|
description:
|
28
48
|
email:
|
29
49
|
- jawnnypoo@gmail.com
|
@@ -42,11 +62,12 @@ post_install_message:
|
|
42
62
|
rdoc_options: []
|
43
63
|
require_paths:
|
44
64
|
- lib
|
65
|
+
- lib
|
45
66
|
required_ruby_version: !ruby/object:Gem::Requirement
|
46
67
|
requirements:
|
47
68
|
- - ">="
|
48
69
|
- !ruby/object:Gem::Version
|
49
|
-
version:
|
70
|
+
version: 2.0.0
|
50
71
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
72
|
requirements:
|
52
73
|
- - ">="
|
@@ -54,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
54
75
|
version: '0'
|
55
76
|
requirements: []
|
56
77
|
rubyforge_project:
|
57
|
-
rubygems_version: 2.6.
|
78
|
+
rubygems_version: 2.6.8
|
58
79
|
signing_key:
|
59
80
|
specification_version: 4
|
60
81
|
summary: Deploy your CI artifacts to Dropbox
|