blufin-lib 1.8.0 → 1.8.1

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
  SHA1:
3
- metadata.gz: 951694bcd607959a657e046002654767755b74d6
4
- data.tar.gz: def507a9855268d197362bad03e915720ef2c26f
3
+ metadata.gz: b1987fd9c5b7b8590adc63c9179ce7eb8d398fb3
4
+ data.tar.gz: 5064081160441c67b7bbe48f369688a9430c85c8
5
5
  SHA512:
6
- metadata.gz: 0bedc142caf1e81f3aa0dcff437217451f8db5560f6d4ef4f58e3fa6540148ad913e781f28873a20a647e21877c21b0d0397a5877576a1f489d554a82ba6ca54
7
- data.tar.gz: 6326f21a88d05ce9abf5296e14d5ccd1cf55a9cd57efd9a43628afd82b1afe095fb4ce9562f2f14618ca3562ff4df1f8989036b178fc9d1a2d95a746494cdf6e
6
+ metadata.gz: e7e9b674320a55992ae41b263bdaf9bcd4e8e5eeba2a821708640e876682f05f4b9209407eb79941955c0b95d2d9ad59b36ff19a096dc8568294b1bf9a61958a
7
+ data.tar.gz: db2bf6c32f4f9e27e06861633dd49b7a12972181860d01674470bd8314e18e421c587ca31b4bf6f0169f72dd3b768a1171eb468a3738902b6a22b1fcc887886b
data/lib/blufin-lib.rb CHANGED
@@ -4,6 +4,7 @@ module Blufin
4
4
  autoload :AWS, 'core/aws'
5
5
  autoload :Base, 'core/base'
6
6
  autoload :Config, 'core/config'
7
+ autoload :Constants, 'core/constants'
7
8
  autoload :DateTimeUtils, 'core/datetime_utils'
8
9
  autoload :Files, 'core/files'
9
10
  autoload :GenerateBase, 'generate/generate_base'
@@ -14,6 +15,9 @@ module Blufin
14
15
  autoload :Numbers, 'core/numbers'
15
16
  autoload :Projects, 'core/projects'
16
17
  autoload :Routes, 'core/routes'
18
+ autoload :Scanner, 'scan/scanner'
19
+ autoload :ScannerJava, 'scan/scanner_java'
20
+ autoload :ScannerVue, 'scan/scanner_vue'
17
21
  autoload :Strings, 'core/strings'
18
22
  autoload :Terminal, 'core/terminal'
19
23
  autoload :Tools, 'core/tools'
