rise-cli 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec_status +5 -5
- data/Gemfile +2 -0
- data/Gemfile.lock +35 -18
- data/TODO.txt +2 -1
- data/bin/rise +15 -4
- data/lib/core/constants.rb +1 -1
- data/lib/core/text.rb +2 -2
- data/lib/core/transport.rb +14 -6
- data/lib/core/util.rb +24 -2
- data/lib/core.rb +1 -1
- data/rise-cli.gemspec +1 -1
- data/scripts/test_and_build.sh +15 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 779d28b4d279139445e1cfc3cabbcb777cc54da6
|
4
|
+
data.tar.gz: 6661708ae6aaac054aba24e89b5ff6e5eed92ce3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 987b5296e8106cedada429dd17c41340cf5c7db17d3c24529be0677ee89234b6bb7a113fe4720d7f5517133f58a123530875b70712fcd084cac35437a0de4b3f
|
7
|
+
data.tar.gz: 93893150e0e7b1d5c144ab76d694dfc43bff214eef0bc082f64ca234a1178ae02c3e3683231f3b21e7651b578564ce22855eec0b2e43e4fe79c102caa9b34ef5
|
data/.rspec_status
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
example_id | status | run_time |
|
2
2
|
---------------------------- | ------ | --------------- |
|
3
|
-
./spec/rise/cli_spec.rb[1:1] | passed | 0.
|
4
|
-
./spec/rise/cli_spec.rb[1:2] | passed | 0.
|
5
|
-
./spec/rise/cli_spec.rb[1:3] | passed | 0.
|
6
|
-
./spec/rise/cli_spec.rb[1:4] | passed | 0.
|
7
|
-
./spec/rise/cli_spec.rb[1:5] | passed | 0.
|
3
|
+
./spec/rise/cli_spec.rb[1:1] | passed | 0.0012 seconds |
|
4
|
+
./spec/rise/cli_spec.rb[1:2] | passed | 0.00088 seconds |
|
5
|
+
./spec/rise/cli_spec.rb[1:3] | passed | 0.00016 seconds |
|
6
|
+
./spec/rise/cli_spec.rb[1:4] | passed | 0.00015 seconds |
|
7
|
+
./spec/rise/cli_spec.rb[1:5] | passed | 0.08628 seconds |
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,11 +1,22 @@
|
|
1
1
|
GEM
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
|
+
activemodel (5.1.4)
|
5
|
+
activesupport (= 5.1.4)
|
6
|
+
activesupport (5.1.4)
|
7
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
8
|
+
i18n (~> 0.7)
|
9
|
+
minitest (~> 5.1)
|
10
|
+
tzinfo (~> 1.1)
|
4
11
|
addressable (2.5.2)
|
5
12
|
public_suffix (>= 2.0.2, < 4.0)
|
6
13
|
ast (2.3.0)
|
7
14
|
bcrypt (3.1.11)
|
8
15
|
clipboard (1.1.1)
|
16
|
+
concurrent-ruby (1.0.5)
|
17
|
+
credit_card_validations (3.4.0)
|
18
|
+
activemodel (>= 3, <= 6)
|
19
|
+
activesupport (>= 3, <= 6)
|
9
20
|
diff-lcs (1.3)
|
10
21
|
domain_name (0.5.20170404)
|
11
22
|
unf (>= 0.0.5, < 1.0.0)
|
@@ -18,8 +29,11 @@ GEM
|
|
18
29
|
domain_name (~> 0.5)
|
19
30
|
http-form_data (2.0.0)
|
20
31
|
http_parser.rb (0.6.0)
|
32
|
+
i18n (0.9.1)
|
33
|
+
concurrent-ruby (~> 1.0)
|
34
|
+
minitest (5.10.3)
|
21
35
|
os (1.0.0)
|
22
|
-
paint (2.0.
|
36
|
+
paint (2.0.1)
|
23
37
|
parallel (1.12.0)
|
24
38
|
parser (2.4.0.0)
|
25
39
|
ast (~> 2.2)
|
@@ -27,22 +41,22 @@ GEM
|
|
27
41
|
public_suffix (3.0.0)
|
28
42
|
rainbow (2.2.2)
|
29
43
|
rake
|
30
|
-
rake (12.
|
44
|
+
rake (12.2.1)
|
31
45
|
rex-text (0.2.15)
|
32
|
-
rspec (3.
|
33
|
-
rspec-core (~> 3.
|
34
|
-
rspec-expectations (~> 3.
|
35
|
-
rspec-mocks (~> 3.
|
36
|
-
rspec-core (3.
|
37
|
-
rspec-support (~> 3.
|
38
|
-
rspec-expectations (3.
|
46
|
+
rspec (3.7.0)
|
47
|
+
rspec-core (~> 3.7.0)
|
48
|
+
rspec-expectations (~> 3.7.0)
|
49
|
+
rspec-mocks (~> 3.7.0)
|
50
|
+
rspec-core (3.7.0)
|
51
|
+
rspec-support (~> 3.7.0)
|
52
|
+
rspec-expectations (3.7.0)
|
39
53
|
diff-lcs (>= 1.2.0, < 2.0)
|
40
|
-
rspec-support (~> 3.
|
41
|
-
rspec-mocks (3.
|
54
|
+
rspec-support (~> 3.7.0)
|
55
|
+
rspec-mocks (3.7.0)
|
42
56
|
diff-lcs (>= 1.2.0, < 2.0)
|
43
|
-
rspec-support (~> 3.
|
44
|
-
rspec-support (3.
|
45
|
-
rubocop (0.
|
57
|
+
rspec-support (~> 3.7.0)
|
58
|
+
rspec-support (3.7.0)
|
59
|
+
rubocop (0.51.0)
|
46
60
|
parallel (~> 1.10)
|
47
61
|
parser (>= 2.3.3.1, < 3.0)
|
48
62
|
powerpack (~> 0.1)
|
@@ -50,21 +64,24 @@ GEM
|
|
50
64
|
ruby-progressbar (~> 1.7)
|
51
65
|
unicode-display_width (~> 1.0, >= 1.0.1)
|
52
66
|
ruby-progressbar (1.9.0)
|
67
|
+
thread_safe (0.3.6)
|
68
|
+
tzinfo (1.2.4)
|
69
|
+
thread_safe (~> 0.1)
|
53
70
|
unf (0.1.4)
|
54
71
|
unf_ext
|
55
72
|
unf_ext (0.0.7.4)
|
56
|
-
unf_ext (0.0.7.4-x64-mingw32)
|
57
73
|
unicode-display_width (1.3.0)
|
58
|
-
whirly (0.2.
|
74
|
+
whirly (0.2.6)
|
59
75
|
unicode-display_width (~> 1.1)
|
60
76
|
|
61
77
|
PLATFORMS
|
62
78
|
ruby
|
63
|
-
x64-mingw32
|
64
79
|
|
65
80
|
DEPENDENCIES
|
81
|
+
activesupport
|
66
82
|
bcrypt
|
67
83
|
clipboard
|
84
|
+
credit_card_validations
|
68
85
|
http
|
69
86
|
os
|
70
87
|
paint
|
@@ -75,4 +92,4 @@ DEPENDENCIES
|
|
75
92
|
whirly
|
76
93
|
|
77
94
|
BUNDLED WITH
|
78
|
-
1.
|
95
|
+
1.16.0
|
data/TODO.txt
CHANGED
@@ -3,4 +3,5 @@ TODO things for rise:
|
|
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
4
|
* Add said file deletion method
|
5
5
|
* Add GZIP file uploads
|
6
|
-
*
|
6
|
+
* Add free and premium accounts (to the website too)
|
7
|
+
- Add safe CC# storing for the local client
|
data/bin/rise
CHANGED
@@ -5,7 +5,6 @@ require 'core'
|
|
5
5
|
options = {}
|
6
6
|
options[:open] = false
|
7
7
|
options[:ignore_files] = nil
|
8
|
-
# TODO: convert the tasks to use thor or Rex::Parser::Arguments from 'rex'
|
9
8
|
OptionParser.new do |opts|
|
10
9
|
opts.banner = "\nUsage: #{File.basename($PROGRAM_NAME)} [options] [task]\nRise version: #{Rise::Constants::VERSION}"
|
11
10
|
opts.separator Paint["\nGlobal Options: ", '#95a5a6']
|
@@ -14,6 +13,10 @@ OptionParser.new do |opts|
|
|
14
13
|
options[:directory] = d unless d.nil?
|
15
14
|
end
|
16
15
|
|
16
|
+
opts.on('-q', '--quiet', 'Run with very little output (only shows result URL)') do
|
17
|
+
options[:quiet] = true
|
18
|
+
end
|
19
|
+
|
17
20
|
opts.on('-v', '--version', 'Show the rise version and exit') do
|
18
21
|
puts "Rise version: #{Paint[Rise::Constants::VERSION, '#2ecc71']}"
|
19
22
|
exit 0
|
@@ -32,7 +35,7 @@ OptionParser.new do |opts|
|
|
32
35
|
options[:open] = true
|
33
36
|
end
|
34
37
|
|
35
|
-
opts.on('-u', '--update', 'Check if rise has a newer version and install it') do
|
38
|
+
opts.on('-u', '--update', 'Check if rise has a newer version and install it (aliased by `update` task)') do
|
36
39
|
Rise::Util.check_for_update!
|
37
40
|
exit 0
|
38
41
|
end
|
@@ -77,18 +80,26 @@ rescue Errno::ENOENT
|
|
77
80
|
ignored = options[:ignored_files]
|
78
81
|
end
|
79
82
|
|
80
|
-
|
83
|
+
key = JSON.parse(File.read(File.join(RISE_DATA_DIR, 'auth', 'creds.json')))['hash']
|
84
|
+
uploader = Rise::Transport::Uploader.new(dir, key, ignored)
|
81
85
|
|
82
86
|
if uploader.total_files_size > 52428800
|
83
87
|
puts Paint["Max file size reached (#{uploader.total_files_size} > 50MB)", '#FF0000']
|
84
88
|
exit 0
|
85
89
|
end
|
86
90
|
|
91
|
+
if options[:quiet]
|
92
|
+
result_url = uploader.upload!
|
93
|
+
Clipboard.copy(result_url)
|
94
|
+
print Paint["Your url is: #{result_url} (copied to clipboard) ", :bold]
|
95
|
+
exit 0
|
96
|
+
end
|
97
|
+
|
87
98
|
puts Paint['Thanks for using Rise! Your local source for serverless deployment!', '#95a5a6']
|
88
99
|
|
89
100
|
Whirly.start(spinner: 'dots', status: "Uploading files (#{uploader.total_files} total files)") do
|
90
101
|
beginning_time = Time.now
|
91
|
-
result_url = uploader.upload!
|
102
|
+
result_url = uploader.upload! # Do the file upload
|
92
103
|
|
93
104
|
Whirly.status = "Done!\n"
|
94
105
|
Clipboard.copy(result_url)
|
data/lib/core/constants.rb
CHANGED
data/lib/core/text.rb
CHANGED
@@ -9,8 +9,8 @@ module Rise
|
|
9
9
|
update Updates the current rise-cli installation (aliased by -u)
|
10
10
|
|
11
11
|
#{Paint['Examples:', '#95a5a6']}
|
12
|
-
#{Paint['$ rise init
|
13
|
-
#{Paint['$ rise -d ../my-project -o', '#2ecc71']}
|
12
|
+
#{Paint['$ rise init --verbose', '#2ecc71']} Reinitializes your password with verbose output
|
13
|
+
#{Paint['$ rise -d ../my-project -o', '#2ecc71']} Will upload all files in `../my-project` and open it in a browser
|
14
14
|
}
|
15
15
|
|
16
16
|
#
|
data/lib/core/transport.rb
CHANGED
@@ -2,6 +2,8 @@ require 'rex/text'
|
|
2
2
|
require 'uri'
|
3
3
|
require 'json'
|
4
4
|
require 'http'
|
5
|
+
require 'active_support'
|
6
|
+
|
5
7
|
|
6
8
|
module Rise
|
7
9
|
#
|
@@ -11,10 +13,10 @@ module Rise
|
|
11
13
|
# Handles uploading files
|
12
14
|
class Uploader
|
13
15
|
attr_reader :folder_path, :total_files, :include_folder
|
14
|
-
attr_reader :uuid, :current_file, :total_files_size
|
16
|
+
attr_reader :uuid, :current_file, :total_files_size, :key
|
15
17
|
attr_accessor :files
|
16
18
|
|
17
|
-
def initialize(folder_path, excluded_files = [], include_folder = true)
|
19
|
+
def initialize(folder_path, key, excluded_files = [], include_folder = true)
|
18
20
|
excluded_files.map! do |a|
|
19
21
|
File.join(File.absolute_path(folder_path), a)
|
20
22
|
end unless excluded_files.nil?
|
@@ -25,13 +27,19 @@ module Rise
|
|
25
27
|
@total_files_size = calculate_files_size
|
26
28
|
@include_folder = include_folder
|
27
29
|
@uuid = "#{File.basename(File.absolute_path(folder_path)).gsub('_', '-')}-#{Rex::Text.rand_text_alphanumeric(8)}" # Structure: foldername-8RNDLTRS
|
30
|
+
@key = key
|
28
31
|
end
|
29
32
|
|
33
|
+
# This makes a HTTP +PUT+ request on port 8080 to the /api/v1/ endpoint
|
34
|
+
# for each file in the selected folder.
|
35
|
+
#
|
36
|
+
# The body of the request is the contents of the file.
|
30
37
|
#
|
31
|
-
#
|
38
|
+
# The +Authorization+ request header is used for making the .keyfile on the serverside
|
39
|
+
# for the future file deletion method.
|
32
40
|
# @return String the final URL of the uploaded contents
|
33
41
|
#
|
34
|
-
def upload!
|
42
|
+
def upload!
|
35
43
|
upload_uri_base = "http://rise.sh:8080/api/v1/#{@uuid}"
|
36
44
|
access_uri = "https://rise.sh/#{@uuid}"
|
37
45
|
uri = ''
|
@@ -46,9 +54,9 @@ module Rise
|
|
46
54
|
File.expand_path(folder_path), '')
|
47
55
|
uri = URI.parse("#{upload_uri_base}/#{final_path.gsub(' ', '')}?dir=#{isdir}")
|
48
56
|
begin
|
49
|
-
HTTP.put(uri.to_s, body: File.read(f))
|
57
|
+
HTTP.auth("#{key}").put(uri.to_s, body: ActiveSupport::Gzip.compress(File.read(f)))
|
50
58
|
rescue Errno::EISDIR
|
51
|
-
HTTP.put(uri.to_s, body: '')
|
59
|
+
HTTP.auth("#{key}").put(uri.to_s, body: '')
|
52
60
|
next
|
53
61
|
end
|
54
62
|
end
|
data/lib/core/util.rb
CHANGED
@@ -7,6 +7,7 @@ require 'io/console'
|
|
7
7
|
require 'whirly'
|
8
8
|
require 'os'
|
9
9
|
require 'json'
|
10
|
+
require 'credit_card_validations'
|
10
11
|
require_relative 'constants'
|
11
12
|
|
12
13
|
module Rise
|
@@ -47,7 +48,6 @@ module Rise
|
|
47
48
|
current_version = JSON.parse(HTTP.get('https://rubygems.org/api/v1/versions/rise-cli/latest.json'))['version']
|
48
49
|
|
49
50
|
current_version_i = current_version.gsub('.', '').to_i
|
50
|
-
puts "#{current_version_i} #{Rise::Constants::VERSION.gsub('.', '').to_i}"
|
51
51
|
|
52
52
|
if current_version_i > Rise::Constants::VERSION.gsub('.', '').to_i
|
53
53
|
Whirly.start(
|
@@ -82,7 +82,8 @@ module Rise
|
|
82
82
|
|
83
83
|
puts Paint['Create a password to secure your uploads.', :bold]
|
84
84
|
pw = Rise::Util.signup
|
85
|
-
while pw.length
|
85
|
+
while (length = pw.length)
|
86
|
+
break if length > 8
|
86
87
|
puts Paint["Password not long enough,
|
87
88
|
it has to be longer than 8 characters\n", :red]
|
88
89
|
pw = Rise::Util.signup
|
@@ -111,5 +112,26 @@ module Rise
|
|
111
112
|
end
|
112
113
|
end
|
113
114
|
|
115
|
+
|
116
|
+
# @param number [String] the credit card number to add
|
117
|
+
def self.add_cc_number(number)
|
118
|
+
if !number.is_a?(String)
|
119
|
+
raise ArgumentError, '`number` must be of type String'
|
120
|
+
end
|
121
|
+
|
122
|
+
if !CreditCardValidations::Detector.new(number).valid?
|
123
|
+
puts Paint['Credit card is not valid']
|
124
|
+
return
|
125
|
+
end
|
126
|
+
|
127
|
+
File.open(File.join(RISE_DIR, 'auth', 'payment', 'cc.json'), 'w') do |c|
|
128
|
+
c.puts(JSON.pretty_generate({'cc' => number}))
|
129
|
+
end
|
130
|
+
|
131
|
+
# TODO make a request to the backend to store the cc in db
|
132
|
+
|
133
|
+
puts 'Credit card stored for later use.'
|
134
|
+
end
|
135
|
+
|
114
136
|
end
|
115
137
|
end
|
data/lib/core.rb
CHANGED
data/rise-cli.gemspec
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
cd ..
|
3
|
+
rspec
|
4
|
+
if [[ "$?" -ne "0" ]]; then
|
5
|
+
echo -e "\033[0;31mTests failed, not building the gem\033[0;0m"
|
6
|
+
exit $?
|
7
|
+
fi
|
8
|
+
|
9
|
+
rubocop --fail-level W
|
10
|
+
if [[ "$?" -ne "0" ]]; then
|
11
|
+
echo -e "\033[0;31mRubocop failed, not building the gem\033[0;0m"
|
12
|
+
exit $?
|
13
|
+
fi
|
14
|
+
|
15
|
+
rake build
|
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.2.
|
4
|
+
version: 0.2.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-11-
|
11
|
+
date: 2017-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clipboard
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: credit_card_validations
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
111
125
|
description:
|
112
126
|
email: 0xCB@protonmail.com
|
113
127
|
executables:
|
@@ -136,6 +150,7 @@ files:
|
|
136
150
|
- lib/core/transport.rb
|
137
151
|
- lib/core/util.rb
|
138
152
|
- rise-cli.gemspec
|
153
|
+
- scripts/test_and_build.sh
|
139
154
|
homepage: http://rubygems.org/gems/rise-cli
|
140
155
|
licenses:
|
141
156
|
- MIT
|