ruby_everywhere 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 75b09aedaa84953cf39a5b6bc7e793f660998f297d5c7cc74ed453fef68172f3
4
- data.tar.gz: f1970350eaaedaf2fed2fd6123a25c152f196019256d5c2ff848a0a262f589c7
3
+ metadata.gz: 9bbeb5f84c4ec19197b0943357aab3392040876afe678f504f717acb22201d18
4
+ data.tar.gz: c48f81139c0aac8763b0c4fd9d04ace837e9131676a151d8d05fe964219ef79e
5
5
  SHA512:
6
- metadata.gz: 3f611fb7632f07a4931b659166ad6c1e0e773b7fa979b38c66f109cb0c22ace4c9710bd977e112d40bceee6efdd358fe5283262d7218f60e36f267e4456e6f5f
7
- data.tar.gz: '08def4faa79e14355864dd66369a8cfb06884b062186234d96478c9cbe3edd9957f14e46319bd2276f5927728ccea0ce442ae6d216b2bc851cd059de815f84a3'
6
+ metadata.gz: 4d144af27b9eaaa9ea2c11c847b41956021ea92d94929d12764f80d1b06dbfa2b43d9fbc43b18e0697c782866a1f46b9a5c5229ed8287ce086aab4c86832d83a
7
+ data.tar.gz: ff6f45ab57847acd8897cf0548e3d6b076289f67524863067f1f581a48af5131b34c6da0a4ac82bcdde269c60aa9d809e93f15710395eeae49b61bc46d6fea67
@@ -6,6 +6,7 @@ require "tmpdir"
6
6
  require "shellwords"
7
7
  require_relative "../shellout"
8
8
  require_relative "../png"
9
+ require_relative "../paths"
9
10
 
10
11
  module Everywhere
11
12
  module Commands
@@ -111,7 +112,7 @@ module Everywhere
111
112
  # Rails binary (as "app-server") + Info.plist + icon. An .app bundle is
112
113
  # just a directory layout, so we build it by hand — no tauri-cli needed.
113
114
  def bundle_app(server_binary, app_name, shell_dir, config, dist_dir: nil)
114
- shell_dir ||= find_shell_dir
115
+ shell_dir ||= Everywhere::Paths.shell_dir!
115
116
  dist_dir ||= File.dirname(server_binary)
116
117
 
117
118
  icon_source = config.icon
@@ -137,17 +138,18 @@ module Everywhere
137
138
  end
138
139
 
139
140
  UI.step("building shell #{UI.dim("(cargo release)")}")
141
+ target_dir = Everywhere::Paths.cargo_target_dir
140
142
  begin
141
- Shellout.run!({}, "cargo", "build", "--release", chdir: shell_dir)
143
+ Shellout.run!({ "CARGO_TARGET_DIR" => target_dir }, "cargo", "build", "--release", chdir: shell_dir)
142
144
  ensure
143
145
  if icon_source && File.exist?(placeholder_backup)
144
146
  FileUtils.mv(placeholder_backup, shell_icon)
145
147
  FileUtils.touch(File.join(shell_dir, "build.rs"))
146
148
  end
147
149
  end
148
- shell_bin = Dir[File.join(shell_dir, "target/release/*")]
150
+ shell_bin = Dir[File.join(target_dir, "release/*")]
149
151
  .find { |f| File.file?(f) && File.executable?(f) && !f.end_with?(".d") }
150
- UI.die!("couldn't find release shell binary in #{shell_dir}/target/release") unless shell_bin
152
+ UI.die!("couldn't find release shell binary in #{target_dir}/release") unless shell_bin
151
153
 
152
154
  app_dir = File.join(dist_dir, "#{app_name}.app")
153
155
  macos = File.join(app_dir, "Contents", "MacOS")
