Class: Everywhere::Commands::Clean

Inherits:
Dry::CLI::Command
  • Object
show all
Defined in:
lib/everywhere/commands/clean.rb

Overview

Wipes the shared build caches under ~/.rubyeverywhere (or $RUBYEVERYWHERE_HOME): the cargo shell cache, the iOS DerivedData / SPM / stamped-project dirs, and the Android Gradle home / icon font / stamped projects. Safe to run any time: everything here is derived output, so the next every dev/every build rebuilds it — cold, and for Android that includes re-downloading Gradle and the Material icon font.

Instance Method Summary collapse

Instance Method Details

#callObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/everywhere/commands/clean.rb', line 17

def call(**)
  caches = [Everywhere::Paths.cargo_target_dir,
            Everywhere::Paths.ios_derived_data_dir,
            Everywhere::Paths.ios_packages_dir,
            File.join(Everywhere::Paths.cache_dir, "ios"),
            Everywhere::Paths.android_gradle_home,
            Everywhere::Paths.android_fonts_dir,
            File.join(Everywhere::Paths.cache_dir, "android")].select { |d| File.exist?(d) }
  return UI.step("nothing to clean #{UI.dim("(no build caches under #{Everywhere::Paths.cache_dir})")}") if caches.empty?

  freed = 0
  caches.each do |dir|
    bytes = dir_bytes(dir)
    freed += bytes
    FileUtils.rm_rf(dir)
    UI.ok("removed #{dir} #{UI.dim("(#{human_size(bytes)})")}")
  end
  UI.success("#{human_size(freed)} freed — the next build recompiles the shells cold")
end