@minnovate/shadow-publisher 0.6.0 → 0.6.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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "git-publisher",
3
3
  "displayName": "Git Publisher",
4
- "version": "0.6.0",
4
+ "version": "0.6.1",
5
5
  "description": "Publish an app folder's Git history to the serverless Git publishing backend and keep it updated (\"publish my app\", \"update my app\", \"fetch the engineered version\").",
6
6
  "author": { "name": "git-publisher project" },
7
7
  "keywords": ["git", "publish", "deploy", "serverless"]
@@ -4646,8 +4646,8 @@ async function followRun(input, opts) {
4646
4646
  refreshed = true;
4647
4647
  if (await opts.refresh()) continue;
4648
4648
  }
4649
- if (answer.status === 401 && isRecord(answer.body) && typeof answer.body["error"] === "string") return { kind: "unauthorized" };
4650
- if (answer.status === 404 || answer.status === 401) return { kind: "unavailable", reason: "no-route" };
4649
+ if (answer.status === 401) return { kind: "unauthorized" };
4650
+ if (answer.status === 404) return { kind: "unavailable", reason: "no-route" };
4651
4651
  if (answer.status === 403) return { kind: "forbidden" };
4652
4652
  if (answer.status === 200) {
4653
4653
  const run = soleRun(answer.body);
@@ -4704,16 +4704,19 @@ function portalForEndpoint(endpoint) {
4704
4704
  if (url2.protocol !== "https:" || url2.pathname.replace(/\/+$/, "") !== "/publish") return null;
4705
4705
  return url2.origin;
4706
4706
  }
4707
+ var RUN_PROGRESS = "run-progress";
4707
4708
  async function confirmPortal(portal, endpoint, fetchImpl = fetch) {
4708
4709
  try {
4709
4710
  const res = await fetchImpl(`${portal}/api/v1/config`, { signal: AbortSignal.timeout(1e4) });
4710
- if (!res.ok) return false;
4711
+ if (!res.ok) return null;
4711
4712
  const body = await res.json();
4712
4713
  const named = body?.publishingEndpoint;
4713
4714
  const bare = (u) => u.replace(/\/+$/, "");
4714
- return typeof named === "string" && bare(named) === bare(endpoint);
4715
+ if (typeof named !== "string" || bare(named) !== bare(endpoint)) return null;
4716
+ const terminal = body?.terminal;
4717
+ return { terminal: Array.isArray(terminal) && terminal.every((name) => typeof name === "string") ? terminal : [] };
4715
4718
  } catch {
4716
- return false;
4719
+ return null;
4717
4720
  }
4718
4721
  }
4719
4722
  function isRecord(value) {
@@ -5832,9 +5835,14 @@ async function installSkills({ log }) {
5832
5835
  // src/follow.ts
5833
5836
  async function followPublication(p, endpoint, o, opts) {
5834
5837
  const derived = portalForEndpoint(endpoint);
5835
- const portal = derived !== null && await confirmPortal(derived, endpoint, opts.fetch) ? derived : null;
5838
+ const confirmed = derived === null ? null : await confirmPortal(derived, endpoint, opts.fetch);
5839
+ const portal = confirmed === null ? null : derived;
5836
5840
  const elsewhere = (reason) => ({ kind: "unavailable", reason, portal, hint: inPortal(portal, "Published.", "Follow it") });
5837
- if (portal === null) return elsewhere("no-portal");
5841
+ if (portal === null || confirmed === null) return elsewhere("no-portal");
5842
+ if (!confirmed.terminal.includes(RUN_PROGRESS)) {
5843
+ const noRoute = { kind: "unavailable", reason: "no-route" };
5844
+ return { ...noRoute, portal, hint: progressHint(noRoute, portal) };
5845
+ }
5838
5846
  const refs = Object.entries(o.refs ?? {});
5839
5847
  if (refs.length !== 1) return elsewhere("several-refs");
5840
5848
  const [ref, commit] = refs[0];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minnovate/shadow-publisher",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "publisher: publish an app's Git history to the serverless Git backend",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",