@biffo/cli 0.185.2 → 0.185.4

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 +19 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -8567,9 +8567,9 @@ function deriveRequiredContexts(observed) {
8567
8567
  const required = Math.ceil(window.length * CONTEXT_CONSISTENCY_THRESHOLD);
8568
8568
  return [...seenOn.entries()].filter(([, shas]) => shas.size >= required).map(([name]) => name).sort();
8569
8569
  }
8570
- function protectionParamsFor(contexts) {
8570
+ function protectionParamsFor(contexts, options = {}) {
8571
8571
  return {
8572
- required_status_checks: { strict: true, contexts: [...contexts].sort() },
8572
+ required_status_checks: { strict: options.strict ?? true, contexts: [...contexts].sort() },
8573
8573
  enforce_admins: false,
8574
8574
  required_pull_request_reviews: {
8575
8575
  required_approving_review_count: 0,
@@ -8702,6 +8702,7 @@ async function runBranchProtectionCheck(explicitRepo, options = {}) {
8702
8702
  });
8703
8703
  const findings = [];
8704
8704
  const audited = [];
8705
+ const observedStrict = /* @__PURE__ */ new Map();
8705
8706
  for (const branch of BRANCHES) {
8706
8707
  try {
8707
8708
  await octokit.repos.getBranch({ owner, repo, branch });
@@ -8713,6 +8714,7 @@ async function runBranchProtectionCheck(explicitRepo, options = {}) {
8713
8714
  try {
8714
8715
  const { data } = await octokit.repos.getBranchProtection({ owner, repo, branch });
8715
8716
  findings.push(...auditBranch(branch, data));
8717
+ observedStrict.set(branch, data.required_status_checks?.strict ?? false);
8716
8718
  } catch (err) {
8717
8719
  if (err.status === 404) {
8718
8720
  findings.push(...auditBranch(branch, null));
@@ -8745,12 +8747,22 @@ async function runBranchProtectionCheck(explicitRepo, options = {}) {
8745
8747
  `);
8746
8748
  console.log(formatPlans(plans));
8747
8749
  let applied = 0;
8750
+ let preserved = 0;
8748
8751
  for (const plan of plans.filter((p) => p.action === "apply")) {
8752
+ const existing = observedStrict.get(plan.branch);
8753
+ const strict = existing ?? true;
8754
+ if (existing === false) {
8755
+ preserved += 1;
8756
+ console.log(
8757
+ ` ${plan.branch}: keeping strict=false \u2014 already set on this branch, so it is a
8758
+ decision rather than a gap. Change it deliberately with \`gh api\`, not here.`
8759
+ );
8760
+ }
8749
8761
  await octokit.repos.updateBranchProtection({
8750
8762
  owner,
8751
8763
  repo,
8752
8764
  branch: plan.branch,
8753
- ...protectionParamsFor(plan.contexts)
8765
+ ...protectionParamsFor(plan.contexts, { strict })
8754
8766
  });
8755
8767
  applied += 1;
8756
8768
  }
@@ -8760,8 +8772,10 @@ async function runBranchProtectionCheck(explicitRepo, options = {}) {
8760
8772
  );
8761
8773
  process.exit(1);
8762
8774
  }
8763
- console.log(`
8764
- \u2713 protection applied to ${applied} branch(es). Re-run without --fix to verify.`);
8775
+ console.log(
8776
+ `
8777
+ \u2713 protection applied to ${applied} branch(es)` + (preserved > 0 ? `, ${preserved} keeping an existing strict=false` : "") + ". Re-run without --fix to verify."
8778
+ );
8765
8779
  return;
8766
8780
  }
8767
8781
  if (findings.length > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@biffo/cli",
3
- "version": "0.185.2",
3
+ "version": "0.185.4",
4
4
  "description": "Biffo project scaffolding CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",