@mmon-co/ncept-local 0.4.1 → 0.4.2

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/hub.js +9 -2
  2. package/package.json +1 -1
package/dist/hub.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { idOf, slugged } from "@mmon-co/ncept-core/resource-url";
1
2
  import { mkdtemp, rename, rm } from "node:fs/promises";
2
3
  import { dirname, basename, join } from "node:path";
3
4
  import { randomUUID } from "node:crypto";
@@ -58,7 +59,8 @@ function releaseAddress(value, base) {
58
59
  const api = value.match(/^(https?:\/\/.+)\/hub\/v1\/releases\/([^/]+)\/([^/?#]+)(?:[?#].*)?$/);
59
60
  const exact = value.match(/^(patch-[0-9a-z-]+)@(.+)$/);
60
61
  const match = page ?? api;
61
- const patchId = match ? decodeURIComponent(match[2] ?? "") : exact?.[1];
62
+ const segment = match ? decodeURIComponent(match[2] ?? "") : exact?.[1];
63
+ const patchId = page && segment ? idOf(segment, "patch") : segment;
62
64
  const version = match ? decodeURIComponent(match[3] ?? "") : exact?.[2];
63
65
  if (!isPatchId(patchId) || !version)
64
66
  throw new Error("Use a Hub release page URL or patch-id@version");
@@ -197,6 +199,7 @@ export function connectHub(profile, theories, confirm, createMission, options =
197
199
  async function release(bundle, blobs, version, visibility) {
198
200
  const { completeContents } = await verifySparseBundle(bundle, captureReading);
199
201
  const uploads = new Map([...completeContents.values()].flatMap(contentAttachments).map((attachment) => [attachment.hash, attachment]));
202
+ const title = completeContents.get(bundle.terminal.digest)?.metadata.properties["patch:title"];
200
203
  return connected(async (call) => {
201
204
  for (const [hash, attachment] of uploads) {
202
205
  // A complete revision can still come from a sparse reading that omitted some blobs.
@@ -211,7 +214,11 @@ export function connectHub(profile, theories, confirm, createMission, options =
211
214
  return {
212
215
  ref: captured.ref,
213
216
  version,
214
- url: base + "/hub/" + captured.ref.identity + "/releases/" + encodeURIComponent(version),
217
+ url: base +
218
+ "/hub/" +
219
+ encodeURIComponent(slugged(captured.ref.identity, typeof title === "string" ? title : undefined)) +
220
+ "/releases/" +
221
+ encodeURIComponent(version),
215
222
  };
216
223
  });
217
224
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mmon-co/ncept-local",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",