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

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



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

def app_bundle_dir
  File.join(cache_dir, "bundle")
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.



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

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.



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

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.



72
73
74
# File 'lib/everywhere/paths.rb', line 72

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.



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

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.



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

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