rise-cli 0.2.6 → 0.2.7

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: 491baec96860c2e6f397b080d97d6a576c354426
4
- data.tar.gz: 3b8d0b79e45e7a2fc30704369b997b854c335e1e
3
+ metadata.gz: 779d28b4d279139445e1cfc3cabbcb777cc54da6
4
+ data.tar.gz: 6661708ae6aaac054aba24e89b5ff6e5eed92ce3
5
5
  SHA512:
6
- metadata.gz: dd4ee49ecc4fb1c41a1fba834f7befefc47d92b7581155c8132b42f7902ae9e7a5b157cb2ebf444b6a0eafd380dde3e5baf6d12e9ff7e1838753cb6afd514c5b
7
- data.tar.gz: b2ee9cf8347959b817363a26b71584d6831c198393db75fc962f9b288a7a3551bde8ea929aa4b8bc404f548696984e4d0f464ae822eaac3fada730899ed929aa
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.00077 seconds |
4
- ./spec/rise/cli_spec.rb[1:2] | passed | 0.00046 seconds |
5
- ./spec/rise/cli_spec.rb[1:3] | passed | 0.00011 seconds |
6
- ./spec/rise/cli_spec.rb[1:4] | passed | 0.00011 seconds |
7
- ./spec/rise/cli_spec.rb[1:5] | passed | 0.08637 seconds |
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
@@ -2,8 +2,10 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
+ gem 'activesupport'
5
6
  gem 'bcrypt', platforms: :ruby
6
7
  gem 'clipboard'
8
+ gem 'credit_card_validations'
7
9
  gem 'http'
8
10
  gem 'os'
9
11
  gem 'paint'
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.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.0.0)
44
+ rake (12.2.1)
31
45
  rex-text (0.2.15)
32
- rspec (3.6.0)
33
- rspec-core (~> 3.6.0)
34
- rspec-expectations (~> 3.6.0)
35
- rspec-mocks (~> 3.6.0)
36
- rspec-core (3.6.0)
37
- rspec-support (~> 3.6.0)
38
- rspec-expectations (3.6.0)
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.6.0)
41
- rspec-mocks (3.6.0)
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.6.0)
44
- rspec-support (3.6.0)
45
- rubocop (0.50.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.5)
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.15.4
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
- * ADD .riseignore functionality
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
- uploader = Rise::Transport::Uploader.new(dir, ignored)
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!(options[:verbose]) # Do the file upload
102
+ result_url = uploader.upload! # Do the file upload
92
103
 
93
104
  Whirly.status = "Done!\n"
94
105
  Clipboard.copy(result_url)
@@ -8,7 +8,7 @@ module Rise
8
8
  # Holds constants used throughout the framework
9
9
  #
10
10
  module Constants
11
- VERSION = '0.2.6'.freeze
11
+ VERSION = '0.2.7'.freeze
12
12
  EMAIL = '0xCB@protonmail.com'.freeze
13
13
  AUTHORS = ['Carter Brainerd']
14
14
  NAME = 'rise-cli'.freeze
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 -v', '#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
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
  #
@@ -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
- # Uploads the files from +folder_path+ to the upload server
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 < 8
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
@@ -2,8 +2,8 @@
2
2
  require 'clipboard'
3
3
  require 'optparse'
4
4
 
5
+
5
6
  # lib files
6
7
  require 'core/transport'
7
8
  require 'core/util'
8
- require 'core/constants'
9
9
  require 'core/text'
data/rise-cli.gemspec CHANGED
@@ -23,5 +23,5 @@ Gem::Specification.new do |s|
23
23
  s.add_runtime_dependency 'whirly'
24
24
  s.add_runtime_dependency 'bcrypt'
25
25
  s.add_runtime_dependency 'os'
26
-
26
+ s.add_runtime_dependency 'credit_card_validations'
27
27
  end
@@ -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.6
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-01 00:00:00.000000000 Z
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