byld-cli 0.0.6 → 0.0.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cfc1cade5d8f4698aa5d65436f066a6f2b157ae9ac0bd2c0860243c56e8c2997
4
- data.tar.gz: 325fcba6e9b8eda3da98c7a53241cdfae26ac6fa53bc6b7bc1786fdd61d15ea0
3
+ metadata.gz: 9921ce939ed12c148d831a6f945df7f7a4ad59e4f7192a00a1012a32b94b946d
4
+ data.tar.gz: d52d9affbe3a25ebc20fd6df327d03f12e3bed95443f647a48381d272a058412
5
5
  SHA512:
6
- metadata.gz: 2c961c79b62a0fa01b04b457e72bb211ae5e9e6c9371a098cbdff212187e99af8eb4ef01206101421abff4bb7c0c48392a816bf1f1e3b4c5c8d4d03d19d8476c
7
- data.tar.gz: 26b482af245002cb2d51d996438a72d7175fc15bba6a927ee92a6f7a80e51837bdb39e721d57986ee234628fc41e1b3996d07a5025148ba73e933078fa769a80
6
+ metadata.gz: 044136c15876ced63c09474f23b939786a6fc3ae2980bd6f1865ce397b6dd41c727f1ac0e46aae2d29814d8c4f40e825997479682dd9d19bde36683d17596097
7
+ data.tar.gz: 919d5255bea0eb5880154b080042d48d9d0db84c43db46ab65585ffbfda08975c165600d8179495312a229d6ed2de076d0480e7966fe2adb28eb31c8f14f20c4
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = 'byld-cli'
6
- spec.version = '0.0.6'
6
+ spec.version = '0.0.7'
7
7
 
8
8
  spec.authors = ['the fellowhip co']
9
9
  spec.summary = 'cli for byld'
@@ -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
- project_config = Config.load(".byld/config.yml")
16
16
 
17
- success, res = Infra.generate_client(name, project_config['project']['namespaceId'])
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
 
@@ -13,15 +13,15 @@ class CreateBlock < Thor::Group
13
13
  end
14
14
 
15
15
  def create_infra
16
- namespace_config = Config.load(".byld/config.yml")
17
- success, res = Infra.create_project(namespace_config['namespace']['id'], name, 'domain')
16
+ namespace_id = ConfigHelper.get_namespace_id
17
+ success, res = Infra.create_project(namespace_id, name, 'domain')
18
18
 
19
19
  if success
20
- block_config = Config.load("#{name}/.byld/config.yml")
21
- block_config.merge!(project: res)
20
+ ConfigHelper.save_config(name, res)
21
+
22
22
  say "👍 Block created successfully!"
23
23
  else
24
- say "⚠️ Error creating block. Reason: #{res}" unless success
24
+ say "⚠️ Error creating block. Reason: #{res['error']}" unless success
25
25
  end
26
26
  end
27
27
 
@@ -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 = YAML::load(File.open(".byld/config.yml"))['storage']
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
@@ -54,7 +54,7 @@ class AccessConsole < Thor::Group
54
54
  end
55
55
  }
56
56
  else
57
- say "⚠️ Error connecting to the console. Reason: #{res}" unless success
57
+ say "⚠️ Error connecting to the console. Reason: #{res['error']}" unless success
58
58
  end
59
59
  end
60
60
  end
@@ -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
@@ -17,12 +17,11 @@ class CreateProject < Thor::Group
17
17
  success, res = Infra.create_namespace(Config.instance['id'], name)
18
18
 
19
19
  if success
20
- namespace_config = Config.load("#{name}/.byld/config.yml")
21
- namespace_config.merge!(namespace: res)
20
+ ConfigHelper.save_config(name, res)
22
21
 
23
22
  say "👍 Project created successfully!"
24
23
  else
25
- say "⚠️ Error creating project. Reason: #{res}" unless success
24
+ say "⚠️ Error creating project. Reason: #{res['error']}" unless success
26
25
  end
27
26
  end
28
27
  end
@@ -7,14 +7,14 @@ class Deploy < Thor::Group
7
7
 
8
8
  def deploy
9
9
  name = File.basename(Dir.getwd)
10
- project_config = Config.load(".byld/config.yml")
10
+ _, project_id = ConfigHelper.get_namespace_and_project
11
11
 
12
12
  say "☝️ Deploying #{name}..."
13
- success, res = Infra.deploy(project_config['project']['id'])
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
 
@@ -17,7 +17,7 @@ class LoginUser < Thor::Group
17
17
 
18
18
  say "👋 You're logged in!"
19
19
  else
20
- say "⚠️ Error signing in. Reason: #{res}" unless success
20
+ say "⚠️ Error signing in. Reason: #{res['error']}" unless success
21
21
  end
22
22
  end
23
23
  end
@@ -8,9 +8,9 @@ class Status < Thor::Group
8
8
  end
9
9
 
10
10
  def print_status
11
- success, res = Infra.get_namespace(namespace_id)
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)
@@ -29,14 +29,4 @@ class Status < Thor::Group
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
@@ -12,15 +12,15 @@ class CreateGate < Thor::Group
12
12
  end
13
13
 
14
14
  def create_infra
15
- namespace_config = Config.load(".byld/config.yml")
16
- sucess, res = Infra.create_project(namespace_config['namespace']['id'], 'gate', 'graph')
15
+ namespace_id = ConfigHelper.get_namespace_id
16
+ sucess, res = Infra.create_project(namespace_id, 'gate', 'graph')
17
17
 
18
18
  if sucess
19
- say "👍 Gate created successfully!"
20
- gate_config = Config.load("gate/.byld/config.yml")
21
- gate_config.merge!(project: res)
19
+ ConfigHelper.save_config('gate', res)
20
+
21
+ say "👍 Gate created successfully!"
22
22
  else
23
- say "⚠️ Error creating gate. Reason: #{res}"
23
+ say "⚠️ Error creating gate. Reason: #{res['error']}"
24
24
  end
25
25
  end
26
26
 
@@ -12,20 +12,20 @@ class Expose < Thor::Group
12
12
  def create_client
13
13
  puts "☝️ Connecting #{name}..."
14
14
 
15
- gate_config = Config.load(".byld/config.yml")
16
- success, res = Infra.generate_client(name, gate_config['project']['namespaceId'])
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
- gate_config = Config.load(".byld/config.yml")
28
- success, res = Infra.generate_edges(name, gate_config['project']['namespaceId'])
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(dir, config)
4
+ block_config = Config.load("#{dir}/.byld/config.yml")
5
+ block_config.merge!(project: config)
6
+ end
7
+
2
8
  def self.get_namespace_and_project
3
- namespace_path = "../.byld/config.yml"
4
- project_path = ".byld/config.yml"
9
+ namespace_path = '../.byld/config.yml'
10
+ project_path = '.byld/config.yml'
5
11
 
6
- namespace_config = Config.load("../.byld/config.yml") if File.exist?(namespace_path)
7
- project_config = Config.load(".byld/config.yml") if File.exist?(project_path)
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 🚫Config is missing! Note: command is valid only within block or gate root folder \n\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
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.6
4
+ version: 0.0.7
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-07-03 00:00:00.000000000 Z
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: []