rise-cli 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -2
- data/.rspec_status +7 -7
- data/.rubocop.yml +2 -2
- data/.travis.yml +9 -9
- data/CONTRIBUTING.md +27 -27
- data/Gemfile +16 -16
- data/Gemfile.lock +97 -95
- data/LICENSE +21 -21
- data/README.md +62 -63
- data/Rakefile +6 -6
- data/TODO.txt +6 -7
- data/bin/console +14 -14
- data/bin/rise +112 -112
- data/bin/setup +0 -0
- data/lib/core/constants.rb +17 -17
- data/lib/core/text.rb +23 -23
- data/lib/core/transport.rb +75 -73
- data/lib/core/util.rb +137 -137
- data/lib/core.rb +9 -9
- data/rise-cli.gemspec +27 -27
- data/scripts/test_and_build.sh +15 -15
- metadata +3 -3
data/lib/core/util.rb
CHANGED
@@ -1,137 +1,137 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
require 'paint'
|
3
|
-
require 'json'
|
4
|
-
require 'http'
|
5
|
-
require 'bcrypt'
|
6
|
-
require 'io/console'
|
7
|
-
require 'whirly'
|
8
|
-
require 'os'
|
9
|
-
require 'json'
|
10
|
-
require 'credit_card_validations'
|
11
|
-
require_relative 'constants'
|
12
|
-
|
13
|
-
module Rise
|
14
|
-
#
|
15
|
-
# Utility methods
|
16
|
-
#
|
17
|
-
module Util
|
18
|
-
#
|
19
|
-
# Checks if rise is being run for the first time
|
20
|
-
#
|
21
|
-
def self.first_run?
|
22
|
-
!File.directory?(File.join(Dir.home, '.rise'))
|
23
|
-
end
|
24
|
-
|
25
|
-
#
|
26
|
-
# 1 = git, 2 = gem, 3 = unknown
|
27
|
-
#
|
28
|
-
def self.git_or_gem?
|
29
|
-
gem = nil
|
30
|
-
return 1 if File.exist?(File.join(Rise::Constants::RISE_DIR, '.git'))
|
31
|
-
if OS.windows?
|
32
|
-
gem = system('which gem > NUL')
|
33
|
-
else
|
34
|
-
gem = system('which gem > /dev/null')
|
35
|
-
end
|
36
|
-
return 2 if gem
|
37
|
-
3
|
38
|
-
end
|
39
|
-
|
40
|
-
#
|
41
|
-
# Check for a new version of the gem
|
42
|
-
#
|
43
|
-
def self.check_for_update!
|
44
|
-
src = Rise::Util.git_or_gem?
|
45
|
-
Rise::Text.vputs("Source: #{src}")
|
46
|
-
begin
|
47
|
-
if src == 2 # if the gem was downloaded from rubygems
|
48
|
-
current_version = JSON.parse(HTTP.get('https://rubygems.org/api/v1/versions/rise-cli/latest.json'))['version']
|
49
|
-
|
50
|
-
current_version_i = current_version.gsub('.', '').to_i
|
51
|
-
|
52
|
-
if current_version_i > Rise::Constants::VERSION.gsub('.', '').to_i
|
53
|
-
Whirly.start(
|
54
|
-
spinner: 'line',
|
55
|
-
status: "New version available (#{Paint[Rise::Constants::VERSION, 'red']} -> #{Paint[current_version, '#3498db']}), updating..."
|
56
|
-
) do
|
57
|
-
system("gem install rise-cli")
|
58
|
-
puts Paint["Update complete, just run #{Paint['`rise`', '#3498db']} to deploy"]
|
59
|
-
end
|
60
|
-
end
|
61
|
-
elsif src == 1
|
62
|
-
Rise::Text.vputs("It seems you're on bleeding edge, fetching new changes...")
|
63
|
-
Rise::Text.vputs("Updating from #{`git show --no-color --oneline -s`.split(' ')[0]} to #{`git rev-parse --short HEAD`}")
|
64
|
-
`git pull`
|
65
|
-
puts Paint["Update complete, just run #{Paint['`rise`', '#3498db']} to deploy"]
|
66
|
-
end
|
67
|
-
rescue StandardError => e
|
68
|
-
puts "Unable to check for updates. Error: #{Paint[e.message, 'red']}"
|
69
|
-
exit 1
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
#
|
74
|
-
# Creates all of the necessary files and login information
|
75
|
-
#
|
76
|
-
def self.setup(first = true)
|
77
|
-
if first
|
78
|
-
puts Paint['Detected first time setup, creating necessary files...', :blue]
|
79
|
-
FileUtils.mkdir(RISE_DATA_DIR)
|
80
|
-
FileUtils.mkdir(File.join(RISE_DATA_DIR, 'auth'))
|
81
|
-
end
|
82
|
-
|
83
|
-
puts Paint['Create a password to secure your uploads.', :bold]
|
84
|
-
pw = Rise::Util.signup
|
85
|
-
while (length = pw.length)
|
86
|
-
break if length > 8
|
87
|
-
puts Paint["Password not long enough,
|
88
|
-
it has to be longer than 8 characters\n", :red]
|
89
|
-
pw = Rise::Util.signup
|
90
|
-
end
|
91
|
-
File.open(File.join(RISE_DATA_DIR, 'auth', 'creds.json'), 'w') do |f|
|
92
|
-
Rise::Text.vputs("\nWriting hash to creds.json...")
|
93
|
-
creds_hash = { 'hash' => BCrypt::Password.create(pw) }
|
94
|
-
f.puts(JSON.pretty_generate(creds_hash))
|
95
|
-
end
|
96
|
-
puts "\nAll done!\nRun #{Paint['`rise`', '#3498db']} to deploy"
|
97
|
-
end
|
98
|
-
|
99
|
-
def self.signup
|
100
|
-
print 'Password: '
|
101
|
-
STDIN.noecho(&:gets).chomp
|
102
|
-
end
|
103
|
-
|
104
|
-
#
|
105
|
-
# Opens +url+ in a web browser if possible
|
106
|
-
#
|
107
|
-
def self.open_deployment_in_browser(url)
|
108
|
-
if OS.windows?
|
109
|
-
system("START \"\" \"#{url}\"")
|
110
|
-
else
|
111
|
-
system("open #{url}")
|
112
|
-
end
|
113
|
-
end
|
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
|
-
|
136
|
-
end
|
137
|
-
end
|
1
|
+
require 'fileutils'
|
2
|
+
require 'paint'
|
3
|
+
require 'json'
|
4
|
+
require 'http'
|
5
|
+
require 'bcrypt'
|
6
|
+
require 'io/console'
|
7
|
+
require 'whirly'
|
8
|
+
require 'os'
|
9
|
+
require 'json'
|
10
|
+
require 'credit_card_validations'
|
11
|
+
require_relative 'constants'
|
12
|
+
|
13
|
+
module Rise
|
14
|
+
#
|
15
|
+
# Utility methods
|
16
|
+
#
|
17
|
+
module Util
|
18
|
+
#
|
19
|
+
# Checks if rise is being run for the first time
|
20
|
+
#
|
21
|
+
def self.first_run?
|
22
|
+
!File.directory?(File.join(Dir.home, '.rise'))
|
23
|
+
end
|
24
|
+
|
25
|
+
#
|
26
|
+
# 1 = git, 2 = gem, 3 = unknown
|
27
|
+
#
|
28
|
+
def self.git_or_gem?
|
29
|
+
gem = nil
|
30
|
+
return 1 if File.exist?(File.join(Rise::Constants::RISE_DIR, '.git'))
|
31
|
+
if OS.windows?
|
32
|
+
gem = system('which gem > NUL')
|
33
|
+
else
|
34
|
+
gem = system('which gem > /dev/null')
|
35
|
+
end
|
36
|
+
return 2 if gem
|
37
|
+
3
|
38
|
+
end
|
39
|
+
|
40
|
+
#
|
41
|
+
# Check for a new version of the gem
|
42
|
+
#
|
43
|
+
def self.check_for_update!
|
44
|
+
src = Rise::Util.git_or_gem?
|
45
|
+
Rise::Text.vputs("Source: #{src}")
|
46
|
+
begin
|
47
|
+
if src == 2 # if the gem was downloaded from rubygems
|
48
|
+
current_version = JSON.parse(HTTP.get('https://rubygems.org/api/v1/versions/rise-cli/latest.json'))['version']
|
49
|
+
|
50
|
+
current_version_i = current_version.gsub('.', '').to_i
|
51
|
+
|
52
|
+
if current_version_i > Rise::Constants::VERSION.gsub('.', '').to_i
|
53
|
+
Whirly.start(
|
54
|
+
spinner: 'line',
|
55
|
+
status: "New version available (#{Paint[Rise::Constants::VERSION, 'red']} -> #{Paint[current_version, '#3498db']}), updating..."
|
56
|
+
) do
|
57
|
+
system("gem install rise-cli")
|
58
|
+
puts Paint["Update complete, just run #{Paint['`rise`', '#3498db']} to deploy"]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
elsif src == 1
|
62
|
+
Rise::Text.vputs("It seems you're on bleeding edge, fetching new changes...")
|
63
|
+
Rise::Text.vputs("Updating from #{`git show --no-color --oneline -s`.split(' ')[0]} to #{`git rev-parse --short HEAD`}")
|
64
|
+
`git pull`
|
65
|
+
puts Paint["Update complete, just run #{Paint['`rise`', '#3498db']} to deploy"]
|
66
|
+
end
|
67
|
+
rescue StandardError => e
|
68
|
+
puts "Unable to check for updates. Error: #{Paint[e.message, 'red']}"
|
69
|
+
exit 1
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
#
|
74
|
+
# Creates all of the necessary files and login information
|
75
|
+
#
|
76
|
+
def self.setup(first = true)
|
77
|
+
if first
|
78
|
+
puts Paint['Detected first time setup, creating necessary files...', :blue]
|
79
|
+
FileUtils.mkdir(RISE_DATA_DIR)
|
80
|
+
FileUtils.mkdir(File.join(RISE_DATA_DIR, 'auth'))
|
81
|
+
end
|
82
|
+
|
83
|
+
puts Paint['Create a password to secure your uploads.', :bold]
|
84
|
+
pw = Rise::Util.signup
|
85
|
+
while (length = pw.length)
|
86
|
+
break if length > 8
|
87
|
+
puts Paint["Password not long enough,
|
88
|
+
it has to be longer than 8 characters\n", :red]
|
89
|
+
pw = Rise::Util.signup
|
90
|
+
end
|
91
|
+
File.open(File.join(RISE_DATA_DIR, 'auth', 'creds.json'), 'w') do |f|
|
92
|
+
Rise::Text.vputs("\nWriting hash to creds.json...")
|
93
|
+
creds_hash = { 'hash' => BCrypt::Password.create(pw) }
|
94
|
+
f.puts(JSON.pretty_generate(creds_hash))
|
95
|
+
end
|
96
|
+
puts "\nAll done!\nRun #{Paint['`rise`', '#3498db']} to deploy"
|
97
|
+
end
|
98
|
+
|
99
|
+
def self.signup
|
100
|
+
print 'Password: '
|
101
|
+
STDIN.noecho(&:gets).chomp
|
102
|
+
end
|
103
|
+
|
104
|
+
#
|
105
|
+
# Opens +url+ in a web browser if possible
|
106
|
+
#
|
107
|
+
def self.open_deployment_in_browser(url)
|
108
|
+
if OS.windows?
|
109
|
+
system("START \"\" \"#{url}\"")
|
110
|
+
else
|
111
|
+
system("open #{url}")
|
112
|
+
end
|
113
|
+
end
|
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
|
+
|
136
|
+
end
|
137
|
+
end
|
data/lib/core.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
# Gems
|
2
|
-
require 'clipboard'
|
3
|
-
require 'optparse'
|
4
|
-
|
5
|
-
|
6
|
-
# lib files
|
7
|
-
require 'core/transport'
|
8
|
-
require 'core/util'
|
9
|
-
require 'core/text'
|
1
|
+
# Gems
|
2
|
+
require 'clipboard'
|
3
|
+
require 'optparse'
|
4
|
+
|
5
|
+
|
6
|
+
# lib files
|
7
|
+
require 'core/transport'
|
8
|
+
require 'core/util'
|
9
|
+
require 'core/text'
|
data/rise-cli.gemspec
CHANGED
@@ -1,27 +1,27 @@
|
|
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 = %w[rise]
|
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|^pkg/
|
15
|
-
}
|
16
|
-
s.homepage = 'http://rubygems.org/gems/rise-cli'
|
17
|
-
s.license = 'MIT'
|
18
|
-
|
19
|
-
s.add_runtime_dependency 'clipboard'
|
20
|
-
s.add_runtime_dependency 'http'
|
21
|
-
s.add_runtime_dependency 'paint'
|
22
|
-
s.add_runtime_dependency 'rex-text'
|
23
|
-
s.add_runtime_dependency 'whirly'
|
24
|
-
s.add_runtime_dependency 'bcrypt'
|
25
|
-
s.add_runtime_dependency 'os'
|
26
|
-
s.add_runtime_dependency 'credit_card_validations'
|
27
|
-
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 = %w[rise]
|
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|^pkg/
|
15
|
+
}
|
16
|
+
s.homepage = 'http://rubygems.org/gems/rise-cli'
|
17
|
+
s.license = 'MIT'
|
18
|
+
|
19
|
+
s.add_runtime_dependency 'clipboard'
|
20
|
+
s.add_runtime_dependency 'http'
|
21
|
+
s.add_runtime_dependency 'paint'
|
22
|
+
s.add_runtime_dependency 'rex-text'
|
23
|
+
s.add_runtime_dependency 'whirly'
|
24
|
+
s.add_runtime_dependency 'bcrypt'
|
25
|
+
s.add_runtime_dependency 'os'
|
26
|
+
s.add_runtime_dependency 'credit_card_validations'
|
27
|
+
end
|
data/scripts/test_and_build.sh
CHANGED
@@ -1,15 +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
|
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.8
|
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-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clipboard
|
@@ -171,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
171
171
|
version: '0'
|
172
172
|
requirements: []
|
173
173
|
rubyforge_project:
|
174
|
-
rubygems_version: 2.
|
174
|
+
rubygems_version: 2.5.2
|
175
175
|
signing_key:
|
176
176
|
specification_version: 4
|
177
177
|
summary: Simple serverless website deployment
|