@@ -0,0 +1,92 @@
1
+ module Blufin
2
+
3
+ class Constants
4
+
5
+ # Returns a Hash of gems. :repo is only filled in inside 'my' gem because it's the only gem where it's defined in the config file (.my.yml).
6
+ # Outside this gem, :repo will simply be nil.
7
+ # @return Hash
8
+ def self.gems
9
+
10
+ {
11
+ 'blufin-lib' => {
12
+ :name => 'blufin-lib',
13
+ :aliases => %w(blufin-lib bl),
14
+ :repo => gem_get_repo('BlufinLib'),
15
+ :version_file => 'lib/version.rb',
16
+ :version_const => 'BLUFIN_LIB_VERSION',
17
+ :downstream => %w(convoy awx blufin eworld my), # Needs to be in this specific order, with convoy first.
18
+ :upstream => %w()
19
+ },
20
+ 'convoy' => {
21
+ :name => 'convoy',
22
+ :aliases => %w(convoy),
23
+ :repo => gem_get_repo('Convoy'),
24
+ :version_file => 'version.rb',
25
+ :version_const => 'CONVOY_VERSION',
26
+ :downstream => %w(awx blufin my eworld),
27
+ :upstream => %w(blufin-lib)
28
+ },
29
+ 'columnist' => {
30
+ :name => 'columnist',
31
+ :aliases => %w(columnist),
32
+ :repo => gem_get_repo('Columnist'),
33
+ :version_file => 'version.rb',
34
+ :version_const => 'COLUMNIST_VERSION',
35
+ :downstream => %w(awx blufin my eworld),
36
+ :upstream => %w()
37
+ },
38
+ 'awx' => {
39
+ :name => 'awx',
40
+ :aliases => %w(awx a),
41
+ :repo => gem_get_repo('AWX'),
42
+ :version_file => 'lib/version.rb',
43
+ :version_const => 'AWX_VERSION',
44
+ :downstream => %w(),
45
+ :upstream => %w(blufin-lib columnist convoy)
46
+ },
47
+ 'blufin' => {
48
+ :name => 'blufin',
49
+ :aliases => %w(blufin b bf),
50
+ :repo => gem_get_repo('Blufin'),
51
+ :version_file => 'lib/version.rb',
52
+ :version_const => 'BLUFIN_VERSION',
53
+ :downstream => %w(),
54
+ :upstream => %w(blufin-lib columnist convoy)
55
+ },
56
+ 'my' => {
57
+ :name => 'my',
58
+ :aliases => %w(my m),
59
+ :repo => gem_get_repo('My'),
60
+ :version_file => 'lib/version.rb',
61
+ :version_const => 'MY_VERSION',
62
+ :downstream => %w(),
63
+ :upstream => %w(blufin-lib columnist convoy)
64
+ },
65
+ 'eworld' => {
66
+ :name => 'eworld',
67
+ :aliases => %w(ew e),
68
+ :repo => gem_get_repo('eWorld'),
69
+ :version_file => 'lib/version.rb',
70
+ :version_const => 'EWORLD_VERSION',
71
+ :downstream => %w(),
72
+ :upstream => %w(blufin-lib columnist convoy)
73
+ }
74
+ }
75
+
76
+ end
77
+
78
+ private
79
+
80
+ # Attempts to get repo. Returns nil if not exists.
81
+ # @return string
82
+ def self.gem_get_repo(key)
83
+ begin
84
+ Blufin::Config::get['Repositories'][key]
85
+ rescue
86
+ nil
87
+ end
88
+ end
89
+
90
+ end
91
+
92
+ end
data/lib/core/projects.rb CHANGED
@@ -29,10 +29,11 @@ module Blufin
29
29
  BUILD = 'Build'
30
30
  COMMANDS = 'Commands'
31
31
  API = 'API'
32
- CRON = 'Cron'
32
+ SCHEDULER = 'Scheduler'
33
33
  WORKER = 'Worker'
34
34
  LAMBDA = 'Lambda'
35
- UI = 'UI'
35
+ UI = 'UI' # TODO - Probably need to extend this to every type of UI.
36
+ QUASAR = 'Quasar'
36
37
  ROUTES_FILE = 'RoutesFile'
37
38
  TITLE = 'Title'
38
39
  ALIAS = 'Alias'
@@ -44,17 +45,21 @@ module Blufin
44
45
  STAGES = 'Stages'
45
46
  TYPE_ALEXA = 'alexa'
46
47
  TYPE_API = 'api'
48
+ TYPE_API_SIMPLE = 'api-simple'
47
49
  TYPE_LAMBDA = 'lambda'
48
50
  TYPE_MVN_LIB = 'mvn-lib'
49
51
  TYPE_NPM_LIB = 'npm-lib'
50
- TYPE_UI = 'ui'
51
52
  TYPE_MOBILE = 'mobile'
53
+ TYPE_QUASAR = 'quasar'
54
+ TYPE_UI = 'ui' # TODO - Probably need to extend this to every type of UI.
52
55
  VALID_TYPES = [
53
56
  TYPE_ALEXA,
54
57
  TYPE_API,
58
+ TYPE_API_SIMPLE,
55
59
  TYPE_LAMBDA,
56
60
  TYPE_MVN_LIB,
57
61
  TYPE_NPM_LIB,
62
+ TYPE_QUASAR,
58
63
  TYPE_UI,
59
64
  TYPE_MOBILE,
60
65
  ]
@@ -69,7 +74,6 @@ module Blufin
69
74
  @@api_data = {}
70
75
  @@lambdas = nil
71
76
  @@libs = {}
72
- @@uis = nil
73
77
  @@dependant_projects_cache = {}
74
78
  @@dependant_repos_cache = {}
