ruby_wasm_ic_installer 0.1.1 → 0.2.0

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: d1849b979aebed885c999fc6ad80b725bc1ab7d0705a2d5e63dfe8b206984c20
4
- data.tar.gz: 354bcb251efdb106a40706cd5b9e67882069b81843ef4d260f54a1c9eae16de4
3
+ metadata.gz: 965561fd823f42be4c7d1f1bc9dd9e3702debac3408b4e88d93ea9ae261a013f
4
+ data.tar.gz: f6addc13d86f239af138d8a173b41bdef0368fffce09e841556f4151a0735d7a
5
5
  SHA512:
6
- metadata.gz: da04ace5eaf7a796d7f78e6115f1dc4a506185e8bd94e691afe25241b3218a119b366504094c6b076832bf057eaf43e377da2b0057ccdde19a71fbdb6f2818e6
7
- data.tar.gz: ca49f20707ad79e6643b12cad22f31b4b3c8bdc0a8a41454e3aeb934f64cd3c80f9fc07fafa22368822225ff265595e85120c0381f6d459a9db6ab0505f9fb04
6
+ metadata.gz: 399c18e33dae5bb39b1f8b2df206ff4452e57064bef102f175202fa6acb9a4115fd2e80681739febdc278cddd8f1051902d7b89cb31ef3aa44d1b6ae0261ed66
7
+ data.tar.gz: 29266aaadfc6bdbf74c92afcad732dde5e8aa22a07327dc0c704ad80057efa505ea5246b48b5601e3f64ab0940d4c82c5f52bca61e1ff64fe41093ae73019d7d
data/README.md CHANGED
@@ -28,9 +28,10 @@ own parser (it resolves nothing: the lock is yours) and, for each locked gem:
28
28
  - **refuses** it if it has a C extension, or is locked only for a native
29
29
  platform: a canister cannot load compiled code, so only pure Ruby can be
30
30
  installed;
31
- - **skips** it, saying so, if `ruby_wasm_ic_minimal` is in the lock and stands
32
- in for it (`stringio`, `strscan`, `date`), since the real ones are C
33
- extensions;
31
+ - **skips** it, saying so, if the target already has it: on `minimal`, when
32
+ `ruby_wasm_ic_minimal` is in the lock and stands in for it (`stringio`,
33
+ `strscan`, `date`); on `full`, the extensions it links (`stringio`,
34
+ `strscan`). The real ones are C extensions;
34
35
  - opens only its `require_paths` (normally `lib/`);
35
36
  - **rewrites magic comments** naming an alias of an encoding a `minimal`
