byld-cli 0.0.3 → 0.0.9
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 +4 -4
- data/byld-cli.gemspec +2 -1
- data/lib/blocks/connect.rb +3 -3
- data/lib/blocks/create_block.rb +7 -10
- data/lib/blocks/run_migration.rb +1 -1
- data/lib/byld_cli.rb +8 -0
- data/lib/common/access_console.rb +7 -3
- data/lib/common/access_logs.rb +1 -1
- data/lib/common/create_project.rb +6 -10
- data/lib/common/deploy.rb +3 -3
- data/lib/common/login_user.rb +1 -1
- data/lib/common/status.rb +4 -14
- data/lib/constants.rb +1 -0
- data/lib/gates/create_gate.rb +9 -12
- data/lib/gates/expose.rb +5 -5
- data/lib/generators/templates/active_record_model.tt +1 -1
- data/lib/helpers/config_helper.rb +28 -5
- data/lib/templates/block/Gemfile +1 -1
- data/lib/templates/gate/Gemfile +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d850ce35811255d939c37b62814d57d6178ca0cf9853e5f565160602fe2e325
|
4
|
+
data.tar.gz: 4b3029fcb988bb369161ffe3499801699d12e3c90b0f5fe7ff3e8821495cb039
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a949f660056c52fc4892de02cfb748127340bdad3c54ca862f4c61958137f082c22b11297bc7cd3b0413415b5ce88c902fb544767e2af504f2221c04eb732ea
|
7
|
+
data.tar.gz: 1c4fcf318a0896e369b21ce45d06028e49e263ac9cd1b08c1ddd5eba166e5536a56010dbf2415237e0ec344e663c6b34138c6305f401d61136e7d974cb328c0a
|
data/byld-cli.gemspec
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
+
require_relative ('./lib/constants')
|
1
2
|
lib = File.expand_path("../lib", __FILE__)
|
2
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
4
|
|
4
5
|
Gem::Specification.new do |spec|
|
5
6
|
spec.name = 'byld-cli'
|
6
|
-
spec.version =
|
7
|
+
spec.version = BYLD_VERSION
|
7
8
|
|
8
9
|
spec.authors = ['the fellowhip co']
|
9
10
|
spec.summary = 'cli for byld'
|
data/lib/blocks/connect.rb
CHANGED
@@ -11,15 +11,15 @@ class Connect < Thor::Group
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def create_client
|
14
|
+
namespace_id, project_id = ConfigHelper.get_namespace_and_project
|
14
15
|
puts "☝️ Connecting #{name}..."
|
15
|
-
namespace_config = Config.load(".byld/config.yml")
|
16
16
|
|
17
|
-
success, res = Infra.generate_client(name,
|
17
|
+
success, res = Infra.generate_client(name, namespace_id)
|
18
18
|
if success
|
19
19
|
create_file ".byld/gen/#{name.underscore}.rb", res.first['content']
|
20
20
|
puts "🔗 #{name} connected successfully!"
|
21
21
|
else
|
22
|
-
say "⚠️ Error connecting block. Reason: #{res}" unless success
|
22
|
+
say "⚠️ Error connecting block. Reason: #{res['error']}" unless success
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
data/lib/blocks/create_block.rb
CHANGED
@@ -7,21 +7,18 @@ class CreateBlock < Thor::Group
|
|
7
7
|
File.dirname(__FILE__)
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
10
|
+
def create_infra
|
11
11
|
say "✍️ Setting up #{name}..."
|
12
|
-
|
13
|
-
|
12
|
+
namespace_id = ConfigHelper.get_namespace_id
|
13
|
+
success, res = Infra.create_project(namespace_id, name, 'domain')
|
14
14
|
|
15
|
-
def create_infra
|
16
|
-
namespace_config = Config.load(".byld/config.yml")
|
17
|
-
success, res = Infra.create_project(namespace_config['namespace']['id'], name, 'domain')
|
18
|
-
|
19
15
|
if success
|
20
|
-
|
21
|
-
|
16
|
+
directory '../templates/block', name
|
17
|
+
ConfigHelper.save_config('project', name, res)
|
18
|
+
|
22
19
|
say "👍 Block created successfully!"
|
23
20
|
else
|
24
|
-
say "⚠️ Error creating block. Reason: #{res}" unless success
|
21
|
+
say "⚠️ Error creating block. Reason: #{res['error']}" unless success
|
25
22
|
end
|
26
23
|
end
|
27
24
|
|
data/lib/blocks/run_migration.rb
CHANGED
@@ -7,7 +7,7 @@ class RunMigration < Thor::Group
|
|
7
7
|
class_option :env, :default => 'dev'
|
8
8
|
|
9
9
|
def run_migrations
|
10
|
-
db_config =
|
10
|
+
db_config = Config.load(".byld/config.yml")['storage']
|
11
11
|
ActiveRecord::Base.establish_connection(db_config)
|
12
12
|
ActiveRecord::MigrationContext.new(".byld/migrations/").migrate
|
13
13
|
end
|
data/lib/byld_cli.rb
CHANGED
@@ -22,6 +22,8 @@ require_relative 'gates/gate'
|
|
22
22
|
require_relative 'gates/expose'
|
23
23
|
|
24
24
|
class ByldCli < Thor
|
25
|
+
map %w[--version -v] => :__print_version
|
26
|
+
|
25
27
|
register(LoginUser, 'login', 'login', 'Logins into your account')
|
26
28
|
register(CreateProject, 'new', 'new [NAME]', 'Creates a new project')
|
27
29
|
register(Deploy, 'deploy', 'deploy', 'Deploys the current block or gate')
|
@@ -37,5 +39,11 @@ class ByldCli < Thor
|
|
37
39
|
|
38
40
|
desc 'gate [COMMAND]', 'Gate commands'
|
39
41
|
subcommand 'gate', Gate
|
42
|
+
|
43
|
+
desc "--version, -v", "Display the version"
|
44
|
+
def __print_version
|
45
|
+
puts BYLD_VERSION
|
46
|
+
end
|
47
|
+
|
40
48
|
end
|
41
49
|
|
@@ -32,13 +32,16 @@ class AccessConsole < Thor::Group
|
|
32
32
|
ws = Faye::WebSocket::Client.new("ws://#{BIFROST_HOST}?namespace=#{res['namespace_name']}&pod=#{res['pod_name']}")
|
33
33
|
|
34
34
|
ws.on :open do |event|
|
35
|
-
puts "
|
35
|
+
puts "🌐 Connecting to IRB Console..."
|
36
36
|
end
|
37
37
|
|
38
38
|
command = ""
|
39
|
+
connected = false
|
39
40
|
ws.on :message do |event|
|
40
41
|
data = Base64.strict_decode64(event.data)
|
41
42
|
if (data.strip.end_with?("#"))
|
43
|
+
puts "🟢 Connected!" unless connected
|
44
|
+
connected = true
|
42
45
|
command = ask(data)
|
43
46
|
ws.send(command)
|
44
47
|
else
|
@@ -49,12 +52,13 @@ class AccessConsole < Thor::Group
|
|
49
52
|
end
|
50
53
|
|
51
54
|
ws.on :close do |event|
|
52
|
-
# p [:close, event.code, event.reason]
|
53
55
|
ws = nil
|
56
|
+
say "⚠️ Connection lost: #{event.code}: #{event.reason}"
|
57
|
+
exit
|
54
58
|
end
|
55
59
|
}
|
56
60
|
else
|
57
|
-
say "⚠️ Error connecting to the console. Reason: #{res}" unless success
|
61
|
+
say "⚠️ Error connecting to the console. Reason: #{res['error']}" unless success
|
58
62
|
end
|
59
63
|
end
|
60
64
|
end
|
data/lib/common/access_logs.rb
CHANGED
@@ -26,7 +26,7 @@ class AccessLogs < Thor::Group
|
|
26
26
|
last_since_time = has_new_logs ? since_time : last_since_time
|
27
27
|
say res['logs'] if has_new_logs
|
28
28
|
else
|
29
|
-
say "⚠️ Error getting logs. Reason: #{res}" unless success
|
29
|
+
say "⚠️ Error getting logs. Reason: #{res['error']}" unless success
|
30
30
|
end
|
31
31
|
sleep 2
|
32
32
|
end
|
@@ -7,22 +7,18 @@ class CreateProject < Thor::Group
|
|
7
7
|
File.dirname(__FILE__)
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
10
|
+
def create_project
|
11
11
|
say "✍️ Setting up your project..."
|
12
|
-
empty_directory name
|
13
|
-
create_file "#{name}/.byld/config.yml"
|
14
|
-
end
|
15
|
-
|
16
|
-
def create_project
|
17
12
|
success, res = Infra.create_namespace(Config.instance['id'], name)
|
18
|
-
|
13
|
+
|
19
14
|
if success
|
20
|
-
|
21
|
-
|
15
|
+
empty_directory name
|
16
|
+
create_file "#{name}/.byld/config.yml"
|
17
|
+
ConfigHelper.save_config('namespace', name, res)
|
22
18
|
|
23
19
|
say "👍 Project created successfully!"
|
24
20
|
else
|
25
|
-
say "⚠️ Error creating project. Reason: #{res}" unless success
|
21
|
+
say "⚠️ Error creating project. Reason: #{res['error']}" unless success
|
26
22
|
end
|
27
23
|
end
|
28
24
|
end
|
data/lib/common/deploy.rb
CHANGED
@@ -7,14 +7,14 @@ class Deploy < Thor::Group
|
|
7
7
|
|
8
8
|
def deploy
|
9
9
|
name = File.basename(Dir.getwd)
|
10
|
-
|
10
|
+
_, project_id = ConfigHelper.get_namespace_and_project
|
11
11
|
|
12
12
|
say "☝️ Deploying #{name}..."
|
13
|
-
success, res = Infra.deploy(
|
13
|
+
success, res = Infra.deploy(project_id)
|
14
14
|
if success
|
15
15
|
say "👌 Deployment triggered!"
|
16
16
|
else
|
17
|
-
say "⚠️ Error deploying block or gate. Reason: #{res}" unless success
|
17
|
+
say "⚠️ Error deploying block or gate. Reason: #{res['error']}" unless success
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
data/lib/common/login_user.rb
CHANGED
data/lib/common/status.rb
CHANGED
@@ -8,35 +8,25 @@ class Status < Thor::Group
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def print_status
|
11
|
-
success, res = Infra.get_namespace(
|
11
|
+
success, res = Infra.get_namespace(ConfigHelper.get_namespace_id)
|
12
12
|
|
13
|
-
say "⚠️ Error fetching project status. Reason: #{res}" unless success
|
13
|
+
say "⚠️ Error fetching project status. Reason: #{res['error']}" and return unless success
|
14
14
|
|
15
15
|
say set_color("\n#{res['name']}\n", :bold)
|
16
16
|
say set_color("gate\n", :bold)
|
17
17
|
|
18
18
|
gates = res['projects']
|
19
|
-
.
|
19
|
+
.select { |project| project['projectType'] == 'graph' }
|
20
20
|
.map { |project| [project['name'], project['status'], project['url'], project['docsUrl']] }
|
21
21
|
|
22
22
|
say Terminal::Table.new headings: ['name', 'status', 'url', 'docs'], rows: gates
|
23
23
|
|
24
24
|
say set_color("\nblocks\n", :bold)
|
25
25
|
blocks = res['projects']
|
26
|
-
.
|
26
|
+
.select { |project| project['projectType'] == 'domain' }
|
27
27
|
.map { |project| [project['name'], project['status']] }
|
28
28
|
|
29
29
|
say Terminal::Table.new headings: ['name', 'status'], rows: blocks
|
30
30
|
end
|
31
31
|
|
32
|
-
def namespace_id
|
33
|
-
config = Config.load(".byld/config.yml")
|
34
|
-
|
35
|
-
if config['namespace'].present?
|
36
|
-
config['namespace']['id']
|
37
|
-
elsif config['project'].present?
|
38
|
-
config['project']['namespaceId']
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
32
|
end
|
data/lib/constants.rb
CHANGED
data/lib/gates/create_gate.rb
CHANGED
@@ -5,22 +5,19 @@ class CreateGate < Thor::Group
|
|
5
5
|
File.dirname(__FILE__)
|
6
6
|
end
|
7
7
|
|
8
|
-
def
|
8
|
+
def create_infra
|
9
9
|
say "✍️ Setting up your gate..."
|
10
|
-
|
11
|
-
directory "../templates/gate", 'gate'
|
12
|
-
end
|
13
10
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
namespace_id = ConfigHelper.get_namespace_id
|
12
|
+
sucess, res = Infra.create_project(namespace_id, 'gate', 'graph')
|
13
|
+
|
18
14
|
if sucess
|
19
|
-
|
20
|
-
|
21
|
-
|
15
|
+
directory "../templates/gate", 'gate'
|
16
|
+
ConfigHelper.save_config('project', 'gate', res)
|
17
|
+
|
18
|
+
say "👍 Gate created successfully!"
|
22
19
|
else
|
23
|
-
say "⚠️ Error creating gate. Reason: #{res}"
|
20
|
+
say "⚠️ Error creating gate. Reason: #{res['error']}"
|
24
21
|
end
|
25
22
|
end
|
26
23
|
|
data/lib/gates/expose.rb
CHANGED
@@ -12,20 +12,20 @@ class Expose < Thor::Group
|
|
12
12
|
def create_client
|
13
13
|
puts "☝️ Connecting #{name}..."
|
14
14
|
|
15
|
-
|
16
|
-
success, res = Infra.generate_client(name,
|
15
|
+
namespace_id, gate_id = ConfigHelper.get_namespace_and_project
|
16
|
+
success, res = Infra.generate_client(name, namespace_id)
|
17
17
|
if success
|
18
18
|
create_file ".byld/gen/#{name.underscore}.rb", res.first['content']
|
19
19
|
puts "🔗 #{name} connected successfully!"
|
20
20
|
else
|
21
|
-
puts "⚠️ Error connecting block. Reason: #{res}"
|
21
|
+
puts "⚠️ Error connecting block. Reason: #{res['error']}"
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
def create_edge
|
26
26
|
puts "☝️ Exposing #{name}..."
|
27
|
-
|
28
|
-
success, res = Infra.generate_edges(name,
|
27
|
+
namespace_id, gate_id = ConfigHelper.get_namespace_and_project
|
28
|
+
success, res = Infra.generate_edges(name, namespace_id)
|
29
29
|
if success
|
30
30
|
res.each do |edge|
|
31
31
|
create_file "./edges/#{edge['name']}", edge['content']
|
@@ -1,13 +1,19 @@
|
|
1
1
|
module ConfigHelper
|
2
|
+
|
3
|
+
def self.save_config(key, dir, config)
|
4
|
+
block_config = Config.load("#{dir}/.byld/config.yml")
|
5
|
+
block_config.merge!(key => config)
|
6
|
+
end
|
7
|
+
|
2
8
|
def self.get_namespace_and_project
|
3
|
-
namespace_path =
|
4
|
-
project_path =
|
9
|
+
namespace_path = '../.byld/config.yml'
|
10
|
+
project_path = '.byld/config.yml'
|
5
11
|
|
6
|
-
namespace_config = Config.load(
|
7
|
-
project_config = Config.load(
|
12
|
+
namespace_config = Config.load(namespace_path) if File.exist?(namespace_path)
|
13
|
+
project_config = Config.load(project_path) if File.exist?(project_path)
|
8
14
|
|
9
15
|
if namespace_config.nil? or project_config.nil?
|
10
|
-
puts "\n
|
16
|
+
puts "\n🚫 Config is missing! Note: This command is valid only within block or gate directory \n\n"
|
11
17
|
exit
|
12
18
|
end
|
13
19
|
|
@@ -16,4 +22,21 @@ module ConfigHelper
|
|
16
22
|
|
17
23
|
[namespace_id, project_id]
|
18
24
|
end
|
25
|
+
|
26
|
+
def self.get_namespace_id
|
27
|
+
config_path = '.byld/config.yml'
|
28
|
+
config = Config.load(config_path) if File.exist?(config_path)
|
29
|
+
|
30
|
+
if config.nil?
|
31
|
+
puts "\n🚫 Config is missing! Note: This command is valid only within block or gate or project directory \n\n"
|
32
|
+
exit
|
33
|
+
end
|
34
|
+
|
35
|
+
if config['namespace'].present?
|
36
|
+
config['namespace']['id']
|
37
|
+
elsif config['project'].present?
|
38
|
+
config['project']['namespaceId']
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
19
42
|
end
|
data/lib/templates/block/Gemfile
CHANGED
data/lib/templates/gate/Gemfile
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: byld-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- the fellowhip co
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 5.2.3
|
111
111
|
description: cli for byld
|
112
|
-
email:
|
112
|
+
email:
|
113
113
|
executables:
|
114
114
|
- byld
|
115
115
|
extensions: []
|
@@ -162,10 +162,10 @@ files:
|
|
162
162
|
- lib/templates/gate/.byld/config.yml.tt
|
163
163
|
- lib/templates/gate/Gemfile
|
164
164
|
- lib/templates/gate/edges/.empty_directory
|
165
|
-
homepage:
|
165
|
+
homepage:
|
166
166
|
licenses: []
|
167
167
|
metadata: {}
|
168
|
-
post_install_message:
|
168
|
+
post_install_message:
|
169
169
|
rdoc_options: []
|
170
170
|
require_paths:
|
171
171
|
- lib
|
@@ -181,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
181
|
version: '0'
|
182
182
|
requirements: []
|
183
183
|
rubygems_version: 3.0.3
|
184
|
-
signing_key:
|
184
|
+
signing_key:
|
185
185
|
specification_version: 4
|
186
186
|
summary: cli for byld
|
187
187
|
test_files: []
|