75
79
  @@project_path_cache = {}
@@ -108,13 +112,14 @@ module Blufin
108
112
 
109
113
  # Gets Project(s) -- but in a single array.
110
114
  # @return Array
111
- def self.get_projects_as_array(type: nil)
115
+ def self.get_projects_as_array(types: nil)
112
116
  projects_arr = []
113
- if type.nil?
117
+ if types.nil?
114
118
  validate_type(project_type, project_id)
115
119
  projects_arr = @@projects_arr
116
120
  else
117
- @@projects_arr.each { |project| projects_arr << project if project[TYPE] == type }
121
+ types = [types] unless types.is_a?(Array)
122
+ @@projects_arr.each { |project| projects_arr << project if types.include?(project[TYPE]) }
118
123
  end
119
124
  projects_arr
120
125
  end
@@ -281,7 +286,7 @@ module Blufin
281
286
  Blufin::Terminal::error('No projects found.') unless array_of_projects.any?
282
287
  return array_of_projects[0] if array_of_projects.length == 1
283
288
  projects = []
284
- array_of_projects.each { |project| projects << { :text => project[PROJECT_ID], :value => project } }
289
+ array_of_projects.each { |project| projects << {:text => project[PROJECT_ID], :value => project} }
285
290
  Blufin::Terminal::prompt_select('Select project:', projects)
286
291
  end
287
292
 
@@ -339,7 +344,7 @@ module Blufin
339
344
  if project_type == TYPE_MVN_LIB || TYPE_NPM_LIB
340
345
  Blufin::Terminal::error("#{Blufin::Terminal::format_highlight(project_id)} \xe2\x80\x94 Duplicate Library Project.", "A library with this ID (#{Blufin::Terminal::format_invalid(project_id)}) has already been registered.") if @@libs.keys.include?(project_id)
341
346
  @@libs[project_id] = project
342
- elsif project_type == TYPE_API
347
+ elsif project_type == TYPE_API || project_type == TYPE_API_SIMPLE
343
348
  [ALIAS, PROJECT_NAME, PROJECT_NAME_PASCAL_CASE, TITLE].each do |x|
344
349
  @@api_data[x] = [] unless @@api_data.has_key?(x) && @@api_data[x].is_a?(Array)
345
350
  property_value = project[API][x].strip.downcase
@@ -373,6 +378,7 @@ module Blufin
373
378
  API => false,
374
379
  LAMBDA => false,
375
380
  UI => false,
381
+ QUASAR => false,
376
382
  DEPLOYMENT => false,
377
383
  }
378
384
  Blufin::Validate::assert_valid_keys(expected, project.keys, source_file)
@@ -418,7 +424,7 @@ module Blufin
418
424
  end
419
425
 
420
426
  # Validate API property.
421
- if project_type == TYPE_API
427
+ if project_type == TYPE_API || project_type == TYPE_API_SIMPLE
422
428
  # Make sure we have the API property.
423
429
  Blufin::Terminal::error("#{Blufin::Terminal::format_highlight(project_id)} \xe2\x80\x94 Missing property: #{Blufin::Terminal::format_highlight(API)}", "This property is required for project(s) with type: #{API}", true) unless project.has_key?(API)
424
430
  # Validate keys are in specific order.
@@ -432,18 +438,18 @@ module Blufin
432
438
  }
433
439
  Blufin::Validate::assert_valid_keys(expected, project[API].keys, source_file)
434
440
  expected_ports = {
435
- API => true,
436
- CRON => true,
437
- WORKER => true
441
+ API => true,
442
+ SCHEDULER => true,
443
+ WORKER => true
438
444
  }
439
445
  Blufin::Validate::assert_valid_keys(expected_ports, project[API][PORTS].keys, source_file)
440
- validate_ports([project[API][PORTS][API], project[API][PORTS][CRON], project[API][PORTS][WORKER]], project_id, used_ports)
446
+ validate_ports([project[API][PORTS][API], project[API][PORTS][SCHEDULER], project[API][PORTS][WORKER]], project_id, used_ports)
441
447
  # Add ports to used_ports.
