@malloydata/malloyyo 0.2.70 → 0.2.72

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.
Files changed (2) hide show
  1. package/dist/index.js +25 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -11,7 +11,7 @@ import { dirname, join } from "node:path";
11
11
  import { fileURLToPath } from "node:url";
12
12
 
13
13
  // package.json
14
- var version = "0.2.70";
14
+ var version = "0.2.72";
15
15
 
16
16
  // src/update-check.ts
17
17
  var UPDATE_CHECK_ARGV = "__update-check";
@@ -3231,7 +3231,11 @@ A repo publishes what git tracks, so there has to be a git repo to ask. Run \`gi
3231
3231
  const tree = git(["write-tree"]).trim();
3232
3232
  const fileCount = (git(["ls-files"]).trim().match(/\n/g)?.length ?? -1) + 1;
3233
3233
  const zip = git(["archive", "--format=zip", tree], "buffer");
3234
- return { zip, fileCount };
3234
+ const largest = git(["ls-tree", "-r", "-l", "-z", tree]).split("\0").filter(Boolean).map((line) => {
3235
+ const [meta, path13] = line.split(" ");
3236
+ return { path: path13 ?? "", bytes: Number(meta?.trim().split(/\s+/)[3]) || 0 };
3237
+ }).sort((a, b) => b.bytes - a.bytes).slice(0, 8);
3238
+ return { zip, fileCount, largest };
3235
3239
  } finally {
3236
3240
  rmSync(dirname2(tmpIndex), { recursive: true, force: true });
3237
3241
  }
@@ -4944,8 +4948,8 @@ bundled ${dashboards.length} dashboard(s) \u2192 ${path9.relative(process.cwd(),
4944
4948
  console.log(` model ${Object.keys(modelFiles).length} .malloy files inlined`);
4945
4949
  if (analytics) console.log(` analytics ${analytics}`);
4946
4950
  if (copiedData.length) {
4947
- const mb = copiedData.reduce((a, r) => a + fs8.statSync(path9.join(root, r)).size, 0) / 1048576;
4948
- console.log(` data ${copiedData.length} file(s) copied, ${mb.toFixed(1)} MB (same-origin)`);
4951
+ const mb2 = copiedData.reduce((a, r) => a + fs8.statSync(path9.join(root, r)).size, 0) / 1048576;
4952
+ console.log(` data ${copiedData.length} file(s) copied, ${mb2.toFixed(1)} MB (same-origin)`);
4949
4953
  }
4950
4954
  console.log(
4951
4955
  target === "pages" ? `
@@ -6361,6 +6365,18 @@ Target resolution:
6361
6365
  whose url should be borrowed. Authenticate the same way as always:
6362
6366
  \`malloyyo login <url>\`, or set $MALLOYYO_TOKEN (mint one at
6363
6367
  <url>/settings/tokens \u2014 that is what CI wants), or pass --token.`;
6368
+ var HOSTED_REQUEST_LIMIT = 4.5 * 1024 * 1024;
6369
+ var mb = (n) => `${(n / 1024 / 1024).toFixed(1)}MB`;
6370
+ function tooLargeHint(requestBytes, largest) {
6371
+ return [
6372
+ `the publish request is ${mb(requestBytes)}; a Vercel-hosted instance accepts ${mb(HOSTED_REQUEST_LIMIT)}.`,
6373
+ `largest files in the archive:`,
6374
+ ...largest.map((f) => ` ${mb(f.bytes).padStart(7)} ${f.path}`),
6375
+ `leave out what the model doesn't read with git's export-ignore, in .gitattributes`,
6376
+ `(anchored with a leading "/", or it matches at every depth):`,
6377
+ ` /docs/ export-ignore`
6378
+ ].join("\n");
6379
+ }
6364
6380
  async function publishRepo(root, datasetNames, target, opts) {
6365
6381
  const t = resolvePublishTarget(root, target, { instance: opts.instance, dataset: opts.repo });
6366
6382
  const bearer = await getAccessToken(t, { tokenFlag: opts.token });
@@ -6374,13 +6390,16 @@ async function publishRepo(root, datasetNames, target, opts) {
6374
6390
  );
6375
6391
  }
6376
6392
  }
6377
- const { zip: archive, fileCount } = gitArchiveZip(root);
6393
+ const { zip: archive, fileCount, largest } = gitArchiveZip(root);
6378
6394
  if (fileCount === 0) throw new Error(`${root} has no files git tracks \u2014 nothing to publish`);
6379
6395
  const git = gitInfo(root);
6380
6396
  const provenance = git.sha ? `${git.branch}@${shortSha(git.sha)}${git.dirty ? " (dirty)" : ""}` : "(no git)";
6381
6397
  console.log(`\u2192 ${t.url} repo=${opts.repo}${opts.createDatasets ? " (create missing)" : ""}`);
6382
6398
  console.log(` ${datasetNames.length} dataset(s): ${datasetNames.join(", ")}`);
6383
6399
  console.log(` ${fileCount} file(s), ${(archive.length / 1024).toFixed(0)}KB archive ${provenance}`);
6400
+ const requestBytes = Math.ceil(archive.length / 3) * 4;
6401
+ const tooLarge = tooLargeHint(requestBytes, largest);
6402
+ if (requestBytes > HOSTED_REQUEST_LIMIT) console.warn(` warning: ${tooLarge}`);
6384
6403
  if (opts.dryRun) {
6385
6404
  console.log("dry run \u2014 not sending");
6386
6405
  return;
@@ -6397,6 +6416,7 @@ async function publishRepo(root, datasetNames, target, opts) {
6397
6416
  })
6398
6417
  });
6399
6418
  const out = await res.json().catch(() => null);
6419
+ if (res.status === 413) throw new Error(`publish refused by ${t.url} (413): ${tooLarge}`);
6400
6420
  if (!res.ok || !out?.ok) {
6401
6421
  throw new Error(out?.error ?? `publish failed (${res.status})`);
6402
6422
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/malloyyo",
3
- "version": "0.2.70",
3
+ "version": "0.2.72",
4
4
  "description": "Publish Malloy models to a Malloyyo instance",
5
5
  "license": "MIT",
6
6
  "repository": {