stable-cli-rails 0.8.3 → 0.8.4
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 +4 -4
- data/lib/stable/cli.rb +5 -0
- data/lib/stable/commands/open.rb +56 -0
- data/lib/stable/commands/upgrade_ruby.rb +7 -9
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ea91d16ba356305a67c3627e75bfe16f2d780c0523d5420485accf4b4b70a2ca
|
|
4
|
+
data.tar.gz: c7344e77e0294a139d14e588fb28706b9c2e22cb5b1b00ae0aaa8e05d182b74a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ab9bfc8f6f5c5588ad6f9b8819ea4b504653ebe40e885e0796c51082e33b8a4e02189aca720dbed0edb971e558c6f4e23d2d405189ab53301eef6283fe3d4280
|
|
7
|
+
data.tar.gz: 8de8596f02772e8a98538ec45b52648869dde114bc65cf5958abff944a5c4c52389c278d1c821589952d0ef347974f22a7c0f9bb25f90ef7159370bfb10130ec
|
data/lib/stable/cli.rb
CHANGED
|
@@ -135,6 +135,11 @@ module Stable
|
|
|
135
135
|
Commands::UpgradeRuby.new(name, version).call
|
|
136
136
|
end
|
|
137
137
|
|
|
138
|
+
desc 'open APP', 'Open a running app in the browser'
|
|
139
|
+
def open(app_name)
|
|
140
|
+
Stable::Commands::Open.new(app_name).call
|
|
141
|
+
end
|
|
142
|
+
|
|
138
143
|
private
|
|
139
144
|
|
|
140
145
|
def next_free_port
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Stable
|
|
4
|
+
module Commands
|
|
5
|
+
# Open command - opens a Rails application in a browser
|
|
6
|
+
class Open
|
|
7
|
+
def initialize(app_name)
|
|
8
|
+
@app_name = app_name
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def call
|
|
12
|
+
app = Services::AppRegistry.find(@app_name)
|
|
13
|
+
abort "App '#{@app_name}' not found" unless app
|
|
14
|
+
|
|
15
|
+
abort "App '#{@app_name}' is not running" unless app[:pid] && process_alive?(app[:pid])
|
|
16
|
+
url = build_url(app)
|
|
17
|
+
open_browser(url)
|
|
18
|
+
puts "✔ Opened #{url}"
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
private
|
|
22
|
+
|
|
23
|
+
def build_url(app)
|
|
24
|
+
scheme = app[:skip_ssl] ? 'http' : 'https'
|
|
25
|
+
if app[:domain]
|
|
26
|
+
"#{scheme}://#{app[:domain]}"
|
|
27
|
+
else
|
|
28
|
+
"#{scheme}://127.0.0.1:#{app[:port]}"
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def open_browser(url)
|
|
33
|
+
cmd =
|
|
34
|
+
case RbConfig::CONFIG['host_os']
|
|
35
|
+
when /darwin/
|
|
36
|
+
"open #{url}"
|
|
37
|
+
when /linux/
|
|
38
|
+
"xdg-open #{url}"
|
|
39
|
+
when /mswin|mingw/
|
|
40
|
+
"start #{url}"
|
|
41
|
+
else
|
|
42
|
+
abort 'Unsupported OS'
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
system(cmd) || abort('Failed to open browser')
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def process_alive?(pid)
|
|
49
|
+
Process.kill(0, pid)
|
|
50
|
+
true
|
|
51
|
+
rescue Errno::ESRCH
|
|
52
|
+
false
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -51,13 +51,13 @@ module Stable
|
|
|
51
51
|
return
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
-
#
|
|
54
|
+
# Remove current Ruby environment and install new one fresh
|
|
55
55
|
puts "🔄 Upgrading #{@name} from Ruby #{current_version} to #{@version}..."
|
|
56
56
|
|
|
57
|
-
# 1. Remove current Ruby version/gemset
|
|
57
|
+
# 1. Remove current Ruby version/gemset
|
|
58
58
|
cleanup_rvm_gemset(app)
|
|
59
59
|
|
|
60
|
-
# 2. Install new Ruby version
|
|
60
|
+
# 2. Install new Ruby version
|
|
61
61
|
setup_new_ruby_version(app, @version)
|
|
62
62
|
|
|
63
63
|
puts ''
|
|
@@ -93,25 +93,23 @@ module Stable
|
|
|
93
93
|
end
|
|
94
94
|
|
|
95
95
|
def setup_new_ruby_version(app, new_version)
|
|
96
|
-
# Follow app_creator.rb pattern exactly
|
|
97
96
|
unless ENV['STABLE_TEST_MODE']
|
|
98
|
-
# Ensure Ruby version & RVM (like app_creator.rb)
|
|
99
97
|
Stable::Services::Ruby.ensure_version(new_version)
|
|
100
98
|
Stable::Services::Ruby.ensure_rvm!
|
|
101
99
|
|
|
102
|
-
# Create gemset
|
|
100
|
+
# Create gemset
|
|
103
101
|
Stable::System::Shell.run("bash -lc 'source #{Stable::Services::Ruby.rvm_script} && rvm #{new_version} do rvm gemset create #{@name} || true'")
|
|
104
102
|
|
|
105
103
|
rvm_cmd = Stable::Services::Ruby.rvm_prefix(new_version, @name)
|
|
106
104
|
|
|
107
|
-
# Install Bundler
|
|
105
|
+
# Install Bundler
|
|
108
106
|
Stable::System::Shell.run("bash -lc '#{rvm_cmd} gem install bundler --no-document'")
|
|
109
107
|
|
|
110
|
-
# Run bundle install
|
|
108
|
+
# Run bundle install
|
|
111
109
|
Stable::System::Shell.run(rvm_run('bundle install --jobs=4 --retry=3', chdir: app[:path]))
|
|
112
110
|
end
|
|
113
111
|
|
|
114
|
-
# Update app configuration
|
|
112
|
+
# Update app configuration
|
|
115
113
|
unless ENV['STABLE_TEST_MODE']
|
|
116
114
|
Dir.chdir(app[:path]) do
|
|
117
115
|
File.write('.ruby-version', "#{new_version}\n")
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: stable-cli-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Danny Simfukwe
|
|
@@ -41,6 +41,7 @@ files:
|
|
|
41
41
|
- lib/stable/commands/doctor.rb
|
|
42
42
|
- lib/stable/commands/list.rb
|
|
43
43
|
- lib/stable/commands/new.rb
|
|
44
|
+
- lib/stable/commands/open.rb
|
|
44
45
|
- lib/stable/commands/remove.rb
|
|
45
46
|
- lib/stable/commands/restart.rb
|
|
46
47
|
- lib/stable/commands/setup.rb
|
|
@@ -91,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
91
92
|
- !ruby/object:Gem::Version
|
|
92
93
|
version: '0'
|
|
93
94
|
requirements: []
|
|
94
|
-
rubygems_version: 3.6.
|
|
95
|
+
rubygems_version: 3.6.9
|
|
95
96
|
specification_version: 4
|
|
96
97
|
summary: Zero-config CLI tool to manage local Rails apps with automatic Caddy and
|
|
97
98
|
HTTPS setup
|