@biffo/cli 0.206.1 → 0.207.0

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 +18 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -8921,7 +8921,7 @@ function deriveRequiredContexts(observed) {
8921
8921
  function protectionParamsFor(contexts, options = {}) {
8922
8922
  return {
8923
8923
  required_status_checks: { strict: options.strict ?? true, contexts: [...contexts].sort() },
8924
- enforce_admins: false,
8924
+ enforce_admins: options.enforceAdmins ?? true,
8925
8925
  required_pull_request_reviews: {
8926
8926
  required_approving_review_count: 0,
8927
8927
  dismiss_stale_reviews: false
@@ -9054,6 +9054,7 @@ async function runBranchProtectionCheck(explicitRepo, options = {}) {
9054
9054
  const findings = [];
9055
9055
  const audited = [];
9056
9056
  const observedStrict = /* @__PURE__ */ new Map();
9057
+ const observedEnforceAdmins = /* @__PURE__ */ new Map();
9057
9058
  for (const branch of BRANCHES) {
9058
9059
  try {
9059
9060
  await octokit.repos.getBranch({ owner, repo, branch });
@@ -9066,6 +9067,7 @@ async function runBranchProtectionCheck(explicitRepo, options = {}) {
9066
9067
  const { data } = await octokit.repos.getBranchProtection({ owner, repo, branch });
9067
9068
  findings.push(...auditBranch(branch, data));
9068
9069
  observedStrict.set(branch, data.required_status_checks?.strict ?? false);
9070
+ observedEnforceAdmins.set(branch, data.enforce_admins?.enabled ?? false);
9069
9071
  } catch (err) {
9070
9072
  if (err.status === 404) {
9071
9073
  findings.push(...auditBranch(branch, null));
@@ -9098,22 +9100,33 @@ async function runBranchProtectionCheck(explicitRepo, options = {}) {
9098
9100
  `);
9099
9101
  console.log(formatPlans(plans));
9100
9102
  let applied = 0;
9101
- let preserved = 0;
9103
+ let preservedStrict = 0;
9104
+ let preservedAdmins = 0;
9102
9105
  for (const plan of plans.filter((p) => p.action === "apply")) {
9103
9106
  const existing = observedStrict.get(plan.branch);
9104
9107
  const strict = existing ?? true;
9105
9108
  if (existing === false) {
9106
- preserved += 1;
9109
+ preservedStrict += 1;
9107
9110
  console.log(
9108
9111
  ` ${plan.branch}: keeping strict=false \u2014 already set on this branch, so it is a
9109
9112
  decision rather than a gap. Change it deliberately with \`gh api\`, not here.`
9110
9113
  );
9111
9114
  }
9115
+ const existingAdmins = observedEnforceAdmins.get(plan.branch);
9116
+ const enforceAdmins = existingAdmins ?? true;
9117
+ if (existingAdmins === false) {
9118
+ preservedAdmins += 1;
9119
+ console.log(
9120
+ ` ${plan.branch}: keeping enforce_admins=false \u2014 already set on this branch, so it
9121
+ is a decision rather than a gap. Note that protection which does not bind an
9122
+ admin is advisory for whoever merges; scripts/protection-audit.sh fails on it.`
9123
+ );
9124
+ }
9112
9125
  await octokit.repos.updateBranchProtection({
9113
9126
  owner,
9114
9127
  repo,
9115
9128
  branch: plan.branch,
9116
- ...protectionParamsFor(plan.contexts, { strict })
9129
+ ...protectionParamsFor(plan.contexts, { strict, enforceAdmins })
9117
9130
  });
9118
9131
  applied += 1;
9119
9132
  }
@@ -9125,7 +9138,7 @@ async function runBranchProtectionCheck(explicitRepo, options = {}) {
9125
9138
  }
9126
9139
  console.log(
9127
9140
  `
9128
- \u2713 protection applied to ${applied} branch(es)` + (preserved > 0 ? `, ${preserved} keeping an existing strict=false` : "") + ". Re-run without --fix to verify."
9141
+ \u2713 protection applied to ${applied} branch(es)` + (preservedStrict > 0 ? `, ${preservedStrict} keeping an existing strict=false` : "") + (preservedAdmins > 0 ? `, ${preservedAdmins} keeping an existing enforce_admins=false` : "") + ". Re-run without --fix to verify."
9129
9142
  );
9130
9143
  return;
9131
9144
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@biffo/cli",
3
- "version": "0.206.1",
3
+ "version": "0.207.0",
4
4
  "description": "Biffo project scaffolding CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",