ruby_everywhere 0.1.12 → 0.1.14

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: 2b4e596b2b262da233f7afa1971c3e2e207e4e7f2416b52c30236892f233b490
4
- data.tar.gz: 6395de83ed4e1122c728689ed8f496b4c86178a90f4d917680f7a1913f65e2c3
3
+ metadata.gz: 43abb21e2044de5630a87ca49d653368af5d84c6186ec993fd4c1b2a588e31c8
4
+ data.tar.gz: cfb169771be7b208b230c6c9d7b0a63f7ed53061724d0008d5551409309e315f
5
5
  SHA512:
6
- metadata.gz: d741017d5a726cb2e13aa951fe495ae5bd90793b410fe614fc72b77550da1e6a6589647924d0d3f5ce84771d545b9eff2f144e77319b15d7c5b462b051246e68
7
- data.tar.gz: 8952e90b1206420b0aa23ad047c6ea4380dc850bc63b9e8ef389a12af9a690d88c0501d009c11c2f316994065bb87c19ef807d4a0408c78e2324bc2ba5235475
6
+ metadata.gz: b5086b64a57d5f010bea583175eb954881370c2d9cb304243249645ccd324a900df7b2748037cf2950894722ea85b9c1ae3ddf71617676c42b5ddb5c619b74cc
7
+ data.tar.gz: e87e280008d30d90a5a85446191673bd7bb2ada124a68a6578068b5f5f078f455461993fddfb5975e606144b029bd49c3fe71379361ee38c3b002769f9af6c19
@@ -50,9 +50,13 @@ module Everywhere
50
50
  return
51
51
  end
52
52
 
53
- framework = Framework.detect(root)
54
- output ||= File.join("dist", File.basename(framework.root))
55
- output_path = File.expand_path(output)
53
+ framework = Framework.detect(root_path)
54
+ # dist/ belongs to the APP, not to the shell's cwd: `every platform
55
+ # runner` invokes us with --root <snapshot> from its own working
56
+ # directory, and `every release` looks for the .app under <root>/dist.
57
+ # Resolving a relative default against Dir.pwd scattered the build
58
+ # products into the runner's checkout instead.
59
+ output_path = output ? File.expand_path(output) : File.join(root_path, "dist", File.basename(root_path))
56
60
  entry_path = File.join(framework.root, entry)
57
61
 
58
62
  unless File.exist?(entry_path)
@@ -62,22 +66,47 @@ module Everywhere
62
66
  UI.step("#{UI.bold(framework.name)} app at #{framework.root}")
63
67
 
64
68
  if skip_press
65
- UI.die!("--skip-press given but #{output} doesn't exist") unless File.exist?(output_path)
66
- UI.step("reusing pressed binary #{output}")
69
+ UI.die!("--skip-press given but #{rel(output_path, root_path)} doesn't exist") unless File.exist?(output_path)
70
+ UI.step("reusing pressed binary #{rel(output_path, root_path)}")
67
71
  else
68
72
  press!(framework, entry, ruby, output_path)
69
73
  end
70
74
 
71
75
  bundle_app(output_path, app_name, shell_dir, config, target: target) if RUBY_PLATFORM.include?("darwin")
72
76
 
73
- UI.success("built #{output} (#{(File.size(output_path) / 1024.0 / 1024.0).round}MB)")
77
+ UI.success("built #{rel(output_path, root_path)} (#{(File.size(output_path) / 1024.0 / 1024.0).round}MB)")
74
78
  end
75
79
 
76
80
  private
77
81
 
82
+ def rel(path, root_path) = UI.short_path(path.sub("#{root_path}/", "").sub("#{Dir.pwd}/", ""))
83
+
84
+ # The precompile step runs against the HOST Ruby — unlike tebako press,
85
+ # which installs the app's gems itself inside the packaged Ruby. A fresh
86
+ # machine (a hosted build runner, a brand-new checkout) has Gemfile.lock
87
+ # but none of the gems, so bin/rails would die with Bundler::GemNotFound.
88
+ def ensure_gems!(framework)
89
+ return if Shellout.run?(bundle_env, "bundle", "check", chdir: framework.root, quiet: true)
90
+
91
+ UI.step("installing gems #{UI.dim("(bundle install — first build on this machine)")}")
92
+ Shellout.run!(bundle_env, "bundle", "install", chdir: framework.root)
93
+ end
94
+
95
+ # EVERY_BUNDLE_PATH (set by `every platform runner`) redirects the app's
96
+ # gems to a stable per-user dir so CI can cache them across builds. It
97
+ # must be merged EXPLICITLY into each host-side bundler command:
98
+ # Shellout.unbundled strips inherited BUNDLE_* vars, so an inherited
99
+ # BUNDLE_PATH would never survive to the child process.
100
+ def bundle_env
101
+ path = ENV["EVERY_BUNDLE_PATH"]
102
+ path ? { "BUNDLE_PATH" => File.expand_path(path) } : {}
103
+ end
104
+
78
105
  def press!(framework, entry, ruby, output_path)
