Class: Everywhere::Receipt
- Inherits:
-
Object
- Object
- Everywhere::Receipt
- Defined in:
- lib/everywhere/receipt.rb
Overview
Builds the machine-readable build receipt (release.json) — the same shape emitted by local, CI, and Platform builds. See platform/docs/build-engine.md §7.
Two layers:
* the *resolved manifest* — the deterministic build request (app,
framework, ruby, toolchain versions, source checksums, target,
permissions). Everything here is knowable BEFORE the build runs and
carries no volatile fields, so the same source + toolchain hashes
identically (manifest_checksum).
* the *artifact* record — filename, checksum, size, and the generic
`signing` block, layered on once a build has produced something.
Constant Summary collapse
- SCHEMA =
1
Instance Method Summary collapse
-
#initialize(root:, config:, framework:, ruby:, target:, channel:, shell_dir: nil, source_checksum: nil, lockfile_checksum: nil) ⇒ Receipt
constructor
source_checksum/lockfile_checksum are optional so a caller building one receipt per target hashes the tree ONCE and threads the digest through the rest — they describe the source, which is identical for every target.
-
#manifest ⇒ Object
The deterministic build request.
-
#manifest_checksum ⇒ Object
sha256 over the canonical (sorted-key) JSON of the manifest.
-
#to_h(artifact:, signing:, build_id: nil, logs_url: nil) ⇒ Object
The full receipt: manifest + artifact record.
- #write(path, **kwargs) ⇒ Object
Constructor Details
#initialize(root:, config:, framework:, ruby:, target:, channel:, shell_dir: nil, source_checksum: nil, lockfile_checksum: nil) ⇒ Receipt
source_checksum/lockfile_checksum are optional so a caller building one receipt per target hashes the tree ONCE and threads the digest through the rest — they describe the source, which is identical for every target.
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/everywhere/receipt.rb', line 29 def initialize(root:, config:, framework:, ruby:, target:, channel:, shell_dir: nil, source_checksum: nil, lockfile_checksum: nil) @root = File.(root) @config = config @framework = framework @ruby = ruby @target_str = target # bare "os-arch" — selects platforms: overrides @target = parse_target(target, channel) @shell_dir = shell_dir @source_checksum = source_checksum @lockfile_checksum = lockfile_checksum end |
Instance Method Details
#manifest ⇒ Object
The deterministic build request.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/everywhere/receipt.rb', line 43 def manifest { "app" => { "name" => @config.name(target: @target_str), "bundle_id" => @config.bundle_id(target: @target_str), "version" => @config.version(target: @target_str) }, "framework" => framework_info, "ruby" => @ruby, "versions" => versions, "source" => { "checksum" => source_checksum, "lockfile_checksum" => lockfile_checksum }, "target" => @target, "permissions" => @config., "mode" => @config.mode, "remote" => { "url" => @config.remote_url }.compact } end |
#manifest_checksum ⇒ Object
sha256 over the canonical (sorted-key) JSON of the manifest. Ties a receipt to the exact request that produced it.
66 67 68 |
# File 'lib/everywhere/receipt.rb', line 66 def manifest_checksum "sha256:#{Digest::SHA256.hexdigest(canonical_json(manifest))}" end |
#to_h(artifact:, signing:, build_id: nil, logs_url: nil) ⇒ Object
The full receipt: manifest + artifact record. signing is the generic
block from the spec — common fields + a platform-specific bag.
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/everywhere/receipt.rb', line 72 def to_h(artifact:, signing:, build_id: nil, logs_url: nil) { "schema" => SCHEMA, "build_id" => build_id, "manifest_checksum" => manifest_checksum }.merge(manifest).merge( "artifact" => artifact_record(artifact).merge("signing" => signing), "logs_url" => logs_url ) end |
#write(path, **kwargs) ⇒ Object
83 84 85 86 |
# File 'lib/everywhere/receipt.rb', line 83 def write(path, **kwargs) File.write(path, "#{JSON.pretty_generate(to_h(**kwargs))}\n") path end |