neetodeploy 1.0.6
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 +7 -0
- data/.ruby-version +1 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +47 -0
- data/exe/neetodeploy +29 -0
- data/lib/neeto_deploy/cli/base.rb +26 -0
- data/lib/neeto_deploy/cli/config/commands.rb +33 -0
- data/lib/neeto_deploy/cli/config/constants.rb +15 -0
- data/lib/neeto_deploy/cli/config/list.rb +50 -0
- data/lib/neeto_deploy/cli/config/set.rb +58 -0
- data/lib/neeto_deploy/cli/config/unset.rb +44 -0
- data/lib/neeto_deploy/cli/exec/base.rb +58 -0
- data/lib/neeto_deploy/cli/login/base.rb +71 -0
- data/lib/neeto_deploy/cli/login/constants.rb +24 -0
- data/lib/neeto_deploy/cli/logs/base.rb +49 -0
- data/lib/neeto_deploy/cli/session.rb +35 -0
- data/lib/neeto_deploy/cli/ui.rb +39 -0
- data/lib/neeto_deploy/cli.rb +40 -0
- data/lib/neeto_deploy/exception_handler.rb +35 -0
- data/lib/neeto_deploy/version.rb +6 -0
- data/lib/neeto_deploy.rb +10 -0
- data/neetodeploy.gemspec +51 -0
- metadata +152 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 38aaafe1332d72299302a1e8e23b51c9bb331247855747ff89447a78e096c3db
|
4
|
+
data.tar.gz: de0682177ba35603b9a324557a7e3a1447595815895d01ce0b02790991e74236
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 61c4a3349bdcb2adea201d5df0111a4299532b4693280ad59466b827d0b6b6f4e96133671d65933de9ef9e1f06a04a63dcc89afca2dda50b0f41fd9db2aea4b6
|
7
|
+
data.tar.gz: 76de2334e8b337aff37239e8e167e27e05d75a6a6112e3b15e6e9480229a9c1d22ccc1dd9b70c6124408578f336df1047b6a25909bacbb43c6cd51e29828896b
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.1.3
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
neetodeploy (1.0.6)
|
5
|
+
dotenv (~> 2.8.1)
|
6
|
+
httparty (~> 0.21.0)
|
7
|
+
launchy (~> 2.5.0)
|
8
|
+
terminal-table (~> 3.0.2)
|
9
|
+
thor (~> 1.2.1)
|
10
|
+
websocket-client-simple
|
11
|
+
|
12
|
+
GEM
|
13
|
+
remote: https://rubygems.org/
|
14
|
+
specs:
|
15
|
+
addressable (2.8.1)
|
16
|
+
public_suffix (>= 2.0.2, < 6.0)
|
17
|
+
byebug (11.1.3)
|
18
|
+
dotenv (2.8.1)
|
19
|
+
event_emitter (0.2.6)
|
20
|
+
httparty (0.21.0)
|
21
|
+
mini_mime (>= 1.0.0)
|
22
|
+
multi_xml (>= 0.5.2)
|
23
|
+
launchy (2.5.2)
|
24
|
+
addressable (~> 2.8)
|
25
|
+
mini_mime (1.1.2)
|
26
|
+
multi_xml (0.6.0)
|
27
|
+
public_suffix (5.0.1)
|
28
|
+
terminal-table (3.0.2)
|
29
|
+
unicode-display_width (>= 1.1.1, < 3)
|
30
|
+
thor (1.2.1)
|
31
|
+
unicode-display_width (2.4.2)
|
32
|
+
websocket (1.2.9)
|
33
|
+
websocket-client-simple (0.6.1)
|
34
|
+
event_emitter
|
35
|
+
websocket
|
36
|
+
|
37
|
+
PLATFORMS
|
38
|
+
arm64-darwin-20
|
39
|
+
arm64-darwin-21
|
40
|
+
x86_64-darwin-21
|
41
|
+
|
42
|
+
DEPENDENCIES
|
43
|
+
byebug
|
44
|
+
neetodeploy!
|
45
|
+
|
46
|
+
BUNDLED WITH
|
47
|
+
2.4.8
|
data/exe/neetodeploy
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "dotenv"
|
5
|
+
require "bundler/setup"
|
6
|
+
|
7
|
+
MIN_RUBY_VERSION = File.read(File.expand_path("../.ruby-version", __dir__)).strip
|
8
|
+
|
9
|
+
raise "neetodeploy requires Ruby version of #{MIN_RUBY_VERSION} or higher" if RUBY_VERSION < MIN_RUBY_VERSION
|
10
|
+
|
11
|
+
Dotenv.load(
|
12
|
+
File.expand_path("../.env.development", __dir__)
|
13
|
+
)
|
14
|
+
|
15
|
+
base_path = File.expand_path("../lib", __dir__)
|
16
|
+
|
17
|
+
if File.exist?(base_path)
|
18
|
+
require_relative "../lib/neeto_deploy"
|
19
|
+
else
|
20
|
+
require "neeto_deploy"
|
21
|
+
end
|
22
|
+
|
23
|
+
args = ARGV
|
24
|
+
|
25
|
+
begin
|
26
|
+
NeetoDeploy::CLI.start(args, debug: true)
|
27
|
+
rescue Exception => e
|
28
|
+
NeetoDeploy::ExceptionHandler.new(e).process
|
29
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "ui"
|
4
|
+
require_relative "../version"
|
5
|
+
|
6
|
+
module NeetoDeploy
|
7
|
+
class CLI
|
8
|
+
NEETO_DEPLOY_HOST = ENV["NEETO_DEPLOY_HOST"] || "https://neeto-engineering.neetodeploy.net" # TODO make this org generic
|
9
|
+
NEETO_DEPLOY_CLI_API_BASE_URL = "#{NEETO_DEPLOY_HOST}/api/cli/#{CLI_API_VERSION}"
|
10
|
+
|
11
|
+
CLI_CONFIG_DIR = "~/.config/neetodeploy".freeze
|
12
|
+
CLI_SESSION_STORE_FILE_PATH = File.expand_path("#{CLI_CONFIG_DIR}/auth.json").freeze
|
13
|
+
|
14
|
+
class Base
|
15
|
+
attr_reader :ui
|
16
|
+
|
17
|
+
def initialize
|
18
|
+
@ui = CLI::UI.new
|
19
|
+
end
|
20
|
+
|
21
|
+
def create_config_dir
|
22
|
+
FileUtils.mkdir_p(File.expand_path(CLI_CONFIG_DIR))
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "thor"
|
4
|
+
|
5
|
+
require_relative "./list"
|
6
|
+
require_relative "./set"
|
7
|
+
require_relative "./unset"
|
8
|
+
|
9
|
+
module NeetoDeploy
|
10
|
+
class CLI
|
11
|
+
module Config
|
12
|
+
class Commands < Thor
|
13
|
+
desc "list", "List all config vars"
|
14
|
+
option :app, type: :string, aliases: "-a", required: true, desc: "App slug" # TODO make this a common static function
|
15
|
+
def list
|
16
|
+
List.new(options:).run
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "set CONFIG_VARS", "Set one or more config vars"
|
20
|
+
option :app, type: :string, aliases: "-a", required: true, desc: "App slug" # TODO make this a common static function
|
21
|
+
def set(*config_vars)
|
22
|
+
Set.new(config_vars, options:).run
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "unset CONFIG_VARS", "Unset one or more config vars"
|
26
|
+
option :app, type: :string, aliases: "-a", required: true, desc: "App slug" # TODO make this a common static function
|
27
|
+
def unset(*config_vars)
|
28
|
+
Unset.new(config_vars, options:).run
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module NeetoDeploy
|
4
|
+
class CLI
|
5
|
+
module Config
|
6
|
+
module Constants
|
7
|
+
NEETO_DEPLOY_CLI_API_CONFIG_VARS_URL = "#{NEETO_DEPLOY_CLI_API_BASE_URL}/config_vars".freeze
|
8
|
+
|
9
|
+
def config_vars_url
|
10
|
+
NEETO_DEPLOY_CLI_API_CONFIG_VARS_URL
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "terminal-table"
|
4
|
+
require "thor"
|
5
|
+
|
6
|
+
require_relative "../session"
|
7
|
+
require_relative "./constants"
|
8
|
+
|
9
|
+
module NeetoDeploy
|
10
|
+
class CLI
|
11
|
+
module Config
|
12
|
+
class List < CLI::Base
|
13
|
+
include Constants
|
14
|
+
include Session
|
15
|
+
|
16
|
+
attr_reader :app_slug
|
17
|
+
|
18
|
+
def initialize(options:)
|
19
|
+
super()
|
20
|
+
@app_slug = options[:app]
|
21
|
+
end
|
22
|
+
|
23
|
+
def run
|
24
|
+
response = send_get_request(
|
25
|
+
config_vars_url, {
|
26
|
+
app_slug:
|
27
|
+
}
|
28
|
+
)
|
29
|
+
|
30
|
+
ui.error(response) and return unless response.success?
|
31
|
+
|
32
|
+
table = Terminal::Table.new(headings: table_columns, rows: table_rows(response["config_vars"]))
|
33
|
+
ui.success(table)
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def table_columns
|
39
|
+
["Key", "Value"]
|
40
|
+
end
|
41
|
+
|
42
|
+
def table_rows(config_vars)
|
43
|
+
config_vars.map do |config_var|
|
44
|
+
[config_var["key"], config_var["value"].gsub("\\n", "\n")]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "terminal-table"
|
4
|
+
require "thor"
|
5
|
+
|
6
|
+
require_relative "../session"
|
7
|
+
require_relative "./constants"
|
8
|
+
|
9
|
+
module NeetoDeploy
|
10
|
+
class CLI
|
11
|
+
module Config
|
12
|
+
class Set < CLI::Base
|
13
|
+
include Constants
|
14
|
+
include Session
|
15
|
+
|
16
|
+
attr_reader :app_slug, :config_vars
|
17
|
+
|
18
|
+
def initialize(config_vars_string_array, options:)
|
19
|
+
super()
|
20
|
+
@app_slug = options[:app]
|
21
|
+
@config_vars = config_vars_string_array.map do |config_var|
|
22
|
+
key, value = config_var.split("=")
|
23
|
+
{ key:, value: }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def run
|
28
|
+
table = Terminal::Table.new(
|
29
|
+
headings: table_columns,
|
30
|
+
rows: config_vars.map { |config_var|
|
31
|
+
[config_var[:key], config_var[:value]]
|
32
|
+
}
|
33
|
+
)
|
34
|
+
ui.info(table)
|
35
|
+
|
36
|
+
ui.info("Setting config vars and restarting app...")
|
37
|
+
|
38
|
+
response = send_post_request(
|
39
|
+
config_vars_url, {
|
40
|
+
app_slug:,
|
41
|
+
config_vars:
|
42
|
+
}
|
43
|
+
)
|
44
|
+
|
45
|
+
ui.error(response) and return unless response.success?
|
46
|
+
|
47
|
+
ui.success("Done")
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def table_columns
|
53
|
+
["Key", "Value"]
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "terminal-table"
|
4
|
+
require "thor"
|
5
|
+
|
6
|
+
require_relative "../session"
|
7
|
+
require_relative "./constants"
|
8
|
+
|
9
|
+
module NeetoDeploy
|
10
|
+
class CLI
|
11
|
+
module Config
|
12
|
+
class Unset < CLI::Base
|
13
|
+
include Constants
|
14
|
+
include Session
|
15
|
+
|
16
|
+
attr_reader :app_slug, :config_vars_string_array, :config_vars
|
17
|
+
|
18
|
+
def initialize(config_vars_string_array, options:)
|
19
|
+
super()
|
20
|
+
@app_slug = options[:app]
|
21
|
+
@config_vars_string_array = config_vars_string_array
|
22
|
+
@config_vars = config_vars_string_array.map do |config_var_key|
|
23
|
+
{ key: config_var_key }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def run
|
28
|
+
ui.info("Unsetting config var keys #{config_vars_string_array} and restarting app...")
|
29
|
+
|
30
|
+
response = send_delete_request(
|
31
|
+
config_vars_url, {
|
32
|
+
app_slug:,
|
33
|
+
config_vars:
|
34
|
+
}
|
35
|
+
)
|
36
|
+
|
37
|
+
ui.error(response) and return unless response.success?
|
38
|
+
|
39
|
+
ui.success("Done")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "websocket-client-simple"
|
3
|
+
require "thor"
|
4
|
+
require "readline"
|
5
|
+
|
6
|
+
module NeetoDeploy
|
7
|
+
class CLI
|
8
|
+
module Exec
|
9
|
+
class Base < CLI::Base
|
10
|
+
attr_reader :app_name
|
11
|
+
def initialize(app_name)
|
12
|
+
@app_name = app_name
|
13
|
+
end
|
14
|
+
|
15
|
+
def process!
|
16
|
+
puts "Opening console for #{app_name}"
|
17
|
+
|
18
|
+
ws = WebSocket::Client::Simple.connect "wss://neeto-deploy-lc.neetoreviewapp.net/cli_console?deployment_name=#{app_name}-web-deployment"
|
19
|
+
|
20
|
+
prompt = ''
|
21
|
+
|
22
|
+
ws.on :message do |msg|
|
23
|
+
message = msg.data
|
24
|
+
if message.to_s.eql?("{\"exitCode\":0,\"signal\":0}")
|
25
|
+
exit 0
|
26
|
+
end
|
27
|
+
cmd = message[0]
|
28
|
+
if cmd == "1"
|
29
|
+
prompt = "\u001b[2K\u001b[0G#{message.delete_prefix("1").split("\r\n").last}"
|
30
|
+
print message.delete_prefix("1")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
ws.on :open do
|
35
|
+
end
|
36
|
+
|
37
|
+
ws.on :close do |e|
|
38
|
+
puts e
|
39
|
+
exit 1
|
40
|
+
end
|
41
|
+
|
42
|
+
ws.on :error do |e|
|
43
|
+
puts e
|
44
|
+
puts "MyserverBackend>> Close entered. Last error:#{$!.class}:#{$!.to_s};Module:#{$0};"
|
45
|
+
$@.each { |backtrace| puts backtrace }
|
46
|
+
exit 1
|
47
|
+
end
|
48
|
+
|
49
|
+
loop do
|
50
|
+
sleep 0.1
|
51
|
+
input = Readline.readline(prompt, true)
|
52
|
+
ws.send "1" + input
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "fileutils"
|
4
|
+
require "httparty"
|
5
|
+
require "launchy"
|
6
|
+
|
7
|
+
require_relative "./constants"
|
8
|
+
|
9
|
+
module NeetoDeploy
|
10
|
+
class CLI
|
11
|
+
module Login
|
12
|
+
class Base < CLI::Base
|
13
|
+
include Constants
|
14
|
+
|
15
|
+
attr_accessor :login_token
|
16
|
+
|
17
|
+
def process!
|
18
|
+
init_session
|
19
|
+
show_login_link_and_open_in_browser
|
20
|
+
wait_until_user_authenticates!
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def init_session
|
26
|
+
response = HTTParty.post(session_create_url)
|
27
|
+
self.login_token = response["login_token"]
|
28
|
+
end
|
29
|
+
|
30
|
+
def show_login_link_and_open_in_browser
|
31
|
+
ui.say(
|
32
|
+
<<~EOF
|
33
|
+
A webpage will be opened in a browser. If it didn't, please open this URL in browser:
|
34
|
+
#{session_login_url}
|
35
|
+
EOF
|
36
|
+
)
|
37
|
+
Launchy.open(session_login_url)
|
38
|
+
end
|
39
|
+
|
40
|
+
def wait_until_user_authenticates!
|
41
|
+
two_minutes_later = Time.now.utc + 120
|
42
|
+
loop_running = true
|
43
|
+
while loop_running
|
44
|
+
loop_running = false if check_if_user_authenticated
|
45
|
+
loop_running = false if Time.now.utc >= two_minutes_later
|
46
|
+
sleep LOGIN_STATUS_CHECK_INTERVAL_SECONDS
|
47
|
+
end
|
48
|
+
ui.say("Logged in successfully")
|
49
|
+
end
|
50
|
+
|
51
|
+
def check_if_user_authenticated
|
52
|
+
response = HTTParty.post(session_login_status_url, format: :json)
|
53
|
+
return false unless response["status"] == "authenticated"
|
54
|
+
|
55
|
+
preserve_session(response["email"], response["session_token"])
|
56
|
+
|
57
|
+
true
|
58
|
+
end
|
59
|
+
|
60
|
+
def preserve_session(email, session_token)
|
61
|
+
create_config_dir
|
62
|
+
|
63
|
+
json = { email:, session_token: }.to_json
|
64
|
+
File.open(CLI_SESSION_STORE_FILE_PATH, "w") do |f|
|
65
|
+
f.write(json)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module NeetoDeploy
|
4
|
+
class CLI
|
5
|
+
module Login
|
6
|
+
module Constants
|
7
|
+
NEETO_DEPLOY_CLI_API_SESSIONS_URL = "#{NEETO_DEPLOY_CLI_API_BASE_URL}/sessions".freeze
|
8
|
+
LOGIN_STATUS_CHECK_INTERVAL_SECONDS = 2
|
9
|
+
|
10
|
+
def session_create_url
|
11
|
+
NEETO_DEPLOY_CLI_API_SESSIONS_URL
|
12
|
+
end
|
13
|
+
|
14
|
+
def session_login_url
|
15
|
+
"#{NEETO_DEPLOY_CLI_API_BASE_URL}/sessions/#{login_token}/authenticate"
|
16
|
+
end
|
17
|
+
|
18
|
+
def session_login_status_url
|
19
|
+
"#{NEETO_DEPLOY_CLI_API_BASE_URL}/sessions/#{login_token}/status"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "websocket-client-simple"
|
3
|
+
require "thor"
|
4
|
+
|
5
|
+
module NeetoDeploy
|
6
|
+
class CLI
|
7
|
+
module Logs
|
8
|
+
class Base < CLI::Base
|
9
|
+
attr_reader :app_name, :process_type
|
10
|
+
|
11
|
+
def initialize(app_name, process_type = nil)
|
12
|
+
@app_name = app_name
|
13
|
+
@process_type = process_type
|
14
|
+
end
|
15
|
+
|
16
|
+
def process!
|
17
|
+
ws = WebSocket::Client::Simple.connect "wss://neeto-deploy-lc.neetoreviewapp.net/cli_logs?deployment_name=#{app_name}&&process_type=#{process_type}"
|
18
|
+
|
19
|
+
ws.on :message do |msg|
|
20
|
+
message = msg.data
|
21
|
+
cmd = message[0]
|
22
|
+
if cmd == "1"
|
23
|
+
STDOUT.write message.delete_prefix("1")
|
24
|
+
STDOUT.flush
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
ws.on :open do
|
29
|
+
end
|
30
|
+
|
31
|
+
ws.on :close do |e|
|
32
|
+
p e
|
33
|
+
exit 1
|
34
|
+
end
|
35
|
+
|
36
|
+
ws.on :error do |e|
|
37
|
+
p e
|
38
|
+
puts "MyserverBackend>> Close entered. Last error:#{$!.class}:#{$!.to_s};Module:#{$0};"
|
39
|
+
$@.each { |backtrace| puts backtrace }
|
40
|
+
exit 1
|
41
|
+
end
|
42
|
+
|
43
|
+
loop do
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "thor"
|
4
|
+
|
5
|
+
module NeetoDeploy
|
6
|
+
class CLI
|
7
|
+
module Session
|
8
|
+
class Error < StandardError
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.require_app_option
|
12
|
+
option :app, type: :string, aliases: "-a", required: true, desc: "App slug"
|
13
|
+
end
|
14
|
+
|
15
|
+
def send_get_request(url, body)
|
16
|
+
HTTParty.get(url, { body: common_body.merge(body), format: :json })
|
17
|
+
end
|
18
|
+
|
19
|
+
def send_post_request(url, body)
|
20
|
+
HTTParty.post(url, { body: common_body.merge(body), format: :json })
|
21
|
+
end
|
22
|
+
|
23
|
+
def send_delete_request(url, body)
|
24
|
+
HTTParty.delete(url, { body: common_body.merge(body), format: :json })
|
25
|
+
end
|
26
|
+
|
27
|
+
def common_body
|
28
|
+
session_info = JSON.parse(File.read(CLI_SESSION_STORE_FILE_PATH))
|
29
|
+
{ session_token: session_info["session_token"] }
|
30
|
+
rescue
|
31
|
+
raise Error.new("Unable to retrieve session info. Try logging in again.")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "thor"
|
4
|
+
|
5
|
+
module NeetoDeploy
|
6
|
+
class CLI
|
7
|
+
class UI
|
8
|
+
attr_accessor :shell
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@shell = Thor::Base.shell.new
|
12
|
+
end
|
13
|
+
|
14
|
+
def say(statement, color = Thor::Shell::Color::YELLOW)
|
15
|
+
shell.say(statement, color)
|
16
|
+
end
|
17
|
+
|
18
|
+
def ask(question, echo = true)
|
19
|
+
shell.ask(question, echo:)
|
20
|
+
end
|
21
|
+
|
22
|
+
def yes?(question)
|
23
|
+
shell.yes?(question)
|
24
|
+
end
|
25
|
+
|
26
|
+
def error(statement)
|
27
|
+
shell.say(statement, Thor::Shell::Color::RED)
|
28
|
+
end
|
29
|
+
|
30
|
+
def success(statement)
|
31
|
+
shell.say(statement, Thor::Shell::Color::GREEN)
|
32
|
+
end
|
33
|
+
|
34
|
+
def info(statement)
|
35
|
+
shell.say(statement)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "thor"
|
4
|
+
|
5
|
+
# TODO: make this like neetob
|
6
|
+
|
7
|
+
module NeetoDeploy
|
8
|
+
class CLI < Thor
|
9
|
+
require_relative "cli/base"
|
10
|
+
require_relative "cli/login/base"
|
11
|
+
require_relative "cli/exec/base"
|
12
|
+
require_relative "cli/logs/base"
|
13
|
+
require_relative "cli/config/commands"
|
14
|
+
|
15
|
+
def self.start(*)
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "login", "Login"
|
20
|
+
def login
|
21
|
+
CLI::Login::Base.new.process!
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "config", "Manage config vars"
|
25
|
+
subcommand "config", Config::Commands
|
26
|
+
|
27
|
+
desc "exec", "Exec into deployment"
|
28
|
+
option :app, type: :string, aliases: "-a", required: true, desc: "App slug"
|
29
|
+
def exec
|
30
|
+
CLI::Exec::Base.new(options[:app]).process!
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "logs", "Show logs"
|
34
|
+
option :app, type: :string, aliases: "-a", required: true, desc: "App slug"
|
35
|
+
option :process_type, type: :string, aliases: "-p", desc: "Process type"
|
36
|
+
def logs
|
37
|
+
CLI::Logs::Base.new(options[:app], options[:process_type]).process!
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "./cli/base"
|
4
|
+
|
5
|
+
module NeetoDeploy
|
6
|
+
class ExceptionHandler < CLI::Base
|
7
|
+
attr_accessor :exception
|
8
|
+
|
9
|
+
def initialize(exception)
|
10
|
+
super()
|
11
|
+
@exception = exception
|
12
|
+
end
|
13
|
+
|
14
|
+
def process
|
15
|
+
case exception
|
16
|
+
when Thor::RequiredArgumentMissingError
|
17
|
+
ui.error(
|
18
|
+
"#{exception.message}."\
|
19
|
+
' Please use the "help" command to check all the required options and try again.'
|
20
|
+
)
|
21
|
+
when Errno::ENOENT
|
22
|
+
ui.error(
|
23
|
+
"#{exception.message}."\
|
24
|
+
" Please check the given path and try again"
|
25
|
+
)
|
26
|
+
when SystemExit
|
27
|
+
ui.error(
|
28
|
+
"Process exit with status code 1"
|
29
|
+
)
|
30
|
+
else
|
31
|
+
ui.error(exception.message)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/neeto_deploy.rb
ADDED
data/neetodeploy.gemspec
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/neeto_deploy/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "neetodeploy"
|
7
|
+
spec.version = NeetoDeploy::VERSION
|
8
|
+
spec.authors = ["Subin Siby"]
|
9
|
+
spec.email = ["subin.siby@bigbinary.com"]
|
10
|
+
|
11
|
+
spec.summary = "CLI for neetoDeploy"
|
12
|
+
spec.description = "Manage neetoDeploy apps with CLI"
|
13
|
+
spec.homepage = "https://github.com/neetohq/neeto-deploy-cli"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = ">= #{File.read(File.expand_path("./.ruby-version", __dir__)).strip}"
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = "https://github.com/neetohq/neeto-deploy-cli"
|
19
|
+
spec.metadata["changelog_uri"] = "https://github.com/neetohq/neeto-deploy-cli/blob/main/CHANGELOG.md"
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` gives the list of files tracked by git.
|
23
|
+
spec.files = Dir.chdir(__dir__) do
|
24
|
+
`git ls-files -z`.split("\x0").filter do |f|
|
25
|
+
(f == __FILE__) || f == ".ruby-version" || f.start_with?("exe/") || f.start_with?("lib/") || f.start_with?("Gemfile")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
# Must have deps
|
33
|
+
spec.add_dependency "dotenv", "~> 2.8.1" # for loading env variables
|
34
|
+
spec.add_dependency "httparty", "~> 0.21.0" # for http requests
|
35
|
+
spec.add_dependency "launchy", "~> 2.5.0" # for opening in browser
|
36
|
+
spec.add_dependency "terminal-table", "~> 3.0.2" # for building cli table
|
37
|
+
spec.add_dependency "thor", "~> 1.2.1" # for cli
|
38
|
+
spec.add_dependency "websocket-client-simple"
|
39
|
+
|
40
|
+
# To add the files from submodules
|
41
|
+
`git submodule --quiet foreach pwd`.split($\).each do |submodule_path|
|
42
|
+
Dir.chdir(submodule_path) do
|
43
|
+
required_submodule_files = `git ls-files -z`
|
44
|
+
.split("\x0")
|
45
|
+
.select { |file| file.match("lib/neeto_compliance*|data/*") }
|
46
|
+
.map { |file| "#{submodule_path}/#{file}" }
|
47
|
+
.map { |file| file.gsub "#{File.dirname(__FILE__)}/", "" }
|
48
|
+
spec.files += required_submodule_files
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
metadata
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: neetodeploy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.6
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Subin Siby
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-05-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: dotenv
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.8.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.8.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: httparty
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.21.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.21.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: launchy
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.5.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.5.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: terminal-table
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.0.2
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.0.2
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: thor
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.2.1
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.2.1
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: websocket-client-simple
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Manage neetoDeploy apps with CLI
|
98
|
+
email:
|
99
|
+
- subin.siby@bigbinary.com
|
100
|
+
executables:
|
101
|
+
- neetodeploy
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- ".ruby-version"
|
106
|
+
- Gemfile
|
107
|
+
- Gemfile.lock
|
108
|
+
- exe/neetodeploy
|
109
|
+
- lib/neeto_deploy.rb
|
110
|
+
- lib/neeto_deploy/cli.rb
|
111
|
+
- lib/neeto_deploy/cli/base.rb
|
112
|
+
- lib/neeto_deploy/cli/config/commands.rb
|
113
|
+
- lib/neeto_deploy/cli/config/constants.rb
|
114
|
+
- lib/neeto_deploy/cli/config/list.rb
|
115
|
+
- lib/neeto_deploy/cli/config/set.rb
|
116
|
+
- lib/neeto_deploy/cli/config/unset.rb
|
117
|
+
- lib/neeto_deploy/cli/exec/base.rb
|
118
|
+
- lib/neeto_deploy/cli/login/base.rb
|
119
|
+
- lib/neeto_deploy/cli/login/constants.rb
|
120
|
+
- lib/neeto_deploy/cli/logs/base.rb
|
121
|
+
- lib/neeto_deploy/cli/session.rb
|
122
|
+
- lib/neeto_deploy/cli/ui.rb
|
123
|
+
- lib/neeto_deploy/exception_handler.rb
|
124
|
+
- lib/neeto_deploy/version.rb
|
125
|
+
- neetodeploy.gemspec
|
126
|
+
homepage: https://github.com/neetohq/neeto-deploy-cli
|
127
|
+
licenses:
|
128
|
+
- MIT
|
129
|
+
metadata:
|
130
|
+
homepage_uri: https://github.com/neetohq/neeto-deploy-cli
|
131
|
+
source_code_uri: https://github.com/neetohq/neeto-deploy-cli
|
132
|
+
changelog_uri: https://github.com/neetohq/neeto-deploy-cli/blob/main/CHANGELOG.md
|
133
|
+
post_install_message:
|
134
|
+
rdoc_options: []
|
135
|
+
require_paths:
|
136
|
+
- lib
|
137
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: 3.1.3
|
142
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
requirements: []
|
148
|
+
rubygems_version: 3.3.26
|
149
|
+
signing_key:
|
150
|
+
specification_version: 4
|
151
|
+
summary: CLI for neetoDeploy
|
152
|
+
test_files: []
|