captive-stack-detector 0.1.1 → 0.2.3
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/lib/captive_stack_detector/js_stack_detector.rb +7 -6
- data/lib/captive_stack_detector/rails_stack_detector.rb +15 -6
- data/lib/captive_stack_detector/system_package_detector.rb +34 -0
- data/lib/captive_stack_detector/types.rb +1 -1
- data/lib/captive_stack_detector/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 53689ba57c5a735ec281c82ea9b38fd91e20e509117f69aeb939b6f49e7a98d3
|
|
4
|
+
data.tar.gz: 12837a574f77ed04eb5e0a71aab90a3a2fa58082bd49391496844400e0db2a14
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 97486347c8c428bc96d8cbe7e0ef2372ebb20c1500c67efcf210b26162e0f577868fd7f8596fc9d7b78ee5f1afde5f9ac4e1cbe171c22aa56b6479e9a9c11b7e
|
|
7
|
+
data.tar.gz: 8c201c41acbd1a35be4841e050dd7d104895c07b48c2b4408b67c638ed9cadb098022bbb284ed126a079d5aee8f31201c8b77f360a9ffe25a4111769eda26d2b
|
|
@@ -15,12 +15,13 @@ module CaptiveStackDetector
|
|
|
15
15
|
raise UnsupportedStack unless type
|
|
16
16
|
|
|
17
17
|
Result.new(
|
|
18
|
-
type:
|
|
19
|
-
subtype:
|
|
20
|
-
services:
|
|
21
|
-
worker:
|
|
22
|
-
runtime:
|
|
23
|
-
env_vars:
|
|
18
|
+
type: type,
|
|
19
|
+
subtype: nil,
|
|
20
|
+
services: Services.new(database: @analyzer.database, queue: @analyzer.queue),
|
|
21
|
+
worker: build_worker,
|
|
22
|
+
runtime: Runtime.new(ruby: nil, node: @reader.node_version),
|
|
23
|
+
env_vars: {},
|
|
24
|
+
system_packages: [],
|
|
24
25
|
)
|
|
25
26
|
end
|
|
26
27
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative "../captive_stack_detector"
|
|
4
|
+
require_relative "system_package_detector"
|
|
4
5
|
|
|
5
6
|
module CaptiveStackDetector
|
|
6
7
|
class RailsStackDetector
|
|
@@ -13,12 +14,13 @@ module CaptiveStackDetector
|
|
|
13
14
|
raise UnsupportedStack unless @analyzer.rails?
|
|
14
15
|
|
|
15
16
|
Result.new(
|
|
16
|
-
type:
|
|
17
|
-
subtype:
|
|
18
|
-
services:
|
|
19
|
-
worker:
|
|
20
|
-
runtime:
|
|
21
|
-
env_vars:
|
|
17
|
+
type: "rails",
|
|
18
|
+
subtype: @analyzer.subtype,
|
|
19
|
+
services: Services.new(database: @analyzer.database, queue: @analyzer.queue),
|
|
20
|
+
worker: build_worker,
|
|
21
|
+
runtime: Runtime.new(ruby: @reader.ruby_version, node: nil),
|
|
22
|
+
env_vars: @reader.env_vars,
|
|
23
|
+
system_packages: system_packages,
|
|
22
24
|
)
|
|
23
25
|
end
|
|
24
26
|
|
|
@@ -28,5 +30,12 @@ module CaptiveStackDetector
|
|
|
28
30
|
command = @analyzer.worker_command(@reader.read("Procfile"))
|
|
29
31
|
command ? Worker.new(command: command) : nil
|
|
30
32
|
end
|
|
33
|
+
|
|
34
|
+
def system_packages
|
|
35
|
+
SystemPackageDetector.new(
|
|
36
|
+
gemfile: @reader.read("Gemfile"),
|
|
37
|
+
aptfile: @reader.read("Aptfile"),
|
|
38
|
+
).packages
|
|
39
|
+
end
|
|
31
40
|
end
|
|
32
41
|
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module CaptiveStackDetector
|
|
4
|
+
class SystemPackageDetector
|
|
5
|
+
GEM_TO_PACKAGES = {
|
|
6
|
+
"ruby-vips" => %w[libvips42 libvips-dev],
|
|
7
|
+
"mini_magick" => %w[imagemagick],
|
|
8
|
+
"rmagick" => %w[imagemagick],
|
|
9
|
+
"wkhtmltopdf-binary" => %w[wkhtmltopdf],
|
|
10
|
+
"sqlite3" => %w[libsqlite3-dev],
|
|
11
|
+
}.freeze
|
|
12
|
+
|
|
13
|
+
def initialize(gemfile:, aptfile:)
|
|
14
|
+
@gemfile = gemfile.to_s
|
|
15
|
+
@aptfile = aptfile.to_s
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def packages
|
|
19
|
+
from_gemfile + from_aptfile
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
def from_gemfile
|
|
25
|
+
GEM_TO_PACKAGES.each_with_object([]) do |(gem, pkgs), result|
|
|
26
|
+
result.concat(pkgs) if @gemfile.match?(/gem ['"]#{Regexp.escape(gem)}['"]/)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def from_aptfile
|
|
31
|
+
@aptfile.lines.map(&:strip).reject { |l| l.empty? || l.start_with?("#") }
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -4,7 +4,7 @@ module CaptiveStackDetector
|
|
|
4
4
|
Services = Data.define(:database, :queue)
|
|
5
5
|
Worker = Data.define(:command)
|
|
6
6
|
Runtime = Data.define(:ruby, :node)
|
|
7
|
-
Result = Data.define(:type, :subtype, :services, :worker, :runtime, :env_vars)
|
|
7
|
+
Result = Data.define(:type, :subtype, :services, :worker, :runtime, :env_vars, :system_packages)
|
|
8
8
|
|
|
9
9
|
UnsupportedStack = Class.new(StandardError)
|
|
10
10
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: captive-stack-detector
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Captive Studio
|
|
@@ -29,6 +29,7 @@ files:
|
|
|
29
29
|
- lib/captive_stack_detector/package_json_analyzer.rb
|
|
30
30
|
- lib/captive_stack_detector/rails_stack_detector.rb
|
|
31
31
|
- lib/captive_stack_detector/ruby_version_detector.rb
|
|
32
|
+
- lib/captive_stack_detector/system_package_detector.rb
|
|
32
33
|
- lib/captive_stack_detector/types.rb
|
|
33
34
|
- lib/captive_stack_detector/version.rb
|
|
34
35
|
homepage: https://github.com/captive-studio/captive-stack-detector
|