442
- used_ports[project[API][PORTS][API]] = project_id
443
- used_ports[project[API][PORTS][CRON]] = project_id
444
- used_ports[project[API][PORTS][WORKER]] = project_id
445
- @@apis = {} if @@apis.nil?
446
- @@apis[project[PROJECT_ID]] = project
448
+ used_ports[project[API][PORTS][API]] = project_id
449
+ used_ports[project[API][PORTS][SCHEDULER]] = project_id
450
+ used_ports[project[API][PORTS][WORKER]] = project_id
451
+ @@apis = {} if @@apis.nil?
452
+ @@apis[project[PROJECT_ID]] = project
447
453
  else
448
454
  # Make sure we DON'T have the API key.
449
455
  Blufin::Terminal::error("#{Blufin::Terminal::format_highlight(project_id)} \xe2\x80\x94 Property not supported: #{Blufin::Terminal::format_invalid(API)}", "This property is only allowed for project(s) with type: #{API}", true) if project.has_key?(API)
@@ -472,24 +478,21 @@ module Blufin
472
478
  Blufin::Terminal::error("#{Blufin::Terminal::format_highlight(project_id)} \xe2\x80\x94 Property not supported: #{Blufin::Terminal::format_invalid(LAMBDA)}", "This property is only allowed for project(s) with type: #{TYPE_LAMBDA}", true) if project.has_key?(LAMBDA)
473
479
  end
474
480
 
475
- # Validate UI property.
476
- if project_type == TYPE_UI
477
- # Make sure we have the UI property.
478
- Blufin::Terminal::error("#{Blufin::Terminal::format_highlight(project_id)} \xe2\x80\x94 Missing property: #{Blufin::Terminal::format_highlight(UI)}", "This property is required for project(s) with type: #{TYPE_UI}", true) unless project.has_key?(UI)
481
+ # Validate Quasar property.
482
+ if project_type == TYPE_QUASAR
483
+ # Make sure we have the QUASAR property.
484
+ Blufin::Terminal::error("#{Blufin::Terminal::format_highlight(project_id)} \xe2\x80\x94 Missing property: #{Blufin::Terminal::format_highlight(QUASAR)}", "This property is required for project(s) with type: #{TYPE_QUASAR}", true) unless project.has_key?(QUASAR)
479
485
  # Validate keys are in specific order.
480
486
  expected = {
481
487
  ROUTES_FILE => true
482
488
  }
483
- Blufin::Validate::assert_valid_keys(expected, project[UI].keys, source_file)
489
+ Blufin::Validate::assert_valid_keys(expected, project[QUASAR].keys, source_file)
484
490
  # Validate RoutesFile exists.
485
- routes_file = "#{Blufin::Projects::get_project_path(project_id, true, project: project)}/#{project[UI][ROUTES_FILE]}"
491
+ routes_file = "#{Blufin::Projects::get_project_path(project_id, true, project: project)}/#{project[QUASAR][ROUTES_FILE]}"
486
492
  Blufin::Terminal::error("Cannot find #{Blufin::Terminal::format_highlight(ROUTES_FILE)}: #{Blufin::Terminal::format_directory(routes_file)}") unless Blufin::Files::file_exists(routes_file)
487
- @@uis = {} if @@uis.nil?
488
- Blufin::Terminal::error("Duplicate UI project: #{Blufin::Terminal::format_invalid(project[PROJECT_ID])}") if @@uis.has_key?(project[PROJECT_ID])
489
- @@uis[project[PROJECT_ID]] = project
490
493
  else
491
494
  # Make sure we DON'T have the UI key.
492
- Blufin::Terminal::error("#{Blufin::Terminal::format_highlight(project_id)} \xe2\x80\x94 Property not supported: #{Blufin::Terminal::format_invalid(UI)}", "This property is only allowed for project(s) with type: #{TYPE_UI}", true) if project.has_key?(UI)
495
+ Blufin::Terminal::error("#{Blufin::Terminal::format_highlight(project_id)} \xe2\x80\x94 Property not supported: #{Blufin::Terminal::format_invalid(QUASAR)}", "This property is only allowed for project(s) with type: #{TYPE_QUASAR}", true) if project.has_key?(QUASAR)
493
496
  end
