neetodeploy 1.1.4 → 1.1.5

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: 19af255afa80f69e3d6e3587f8917788e866cef5b296525c641415e9285d8720
4
- data.tar.gz: d851f2610614e2f0f7d3054e72d70b770bb8deb3896fe3c70eafd9ebe70efe22
3
+ metadata.gz: 305d6867816ecbca9f4c86d447117ff8fefebac877e6177000cf29f338c2b11b
4
+ data.tar.gz: 97243a423a38b634cb30289dfaf93ca71cb7bc96e9d83e3c9c57e16a54814f64
5
5
  SHA512:
6
- metadata.gz: 40566c170d6f756b33446a237a670532188b5f32eac9cd8ee738b531793e9218e187efe091ec677b8730c68cc2e1ee27511e453cd5503dee7ee2f76f172fb554
7
- data.tar.gz: efe2823e4c1aa55006f7284f69547e6292e378886bce2fd0ef214fbca559d185240dfd36ff498267c98698bd78fa055965359d05d26553187620c0c7d38c61b9
6
+ metadata.gz: de103bbd5f402dd3903b49f85008299652b7680b7a7a1e0fc8835dc3804cd91a7e204915183497fa020a9eedd7fbae20590af4c833c58e7327e276bf473c4770
7
+ data.tar.gz: 7f13ee1a14bc878f0c8e718d2fa045b3ceea1f44614e78ffbcfad9cdf6fbdeca38793ef2629f33950ceb9e30f2aeb0b226987fbc6e649498bfcda841ac00fa58
data/Gemfile.lock CHANGED
@@ -1,13 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- neetodeploy (1.1.4)
4
+ neetodeploy (1.1.5)
5
5
  colorize
6
6
  dotenv (~> 2.8.1)
7
7
  httparty (~> 0.21.0)
8
8
  launchy (~> 2.5.0)
9
9
  terminal-table (~> 3.0.2)
10
10
  thor (~> 1.3.0)
11
+ tty-spinner
11
12
  websocket-client-simple
12
13
 
13
14
  GEM
@@ -30,6 +31,9 @@ GEM
30
31
  terminal-table (3.0.2)
31
32
  unicode-display_width (>= 1.1.1, < 3)
32
33
  thor (1.3.0)
34
+ tty-cursor (0.7.1)
35
+ tty-spinner (0.9.3)
36
+ tty-cursor (~> 0.7)
33
37
  unicode-display_width (2.4.2)
34
38
  websocket (1.2.9)
35
39
  websocket-client-simple (0.6.1)
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "thor"
4
+ require_relative "./info"
5
+
6
+ module NeetoDeploy
7
+ class CLI
8
+ module Addon
9
+ class Commands < Thor
10
+ desc "info", "Get addon informations"
11
+ option :addon_name, type: :string, aliases: "-n", required: true, desc: "Addon name"
12
+ def info
13
+ Info.new(options).run
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NeetoDeploy
4
+ class CLI
5
+ module Addon
6
+ module Constants
7
+ NEETO_DEPLOY_CLI_API_ADDON_URL = "#{NEETO_DEPLOY_CLI_API_BASE_URL}/addons".freeze
8
+
9
+ def addon_url(addon_name)
10
+ "#{NEETO_DEPLOY_CLI_API_BASE_URL}/addons/#{addon_name}"
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,54 @@
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 Info < CLI::Base
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
+ 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 flatten_hash_from(hash)
32
+ hash.each_with_object({}) do |(key, value), memo|
33
+ next flatten_hash_from(value).each do |k, v|
34
+ memo["#{k}".intern] = v
35
+ end if value.is_a? Hash
36
+ memo[key] = value
37
+ end
38
+ end
39
+
40
+ def send_request
41
+ @response = send_get_request(addon_url(addon_name), {})
42
+ end
43
+
44
+ def print_output
45
+ ui.error(@response["error"]) and return unless @response.success?
46
+
47
+ flatten_hash_from(JSON[@response.body]).each do |k, v|
48
+ ui.info("#{k}: #{v}")
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -33,8 +33,10 @@ module NeetoDeploy
33
33
  ui.error(response) and return unless response.success?
