neetodeploy 1.1.5 → 1.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
  SHA256:
3
- metadata.gz: 305d6867816ecbca9f4c86d447117ff8fefebac877e6177000cf29f338c2b11b
4
- data.tar.gz: 97243a423a38b634cb30289dfaf93ca71cb7bc96e9d83e3c9c57e16a54814f64
3
+ metadata.gz: 7758b6320f1b7a4e6ca6245794c802800ade04945bfa1396ea027a67629a02ec
4
+ data.tar.gz: 95f3f1b502eaf798d0dfc00d79db4f4b5e2badc5c015043c2e65b0525f56486b
5
5
  SHA512:
6
- metadata.gz: de103bbd5f402dd3903b49f85008299652b7680b7a7a1e0fc8835dc3804cd91a7e204915183497fa020a9eedd7fbae20590af4c833c58e7327e276bf473c4770
7
- data.tar.gz: 7f13ee1a14bc878f0c8e718d2fa045b3ceea1f44614e78ffbcfad9cdf6fbdeca38793ef2629f33950ceb9e30f2aeb0b226987fbc6e649498bfcda841ac00fa58
6
+ metadata.gz: 4654d5e1e23becddf4b9726aaed9619100933d81a06a495f119ef51c63a4466bd4cf371d77706cd58fd15e07cc9930c7ae3b1e05e0c5110a11e3f8969ea61f19
7
+ data.tar.gz: 06bff1ef5ad906b62f0d26dcb59170f8d1569476cb3e9a09321813c94cf02d319eb722327049163f64e654fa295637f33798550627d7b518d2a17b3eada1495a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- neetodeploy (1.1.5)
4
+ neetodeploy (1.1.6)
5
5
  colorize
6
6
  dotenv (~> 2.8.1)
7
7
  httparty (~> 0.21.0)
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "thor"
4
4
  require_relative "./info"
5
+ require_relative "./scheduled_exports_settings"
5
6
 
6
7
  module NeetoDeploy
7
8
  class CLI
@@ -12,6 +13,12 @@ module NeetoDeploy
12
13
  def info
13
14
  Info.new(options).run
14
15
  end
16
+
17
+ desc "scheduled_exports_enabled", "Check whether scheduled exports is enabled for an app"
18
+ option :app_name, type: :string, aliases: "-a", required: true, desc: "App name"
19
+ def scheduled_exports_enabled
20
+ ScheduledExportsSettings.new(options).run
21
+ end
15
22
  end
16
23
  end
17
24
  end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "thor"
