Class: Kettle::Dev::LockfileReset
- Inherits:
-
Object
- Object
- Kettle::Dev::LockfileReset
- Defined in:
- lib/kettle/dev/lockfile_reset.rb
Constant Summary collapse
- DEFAULT_DISABLED_ENV =
{ "KETTLE_DEV_DEV" => "false", "K_JEM_TEMPLATING" => "false", "STRUCTUREDMERGE_DEV" => "false", "TREE_SITTER_LANGUAGE_PACK_DEV" => "false", "RUBOCOP_LTS_LOCAL" => "false", "GALTZO_FLOSS_DEV" => "false", "UR_BRAIN_DEV" => "false" }.freeze
- RELEASE_LOCKFILES_TARGET =
"release-lockfiles"- SUPPORTED_TARGETS =
["Gemfile.lock", "Appraisal.root.gemfile.lock", RELEASE_LOCKFILES_TARGET].freeze
- UNBUNDLED_ENV_KEYS =
(BundlerEnvGuard::RESET_ENV_KEYS + %w[ RUBYLIB RUBYOPT ]).freeze
Instance Attribute Summary collapse
-
#release_graph_contract ⇒ Object
readonly
Returns the value of attribute release_graph_contract.
Class Method Summary collapse
- .checksum_entries_from_source(lockfile_source) ⇒ Object
- .gem_specs_from_source(lockfile_source) ⇒ Object
- .local_path_remote?(remote) ⇒ Boolean
- .local_path_remote_lines_from_source(lockfile_source) ⇒ Object
Instance Method Summary collapse
- #active_local_path_env?(name) ⇒ Boolean
- #allowed_local_path?(path) ⇒ Boolean
-
#appraisal_normalization_env ⇒ Object
Appraisal generation normally uses the release-normalized environment.
-
#bundled_with_checksum_mismatch?(path) ⇒ Boolean
A release reset updates both
BUNDLED WITHand CHECKSUMS. - #bundled_with_version(path) ⇒ Object
- #bundler_command_prefix(env) ⇒ Object
- #canonical_path(path) ⇒ Object
- #diagnostics(path, strict: false) ⇒ Object
- #disabled_local_path_env ⇒ Object
- #disallowed_local_path_remote_lines(path) ⇒ Object
- #display_path(path) ⇒ Object
- #dynamic_local_path_env ⇒ Object
- #empty_registry_checksums(path) ⇒ Object
- #gemfile_for_lockfile(path) ⇒ Object
- #has_any_sha_checksum?(path) ⇒ Boolean
- #has_local_path_remote?(path, strict: false) ⇒ Boolean
-
#initialize(root:, command_runner:) ⇒ LockfileReset
constructor
A new instance of LockfileReset.
- #local_path_env_value?(value) ⇒ Boolean
- #local_path_remote_at(path, line_number) ⇒ Object
- #local_path_remote_lines(path) ⇒ Object
- #lockfile_path_for(target) ⇒ Object
- #lockfile_paths ⇒ Object
- #lockfile_paths_for(target) ⇒ Object
- #lockfile_platforms(path) ⇒ Object
- #non_registry_source_gems(path) ⇒ Object
- #normalization_env ⇒ Object
- #normalization_needed?(path, strict: false) ⇒ Boolean
- #path_dependency_gems(path) ⇒ Object
- #path_source_gems(path) ⇒ Object
- #release_lockfiles_target?(target) ⇒ Boolean
-
#release_normalization_env ⇒ Object
The release graph, not ambient development ENV, decides which local selectors remain active while Bundler normalizes a release lockfile.
- #release_platforms_for(paths) ⇒ Object
- #reset(target, skip_changelog_dependency: false) ⇒ Object
- #reset_command(path:, gemfile:, full_update: false, platforms: nil, skip_changelog_dependency: false, update_bundler: false, isolated_gem_home: nil, isolated_gem_path: nil, strict: false) ⇒ Object
- #reset_lockfile!(path, full_update: false, platforms: nil, skip_changelog_dependency: false, update_bundler: false, strict: false) ⇒ Object
- #reset_platforms(path) ⇒ Object
- #reset_update_gems(path) ⇒ Object
- #template_local_environment? ⇒ Boolean
- #unreleased_workspace_registry_specs(path) ⇒ Object
Constructor Details
#initialize(root:, command_runner:) ⇒ LockfileReset
Returns a new instance of LockfileReset.
118 119 120 121 122 123 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 118 def initialize(root:, command_runner:) @root = root @command_runner = command_runner @release_platforms = {} @release_graph_contract = ReleaseGraphContract.from_environment(root: root) end |
Instance Attribute Details
#release_graph_contract ⇒ Object (readonly)
Returns the value of attribute release_graph_contract.
406 407 408 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 406 def release_graph_contract @release_graph_contract end |
Class Method Details
.checksum_entries_from_source(lockfile_source) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 58 def checksum_entries_from_source(lockfile_source) in_checksums = false entries = {} lockfile_source.each_line do |line| stripped = line.chomp if stripped == "CHECKSUMS" in_checksums = true next end next unless in_checksums break if !stripped.empty? && stripped == stripped.upcase && !stripped.start_with?(" ") next unless stripped.start_with?(" ") parsed = parse_lockfile_spec_line(stripped) entries[[parsed.fetch(:name), parsed.fetch(:version)]] = parsed.fetch(:suffix) if parsed end in_checksums ? entries : nil end |
.gem_specs_from_source(lockfile_source) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 77 def gem_specs_from_source(lockfile_source) in_gem = false in_specs = false specs = [] lockfile_source.each_line do |line| stripped = line.chomp if stripped == "GEM" in_gem = true in_specs = false next end next unless in_gem break if !stripped.empty? && stripped == stripped.upcase && !stripped.start_with?(" ") if stripped == " specs:" in_specs = true next end next unless in_specs next unless line.start_with?(" ") && !line.start_with?(" ") parsed = parse_lockfile_spec_line(stripped) specs << [parsed.fetch(:name), parsed.fetch(:version)] if parsed end specs.uniq end |
.local_path_remote?(remote) ⇒ Boolean
52 53 54 55 56 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 52 def local_path_remote?(remote) return true if remote.start_with?("/", "./", "../", ".\\", "..\\", "\\\\") remote.length >= 3 && remote[1] == ":" && ["/", "\\"].include?(remote[2]) end |
.local_path_remote_lines_from_source(lockfile_source) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 34 def local_path_remote_lines_from_source(lockfile_source) in_path = false lockfile_source.each_line.with_index(1).filter_map do |line, index| stripped = line.strip if stripped.match?(/\A[A-Z][A-Z ]*\z/) in_path = stripped == "PATH" next end next unless in_path next unless stripped.start_with?("remote:") remote = stripped["remote:".length, stripped.length].strip next if remote == "." next unless local_path_remote?(remote) index end end |
Instance Method Details
#active_local_path_env?(name) ⇒ Boolean
393 394 395 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 393 def active_local_path_env?(name) local_path_env_value?(ENV[name]) end |
#allowed_local_path?(path) ⇒ Boolean
418 419 420 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 418 def allowed_local_path?(path) release_graph_contract.allowed_path?(path) end |
#appraisal_normalization_env ⇒ Object
Appraisal generation normally uses the release-normalized environment. During family templating it instead needs the caller's deliberately selected local graph so generated Appraisal Gemfiles can resolve unpublished sibling dependencies.
362 363 364 365 366 367 368 369 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 362 def appraisal_normalization_env env = normalization_env return env unless template_local_environment? env.reject do |name, _value| name == "K_JEM_TEMPLATING" || active_local_path_env?(name) end end |
#bundled_with_checksum_mismatch?(path) ⇒ Boolean
A release reset updates both BUNDLED WITH and CHECKSUMS. When a
nested tool leaked its Bundler into a member lockfile, a later cleanup
can otherwise replace only the checksum entry and leave an impossible
lockfile behind. Only flag a mismatch when the lockfile already tracks
Bundler in CHECKSUMS, preserving older lockfiles that lack that entry.
489 490 491 492 493 494 495 496 497 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 489 def bundled_with_checksum_mismatch?(path) version = bundled_with_version(path) return false if version.empty? checksums = self.class.checksum_entries_from_source(File.read(path)) return false unless checksums&.keys&.any? { |name, _checksum_version| name == "bundler" } !checksums.key?(["bundler", version]) end |
#bundled_with_version(path) ⇒ Object
499 500 501 502 503 504 505 506 507 508 509 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 499 def bundled_with_version(path) lines = File.readlines(path) marker = lines.index { |line| line.strip == "BUNDLED WITH" } return "" unless marker lines[marker.succ..-1].each do |line| version = line.strip return version unless version.empty? end "" end |
#bundler_command_prefix(env) ⇒ Object
229 230 231 232 233 234 235 236 237 238 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 229 def bundler_command_prefix(env) command = +"env" UNBUNDLED_ENV_KEYS.each do |key| command << " -u #{key}" end env.each do |key, value| command << " #{key}=#{Shellwords.escape(value)}" end command end |
#canonical_path(path) ⇒ Object
422 423 424 425 426 427 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 422 def canonical_path(path) = File.(path, root) File.realpath() rescue Errno::ENOENT end |
#diagnostics(path, strict: false) ⇒ Object
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 283 def diagnostics(path, strict: false) diagnostics = [] disallowed_local_path_remote_lines(path).each do |line_number| diagnostics << "#{display_path(path)} has local path remote at line #{line_number}" end empty_registry_checksums(path).each do |name, version, line_number| diagnostics << "#{display_path(path)} CHECKSUMS has no sha256 for #{name} #{version} at line #{line_number}" end unreleased_workspace_registry_specs(path).each do |name, version, line_number| diagnostics << "#{display_path(path)} locks local workspace gem #{name} #{version} as a registry gem, but that version is not resolvable from the configured gem source at line #{line_number}" end if bundled_with_checksum_mismatch?(path) diagnostics.push("#{display_path(path)} BUNDLED WITH #{bundled_with_version(path)} has no matching Bundler checksum") end diagnostics end |
#disabled_local_path_env ⇒ Object
354 355 356 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 354 def disabled_local_path_env DEFAULT_DISABLED_ENV.merge(dynamic_local_path_env) end |
#disallowed_local_path_remote_lines(path) ⇒ Object
408 409 410 411 412 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 408 def disallowed_local_path_remote_lines(path) local_path_remote_lines(path).reject do |line_number| allowed_local_path?(local_path_remote_at(path, line_number)) end end |
#display_path(path) ⇒ Object
531 532 533 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 531 def display_path(path) Kettle::Dev.display_path(path) end |
#dynamic_local_path_env ⇒ Object
371 372 373 374 375 376 377 378 379 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 371 def dynamic_local_path_env ENV.each_with_object({}) do |(key, value), env| next unless key.end_with?("_DEV", "_LOCAL") next unless local_path_env_value?(value) next if release_graph_contract.selector_env.key?(key) env[key] = "false" end end |
#empty_registry_checksums(path) ⇒ Object
429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 429 def empty_registry_checksums(path) non_registry_gems = non_registry_source_gems(path) | path_dependency_gems(path) in_checksums = false entries = File.readlines(path).filter_map.with_index(1) do |line, index| stripped = line.strip if stripped == "CHECKSUMS" in_checksums = true next end next unless in_checksums next if stripped.empty? next if stripped == "BUNDLED WITH" match = stripped.match(/\A([A-Za-z0-9_.-]+) \(([^)]+)\)(?:\s+(sha256=.*))?\z/) next unless match name = match[1] checksum = match[3].to_s next unless checksum.empty? next if non_registry_gems.include?(name) [name, match[2], index] end return [] unless has_any_sha_checksum?(path) entries end |
#gemfile_for_lockfile(path) ⇒ Object
337 338 339 340 341 342 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 337 def gemfile_for_lockfile(path) basename = File.basename(path) return File.join(root, "Gemfile") if basename == "Gemfile.lock" path.delete_suffix(".lock") end |
#has_any_sha_checksum?(path) ⇒ Boolean
470 471 472 473 474 475 476 477 478 479 480 481 482 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 470 def has_any_sha_checksum?(path) in_checksums = false File.readlines(path).any? do |line| stripped = line.strip if stripped == "CHECKSUMS" in_checksums = true next false end next false unless in_checksums stripped.include?("sha256=") end end |
#has_local_path_remote?(path, strict: false) ⇒ Boolean
397 398 399 400 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 397 def has_local_path_remote?(path, strict: false) paths = disallowed_local_path_remote_lines(path) !paths.empty? end |
#local_path_env_value?(value) ⇒ Boolean
381 382 383 384 385 386 387 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 381 def local_path_env_value?(value) text = value.to_s.strip return false if text.empty? || text.casecmp("false").zero? return true if text.start_with?("/", "./", "../", "~") text.include?(File::SEPARATOR) end |
#local_path_remote_at(path, line_number) ⇒ Object
414 415 416 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 414 def local_path_remote_at(path, line_number) File.readlines(path)[line_number - 1].to_s.split("remote:", 2).last.to_s.strip end |
#local_path_remote_lines(path) ⇒ Object
402 403 404 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 402 def local_path_remote_lines(path) self.class.local_path_remote_lines_from_source(File.read(path)) end |
#lockfile_path_for(target) ⇒ Object
308 309 310 311 312 313 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 308 def lockfile_path_for(target) paths = lockfile_paths_for(target) raise Error, "reset target #{target.inspect} resolves to multiple lockfiles; use lockfile_paths_for" if paths.length != 1 paths.first end |
#lockfile_paths ⇒ Object
300 301 302 303 304 305 306 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 300 def lockfile_paths candidates = [ File.join(root, "Gemfile.lock"), File.join(root, "Appraisal.root.gemfile.lock") ] candidates.select { |path| File.file?(path) }.sort end |
#lockfile_paths_for(target) ⇒ Object
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 315 def lockfile_paths_for(target) normalized = target.to_s.strip raise Error, "reset requires TARGET" if normalized.empty? if release_lockfiles_target?(normalized) paths = lockfile_paths raise Error, "no release lockfiles found" if paths.empty? return paths end supported = SUPPORTED_TARGETS.reject { |candidate| candidate == RELEASE_LOCKFILES_TARGET } match = supported.find { |candidate| candidate.casecmp(normalized).zero? } unless match raise Error, "reset target #{normalized.inspect} is not supported; supported targets: #{SUPPORTED_TARGETS.join(", ")}" end [File.join(root, match)] end |
#lockfile_platforms(path) ⇒ Object
252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 252 def lockfile_platforms(path) in_platforms = false File.readlines(path).filter_map do |line| stripped = line.strip if stripped.match?(/\A[A-Z][A-Z ]*\z/) in_platforms = stripped == "PLATFORMS" next end next unless in_platforms next if stripped.empty? stripped end end |
#non_registry_source_gems(path) ⇒ Object
518 519 520 521 522 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 518 def non_registry_source_gems(path) lockfile_parser(path).specs.each_with_object(Set.new) do |spec, gems| gems << spec.name unless registry_source?(spec.source) end end |
#normalization_env ⇒ Object
344 345 346 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 344 def normalization_env disabled_local_path_env end |
#normalization_needed?(path, strict: false) ⇒ Boolean
276 277 278 279 280 281 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 276 def normalization_needed?(path, strict: false) has_local_path_remote?(path, strict: strict) || !empty_registry_checksums(path).empty? || !unreleased_workspace_registry_specs(path).empty? || bundled_with_checksum_mismatch?(path) end |
#path_dependency_gems(path) ⇒ Object
524 525 526 527 528 529 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 524 def path_dependency_gems(path) lockfile_parser(path).dependencies.each_value.each_with_object(Set.new) do |dependency, gems| source = dependency.source gems << dependency.name if path_source?(source) && !self_path_source?(source) end end |
#path_source_gems(path) ⇒ Object
511 512 513 514 515 516 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 511 def path_source_gems(path) lockfile_parser(path).specs.each_with_object(Set.new) do |spec, gems| source = spec.source gems << spec.name if path_source?(source) && !self_path_source?(source) end end |
#release_lockfiles_target?(target) ⇒ Boolean
333 334 335 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 333 def release_lockfiles_target?(target) target.to_s.strip.casecmp(RELEASE_LOCKFILES_TARGET).zero? end |
#release_normalization_env ⇒ Object
The release graph, not ambient development ENV, decides which local selectors remain active while Bundler normalizes a release lockfile.
350 351 352 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 350 def release_normalization_env disabled_local_path_env.merge(release_graph_contract.normalization_environment) end |
#release_platforms_for(paths) ⇒ Object
246 247 248 249 250 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 246 def release_platforms_for(paths) paths.each_with_object({}) do |path, platforms| platforms[path] = (@release_platforms[path] ||= reset_platforms(path)) end end |
#reset(target, skip_changelog_dependency: false) ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 125 def reset(target, skip_changelog_dependency: false) BundlerEnvGuard.warn_unexpected_env! paths = lockfile_paths_for(target) release_lockfiles = release_lockfiles_target?(target) # The selected graph governs both tracked release locks and disposable # release-task locks. Registry contracts reject every PATH source; # CI-resident monorepo contracts retain only declared contained paths. force_full_update = release_lockfiles && ( release_graph_contract.registry_only? || paths.any? { |path| normalization_needed?(path, strict: true) } ) platforms = release_platforms_for(paths) if force_full_update uninstall_unreleased_local_gems(paths) if force_full_update paths.each do |path| if force_full_update || normalization_needed?(path, strict: release_lockfiles) reset_lockfile!( path, full_update: force_full_update, platforms: platforms&.fetch(path), skip_changelog_dependency: skip_changelog_dependency, update_bundler: force_full_update, strict: release_lockfiles ) end end if force_full_update && uninstall_unreleased_local_gems(paths) paths.each do |path| reset_lockfile!( path, full_update: true, platforms: platforms.fetch(path), skip_changelog_dependency: skip_changelog_dependency, update_bundler: true, strict: release_lockfiles ) end end diagnostics = paths.flat_map { |path| diagnostics(path, strict: release_lockfiles) } raise Error, (target, diagnostics) unless diagnostics.empty? paths end |
#reset_command(path:, gemfile:, full_update: false, platforms: nil, skip_changelog_dependency: false, update_bundler: false, isolated_gem_home: nil, isolated_gem_path: nil, strict: false) ⇒ Object
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 194 def reset_command(path:, gemfile:, full_update: false, platforms: nil, skip_changelog_dependency: false, update_bundler: false, isolated_gem_home: nil, isolated_gem_path: nil, strict: false) update_gems = (full_update || has_local_path_remote?(path, strict: strict)) ? [] : reset_update_gems(path) platforms ||= reset_platforms(path) removed_platforms = full_update ? [] : lockfile_platforms(path) - platforms env = (strict ? release_normalization_env : normalization_env).merge( "BUNDLE_GEMFILE" => gemfile, "BUNDLE_LOCKFILE" => path ) env["KETTLE_DEV_SKIP_CHANGELOG_DEPENDENCY"] = "true" if skip_changelog_dependency if isolated_gem_home env["GEM_HOME"] = isolated_gem_home env["GEM_PATH"] = isolated_gem_path || isolated_gem_home end command_prefix = bundler_command_prefix(env) command = +"#{command_prefix} bundle lock" # Bundler accepts each platform option once followed by a list. Repeating # either option silently keeps only the final occurrence with Bundler 4. command << " --remove-platform #{removed_platforms.sort.map { |platform| Shellwords.escape(platform) }.join(" ")}" unless removed_platforms.empty? command << " --add-platform #{platforms.map { |platform| Shellwords.escape(platform) }.join(" ")}" unless platforms.empty? command << " --update" command << " #{update_gems.map { |gem_name| Shellwords.escape(gem_name) }.join(" ")}" unless update_gems.empty? command << " --add-checksums" unless update_bundler return command unless update_bundler # `bundle lock --bundler` accepts a requirement and retains a locked # prerelease that satisfies it. `bundle update --bundler=VERSION` # records the exact Bundler that is executing the reset instead. # Finish with `bundle lock --add-checksums`, since `bundle update` # does not support that option. bundler_version = Shellwords.escape(Bundler::VERSION) command << " && #{command_prefix} bundle update --bundler=#{bundler_version}" command << " && #{command_prefix} bundle lock --add-checksums" command end |
#reset_lockfile!(path, full_update: false, platforms: nil, skip_changelog_dependency: false, update_bundler: false, strict: false) ⇒ Object
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 167 def reset_lockfile!(path, full_update: false, platforms: nil, skip_changelog_dependency: false, update_bundler: false, strict: false) gemfile = gemfile_for_lockfile(path) unless gemfile && File.file?(gemfile) warn("Cannot reset #{display_path(path)} because its Gemfile was not found.") return end with_isolated_gem_paths do |gem_home| install_gemfile_bootstrap_gems!(gemfile: gemfile, lockfile: path, gem_home: gem_home) command = reset_command( path: path, gemfile: gemfile, full_update: full_update, platforms: platforms, skip_changelog_dependency: skip_changelog_dependency, update_bundler: update_bundler, isolated_gem_home: gem_home, strict: strict ) if full_update || has_local_path_remote?(path, strict: strict) rebuild_lockfile(path) { command_runner.call(command) } else command_runner.call(command) end end end |
#reset_platforms(path) ⇒ Object
240 241 242 243 244 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 240 def reset_platforms(path) platforms = lockfile_platforms(path) platforms = [Gem::Platform.local.to_s] if platforms.empty? platforms.reject(&:empty?).sort end |
#reset_update_gems(path) ⇒ Object
267 268 269 270 271 272 273 274 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 267 def reset_update_gems(path) ( path_source_gems(path).to_a | path_dependency_gems(path).to_a | empty_registry_checksums(path).map(&:first) | unreleased_workspace_registry_specs(path).map(&:first) ).uniq.sort end |
#template_local_environment? ⇒ Boolean
389 390 391 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 389 def template_local_environment? %w[1 true yes on].include?(ENV.fetch("K_JEM_TEMPLATING", "").to_s.strip.downcase) end |
#unreleased_workspace_registry_specs(path) ⇒ Object
457 458 459 460 461 462 463 464 465 466 467 468 |
# File 'lib/kettle/dev/lockfile_reset.rb', line 457 def unreleased_workspace_registry_specs(path) local_names = local_workspace_gem_names return [] if local_names.empty? source_urls = registry_source_urls(path) registry_specs_with_lines(path).filter_map do |name, version, line_number| next unless local_names.include?(name) next if gem_source_version_available?(name, version, source_urls) [name, version, line_number] end end |