34
34
 
35
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"
36
38
 
37
- ws = WebSocket::Client::Simple.connect "wss://neeto-deploy-lc.neetodeployapp.com/cli_console?deployment_name=#{app_name}&console_token=#{console_token}"
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}"
38
40
 
39
41
  prompt = ''
40
42
 
@@ -3,6 +3,7 @@
3
3
  require "thor"
4
4
  require_relative "./set"
5
5
  require_relative "./get"
6
+ require_relative "./reset_stats"
6
7
 
7
8
  module NeetoDeploy
8
9
  class CLI
@@ -23,6 +24,13 @@ module NeetoDeploy
23
24
  def get
24
25
  Get.new(options).run
25
26
  end
27
+
28
+ desc "reset-stats", "Resets the statistics of the Redis instance"
29
+ option :addon_name, type: :string, aliases: "-n", required: true, desc: "Addon name"
30
+ def reset_stats
31
+ ResetStats.new(options).run
32
+ end
33
+
26
34
  end
27
35
  end
28
36
  end
@@ -5,7 +5,7 @@ module NeetoDeploy
5
5
  module Redis
6
6
  module Constants
7
7
  NEETO_DEPLOY_CLI_API_ADDONS_REDIS_URL = "#{NEETO_DEPLOY_CLI_API_BASE_URL}/addons/redis".freeze
8
- AVAILABLE_REDIS_CONFIGS_TO_EDIT = ["maxmemory-policy"]
8
+ AVAILABLE_REDIS_CONFIGS_TO_EDIT = ["maxmemory-policy", "notify-keyspace-events"]
9
9
 
10
10
  def redis_addon_url
11
11
  NEETO_DEPLOY_CLI_API_ADDONS_REDIS_URL
@@ -20,17 +20,28 @@ module NeetoDeploy
20
20
  end
21
21
 
22
22
  def run
23
- response = send_patch_request(
24
- redis_addon_url, {
25
- addon_name:,
26
- command: "CONFIG get #{key}"
27
- }
28
- )
23
+ ui.execute_with_loading("Fetching info...") do
24
+ send_request
25
+ end
26
+ print_output
27
+ end
29
28
 
30
- ui.error(response) and return unless response.success?
29
+ private
31
30
 
32
- ui.success(response["message"])
33
- end
31
+ def send_request
32
+ @response = send_patch_request(
33
+ redis_addon_url, {
34
+ addon_name:,
35
+ command: "CONFIG get #{key}"
36
+ }
37
+ )
38
+ end
39
+
40
+ def print_output
41
+ ui.error(@response["error"]) and return unless @response.success?
42
+
43
+ ui.success(@response["message"])
44
+ end
34
45
  end
35
46
  end
36
47
  end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "thor"
4
+ require_relative "../session"
5
+ require_relative "./constants"
6
+
7
+ module NeetoDeploy
8
+ class CLI
9
+ module Redis
10
+ class ResetStats < CLI::Base
11
+ include Constants
12
+ include Session
13
+
14
+ attr_reader :addon_name
15
+
16
+ def initialize(options)
17
+ super()
18
+ @addon_name = options[:addon_name]
19
+ end
20
+
21
+ def run
22
+ if ui.yes?("Are you sure you want to reset the statistics (y/n)")
23
+ response = send_patch_request(
24
+ redis_addon_url, {
25
+ addon_name:,
26
+ command: "CONFIG RESETSTAT"
27
+ }
28
+ )
29
+ ui.error(response["error"]) and return unless response.success?
30
+
31
+ ui.success("Stats reset successful.")
32
+ else
33
+ puts "Reset cancelled."
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "thor"
4
- require "byebug"
5
4
 
6
5
  require_relative "../session"
7
6
  require_relative "./constants"
@@ -28,16 +27,10 @@ module NeetoDeploy
28
27
  return
29
28
  end
30
29
 
31
- response = send_patch_request(
32
- redis_addon_url, {
33
- addon_name:,
34
- command: "CONFIG set #{key} #{value}"
35
- }
36
- )
37
-
38
- ui.error(response) and return unless response.success?
39
-
40
- ui.success("Done")
30
+ ui.execute_with_loading("Setting config...") do
31
+ send_request
32
+ end
33
+ print_output
41
34
  end