4
+
5
+ require_relative "../session"
6
+ require_relative "./constants"
7
+
8
+ module NeetoDeploy
9
+ class CLI
10
+ module Addon
11
+ class ScheduledExportsSettings < CLI::Base
12
+ include Constants
13
+ include Session
14
+
15
+ attr_reader :app_name
16
+
17
+ def initialize(options)
18
+ super()
19
+ @app_name = options[:app_name]
20
+ end
21
+
22
+ def run
23
+ ui.execute_with_loading("Fetching info...") do
24
+ send_request
25
+ end
26
+ print_output
27
+ end
28
+
29
+ private
30
+
31
+ def send_request
32
+ @response = send_get_request("#{NEETO_DEPLOY_CLI_API_BASE_URL}/scheduled_exports/#{app_name}", {app_slug: app_name})
33
+ end
34
+
35
+ def print_output
36
+ ui.error(@response["error"]) and return unless @response.success?
37
+
38
+ scheduled_exports = JSON.parse(@response.body)["scheduled_exports_enabled"]
39
+ if scheduled_exports.nil?
40
+ ui.error("App doesn't seem to have a primary database addon")
41
+ else
42
+ ui.info("Scheduled exports is turned #{scheduled_exports ? "\u001b[32mon\u001b[0m" : "\u001b[31moff\u001b[0m"} for #{app_name}'s primary database")
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "thor"
4
+
5
+ require_relative "./list"
6
+
7
+ module NeetoDeploy
8
+ class CLI
9
+ module AutoscalingConfig
10
+ class Commands < Thor
11
+ desc "list", "List autoscaling configs of an app"
12
+ option :app, type: :string, aliases: "-a", required: true, desc: "App slug"
13
+ def list
14
+ List.new(options:).run
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "thor"
4
+
5
+ module NeetoDeploy
6
+ class CLI
7
+ module AutoscalingConfig
8
+ class List < CLI::Base
9
+ include Session
10
+
11
+ attr_reader :app_slug
12
+
13
+ def initialize(options:)
14
+ super()
15
+ @app_slug = options[:app]
16
+ end
17
+
18
+ def run
19
+ response = send_get_request(
20
+ "#{NEETO_DEPLOY_CLI_API_BASE_URL}/autoscaling_configs/#{app_slug}", {
21
+ app_slug:
22
+ }
23
+ )
24
+
25
+ ui.error(response) and return unless response.success?
26
+
27
+ ui.success(JSON.parse(response.body)["autoscaling_status"])
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -4,7 +4,7 @@ require_relative "ui"
4
4
  require_relative "../version"
5
5
 
6
6
  module NeetoDeploy
7
- class CLI
7
+ class CLI
8
8
  NEETO_DEPLOY_HOST = ENV["NEETO_DEPLOY_HOST"] || "https://app.neetodeploy.com"
9
9
  NEETO_DEPLOY_CLI_API_BASE_URL = "#{NEETO_DEPLOY_HOST}/api/cli/#{CLI_API_VERSION}"
10
10
 
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "thor"
4
+
5
+ module NeetoDeploy
6
+ class CLI
7
+ class DynoConsoleManager < Base
8
+ DYNO_CONSOLE_MANAGER_URL = "wss://neeto-deploy-lc.neetodeployapp.com"
9
+
10
+ def initialize
11
+ super()
12
+ @prompt = ""
13
+ end
14
+
15
+ def run_console
16
+ start_spinner
17
+ send_console_session_request
18
+ ui.error(response) and return unless @response.success?
19
+
20
+ send_websocket_request
21
+ define_websocket_blocks
22
+ end
23
+
24
+ private
25
+
26
+ def start_spinner
27
+ @spinner = TTY::Spinner.new("[:spinner] Connecting to #{@instance_name}", format: :classic)
28
+ @spinner.auto_spin
29
+ end
30
+
31
+ def define_websocket_blocks
32
+ stop_spinner = lambda do
33
+ @spinner.stop unless @connection_established
34
+ end
35
+
36
+ cleanup = lambda do
37
+ connection_cleanup
38
+ end
39
+
40
+ @ws.on :message do |msg|
41
+ message = msg.data
42
+ if message.to_s.eql?("{\"exitCode\":0,\"signal\":0}")
43
+ cleanup.call
44
+ exit 0
45
+ end
46
+ cmd = message[0]
47
+ if cmd == "1"
48
+ extracted_message = message.delete_prefix("1")
49
+ stop_spinner.call && @connection_established = true unless extracted_message == ""
50
+ @prompt = "\u001b[2K\u001b[0G#{extracted_message.split("\r\n").last}"
51
+ print extracted_message
52
+ end
53
+ end
54
+
55
+ @ws.on :open do
56
+ end
57
+
58
+ @ws.on :close do |e|
59
+ puts e
60
+ exit 1
61
+ end
62
+
63
+ @ws.on :error do |e|
64
+ puts e
65
+ puts "MyserverBackend>> Close entered. Last error:#{$!.class}:#{$!.to_s};Module:#{$0};"
66
+ $@.each { |backtrace| puts backtrace }
67
+ exit 1
68
+ end
69
+
70
+ trap("SIGINT") do
71
+ Thread.new { @ws.send "4" }
72
+ end
73
+
74
+ loop do
75
+ sleep 0.1
76
+ input = Readline.readline(@prompt, true)
77
+ @ws.send "1" + input
78
+ end
79
+ end
80
+
81
+ def connection_cleanup
82
+ end
83
+ end
84
+ end
85
+ end
@@ -1,15 +1,17 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "websocket-client-simple"
3
4
  require "thor"
4
5
  require "readline"
5
6
 
6
7
  require_relative "../session"
7
8
  require_relative "./constants"
9
+ require_relative "../dyno_console_manager"
8
10
 
9
11
  module NeetoDeploy
10
12
  class CLI
11
13
  module Exec
12
- class Base < CLI::Base
14
+ class Base < CLI::DynoConsoleManager
13
15
  include Constants
14
16
  include Session
15
17
 
@@ -18,77 +20,32 @@ module NeetoDeploy
18
20
  def initialize(app_name)
19
21
  super()
20
22
  @app_name = app_name
23
+ @instance_name = app_name
24
+ @connection_established = false
21
25
  end
22
26
 
23
27
  def process!
24
- puts "Opening console for #{app_name}"
25
-
26
- response = send_post_request(
27
- console_session_base_url, {
28
- # TODO refactor app_slug to app_name in dashboard app
29
- app_slug: app_name,
30
- }
31
- )
32
-
33
- ui.error(response) and return unless response.success?
34
-
35
- console_token = response.parsed_response["console_token"]
36
- pubsub_token = response.parsed_response["console_pubsub_token"]
37
- deployment_name = "#{app_name}-#{pubsub_token}-console-deployment"
38
-
39
- ws = WebSocket::Client::Simple.connect "wss://neeto-deploy-lc.neetodeployapp.com/cli_console?app_name=#{app_name}&deployment_name=#{deployment_name}&console_token=#{console_token}"
40
-
41
- prompt = ''
42
-
43
- delete_url = "#{console_session_base_url}/#{console_token}"
44
- app_slug = app_name
45
-
46
- send_delete_request = lambda do |url, body|
47
- send_delete_request(url, body)
48
- end
28
+ run_console
29
+ end
49
30
 
50
- ws.on :message do |msg|
51
- message = msg.data
52
- if message.to_s.eql?("{\"exitCode\":0,\"signal\":0}")
53
- send_delete_request.call(
54
- delete_url, {
55
- app_slug:
56
- }
57
- )
58
- exit 0
59
- end
60
- cmd = message[0]
61
- if cmd == "1"
62
- prompt = "\u001b[2K\u001b[0G#{message.delete_prefix("1").split("\r\n").last}"
63
- print message.delete_prefix("1")
64
- end
65
- end
31
+ private
66
32
 
67
- ws.on :open do
33
+ def send_console_session_request
34
+ @response = send_post_request(console_session_base_url, { app_slug: @app_name })
68
35
  end
69
36
 
70
- ws.on :close do |e|
71
- puts e
72
- exit 1
73
- end
37
+ def send_websocket_request
38
+ @console_token = @response.parsed_response["console_token"]
39
+ pubsub_token = @response.parsed_response["console_pubsub_token"]
40
+ deployment_name = "#{app_name}-#{pubsub_token}-console-deployment"
74
41
 
75
- ws.on :error do |e|
76
- puts e
77
- puts "MyserverBackend>> Close entered. Last error:#{$!.class}:#{$!.to_s};Module:#{$0};"
78
- $@.each { |backtrace| puts backtrace }
79
- exit 1
42
+ @ws = WebSocket::Client::Simple.connect "#{DYNO_CONSOLE_MANAGER_URL}/cli_console?app_name=#{app_name}&deployment_name=#{deployment_name}&console_token=#{@console_token}&kind=web"
80
43
  end
81
44
 
82
- trap("SIGINT") do
83
- Thread.new { ws.send "4" }
45
+ def connection_cleanup
46
+ url = "#{console_session_base_url}/#{@console_token}"
47
+ send_delete_request(url, { app_slug: app_name })
84
48
  end
85
-
86
- loop do
87
- sleep 0.1
88
- input = Readline.readline(prompt, true)
89
- ws.send "1" + input
90
- end
91
- end
92
49
  end
93
50
  end
94
51
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "./console"
4
+
5
+ module NeetoDeploy
6
+ class CLI
7
+ module Pg
8
+ class Commands < Thor
9
+ desc "cli", "Connect to postgresql console"
10
+ option :addon_name, type: :string, aliases: "-n", required: true, desc: "Addon name"
11
+
12
+ def cli
13
+ Console.new(options).run
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "thor"
4
+ require_relative "../session"
5
+ require_relative "./constants"
6
+ require_relative "../dyno_console_manager"
7
+
8
+ module NeetoDeploy
9
+ class CLI
10
+ module Pg
11
+ class Console < CLI::DynoConsoleManager
12
+ include Constants
13
+ include Session
14
+
15
+ attr_reader :addon_name
16
+
17
+ def initialize(options)
18
+ super()
19
+ @addon_name = options[:addon_name]
20
+ @instance_name = options[:addon_name]
21
+ @connection_established = false
22
+ end
23
+
24
+ def run
25
+ run_console
26
+ end
27
+
28
+ private
29
+
30
+ def send_console_session_request
31
+ @response = send_post_request(console_session_base_url(addon_name), {})
32
+ end
33
+
34
+ def send_websocket_request
35
+ console_token = @response.parsed_response["console_token"]
36
+ database_url = @response.parsed_response["url"]
37
+ deployment_name = @response.parsed_response["internal_name"]
38
+ app_name = @response.parsed_response["app_name"]
39
+
40
+ @ws = WebSocket::Client::Simple.connect "#{DYNO_CONSOLE_MANAGER_URL}/cli_console?app_name=#{app_name}&deployment_name=#{deployment_name}&console_token=#{console_token}&database_url=#{database_url}&kind=postgres"
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NeetoDeploy
4
+ class CLI
5
+ module Pg
6
+ module Constants
7
+ def console_session_base_url(addon_name)
8
+ "#{NEETO_DEPLOY_CLI_API_BASE_URL}/addons/#{addon_name}/console_session"
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -13,7 +13,9 @@ module NeetoDeploy
13
13
  require_relative "cli/logs/base"
14
14
  require_relative "cli/env/commands"
15
15
  require_relative "cli/redis/commands"
16
+ require_relative "cli/pg/commands"
16
17
  require_relative "cli/addon/commands"
18
+ require_relative "cli/autoscaling_config/commands"
17
19
 
18
20
  def self.start(*)
19
21
  super
@@ -43,7 +45,13 @@ module NeetoDeploy
43
45
  desc "redis", "Manage redis addons"
44
46
  subcommand "redis", Redis::Commands
45
47
 
48
+ desc "pg", "Manage postgresql addons"
49
+ subcommand "pg", Pg::Commands
50
+
46
51
  desc "addon", "Manage addons"
47
52
  subcommand "addon", Addon::Commands
53
+
54
+ desc "autoscaling_config", "Manage autoscaling"
55
+ subcommand "autoscaling_config", AutoscalingConfig::Commands
48
56
  end
49
57
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NeetoDeploy
4
- VERSION = "1.1.5"
4
+ VERSION = "1.1.6"
5
5
  CLI_API_VERSION = "v1"
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neetodeploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Subin Siby
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-05-16 00:00:00.000000000 Z
11
+ date: 2024-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv
@@ -139,7 +139,11 @@ files:
139
139
  - lib/neeto_deploy/cli/addon/commands.rb
140
140
  - lib/neeto_deploy/cli/addon/constants.rb
141
141
  - lib/neeto_deploy/cli/addon/info.rb
142
+ - lib/neeto_deploy/cli/addon/scheduled_exports_settings.rb
143
+ - lib/neeto_deploy/cli/autoscaling_config/commands.rb
144
+ - lib/neeto_deploy/cli/autoscaling_config/list.rb
142
145
  - lib/neeto_deploy/cli/base.rb
146
+ - lib/neeto_deploy/cli/dyno_console_manager.rb
143
147
  - lib/neeto_deploy/cli/env/commands.rb
144
148
  - lib/neeto_deploy/cli/env/constants.rb
145
149
  - lib/neeto_deploy/cli/env/list.rb
@@ -151,6 +155,9 @@ files:
151
155
  - lib/neeto_deploy/cli/login/constants.rb
152
156
  - lib/neeto_deploy/cli/logs/base.rb
153
157
  - lib/neeto_deploy/cli/logs/constants.rb
158
+ - lib/neeto_deploy/cli/pg/commands.rb
159
+ - lib/neeto_deploy/cli/pg/console.rb
160
+ - lib/neeto_deploy/cli/pg/constants.rb
154
161
  - lib/neeto_deploy/cli/redis/commands.rb
155
162
  - lib/neeto_deploy/cli/redis/constants.rb
156
163
  - lib/neeto_deploy/cli/redis/get.rb