byld-cli 0.0.4 ā†’ 0.0.10

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: 277caf41280001f2587527817c56ec5744c90460adda580c7fb951f4e16e32c5
4
- data.tar.gz: 9c1c6362c89ad322259898b1e1ef6f48042bc9decb4bafd67fc5b17e2bd5eb7b
3
+ metadata.gz: f54dcaf0f049e530ed6e87ee51716fb2e1ca0c43a65e45312a54917917d7c9f0
4
+ data.tar.gz: d2ef0b741afef1d26914b5ed7375c2532f8fa8b5e56b25c3c7fc576366ffaf12
5
5
  SHA512:
6
- metadata.gz: b9f004be65ccd30f5deaf4e38d3d4ea3a4349cb58a1ac0ab35b58c89f52b35d280c84edc115193f54490a8ec00b5637506d402a617ece6fb54c5831f1dc7370d
7
- data.tar.gz: c14b670b116ee4f97b8cc4a47df7f36c56afaac0c49cc9ca79e14c845d073784147e7143a06e6b52dc655b3231c278d75830418777c20c54a93eeb013fa3fe73
6
+ metadata.gz: 4ce0b15f358b8963bd50ad9c3812a999cfda080c44b372de5c91f9ef20060b3baf71550e26de22bf2c4e8a6098d2b7fa2aa99ad821d4b0478df812131a5154d8
7
+ data.tar.gz: 6b45b3fc3f0699a0b717aed44fbd41708569f8e6dc8654d62a5f2181ae3323900105eea3856987b8be2cec8a48246e9ea730cacc77a3624a440ec85d1ed6eba2
@@ -0,0 +1,18 @@
1
+ FROM ruby:2.6.6
2
+ ENV APP_HOME /cli
3
+ RUN mkdir $APP_HOME
4
+ WORKDIR $APP_HOME
5
+
6
+ RUN gem install guard guard-process guard-shell
7
+
8
+ ADD *.gemspec $APP_HOME/
9
+ ADD Gemfile* $APP_HOME/
10
+ ADD ./lib/constants.rb $APP_HOME/lib/
11
+ RUN bundle install
12
+
13
+ ARG project_type
14
+ ADD .irbrc /root/
15
+ ADD Guardfile.$project_type /root/.Guardfile
16
+
17
+ ADD . $APP_HOME
18
+ RUN rake install
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- byld-cli (0.0.1)
4
+ byld-cli (0.0.10)
5
+ activerecord (= 5.2.3)
5
6
  activesupport (= 5.2.3)
6
7
  archive-zip (= 0.12)
7
8
  faye-websocket (= 0.10.9)
@@ -12,6 +13,12 @@ PATH
12
13
  GEM
13
14
  remote: https://rubygems.org/
14
15
  specs:
16
+ activemodel (5.2.3)
17
+ activesupport (= 5.2.3)
18
+ activerecord (5.2.3)
19
+ activemodel (= 5.2.3)
20
+ activesupport (= 5.2.3)
21
+ arel (>= 9.0)
15
22
  activesupport (5.2.3)
16
23
  concurrent-ruby (~> 1.0, >= 1.0.2)
17
24
  i18n (>= 0.7, < 2)
@@ -19,6 +26,7 @@ GEM
19
26
  tzinfo (~> 1.1)
20
27
  archive-zip (0.12.0)
21
28
  io-like (~> 0.3.0)
29
+ arel (9.0.0)
22
30
  concurrent-ruby (1.1.6)
23
31
  eventmachine (1.2.7)
24
32
  faye-websocket (0.10.9)
@@ -42,7 +50,7 @@ GEM
42
50
  tzinfo (1.2.7)
43
51
  thread_safe (~> 0.1)
44
52
  unicode-display_width (1.7.0)
45
- websocket-driver (0.7.2)
53
+ websocket-driver (0.7.3)
46
54
  websocket-extensions (>= 0.1.0)
47
55
  websocket-extensions (0.1.5)
48
56
 
