neetodeploy 1.1.6 → 1.1.8

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: 7758b6320f1b7a4e6ca6245794c802800ade04945bfa1396ea027a67629a02ec
4
- data.tar.gz: 95f3f1b502eaf798d0dfc00d79db4f4b5e2badc5c015043c2e65b0525f56486b
3
+ metadata.gz: c76a4214357b2c2da95a83e581ed24e1ea67079487be44ec46f36642fcc6b54c
4
+ data.tar.gz: 7d76010751d2ea5f58884ad597cd52d0e09713ee2ce93c156b7a9c1182e6300d
5
5
  SHA512:
6
- metadata.gz: 4654d5e1e23becddf4b9726aaed9619100933d81a06a495f119ef51c63a4466bd4cf371d77706cd58fd15e07cc9930c7ae3b1e05e0c5110a11e3f8969ea61f19
7
- data.tar.gz: 06bff1ef5ad906b62f0d26dcb59170f8d1569476cb3e9a09321813c94cf02d319eb722327049163f64e654fa295637f33798550627d7b518d2a17b3eada1495a
6
+ metadata.gz: 92fd39525159fe65d6ed7faee0824c870face78481b68918031f3b2c374c4bde81b0b9c83d7a7c5d689397d5142a32dae12bdc9b11d110d76910e6e138f82220
7
+ data.tar.gz: 940ae23e945b2dfda9c2d02f7d50dd4d7fb8bbcf73b136e8d068c9bc75966e4051bf4b5f10a123e8478489e75e6fc165b6242e12c098c042f8bd1862328ab0ea
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- neetodeploy (1.1.6)
4
+ neetodeploy (1.1.8)
5
5
  colorize
6
6
  dotenv (~> 2.8.1)
7
7
  httparty (~> 0.21.0)
data/exe/console ADDED
Binary file
@@ -12,6 +12,7 @@ module NeetoDeploy
12
12
  class Commands < Thor
13
13
  desc "list", "List all environment variable"
14
14
  option :app, type: :string, aliases: "-a", required: true, desc: "App slug" # TODO make this a common static function
15
+ option :json, type: :boolean, aliases: "-j", desc: "Output config vars in json format"
15
16
  def list
16
17
  List.new(options:).run
17
18
  end
@@ -13,11 +13,12 @@ module NeetoDeploy
13
13
  include Constants
14
14
  include Session
15
15
 
16
- attr_reader :app_slug
16
+ attr_reader :app_slug, :is_json_format
17
17
 
18
18
  def initialize(options:)
19
19
  super()
20
20
  @app_slug = options[:app]
21
+ @is_json_format = options[:json]
21
22
  end
22
23
 
23
24
  def run
@@ -29,8 +30,8 @@ module NeetoDeploy
29
30
 
30
31
  ui.error(response) and return unless response.success?
31
32
 
32
- table = Terminal::Table.new(headings: table_columns, rows: table_rows(response["environment_variables"]))
33
- ui.success(table)
33
+ data = is_json_format ? json_data(response["environment_variables"]) : table_data(response["environment_variables"])
34
+ ui.success(data)
34
35
  end
35
36
 
36
37
  private
@@ -44,6 +45,18 @@ module NeetoDeploy
44
45
  [environment_variable["key"], environment_variable["value"].gsub("\\n", "\n")]
45
46
  end
46
47
  end
48
+
49
+ def table_data(envs)
50
+ Terminal::Table.new(headings: table_columns, rows: table_rows(envs))
51
+ end
52
+
53
+ def json_data(envs)
54
+ resulting_hash = envs.each_with_object({}) do |item, hash|
55
+ hash[item["key"]] = item["value"]
56
+ end
57
+ JSON.pretty_generate(resulting_hash)
58
+ end
59
+
47
60
  end
48
61
  end
49
62
  end
@@ -11,7 +11,7 @@ require_relative "../dyno_console_manager"
11
11
  module NeetoDeploy
