ruby_everywhere 0.1.5 → 0.1.6

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: e8f07eb6ae976f35ea7ccda33b87bfefd7c2d0ffd39c1b7aa1f7001bedbd482b
4
- data.tar.gz: b0b9afc49cdc99e731c5bc7a742f8a90c4a5c94d496749131fa37b403567f91c
3
+ metadata.gz: 0e9efcbd721dfa8ec5eb10adcbd9d96970feb860b9bfa20d3d6b761012bb8d1b
4
+ data.tar.gz: 66a196953da3501c430aa91318d02cc51fc42ff4ebfe294d33a58c44cf7d5333
5
5
  SHA512:
6
- metadata.gz: f13c6059ba2dae4dbe87c21a376265ae7cef7f84a890492897694dde101e9b94bc4990df82b6efc64f278e1ed35d3d921e8bfd7d5c131763cc79589d096d4211
7
- data.tar.gz: 741d54c87c703df48024662485d03edcc15546c20f3fbe6f6d52b2b3c6056658c8aff7f2e73eb558d7f31961aa1c65c686a656bfc5e9bf9c2d900a3c633057aa
6
+ metadata.gz: 0644e199416ba7568a78812a83ba97fda7b97a829bca821540ba03f355b5798b2e69765db1aa5bd498e0f537edff73d8cad34ba0ce855261338a1522421b60ef
7
+ data.tar.gz: 9fb95b8c424cbcc6c82148f4bab93fd07d243e5c2051a0b7b5b056a3ded8fc2a8f43f5e6730b3791edd53d249dde25e001ff2d5d729e4c6a216d44831448cb6b
@@ -4,11 +4,13 @@ require "dry/cli"
4
4
  require_relative "../everywhere"
5
5
  require_relative "framework"
6
6
  require_relative "commands/build"
7
+ require_relative "commands/clean"
7
8
  require_relative "commands/dev"
8
9
  require_relative "commands/icon"
9
10
  require_relative "commands/doctor"
10
11
  require_relative "commands/install"
11
12
  require_relative "commands/release"
13
+ require_relative "commands/shell_dir"
12
14
  require_relative "commands/platform/login"
13
15
  require_relative "commands/platform/logout"
14
16
  require_relative "commands/platform/auth_status"
@@ -34,8 +36,10 @@ module Everywhere
34
36
  register "install", Commands::Install
35
37
  register "dev", Commands::Dev
36
38
  register "build", Commands::Build
39
+ register "clean", Commands::Clean
37
40
  register "icon", Commands::Icon
38
41
  register "release", Commands::Release
42
+ register "shell-dir", Commands::ShellDir
39
43
 
40
44
  register "platform login", Commands::PlatformLogin