@@ -185,12 +187,6 @@ module Everywhere
185
187
  UI.success("app bundle: #{app_dir.sub("#{Dir.pwd}/", "")} #{UI.dim("(open it!)")}")
186
188
  end
187
189
 
188
- def find_shell_dir
189
- candidates = ["shell/src-tauri", "../shell/src-tauri", "src-tauri"]
190
- found = candidates.find { |c| File.exist?(File.join(c, "tauri.conf.json")) }
191
- found ? File.expand_path(found) : UI.die!("couldn't find the shell (looked in #{candidates.join(", ")}); pass --shell-dir")
192
- end
193
-
194
190
  # macOS ships everything needed to make an .icns from a png.
195
191
  def make_icns(png, resources_dir)
196
192
  return nil unless File.exist?(png)
@@ -3,6 +3,7 @@
3
3
  require "dry/cli"
4
4
  require "socket"
5
5
  require_relative "../shellout"
6
+ require_relative "../paths"
6
7
 
7
8
  module Everywhere
8
9
  module Commands
@@ -18,7 +19,7 @@ module Everywhere
18
19
  def call(port: "3000", shell_dir: nil, **)
19
20
  framework = Framework.detect
20
21
  config = Everywhere::Config.load(framework.root)
21
- shell_dir ||= find_shell_dir
22
+ shell_dir ||= Everywhere::Paths.shell_dir!
22
23
 
23
24
  server_pid = nil
24
25
  if port_open?(port)
@@ -32,7 +33,8 @@ module Everywhere
32
33
 
33
34
  dev_url = "http://127.0.0.1:#{port}#{config.entry_path}"
34
35
  UI.step("opening desktop shell → #{UI.cyan(dev_url)}")
35
- Shellout.run!({ "NATIVE_DEV_URL" => dev_url, "NATIVE_CONFIG" => config.to_shell_json },
36
+ Shellout.run!({ "NATIVE_DEV_URL" => dev_url, "NATIVE_CONFIG" => config.to_shell_json,
37
+ "CARGO_TARGET_DIR" => Everywhere::Paths.cargo_target_dir },
36
38
  "cargo", "run", chdir: shell_dir)
37
39
  ensure
38
40
  if server_pid
@@ -43,12 +45,6 @@ module Everywhere
43
45
 
44
46
  private
45
47
 
46
- def find_shell_dir
47
- candidates = ["shell/src-tauri", "../shell/src-tauri", "src-tauri"]
48
- found = candidates.find { |c| File.exist?(File.join(c, "tauri.conf.json")) }
49
- found or UI.die!("couldn't find the shell (looked in #{candidates.join(", ")}); pass --shell-dir")
50
- end
51
-
52
48
  def port_open?(port)
53
49
  TCPSocket.new("127.0.0.1", Integer(port)).close
54
50
  true
@@ -3,6 +3,7 @@
3
3
  require "dry/cli"
4
4
  require_relative "../shellout"
5
5
  require_relative "../receipt"
6
+ require_relative "../paths"
6
7
  require_relative "build"
7
8
 
8
9
  module Everywhere
@@ -93,9 +94,7 @@ module Everywhere
93
94
  def resolve_shell_dir(given)
94
95
  return File.expand_path(given) if given
95
96
 
96
- ["shell/src-tauri", "../shell/src-tauri", "src-tauri"]
97
- .map { |c| File.expand_path(c) }
98
- .find { |c| File.exist?(File.join(c, "tauri.conf.json")) }
97
+ Everywhere::Paths.shell_dir
99
98
  end
100
99
 
101
100
  # Read the truth back off the bundle rather than trusting the script's log:
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Everywhere
4
+ # Filesystem locations the CLI resolves relative to the gem itself, so
5
+ # `every dev`/`build`/`release` work in any project the gem is installed into.
6
+ module Paths
7
+ module_function
8
+
9
+ # The gem's own root — the dir holding lib/, exe/, support/. Correct whether
10
+ # the code runs from a git checkout or an installed gem.
11
+ def gem_root
12
+ File.expand_path("../..", __dir__)
13
+ end
14
+
15
+ # The generic Tauri shell vendored inside the gem: support/shell/ holds the
16
+ # src-tauri app and the splash/ dir it serves. This is the shell the CLI
17
+ # uses unless the caller overrides it with --shell-dir.
18
+ def bundled_shell_dir
19
+ File.join(gem_root, "support", "shell", "src-tauri")
20
+ end
21
+
22
+ # Absolute path to the shell's src-tauri directory, or nil if the vendored
23
+ # copy is missing (a corrupt/partial install).
24
+ def shell_dir
25
+ bundled_shell_dir if File.exist?(File.join(bundled_shell_dir, "tauri.conf.json"))
26
+ end
27
+
28
+ # Like #shell_dir but aborts with a helpful message when the shell is
29
+ # missing. The --shell-dir hint covers monorepo dev pointed at build-runner.
30
+ def shell_dir!
31
+ shell_dir or UI.die!("couldn't find the bundled shell at #{bundled_shell_dir}; " \
32
+ "reinstall ruby_everywhere or pass --shell-dir")
33
+ end
34
+
35
+ # Per-user cache dir. Keeps heavy build state out of the gem and the app.
36
+ def cache_dir
37
+ File.expand_path(ENV["RUBYEVERYWHERE_HOME"] || "~/.rubyeverywhere")
38
+ end
39
+
40
+ # Where cargo writes the shell's build output (CARGO_TARGET_DIR). Redirected
41
+ # here so cargo never dumps a multi-GB target/ into the installed gem, and so
42
+ # the shell compiles warm across projects — the shell source is identical for
43
+ # everyone, so one shared target dir is safe to reuse.
44
+ def cargo_target_dir
45
+ File.join(cache_dir, "shell-target")
46
+ end
47
+ end
48
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Everywhere
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
5
5
 
6
6
  # Version of the vendored @rubyeverywhere/bridge JS this gem ships. Tracks
7
7
  # bridge/package.json — bump it whenever lib/everywhere/javascript/bridge.js is
@@ -0,0 +1,40 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Starting…</title>
6
+ <style>
7
+ :root { color-scheme: light dark; }
8
+ body {
9
+ margin: 0; height: 100vh; display: grid; place-items: center;
10
+ font-family: -apple-system, system-ui, sans-serif;
11
+ background: var(--bg, light-dark(#faf9f7, #1c1b1a));
12
+ color: light-dark(#333, #ddd);
13
+ }
14
+ .boot { text-align: center; }
15
+ .gem { font-size: 56px; animation: pulse 1.2s ease-in-out infinite; }
16
+ @keyframes pulse { 50% { opacity: 0.35; transform: scale(0.92); } }
17
+ h1 { margin: 12px 0 0; font-size: 17px; font-weight: 600; }
18
+ p { margin-top: 4px; font-size: 13px; opacity: 0.6; }
19
+ </style>
20
+ </head>
21
+ <body>
22
+ <div class="boot">
23
+ <div class="gem">💎</div>
24
+ <h1 id="name"></h1>
25
+ <p>Starting…</p>
26
+ </div>
27
+ <script>
28
+ // The shell injects window.__EVERYWHERE_CONFIG__ (from config/everywhere.yml)
29
+ // into every page, this splash included.
30
+ const cfg = window.__EVERYWHERE_CONFIG__ || {};
31
+ if (cfg.name) {
32
+ document.getElementById("name").textContent = cfg.name;
33
+ document.title = cfg.name;
34
+ }
35
+ const dark = matchMedia("(prefers-color-scheme: dark)").matches;
36
+ const bg = cfg.background_color && (dark ? cfg.background_color.dark : cfg.background_color.light);
37
+ if (bg) document.body.style.setProperty("--bg", bg);
38
+ </script>
39
+ </body>
40
+ </html>