Class: Everywhere::Commands::PlatformBuild

Inherits:
Dry::CLI::Command
  • Object
show all
Defined in:
lib/everywhere/commands/platform/build.rb

Overview

every platform build — hosted build (Model B): snapshot the source, upload it straight to storage, submit a build for the configured targets, then tail logs and pull the finished artifacts. No local toolchain needed.

Instance Method Summary collapse

Instance Method Details

#call(root: ".", url: nil, target: nil, channel: "direct", ruby: nil, output: nil, wait: true, download: true) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/everywhere/commands/platform/build.rb', line 31

def call(root: ".", url: nil, target: nil, channel: "direct", ruby: nil, output: nil,
         wait: true, download: true, **)
  root_path = File.expand_path(root)
  config = Everywhere::Config.load(root_path)
  base = Everywhere::Platform::Client.base_url(url)
  creds = Everywhere::Platform::Credentials.load.for(base)
  UI.die!("not logged in to #{base} — run `every platform login`") unless creds

  client = Everywhere::Platform::Client.new(base, token: creds["token"])
  framework = config.remote? ? nil : Everywhere::Framework.detect(root_path)
  targets = resolve_targets(target, config)
  ruby ||= config.build_ruby || "4.0.6"

  Dir.mktmpdir("every-snapshot") do |tmp|
    signed_id = snapshot_and_upload(client, root_path, tmp)
    manifest = Everywhere::Receipt.new(
      root: root_path, config: config, framework: framework, ruby: ruby,
      target: targets.first, channel: channel
    ).manifest

    build = submit(client, targets, channel, signed_id, manifest)
    UI.success("submitted #{UI.bold(build["id"])} for #{targets.join(", ")}")

    return unless wait

    final = poll_and_tail(client, build["id"])
    report(client, final, output || File.join(root_path, "dist"), download)
  end
rescue Everywhere::Error => e
  UI.die!(e.message)
end