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.



74
75
76
# File 'lib/everywhere/paths.rb', line 74

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.



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

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.



129
130
131
# File 'lib/everywhere/paths.rb', line 129

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.



122
123
124
# File 'lib/everywhere/paths.rb', line 122

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.



114
115
116
# File 'lib/everywhere/paths.rb', line 114

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).



192
193
194
# File 'lib/everywhere/paths.rb', line 192

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.



65
66
67
# File 'lib/everywhere/paths.rb', line 65

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

.bundled_desktop_dirObject

The generic Tauri shell bundled inside the gem: support/desktop/ holds the src-tauri app and the splash/ dir it serves, alongside support/mobile/ios and support/mobile/android. 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.

The directory is named for the platform; the reader keeps the "shell" wording because that's what the flag, the command and every caller call it.



23
24
25
# File 'lib/everywhere/paths.rb', line 23

def bundled_desktop_dir
  File.join(gem_root, "support", "desktop", "src-tauri")
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.



44
45
46
# File 'lib/everywhere/paths.rb', line 44

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

.cache_dirObject

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



86
87
88
# File 'lib/everywhere/paths.rb', line 86

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) for apps on the fast path — the ones that declare no native.desktop. Redirected here so cargo never dumps a multi-GB target/ into the installed gem, and so the shell compiles warm across projects: with no app Rust in it the shell source really is identical for everyone, so one shared target dir is safe to reuse. An app that declares extensions gets desktop_target_dir instead, because that premise stops holding the moment its crate graph differs.



184
185
186
# File 'lib/everywhere/paths.rb', line 184

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

.desktop_assets_dir(bundle_id) ⇒ Object

Where every dev stages native/desktop/assets for the running shell. A staged copy rather than the source tree on purpose: the packaged app reads ONE flat Resources/assets folder, and pointing dev at the nested source would quietly resolve assets/branding/logo.png in a build and not in dev. Staging runs the same DesktopAssets compiler both ways, so the two can't drift. Keyed by bundle id like the mobile work dirs.



173
174
175
# File 'lib/everywhere/paths.rb', line 173

def desktop_assets_dir(bundle_id)
  File.join(cache_dir, "desktop-assets", bundle_id)
end

.desktop_dev_app_dir(bundle_id) ⇒ Object

Where every dev keeps the throwaway .app wrapper it runs the shell inside. macOS reads the application name from CFBundleName, so a bare cargo run binary shows up as the crate name — "example-shell" — in the menu bar, the About/Hide/Quit items and the Dock. The wrapper exists only to carry an Info.plist; the binary inside it is a hard link to cargo's.



156
157
158
# File 'lib/everywhere/paths.rb', line 156

def desktop_dev_app_dir(bundle_id)
  File.join(cache_dir, "desktop-app", bundle_id)
end

.desktop_icon_dir(bundle_id) ⇒ Object

Where every dev stages the app's Dock icon for the running shell. The shaped master is derived from app.icon, so it's a build product, not the app's own file — it belongs in the cache next to the rest of them.



163
164
165
# File 'lib/everywhere/paths.rb', line 163

def desktop_icon_dir(bundle_id)
  File.join(cache_dir, "desktop-icon", bundle_id)
end

.desktop_target_dir(bundle_id) ⇒ Object

CARGO_TARGET_DIR for a stamped shell. Per-app rather than shared, because the whole point of stamping is that this app's crate graph differs from every other app's — pointing them at one target dir would make cargo rebuild the world on every alternating build.



147
148
149
# File 'lib/everywhere/paths.rb', line 147

def desktop_target_dir(bundle_id)
  File.join(cache_dir, "desktop-target", bundle_id)
end

.desktop_work_dir(bundle_id) ⇒ Object

The stamped copy of the Tauri shell for one app, keyed by bundle id. Only apps that declare native.desktop get one — everyone else compiles the gem's own copy, which is identical for them and stays warm across projects (see cargo_target_dir). Persistent for the same reason the mobile work dirs are: cargo's incremental state lives inside it, and a cold Tauri build is minutes where a warm one is seconds.



139
140
141
# File 'lib/everywhere/paths.rb', line 139

def desktop_work_dir(bundle_id)
  File.join(cache_dir, "desktop", bundle_id)
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.



100
101
102
# File 'lib/everywhere/paths.rb', line 100

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).



50
51
52
# File 'lib/everywhere/paths.rb', line 50

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.



56
57
58
59
# File 'lib/everywhere/paths.rb', line 56

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.



106
107
108
# File 'lib/everywhere/paths.rb', line 106

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.



93
94
95
# File 'lib/everywhere/paths.rb', line 93

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).



29
30
31
# File 'lib/everywhere/paths.rb', line 29

def shell_dir
  bundled_desktop_dir if File.exist?(File.join(bundled_desktop_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.



35
36
37
38
# File 'lib/everywhere/paths.rb', line 35

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