41
45
  register "platform logout", Commands::PlatformLogout
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dry/cli"
4
+ require "fileutils"
5
+
6
+ module Everywhere
7
+ module Commands
8
+ # Wipes the shared cargo build cache under ~/.rubyeverywhere (or
9
+ # $RUBYEVERYWHERE_HOME). Safe to run any time: only compiled shell output
10
+ # lives there, so the next `every dev`/`every build` just recompiles cold.
11
+ class Clean < Dry::CLI::Command
12
+ desc "Remove the cargo shell-build cache (~/.rubyeverywhere/shell-target)"
13
+
14
+ def call(**)
15
+ target = Everywhere::Paths.cargo_target_dir
16
+ return UI.step("nothing to clean #{UI.dim("(#{target} doesn't exist)")}") unless File.exist?(target)
17
+
18
+ size = human_size(dir_bytes(target))
19
+ FileUtils.rm_rf(target)
20
+ UI.success("removed #{target} (#{size} freed) — the next build recompiles the shell cold")
21
+ end
22
+
23
+ private
24
+
25
+ def dir_bytes(dir)
26
+ Dir.glob(File.join(dir, "**", "*"), File::FNM_DOTMATCH).sum do |f|
27
+ File.file?(f) ? File.size(f) : 0
28
+ end
29
+ end
30
+
31
+ def human_size(bytes)
32
+ return "#{bytes} B" if bytes < 1024
33
+
34
+ units = %w[KB MB GB TB]
35
+ exp = [(Math.log(bytes) / Math.log(1024)).floor, units.size].min
36
+ format("%.1f %s", bytes.to_f / (1024**exp), units[exp - 1])
37
+ end
38
+ end
39
+ end
40
+ end
@@ -7,7 +7,7 @@ module Everywhere
7
7
  module Commands
8
8
  # Check that this machine can build desktop apps.
9
9
  class Doctor < Dry::CLI::Command
10
- desc "Check the toolchain (tebako, rust, brew deps, Xcode 26 shims)"
10
+ desc "Check the toolchain (rbe-tebako, rust, brew deps)"
11
11
 
12
12
  def call(**)
13
13
  ok = true
@@ -15,23 +15,8 @@ module Everywhere
15
15
  ok &= check("cargo installed") { Shellout.run?("cargo --version > /dev/null 2>&1") }
16
16
  ok &= check("homebrew bison") { !`brew --prefix bison 2>/dev/null`.strip.empty? }
17
17
 
18
- if RUBY_PLATFORM.include?("darwin") && clang_major >= 21
19
- ok &= check("Xcode #{clang_major} CXX shim (~/.tebako-shims/clang++)") do
20
- File.executable?(File.expand_path("~/.tebako-shims/clang++"))
21
- end
22
- ok &= check("tebako force_ruby_platform patch") do
23
- helper = `gem contents rbe-tebako 2>/dev/null`.lines.map(&:strip).find { |l| l.end_with?("deploy_helper.rb") }
24
- helper.nil? || File.read(helper).include?(%(@force_ruby_platform = "true"
25
- @nokogiri_option = "--no-use-system-libraries"))
26
- end
27
- ok &= check("tebako rbconfig warnflags patch") do
28
- stash = Dir[File.expand_path("~/.tebako/deps/stash_*/lib/ruby/*/**/rbconfig.rb")]
29
- stash.empty? || stash.all? { |f| File.read(f).include?("default-const-init") }
30
- end
31
- end
32
-
33
18
  puts
34
- ok ? UI.success("ready to build") : UI.bad("fix the items above (see project docs / memory for recipes)")
19
+ ok ? UI.success("ready to build") : UI.bad("fix the items above (see https://rubyeverywhere.com/docs/diy/requirements)")
35
20
  exit(1) unless ok
36
21
  end
37
22
 
@@ -45,10 +30,6 @@ module Everywhere
45
30
  UI.bad(label)
46
31
  false
47
32
  end
48
-
49
- def clang_major
50
- @clang_major ||= `clang --version 2>/dev/null`[/version (\d+)/, 1].to_i
51
- end
52
33
  end
53
34
  end
54
35
  end
@@ -12,15 +12,17 @@ module Everywhere
12
12
  desc "Prepare this app for RubyEverywhere (boot stub, config/everywhere.yml, config tweaks)"
13
13
 
14
14
  option :root, default: ".", desc: "App root directory"
15
- option :path, default: nil, desc: "Use a local checkout of ruby_everywhere in the Gemfile (path:)"
15
+ option :local, type: :boolean, default: false, desc: "Configure local mode (compile & ship the app) instead of remote mode"
16
16
 
17
- def call(root: ".", path: nil, **)
17
+ def call(root: ".", local: false, **)
18
+ @mode = local ? "local" : "remote"
18
19
  @framework = Framework.detect(root)
19
20
  @root = @framework.root
20
21
  UI.step("#{UI.bold(@framework.name)} app at #{@root}")
22
+ UI.warn("local mode: only SQLite databases are supported") if local
21
23
 
22
24
  # Common to every framework.
23
- add_gem(path)
25
+ add_gem
24
26
  write_config
25
27
  write_boot_stub
26
28
 
@@ -86,13 +88,12 @@ module Everywhere
86
88
  made ? UI.ok(label) : UI.step("#{label} #{UI.dim("(already done, skipped)")}")
87
89
  end
88
90
 
89
- def add_gem(path)
91
+ def add_gem
90
92
  gemfile = app_file("Gemfile")
91
93
  contents = File.read(gemfile)
92
94
  return change("add ruby_everywhere to Gemfile", false) if contents.match?(/gem ["']ruby_everywhere["']/)
93
95
 
94
- line = path ? "gem \"ruby_everywhere\", path: #{path.inspect}" : "gem \"ruby_everywhere\""
95
- File.write(gemfile, "#{contents.chomp}\n\n# Desktop apps from this #{@framework.name.capitalize} app — https://rubyeverywhere.com\n#{line}\n")
96
+ File.write(gemfile, "#{contents.chomp}\n\n# Desktop apps from this #{@framework.name.capitalize} app https://rubyeverywhere.com\ngem \"ruby_everywhere\"\n")
96
97
  Shellout.run!({}, "bundle", "install", "--quiet", chdir: @root)
97
98
  change("add ruby_everywhere to Gemfile", true)
98
99
  end
@@ -112,15 +113,12 @@ module Everywhere
112
113
  # platform (and the macOS bundle id). Set once, never change it.
113
114
  bundle_id: com.example.#{slug}
114
115
  version: "0.1.0" # marketing version (CFBundleShortVersionString)
115
- mode: local # "local" (compile & ship the app) or "remote" (native shell around a deployed site)
116
+ mode: #{@mode.ljust(6)} # "local" (compile & ship the app) or "remote" (native shell around a deployed site)
116
117
  entry_path: / # initial url on app launch
117
118
  # icon: icon.png # PNG used to generate app icons (defaults to icon.png at the app root if present)
118
119
  # splash: splash.html # custom boot splash (HTML); window.__EVERYWHERE_CONFIG__ carries name/colors
119
120
 
120
- # Remote mode only — the deployed URL the native shell opens.
121
- # Set mode: remote above, then uncomment:
122
- # remote:
123
- # url: https://example.com
121
+ #{remote_section.chomp}
124
122
 
125
123
  appearance:
126
124
  # Colors take a hex string, or split by system theme:
@@ -171,6 +169,25 @@ module Everywhere
171
169
  change("create config/everywhere.yml", true)
172
170
  end
173
171
 
172
+ # Remote mode (the default) gets a live remote: block ready to point at the
173
+ # deployed site; local mode keeps it commented out for later.
174
+ def remote_section
175
+ if @mode == "remote"
176
+ <<~YAML
177
+ # Remote mode — the deployed URL the native shell opens.
178
+ remote:
179
+ url: "https://example.com"
180
+ YAML
181
+ else
182
+ <<~YAML
183
+ # Remote mode only — the deployed URL the native shell opens.
184
+ # Set mode: remote above, then uncomment:
185
+ # remote:
186
+ # url: "https://example.com"
187
+ YAML
188
+ end
189
+ end
190
+
174
191
  def write_boot_stub
175
192
  stub = app_file("native_boot.rb")
176
193
  return change("create native_boot.rb", false) if File.exist?(stub)
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dry/cli"
4
+
5
+ module Everywhere
6
+ module Commands
7
+ # Print the absolute path of the gem-bundled Tauri shell (src-tauri).
8
+ # Output is the bare path so external tooling can capture it — e.g. the
9
+ # build-runner workflows resolve the shell with `$(every shell-dir)`.
10
+ class ShellDir < Dry::CLI::Command
11
+ desc "Print the path of the bundled Tauri shell (src-tauri)"
12
+
13
+ def call(**)
14
+ puts Everywhere::Paths.shell_dir!
15
+ end
16
+ end
17
+ end
18
+ end
@@ -12,21 +12,22 @@ module Everywhere
12
12
  File.expand_path("../..", __dir__)
13
13
  end
14
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.
15
+ # The generic Tauri shell bundled inside the gem: support/shell/ holds the
16
+ # src-tauri app and the splash/ dir it serves. This is the CANONICAL copy of
17
+ # the shell — external consumers (e.g. the build-runner repo) resolve it via
18
+ # `every shell-dir`. The CLI uses it unless the caller passes --shell-dir.
18
19
  def bundled_shell_dir
19
20
  File.join(gem_root, "support", "shell", "src-tauri")
20
21
  end
21
22
 
22
- # Absolute path to the shell's src-tauri directory, or nil if the vendored
23
+ # Absolute path to the shell's src-tauri directory, or nil if the bundled
23
24
  # copy is missing (a corrupt/partial install).
24
25
  def shell_dir
25
26
  bundled_shell_dir if File.exist?(File.join(bundled_shell_dir, "tauri.conf.json"))
26
27
  end
27
28
 
28
29
  # 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
+ # missing. The --shell-dir hint covers dev on a modified shell checkout.
30
31
  def shell_dir!
31
32
  shell_dir or UI.die!("couldn't find the bundled shell at #{bundled_shell_dir}; " \
32
33
  "reinstall ruby_everywhere or pass --shell-dir")
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Everywhere
4
- VERSION = "0.1.5"
4
+ VERSION = "0.1.6"
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_everywhere
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrea Fomera
@@ -9,6 +9,20 @@ bindir: exe
9
9
  cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: base64
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '0.2'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '0.2'
12
26
  - !ruby/object:Gem::Dependency
13
27
  name: dry-cli
14
28
  requirement: !ruby/object:Gem::Requirement
@@ -53,6 +67,7 @@ files:
53
67
  - lib/everywhere/boot.rb
54
68
  - lib/everywhere/cli.rb
55
69
  - lib/everywhere/commands/build.rb
70
+ - lib/everywhere/commands/clean.rb
56
71
  - lib/everywhere/commands/dev.rb
57
72
  - lib/everywhere/commands/doctor.rb
58
73
  - lib/everywhere/commands/icon.rb
@@ -63,6 +78,7 @@ files:
63
78
  - lib/everywhere/commands/platform/logout.rb
64
79
  - lib/everywhere/commands/platform/runner.rb
65
80
  - lib/everywhere/commands/release.rb
81
+ - lib/everywhere/commands/shell_dir.rb
66
82
  - lib/everywhere/config.rb
67
83
  - lib/everywhere/database.rb
68
84
  - lib/everywhere/framework.rb