rise-cli 0.2.9 → 0.3.0

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.
data/lib/core/util.rb CHANGED
@@ -1,144 +1,144 @@
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
- if src == 2
46
- Rise::Text.vputs("Source: RubyGems")
47
- elsif src == 1
48
- Rise::Text.vputs("Source: git")
49
- else
50
- Rise::Text.vputs("Source: unknown")
51
- end
52
-
53
- begin
54
- if src == 2 # if the gem was downloaded from rubygems
55
- current_version = JSON.parse(HTTP.get('https://rubygems.org/api/v1/versions/rise-cli/latest.json'))['version']
56
-
57
- current_version_i = current_version.gsub('.', '').to_i
58
-
59
- if current_version_i > Rise::Constants::VERSION.gsub('.', '').to_i
60
- Whirly.start(
61
- spinner: 'line',
62
- status: "New version available (#{Paint[Rise::Constants::VERSION, 'red']} -> #{Paint[current_version, '#3498db']}), updating..."
63
- ) do
64
- system("gem install rise-cli")
65
- puts Paint["Update complete, just run #{Paint['`rise`', '#3498db']} to deploy"]
66
- end
67
- end
68
- elsif src == 1
69
- Rise::Text.vputs("It seems you're on bleeding edge, fetching new changes...")
70
- Rise::Text.vputs("Updating from #{`git show --no-color --oneline -s`.split(' ')[0]} to #{`git rev-parse --short HEAD`}")
71
- `git pull`
72
- puts Paint["Update complete, just run #{Paint['`rise`', '#3498db']} to deploy"]
73
- end
74
- rescue StandardError => e
75
- puts "Unable to check for updates. Error: #{Paint[e.message, 'red']}"
76
- exit 1
77
- end
78
- end
79
-
80
- #
81
- # Creates all of the necessary files and login information
82
- #
83
- def self.setup(first = true)
84
- if first
85
- puts Paint['Detected first time setup, creating necessary files...', :blue]
86
- FileUtils.mkdir(RISE_DATA_DIR)
87
- FileUtils.mkdir(File.join(RISE_DATA_DIR, 'auth'))
88
- end
89
-
90
- puts Paint['Create a password to secure your uploads.', :bold]
91
- pw = Rise::Util.signup
92
- while (length = pw.length)
93
- break if length > 8
94
- puts Paint["Password not long enough,
95
- it has to be longer than 8 characters\n", :red]
96
- pw = Rise::Util.signup
97
- end
98
- File.open(File.join(RISE_DATA_DIR, 'auth', 'creds.json'), 'w') do |f|
99
- Rise::Text.vputs("\nWriting hash to creds.json...")
100
- creds_hash = { 'hash' => BCrypt::Password.create(pw) }
101
- f.puts(JSON.pretty_generate(creds_hash))
102
- end
103
- puts "\nAll done!\nRun #{Paint['`rise`', '#3498db']} to deploy"
104
- end
105
-
106
- def self.signup
107
- print 'Password: '
108
- STDIN.noecho(&:gets).chomp
109
- end
110
-
111
- #
112
- # Opens +url+ in a web browser if possible
113
- #
114
- def self.open_deployment_in_browser(url)
115
- if OS.windows?
116
- system("START \"\" \"#{url}\"")
117
- else
118
- system("open #{url}")
119
- end
120
- end
121
-
122
-
123
- # @param number [String] the credit card number to add
124
- def self.add_cc_number(number)
125
- if !number.is_a?(String)
126
- raise ArgumentError, '`number` must be of type String'
127
- end
128
-
129
- if !CreditCardValidations::Detector.new(number).valid?
130
- puts Paint['Credit card is not valid']
131
- return
132
- end
133
-
134
- File.open(File.join(RISE_DIR, 'auth', 'payment', 'cc.json'), 'w') do |c|
135
- c.puts(JSON.pretty_generate({'cc' => number}))
136
- end
137
-
138
- # TODO make a request to the backend to store the cc in db
139
-
140
- puts 'Credit card stored for later use.'
141
- end
142
-
143
- end
144
- 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
+ if src == 2
46
+ Rise::Text.vputs("Source: RubyGems")
47
+ elsif src == 1
48
+ Rise::Text.vputs("Source: git")
49
+ else
50
+ Rise::Text.vputs("Source: unknown")
51
+ end
52
+
53
+ begin
54
+ if src == 2 # if the gem was downloaded from rubygems
55
+ current_version = JSON.parse(HTTP.get('https://rubygems.org/api/v1/versions/rise-cli/latest.json'))['version']
56
+
57
+ current_version_i = current_version.gsub('.', '').to_i
58
+
59
+ if current_version_i > Rise::Constants::VERSION.gsub('.', '').to_i
60
+ Whirly.start(
61
+ spinner: 'line',
62
+ status: "New version available (#{Paint[Rise::Constants::VERSION, 'red']} -> #{Paint[current_version, '#3498db']}), updating..."
63
+ ) do
64
+ system("gem install rise-cli")
65
+ puts Paint["Update complete, just run #{Paint['`rise`', '#3498db']} to deploy"]
66
+ end
67
+ end
68
+ elsif src == 1
69
+ Rise::Text.vputs("It seems you're on bleeding edge, fetching new changes...")
70
+ Rise::Text.vputs("Updating from #{`git show --no-color --oneline -s`.split(' ')[0]} to #{`git rev-parse --short HEAD`}")
71
+ `git pull`
72
+ puts Paint["Update complete, just run #{Paint['`rise`', '#3498db']} to deploy"]
73
+ end
74
+ rescue StandardError => e
75
+ puts "Unable to check for updates. Error: #{Paint[e.message, 'red']}"
76
+ exit 1
77
+ end
78
+ end
79
+
80
+ #
81
+ # Creates all of the necessary files and login information
82
+ #
83
+ def self.setup(first = true)
84
+ if first
85
+ puts Paint['Detected first time setup, creating necessary files...', :blue]
86
+ FileUtils.mkdir(RISE_DATA_DIR)
87
+ FileUtils.mkdir(File.join(RISE_DATA_DIR, 'auth'))
88
+ end
89
+
90
+ puts Paint['Create a password to secure your uploads.', :bold]
91
+ pw = Rise::Util.signup
92
+ while (length = pw.length)
93
+ break if length > 8
94
+ puts Paint["Password not long enough,
95
+ it has to be longer than 8 characters\n", :red]
96
+ pw = Rise::Util.signup
97
+ end
98
+ File.open(File.join(RISE_DATA_DIR, 'auth', 'creds.json'), 'w') do |f|
99
+ Rise::Text.vputs("\nWriting hash to creds.json...")
100
+ creds_hash = { 'hash' => BCrypt::Password.create(pw) }
101
+ f.puts(JSON.pretty_generate(creds_hash))
102
+ end
103
+ puts "\nAll done!\nRun #{Paint['`rise`', '#3498db']} to deploy"
104
+ end
105
+
106
+ def self.signup
107
+ print 'Password: '
108
+ STDIN.noecho(&:gets).chomp
109
+ end
110
+
111
+ #
112
+ # Opens +url+ in a web browser if possible
113
+ #
114
+ def self.open_deployment_in_browser(url)
115
+ if OS.windows?
116
+ system("START \"\" \"#{url}\"")
117
+ else
118
+ system("open #{url}")
119
+ end
120
+ end
121
+
122
+
123
+ # @param number [String] the credit card number to add
124
+ def self.add_cc_number(number)
125
+ if !number.is_a?(String)
126
+ raise ArgumentError, '`number` must be of type String'
127
+ end
128
+
129
+ if !CreditCardValidations::Detector.new(number).valid?
130
+ puts Paint['Credit card is not valid']
131
+ return
132
+ end
133
+
134
+ File.open(File.join(RISE_DIR, 'auth', 'payment', 'cc.json'), 'w') do |c|
135
+ c.puts(JSON.pretty_generate({'cc' => number}))
136
+ end
137
+
138
+ # TODO make a request to the backend to store the cc in db
139
+
140
+ puts 'Credit card stored for later use.'
141
+ end
142
+
143
+ end
144
+ 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
@@ -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.9
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carter Brainerd
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-18 00:00:00.000000000 Z
11
+ date: 2018-03-25 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.5.2
174
+ rubygems_version: 2.5.1
175
175
  signing_key:
176
176
  specification_version: 4
177
177
  summary: Simple serverless website deployment