Class: BoringBuilder::Project
- Inherits:
-
Object
- Object
- BoringBuilder::Project
- Defined in:
- lib/boringbuilder/project.rb
Constant Summary collapse
- DEFAULT_EXCLUDES =
%w[ .env .env.* .bundle/cache .git coverage dist log node_modules tmp vendor/bundle ].freeze
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
Instance Method Summary collapse
- #app_name ⇒ Object
- #application_path ⇒ Object
- #application_user ⇒ Object
- #artifact ⇒ Object
- #artifact_paths ⇒ Object
- #assets? ⇒ Boolean
- #bootsnap? ⇒ Boolean
- #container(client, progress: DaggerRuby::Progress.silent) ⇒ Object
- #custom_pipeline? ⇒ Boolean
- #framework ⇒ Object
- #hanami? ⇒ Boolean
-
#initialize(configuration) ⇒ Project
constructor
A new instance of Project.
- #locked? ⇒ Boolean
- #output_path ⇒ Object
- #plan ⇒ Object
- #rails? ⇒ Boolean
- #root ⇒ Object
- #ruby? ⇒ Boolean
- #ruby_version ⇒ Object
- #runtime_command ⇒ Object
- #runtime_entrypoint ⇒ Object
- #runtime_environment ⇒ Object
- #runtime_port ⇒ Object
- #source(client) ⇒ Object
- #source_file(client, path) ⇒ Object
- #validate! ⇒ Object
- #web? ⇒ Boolean
Constructor Details
#initialize(configuration) ⇒ Project
Returns a new instance of Project.
20 21 22 |
# File 'lib/boringbuilder/project.rb', line 20 def initialize(configuration) @configuration = configuration end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
18 19 20 |
# File 'lib/boringbuilder/project.rb', line 18 def configuration @configuration end |
Instance Method Details
#app_name ⇒ Object
48 49 50 |
# File 'lib/boringbuilder/project.rb', line 48 def app_name @app_name ||= root.basename.to_s.downcase.gsub(/[^a-z0-9]+/, "-").gsub(/\A-+|-+\z/, "") end |
#application_path ⇒ Object
93 94 95 |
# File 'lib/boringbuilder/project.rb', line 93 def application_path application.path end |
#application_user ⇒ Object
97 98 99 |
# File 'lib/boringbuilder/project.rb', line 97 def application_user application.user end |
#artifact ⇒ Object
121 122 123 124 125 126 127 128 |
# File 'lib/boringbuilder/project.rb', line 121 def artifact @artifact ||= begin configured = configuration.artifact add_configured_entries(configured) add_default_entries(configured) if configured.empty? configured end end |
#artifact_paths ⇒ Object
89 90 91 |
# File 'lib/boringbuilder/project.rb', line 89 def artifact_paths artifact.entries.filter_map { |entry| entry.source if entry.origin == :container }.map(&:to_s) end |
#assets? ⇒ Boolean
77 78 79 80 81 |
# File 'lib/boringbuilder/project.rb', line 77 def assets? return configuration.assets unless configuration.assets.nil? root.join("app/assets").directory? || root.join("config/manifest.js").file? end |
#bootsnap? ⇒ Boolean
83 84 85 86 87 |
# File 'lib/boringbuilder/project.rb', line 83 def bootsnap? return configuration.bootsnap unless configuration.bootsnap.nil? root.join("Gemfile.lock").read.match?(/^ bootsnap \(/) end |
#container(client, progress: DaggerRuby::Progress.silent) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/boringbuilder/project.rb', line 33 def container(client, progress: DaggerRuby::Progress.silent) return Pipeline.new(self, client, progress: progress).build(&configuration.pipeline) if custom_pipeline? builder = rails? ? RailsBuild : RubyBuild builder.new(self, client, progress: progress).container end |
#custom_pipeline? ⇒ Boolean
152 153 154 |
# File 'lib/boringbuilder/project.rb', line 152 def custom_pipeline? !configuration.pipeline.nil? end |
#framework ⇒ Object
64 65 66 |
# File 'lib/boringbuilder/project.rb', line 64 def framework application.framework end |
#hanami? ⇒ Boolean
60 61 62 |
# File 'lib/boringbuilder/project.rb', line 60 def hanami? application.hanami? end |
#locked? ⇒ Boolean
68 69 70 |
# File 'lib/boringbuilder/project.rb', line 68 def locked? root.join("Gemfile.lock").file? end |
#output_path ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/boringbuilder/project.rb', line 130 def output_path return configuration.output if configuration.output suffix = { directory: "rootfs", tar: "tar", tar_zst: "tar.zst", oci: "oci.tar", docker: "docker.tar" }.fetch(configuration.format) platform = configuration.platform&.tr("/", "-") || "native" root.join("dist", "#{app_name}-#{platform}.#{suffix}") end |
#plan ⇒ Object
40 41 42 |
# File 'lib/boringbuilder/project.rb', line 40 def plan ProjectPlan.new(self).to_h end |
#rails? ⇒ Boolean
52 53 54 |
# File 'lib/boringbuilder/project.rb', line 52 def rails? application.rails? end |
#root ⇒ Object
44 45 46 |
# File 'lib/boringbuilder/project.rb', line 44 def root configuration.root end |
#ruby? ⇒ Boolean
56 57 58 |
# File 'lib/boringbuilder/project.rb', line 56 def ruby? application.ruby? end |
#ruby_version ⇒ Object
72 73 74 75 |
# File 'lib/boringbuilder/project.rb', line 72 def ruby_version @ruby_version ||= mise_ruby_version || tool_versions_ruby_version || ruby_version_file || gemfile_ruby_version || locked_ruby_version || RUBY_VERSION end |
#runtime_command ⇒ Object
105 106 107 |
# File 'lib/boringbuilder/project.rb', line 105 def runtime_command application.runtime_command end |
#runtime_entrypoint ⇒ Object
109 110 111 |
# File 'lib/boringbuilder/project.rb', line 109 def runtime_entrypoint application.runtime_entrypoint end |
#runtime_environment ⇒ Object
101 102 103 |
# File 'lib/boringbuilder/project.rb', line 101 def runtime_environment application.runtime_environment end |
#runtime_port ⇒ Object
113 114 115 |
# File 'lib/boringbuilder/project.rb', line 113 def runtime_port application.runtime_port end |
#source(client) ⇒ Object
144 145 146 |
# File 'lib/boringbuilder/project.rb', line 144 def source(client) client.host.directory(root.to_s, exclude: DEFAULT_EXCLUDES, gitignore: true) end |
#source_file(client, path) ⇒ Object
148 149 150 |
# File 'lib/boringbuilder/project.rb', line 148 def source_file(client, path) client.host.file(root.join(path).to_s) end |
#validate! ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/boringbuilder/project.rb', line 24 def validate! configuration.validate! validate_lockfile! validate_application! validate_native_javascript! Exporters::Resolver.new(self, nil).validate! self end |
#web? ⇒ Boolean
117 118 119 |
# File 'lib/boringbuilder/project.rb', line 117 def web? application.web? end |