@@ -0,0 +1,13 @@
1
+ guard :shell do
2
+ watch('Gemfile') do
3
+ `bundle install`
4
+ end
5
+ watch /.byld\/migrations\/.*.rb/ do
6
+ `byld block migrate`
7
+ end
8
+ end
9
+
10
+ guard :process, command: ['bundle', 'exec', 'ruby', '-e', "require('byld/block/server')"], stop_signal: 'KILL' do
11
+ watch /.*/
12
+ ignore /.*\.sqlite/
13
+ end
@@ -0,0 +1,9 @@
1
+ guard :shell do
2
+ watch('Gemfile') do
3
+ `bundle install`
4
+ end
5
+ end
6
+
7
+ guard :process, command: ['bundle', 'exec', 'ruby', '-e', "require('byld/gate/server')"], stop_signal: 'KILL' do
8
+ watch /.*/
9
+ end
@@ -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 = '0.0.4'
7
+ spec.version = BYLD_VERSION
7
8
 
8
9
  spec.authors = ['the fellowhip co']
9
10
  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
- namespace_config = Config.load(".byld/config.yml")
16
16
 
17
- success, res = Infra.generate_client(name, namespace_config['namespace']['id'])
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
 
@@ -7,21 +7,18 @@ class CreateBlock < Thor::Group
7
7
  File.dirname(__FILE__)
8
8
  end
9
9
 
10
- def create_directory
10
+ def create_infra
11
11
  say "āœļø Setting up #{name}..."
12
- directory '../templates/block', name
13
- end
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
- block_config = Config.load("#{name}/.byld/config.yml")
21
- block_config.merge!(project: res)
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
 
@@ -7,13 +7,13 @@ 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
- ActiveRecord::MigrationContext.new(".byld/migrations/").migrate
12
+ ActiveRecord::MigrationContext.new("models/migrations/").migrate
13
13
  end
14
14
 
15
15
  def update_schema
16
- filename = ".byld/schema.rb"
16
+ filename = "models/schema.rb"
17
17
  File.open(filename, "w:utf-8") do |file|
18
18
  ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, file)
19
19
  end
@@ -8,6 +8,6 @@ class StartBlock < Thor::Group
8
8
  end
9
9
 
10
10
  def start_block
11
- Kernel.exec("bundle exec ruby -e \"require 'byld/block/server'\"")
11
+ Kernel.exec("bundle exec ruby -e \"require('byld/block/server')\"")
12
12
  end
13
13
  end
@@ -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 "šŸŸ¢ Connected!"
35
+ puts "šŸŒ Connecting to Byld 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
@@ -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 create_directory
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
- namespace_config = Config.load("#{name}/.byld/config.yml")
21
- namespace_config.merge!(namespace: res)
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
@@ -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,35 +8,25 @@ 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)
17
17
 
18
18
  gates = res['projects']
19
- .filter { |project| project['projectType'] == 'graph' }
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
- .filter { |project| project['projectType'] == 'domain' }
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
@@ -1,3 +1,4 @@
1
1
  BYLD_CONF = "#{Dir.home}/.byld.yaml"
2
2
  BYLD_HOST = ENV['BYLD_HOST'] || 'api.letsbyld.com'
3
3
  BIFROST_HOST = ENV['BIFROST_HOST'] || 'sockets.letsbyld.com'
4
+ BYLD_VERSION = '0.0.10'
@@ -5,22 +5,19 @@ class CreateGate < Thor::Group
5
5
  File.dirname(__FILE__)
6
6
  end
7
7
 
8
- def create_directory
8
+ def create_infra
9
9
  say "āœļø Setting up your gate..."
10
-
11
- directory "../templates/gate", 'gate'
12
- end
13
10
 
14
- def create_infra
15
- namespace_config = Config.load(".byld/config.yml")
16
- sucess, res = Infra.create_project(namespace_config['namespace']['id'], 'gate', 'graph')
17
-
11
+ namespace_id = ConfigHelper.get_namespace_id
12
+ sucess, res = Infra.create_project(namespace_id, 'gate', 'graph')
13
+
18
14
  if sucess
19
- say "šŸ‘ Gate created successfully!"
20
- gate_config = Config.load("gate/.byld/config.yml")
21
- gate_config.merge!(project: res)
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
 
@@ -12,27 +12,27 @@ 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']
32
32
  puts "šŸŒ #{name} exposed successfully!"
