rise-cli 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a042babbf5841cea38ff6f817a897df81b5ac7ed
4
- data.tar.gz: 62f51e2ecba07e27d7e0caf2b303a435bc068561
3
+ metadata.gz: '0185e22100dd231bed9d7cc3e4fc3cc499dcf47a'
4
+ data.tar.gz: 7e5a6316aa1d540f4c78eb2871bce557ed1f4adb
5
5
  SHA512:
6
- metadata.gz: 9a0c45a41b6915c3b2b6f6eed4564e9333a4f87d7f3802b71f1772510de68d21cef19a9e11f0d1ec0e242e0a3d14ef98ac4615f617a277b10702b3aa8437c97e
7
- data.tar.gz: 206827025f32604d2df360a2bcf1ffa1e8563c156f4a78dad4643b4a2310688c6f1fd5b20b66ed4803703d6e22f908525dcd5fa7f9615b951a55596f0ce8f318
6
+ metadata.gz: 9050d3c0c38806fdce3b774430191df4787da7bf7c143935d0865b241cb19fcaf6282c8de6cef250c12809a569491cbab83ec78cf884c179f25850fd96c84a7c
7
+ data.tar.gz: d82f52379586644f1895772621eb2992097901bb7caa1b288ff6f7f9bb2e41d321757b19b7ba654462efd94760fe26e5d4412dd65ebc99c4a4cd56f152d69018
data/bin/rise CHANGED
@@ -8,8 +8,13 @@ require 'core'
8
8
  options = {}
9
9
  OptionParser.new do |opts|
10
10
  opts.banner = "Usage: #{$PROGRAM_NAME} [options]"
11
+ opts.separator Paint["\nGeneral Options: ", '#95a5a6']
12
+
13
+ opts.on('--version', 'Show the rise version and exit') do
14
+ puts "Rise version: #{Paint[Rise::Constants::VERSION, '#2ecc71']}"
15
+ exit 0
16
+ end
11
17
 
12
- opts.separator Paint['\nGeneral Options: ', '#95a5a6']
13
18
  opts.on('-v', '--verbose', 'Run verbosely') do |v|
14
19
  options[:verbose] = v
15
20
  end
@@ -18,6 +23,11 @@ OptionParser.new do |opts|
18
23
  options[:directory] = d unless d.nil?
19
24
  end
20
25
 
26
+ opts.on('-u', '--update', 'Check if rise has a newer version and install it') do
27
+ Rise::Util.check_for_update!
28
+ exit 0
29
+ end
30
+
21
31
  opts.on('-h', '--help', 'Show this help message') do
22
32
  puts opts
23
33
  exit
@@ -26,10 +36,10 @@ end.parse!(ARGV)
26
36
 
27
37
  if Rise::Util.is_first_run?
28
38
  Rise::Util.setup
29
- puts '\nPlease run the `rise` command again to upload your files.'
39
+ puts "\nPlease run the `rise` command again to upload your files."
30
40
  exit 0
31
41
  end
32
-
42
+ Rise::Util.check_for_update!
33
43
  result_url = ''
34
44
  uploader = Rise::Transport::Uploader.new(options[:directory]) unless options[:directory].nil?
35
45
  uploader = Rise::Transport::Uploader.new(Dir.pwd) if options[:directory].nil?
@@ -5,7 +5,7 @@ UPLOAD_PORT = 8080.freeze
5
5
 
6
6
  module Rise
7
7
  module Constants
8
- VERSION = '0.1.5'
8
+ VERSION = '0.1.6'
9
9
  EMAIL = '0xCB@protonmail.com'
10
10
  AUTHORS = ['Carter Brainerd']
11
11
  NAME = 'rise-cli'
data/lib/core/util.rb CHANGED
@@ -4,6 +4,8 @@ require 'json'
4
4
  require 'http'
5
5
  require 'digest'
6
6
  require 'io/console'
7
+ require 'tempfile'
8
+ require 'whirly'
7
9
  require_relative 'constants'
8
10
 
9
11
  #
@@ -19,6 +21,31 @@ module Rise
19
21
  !File.directory?(File.join(Dir.home, '.rise'))
20
22
  end
21
23
 
24
+ #
25
+ # Check for a new version of the gem
26
+ #
27
+ def self.check_for_update!
28
+ begin
29
+ output = ''
30
+ temp = Tempfile.new('rise-updater-output')
31
+ path = temp.path
32
+ system("gem outdated > #{path}")
33
+ output << temp.read
34
+ if output.include? 'rise-cli'
35
+ Whirly.start(spinner: 'line', status: Paint['New version available, updating...', 'blue']) do
36
+ system("gem uninstall rise-cli -v #{Rise::Constants::VERSION} > /dev/null")
37
+ system("gem install rise-cli > /dev/null")
38
+ puts Paint["Update complete, just run #{Paint['`rise`', '#3498db']} to deploy"]
39
+ end
40
+ end
41
+ rescue Exception => e
42
+ puts "Unable to check for updates. Error: #{Paint[e.message, 'red']}"
43
+ exit 1
44
+ ensure
45
+ temp.close
46
+ temp.unlink
47
+ end
48
+ end
22
49
  #
23
50
  # Creates all of the necessary files and login information
24
51
  #
data/lib/core.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  # Gems
2
2
  require 'clipboard'
3
- require 'whirly'
4
3
  require 'rex/text'
5
4
  require 'optparse'
6
5
 
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.1.5
4
+ version: 0.1.6
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-08 00:00:00.000000000 Z
11
+ date: 2017-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clipboard