42
35
 
43
36
  private
@@ -45,6 +38,21 @@ module NeetoDeploy
45
38
  def valid_config?
46
39
  AVAILABLE_REDIS_CONFIGS_TO_EDIT.include?(key)
47
40
  end
41
+
42
+ def send_request
43
+ @response = send_patch_request(
44
+ redis_addon_url, {
45
+ addon_name:,
46
+ command: "CONFIG set #{key} #{value}"
47
+ }
48
+ )
49
+ end
50
+
51
+ def print_output
52
+ ui.error(@response["error"]) and return unless @response.success?
53
+
54
+ ui.success("#{key} config for #{addon_name} set to #{value}")
55
+ end
48
56
  end
49
57
  end
50
58
  end
@@ -34,6 +34,13 @@ module NeetoDeploy
34
34
  def info(statement)
35
35
  shell.say(statement)
36
36
  end
37
+
38
+ def execute_with_loading(msg)
39
+ @spinner = TTY::Spinner.new("[:spinner] #{msg}", format: :classic)
40
+ @spinner.auto_spin
41
+ yield
42
+ @spinner.stop
43
+ end
37
44
  end
38
45
  end
39
46
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "thor"
4
+ require 'tty-spinner'
4
5
 
5
6
  # TODO: make this like neetob
6
7
 
@@ -12,6 +13,7 @@ module NeetoDeploy
12
13
  require_relative "cli/logs/base"
13
14
  require_relative "cli/env/commands"
14
15
  require_relative "cli/redis/commands"
16
+ require_relative "cli/addon/commands"
15
17
 
16
18
  def self.start(*)
17
19
  super
@@ -40,5 +42,8 @@ module NeetoDeploy
40
42
 
41
43
  desc "redis", "Manage redis addons"
42
44
  subcommand "redis", Redis::Commands
45
+
46
+ desc "addon", "Manage addons"
47
+ subcommand "addon", Addon::Commands
43
48
  end
44
49
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NeetoDeploy
4
- VERSION = "1.1.4"
4
+ VERSION = "1.1.5"
5
5
  CLI_API_VERSION = "v1"
6
6
  end
data/neetodeploy.gemspec CHANGED
@@ -37,6 +37,7 @@ Gem::Specification.new do |spec|
37
37
  spec.add_dependency "thor", "~> 1.3.0" # for cli
38
38
  spec.add_dependency "websocket-client-simple"
39
39
  spec.add_dependency "colorize"
40
+ spec.add_dependency "tty-spinner"
40
41
 
41
42
  # To add the files from submodules
42
43
  `git submodule --quiet foreach pwd`.split($\).each do |submodule_path|
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.4
4
+ version: 1.1.5
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-04-16 00:00:00.000000000 Z
11
+ date: 2024-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: tty-spinner
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  description: Manage neetoDeploy apps with CLI
112
126
  email:
113
127
  - subin.siby@bigbinary.com
@@ -122,6 +136,9 @@ files:
122
136
  - exe/neetodeploy
123
137
  - lib/neeto_deploy.rb
124
138
  - lib/neeto_deploy/cli.rb
139
+ - lib/neeto_deploy/cli/addon/commands.rb
140
+ - lib/neeto_deploy/cli/addon/constants.rb
141
+ - lib/neeto_deploy/cli/addon/info.rb
125
142
  - lib/neeto_deploy/cli/base.rb
126
143
  - lib/neeto_deploy/cli/env/commands.rb
127
144
  - lib/neeto_deploy/cli/env/constants.rb
@@ -137,6 +154,7 @@ files:
137
154
  - lib/neeto_deploy/cli/redis/commands.rb
138
155
  - lib/neeto_deploy/cli/redis/constants.rb
139
156
  - lib/neeto_deploy/cli/redis/get.rb
157
+ - lib/neeto_deploy/cli/redis/reset_stats.rb
140
158
  - lib/neeto_deploy/cli/redis/set.rb
141
159
  - lib/neeto_deploy/cli/session.rb
142
160
  - lib/neeto_deploy/cli/ui.rb