Class: CaptiveStackDetector::PackageJsonAnalyzer

Inherits:
Object
  • Object
show all
Defined in:
lib/captive_stack_detector/package_json_analyzer.rb

Instance Method Summary collapse

Constructor Details

#initialize(package_json) ⇒ PackageJsonAnalyzer

Returns a new instance of PackageJsonAnalyzer.



8
9
10
# File 'lib/captive_stack_detector/package_json_analyzer.rb', line 8

def initialize(package_json)
  @parsed = JSON.parse(package_json)
end

Instance Method Details

#backendObject



33
34
35
# File 'lib/captive_stack_detector/package_json_analyzer.rb', line 33

def backend
  (deps.key?("@supabase/supabase-js") || deps.key?("@supabase/ssr")) ? "supabase" : nil
end

#databaseObject



23
24
25
26
27
# File 'lib/captive_stack_detector/package_json_analyzer.rb', line 23

def database
  return "postgres" if deps.key?("pg") || backend

  nil
end

#queueObject



29
30
31
# File 'lib/captive_stack_detector/package_json_analyzer.rb', line 29

def queue
  (deps.key?("redis") || deps.key?("ioredis")) ? "redis" : nil
end

#subtypeObject



19
20
21
# File 'lib/captive_stack_detector/package_json_analyzer.rb', line 19

def subtype
  SsrFrameworkDetector.server?(deps) ? "server" : nil
end

#typeObject



12
13
14
15
16
17
# File 'lib/captive_stack_detector/package_json_analyzer.rb', line 12

def type
  return "expo" if deps.key?("expo")
  return "node" if @parsed.dig("scripts", "start")

  nil
end