494
497
 
495
498
  # Validate upstream/downstream Libs(s).
data/lib/core/update.rb CHANGED
@@ -5,9 +5,16 @@ module Blufin
5
5
  # Updates ruby-gem.
6
6
  # @return void
7
7
  def self.run(gem_name)
8
-
9
- raise RuntimeError, "Update #{gem_name}. Not yet implemented!"
10
-
8
+ gems = Blufin::Constants::gems
9
+ raise RuntimeError, "Invalid gem name: #{gem_name}" unless gems.keys.include?(gem_name)
10
+ Blufin::Terminal::info("Updating gem: #{Blufin::Terminal::format_action(gem_name)}")
11
+ # Uninstall all gems (including upstream).
12
+ gems[gem_name][:upstream].each { |upstream_gem| Blufin::Terminal::execute("gem uninstall #{upstream_gem} --force -I -x") }
13
+ Blufin::Terminal::execute("gem uninstall #{gem_name} --force -I -x")
14
+ # Re-install all gems (including upstream).
15
+ gems[gem_name][:upstream].each { |upstream_gem| Blufin::Terminal::execute("gem install #{upstream_gem}") }
16
+ res = Blufin::Terminal::execute("gem install #{gem_name}", capture: true)
17
+ Blufin::Terminal::success("Your are now on: #{Blufin::Terminal::format_highlight(`gem list | grep "#{gem_name} "`).gsub("\n", '')}", Blufin::Arrays::convert_string_to_line_array(res[0]))
11
18
  end
12
19
 
13
20
  end
@@ -20,6 +20,28 @@ module Blufin
20
20
 
21
21
  end
22
22
 
23
+ # Display errors/warnings after code generation, if any.
24
+ # This method currently terminates with a 1 exit code if errors/warnings occurred, 0 if not.
25
+ # @return void
26
+ def self.exit_code_generation(errors, warnings)
27
+
28
+ if warnings.any?
29
+ Blufin::Terminal::warning('Please fix the following warnings(s):', nil, false)
30
+ warnings.each { |warning| puts " #{warning}" }
31
+ puts
32
+ end
33
+
34
+ if errors.any?
35
+ Blufin::Terminal::error('Please fix the following error(s):', nil, false)
36
+ errors.each { |error| puts " #{error}" }
37
+ puts
38
+ exit 1
39
+ end
40
+
41
+ return errors.any? || warnings.any? ? 1 : 0
42
+
43
+ end
44
+
23
45
  end
24
46
 
25
47
  end
@@ -8,7 +8,7 @@ module Blufin
8
8
  # Generates routes in the UI.
9
9
  # @return void
10
10
  def self.run(project)
11
- raise RuntimeError, "Expected project type to be: #{Blufin::Projects::TYPE_UI}, instead got: #{project[Blufin::Projects::TYPE]}" unless project[Blufin::Projects::TYPE] == Blufin::Projects::TYPE_UI
11
+ raise RuntimeError, "Expected project type to be: #{Blufin::Projects::TYPE_QUASAR}, instead got: #{project[Blufin::Projects::TYPE]}" unless project[Blufin::Projects::TYPE] == Blufin::Projects::TYPE_QUASAR
12
12
  @errors = []
13
13
  @warnings = []
14
14
  @files = []
@@ -19,7 +19,7 @@ const routes = [
19
19
  {
20
20
  TEMPLATE
21
21
  project_path = Blufin::Projects::get_project_path(project[Blufin::Projects::PROJECT_ID], true)
22
- routes_file = "#{project_path}/#{project[Blufin::Projects::UI][Blufin::Projects::ROUTES_FILE]}"
22
+ routes_file = "#{project_path}/#{project[Blufin::Projects::QUASAR][Blufin::Projects::ROUTES_FILE]}"
23
23
  routes_yml = Blufin::Yml::read_file(routes_file, SCHEMA_FILE)
24
24
  target_file = "#{project_path}/src/#{Blufin::Strings::remove_surrounding_slashes(routes_yml['RoutesFile'])}"
25
25
  layout = routes_yml['Layout']
@@ -0,0 +1,34 @@
1
+ module Blufin
2
+
3
+ class Scanner
4
+
5
+ # Initialize the class.
6
+ # @return void
7
+ def initialize(java_path: nil, vue_path: nil)
8
+
9
+ scan_java(java_path) unless java_path.nil?
10
+ scan_vue(vue_path) unless vue_path.nil?
11
+
12
+ end
13
+
14
+ private
15
+
16
+ # Scan Java code.
17
+ # @return void
18
+ def scan_java(path)
19
+
20
+ Blufin::ScannerJava::scan(path)
21
+
22
+ end
23
+
24
+ # Scan Vue code.
25
+ # @return void
26
+ def scan_vue(path)
27
+
28
+ Blufin::ScannerVue::scan(path)
29
+
30
+ end
31
+
32
+ end
33
+
34
+ end
@@ -0,0 +1,19 @@
1
+ module Blufin
2
+
3
+ class ScannerJava
4
+
5
+ # Scan Java code.
6
+ # @return void
7
+ def self.scan(path)
8
+
9
+ # Check path exists.
10
+ Blufin::Terminal::error("Path does not exist: #{Blufin::Terminal::format_invalid(path)}") unless Blufin::Files::path_exists(path)
11
+
12
+ # TODO - REMOVE
13
+ raise 'Not yet implemented!'
14
+
15
+ end
16
+
17
+ end
18
+
19
+ end
@@ -0,0 +1,20 @@
1
+ module Blufin
2
+
3
+ class ScannerVue
4
+
5
+ # Scan Vue code.
6
+ # @return void
7
+ def self.scan(path)
8
+
9
+ # Check path exists.
10
+ Blufin::Terminal::error("Path does not exist: #{Blufin::Terminal::format_invalid(path)}") unless Blufin::Files::path_exists(path)
11
+
12
+ # TODO - REMOVE
13
+ raise 'Not yet implemented!'
14
+
15
+ end
16
+
17
+
18
+ end
19
+
20
+ end
data/lib/version.rb CHANGED
@@ -1 +1 @@
1
- BLUFIN_LIB_VERSION = '1.8.0'
1
+ BLUFIN_LIB_VERSION = '1.8.1'
@@ -125,7 +125,7 @@ mapping:
125
125
  API:
126
126
  type: number
127
127
  required: yes
128
- Cron:
128
+ Scheduler:
129
129
  type: number
130
130
  required: yes
131
131
  Worker:
@@ -146,8 +146,13 @@ mapping:
146
146
  required: yes
147
147
  sequence:
148
148
  - type: str
149
- UI:
149
+ Quasar:
150
150
  type: map
151
151
  mapping:
152
152
  RoutesFile:
153
+ required: yes
154
+ UI:
155
+ type: map
156
+ mapping:
157
+ DeleteMe: # TODO - Finish this (or remove)
153
158
  required: yes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blufin-lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Albert Rannetsperger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-12 00:00:00.000000000 Z
11
+ date: 2019-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline
@@ -133,6 +133,7 @@ files:
133
133
  - lib/core/aws.rb
134
134
  - lib/core/base.rb
135
135
  - lib/core/config.rb
136
+ - lib/core/constants.rb
136
137
  - lib/core/datetime_utils.rb
137
138
  - lib/core/files.rb
138
139
  - lib/core/git.rb
@@ -150,6 +151,9 @@ files:
150
151
  - lib/core/yml.rb
151
152
  - lib/generate/generate_base.rb
152
153
  - lib/generate/generate_ui_routes.rb
154
+ - lib/scan/scanner.rb
155
+ - lib/scan/scanner_java.rb
156
+ - lib/scan/scanner_vue.rb
153
157
  - lib/version.rb
154
158
  - opt/schema/projects.yml
155
159
  - opt/schema/routes.yml
@@ -174,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
178
  version: '0'
175
179
  requirements: []
176
180
  rubyforge_project:
177
- rubygems_version: 2.5.1
181
+ rubygems_version: 2.5.2.3
178
182
  signing_key:
179
183
  specification_version: 4
180
184
  summary: Blufin Lib