12
12
  class CLI
13
13
  module Exec
14
- class Base < CLI::DynoConsoleManager
14
+ class Base < CLI::Base
15
15
  include Constants
16
16
  include Session
17
17
 
@@ -20,31 +20,51 @@ module NeetoDeploy
20
20
  def initialize(app_name)
21
21
  super()
22
22
  @app_name = app_name
23
- @instance_name = app_name
24
- @connection_established = false
25
23
  end
26
24
 
27
25
  def process!
28
- run_console
26
+ start_spinner
27
+ send_console_session_request
28
+ ui.error("\n#{@response.body}") and return unless @response.success?
29
+
30
+
31
+ buffer_wait_block
32
+ start_console
33
+ connection_cleanup_callback
29
34
  end
30
35
 
31
36
  private
32
37
 
38
+ def console_executable_path
39
+ gem_spec = Gem::Specification.find_by_name("neetodeploy")
40
+ gem_dir = gem_spec.gem_dir
41
+ executable_path = File.join(gem_dir, "exe", "console")
42
+ end
43
+
44
+ def start_console
45
+ @pubsub_token = @response.parsed_response["console_pubsub_token"]
46
+ console_access_token = @response.parsed_response["console_access_token"]
47
+ pod_name = "#{app_name}-#{@pubsub_token}-console-deployment"
48
+ system("#{console_executable_path} #{pod_name} #{console_access_token}")
49
+ end
50
+
33
51
  def send_console_session_request
34
52
  @response = send_post_request(console_session_base_url, { app_slug: @app_name })
35
53
  end
36
54
 
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"
55
+ def connection_cleanup_callback
56
+ url = "#{console_session_base_url}/#{app_name}"
57
+ send_delete_request(url, { pubsub_token: @pubsub_token })
58
+ end
41
59
 
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"
60
+ def start_spinner
61
+ @spinner = TTY::Spinner.new("[:spinner] Connecting to #{app_name}", format: :classic)
62
+ @spinner.auto_spin
43
63
  end
44
64
 
45
- def connection_cleanup
46
- url = "#{console_session_base_url}/#{@console_token}"
47
- send_delete_request(url, { app_slug: app_name })
65
+ def buffer_wait_block
66
+ sleep 5
67
+ @spinner.stop
48
68
  end
49
69
  end
50
70
  end
@@ -6,12 +6,12 @@ module NeetoDeploy
6
6
  class CLI
7
7
  module Pg
8
8
  class Commands < Thor
9
- desc "cli", "Connect to postgresql console"
10
- option :addon_name, type: :string, aliases: "-n", required: true, desc: "Addon name"
9
+ # desc "cli", "Connect to postgresql console"
10
+ # option :addon_name, type: :string, aliases: "-n", required: true, desc: "Addon name"
11
11
 
12
- def cli
13
- Console.new(options).run
14
- end
12
+ # def cli
13
+ # Console.new(options).run
14
+ # end
15
15
  end
16
16
  end
17
17
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NeetoDeploy
4
- VERSION = "1.1.6"
4
+ VERSION = "1.1.8"
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.6
4
+ version: 1.1.8
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-07-01 00:00:00.000000000 Z
11
+ date: 2024-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv
@@ -126,6 +126,7 @@ description: Manage neetoDeploy apps with CLI
126
126
  email:
127
127
  - subin.siby@bigbinary.com
128
128
  executables:
129
+ - console
129
130
  - neetodeploy
130
131
  extensions: []
131
132
  extra_rdoc_files: []
@@ -133,6 +134,7 @@ files:
133
134
  - ".ruby-version"
134
135
  - Gemfile
135
136
  - Gemfile.lock
137
+ - exe/console
136
138
  - exe/neetodeploy
137
139
  - lib/neeto_deploy.rb
138
140
  - lib/neeto_deploy/cli.rb