rise-cli 0.1.9 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6441a8893f5b8526ec5e9cfb877b150249fcf90a
4
- data.tar.gz: eef892f66d4561b8d8b226c7718d9f745ecb8531
3
+ metadata.gz: 45bf66600ed73d3196237da7baf820fc7f5d70b0
4
+ data.tar.gz: 829875b55c1c519238ce8a1cc11d094e9c5be679
5
5
  SHA512:
6
- metadata.gz: cb77ea27f04538c80789df8ea02bde4d13dd788b5ba70b3bf8412c1c8ccdea363aa38e98e0844a63057feab9e4cfabd690eeef783b3165b1a096d5b2b329ef59
7
- data.tar.gz: 63ce831369cc2d27681b6f90051d8b5edb305bffc71b49dfa5e923e76334e7ff91df5cadfc47deac7d143d7fa6d87fdd41eedcfcfc2cfe519e7949a9d8fd00e9
6
+ metadata.gz: 4eb1cfd3a0c32b6743f2fe5f641c44a29056ce3e747c9263cc45516f6eb5da15aca42b2bb6fb769c075699de0ef0d753ecb59e5e6c2d42306ab7ac538a3a26d0
7
+ data.tar.gz: 7b588ad2f036ac8f1db48fa8b534c9cfea6ad6e16991ceb1d5099f9b4f924c9c10c159ea3efa8b3935077d80c7c63ee1f9283d48d9f3d75cc7ed32c0bc0a1a61
@@ -8,9 +8,10 @@ module Rise
8
8
  # Holds constants used throughout the framework
9
9
  #
10
10
  module Constants
11
- VERSION = '0.1.9'.freeze
12
- EMAIL = '0xCB@protonmail.com'.freeze
13
- AUTHORS = ['Carter Brainerd']
14
- NAME = 'rise-cli'.freeze
11
+ VERSION = '0.2.0'.freeze
12
+ EMAIL = '0xCB@protonmail.com'.freeze
13
+ AUTHORS = ['Carter Brainerd']
14
+ NAME = 'rise-cli'.freeze
15
+ RISE_DIR = File.join(File.dirname(__FILE__), '..', '..')
15
16
  end
16
17
  end
@@ -51,7 +51,7 @@ module Rise
51
51
  access_uri
52
52
  end
53
53
 
54
- private
54
+ protected
55
55
 
56
56
  def calculate_files_size
57
57
  @files.inject(0){|sum, file| sum + File.size(file)}
data/lib/core/util.rb CHANGED
@@ -4,9 +4,9 @@ require 'json'
4
4
  require 'http'
5
5
  require 'digest'
6
6
  require 'io/console'
7
- require 'tempfile'
8
7
  require 'whirly'
9
8
  require 'os'
9
+ require 'json'
10
10
  require_relative 'constants'
11
11
 
12
12
  module Rise
@@ -25,34 +25,39 @@ module Rise
25
25
  # Check for a new version of the gem
26
26
  #
27
27
  def self.check_for_update!
28
- output = ''
29
- temp = Tempfile.new('rise-updater-output')
30
- path = temp.path
31
- system("gem outdated > #{path}")
32
- output << temp.read
33
- if output.include? 'rise-cli'
34
- Whirly.start(
35
- spinner: 'line',
36
- status: Paint['New version available, updating...', 'blue']
37
- ) do
38
- system("gem uninstall rise-cli -v #{Rise::Constants::VERSION} > /dev/null")
39
- system("gem install rise-cli > /dev/null")
40
- puts Paint["Update complete, just run #{Paint['`rise`', '#3498db']} to deploy"]
28
+ src = git_or_gem
29
+ begin
30
+ if src == 2 # if the gem was downloaded from rubygems
31
+ current_version = JSON.parse(HTTP.get('https://rubygems.org/api/v1/versions/rise-cli/latest.json'))['version']
32
+ if current_version != Rise::Constants::VERSION
33
+ Whirly.start(
34
+ spinner: 'line',
35
+ status: "New version available (#{Paint[Rise::Constants::VERSION, 'red']} -> #{Paint[current_version, '#3498db']}), updating..."
36
+ ) do
37
+ system("gem uninstall rise-cli -v #{Rise::Constants::VERSION} > /dev/null")
38
+ system("gem install rise-cli > /dev/null")
39
+ puts Paint["Update complete, just run #{Paint['`rise`', '#3498db']} to deploy"]
40
+ end
41
+ end
42
+ elsif src == 1
43
+ if `git log HEAD..origin/master --oneline` != ''
44
+ puts "It seems you're on bleeding edge, fetching new changes..."
45
+ vputs("Updating from #{`git show --no-color --oneline -s`.split(' ')[0]} to #{`git rev-parse --short HEAD`}")
46
+ `git pull`
47
+ puts Paint["Update complete, just run #{Paint['`rise`', '#3498db']} to deploy"]
48
+ end
41
49
  end
50
+ rescue StandardError => e
51
+ puts "Unable to check for updates. Error: #{Paint[e.message, 'red']}"
52
+ exit 1
42
53
  end
43
- rescue StandardError => e
44
- puts "Unable to check for updates. Error: #{Paint[e.message, 'red']}"
45
- exit 1
46
- ensure
47
- temp.close
48
- temp.unlink
49
54
  end
50
55
 
51
56
  #
52
57
  # Creates all of the necessary files and login information
53
58
  #
54
59
  def self.setup
55
- puts Paint['Detected first time setup, creating necessary files...', :blue]
60
+ puts Paint['Detected first time run, creating necessary files...', :blue]
56
61
  FileUtils.mkdir(RISE_DATA_DIR)
57
62
  FileUtils.mkdir(File.join(RISE_DATA_DIR, 'auth'))
58
63
 
@@ -76,7 +81,7 @@ module Rise
76
81
  #
77
82
  # Opens +url+ in a web browser if possible
78
83
  #
79
- def open_deployment_in_browser(url)
84
+ def self.open_deployment_in_browser(url)
80
85
  if OS.windows?
81
86
  system("START \"\" \"#{url}\"")
82
87
  else
@@ -84,5 +89,25 @@ module Rise
84
89
  end
85
90
  end
86
91
 
92
+
93
+
94
+ protected
95
+ #
96
+ # 1 = git, 2 = gem, 3 = unknown
97
+ #
98
+ def git_or_gem
99
+ gem = nil
100
+ 1 if File.exist?(File.join(Rise::Constants::VERSION, '.git'))
101
+ if OS.windows?
102
+ gem = system('which gem > NUL')
103
+ else
104
+ gem = system('which gem > /dev/null')
105
+ end
106
+
107
+ 2 if gem == true
108
+ 3
109
+ end
110
+
111
+
87
112
  end
88
113
  end
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.9
4
+ version: 0.2.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: 2017-10-19 00:00:00.000000000 Z
11
+ date: 2017-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clipboard