33
33
  end
34
34
  else
35
- puts "āš ļø Error exposing block. Reason: #{res}"
35
+ puts "āš ļø Error exposing block. Reason: #{res['error']}"
36
36
  end
37
37
  end
38
38
 
@@ -18,10 +18,10 @@ class MigrationGenerator
18
18
  private
19
19
  def create_migration_file(name, template)
20
20
  timestamp = Time.now.strftime("%Y%m%d%H%M%S")
21
- path = ".byld/migrations/#{timestamp}_#{name}.rb"
22
-
21
+ path = "models/migrations/#{timestamp}_#{name}.rb"
22
+
23
23
  template("./templates/#{template}", path)
24
24
  puts "Migration #{path} created!"
25
25
  end
26
-
26
+
27
27
  end
@@ -1,3 +1,3 @@
1
- class <%= @model_camel %> < ActiveRecord::Base
2
- expose allow: [:get, :create, :update, :delete]
1
+ class <%= @model_camel %> < Byld::Model
2
+ enable_builtins
3
3
  end
@@ -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 = "../.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
@@ -3,5 +3,5 @@ source "https://rubygems.org"
3
3
  gem 'sqlite3'
4
4
 
5
5
  source "https://rubygems.pkg.github.com/the-fellowship-co/" do
6
- gem "byld-framework", "0.1.27"
6
+ gem "byld-framework", "0.1.38"
7
7
  end
@@ -0,0 +1,9 @@
1
+ # Add your configs in this file. You can access them in your code using
2
+ # `Settings`.
3
+ # Ex:
4
+ # key1: val1
5
+ # key2:
6
+ # nestedKey: val
7
+ # To access the config data,
8
+ # Settings.key1, Settings.key2, Settings.key2.nestedKey
9
+
@@ -1,5 +1,5 @@
1
1
  source "https://rubygems.org"
2
2
 
3
3
  source "https://rubygems.pkg.github.com/the-fellowship-co/" do
4
- gem "byld-framework", "0.1.27"
4
+ gem "byld-framework", "0.1.38"
5
5
  end
@@ -0,0 +1,9 @@
1
+ # Add your configs in this file. You can access them in your code using
2
+ # `Settings`.
3
+ # Ex:
4
+ # key1: val1
5
+ # key2:
6
+ # nestedKey: val
7
+ # To access the config data,
8
+ # Settings.key1, Settings.key2, Settings.key2.nestedKey
9
+
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
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - the fellowhip co
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-28 00:00:00.000000000 Z
11
+ date: 2020-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -120,8 +120,11 @@ files:
120
120
  - ".irbrc"
121
121
  - ".ruby-gemset"
122
122
  - ".ruby-version"
123
+ - Dockerfile
123
124
  - Gemfile
124
125
  - Gemfile.lock
126
+ - Guardfile.block
127
+ - Guardfile.gate
125
128
  - README.md
126
129
  - Rakefile
127
130
  - byld-cli.gemspec
@@ -155,12 +158,14 @@ files:
155
158
  - lib/helpers/config_helper.rb
156
159
  - lib/templates/block/.byld/config.yml.tt
157
160
  - lib/templates/block/.byld/gen/.empty_directory
158
- - lib/templates/block/.byld/migrations/.empty_directory
159
161
  - lib/templates/block/Gemfile
162
+ - lib/templates/block/config.yml.tt
160
163
  - lib/templates/block/models/.empty_directory
161
164
  - lib/templates/block/models/messages/.empty_directory
165
+ - lib/templates/block/models/migrations/.empty_directory
162
166
  - lib/templates/gate/.byld/config.yml.tt
163
167
  - lib/templates/gate/Gemfile
168
+ - lib/templates/gate/config.yml.tt
164
169
  - lib/templates/gate/edges/.empty_directory
165
170
  homepage:
166
171
  licenses: []
@@ -180,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
185
  - !ruby/object:Gem::Version
181
186
  version: '0'
182
187
  requirements: []
183
- rubygems_version: 3.0.3
188
+ rubygems_version: 3.0.8
184
189
  signing_key:
185
190
  specification_version: 4
186
191
  summary: cli for byld