neetodeploy 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -1
- data/lib/neeto_deploy/cli/logs/base.rb +62 -18
- data/lib/neeto_deploy/cli/logs/constants.rb +15 -0
- data/lib/neeto_deploy/cli.rb +1 -1
- data/lib/neeto_deploy/version.rb +1 -1
- data/neetodeploy.gemspec +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19af255afa80f69e3d6e3587f8917788e866cef5b296525c641415e9285d8720
|
4
|
+
data.tar.gz: d851f2610614e2f0f7d3054e72d70b770bb8deb3896fe3c70eafd9ebe70efe22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40566c170d6f756b33446a237a670532188b5f32eac9cd8ee738b531793e9218e187efe091ec677b8730c68cc2e1ee27511e453cd5503dee7ee2f76f172fb554
|
7
|
+
data.tar.gz: efe2823e4c1aa55006f7284f69547e6292e378886bce2fd0ef214fbca559d185240dfd36ff498267c98698bd78fa055965359d05d26553187620c0c7d38c61b9
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
neetodeploy (1.1.
|
4
|
+
neetodeploy (1.1.4)
|
5
|
+
colorize
|
5
6
|
dotenv (~> 2.8.1)
|
6
7
|
httparty (~> 0.21.0)
|
7
8
|
launchy (~> 2.5.0)
|
@@ -15,6 +16,7 @@ GEM
|
|
15
16
|
addressable (2.8.1)
|
16
17
|
public_suffix (>= 2.0.2, < 6.0)
|
17
18
|
byebug (11.1.3)
|
19
|
+
colorize (1.1.0)
|
18
20
|
dotenv (2.8.1)
|
19
21
|
event_emitter (0.2.6)
|
20
22
|
httparty (0.21.0)
|
@@ -1,45 +1,89 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require "websocket-client-simple"
|
3
4
|
require "thor"
|
5
|
+
require "colorize"
|
6
|
+
|
7
|
+
require_relative "../session"
|
8
|
+
require_relative "./constants"
|
4
9
|
|
5
10
|
module NeetoDeploy
|
6
11
|
class CLI
|
7
12
|
module Logs
|
8
13
|
class Base < CLI::Base
|
14
|
+
include Constants
|
15
|
+
include Session
|
16
|
+
|
9
17
|
attr_reader :app_name, :process_type
|
10
18
|
|
11
19
|
def initialize(app_name, process_type = nil)
|
20
|
+
super()
|
12
21
|
@app_name = app_name
|
13
22
|
@process_type = process_type
|
14
23
|
end
|
15
24
|
|
16
25
|
def process!
|
17
|
-
|
26
|
+
stream_logs
|
27
|
+
end
|
18
28
|
|
19
|
-
|
20
|
-
begin
|
21
|
-
data = JSON.parse(msg.data)
|
22
|
-
puts data["streams"].map { |stream| stream["values"][0][1] }
|
23
|
-
rescue JSON::ParserError => e
|
24
|
-
end
|
25
|
-
end
|
29
|
+
private
|
26
30
|
|
27
|
-
|
31
|
+
def uri
|
32
|
+
"wss://connect.neetodeploy.com/cable"
|
28
33
|
end
|
29
34
|
|
30
|
-
|
31
|
-
|
32
|
-
|
35
|
+
def ensure_app_access?
|
36
|
+
response = send_get_request(app_verify_access_url, { app_slug: app_name })
|
37
|
+
@ui.error(JSON[response.body]["error"]) unless response.success?
|
38
|
+
response.success?
|
33
39
|
end
|
34
40
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
41
|
+
def stream_logs
|
42
|
+
ws_connection = WebSocket::Client::Simple.connect(uri)
|
43
|
+
session_token = common_body[:session_token]
|
44
|
+
app_slug = @app_name
|
45
|
+
process_type = @process_type
|
46
|
+
pubsub_token = SecureRandom.hex(16)
|
47
|
+
|
48
|
+
ws_connection.on :open do
|
49
|
+
payload = {
|
50
|
+
command: "subscribe",
|
51
|
+
identifier: {
|
52
|
+
channel: "Cli::LogChannel", app_slug:, pubsub_token:, process_type:,
|
53
|
+
session_token:
|
54
|
+
}.to_json
|
55
|
+
}
|
56
|
+
ws_connection.send(payload.to_json)
|
57
|
+
end
|
58
|
+
|
59
|
+
ws_connection.on :message do |msg|
|
60
|
+
unless msg.data.empty?
|
61
|
+
parsed_msg = JSON.parse(msg.data)
|
62
|
+
if parsed_msg["type"].nil?
|
63
|
+
parsed_msg["message"]&.each do |log|
|
64
|
+
STDOUT.write "#{Time.at(log[0].to_i / 1e9).to_s.light_magenta} #{log[1]}\n"
|
65
|
+
end
|
66
|
+
elsif parsed_msg["type"] == "disconnect"
|
67
|
+
puts parsed_msg["error"].red
|
68
|
+
exit
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
ws_connection.on :close do |e|
|
74
|
+
p e unless e.nil?
|
75
|
+
exit 1
|
76
|
+
end
|
77
|
+
|
78
|
+
ws_connection.on :error do |e|
|
79
|
+
p e
|
80
|
+
puts "MyserverBackend>> Close entered. Last error:#{$!.class}:#{$!.to_s};Module:#{$0};"
|
81
|
+
$@.each { |backtrace| puts backtrace }
|
82
|
+
exit 1
|
83
|
+
end
|
39
84
|
|
40
|
-
|
85
|
+
loop do end
|
41
86
|
end
|
42
|
-
end
|
43
87
|
end
|
44
88
|
end
|
45
89
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module NeetoDeploy
|
4
|
+
class CLI
|
5
|
+
module Logs
|
6
|
+
module Constants
|
7
|
+
NEETO_DEPLOY_CLI_API_ENVIRONMENT_VARIABLES_URL = "#{NEETO_DEPLOY_CLI_API_BASE_URL}/apps/access".freeze
|
8
|
+
|
9
|
+
def app_verify_access_url
|
10
|
+
NEETO_DEPLOY_CLI_API_ENVIRONMENT_VARIABLES_URL
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/neeto_deploy/cli.rb
CHANGED
@@ -33,7 +33,7 @@ module NeetoDeploy
|
|
33
33
|
|
34
34
|
desc "logs", "Show logs"
|
35
35
|
option :app, type: :string, aliases: "-a", required: true, desc: "App slug"
|
36
|
-
option :process_type, type: :string, aliases: "-p", desc: "Process type"
|
36
|
+
option :process_type, type: :string, aliases: "-p", required: true, desc: "Process type"
|
37
37
|
def logs
|
38
38
|
CLI::Logs::Base.new(options[:app], options[:process_type]).process!
|
39
39
|
end
|
data/lib/neeto_deploy/version.rb
CHANGED
data/neetodeploy.gemspec
CHANGED
@@ -36,6 +36,7 @@ Gem::Specification.new do |spec|
|
|
36
36
|
spec.add_dependency "terminal-table", "~> 3.0.2" # for building cli table
|
37
37
|
spec.add_dependency "thor", "~> 1.3.0" # for cli
|
38
38
|
spec.add_dependency "websocket-client-simple"
|
39
|
+
spec.add_dependency "colorize"
|
39
40
|
|
40
41
|
# To add the files from submodules
|
41
42
|
`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
|
+
version: 1.1.4
|
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-
|
11
|
+
date: 2024-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: colorize
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
description: Manage neetoDeploy apps with CLI
|
98
112
|
email:
|
99
113
|
- subin.siby@bigbinary.com
|
@@ -119,6 +133,7 @@ files:
|
|
119
133
|
- lib/neeto_deploy/cli/login/base.rb
|
120
134
|
- lib/neeto_deploy/cli/login/constants.rb
|
121
135
|
- lib/neeto_deploy/cli/logs/base.rb
|
136
|
+
- lib/neeto_deploy/cli/logs/constants.rb
|
122
137
|
- lib/neeto_deploy/cli/redis/commands.rb
|
123
138
|
- lib/neeto_deploy/cli/redis/constants.rb
|
124
139
|
- lib/neeto_deploy/cli/redis/get.rb
|