106
+ ensure_gems!(framework) if framework.precompile?
107
+
79
108
  UI.step("precompiling assets")
80
- Shellout.run!(framework.precompile_env, framework.precompile_command, chdir: framework.root)
109
+ Shellout.run!(framework.precompile_env.merge(bundle_env), framework.precompile_command, chdir: framework.root)
81
110
 
82
111
  out_dir = File.dirname(output_path)
83
112
  # Tebako packages the whole app root, so stale build products in an
@@ -108,7 +137,7 @@ module Everywhere
108
137
  # Leaving precompiled assets behind shadows dev-mode assets (new JS
109
138
  # wouldn't load in `every dev` until someone clobbers by hand).
110
139
  UI.step("cleaning up precompiled assets")
111
- Shellout.run!(framework.precompile_env, framework.cleanup_command, chdir: framework.root)
140
+ Shellout.run!(framework.precompile_env.merge(bundle_env), framework.cleanup_command, chdir: framework.root)
112
141
 
113
142
  surface_warnings(log)
114
143
  end
@@ -8,6 +8,7 @@ require "base64"
8
8
  require "json"
9
9
  require "open3"
10
10
  require_relative "../../ui"
11
+ require_relative "../../paths"
11
12
  require_relative "../../platform/client"
12
13
 
13
14
  module Everywhere
@@ -133,7 +134,12 @@ module Everywhere
133
134
  # The web UI renders ANSI, but `every release` runs here as a pipe (not a
134
135
  # TTY) so it would otherwise strip all color. Force it on — for our own
135
136
  # output and for cargo — so the hosted log looks like the local one.
136
- forced = { "CLICOLOR_FORCE" => "1", "CARGO_TERM_COLOR" => "always" }
137
+ #
138
+ # EVERY_BUNDLE_PATH sends the app's gems to a stable per-user dir
139
+ # (instead of the runner's own gem env) so CI can cache them across
140
+ # builds of the same app — the gem analogue of the shell-target cache.
141
+ forced = { "CLICOLOR_FORCE" => "1", "CARGO_TERM_COLOR" => "always",
142
+ "EVERY_BUNDLE_PATH" => Everywhere::Paths.app_bundle_dir }
137
143
  success = stream(forced.merge(signing_env), cmd)
138
144
 
139
145
  dist = File.join(src, "dist")
@@ -73,6 +73,10 @@ module Everywhere
73
73
  # Env each framework needs set before the app loads, beyond NATIVE_PACKAGED.
74
74
  def env_exports = {}
75
75
 
76
+ # Whether the build must run anything against the app's bundle on the HOST
77
+ # Ruby (asset precompile). Sinatra's no-op precompile opts out.
78
+ def precompile? = precompile_command != "true"
79
+
76
80
  def render_boot_stub(env, setup_line)
77
81
  exports = ({ "NATIVE_PACKAGED" => "1" }.merge(env))
78
82
  .map { |k, v| "ENV[#{k.inspect}] ||= #{v.inspect}" }.join("\n")
@@ -45,5 +45,13 @@ module Everywhere
45
45
  def cargo_target_dir
46
46
  File.join(cache_dir, "shell-target")
47
47
  end
48
+
49
+ # Where a build runner installs the APP's gems (BUNDLE_PATH), so CI can
50
+ # cache them across builds of the same app. Local builds never use this —
51
+ # dev machines keep their own bundler setup; the runner opts in by setting
52
+ # EVERY_BUNDLE_PATH (see Commands::Build#bundle_env).
53
+ def app_bundle_dir
54
+ File.join(cache_dir, "bundle")
55
+ end
48
56
  end
49
57
  end
@@ -17,8 +17,10 @@ module Everywhere
17
17
  UI.die!("command failed: #{cmd.join(" ")}") unless success
18
18
  end
19
19
 
20
- def run?(*cmd)
21
- unbundled { system(*cmd) }
20
+ def run?(*cmd, chdir: Dir.pwd, quiet: false)
21
+ opts = { chdir: chdir }
22
+ opts.update(out: File::NULL, err: File::NULL) if quiet
23
+ unbundled { system(*cmd, **opts) }
22
24
  end
23
25
 
24
26
  # Run a command and capture its combined stdout+stderr. Returns
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Everywhere
4
- VERSION = "0.1.12"
4
+ VERSION = "0.1.14"
5
5
 
6
6
  # Version of the @rubyeverywhere/bridge JS this gem ships. bridge/ in the
7
7
  # gem IS the npm package (served to Rails apps by Everywhere::Engine,
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.12
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrea Fomera