36
37
  canister claims (`# encoding: binary` to `ascii-8bit`, `ascii` to
@@ -40,7 +41,9 @@ own parser (it resolves nothing: the lock is yours) and, for each locked gem:
40
41
  comment before any Ruby runs. It lists nine more names (the UTF-16 and
41
42
  UTF-32 family, UTF8-MAC, EUC-JP, Windows-31J) with no encoding behind them:
42
43
  a file whose comment names one would load as ASCII-8BIT, so it is refused
43
- too. Every rewrite is in the report.
44
+ too. Every rewrite is in the report. (This is `minimal`'s rule and is
45
+ applied to every target for now; a `full` canister has not needed an install
46
+ yet, so it is revisited then.)
44
47
 
45
48
  It asks the canister what it has (`installed`), and sends **only the gem
46
49
  versions it lacks**, packed into calls of up to 2,000,000 bytes (the IC's
@@ -83,22 +86,24 @@ ruby_wasm_ic_installer setup my_app [--yes | --check]
83
86
  `setup` makes three changes, each between marker comments
84
87
  (`# >>> ruby_wasm_ic_installer` … `# <<< ruby_wasm_ic_installer`):
85
88
 
86
- - in **`ic-interface.rb`**, the Installer's four Declarations and their types:
89
+ - in **`ic-interface.rb`**, the Installer's five Declarations and their types:
87
90
 
88
91
  ```ruby
89
92
  type :InstallFile, record(path: Text, body: Blob)
90
93
  type :InstallSetup, record(generation: Nat64, load_paths: Vec[Text])
91
94
  type :InstallCommit, record(gems: Vec[Text], setup: Opt[:InstallSetup])
92
95
  type :Installed, record(running: Opt[Nat64], pending: Opt[Nat64], gems: Vec[Text], partial: Vec[Text],
93
- load_paths: Vec[Text], running_paths: Vec[Text])
96
+ load_paths: Vec[Text], running_paths: Vec[Text], protocol: Nat64,
97
+ build: Opt[Text], release: Opt[Text], load_failures: Vec[Text])
94
98
  update :install_put, takes: [Vec[:InstallFile]], returns: Text
95
99
  update :install_commit, takes: [:InstallCommit], returns: Text
96
100
  update :install_remove, takes: [Text], returns: Text
101
+ query :install_verify, takes: [Vec[Text]], returns: Vec[Text]
97
102
  query :installed, takes: [], returns: :Installed
98
103
  ```
99
104
 
100
105
  - at the top of **`app.rb`** (after any shebang and magic comments), the
101
- `require` of the canister half, which defines those four methods and loads
106
+ `require` of the canister half, which defines those five methods and loads
102
107
  `/data/setup.rb` if there is one;
103
108
  - the canister half itself, copied to **`vendor/ruby_wasm_ic_installer/`**.
104
109
  It uses only core Ruby and ruby_wasm_builder's `IC`, and loads on `minimal`.
@@ -128,11 +133,73 @@ rescue LoadError
128
133
  end
129
134
  ```
130
135
 
136
+ ## The target: Build and Release
137
+
138
+ What a gem needs depends on the module the canister runs: its **Build**
139
+ (`minimal` or `full`) and ruby_wasm_builder **Release**. Declare it in
140
+ `.ruby_wasm_ic_installer.yml`, in the icp project root (or `--config PATH`):
141
+
142
+ ```yaml
143
+ build: full # minimal | full
144
+ release: 0.13.0
145
+ verify: [roda, ruby_wasm_ic_rack] # require names `verify` checks on the canister
146
+ ```
147
+
148
+ Every key is optional. The target is resolved, highest first, from `--build`
149
+ and `--release`, this file, what the canister reports (`IC::BUILD` and
150
+ `IC::RELEASE`, once the builder sets them), and last the assumption `minimal`,
151
+ which prints a line saying so. The file is the desired state and the canister
152
+ the observed one; the Installer keeps no state of its own, so a move from one
153
+ Build or Release to another shows as a **transition** line until the canister
154
+ has been upgraded.
155
+
156
+ On the target, `install` and `status`:
157
+
158
+ - on `full`, skip `stringio` and `strscan` as linked, and **refuse**
159
+ `ruby_wasm_ic_minimal` by name ("remove it from the Gemfile: `full` links
160
+ the real extensions") before anything is sent;
161
+ - refuse a gem version known to refuse the target (`ruby_wasm_ic_minimal`
162
+ before 0.1.5 on `minimal` 0.13.0 or later). `install` checks the lock;
163
+ `status` checks what the pending and running setups would load.
164
+ - refuse any other compiled gem: add it to ruby_wasm_builder, not here.
165
+
166
+ The tables behind this are in this gem (`Rules`); a new row is a release.
167
+
168
+ **Gems first, then the module.** A new setup file takes effect at the next
169
+ upgrade, **whatever module that upgrade brings**: the canister half boots
170
+ `/data/setup.rb` as it finds it. So to move a canister to a new Release,
171
+ `install` first (to the canister still running the old one), then upgrade to
172
+ the new module. This is guaranteed and has a spec.
173
+
174
+ ## Verifying a boot
175
+
176
+ The canister half wraps `require` and records each error that escapes an
177
+ outermost `require` from an installed gem (name, version, the error's first
178
+ line; at most 50 a boot). A gem's own `rescue LoadError` around an optional
179
+ require is nested, so it is not recorded; an Application that rescues
180
+ `LoadError` itself for a deliberately optional gem will see it listed.
181
+ `status` prints them as `load failure:`.
182
+
183
+ `verify` goes further: it calls `install_verify` (a query, so it changes
184
+ nothing) with the names in `verify:`, which `require`s each on the canister
185
+ and answers `ok` or the error. It takes names, never code. `verify-init`
186
+ writes a first list: the require name each locked gem's gemspec points at
187
+ (`autorequire`, else a file named for the gem under its `require_paths`),
188
+ from the gemspec's file list alone, with no gem code run; it names the gems it
189
+ found nothing for.
190
+
191
+ `install --upgrade` sends, runs `icp deploy <canister> --mode upgrade`, and
192
+ verifies, exiting 1 if anything failed to load. A CI job can filter on
193
+ `Gemfile*` and pass `--upgrade` only then. `icp deploy` builds and installs
194
+ the project's module as well, so the new module lands in the same step.
195
+
131
196
  ## Commands
132
197
 
133
198
  ```
134
- ruby_wasm_ic_installer install CANISTER [--lock Gemfile.lock] [--dry-run] [icp options]
199
+ ruby_wasm_ic_installer install CANISTER [--lock Gemfile.lock] [--dry-run] [--upgrade] [icp options]
135
200
  ruby_wasm_ic_installer status CANISTER [icp options]
201
+ ruby_wasm_ic_installer verify CANISTER [icp options]
202
+ ruby_wasm_ic_installer verify-init [--lock Gemfile.lock] [--yes]
136
203
  ruby_wasm_ic_installer prune CANISTER [--dry-run] [icp options]
137
204
  ruby_wasm_ic_installer setup APP_DIR [--yes | --check]
138
205
  ```
@@ -141,15 +208,20 @@ ruby_wasm_ic_installer setup APP_DIR [--yes | --check]
141
208
  options pass through to `icp canister call`: `-e/--environment`,
142
209
  `-n/--network`, `--identity`, `--project-root` (icp's
143
210
  `--project-root-override`) and `--icp PATH`. Other options: `--cache DIR`,
144
- `--budget BYTES`.
211
+ `--budget BYTES`, `--build`, `--release`, `--config PATH`.
212
+
213
+ An icp-cli error (a project that will not load, say, or a missing file icp
214
+ reads) is printed as icp-cli's own message under a header saying so, so it does
215
+ not look like an Installer fault.
145
216
 
146
217
  Every call goes through `icp canister call <canister> <method> --args-file
147
218
  <file> --args-format bin -o hex`, so it needs [icp-cli](https://cli.internetcomputer.org)
148
219
  1.6 or later. The gem encodes and decodes its few Candid types itself; it
149
220
  holds no keys and picks no network.
150
221
 
151
- Exit status: 0 done, 1 refused (by the canister, or by `setup`'s questions),
152
- 2 a usage error or a gem it cannot install.
222
+ Exit status: 0 done, 1 refused (by the canister, or by `setup`'s questions) or
223
+ a verify that failed, 2 a usage error, a gem it cannot install, or a gem the
224
+ target refuses.
153
225
 
154
226
  ## Limits
155
227
 
@@ -162,6 +234,11 @@ Exit status: 0 done, 1 refused (by the canister, or by `setup`'s questions),
162
234
  canister claims (ruby_wasm_builder's ADR-0053; the other nine names it lists
163
235
  were probed on 0.8.0 and are names only, W30). A Build that links encodings
164
236
  is a release of this gem.
237
+ - **Two halves, one version.** The canister half is vendored into the
238
+ Application, so it can be older than this gem. `installed` reports a
239
+ `protocol` number (2 from 0.2.0); against protocol 1 the Installer still
240
+ installs, says the canister half reports no Build and no load failures, and
241
+ `verify` asks you to re-run `setup`.
165
242
  - The canister keeps no content hash of what it holds yet: `installed` reports
166
243
  versions, not digests.
167
244
 
@@ -21,7 +21,7 @@ module RubyWasmIcInstaller
21
21
  CLOSE = "# <<< ruby_wasm_ic_installer"
22
22
  NOTE = " (written by `ruby_wasm_ic_installer setup`; edit outside these lines)"
23
23
  BLOCK = /^#{Regexp.escape(OPEN)}.*?^#{Regexp.escape(CLOSE)}\n?/m
24
- NAMES = %w[install_put install_commit install_remove installed].freeze
24
+ NAMES = %w[install_put install_commit install_remove install_verify installed].freeze
25
25
  TYPES = %w[InstallFile InstallSetup InstallCommit Installed].freeze
26
26
  VENDOR = File.join("vendor", "ruby_wasm_ic_installer")
27
27
  CANISTER_SOURCE = File.expand_path("canister.rb", __dir__)
@@ -32,10 +32,12 @@ module RubyWasmIcInstaller
32
32
  type :InstallSetup, record(generation: Nat64, load_paths: Vec[Text])
33
33
  type :InstallCommit, record(gems: Vec[Text], setup: Opt[:InstallSetup])
34
34
  type :Installed, record(running: Opt[Nat64], pending: Opt[Nat64], gems: Vec[Text], partial: Vec[Text],
35
- load_paths: Vec[Text], running_paths: Vec[Text])
35
+ load_paths: Vec[Text], running_paths: Vec[Text], protocol: Nat64,
36
+ build: Opt[Text], release: Opt[Text], load_failures: Vec[Text])
36
37
  update :install_put, takes: [Vec[:InstallFile]], returns: Text
37
38
  update :install_commit, takes: [:InstallCommit], returns: Text
38
39
  update :install_remove, takes: [Text], returns: Text
40
+ query :install_verify, takes: [Vec[Text]], returns: Vec[Text]
39
41
  query :installed, takes: [], returns: :Installed
40
42
  #{CLOSE}
41
43
  RUBY
@@ -94,6 +94,9 @@ module RubyWasmIcInstaller
94
94
  # (text)
95
95
  def text_arg(s) = MAGIC + leb(0) + leb(1) + sleb(TEXT) + text_value(s)
96
96
 
97
+ # (vec text)
98
+ def texts_arg(list) = MAGIC + types("\x6d".b + sleb(TEXT)) + leb(1) + sleb(0) + texts_value(list)
99
+
97
100
  # ()
98
101
  def empty_args = MAGIC + leb(0) + leb(0)
99
102
 
@@ -19,6 +19,21 @@
19
19
  # pending one names it. Every method is for the canister's controllers only.
20
20
  module RubyWasmIcInstaller
21
21
  module Canister
22
+ # The version of this half's API, reported by `installed`. 1 had no
23
+ # protocol field; 2 adds protocol, build, release, load_failures and
24
+ # install_verify.
25
+ PROTOCOL = 2
26
+ MAX_FAILURES = 50
27
+
28
+ # Prepended to Object so every `require` passes through. It records an
29
+ # error that escapes an outermost `require` and comes from an installed
30
+ # gem, then raises it unchanged.
31
+ module RequireRecorder
32
+ private
33
+
34
+ def require(name) = RubyWasmIcInstaller::Canister.record_require { super }
35
+ end
36
+
22
37
  # A gem version's directory: a gem name, a dash, a version.
23
38
  NAME_VERSION = /\A[A-Za-z0-9][A-Za-z0-9_.\-]*-[0-9][A-Za-z0-9_.\-]*\z/
24
39
  SETUP_HEAD = "# generated by ruby_wasm_ic_installer: do not edit, it is rewritten by install_commit\n"
@@ -39,6 +54,9 @@ module RubyWasmIcInstaller
39
54
  def boot!
40
55
  @running_generation = nil
41
56
  @running_paths = []
57
+ @failures = []
58
+ @depth = 0
59
+ Object.prepend(RequireRecorder) unless Object.ancestors.include?(RequireRecorder)
42
60
  load(setup_file) if File.file?(setup_file)
43
61
  self
44
62
  end
@@ -54,6 +72,34 @@ module RubyWasmIcInstaller
54
72
  nil
55
73
  end
56
74
 
75
+ # Runs a `require`; if it raises out of the outermost call, notes which
76
+ # installed gem it came from. A gem's own `rescue LoadError` around an
77
+ # optional require is nested, so it is not recorded.
78
+ def record_require
79
+ outer = (@depth ||= 0).zero?
80
+ @depth += 1
81
+ yield
82
+ rescue ScriptError, StandardError => e
83
+ record_failure(e) if outer && !@verifying
84
+ raise
85
+ ensure
86
+ @depth -= 1
87
+ end
88
+
89
+ # install_verify: a query. Requires each name and says how it went.
90
+ def verify(names)
91
+ controller!
92
+ @verifying = true
93
+ names.map do |n|
94
+ require n
95
+ "ok #{n}"
96
+ rescue ScriptError, StandardError => e
97
+ "FAIL #{n}: #{describe(e)}"
98
+ end
99
+ ensure
100
+ @verifying = false
101
+ end
102
+
57
103
  # install_put: files into .partial/<name-version>/, each path
58
104
  # "<name-version>/<path inside the gem>".
59
105
  def put(files)
@@ -114,7 +160,11 @@ module RubyWasmIcInstaller
114
160
  gems: list(gems_dir),
115
161
  partial: list(partial_dir),
116
162
  load_paths: pending_paths,
117
- running_paths: (@running_paths || []).map { _1.delete_prefix("#{gems_dir}/") }
163
+ running_paths: (@running_paths || []).map { _1.delete_prefix("#{gems_dir}/") },
164
+ protocol: PROTOCOL,
165
+ build: builder_const(:BUILD),
166
+ release: builder_const(:RELEASE),
167
+ load_failures: (@failures || []).dup
118
168
  }
119
169
  end
120
170
 
@@ -127,6 +177,34 @@ module RubyWasmIcInstaller
127
177
 
128
178
  private
129
179
 
180
+ # What the builder says about this module, once it says it (IC::BUILD,
181
+ # IC::RELEASE); nil until then.
182
+ def builder_const(name)
183
+ return nil unless defined?(IC) && IC.const_defined?(name)
184
+
185
+ IC.const_get(name).to_s
186
+ end
187
+
188
+ def describe(error) = "#{error.class}: #{error.message.lines.first.to_s.strip}"
189
+
190
+ def record_failure(error)
191
+ return if (@failures ||= []).size >= MAX_FAILURES
192
+
193
+ name = gem_of(error)
194
+ @failures << "#{name}: #{describe(error)}" if name
195
+ end
196
+
197
+ # The installed gem an error came from: the first backtrace frame inside
198
+ # the gems directory, or, for a SyntaxError (whose backtrace is the
199
+ # requiring line), the path its message names.
200
+ def gem_of(error)
201
+ (error.backtrace_locations || []).each do |loc|
202
+ path = loc.absolute_path || loc.path
203
+ return path.delete_prefix("#{gems_dir}/").split("/").first if path&.start_with?("#{gems_dir}/")
204
+ end
205
+ error.message[%r{#{Regexp.escape(gems_dir)}/([^/]+)/}, 1]
206
+ end
207
+
130
208
  def controller!
131
209
  IC.caller.controller? || IC.refuse("only a controller may install code")
132
210
  end
@@ -203,6 +281,7 @@ end
203
281
  def install_put(files) = RubyWasmIcInstaller::Canister.put(files)
204
282
  def install_commit(request) = RubyWasmIcInstaller::Canister.commit(request)
205
283
  def install_remove(name_version) = RubyWasmIcInstaller::Canister.remove(name_version)
284
+ def install_verify(names) = RubyWasmIcInstaller::Canister.verify(names)
206
285
  def installed = RubyWasmIcInstaller::Canister.installed
207
286
 
208
287
  RubyWasmIcInstaller::Canister.boot! if defined?(IC::DATA_DIR)
@@ -7,14 +7,22 @@ module RubyWasmIcInstaller
7
7
  class CLI
8
8
  USAGE = <<~TEXT
9
9
  Usage:
10
- ruby_wasm_ic_installer install CANISTER [--lock Gemfile.lock] [--dry-run] [icp options]
10
+ ruby_wasm_ic_installer install CANISTER [--lock Gemfile.lock] [--dry-run] [--upgrade] [icp options]
11
11
  ruby_wasm_ic_installer status CANISTER [icp options]
12
+ ruby_wasm_ic_installer verify CANISTER [icp options]
13
+ ruby_wasm_ic_installer verify-init [--lock Gemfile.lock] [--yes]
12
14
  ruby_wasm_ic_installer prune CANISTER [--dry-run] [icp options]
13
15
  ruby_wasm_ic_installer setup APP_DIR [--yes | --check]
14
16
 
15
17
  install sends the lock's pure-Ruby gems the canister lacks, then the setup
16
- file that loads them; it takes effect at the next upgrade
17
- status what the canister has installed, running and pending
18
+ file that loads them; it takes effect at the next upgrade, or at
19
+ once with --upgrade (icp deploy --mode upgrade, then verify)
20
+ status what the canister has installed, running and pending; the target
21
+ Build and Release; gems the target refuses; the boot's load failures
22
+ verify requires the names in the config's verify: list on the canister,
23
+ and reports the boot's load failures; exits 1 if any failed
24
+ verify-init writes the front-door require names of the lock's gems into
25
+ the config's verify: list, for you to edit
18
26
  prune removes every version neither the running nor the pending setup names
19
27
  setup wires the Installer's methods into an Application (ic-interface.rb,
20
28
  app.rb, vendor/ruby_wasm_ic_installer/)
@@ -26,6 +34,10 @@ module RubyWasmIcInstaller
26
34
  Other options:
27
35
  --cache DIR where fetched .gem files are kept
28
36
  (default: ~/.cache/ruby_wasm_ic_installer)
37
+ --build minimal|full the target Build (else the config, else the canister's report,
38
+ else minimal)
39
+ --release VERSION the target Release, likewise
40
+ --config PATH the config file (default: #{Config::FILE} in the project root)
29
41
  --budget BYTES the largest batch, in bytes of Candid (default: #{Plan::DEFAULT_BUDGET})
30
42
  -h, --help, --version
31
43
  TEXT
@@ -45,6 +57,7 @@ module RubyWasmIcInstaller
45
57
  # The exit status.
46
58
  def run(argv)
47
59
  opts = { lock: "Gemfile.lock", icp: "icp", icp_args: [], dry_run: false, yes: false, check: false,
60
+ upgrade: false, flags: {}, config: nil, project_root: nil,
48
61
  cache: File.join(Dir.home, ".cache", "ruby_wasm_ic_installer"), budget: Plan::DEFAULT_BUDGET }
49
62
  args = parser(opts).parse(argv)
50
63
  return 0 if opts[:done]
@@ -52,15 +65,22 @@ module RubyWasmIcInstaller
52
65
  command = args.shift
53
66
  target = args.shift
54
67
  raise Error, "#{USAGE}\nunexpected: #{args.join(' ')}" unless args.empty?
55
- raise Error, USAGE if command.nil? || target.nil?
68
+ raise Error, USAGE if command.nil? || (target.nil? && command != "verify-init")
56
69
 
57
70
  case command
58
71
  when "setup" then setup(target, opts)
59
- when "install" then report(installer(target, opts).install(Lockfile.read(opts[:lock]), dry_run: opts[:dry_run]))
72
+ when "install" then report(installer(target, opts).install(Lockfile.read(opts[:lock]), dry_run: opts[:dry_run],
73
+ upgrade: opts[:upgrade]))
60
74
  when "status" then report(installer(target, opts).status)
75
+ when "verify" then report(installer(target, opts).verify)
76
+ when "verify-init" then verify_init(opts)
61
77
  when "prune" then report(installer(target, opts).prune(dry_run: opts[:dry_run]))
62
78
  else raise Error, "#{USAGE}\nunknown command: #{command}"
63
79
  end
80
+ rescue Installer::VerifyFailed => e
81
+ e.lines.each { @out.puts(_1) }
82
+ @err.puts(e.message)
83
+ 1
64
84
  rescue Error, OptionParser::ParseError => e
65
85
  @err.puts(e.message)
66
86
  e.is_a?(Runner::CallError) || e.is_a?(AppSetup::Aborted) ? 1 : 2
@@ -74,6 +94,10 @@ module RubyWasmIcInstaller
74
94
  o.on("--lock PATH") { opts[:lock] = _1 }
75
95
  o.on("--dry-run") { opts[:dry_run] = true }
76
96
  o.on("--yes") { opts[:yes] = true }
97
+ o.on("--upgrade") { opts[:upgrade] = true }
98
+ o.on("--build BUILD") { opts[:flags][:build] = Config.check_build(_1, "--build") }
99
+ o.on("--release VERSION") { opts[:flags][:release] = Config.check_release(_1, "--release") }
100
+ o.on("--config PATH") { opts[:config] = _1 }
77
101
  o.on("--check") { opts[:check] = true }
78
102
  o.on("--icp PATH") { opts[:icp] = _1 }
79
103
  o.on("--cache DIR") { opts[:cache] = _1 }
@@ -81,7 +105,10 @@ module RubyWasmIcInstaller
81
105
  o.on("-e", "--environment ENV") { opts[:icp_args] += ["-e", _1] }
82
106
  o.on("-n", "--network NETWORK") { opts[:icp_args] += ["-n", _1] }
83
107
  o.on("--identity NAME") { opts[:icp_args] += ["--identity", _1] }
84
- o.on("--project-root DIR") { opts[:icp_args] += ["--project-root-override", _1] }
108
+ o.on("--project-root DIR") do
109
+ opts[:icp_args] += ["--project-root-override", _1]
110
+ opts[:project_root] = _1
111
+ end
85
112
  o.on("-h", "--help") { @out.puts(USAGE) || opts[:done] = true }
86
113
  o.on("--version") { @out.puts(VERSION) || opts[:done] = true }
87
114
  end
@@ -89,7 +116,30 @@ module RubyWasmIcInstaller
89
116
 
90
117
  def installer(canister, opts)
91
118
  runner = @runner || Runner.new(canister: canister, icp: opts[:icp], icp_args: opts[:icp_args])
92
- Installer.new(runner: runner, gem_files: @gem_files || GemFiles.new(cache: opts[:cache]), budget: opts[:budget])
119
+ Installer.new(runner: runner, gem_files: @gem_files || GemFiles.new(cache: opts[:cache]), budget: opts[:budget],
120
+ config: config(opts), flags: opts[:flags])
121
+ end
122
+
123
+ def config_path(opts) = opts[:config] || Config.default_path(opts[:project_root])
124
+
125
+ def config(opts) = Config.read(config_path(opts))
126
+
127
+ # Writes the lock's gems' front-door names into the config's verify: list.
128
+ # It keeps the other keys but not comments, and does not overwrite a list
129
+ # that is already there without --yes.
130
+ def verify_init(opts)
131
+ path = config_path(opts)
132
+ found, unresolved = installer(nil, opts).entry_points(Lockfile.read(opts[:lock]))
133
+ data = File.file?(path) ? (YAML.safe_load_file(path) || {}) : {}
134
+ Config.new(data, path: path) # a malformed file stops here
135
+ if Array(data["verify"]).any? && !opts[:yes]
136
+ raise Error, "#{path} already has a verify: list; run again with --yes to replace it"
137
+ end
138
+
139
+ File.write(path, YAML.dump(data.merge("verify" => found)))
140
+ @out.puts("wrote #{path}: verify: #{found.join(', ')}")
141
+ unresolved.each { @out.puts("no front door found for #{_1}: add its require name by hand if the app needs it") }
142
+ 0
93
143
  end
94
144
 
95
145
  def setup(dir, opts)
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "yaml"
4
+
5
+ module RubyWasmIcInstaller
6
+ # The developer's declaration of what the canister is meant to run, read
7
+ # from `.ruby_wasm_ic_installer.yml` in the icp project (or --config):
8
+ #
9
+ # build: full # minimal | full
10
+ # release: 0.13.0 # the ruby_wasm_builder Release
11
+ # verify: [roda] # require names `verify` checks on the canister
12
+ #
13
+ # Every key is optional. The file is the desired state; the canister is the
14
+ # observed state; the Installer reconciles them and keeps no state of its own.
15
+ class Config
16
+ FILE = ".ruby_wasm_ic_installer.yml"
17
+ BUILDS = %w[minimal full].freeze
18
+ KEYS = %w[build release verify].freeze
19
+
20
+ attr_reader :build, :release, :verify, :path
21
+
22
+ def self.default_path(project_root) = File.join(project_root || ".", FILE)
23
+
24
+ def self.empty = new({}, path: nil)
25
+
26
+ # An absent file is an empty Config; a malformed one is an Error.
27
+ def self.read(path)
28
+ return empty unless File.file?(path)
29
+
30
+ data = YAML.safe_load_file(path) || {}
31
+ raise Error, "#{path} must be a YAML mapping" unless data.is_a?(Hash)
32
+
33
+ new(data, path: path)
34
+ rescue Psych::Exception => e
35
+ raise Error, "#{path} is not valid YAML: #{e.message}"
36
+ end
37
+
38
+ def initialize(data, path:)
39
+ @path = path
40
+ unknown = data.keys.map(&:to_s) - KEYS
41
+ raise Error, "#{path}: unknown key #{unknown.join(', ')} (known: #{KEYS.join(', ')})" unless unknown.empty?
42
+
43
+ @build = self.class.check_build(data["build"], path)
44
+ @release = self.class.check_release(data["release"], path)
45
+ @verify = check_verify(data["verify"])
46
+ end
47
+
48
+ def self.check_build(value, where)
49
+ return nil if value.nil?
50
+ return value.to_s if BUILDS.include?(value.to_s)
51
+
52
+ raise Error, "#{where}: build must be one of #{BUILDS.join(', ')}, not #{value.inspect}"
53
+ end
54
+
55
+ def self.check_release(value, where)
56
+ return nil if value.nil?
57
+ return value.to_s if ::Gem::Version.correct?(value.to_s)
58
+
59
+ raise Error, "#{where}: release must be a version such as 0.13.0, not #{value.inspect}"
60
+ end
61
+
62
+ private
63
+
64
+ def check_verify(value)
65
+ return [] if value.nil?
66
+ return value if value.is_a?(Array) && value.all?(String)
67
+
68
+ raise Error, "#{@path}: verify must be a list of require names"
69
+ end
70
+ end
71
+ end
@@ -51,6 +51,18 @@ module RubyWasmIcInstaller
51
51
  []
52
52
  end
53
53
 
54
+ # The require names that look like this gem's front door: its
55
+ # `autorequire` if it sets one, else the files under its require_paths
56
+ # named for the gem (`roda`, `net-http` as `net/http` or `net_http`). A
57
+ # scan of the gemspec's file list; no gem code runs.
58
+ def entry_points(locked)
59
+ spec = ::Gem::Package.new(fetch(locked)).spec
60
+ return [spec.autorequire] if spec.autorequire
61
+
62
+ names = [locked.name, locked.name.tr("-", "/"), locked.name.tr("-", "_")].uniq
63
+ names.select { |n| spec.require_paths.any? { |rp| spec.files.include?("#{rp}/#{n}.rb") } }
64
+ end
65
+
54
66
  private
55
67
 
56
68
  def fetch(locked)
@@ -90,7 +102,8 @@ module RubyWasmIcInstaller
90
102
  return if spec.extensions.empty?
91
103
 
92
104
  raise Refused, "#{locked.name_version} has a C extension (#{spec.extensions.join(', ')}): only pure-Ruby " \
93
- "gems can be installed into a canister, which cannot load compiled code"
105
+ "gems can be installed into a canister, which cannot load compiled code; a compiled gem has to " \
106
+ "be added to ruby_wasm_builder"
94
107
  end
95
108
 
96
109
  def read_files(locked, package, spec)
@@ -1,60 +1,96 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyWasmIcInstaller
4
- # The off-chain half's three acts against one canister, through a Runner:
4
+ # The off-chain half's acts against one canister, through a Runner:
5
5
  # `install` (the lock's gems the canister lacks, then the setup file),
6
- # `status` (what installed() says) and `prune` (every version neither the
7
- # running boot nor the pending setup names). Each returns the lines of its
8
- # report; nothing here prints.
6
+ # `status` (what installed() says), `verify` (require the config's names on
7
+ # the canister) and `prune` (every version neither the running boot nor the
8
+ # pending setup names). Each returns the lines of its report; nothing here
9
+ # prints.
10
+ #
11
+ # The decisions are made here, on the developer's machine, from the config
12
+ # (the desired state) and what the canister reports (the observed state);
13
+ # the canister only answers facts.
9
14
  class Installer
10
15
  MINIMAL = "ruby_wasm_ic_minimal"
16
+ REQUIRED = %i[running pending gems partial load_paths running_paths].freeze
17
+ # Fields a protocol-1 canister half does not have.
18
+ OPTIONAL = { protocol: 1, build: nil, release: nil, load_failures: [] }.freeze
11
19
 
12
- def initialize(runner:, gem_files:, budget: Plan::DEFAULT_BUDGET)
20
+ # The target would load a gem that refuses it, or the lock holds a
21
+ # compiled gem: nothing was sent.
22
+ class Refused < Error; end
23
+
24
+ # `verify` found failures; `lines` is the whole report.
25
+ class VerifyFailed < Error
26
+ attr_reader :lines
27
+
28
+ def initialize(lines)
29
+ @lines = lines
30
+ super("verification failed")
31
+ end
32
+ end
33
+
34
+ def initialize(runner:, gem_files:, budget: Plan::DEFAULT_BUDGET, config: Config.empty, flags: {})
13
35
  @runner = runner
14
36
  @gem_files = gem_files
15
37
  @budget = budget
38
+ @config = config
39
+ @flags = flags
16
40
  end
17
41
 
18
42
  def status
19
43
  i = installed
44
+ target = Target.resolve(flags: @flags, config: @config, info: i)
20
45
  [
21
46
  "running generation: #{i[:running] || 'none'}",
22
47
  "pending generation: #{i[:pending] || 'none'}#{pending_note(i)}",
23
48
  "installed: #{i[:gems].empty? ? 'none' : i[:gems].join(', ')}",
24
- *(i[:partial].empty? ? [] : ["half-sent (.partial): #{i[:partial].join(', ')}"])
49
+ *(i[:partial].empty? ? [] : ["half-sent (.partial): #{i[:partial].join(', ')}"]),
50
+ *canister_lines(i), target.describe, *transition_lines(i, target),
51
+ *refusal_lines(target, i), *failure_lines(i)
25
52
  ]
26
53
  end
27
54
 
28
- # `dry_run`: plan and report, call nothing that writes.
29
- def install(lockfile, dry_run: false)
30
- report = []
55
+ # `dry_run`: plan and report, call nothing that writes. `upgrade`: after
56
+ # sending, deploy the project as an upgrade and verify the boot.
57
+ def install(lockfile, dry_run: false, upgrade: false)
58
+ i = installed
59
+ target = Target.resolve(flags: @flags, config: @config, info: i)
60
+ report = [*canister_lines(i), target.describe, *transition_lines(i, target)]
31
61
  locked = lockfile.gems
32
- skip = standins(locked)
33
- skipped, wanted = locked.partition { skip.include?(_1.name) }
34
- skipped.each { report << "skip #{_1.name_version}: #{MINIMAL} stands in for #{_1.name} on a minimal canister" }
62
+ refuse!(target, locked.map { [_1.name, _1.version] }, report)
63
+
64
+ skip = skips(target, locked)
65
+ skipped, wanted = locked.partition { skip.key?(_1.name) }
66
+ skipped.each { report << "skip #{_1.name_version}: #{skip[_1.name]}" }
35
67
  prepared = wanted.map { @gem_files.prepare(_1) }
36
68
  prepared.flat_map(&:rewrites).each do |r|
37
69
  report << "rewrite #{r.file}:#{r.line}: magic comment #{r.from} -> #{r.to}"
38
70
  end
39
71
 
40
- plan = Plan.new(prepared, installed, budget: @budget)
72
+ plan = Plan.new(prepared, i, budget: @budget)
41
73
  plan.sent.each { report << "send #{_1.name_version} (#{_1.files.size} files, #{_1.bytes} bytes)" }
42
- if plan.empty?
43
- report << "nothing to send: the canister has every locked gem and the setup file already names them"
44
- return report
45
- end
74
+ send_plan(plan, report, dry_run)
75
+ report << "upgrade the canister to load it (icp deploy --mode upgrade)" if plan.generation && !dry_run && !upgrade
76
+ upgrade!(report) if upgrade && !dry_run
77
+ report
78
+ end
46
79
 
47
- plan.steps.each do |step|
48
- report << "#{dry_run ? 'would call' : 'call'} #{step.method}: #{step.note}"
49
- next if dry_run
80
+ # Requires the config's `verify` names on the canister, and reports its
81
+ # boot's load failures. Raises VerifyFailed if either has any.
82
+ def verify
83
+ i = installed
84
+ raise Error, "the canister half is protocol #{i[:protocol]}: run `ruby_wasm_ic_installer setup` and upgrade" if i[:protocol] < 2
50
85
 
51
- reply = Candid.decode(@runner.call(step.method, step.args)).first
52
- report << " #{reply}"
53
- end
54
- report << (plan.generation ? "setup generation #{plan.generation} takes effect at the next upgrade" \
55
- : "the setup file is unchanged")
56
- report << "upgrade the canister to load it (icp deploy --mode upgrade)" if plan.generation && !dry_run
57
- report
86
+ lines = @config.verify.empty? ? ["no verify: list in #{Config::FILE}; checking the boot's load failures only"] : []
87
+ results = @config.verify.empty? ? [] : verify_calls(@config.verify)
88
+ lines.concat(results)
89
+ lines.concat(failure_lines(i))
90
+ failed = results.grep(/\AFAIL /).size + i[:load_failures].size
91
+ raise VerifyFailed, lines + ["#{failed} failed"] unless failed.zero?
92
+
93
+ lines << "verified: #{results.size} require names, no load failures"
58
94
  end
59
95
 
60
96
  def prune(dry_run: false)
@@ -71,13 +107,114 @@ module RubyWasmIcInstaller
71
107
  end
72
108
  end
73
109
 
110
+ # The lock's gems' entry points, for `verify-init`: [found names, gems
111
+ # with none found]. Gems the target links in or stands in for are left out.
112
+ def entry_points(lockfile)
113
+ i = installed
114
+ target = Target.resolve(flags: @flags, config: @config, info: i)
115
+ locked = lockfile.gems
116
+ skip = skips(target, locked)
117
+ found = []
118
+ unresolved = []
119
+ locked.reject { skip.key?(_1.name) }.each do |g|
120
+ names = @gem_files.entry_points(g)
121
+ names.empty? ? unresolved << g.name_version : found.concat(names)
122
+ end
123
+ [found.uniq, unresolved]
124
+ end
125
+
74
126
  private
75
127
 
76
128
  def installed
77
129
  v = Candid.decode(@runner.call("installed", Candid.empty_args, query: true)).first
78
- Candid.record(v, :running, :pending, :gems, :partial, :load_paths, :running_paths)
130
+ rec = Candid.record(v, *REQUIRED)
131
+ OPTIONAL.each do |name, default|
132
+ h = Candid.idl_hash(name)
133
+ rec[name] = v.key?(h) ? v[h] : default
134
+ end
135
+ rec
79
136
  end
80
137
 
138
+ def send_plan(plan, report, dry_run)
139
+ if plan.empty?
140
+ report << "nothing to send: the canister has every locked gem and the setup file already names them"
141
+ return
142
+ end
143
+
144
+ plan.steps.each do |step|
145
+ report << "#{dry_run ? 'would call' : 'call'} #{step.method}: #{step.note}"
146
+ next if dry_run
147
+
148
+ reply = Candid.decode(@runner.call(step.method, step.args)).first
149
+ report << " #{reply}"
150
+ end
151
+ report << (plan.generation ? "setup generation #{plan.generation} takes effect at the next upgrade" \
152
+ : "the setup file is unchanged")
153
+ end
154
+
155
+ # Deploys the project as an upgrade, then checks the boot.
156
+ def upgrade!(report)
157
+ report << "call icp deploy --mode upgrade"
158
+ @runner.deploy
159
+ i = installed
160
+ results = @config.verify.empty? ? [] : verify_calls(@config.verify)
161
+ report.concat(results)
162
+ report.concat(failure_lines(i))
163
+ failed = results.grep(/\AFAIL /).size + i[:load_failures].size
164
+ raise VerifyFailed, report + ["upgraded, but #{failed} failed"] unless failed.zero?
165
+
166
+ report << "upgraded: the boot loaded every gem#{@config.verify.empty? ? '' : " and #{results.size} verify names"}"
167
+ end
168
+
169
+ def verify_calls(names)
170
+ Candid.decode(@runner.call("install_verify", Candid.texts_arg(names), query: true)).first
171
+ end
172
+
173
+ # What the target does not need sent: the stand-ins a minimal canister
174
+ # has (named by the lock's ruby_wasm_ic_minimal), or what the Build links.
175
+ def skips(target, locked)
176
+ if target.build == "full"
177
+ Rules.linked(target).to_h { [_1, "linked into the full module, so it is not sent"] }
178
+ else
179
+ minimal = locked.find { _1.name == MINIMAL }
180
+ (minimal ? @gem_files.standins(minimal) : []).to_h do
181
+ [_1, "#{MINIMAL} stands in for #{_1} on a minimal canister"]
182
+ end
183
+ end
184
+ end
185
+
186
+ def refuse!(target, gems, report)
187
+ msgs = Rules.refused(target, gems)
188
+ return if msgs.empty?
189
+
190
+ raise Refused, (report + ["refused: nothing was sent:"] + msgs.map { " #{_1}" }).join("\n")
191
+ end
192
+
193
+ def canister_lines(i)
194
+ return ["canister half: protocol 1, which reports no Build and no load failures: run " \
195
+ "`ruby_wasm_ic_installer setup` to update it"] if i[:protocol] < 2
196
+
197
+ ["canister: protocol #{i[:protocol]}, #{i[:build] ? "build #{i[:build]}" : 'build not reported'}" \
198
+ "#{i[:release] ? ", release #{i[:release]}" : ''}"]
199
+ end
200
+
201
+ # The declared target against what the canister runs: a move to another
202
+ # Build or Release.
203
+ def transition_lines(i, target)
204
+ from = [i[:build], i[:release]].compact.join(" ")
205
+ return [] if from.empty? || (i[:build] == target.build && (target.release.nil? || i[:release] == target.release))
206
+
207
+ ["transition: the canister runs #{from}; this is for #{target}"]
208
+ end
209
+
210
+ # What the pending and running setups would load that the target refuses.
211
+ def refusal_lines(target, i)
212
+ pairs = (i[:load_paths] + i[:running_paths]).map { _1.split("/").first }.uniq.map { _1.rpartition("-").then { |a, _, v| [a, v] } }
213
+ Rules.refused(target, pairs).map { "refuses #{target}: #{_1}" }
214
+ end
215
+
216
+ def failure_lines(i) = i[:load_failures].map { "load failure: #{_1}" }
217
+
81
218
  def names_of(paths) = paths.map { _1.split("/").first }.uniq
82
219
 
83
220
  def pending_note(i)
@@ -85,10 +222,5 @@ module RubyWasmIcInstaller
85
222
 
86
223
  " (takes effect at the next upgrade)"
87
224
  end
88
-
89
- def standins(locked)
90
- minimal = locked.find { _1.name == MINIMAL }
91
- minimal ? @gem_files.standins(minimal) : []
92
- end
93
225
  end
94
226
  end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyWasmIcInstaller
4
+ # What depends on the target Build and Release. Each table is this gem's
5
+ # mirror of the builder's: a change to it is a release of this gem.
6
+ module Rules
7
+ # C extensions each Build links in itself, so the lock's gems of these
8
+ # names are skipped, not sent (and not refused as C extensions).
9
+ LINKED = { "full" => %w[stringio strscan].freeze }.freeze
10
+
11
+ # A gem (and versions of it) that refuses to load on a target.
12
+ Refusal = Struct.new(:gem, :build, :gem_versions, :releases, :message, keyword_init: true)
13
+
14
+ REFUSALS = [
15
+ Refusal.new(gem: "ruby_wasm_ic_minimal", build: "full",
16
+ message: "ruby_wasm_ic_minimal is for `minimal` and refuses to load on `full`: remove it from the " \
17
+ "Gemfile: `full` links the real extensions"),
18
+ Refusal.new(gem: "ruby_wasm_ic_minimal", build: "minimal", gem_versions: "< 0.1.5", releases: ">= 0.13.0",
19
+ message: "ruby_wasm_ic_minimal before 0.1.5 refuses to load on minimal 0.13.0 or later: " \
20
+ "update it to 0.1.5 or later")
21
+ ].freeze
22
+
23
+ module_function
24
+
25
+ # The messages of every Refusal the `gems` ([name, version] pairs) hit on
26
+ # `target`.
27
+ def refused(target, gems)
28
+ gems.flat_map do |name, version|
29
+ REFUSALS.select { hit?(_1, target, name, version) }.map { "#{name}-#{version}: #{_1.message}" }
30
+ end
31
+ end
32
+
33
+ def hit?(rule, target, name, version)
34
+ return false unless rule.gem == name && rule.build == target.build
35
+ return false if rule.gem_versions && !::Gem::Requirement.new(rule.gem_versions).satisfied_by?(::Gem::Version.new(version))
36
+ return true unless rule.releases
37
+
38
+ rel = target.release_version
39
+ !rel.nil? && ::Gem::Requirement.new(rule.releases).satisfied_by?(rel)
40
+ end
41
+
42
+ def linked(target) = LINKED.fetch(target.build, [])
43
+ end
44
+ end
@@ -41,8 +41,7 @@ module RubyWasmIcInstaller
41
41
  argv = [@icp, "canister", "call", @canister, method, "--args-file", f.path, "--args-format", "bin",
42
42
  "-o", "hex", *(query ? ["--query"] : []), *@icp_args]
43
43
  out, err, status = @spawn.call(*argv)
44
- raise CallError.new("#{method}: #{err.strip.empty? ? out.strip : err.strip}", refusal: refusal(err)) \
45
- unless status.success?
44
+ raise CallError.new(failure("icp canister call #{method}", out, err), refusal: refusal(err)) unless status.success?
46
45
 
47
46
  hex = out.strip
48
47
  raise CallError, "#{method}: icp replied #{out.inspect[0, 200]}, not hex" unless hex.match?(/\A(?:[0-9a-fA-F]{2})+\z/)
@@ -51,8 +50,23 @@ module RubyWasmIcInstaller
51
50
  end
52
51
  end
53
52
 
53
+ # `icp deploy <canister> --mode upgrade`: builds and installs the project's
54
+ # module as an upgrade, which boots the canister again.
55
+ def deploy
56
+ out, err, status = @spawn.call(@icp, "deploy", @canister, "--mode", "upgrade", *@icp_args)
57
+ raise CallError, failure("icp deploy #{@canister} --mode upgrade", out, err) unless status.success?
58
+
59
+ out
60
+ end
61
+
54
62
  private
55
63
 
64
+ # icp-cli's own message under a header saying whose it is, so a project
65
+ # error (a missing file icp reads, say) does not look like an Installer fault.
66
+ def failure(what, out, err)
67
+ "#{what} failed (icp-cli's message follows):\n#{err.strip.empty? ? out.strip : err.strip}"
68
+ end
69
+
56
70
  # The text after `refused: ` in a trap message, if the canister refused.
57
71
  def refusal(err) = err[/refused: (.*?)(?:'|"|$)/, 1]
58
72
  end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyWasmIcInstaller
4
+ # The Build and Release an install is for. Resolved, highest first, from
5
+ # the --build / --release flags, the config file (the declared target), the
6
+ # canister's own report (what it runs now), and last the assumption that the
7
+ # canister is `minimal`, which is what 0.1.x always assumed.
8
+ Target = Struct.new(:build, :release, :build_source, :release_source, keyword_init: true) do
9
+ def self.resolve(flags:, config:, info:)
10
+ build, bsrc = pick(flags[:build], "--build", config.build, config.path, info[:build], "the canister")
11
+ release, rsrc = pick(flags[:release], "--release", config.release, config.path, info[:release], "the canister")
12
+ if build.nil?
13
+ build = "minimal"
14
+ bsrc = "assumed: no --build, no #{Config::FILE}, and the canister does not report its Build"
15
+ end
16
+ new(build: Config.check_build(build, bsrc), release: release && Config.check_release(release, rsrc),
17
+ build_source: bsrc, release_source: rsrc)
18
+ end
19
+
20
+ def self.pick(flag, flag_name, declared, path, reported, who)
21
+ return [flag, flag_name] if flag
22
+ return [declared, path] if declared
23
+ return [reported, who] if reported
24
+
25
+ [nil, nil]
26
+ end
27
+
28
+ def to_s = [build, release].compact.join(" ")
29
+
30
+ def describe
31
+ src = ["build from #{build_source}", *(release ? ["release from #{release_source}"] : [])].join(", ")
32
+ "target: #{self} (#{src})"
33
+ end
34
+
35
+ def release_version = release && ::Gem::Version.new(release)
36
+ end
37
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyWasmIcInstaller
4
- VERSION = "0.1.1"
4
+ VERSION = "0.2.0"
5
5
  end
@@ -10,6 +10,9 @@ end
10
10
 
11
11
  require_relative "ruby_wasm_ic_installer/version"
12
12
  require_relative "ruby_wasm_ic_installer/candid"
13
+ require_relative "ruby_wasm_ic_installer/config"
14
+ require_relative "ruby_wasm_ic_installer/target"
15
+ require_relative "ruby_wasm_ic_installer/rules"
13
16
  require_relative "ruby_wasm_ic_installer/lockfile"
14
17
  require_relative "ruby_wasm_ic_installer/magic_comment"
15
18
  require_relative "ruby_wasm_ic_installer/gem_files"
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_wasm_ic_installer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - the ruby_wasm_builder authors
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2026-10-28 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies: []
13
12
  description: 'The Installer for canisters packed by ruby_wasm_builder: reads an Application''s
14
13
  Gemfile.lock, fetches its pure-Ruby gems and sends the ones a canister lacks through
15
14
  `icp canister call`, into /data, where a carried canister half loads them at the
16
15
  next boot. `setup` wires the canister half into an Application.'
17
- email:
18
16
  executables:
19
17
  - ruby_wasm_ic_installer
20
18
  extensions: []
@@ -28,13 +26,16 @@ files:
28
26
  - lib/ruby_wasm_ic_installer/candid.rb
29
27
  - lib/ruby_wasm_ic_installer/canister.rb
30
28
  - lib/ruby_wasm_ic_installer/cli.rb
29
+ - lib/ruby_wasm_ic_installer/config.rb
31
30
  - lib/ruby_wasm_ic_installer/diff.rb
32
31
  - lib/ruby_wasm_ic_installer/gem_files.rb
33
32
  - lib/ruby_wasm_ic_installer/installer.rb
34
33
  - lib/ruby_wasm_ic_installer/lockfile.rb
35
34
  - lib/ruby_wasm_ic_installer/magic_comment.rb
36
35
  - lib/ruby_wasm_ic_installer/plan.rb
36
+ - lib/ruby_wasm_ic_installer/rules.rb
37
37
  - lib/ruby_wasm_ic_installer/runner.rb
38
+ - lib/ruby_wasm_ic_installer/target.rb
38
39
  - lib/ruby_wasm_ic_installer/version.rb
39
40
  homepage: https://github.com/graial/ruby_wasm_ic_installer
40
41
  licenses:
@@ -42,7 +43,6 @@ licenses:
42
43
  metadata:
43
44
  source_code_uri: https://github.com/graial/ruby_wasm_ic_installer
44
45
  rubygems_mfa_required: 'true'
45
- post_install_message:
46
46
  rdoc_options: []
47
47
  require_paths:
48
48
  - lib
@@ -57,8 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
57
57
  - !ruby/object:Gem::Version
58
58
  version: '0'
59
59
  requirements: []
60
- rubygems_version: 3.5.11
61
- signing_key:
60
+ rubygems_version: 4.0.23
62
61
  specification_version: 4
63
62
  summary: Install pure-Ruby gems into a Ruby canister on the Internet Computer, through
64
63
  calls