@kungfu-tech/buildchain 4.0.2-alpha.45 → 4.0.2-alpha.47

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.
@@ -265,11 +265,11 @@ async function observedSourceTimestamp(repository, sourceSha) {
265
265
  fail("protected publication source timestamp is unavailable");
266
266
  return new Date(observed).toISOString();
267
267
  }
268
- async function observeProductPublicationRecovery(repository, sourceSha, candidateVersion) {
268
+ async function observeProductPublicationRecovery(repository, sourceSha, candidateVersion, channel) {
269
269
  const apiUrl = process.env.GITHUB_API_URL || "https://api.github.com", token = process.env.GH_TOKEN || process.env.GITHUB_TOKEN || "", prefix = `heads/buildchain/v4-product-state/${sourceSha}-`;
270
270
  const stateRefs = (await githubJson({ apiUrl, token, path: `/repos/${repository}/git/matching-refs/${prefix}`, allowNotFound: true })) || [];
271
271
  const recoveryStates = await Promise.all(stateRefs.map(async (stateRef) => { const version = v4ProductStateVersion(stateRef, sourceSha); const [stateCommit, exactTagRef] = await Promise.all([githubJson({ apiUrl, token, path: `/repos/${repository}/git/commits/${stateRef.object.sha}` }), githubJson({ apiUrl, token, path: `/repos/${repository}/git/ref/tags/v${version}`, allowNotFound: true })]); return { stateRef, stateCommit, exactTagRef }; }));
272
- const exactTagRef = recoveryStates.length ? undefined : await githubJson({ apiUrl, token, path: `/repos/${repository}/git/ref/tags/v${encodeURIComponent(candidateVersion)}`, allowNotFound: true }); return { recoveryStates, exactTagRef };
272
+ const exactTagRef = recoveryStates.length ? undefined : await githubJson({ apiUrl, token, path: `/repos/${repository}/git/ref/tags/v${encodeURIComponent(channel === "stable" ? candidateVersion.replace(/-alpha\.\d+$/u, "") : candidateVersion)}`, allowNotFound: true }); return { recoveryStates, exactTagRef };
273
273
  }
274
274
  async function materializeProductPublicationIntent({
275
275
  candidate,
@@ -282,8 +282,8 @@ async function materializeProductPublicationIntent({
282
282
  );
283
283
  const sourceTimestamp = await observedSourceTimestamp(repository, route.requestedSha);
284
284
  const version = String(candidate.publicationVersion || candidate.version || "").trim(), explicitResume = String(inputs["resume-transaction-id"] || "") !== "";
285
- const recovery = route.decision !== "Resume" || explicitResume ? {} : await observeProductPublicationRecovery(repository, route.requestedSha, version);
286
- const recoveredVersion = selectV4RecoveredProductPublicationVersion({ routeDecision: route.decision, candidateVersion: version, requestedSha: route.requestedSha, explicitResume, ...recovery });
285
+ const recovery = route.decision !== "Resume" || explicitResume ? {} : await observeProductPublicationRecovery(repository, route.requestedSha, version, route.channel);
286
+ const recoveredVersion = selectV4RecoveredProductPublicationVersion({ routeDecision: route.decision, candidateVersion: version, channel: route.channel, requestedSha: route.requestedSha, explicitResume, ...recovery });
287
287
  execFileSync(
288
288
  process.execPath,
289
289
  [