rise-cli 0.1.0 → 0.1.1b

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
  SHA1:
3
- metadata.gz: f7286a03eca652a914158802a4d627fd984477c9
4
- data.tar.gz: afdd779d5dcf909d314bb404aa3515093b8c0bad
3
+ metadata.gz: 6c19e40fbcfc7dafe5c750cd1b3882c716560c89
4
+ data.tar.gz: 9f1a82d7d3037b863204583fbc194113b40c0c03
5
5
  SHA512:
6
- metadata.gz: 0da0599524d7d0f1cdce93bd08d713e24b24d9a51009fa14312a0b89591c5caba6cb0e2545fb42ceb127daa6c4170321257619760df80315febc377e426d2a7b
7
- data.tar.gz: b34df62a02a923da1f53144522bfc25903a4b5aecd56e3a0dce32aec9a5e782cdeb9246b729fea7d176b3384597d759f6ba647d06dadab2c0a5d9c7aa8aed394
6
+ metadata.gz: 7b4f6e7d3d865bff9f27acb8de7bf716b6c4bde095dbdf933d05d28ca6cb9041ce741408eb6b380d551457beb640e9fc9aa903e3e8961148b2c502eeea04b2e8
7
+ data.tar.gz: af85846bf1b54bd669e12db728120577bfe995473c58fc50c63c6aec5fecf6ca63484cf5d915758c01f7c9e82396f506ea06f512a8b685a34a43ac1ea0d12edd
data/.gitignore CHANGED
@@ -1,8 +1,8 @@
1
- # any test files
2
- *test*
3
-
4
- # compiled gems
5
- rise-*.gem
6
-
7
- # Old html files
8
- views
1
+ # any test files
2
+ *test*
3
+
4
+ # compiled gems
5
+ rise-*.gem
6
+
7
+ # Old html files
8
+ views
data/.travis.yml CHANGED
@@ -1,8 +1,8 @@
1
- language: ruby
2
- dist: trusty
3
- rvm:
4
- - 2.4
5
-
6
- script:
7
- - bundle && bundle install
8
- # - rubocop --fail-level W
1
+ language: ruby
2
+ dist: trusty
3
+ rvm:
4
+ - 2.4
5
+
6
+ script:
7
+ - bundle && bundle install
8
+ # - rubocop --fail-level W
data/CONTRIBUTING.md CHANGED
@@ -1,21 +1,21 @@
1
- ## Thanks!
2
- Thank you for wanting to contribute to rise!
3
- If you want to contribute, there are a few guidelines that
4
- should generally be followed.
5
-
6
- ### Code contributions
7
- * **Do** your best to stick to the [Ruby style guide]
8
- * **Do** follow the [50/72 rule] for Git commit messages.
9
- * **Do** make sure that there are no rubocop warnings on your new code
10
-
11
- ### Pull Requests
12
- * **Do** have a clear, concise title
13
- * **Do** include as many details as possible in the pull request body
14
- * **Do** include console output (if applicable) in your pull request (asciinema if possible)
15
- * **Do** `require` your new file in `lib/core.rb` and place the file in `lib/core/`if you are adding new library code.
16
- * **Don't** leave your pull request descriptions blank.
17
- * **Don't** go radio silent on pull requests, try to reply fast so we can land your code quicker
18
-
19
-
20
- [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
1
+ ## Thanks!
2
+ Thank you for wanting to contribute to rise!
3
+ If you want to contribute, there are a few guidelines that
4
+ should generally be followed.
5
+
6
+ ### Code contributions
7
+ * **Do** your best to stick to the [Ruby style guide]
8
+ * **Do** follow the [50/72 rule] for Git commit messages.
9
+ * **Do** make sure that there are no rubocop warnings on your new code
10
+
11
+ ### Pull Requests
12
+ * **Do** have a clear, concise title
13
+ * **Do** include as many details as possible in the pull request body
14
+ * **Do** include console output (if applicable) in your pull request (asciinema if possible)
15
+ * **Do** `require` your new file in `lib/core.rb` and place the file in `lib/core/`if you are adding new library code.
16
+ * **Don't** leave your pull request descriptions blank.
17
+ * **Don't** go radio silent on pull requests, try to reply fast so we can land your code quicker
18
+
19
+
20
+ [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
data/Gemfile CHANGED
@@ -1,9 +1,9 @@
1
- # frozen_string_literal: true
2
- source 'https://rubygems.org'
3
-
4
- gem 'whirly'
5
- gem 'paint'
6
- gem 'clipboard'
7
- gem 'rex-text'
8
- gem 'http'
9
- gem 'rubocop'
1
+ # frozen_string_literal: true
2
+ source 'https://rubygems.org'
3
+
4
+ gem 'whirly'
5
+ gem 'paint'
6
+ gem 'clipboard'
7
+ gem 'rex-text'
8
+ gem 'http'
9
+ gem 'rubocop'
data/Gemfile.lock CHANGED
@@ -1,58 +1,58 @@
1
- GEM
2
- remote: https://rubygems.org/
3
- specs:
4
- addressable (2.5.2)
5
- public_suffix (>= 2.0.2, < 4.0)
6
- ast (2.3.0)
7
- clipboard (1.1.1)
8
- domain_name (0.5.20170404)
9
- unf (>= 0.0.5, < 1.0.0)
10
- http (3.0.0)
11
- addressable (~> 2.3)
12
- http-cookie (~> 1.0)
13
- http-form_data (>= 2.0.0.pre.pre2, < 3)
14
- http_parser.rb (~> 0.6.0)
15
- http-cookie (1.0.3)
16
- domain_name (~> 0.5)
17
- http-form_data (2.0.0)
18
- http_parser.rb (0.6.0)
19
- paint (2.0.0)
20
- parallel (1.12.0)
21
- parser (2.4.0.0)
22
- ast (~> 2.2)
23
- powerpack (0.1.1)
24
- public_suffix (3.0.0)
25
- rainbow (2.2.2)
26
- rake
27
- rake (12.0.0)
28
- rex-text (0.2.15)
29
- rubocop (0.50.0)
30
- parallel (~> 1.10)
31
- parser (>= 2.3.3.1, < 3.0)
32
- powerpack (~> 0.1)
33
- rainbow (>= 2.2.2, < 3.0)
34
- ruby-progressbar (~> 1.7)
35
- unicode-display_width (~> 1.0, >= 1.0.1)
36
- ruby-progressbar (1.9.0)
37
- unf (0.1.4)
38
- unf_ext
39
- unf_ext (0.0.7.4)
40
- unf_ext (0.0.7.4-x64-mingw32)
41
- unicode-display_width (1.3.0)
42
- whirly (0.2.5)
43
- unicode-display_width (~> 1.1)
44
-
45
- PLATFORMS
46
- ruby
47
- x64-mingw32
48
-
49
- DEPENDENCIES
50
- clipboard
51
- http
52
- paint
53
- rex-text
54
- rubocop
55
- whirly
56
-
57
- BUNDLED WITH
58
- 1.15.4
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ addressable (2.5.2)
5
+ public_suffix (>= 2.0.2, < 4.0)
6
+ ast (2.3.0)
7
+ clipboard (1.1.1)
8
+ domain_name (0.5.20170404)
9
+ unf (>= 0.0.5, < 1.0.0)
10
+ http (3.0.0)
11
+ addressable (~> 2.3)
12
+ http-cookie (~> 1.0)
13
+ http-form_data (>= 2.0.0.pre.pre2, < 3)
14
+ http_parser.rb (~> 0.6.0)
15
+ http-cookie (1.0.3)
16
+ domain_name (~> 0.5)
17
+ http-form_data (2.0.0)
18
+ http_parser.rb (0.6.0)
19
+ paint (2.0.0)
20
+ parallel (1.12.0)
21
+ parser (2.4.0.0)
22
+ ast (~> 2.2)
23
+ powerpack (0.1.1)
24
+ public_suffix (3.0.0)
25
+ rainbow (2.2.2)
26
+ rake
27
+ rake (12.0.0)
28
+ rex-text (0.2.15)
29
+ rubocop (0.50.0)
30
+ parallel (~> 1.10)
31
+ parser (>= 2.3.3.1, < 3.0)
32
+ powerpack (~> 0.1)
33
+ rainbow (>= 2.2.2, < 3.0)
34
+ ruby-progressbar (~> 1.7)
35
+ unicode-display_width (~> 1.0, >= 1.0.1)
36
+ ruby-progressbar (1.9.0)
37
+ unf (0.1.4)
38
+ unf_ext
39
+ unf_ext (0.0.7.4)
40
+ unf_ext (0.0.7.4-x64-mingw32)
41
+ unicode-display_width (1.3.0)
42
+ whirly (0.2.5)
43
+ unicode-display_width (~> 1.1)
44
+
45
+ PLATFORMS
46
+ ruby
47
+ x64-mingw32
48
+
49
+ DEPENDENCIES
50
+ clipboard
51
+ http
52
+ paint
53
+ rex-text
54
+ rubocop
55
+ whirly
56
+
57
+ BUNDLED WITH
58
+ 1.15.4
data/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2017 Carter Brainerd
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Carter Brainerd
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,53 +1,53 @@
1
- ![rise](https://github.com/cbrnrd/rise/raw/master/img/rise_logo.png)
2
- [![Code Climate](https://codeclimate.com/github/cbrnrd/rise/badges/gpa.svg)](https://codeclimate.com/github/cbrnrd/rise)
3
- [![Build Status](https://travis-ci.org/cbrnrd/rise.svg?branch=master)](https://travis-ci.org/cbrnrd/rise)
4
-
5
-
6
- # Usage
7
-
8
- Using rise is simple, just run the `rise` command
9
-
10
- [![asciicast](https://asciinema.org/a/KfCcwzkm5b5gKOkfJ9vfBcPQz.png)](https://asciinema.org/a/KfCcwzkm5b5gKOkfJ9vfBcPQz)
11
-
12
- ## Installing
13
-
14
- In order to get rise up and running, there's 2 ways you can install it.
15
-
16
- 1. Download the gem
17
-
18
- ```
19
- gem install rise-cli
20
- ```
21
-
22
- 2. Build from source
23
-
24
- ```
25
- $ git clone https://github.com/cbrnrd/rise
26
- $ bundle install
27
- ```
28
-
29
- ## Built With
30
-
31
- - [Rubygems](https://rubygems.org) - the Ruby community's gem hosting service
32
- - [Atom](https://atom.io/) - A hackable text editor for the 21st Century
33
- - [DigitalOcean](https://digitalocean.com) - Used for server hosting
34
-
35
- ## Contributing
36
-
37
- 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
-
39
-
40
- ## Coming soon
41
- - rise.sh registration and 24/7 server uptime
42
- - gzip file transfer
43
- - actual use of the password hash for secure uploads
44
-
45
- ## Authors
46
-
47
- - **Carter Brainerd** - [Website](https://carterbrainerd.me)
48
-
49
- See also the list of [contributors](https://github.com/cbrnrd/rise/contributors) who participated in this project.
50
-
51
- ## License
52
-
53
- This project is licensed under the MIT License - see the [LICENSE](https://github.com/cbrnrd/rise/blob/master/LICENSE) file for details
1
+ ![rise](https://github.com/cbrnrd/rise/raw/master/img/rise_logo.png)
2
+ [![Code Climate](https://codeclimate.com/github/cbrnrd/rise/badges/gpa.svg)](https://codeclimate.com/github/cbrnrd/rise)
3
+ [![Build Status](https://travis-ci.org/cbrnrd/rise.svg?branch=master)](https://travis-ci.org/cbrnrd/rise)
4
+ [![Gem Version](https://badge.fury.io/rb/rise-cli.svg)](https://badge.fury.io/rb/rise-cli)
5
+
6
+ # Usage
7
+
8
+ Using rise is simple, just run the `rise` command
9
+
10
+ [![asciicast](https://asciinema.org/a/Z7aigs1yAaqJWYqL1fQaqv9yt.png)](https://asciinema.org/a/Z7aigs1yAaqJWYqL1fQaqv9yt)
11
+
12
+ ## Installing
13
+
14
+ In order to get rise up and running, there's 2 ways you can install it.
15
+
16
+ 1. Download the gem
17
+
18
+ ```
19
+ gem install rise-cli
20
+ ```
21
+
22
+ 2. Build from source
23
+
24
+ ```
25
+ $ git clone https://github.com/cbrnrd/rise
26
+ $ bundle install
27
+ ```
28
+
29
+ ## Built With
30
+
31
+ - [Rubygems](https://rubygems.org) - the Ruby community's gem hosting service
32
+ - [Atom](https://atom.io/) - A hackable text editor for the 21st Century
33
+ - [DigitalOcean](https://digitalocean.com) - Used for server hosting
34
+
35
+ ## Contributing
36
+
37
+ 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
+
39
+
40
+ ## Coming soon
41
+ - rise.sh registration and 24/7 server uptime
42
+ - gzip file transfer
43
+ - actual use of the password hash for secure uploads
44
+
45
+ ## Authors
46
+
47
+ - **Carter Brainerd** - [Website](https://carterbrainerd.me)
48
+
49
+ See also the list of [contributors](https://github.com/cbrnrd/rise/contributors) who participated in this project.
50
+
51
+ ## License
52
+
53
+ This project is licensed under the MIT License - see the [LICENSE](https://github.com/cbrnrd/rise/blob/master/LICENSE) file for details
data/TODO.txt ADDED
@@ -0,0 +1,3 @@
1
+ TODO things for rise:
2
+ * FIX THE DAMN AUTH ARCHITECTURE SO IT WORKS DAMN IT
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.
data/bin/rise CHANGED
@@ -1,56 +1,55 @@
1
- #!/usr/bin/env ruby
2
-
3
- # TODO
4
- # => fix recursive upload bug where it only uploads the first layer of files (dirs are just blank files)
5
- # => UPDATE: dirs are now dirs, but theyre empty, details on server/server.rb:23-24
6
- # => Try to fix spinner bug on Windows (may be a weird interaction with \r)
7
-
8
- # Put all our core library files in the require path
9
- $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
10
-
11
- require 'core'
12
-
13
- options = {}
14
- OptionParser.new do |opts|
15
- opts.banner = "Usage: #{$PROGRAM_NAME} [options]"
16
-
17
- opts.separator Paint['\nGeneral Options: ', '#95a5a6']
18
- opts.on('-v', '--verbose', 'Run verbosely') do |v|
19
- options[:verbose] = v
20
- end
21
- # directory flag
22
- opts.on('-d DIR', '--dir DIR', String, 'Upload files in DIR') do |d|
23
- options[:directory] = d unless d.nil?
24
- end
25
-
26
- opts.on('-h', '--help', 'Show this help message') do
27
- puts opts
28
- exit
29
- end
30
- end.parse!(ARGV)
31
-
32
- if Rise::Util.is_first_run?
33
- Rise::Util.setup
34
- puts '\nPlease run the `rise` command again to upload your files.'
35
- exit 0
36
- end
37
-
38
- result_url = ''
39
- uploader = Rise::Transport::Uploader.new(options[:directory]) unless options[:directory].nil?
40
- uploader = Rise::Transport::Uploader.new(Dir.pwd) if options[:directory].nil?
41
-
42
-
43
- puts Paint['Thanks for using Rise! Your local source for serverless deployment!', '#95a5a6']
44
-
45
- Whirly.start(spinner: 'dots', status: "Uploading files (#{uploader.total_files} total files)") do
46
- beginning_time = Time.now
47
- sleep 1 # Just to see the spinner if the files are small
48
- result_url = uploader.upload!(options[:verbose]) # Do the file upload
49
-
50
- Whirly.status = 'Done!\n'
51
- Clipboard.copy(result_url)
52
- print Paint["Your url is: #{result_url} (copied to clipboard) ", :bold]
53
- puts Paint["[#{((Time.now - beginning_time)).round(2)}s]", "#95a5a6"]
54
-
55
- puts Paint['Deployment successful!', '#3498db']
56
- end
1
+ #!/usr/bin/env ruby
2
+
3
+ # TODO
4
+ # => fix recursive upload bug where it only uploads the first layer of files (dirs are just blank files)
5
+ # => UPDATE: dirs are now dirs, but theyre empty, details on server/server.rb:23-24
6
+ # => Try to fix spinner bug on Windows (may be a weird interaction with \r)
7
+
8
+ # Put all our core library files in the require path
9
+ $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
10
+
11
+ require 'core'
12
+
13
+ options = {}
14
+ OptionParser.new do |opts|
15
+ opts.banner = "Usage: #{$PROGRAM_NAME} [options]"
16
+
17
+ opts.separator Paint['\nGeneral Options: ', '#95a5a6']
18
+ opts.on('-v', '--verbose', 'Run verbosely') do |v|
19
+ options[:verbose] = v
20
+ end
21
+ # directory flag
22
+ opts.on('-d DIR', '--dir DIR', String, 'Upload files in DIR') do |d|
23
+ options[:directory] = d unless d.nil?
24
+ end
25
+
26
+ opts.on('-h', '--help', 'Show this help message') do
27
+ puts opts
28
+ exit
29
+ end
30
+ end.parse!(ARGV)
31
+
32
+ if Rise::Util.is_first_run?
33
+ Rise::Util.setup
34
+ puts '\nPlease run the `rise` command again to upload your files.'
35
+ exit 0
36
+ end
37
+
38
+ result_url = ''
39
+ uploader = Rise::Transport::Uploader.new(options[:directory]) unless options[:directory].nil?
40
+ uploader = Rise::Transport::Uploader.new(Dir.pwd) if options[:directory].nil?
41
+
42
+
43
+ puts Paint['Thanks for using Rise! Your local source for serverless deployment!', '#95a5a6']
44
+
45
+ Whirly.start(spinner: 'dots', status: "Uploading files (#{uploader.total_files} total files)") do
46
+ beginning_time = Time.now
47
+ result_url = uploader.upload!(options[:verbose]) # Do the file upload
48
+
49
+ Whirly.status = 'Done!\n'
50
+ Clipboard.copy(result_url)
51
+ print Paint["Your url is: #{result_url} (copied to clipboard) ", :bold]
52
+ puts Paint["[#{((Time.now - beginning_time)).round(2)}s]", "#95a5a6"]
53
+
54
+ puts Paint['Deployment successful!', '#3498db']
55
+ end
data/bin/setup ADDED
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ bundle install
@@ -1,4 +1,4 @@
1
- RISE_DATA_DIR = File.join(Dir.home, '.rise')
2
- DOMAIN = 'localhost'.freeze # change to rise.* when i register it
3
- AUTH_PORT = 4567.freeze
4
- UPLOAD_PORT = 8080.freeze
1
+ RISE_DATA_DIR = File.join(Dir.home, '.rise')
2
+ DOMAIN = 'rise.sh'.freeze
3
+ AUTH_PORT = 4567.freeze
4
+ UPLOAD_PORT = 8080.freeze
@@ -1,52 +1,52 @@
1
- ##
2
- # This file handles all communication to the Upto servers
3
- ##
4
- require 'colorize'
5
- require 'rex/text'
6
- require 'uri'
7
- require 'json'
8
- require 'http'
9
-
10
- module Rise
11
- module Transport
12
-
13
- # Handles uploading files
14
- class Uploader
15
-
16
- attr_reader :folder_path, :total_files, :include_folder, :uuid, :current_file
17
- attr_accessor :files
18
-
19
- def initialize(folder_path, include_folder=true)
20
- @folder_path = folder_path
21
- @files = Dir.glob("#{File.absolute_path(folder_path)}/**/*")
22
- @total_files = @files.length
23
- @include_folder = include_folder
24
- @uuid = "#{File.basename(File.absolute_path(folder_path))}-#{Rex::Text::rand_text_alphanumeric(8)}" # Structure: foldername-8RNDLTRS
25
- end
26
-
27
- def upload!(*)
28
- upload_uri_base = "http://rise.sh:8080/api/v1/#{@uuid}"
29
- access_uri = "http://rise.sh/#{@uuid}"
30
- uri = ''
31
-
32
- # This sorts the files by (file path) length.
33
- # It is supposed to make the server make the first layer of files
34
- # before the rest of the layers.
35
- ordered_files = files.sort_by(&:length)
36
- ordered_files.each do |f|
37
- isdir = File.directory?(f)
38
- final_path = File.absolute_path(f).gsub(File.expand_path(folder_path), '')
39
- uri = URI.parse("#{upload_uri_base}/#{final_path}?dir=#{isdir}")
40
- begin
41
- HTTP.put(uri.to_s, :body => File.read(f))
42
- rescue Errno::EISDIR
43
- HTTP.put(uri.to_s, :body => '')
44
- next
45
- end
46
- end
47
- return access_uri
48
- end
49
-
50
- end
51
- end
52
- end
1
+ ##
2
+ # This file handles all communication to the Upto servers
3
+ ##
4
+ require 'colorize'
5
+ require 'rex/text'
6
+ require 'uri'
7
+ require 'json'
8
+ require 'http'
9
+
10
+ module Rise
11
+ module Transport
12
+
13
+ # Handles uploading files
14
+ class Uploader
15
+
16
+ attr_reader :folder_path, :total_files, :include_folder, :uuid, :current_file
17
+ attr_accessor :files
18
+
19
+ def initialize(folder_path, include_folder=true)
20
+ @folder_path = folder_path
21
+ @files = Dir.glob("#{File.absolute_path(folder_path)}/**/*")
22
+ @total_files = @files.length
23
+ @include_folder = include_folder
24
+ @uuid = "#{File.basename(File.absolute_path(folder_path))}-#{Rex::Text::rand_text_alphanumeric(8)}" # Structure: foldername-8RNDLTRS
25
+ end
26
+
27
+ def upload!(*)
28
+ upload_uri_base = "http://rise.sh:8080/api/v1/#{@uuid}"
29
+ access_uri = "http://rise.sh/#{@uuid}"
30
+ uri = ''
31
+
32
+ # This sorts the files by (file path) length.
33
+ # It is supposed to make the server make the first layer of files
34
+ # before the rest of the layers.
35
+ ordered_files = files.sort_by(&:length)
36
+ ordered_files.each do |f|
37
+ isdir = File.directory?(f)
38
+ final_path = File.absolute_path(f).gsub(File.expand_path(folder_path), '')
39
+ uri = URI.parse("#{upload_uri_base}/#{final_path}?dir=#{isdir}")
40
+ begin
41
+ HTTP.put(uri.to_s, :body => File.read(f))
42
+ rescue Errno::EISDIR
43
+ HTTP.put(uri.to_s, :body => '')
44
+ next
45
+ end
46
+ end
47
+ return access_uri
48
+ end
49
+
50
+ end
51
+ end
52
+ end
data/lib/core/util.rb CHANGED
@@ -1,88 +1,88 @@
1
- require 'fileutils'
2
- require 'paint'
3
- require 'json'
4
- require 'http'
5
- require 'digest'
6
- require 'io/console'
7
- require_relative 'constants'
8
-
9
- #
10
- # Utility methods
11
- #
12
- module Rise
13
- module Util
14
-
15
- #
16
- # Checks if rise is being run for the first time
17
- #
18
- def self.is_first_run?
19
- !File.directory?(File.join(Dir.home, '.rise'))
20
- end
21
-
22
- #
23
- # Creates all of the necessary files and login information
24
- #
25
- def self.setup
26
- puts Paint['Detected first time setup, creating necessary files...', :blue]
27
- FileUtils.mkdir(RISE_DATA_DIR)
28
- FileUtils.mkdir(File.join(RISE_DATA_DIR, 'auth'))
29
-
30
- # Get the input from the user
31
- print Paint['1. Log in\n2. Sign up\n > ', :bold]
32
- while (choice = gets.chomp!)
33
- if choice == '1'
34
- login
35
- break
36
- elsif choice == '2'
37
- signup
38
- break
39
- else
40
- puts Paint['Please type `1` or `2`', :red]
41
- next
42
- end
43
- end
44
-
45
- end
46
-
47
- end
48
- end
49
-
50
- # DO NOT USE
51
- def login
52
-
53
- print '\nEmail: '
54
- email = gets.chomp!
55
- print '\nPassword: '
56
- password = STDIN.noecho(&:gets)
57
- hash = Digest::SHA256.hexdigest(password)
58
- res = HTTP.post("http://#{DOMAIN}:#{AUTH_PORT}/login?email=#{email}&hash=#{hash}")
59
- if res.code == 200
60
- puts Paint['\nLogin successful!', :green, :bold]
61
- else
62
- puts Paint['\nLogin failed!', :red, :bold]
63
- puts "Printing error: #{res.code}: #{res.body}"
64
- end
65
- end
66
-
67
- # DO NOT USE
68
- def signup
69
- print '\nEmail: '
70
- email = gets.chomp!
71
- print '\nPassword: '
72
- password = STDIN.noecho(&:gets)
73
- hash = Digest::SHA256.hexdigest(password)
74
- res = HTTP.post("http://#{DOMAIN}:#{AUTH_PORT}/signup?email=#{email}&hash=#{hash}")
75
- if res.code == 200
76
- puts Paint['\nSignup successful!', :green, :bold]
77
- File.open(File.join(RISE_DATA_DIR, 'auth', 'creds.json'), 'a') do |f|
78
- creds_hash = {
79
- 'email' => email,
80
- 'hash' => hash
81
- }
82
- f.puts(creds_hash.to_json)
83
- end
84
- elsif res.code == 409 # user already exists
85
- puts Paint['\nSignup failed!', :red, :bold]
86
- puts "Printing error: #{res.body}"
87
- end
88
- end
1
+ require 'fileutils'
2
+ require 'paint'
3
+ require 'json'
4
+ require 'http'
5
+ require 'digest'
6
+ require 'io/console'
7
+ require_relative 'constants'
8
+
9
+ #
10
+ # Utility methods
11
+ #
12
+ module Rise
13
+ module Util
14
+
15
+ #
16
+ # Checks if rise is being run for the first time
17
+ #
18
+ def self.is_first_run?
19
+ !File.directory?(File.join(Dir.home, '.rise'))
20
+ end
21
+
22
+ #
23
+ # Creates all of the necessary files and login information
24
+ #
25
+ def self.setup
26
+ puts Paint['Detected first time setup, creating necessary files...', :blue]
27
+ FileUtils.mkdir(RISE_DATA_DIR)
28
+ FileUtils.mkdir(File.join(RISE_DATA_DIR, 'auth'))
29
+
30
+ # Get the input from the user
31
+ print Paint['1. Log in\n2. Sign up\n > ', :bold]
32
+ while (choice = gets.chomp!)
33
+ if choice == '1'
34
+ login
35
+ break
36
+ elsif choice == '2'
37
+ signup
38
+ break
39
+ else
40
+ puts Paint['Please type `1` or `2`', :red]
41
+ next
42
+ end
43
+ end
44
+
45
+ end
46
+
47
+ end
48
+ end
49
+
50
+ # DO NOT USE
51
+ def login
52
+
53
+ print '\nEmail: '
54
+ email = gets.chomp!
55
+ print '\nPassword: '
56
+ password = STDIN.noecho(&:gets)
57
+ hash = Digest::SHA256.hexdigest(password)
58
+ res = HTTP.post("http://#{DOMAIN}:#{AUTH_PORT}/login?email=#{email}&hash=#{hash}")
59
+ if res.code == 200
60
+ puts Paint['\nLogin successful!', :green, :bold]
61
+ else
62
+ puts Paint['\nLogin failed!', :red, :bold]
63
+ puts "Printing error: #{res.code}: #{res.body}"
64
+ end
65
+ end
66
+
67
+ # DO NOT USE
68
+ def signup
69
+ print '\nEmail: '
70
+ email = gets.chomp!
71
+ print '\nPassword: '
72
+ password = STDIN.noecho(&:gets)
73
+ hash = Digest::SHA256.hexdigest(password)
74
+ res = HTTP.post("http://#{DOMAIN}:#{AUTH_PORT}/signup?email=#{email}&hash=#{hash}")
75
+ if res.code == 200
76
+ puts Paint['\nSignup successful!', :green, :bold]
77
+ File.open(File.join(RISE_DATA_DIR, 'auth', 'creds.json'), 'a') do |f|
78
+ creds_hash = {
79
+ 'email' => email,
80
+ 'hash' => hash
81
+ }
82
+ f.puts(creds_hash.to_json)
83
+ end
84
+ elsif res.code == 409 # user already exists
85
+ puts Paint['\nSignup failed!', :red, :bold]
86
+ puts "Printing error: #{res.body}"
87
+ end
88
+ end
data/lib/core.rb CHANGED
@@ -1,10 +1,10 @@
1
- # Gems
2
- require 'clipboard'
3
- require 'whirly'
4
- require 'rex/text'
5
- require 'optparse'
6
-
7
- # lib files
8
- require 'core/transport'
9
- require 'core/util'
10
- require 'core/constants'
1
+ # Gems
2
+ require 'clipboard'
3
+ require 'whirly'
4
+ require 'rex/text'
5
+ require 'optparse'
6
+
7
+ # lib files
8
+ require 'core/transport'
9
+ require 'core/util'
10
+ require 'core/constants'
data/rise-cli.gemspec CHANGED
@@ -1,15 +1,23 @@
1
- Gem::Specification.new do |s|
2
- s.name = 'rise-cli'
3
- s.version = '0.1.0'
4
- s.executables << 'rise'
5
- s.date = '2017-10-04'
6
- s.summary = "Simple serverless website deployment"
7
- s.authors = ["Carter Brainerd"]
8
- s.email = '0xCB@protonmail.com'
9
- s.files = `git ls-files`.split($/).reject { |file|
10
- file =~ /^server|rise.gemspec/
11
- }
12
- s.homepage =
13
- 'http://rubygems.org/gems/rise-cli'
14
- s.license = 'MIT'
15
- end
1
+ Gem::Specification.new do |s|
2
+ s.name = 'rise-cli'
3
+ s.version = '0.1.1b'
4
+ s.executables = ['rise']
5
+ s.date = '2017-10-04'
6
+ s.summary = "Simple serverless website deployment"
7
+ s.authors = ["Carter Brainerd"]
8
+ s.email = '0xCB@protonmail.com'
9
+ s.files = `git ls-files`.split($/).reject { |file|
10
+ file =~ /^server|rise.gemspec/
11
+ }
12
+ s.homepage =
13
+ 'http://rubygems.org/gems/rise-cli'
14
+ s.license = 'MIT'
15
+
16
+ s.add_runtime_dependency 'http'
17
+ s.add_runtime_dependency 'paint'
18
+ s.add_runtime_dependency 'clipboard'
19
+ s.add_runtime_dependency 'whirly'
20
+ s.add_runtime_dependency 'rex-text'
21
+
22
+ s.post_install_message = "Thanks for installing rise!\n Just run `rise` to deploy your website."
23
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rise-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1b
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carter Brainerd
@@ -9,7 +9,77 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2017-10-04 00:00:00.000000000 Z
12
- dependencies: []
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: http
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: paint
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: clipboard
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: whirly
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rex-text
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
13
83
  description:
14
84
  email: 0xCB@protonmail.com
15
85
  executables:
@@ -24,7 +94,9 @@ files:
24
94
  - Gemfile.lock
25
95
  - LICENSE
26
96
  - README.md
97
+ - TODO.txt
27
98
  - bin/rise
99
+ - bin/setup
28
100
  - img/rise_logo.png
29
101
  - lib/core.rb
30
102
  - lib/core/constants.rb
@@ -35,7 +107,9 @@ homepage: http://rubygems.org/gems/rise-cli
35
107
  licenses:
36
108
  - MIT
37
109
  metadata: {}
38
- post_install_message:
110
+ post_install_message: |-
111
+ Thanks for installing rise!
112
+ Just run `rise` to deploy your website.
39
113
  rdoc_options: []
40
114
  require_paths:
41
115
  - lib
@@ -46,12 +120,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
46
120
  version: '0'
47
121
  required_rubygems_version: !ruby/object:Gem::Requirement
48
122
  requirements:
49
- - - ">="
123
+ - - ">"
50
124
  - !ruby/object:Gem::Version
51
- version: '0'
125
+ version: 1.3.1
52
126
  requirements: []
53
127
  rubyforge_project:
54
- rubygems_version: 2.5.2
128
+ rubygems_version: 2.6.13
55
129
  signing_key:
56
130
  specification_version: 4
57
131
  summary: Simple serverless website deployment