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
85 86 87 |
# File 'lib/rails/hyperdrive/auto_install.rb', line 85 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.
79 80 81 82 83 |
# File 'lib/rails/hyperdrive/auto_install.rb', line 79 def development?(env) return false unless env.to_s == DEVELOPMENT return false if ENV["CI"] && !ENV["CI"].empty? !frozen_bundle? end |
.frozen_bundle? ⇒ Boolean
89 90 91 92 93 |
# File 'lib/rails/hyperdrive/auto_install.rb', line 89 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
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 73 74 |
# File 'lib/rails/hyperdrive/auto_install.rb', line 44 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)) enabled = LockFile.load(File.join(root, InstallLayout::LOCK_PATH)).enabled_gems artifacts = BundlerArtifactDiscovery.discover(enabled_gems: enabled) 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
95 96 97 |
# File 'lib/rails/hyperdrive/auto_install.rb', line 95 def skip(reason, error = nil) Result.new(installed: [], outdated: [], orphaned: [], skipped: reason, error: error) end |