rise-cli 0.1.1 → 0.1.2

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
  SHA1:
3
- metadata.gz: a2f60a8fa4846b20021e22e34ad21b18caf24b70
4
- data.tar.gz: 0c83c82f070a28ad07581995cab53cfd6f337bef
3
+ metadata.gz: cdef862bc3671000dec6934968dccfc5ec3779b9
4
+ data.tar.gz: 22722f2f0138492a3a04ec258a06289dfd0c37e4
5
5
  SHA512:
6
- metadata.gz: 8746c647f86249cd72acf66f12de70bc6e2ce1d587749b682a714e98df6906c2bfd98256e38b74fe91c049c2d6568c1b22ce12b3faf316ad160ec5cd393c6b64
7
- data.tar.gz: 2d0182ffa07d77851a0a364d533bf6ea7848113a33a1da0d86d3e82603e68a1c4bcb495e72dffecb8df19242c5b01bd6cdd23fc61373747d1b579e3b03275e8e
6
+ metadata.gz: 9ff43ad673f7c55d995affe073202783d0785fb6b33c95a548922f4d2e4e2eb6b9faf9a97d23fd8749f8a0386ded5abd77c9082e1b2afc73c3a0f70eab7b4ca2
7
+ data.tar.gz: 4909d2077e1e42caeadc4454e9da93216dac1937cbbf52bee13259d896fbb77aa178da341232885a36517de3d8e1570612de92822f53135bf7579b00b9828d3a
data/.gitignore CHANGED
@@ -1,8 +1,2 @@
1
- # any test files
2
- *test*
3
-
4
- # compiled gems
5
- rise-*.gem
6
-
7
- # Old html files
8
- views
1
+ # Old html files
2
+ 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
- [![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/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/Rakefile ADDED
@@ -0,0 +1,6 @@
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,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.
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/console ADDED
@@ -0,0 +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__)
data/bin/rise CHANGED
@@ -1,55 +1,50 @@
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
1
+ #!/usr/bin/env ruby
2
+
3
+ # TODO
4
+ # => Try to fix spinner bug on Windows (may be a weird interaction with \r)
5
+
6
+ require 'core'
7
+
8
+ options = {}
9
+ OptionParser.new do |opts|
10
+ opts.banner = "Usage: #{$PROGRAM_NAME} [options]"
11
+
12
+ opts.separator Paint['\nGeneral Options: ', '#95a5a6']
13
+ opts.on('-v', '--verbose', 'Run verbosely') do |v|
14
+ options[:verbose] = v
15
+ end
16
+ # directory flag
17
+ opts.on('-d DIR', '--dir DIR', String, 'Upload files in DIR') do |d|
18
+ options[:directory] = d unless d.nil?
19
+ end
20
+
21
+ opts.on('-h', '--help', 'Show this help message') do
22
+ puts opts
23
+ exit
24
+ end
25
+ end.parse!(ARGV)
26
+
27
+ if Rise::Util.is_first_run?
28
+ Rise::Util.setup
29
+ puts '\nPlease run the `rise` command again to upload your files.'
30
+ exit 0
31
+ end
32
+
33
+ result_url = ''
34
+ uploader = Rise::Transport::Uploader.new(options[:directory]) unless options[:directory].nil?
35
+ uploader = Rise::Transport::Uploader.new(Dir.pwd) if options[:directory].nil?
36
+
37
+
38
+ puts Paint['Thanks for using Rise! Your local source for serverless deployment!', '#95a5a6']
39
+
40
+ Whirly.start(spinner: 'dots', status: "Uploading files (#{uploader.total_files} total files)") do
41
+ beginning_time = Time.now
42
+ result_url = uploader.upload!(options[:verbose]) # Do the file upload
43
+
44
+ Whirly.status = 'Done!\n'
45
+ Clipboard.copy(result_url)
46
+ print Paint["Your url is: #{result_url} (copied to clipboard) ", :bold]
47
+ puts Paint["[#{((Time.now - beginning_time)).round(2)}s]", "#95a5a6"]
48
+
49
+ puts Paint['Deployment successful!', '#3498db']
50
+ end
data/bin/setup CHANGED
@@ -1,3 +1,8 @@
1
- #!/bin/bash
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
2
5
 
3
6
  bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -1,4 +1,13 @@
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
+ RISE_DATA_DIR = File.join(Dir.home, '.rise')
2
+ DOMAIN = 'rise.sh'.freeze
3
+ AUTH_PORT = 4567.freeze
4
+ UPLOAD_PORT = 8080.freeze
5
+
6
+ module Rise
7
+ module Constants
8
+ VERSION = '0.1.2'
9
+ EMAIL = '0xCB@protonmail.com'
10
+ AUTHORS = ['Carter Brainerd']
11
+ NAME = 'rise-cli'
12
+ end
13
+ end
@@ -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'
Binary file
data/rise-cli.gemspec CHANGED
@@ -1,15 +1,25 @@
1
- Gem::Specification.new do |s|
2
- s.name = 'rise-cli'
3
- s.version = '0.1.1'
4
- s.executables = ['rise', 'setup']
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
+ # Put all our core library files in the require path
2
+ $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), 'lib')))
3
+ require 'core'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = Rise::Constants::NAME
7
+ s.version = Rise::Constants::VERSION
8
+ s.executables = ['rise', 'setup', 'console']
9
+ s.date = Time.now.strftime('%Y-%m-%d')
10
+ s.summary = "Simple serverless website deployment"
11
+ s.authors = Rise::Constants::AUTHORS
12
+ s.email = Rise::Constants::EMAIL
13
+ s.files = `git ls-files`.split($/).reject { |file|
14
+ file =~ /^server|^spec/
15
+ }
16
+ s.homepage =
17
+ 'http://rubygems.org/gems/rise-cli'
18
+ s.license = 'MIT'
19
+
20
+ s.add_runtime_dependency 'clipboard'
21
+ s.add_runtime_dependency 'http'
22
+ s.add_runtime_dependency 'paint'
23
+ s.add_runtime_dependency 'rex-text'
24
+ s.add_runtime_dependency 'whirly'
25
+ end
metadata CHANGED
@@ -1,20 +1,91 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rise-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
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-04 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2017-10-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: clipboard
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: http
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: paint
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: rex-text
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: whirly
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:
16
86
  - rise
17
87
  - setup
88
+ - console
18
89
  extensions: []
19
90
  extra_rdoc_files: []
20
91
  files:
@@ -25,7 +96,9 @@ files:
25
96
  - Gemfile.lock
26
97
  - LICENSE
27
98
  - README.md
99
+ - Rakefile
28
100
  - TODO.txt
101
+ - bin/console
29
102
  - bin/rise
30
103
  - bin/setup
31
104
  - img/rise_logo.png
@@ -33,6 +106,7 @@ files:
33
106
  - lib/core/constants.rb
34
107
  - lib/core/transport.rb
35
108
  - lib/core/util.rb
109
+ - pkg/rise-cli-0.1.2.gem
36
110
  - rise-cli.gemspec
37
111
  homepage: http://rubygems.org/gems/rise-cli
38
112
  licenses:
@@ -54,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
54
128
  version: '0'
55
129
  requirements: []
56
130
  rubyforge_project:
57
- rubygems_version: 2.6.13
131
+ rubygems_version: 2.5.2
58
132
  signing_key:
59
133
  specification_version: 4
60
134
  summary: Simple serverless website deployment