rise-cli 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -1
- data/CONTRIBUTING.md +7 -2
- data/Gemfile +5 -3
- data/Gemfile.lock +15 -0
- data/README.md +15 -5
- data/Rakefile +6 -6
- data/TODO.txt +3 -0
- data/bin/console +14 -14
- data/bin/rise +3 -4
- data/lib/core/constants.rb +4 -1
- data/lib/core/transport.rb +16 -13
- data/lib/core/util.rb +39 -80
- data/rise-cli.gemspec +6 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d388afeca104cc2795a4b124033584c59e6e2d21
|
4
|
+
data.tar.gz: 0eee79cafb98f3cdcfadfaff3def1b3f4d9f6f21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de5ac24bcb194d75b971242c94a24326b3e590396e29e23aded7558e0fb5f729a9f459f558c714aa7419fb9af074766951a78dfdc441baf215a47c7b8c09a63c
|
7
|
+
data.tar.gz: 22c48506472ce2b0c2f55351444ce2c0d2c3014f749802d0d7b9f3bc7c17f851203cb5fd569f3c94b1f08cfca0196da0b6de86fc07a3291aa07e8684514cae9f
|
data/.travis.yml
CHANGED
data/CONTRIBUTING.md
CHANGED
@@ -3,10 +3,15 @@ Thank you for wanting to contribute to rise!
|
|
3
3
|
If you want to contribute, there are a few guidelines that
|
4
4
|
should generally be followed.
|
5
5
|
|
6
|
+
### How the contributing process goes
|
7
|
+
1. You create a pull request doing your best to follow the do's and dont's outlined below
|
8
|
+
2. I will review your code if it needs to be reviewed
|
9
|
+
3. If travis and codeclimate OK the changes, your code will be merged onto master and eventually shipped with the next gem release
|
10
|
+
|
6
11
|
### Code contributions
|
7
12
|
* **Do** your best to stick to the [Ruby style guide]
|
8
13
|
* **Do** follow the [50/72 rule] for Git commit messages.
|
9
|
-
* **Do** make sure that there are no rubocop warnings on your new code
|
14
|
+
* **Do** make sure that there are no rubocop warnings on your new code (using `--fail-level W`)
|
10
15
|
|
11
16
|
### Pull Requests
|
12
17
|
* **Do** have a clear, concise title
|
@@ -18,4 +23,4 @@ should generally be followed.
|
|
18
23
|
|
19
24
|
|
20
25
|
[Ruby style guide]:https://github.com/bbatsov/ruby-style-guide
|
21
|
-
[50/72]:http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
|
26
|
+
[50/72 rule]:http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -5,6 +5,7 @@ GEM
|
|
5
5
|
public_suffix (>= 2.0.2, < 4.0)
|
6
6
|
ast (2.3.0)
|
7
7
|
clipboard (1.1.1)
|
8
|
+
diff-lcs (1.3)
|
8
9
|
domain_name (0.5.20170404)
|
9
10
|
unf (>= 0.0.5, < 1.0.0)
|
10
11
|
http (3.0.0)
|
@@ -26,6 +27,19 @@ GEM
|
|
26
27
|
rake
|
27
28
|
rake (12.0.0)
|
28
29
|
rex-text (0.2.15)
|
30
|
+
rspec (3.6.0)
|
31
|
+
rspec-core (~> 3.6.0)
|
32
|
+
rspec-expectations (~> 3.6.0)
|
33
|
+
rspec-mocks (~> 3.6.0)
|
34
|
+
rspec-core (3.6.0)
|
35
|
+
rspec-support (~> 3.6.0)
|
36
|
+
rspec-expectations (3.6.0)
|
37
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
38
|
+
rspec-support (~> 3.6.0)
|
39
|
+
rspec-mocks (3.6.0)
|
40
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
41
|
+
rspec-support (~> 3.6.0)
|
42
|
+
rspec-support (3.6.0)
|
29
43
|
rubocop (0.50.0)
|
30
44
|
parallel (~> 1.10)
|
31
45
|
parser (>= 2.3.3.1, < 3.0)
|
@@ -51,6 +65,7 @@ DEPENDENCIES
|
|
51
65
|
http
|
52
66
|
paint
|
53
67
|
rex-text
|
68
|
+
rspec
|
54
69
|
rubocop
|
55
70
|
whirly
|
56
71
|
|
data/README.md
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
![rise](https://github.com/cbrnrd/rise/raw/master/img/rise_logo.png)
|
2
|
-
|
3
|
-
[![
|
4
|
-
[![
|
2
|
+
|
3
|
+
[![Code Climate](https://img.shields.io/codeclimate/github/cbrnrd/rise.svg?style=flat-square)](https://codeclimate.com/github/cbrnrd/rise)
|
4
|
+
[![Build Status](https://img.shields.io/travis/cbrnrd/rise.svg?style=flat-square)](https://travis-ci.org/cbrnrd/rise)
|
5
|
+
[![Gem](https://img.shields.io/gem/v/rise-cli.svg?style=flat-square)](https://rubygems.org/gems/rise-cli)
|
6
|
+
[![Gem](https://img.shields.io/gem/dt/rise-cli.svg?style=flat-square)](https://rubygems.org/gems/rise-cli)
|
7
|
+
[![license](https://img.shields.io/github/license/mashape/apistatus.svg?style=flat-square)](https://github.com/cbrnrd/rise/blob/master/LICENSE)
|
5
8
|
|
6
9
|
# Usage
|
7
10
|
|
@@ -28,7 +31,7 @@ In order to get rise up and running, there's 2 ways you can install it.
|
|
28
31
|
|
29
32
|
## Built With
|
30
33
|
|
31
|
-
- [
|
34
|
+
- [RubyGems](https://rubygems.org) - the Ruby community's gem hosting service
|
32
35
|
- [Atom](https://atom.io/) - A hackable text editor for the 21st Century
|
33
36
|
- [DigitalOcean](https://digitalocean.com) - Used for server hosting
|
34
37
|
|
@@ -36,9 +39,16 @@ In order to get rise up and running, there's 2 ways you can install it.
|
|
36
39
|
|
37
40
|
Please read [CONTRIBUTING.md](https://github.com/cbrnrd/rise/blob/master/CONTRIBUTING.md) for details on our code of conduct, and the process for submitting a pull requests.
|
38
41
|
|
42
|
+
## Features
|
43
|
+
- No need to install git, svn, or any other version control software.
|
44
|
+
- No complex cloud setup
|
45
|
+
- Extremely fast upload speeds
|
46
|
+
- Unlimited unique URL's
|
47
|
+
- No manual setup of websites
|
48
|
+
- Your services are always served over a secure connection
|
49
|
+
- Open source so that you can know exactly what code is runnning on your computer.
|
39
50
|
|
40
51
|
## Coming soon
|
41
|
-
- rise.sh registration and 24/7 server uptime
|
42
52
|
- gzip file transfer
|
43
53
|
- actual use of the password hash for secure uploads
|
44
54
|
|
data/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
|
4
|
-
RSpec::Core::RakeTask.new(:spec)
|
5
|
-
|
6
|
-
task :
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
5
|
+
|
6
|
+
task default: :spec
|
data/TODO.txt
CHANGED
@@ -1,3 +1,6 @@
|
|
1
1
|
TODO things for rise:
|
2
2
|
* FIX THE DAMN AUTH ARCHITECTURE SO IT WORKS DAMN IT
|
3
3
|
* Add a .keyfile to each upload containing a private key. This file will be used to make sure that the same uuid can't be uploaded to twice and for a future file deletion method.
|
4
|
+
* Add said file deletion method
|
5
|
+
* Limit uploads to 50MB
|
6
|
+
* Add GZIP file uploads
|
data/bin/console
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "rise"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start(__FILE__)
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "rise"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/rise
CHANGED
@@ -34,7 +34,7 @@ OptionParser.new do |opts|
|
|
34
34
|
end
|
35
35
|
end.parse!(ARGV)
|
36
36
|
|
37
|
-
if Rise::Util.
|
37
|
+
if Rise::Util.first_run?
|
38
38
|
Rise::Util.setup
|
39
39
|
puts "\nPlease run the `rise` command again to upload your files."
|
40
40
|
exit 0
|
@@ -44,17 +44,16 @@ result_url = ''
|
|
44
44
|
uploader = Rise::Transport::Uploader.new(options[:directory]) unless options[:directory].nil?
|
45
45
|
uploader = Rise::Transport::Uploader.new(Dir.pwd) if options[:directory].nil?
|
46
46
|
|
47
|
-
|
48
47
|
puts Paint['Thanks for using Rise! Your local source for serverless deployment!', '#95a5a6']
|
49
48
|
|
50
49
|
Whirly.start(spinner: 'dots', status: "Uploading files (#{uploader.total_files} total files)") do
|
51
50
|
beginning_time = Time.now
|
52
|
-
result_url = uploader.upload!(options[:verbose])
|
51
|
+
result_url = uploader.upload!(options[:verbose]) # Do the file upload
|
53
52
|
|
54
53
|
Whirly.status = 'Done!\n'
|
55
54
|
Clipboard.copy(result_url)
|
56
55
|
print Paint["Your url is: #{result_url} (copied to clipboard) ", :bold]
|
57
|
-
puts Paint["[#{((Time.now - beginning_time)).round(2)}s]",
|
56
|
+
puts Paint["[#{((Time.now - beginning_time)).round(2)}s]", '#95a5a6']
|
58
57
|
|
59
58
|
puts Paint['Deployment successful!', '#3498db']
|
60
59
|
end
|
data/lib/core/constants.rb
CHANGED
@@ -4,8 +4,11 @@ AUTH_PORT = 4567.freeze
|
|
4
4
|
UPLOAD_PORT = 8080.freeze
|
5
5
|
|
6
6
|
module Rise
|
7
|
+
#
|
8
|
+
# Holds constants used throughout the framework
|
9
|
+
#
|
7
10
|
module Constants
|
8
|
-
VERSION = '0.1.
|
11
|
+
VERSION = '0.1.7'
|
9
12
|
EMAIL = '0xCB@protonmail.com'
|
10
13
|
AUTHORS = ['Carter Brainerd']
|
11
14
|
NAME = 'rise-cli'
|
data/lib/core/transport.rb
CHANGED
@@ -1,28 +1,31 @@
|
|
1
|
-
##
|
2
|
-
# This file handles all communication to the Upto servers
|
3
|
-
##
|
4
1
|
require 'rex/text'
|
5
2
|
require 'uri'
|
6
3
|
require 'json'
|
7
4
|
require 'http'
|
8
5
|
|
9
6
|
module Rise
|
7
|
+
#
|
8
|
+
# Handles all communication with the rise upload server
|
9
|
+
#
|
10
10
|
module Transport
|
11
|
-
|
12
11
|
# Handles uploading files
|
13
12
|
class Uploader
|
14
|
-
|
15
|
-
attr_reader :
|
13
|
+
attr_reader :folder_path, :total_files, :include_folder
|
14
|
+
attr_reader :uuid, :current_file
|
16
15
|
attr_accessor :files
|
17
16
|
|
18
|
-
def initialize(folder_path, include_folder=true)
|
17
|
+
def initialize(folder_path, include_folder = true)
|
19
18
|
@folder_path = folder_path
|
20
19
|
@files = Dir.glob("#{File.absolute_path(folder_path)}/**/*")
|
21
20
|
@total_files = @files.length
|
22
21
|
@include_folder = include_folder
|
23
|
-
@uuid = "#{File.basename(File.absolute_path(folder_path))}-#{Rex::Text
|
22
|
+
@uuid = "#{File.basename(File.absolute_path(folder_path))}-#{Rex::Text.rand_text_alphanumeric(8)}" # Structure: foldername-8RNDLTRS
|
24
23
|
end
|
25
24
|
|
25
|
+
#
|
26
|
+
# Uploads the files from +folder_path+ to the upload server
|
27
|
+
# @return String the final URL of the uploaded contents
|
28
|
+
#
|
26
29
|
def upload!(*)
|
27
30
|
upload_uri_base = "http://rise.sh:8080/api/v1/#{@uuid}"
|
28
31
|
access_uri = "https://rise.sh/#{@uuid}"
|
@@ -34,18 +37,18 @@ module Rise
|
|
34
37
|
ordered_files = files.sort_by(&:length)
|
35
38
|
ordered_files.each do |f|
|
36
39
|
isdir = File.directory?(f)
|
37
|
-
final_path = File.absolute_path(f).gsub(
|
40
|
+
final_path = File.absolute_path(f).gsub(
|
41
|
+
File.expand_path(folder_path), '')
|
38
42
|
uri = URI.parse("#{upload_uri_base}/#{final_path}?dir=#{isdir}")
|
39
43
|
begin
|
40
|
-
HTTP.put(uri.to_s, :
|
44
|
+
HTTP.put(uri.to_s, body: File.read(f))
|
41
45
|
rescue Errno::EISDIR
|
42
|
-
HTTP.put(uri.to_s, :
|
46
|
+
HTTP.put(uri.to_s, body: '')
|
43
47
|
next
|
44
48
|
end
|
45
49
|
end
|
46
|
-
|
50
|
+
access_uri
|
47
51
|
end
|
48
|
-
|
49
52
|
end
|
50
53
|
end
|
51
54
|
end
|
data/lib/core/util.rb
CHANGED
@@ -8,16 +8,15 @@ require 'tempfile'
|
|
8
8
|
require 'whirly'
|
9
9
|
require_relative 'constants'
|
10
10
|
|
11
|
-
#
|
12
|
-
# Utility methods
|
13
|
-
#
|
14
11
|
module Rise
|
12
|
+
#
|
13
|
+
# Utility methods
|
14
|
+
#
|
15
15
|
module Util
|
16
|
-
|
17
16
|
#
|
18
17
|
# Checks if rise is being run for the first time
|
19
18
|
#
|
20
|
-
def self.
|
19
|
+
def self.first_run?
|
21
20
|
!File.directory?(File.join(Dir.home, '.rise'))
|
22
21
|
end
|
23
22
|
|
@@ -25,27 +24,29 @@ module Rise
|
|
25
24
|
# Check for a new version of the gem
|
26
25
|
#
|
27
26
|
def self.check_for_update!
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
27
|
+
output = ''
|
28
|
+
temp = Tempfile.new('rise-updater-output')
|
29
|
+
path = temp.path
|
30
|
+
system("gem outdated > #{path}")
|
31
|
+
output << temp.read
|
32
|
+
if output.include? 'rise-cli'
|
33
|
+
Whirly.start(
|
34
|
+
spinner: 'line',
|
35
|
+
status: Paint['New version available, updating...', 'blue']
|
36
|
+
) do
|
37
|
+
system("gem uninstall rise-cli -v #{Rise::Constants::VERSION} > /dev/null")
|
38
|
+
system("gem install rise-cli > /dev/null")
|
39
|
+
puts Paint["Update complete, just run #{Paint['`rise`', '#3498db']} to deploy"]
|
40
40
|
end
|
41
|
-
rescue Exception => e
|
42
|
-
puts "Unable to check for updates. Error: #{Paint[e.message, 'red']}"
|
43
|
-
exit 1
|
44
|
-
ensure
|
45
|
-
temp.close
|
46
|
-
temp.unlink
|
47
41
|
end
|
42
|
+
rescue StandardError => e
|
43
|
+
puts "Unable to check for updates. Error: #{Paint[e.message, 'red']}"
|
44
|
+
exit 1
|
45
|
+
ensure
|
46
|
+
temp.close
|
47
|
+
temp.unlink
|
48
48
|
end
|
49
|
+
|
49
50
|
#
|
50
51
|
# Creates all of the necessary files and login information
|
51
52
|
#
|
@@ -54,63 +55,21 @@ module Rise
|
|
54
55
|
FileUtils.mkdir(RISE_DATA_DIR)
|
55
56
|
FileUtils.mkdir(File.join(RISE_DATA_DIR, 'auth'))
|
56
57
|
|
57
|
-
#TODO Reimplement when the backend server actually works
|
58
|
-
#
|
59
|
-
#print Paint['1. Log in\n2. Sign up\n > ', :bold]
|
60
|
-
#while (choice = gets.chomp!)
|
61
|
-
#
|
62
|
-
#
|
63
|
-
#
|
64
|
-
#
|
65
|
-
#
|
66
|
-
#
|
67
|
-
#
|
68
|
-
#
|
69
|
-
#
|
70
|
-
#
|
71
|
-
#end
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
# DO NOT USE
|
79
|
-
def login
|
80
|
-
|
81
|
-
print '\nEmail: '
|
82
|
-
email = gets.chomp!
|
83
|
-
print '\nPassword: '
|
84
|
-
password = STDIN.noecho(&:gets)
|
85
|
-
hash = Digest::SHA256.hexdigest(password)
|
86
|
-
res = HTTP.post("http://#{DOMAIN}:#{AUTH_PORT}/login?email=#{email}&hash=#{hash}")
|
87
|
-
if res.code == 200
|
88
|
-
puts Paint['\nLogin successful!', :green, :bold]
|
89
|
-
else
|
90
|
-
puts Paint['\nLogin failed!', :red, :bold]
|
91
|
-
puts "Printing error: #{res.code}: #{res.body}"
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
# DO NOT USE
|
96
|
-
def signup
|
97
|
-
print '\nEmail: '
|
98
|
-
email = gets.chomp!
|
99
|
-
print '\nPassword: '
|
100
|
-
password = STDIN.noecho(&:gets)
|
101
|
-
hash = Digest::SHA256.hexdigest(password)
|
102
|
-
res = HTTP.post("http://#{DOMAIN}:#{AUTH_PORT}/signup?email=#{email}&hash=#{hash}")
|
103
|
-
if res.code == 200
|
104
|
-
puts Paint['\nSignup successful!', :green, :bold]
|
105
|
-
File.open(File.join(RISE_DATA_DIR, 'auth', 'creds.json'), 'a') do |f|
|
106
|
-
creds_hash = {
|
107
|
-
'email' => email,
|
108
|
-
'hash' => hash
|
109
|
-
}
|
110
|
-
f.puts(creds_hash.to_json)
|
58
|
+
# TODO: Reimplement when the backend server actually works
|
59
|
+
# Get the input from the user
|
60
|
+
# print Paint['1. Log in\n2. Sign up\n > ', :bold]
|
61
|
+
# while (choice = gets.chomp!)
|
62
|
+
# if choice == '1'
|
63
|
+
# login
|
64
|
+
# break
|
65
|
+
# elsif choice == '2'
|
66
|
+
# signup
|
67
|
+
# break
|
68
|
+
# else
|
69
|
+
# puts Paint['Please type `1` or `2`', :red]
|
70
|
+
# next
|
71
|
+
# end
|
72
|
+
# end
|
111
73
|
end
|
112
|
-
elsif res.code == 409 # user already exists
|
113
|
-
puts Paint['\nSignup failed!', :red, :bold]
|
114
|
-
puts "Printing error: #{res.body}"
|
115
74
|
end
|
116
75
|
end
|
data/rise-cli.gemspec
CHANGED
@@ -5,17 +5,16 @@ require 'core'
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = Rise::Constants::NAME
|
7
7
|
s.version = Rise::Constants::VERSION
|
8
|
-
s.executables = [
|
8
|
+
s.executables = %w[rise setup console]
|
9
9
|
s.date = Time.now.strftime('%Y-%m-%d')
|
10
|
-
s.summary =
|
10
|
+
s.summary = 'Simple serverless website deployment'
|
11
11
|
s.authors = Rise::Constants::AUTHORS
|
12
12
|
s.email = Rise::Constants::EMAIL
|
13
13
|
s.files = `git ls-files`.split($/).reject { |file|
|
14
|
-
|
15
|
-
|
16
|
-
s.homepage =
|
17
|
-
|
18
|
-
s.license = 'MIT'
|
14
|
+
file =~ /^server|^spec|^pkg/
|
15
|
+
}
|
16
|
+
s.homepage = 'http://rubygems.org/gems/rise-cli'
|
17
|
+
s.license = 'MIT'
|
19
18
|
|
20
19
|
s.add_runtime_dependency 'clipboard'
|
21
20
|
s.add_runtime_dependency 'http'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rise-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carter Brainerd
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clipboard
|