@rmartz/pr-policy 0.10.0 → 0.11.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.
@@ -7,7 +7,7 @@ import {
7
7
  postVerdict,
8
8
  resolveRepoTarget,
9
9
  selectChecks
10
- } from "../chunk-TLGL2PTZ.js";
10
+ } from "../chunk-LWLZD5YW.js";
11
11
 
12
12
  // src/bin/pr-policy.ts
13
13
  import { readFile } from "fs/promises";
@@ -708,15 +708,15 @@ function pipVersions(text) {
708
708
  }
709
709
  return versions;
710
710
  }
711
- function versionsOf(path, text) {
711
+ function manifestVersions(path, text) {
712
712
  return basename(path) === "package.json" ? npmVersions(text) : pipVersions(text);
713
713
  }
714
714
  function sensitiveBumps(changes) {
715
715
  const bumped = /* @__PURE__ */ new Set();
716
716
  for (const change of changes) {
717
717
  if (change.baseText === void 0 || change.headText === void 0) continue;
718
- const before = versionsOf(change.path, change.baseText);
719
- const after = versionsOf(change.path, change.headText);
718
+ const before = manifestVersions(change.path, change.baseText);
719
+ const after = manifestVersions(change.path, change.headText);
720
720
  if (before === null || after === null) continue;
721
721
  for (const name of CI_SENSITIVE_PACKAGES) {
722
722
  const was = before.get(name);
@@ -1156,6 +1156,34 @@ function isReleasePleaseTitle(title) {
1156
1156
  return RELEASE_PLEASE_TITLE.test(title);
1157
1157
  }
1158
1158
 
1159
+ // src/checks/title/major-bump.ts
1160
+ var LEADING_VERSION = /^[\^~=<>!v\s]*(\d+)(?:\.(\d+))?(?:\.(\d+))?/;
1161
+ function parseVersion(spec) {
1162
+ const match = LEADING_VERSION.exec(spec);
1163
+ if (match === null) return void 0;
1164
+ const [, major = "0", minor = "0", patch = "0"] = match;
1165
+ return { major: Number(major), text: `${major}.${minor}.${patch}` };
1166
+ }
1167
+ function majorBumps(changes) {
1168
+ const bumps = /* @__PURE__ */ new Set();
1169
+ for (const change of changes) {
1170
+ if (change.baseText === void 0 || change.headText === void 0) continue;
1171
+ const before = manifestVersions(change.path, change.baseText);
1172
+ const after = manifestVersions(change.path, change.headText);
1173
+ if (before === null || after === null) continue;
1174
+ for (const [name, spec] of after) {
1175
+ const was = before.get(name);
1176
+ if (was === void 0) continue;
1177
+ const from = parseVersion(was);
1178
+ const to = parseVersion(spec);
1179
+ if (from !== void 0 && to !== void 0 && to.major > from.major) {
1180
+ bumps.add(`${name} ${from.text} \u2192 ${to.text}`);
1181
+ }
1182
+ }
1183
+ }
1184
+ return [...bumps];
1185
+ }
1186
+
1159
1187
  // src/checks/title/type-paths.ts
1160
1188
  function isMarkdownPath(path) {
1161
1189
  return path.toLowerCase().endsWith(".md");
@@ -1208,6 +1236,7 @@ function decideTitle(pr) {
1208
1236
  }
1209
1237
  const findings = [];
1210
1238
  const functional = isFunctionalType(title.type);
1239
+ const breakingTitle = `${title.type}${title.scope ? `(${title.scope})` : ""}!: ${title.subject}`;
1211
1240
  const breakingLabel = labels.has(BREAKING_CHANGE_LABEL);
1212
1241
  const breakingIntent = breakingLabel || labels.has(HOTFIX_LABEL);
1213
1242
  if (!functional) {
@@ -1228,7 +1257,7 @@ function decideTitle(pr) {
1228
1257
  } else if (breakingIntent && !title.breaking) {
1229
1258
  findings.push(
1230
1259
  block2(
1231
- `The PR is labelled breaking but the title has no \`!\`, so the release would miss the major. Retitle to \`${title.type}${title.scope ? `(${title.scope})` : ""}!: ${title.subject}\`.`
1260
+ `The PR is labelled breaking but the title has no \`!\`, so the release would miss the major. Retitle to \`${breakingTitle}\`.`
1232
1261
  )
1233
1262
  );
1234
1263
  } else if (!breakingIntent && title.breaking) {
@@ -1238,6 +1267,14 @@ function decideTitle(pr) {
1238
1267
  )
1239
1268
  );
1240
1269
  }
1270
+ const majors = majorBumps(pr.manifestChanges);
1271
+ if (functional && !breakingIntent && !title.breaking && majors.length > 0) {
1272
+ findings.push(
1273
+ block2(
1274
+ `This PR bumps a dependency's major version (${majors.map((bump) => `\`${bump}\``).join(", ")}), so it is a breaking change. Retitle to \`${breakingTitle}\` and add the \`${BREAKING_CHANGE_LABEL}\` label.`
1275
+ )
1276
+ );
1277
+ }
1241
1278
  const pathViolation = typePathViolation(title.type, pr.changedFiles);
1242
1279
  if (pathViolation !== void 0) findings.push(block2(pathViolation));
1243
1280
  const mayRetitle = !functional && title.type !== "ci";
package/dist/index.d.ts CHANGED
@@ -277,7 +277,7 @@ declare const COMMIT_TYPES: readonly ["feat", "fix", "docs", "chore", "refactor"
277
277
  type CommitType = (typeof COMMIT_TYPES)[number];
278
278
  /**
279
279
  * The only types that may carry `!`. Under semantic-release `!` cuts a major, so
280
- * it is reserved for shippable functional change (rmartz/dotfiles#1559).
280
+ * it is reserved for shippable functional change.
281
281
  */
282
282
  declare const FUNCTIONAL_TYPES: readonly ["feat", "fix", "perf", "revert"];
283
283
  interface ParsedTitle {
package/dist/index.js CHANGED
@@ -48,7 +48,7 @@ import {
48
48
  sensitiveBumps,
49
49
  statusBody,
50
50
  titleCheck
51
- } from "./chunk-TLGL2PTZ.js";
51
+ } from "./chunk-LWLZD5YW.js";
52
52
  export {
53
53
  AMBIGUOUS_INDICATORS,
54
54
  BLOCKED_LABEL,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rmartz/pr-policy",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "Read-only PR content classifiers — CI-change classification, title-type rules, and more — reported as one blocking pr-policy check-run. Distributed as a pinned Action kept current by Dependabot.",
5
5
  "keywords": [
6
6
  "pr-policy",