Module: Rails::Hyperdrive::AutoInstall
- Defined in:
- lib/rails/hyperdrive/auto_install.rb
Overview
Requires no booted Rails and never raises — every failure comes back as a skipped result.
Defined Under Namespace
Classes: Result
Constant Summary collapse
- DEVELOPMENT =
"development".freeze
Class Method Summary collapse
- .current_env ⇒ Object
-
.development?(env) ⇒ Boolean
Rails may never boot in this process, and this guard fronts a write into the working tree, which a deploy or a CI container must never have modified underneath it.
- .frozen_bundle? ⇒ Boolean
- .run(root: Dir.pwd, env: current_env, io: nil) ⇒ Object
- .skip(reason, error = nil) ⇒ Object
Class Method Details
.current_env ⇒ Object
83 84 85 |
# File 'lib/rails/hyperdrive/auto_install.rb', line 83 def current_env ENV["RAILS_ENV"] || ENV["RACK_ENV"] || DEVELOPMENT end |
.development?(env) ⇒ Boolean
Rails may never boot in this process, and this guard fronts a write into the working tree, which a deploy or a CI container must never have modified underneath it.
77 78 79 80 81 |
# File 'lib/rails/hyperdrive/auto_install.rb', line 77 def development?(env) return false unless env.to_s == DEVELOPMENT return false if ENV["CI"] && !ENV["CI"].empty? !frozen_bundle? end |
.frozen_bundle? ⇒ Boolean
87 88 89 90 91 |
# File 'lib/rails/hyperdrive/auto_install.rb', line 87 def frozen_bundle? ::Bundler.respond_to?(:frozen_bundle?) && ::Bundler.frozen_bundle? rescue StandardError false end |
.run(root: Dir.pwd, env: current_env, io: nil) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/rails/hyperdrive/auto_install.rb', line 43 def run(root: Dir.pwd, env: current_env, io: nil) root = File.(root.to_s) return skip(:not_development) unless development?(env) return skip(:not_initialized) unless File.exist?(File.join(root, InstallLayout::LOCK_PATH)) artifacts = BundlerArtifactDiscovery.discover status = ArtifactStatus.compare(root: root, artifacts: artifacts) installed = [] unwired = false unless status.missing.empty? pipeline = InstallPipeline.new( root: root, shell: InstallShell.new(root: root, io: io), artifacts: artifacts, mode: :additive ) installed = pipeline.call.installed # This runs from a bundle install, which must not edit CLAUDE.md, so a # guideline landing in an app with no import line stays out of context # until the user runs a sync. unwired = pipeline.lock.claude_md_state.nil? && (installed & pipeline.lock.guideline_paths).any? end Result.new(installed: installed, outdated: status.outdated, orphaned: status.orphaned, unwired: unwired) rescue StandardError => e skip(:error, e) end |
.skip(reason, error = nil) ⇒ Object
93 94 95 |
# File 'lib/rails/hyperdrive/auto_install.rb', line 93 def skip(reason, error = nil) Result.new(installed: [], outdated: [], orphaned: [], skipped: reason, error: error) end |