@biffo/cli 0.228.1 → 0.228.3

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 +44 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -9879,6 +9879,49 @@ function checkReleaseSubject(changedFiles, subject, manifest, isInstance) {
9879
9879
  }
9880
9880
 
9881
9881
  // src/scripts/check-release-subject.ts
9882
+ async function fetchPrTitleViaGh({
9883
+ GH_TOKEN,
9884
+ PR_NUMBER,
9885
+ GH_REPO
9886
+ }) {
9887
+ const { stdout } = await execa10(
9888
+ "gh",
9889
+ ["pr", "view", PR_NUMBER, "--repo", GH_REPO, "--json", "title", "--jq", ".title"],
9890
+ { env: { ...process.env, GH_TOKEN } }
9891
+ );
9892
+ return stdout.trim();
9893
+ }
9894
+ async function resolveReleaseSubject({
9895
+ env = process.env,
9896
+ cwd,
9897
+ fetchLiveTitle = fetchPrTitleViaGh
9898
+ }) {
9899
+ const explicit = env["PR_TITLE"]?.trim();
9900
+ if (explicit) return explicit;
9901
+ const GH_TOKEN = env["GH_TOKEN"];
9902
+ const PR_NUMBER = env["PR_NUMBER"];
9903
+ const GH_REPO = env["GH_REPO"];
9904
+ const trio = [GH_TOKEN, PR_NUMBER, GH_REPO];
9905
+ if (trio.some(Boolean) && !trio.every(Boolean)) {
9906
+ throw new Error(
9907
+ "GH_TOKEN, PR_NUMBER and GH_REPO must all be set together for the live PR-title fetch; got only some of them."
9908
+ );
9909
+ }
9910
+ if (trio.every(Boolean)) {
9911
+ try {
9912
+ return await fetchLiveTitle({
9913
+ GH_TOKEN,
9914
+ PR_NUMBER,
9915
+ GH_REPO
9916
+ });
9917
+ } catch (err) {
9918
+ throw new Error(
9919
+ `could not fetch the live title of PR #${PR_NUMBER} in ${GH_REPO}: ${err.message}`
9920
+ );
9921
+ }
9922
+ }
9923
+ return (await execa10("git", ["log", "-1", "--format=%s"], { cwd })).stdout.trim();
9924
+ }
9882
9925
  async function runReleaseSubjectCheck(argv) {
9883
9926
  const base = process.env["GITHUB_BASE_REF"] ?? argv[0];
9884
9927
  if (!base) {
@@ -9891,7 +9934,7 @@ async function runReleaseSubjectCheck(argv) {
9891
9934
  cwd: root
9892
9935
  });
9893
9936
  const changedFiles = stdout.split("\n").map((s) => s.trim()).filter(Boolean);
9894
- const subject = process.env["PR_TITLE"]?.trim() || (await execa10("git", ["log", "-1", "--format=%s"], { cwd: root })).stdout.trim();
9937
+ const subject = await resolveReleaseSubject({ cwd: root });
9895
9938
  const manifest = readCoreManifest(root);
9896
9939
  const { unparseable, bump, templateOwnedChanges, skippedAsInstance } = checkReleaseSubject(
9897
9940
  changedFiles,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@biffo/cli",
3
- "version": "0.228.1",
3
+ "version": "0.228.3",
4
4
  "description": "Biffo project scaffolding CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",