@imagina-build/ias-cli 0.1.5 → 0.2.1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imagina-build/ias-cli",
3
- "version": "0.1.5",
3
+ "version": "0.2.1",
4
4
  "description": "The command line of Imagina Application Services (IAS): ias.json, OTA updates, internal distribution and the checks of a project.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -121,7 +121,7 @@ function sdkCheck(dir, add) {
121
121
  const { declared, installed, plugin } = state;
122
122
  if (!declared && !installed) {
123
123
  if (plugin === 'yes') add('sdk', 'fail', `app.json has the plugin of ${SDK_PACKAGE}, but the app does not have the package`, 'ias sdk install installs it: expo config and the builds fail without it');
124
- else add('sdk', 'warn', `the app does not use ${SDK_PACKAGE}`, `ias sdk install, if it uses ias.sync, ias.push or ias.updates, or takes its configuration from ias.json`);
124
+ else add('sdk', 'warn', `the app does not use ${SDK_PACKAGE}`, `ias sdk install, if it uses ias.sync or ias.push, or takes its configuration from ias.json`);
125
125
  return;
126
126
  }
127
127
  if (!installed) {
@@ -387,6 +387,12 @@ export async function check(settings, { platforms = PLATFORMS }, output) {
387
387
  return { checks };
388
388
  }
389
389
 
390
+ /**
391
+ * The URL of a file the manifest points to, asked of the server this publication went to: a manifest may name any of
392
+ * the hosts the server answers for (the old domain, the new one), and they all serve the same path.
393
+ */
394
+ const assetOf = (url, settings) => new URL(new URL(url, settings.manifestUrl).pathname, settings.base);
395
+
390
396
  /**
391
397
  * Asks for the manifest as a phone would and checks the signature, the id and every file it points to. `checked`
392
398
  * holds the files already checked in this run (one per settings): the platforms share most of them. `channel` and
@@ -418,7 +424,7 @@ export async function checkServed(settings, platform, runtime, expectedId, outpu
418
424
  checked.add(asset.hash);
419
425
  // Each file once, and the bundle also without gzip.
420
426
  for (const encoding of index === 0 ? [undefined, 'identity'] : [undefined]) {
421
- const answer = await download(new URL(asset.url, settings.manifestUrl), encoding ? { 'accept-encoding': encoding } : {}, output);
427
+ const answer = await download(assetOf(asset.url, settings), encoding ? { 'accept-encoding': encoding } : {}, output);
422
428
  if (!answer.ok) throw new Error(`${platform}: ${asset.url} answered ${answer.status}`);
423
429
  if (sha256(Buffer.from(await answer.arrayBuffer())) !== asset.hash) throw new Error(`${platform}: ${asset.url} does not match its hash`);
424
430
  }
package/src/config.mjs CHANGED
@@ -163,7 +163,7 @@ function iasUpdateSettings({ dir, config }, env) {
163
163
  manifestUrl: manifestUrl.href,
164
164
  base,
165
165
  project: manifestUrl.pathname.match(MANIFEST_PATH)[1],
166
- assetPath: `${new URL(base).pathname}/assets/`,
166
+ assetPath: `${base}/assets/`,
167
167
  keyid,
168
168
  certificate: new X509Certificate(readFileSync(certificateFile)),
169
169
  signingSource: appCertificate ? 'app.json' : 'updates.signing of ias.json',
@@ -203,7 +203,7 @@ function legacyUpdateSettings(projectDir, env) {
203
203
  manifestUrl: manifestUrl.href,
204
204
  base,
205
205
  project: manifestUrl.pathname.match(MANIFEST_PATH)[1],
206
- assetPath: `${new URL(base).pathname}/assets/`,
206
+ assetPath: `${base}/assets/`,
207
207
  keyid: updates.codeSigningMetadata.keyid,
208
208
  certificate,
209
209
  privateKey,
package/src/ota.mjs CHANGED
@@ -30,9 +30,10 @@ export function readEnvFile(path, names) {
30
30
  }
31
31
 
32
32
  /**
33
- * One manifest per platform from an expo export folder: the same createdAt, the runtime of each platform, relative
34
- * asset URLs, metadata {} (filters could make phones load an older update) and the public config as extra.expoClient.
35
- * Returns the manifests and the files to upload, by hash. Throws if a bundle lacks a value it must carry.
33
+ * One manifest per platform from an expo export folder: the same createdAt, the runtime of each platform, absolute
34
+ * asset URLs (the released expo-updates clients do not resolve relative ones), metadata {} (filters could make phones
35
+ * load an older update) and the public config as extra.expoClient. Returns the manifests and the files to upload, by
36
+ * hash. Throws if a bundle lacks a value it must carry.
36
37
  */
37
38
  export function buildManifests({ dist, metadata, platforms, runtimes, expoClient, assetPath, createdAt, mustContain = [] }) {
38
39
  const files = new Map();