Module: Everywhere::Paths

Defined in:
lib/everywhere/paths.rb

Overview

Filesystem locations the CLI resolves relative to the gem itself, so every dev/build/release work in any project the gem is installed into.

Class Method Summary collapse

Class Method Details

.android_dirObject

Absolute path to the Android template, or nil when it isn't there. Unlike #ios_dir, nil is the NORMAL state until the template lands — callers must read it as "Android isn't buildable in this release yet", not as a corrupt install. settings.gradle.kts is the marker because it's the one file every Gradle project must have at its root.



70
71
72
# File 'lib/everywhere/paths.rb', line 70

def android_dir
  bundled_android_dir if File.exist?(File.join(bundled_android_dir, "settings.gradle.kts"))
end

.android_dir!Object

Like #android_dir but aborts with a helpful message when the template is missing. The --template-dir hint covers dev on a modified template.



76
77
78
79
# File 'lib/everywhere/paths.rb', line 76

def android_dir!
  android_dir or UI.die!("couldn't find the bundled Android template at #{bundled_android_dir}; " \
                         "reinstall ruby_everywhere or pass --template-dir")
end

.android_fonts_dirObject

Where the Material Symbols icon font is cached after its one-time fetch. The font is ~10 MB, so it's fetched on first Android build instead of riding along in a 229 KB gem that most users never build Android with.



125
126
127
# File 'lib/everywhere/paths.rb', line 125

def android_fonts_dir
  File.join(cache_dir, "android-fonts")
end

.android_gradle_homeObject

GRADLE_USER_HOME for shell builds. Redirected here so the multi-GB Gradle distribution, the Android Gradle Plugin and the Hotwire artifacts are downloaded once and stay warm across every app — and never land inside the installed gem. Same trick as cargo_target_dir.



118
119
120
# File 'lib/everywhere/paths.rb', line 118

def android_gradle_home
  File.join(cache_dir, "android-gradle")
end

.android_work_dir(application_id) ⇒ Object

The stamped copy of the Android template for one app, keyed by applicationId. Persistent for the same reasons ios_work_dir is: Gradle's incremental state is path-sensitive, and the stamped project opens in Android Studio unmodified.



110
111
112
# File 'lib/everywhere/paths.rb', line 110

def android_work_dir(application_id)
  File.join(cache_dir, "android", application_id)
end

.app_bundle_dirObject

Where a build runner installs the APP's gems (BUNDLE_PATH), so CI can cache them across builds of the same app. Local builds never use this — dev machines keep their own bundler setup; the runner opts in by setting EVERY_BUNDLE_PATH (see Commands::Build#bundle_env).



141
142
143
# File 'lib/everywhere/paths.rb', line 141

def app_bundle_dir
  File.join(cache_dir, "bundle")
end

.bundled_android_dirObject

The Hotwire Native Android shell template bundled inside the gem: support/mobile/android/ holds a frozen Gradle project (wrapper committed) the CLI stamps per-app — everywhere.properties + assets + res, never a build script. Same freeze contract the iOS template has.



61
62
63
# File 'lib/everywhere/paths.rb', line 61

def bundled_android_dir
  File.join(gem_root, "support", "mobile", "android")
end

.bundled_ios_dirObject

The Hotwire Native iOS shell template bundled inside the gem: support/mobile/ios/ holds a frozen Xcode project the CLI stamps per-app (xcconfig + everywhere.json + AppIcon — never the pbxproj). The mobile/ parent leaves room for support/mobile/android later.



40
41
42
# File 'lib/everywhere/paths.rb', line 40

def bundled_ios_dir
  File.join(gem_root, "support", "mobile", "ios")
end

.bundled_shell_dirObject

The generic Tauri shell bundled inside the gem: support/shell/ holds the src-tauri app and the splash/ dir it serves. This is the CANONICAL copy of the shell — external consumers (e.g. the build-runner repo) resolve it via every shell-dir. The CLI uses it unless the caller passes --shell-dir.



19
20
21
# File 'lib/everywhere/paths.rb', line 19

def bundled_shell_dir
  File.join(gem_root, "support", "shell", "src-tauri")
end

.cache_dirObject

Per-user cache dir. Keeps heavy build state out of the gem and the app.



82
83
84
# File 'lib/everywhere/paths.rb', line 82

def cache_dir
  File.expand_path(ENV["RUBYEVERYWHERE_HOME"] || "~/.rubyeverywhere")
end

.cargo_target_dirObject

Where cargo writes the shell's build output (CARGO_TARGET_DIR). Redirected here so cargo never dumps a multi-GB target/ into the installed gem, and so the shell compiles warm across projects — the shell source is identical for everyone, so one shared target dir is safe to reuse.



133
134
135
# File 'lib/everywhere/paths.rb', line 133

def cargo_target_dir
  File.join(cache_dir, "shell-target")
end

.gem_rootObject

The gem's own root — the dir holding lib/, exe/, support/. Correct whether the code runs from a git checkout or an installed gem.



11
12
13
# File 'lib/everywhere/paths.rb', line 11

def gem_root
  File.expand_path("../..", __dir__)
end

.ios_derived_data_dirObject

Where xcodebuild writes DerivedData for iOS shell builds. Shared across apps like cargo_target_dir — safe because the product is always App.app; worst case a mismatch is a cache miss, never a wrong artifact.



96
97
98
# File 'lib/everywhere/paths.rb', line 96

def ios_derived_data_dir
  File.join(cache_dir, "ios-derived-data")
end

.ios_dirObject

Absolute path to the iOS template, or nil if the bundled copy is missing (a corrupt/partial install).



46
47
48
# File 'lib/everywhere/paths.rb', line 46

def ios_dir
  bundled_ios_dir if File.exist?(File.join(bundled_ios_dir, "App.xcodeproj", "project.pbxproj"))
end

.ios_dir!Object

Like #ios_dir but aborts with a helpful message when the template is missing. The --template-dir hint covers dev on a modified template.



52
53
54
55
# File 'lib/everywhere/paths.rb', line 52

def ios_dir!
  ios_dir or UI.die!("couldn't find the bundled iOS template at #{bundled_ios_dir}; " \
                     "reinstall ruby_everywhere or pass --template-dir")
end

.ios_packages_dirObject

Where SPM clones the shell's package dependencies (hotwire-native-ios), so resolution is warm/offline after the first build.



102
103
104
# File 'lib/everywhere/paths.rb', line 102

def ios_packages_dir
  File.join(cache_dir, "ios-packages")
end

.ios_work_dir(bundle_id) ⇒ Object

The stamped copy of the iOS template for one app. Persistent (not a tmpdir) on purpose: a stable project path keeps Xcode's incremental state valid across builds, and users can open the stamped project in Xcode.



89
90
91
# File 'lib/everywhere/paths.rb', line 89

def ios_work_dir(bundle_id)
  File.join(cache_dir, "ios", bundle_id)
end

.shell_dirObject

Absolute path to the shell's src-tauri directory, or nil if the bundled copy is missing (a corrupt/partial install).



25
26
27
# File 'lib/everywhere/paths.rb', line 25

def shell_dir
  bundled_shell_dir if File.exist?(File.join(bundled_shell_dir, "tauri.conf.json"))
end

.shell_dir!Object

Like #shell_dir but aborts with a helpful message when the shell is missing. The --shell-dir hint covers dev on a modified shell checkout.



31
32
33
34
# File 'lib/everywhere/paths.rb', line 31

def shell_dir!
  shell_dir or UI.die!("couldn't find the bundled shell at #{bundled_shell_dir}; " \
                       "reinstall ruby_everywhere or pass --shell-dir")
end