@mark1russell7/conventions 0.12.2 → 0.13.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.
package/README.md CHANGED
@@ -76,7 +76,7 @@ The field `conventions` of the root `package.json` sets the rules. An exception
76
76
  | Field | What it sets |
77
77
  |---|---|
78
78
  | `rules.<id>.off` | The rule does not start. The text is the reason, and the output shows it. |
79
- | `rules.<id>.ignore` | The globs of the files whose breaks the rule does not report. It needs `reason`. |
79
+ | `rules.<id>.ignore` | The globs of the files whose breaks the rule does not report. It needs `reason`. On a pull request or with `--base`, a file that the change adds is not ignored: `ignore` keeps only the exceptions that exist. A renamed file is not added. |
80
80
  | `rules.<id>.reason` | The reason of `ignore` or of a changed option. |
81
81
  | `rules.<id>.<option>` | An option of the rule. It needs `reason`, because a changed option can make a rule weaker. `conventions --list` shows the options and their values. |
82
82
  | `packages` | The globs of the package folders. The default is the `packages` list of `pnpm-workspace.yaml`. |
package/build/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { c as runCli } from "./run-D6OdZDaQ.js";
2
+ import { c as runCli } from "./run-C-8IoeoO.js";
3
3
  // src/cli.ts
4
4
  try {
5
5
  process.exitCode = runCli(process.argv.slice(2), {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/rule.ts","../src/config.ts","../src/rules/cue-preset.ts","../src/rules/gate-trigger.ts","../src/rules/main-check.ts","../src/rules/no-build-output.ts","../src/rules/no-local-paths.ts","../src/rules/pinned-git-deps.ts","../src/rules/release-files.ts","../src/rules/required-scripts.ts","../src/rules/roadmap-parses.ts","../src/rules/runner-budget.ts","../src/rules/source-main.ts","../src/rules/tests-required.ts","../src/rules/tsconfig-test.ts","../src/rules/typed-files.ts","../src/rules/typed-scripts.ts","../src/rules/trust-policy.ts","../src/rules/workspace-protocol.ts","../src/rules/index.ts","../src/run.ts","../src/workspace.ts"],"mappings":";UASiB;WACN;WACA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qBCcf,cAAc;qBCjCd,iBAAiB;;wBCqCd,cAAc;qBAajB,eAAe;;;;;;wBC3DZ,eAAe,oBAAoB;;wBAUnC,mBAAmB;qBAsJtB,cAAc;;wBCrKX,QAAQ;;wBAQR,aAAa;qBAKhB,YAAY;qBCkBZ,eAAe;;wBCpBZ,SAAS,0BAA0B;qBAKtC,cAAc;;wBCmDX,gBAAgB;;;;;wBAmChB,UACd,SAAS,SAAS,0BAClB,cACA,OAAM;qBAkRK,YAAY;qBC/VZ,cAAc;;qBC3Bd;;qBAGA;qBA6DA,aAAa;qBCnEb,mBAAmB;;qBCenB,gBAAgB;;UCXZ;WACN;WACA;WACA;;WAEA;WACA,iBAAiB;;WAEjB;;WAEA;;;UAIM;WACN,gBAAgB;;WAEhB;;;UAIM;;WAEN;;WAEA;;WAEA;WACA,MAAM,SAAS;;WAEf,iBAAiB;;;wBAaZ,WAAW,cAAc,iBAAgB,SAAiB;;wBAO1D,cAAc,cAAc,QAAQ,mBAAmB,UAAS,KAAK,gCAAqC;;wBAwB1G,UAAU,SAAS,eAAe;;UAoCjC;;WAEN;;WAEA;;WAEA,QAAQ;;;;;;;wBAWH,OAAO,SAAS,eAAe;;wBAyC/B,aAAa,QAAQ;;wBA0BrB,gBAAgB,QAAQ;;wBAsBxB,YAAY,QAAQ;;wBAYpB,UAAU,QAAQ,+BAA+B,iBAAgB;;UAkBhE;WACN;WACA,KAAK,SAAS;WACd,SAAS;WACT,SAAS;;;qBAIP;;wBA0BG,OAAO,yBAAyB,IAAI;;;;;;wBC9QpC,aAAa,eAAe;;;;;wBAsD5B,YAAY,cAAc;;;;;;wBA8B1B,eAAe;;;;;;;wBAwCf,eAAe,cAAc"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/rule.ts","../src/config.ts","../src/rules/cue-preset.ts","../src/rules/gate-trigger.ts","../src/rules/main-check.ts","../src/rules/no-build-output.ts","../src/rules/no-local-paths.ts","../src/rules/pinned-git-deps.ts","../src/rules/release-files.ts","../src/rules/required-scripts.ts","../src/rules/roadmap-parses.ts","../src/rules/runner-budget.ts","../src/rules/source-main.ts","../src/rules/tests-required.ts","../src/rules/tsconfig-test.ts","../src/rules/typed-files.ts","../src/rules/typed-scripts.ts","../src/rules/trust-policy.ts","../src/rules/workspace-protocol.ts","../src/rules/index.ts","../src/run.ts","../src/workspace.ts"],"mappings":";UASiB;WACN;WACA;WACA;;;UAIM;;WAEN;;WAEA;WACA;;WAEA;;WAEA,iBAAiB;;;;;;UAOX;;WAEN;;WAEA;;WAEA;;;wBAIK,YAAY,cAAc,cAAc;;KAQ5C;;KAGA,UAAU,SAAS,eAAe;;UAG7B;WACN;WACA,SAAS;WACT;;;KAIC,WAAW,SAAS;;UAGf;;WAEN;;WAEA;;WAEA;;WAEA;WACA,UAAU;;;UAIJ;;WAEN;;WAEA,aAAa;;WAEb,mBAAmB;;WAEnB,KAAK,SAAS;;WAEd;;EAET;;EAEA,IAAI;;;KAIM,uBAAuB;WAAqB;;;UAGvC;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA,kBAAkB;;WAElB,SAAS,SAAS,eAAe;EAC1C,MAAM,SAAS,aAAa,SAAS,UAAU;;;qBAIpC;;wBAGG,aAAa,UAAU,UAAU;;wBAOjC,OAAO,cAAc,gBAAgB;;wBAOrC,QAAQ,cAAc,eAAe;;qBAMxC,WAAY,gBAAgB;;qBAG5B,YAAa;;wBAGV,WAAW,cAAc;;;;;;wBASzB,WAAW;;wBA2BX,UAAU;;wBAUV,OAAO,cAAc;;qBAOxB,UAAW,aAAa;;;;;wBAMrB,aAAa,SAAS,KAAK,oDAAoD;;UCrM9E;;WAEN;;WAEA;;WAEA;;WAEA,SAAS;;;UAIH;;WAEN;;WAEA,OAAO,SAAS,eAAe;;;wBAW1B,eAAe,MAAM,OAAO;;;;;;;wBAU5B,YAAY,gBAAgB,gBAAgB,SAAS;;qBCnCxD;qBA2FA,WAAW;;UCtFP;WACN;WACA;WACA;;;wBAIK,cAAc,eAAe;;qBAo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AAc;;;;;;wBA8B1B,eAAe;;;;;;;wBAwCf,eAAe,cAAc"}
package/build/index.js CHANGED
@@ -1 +1 @@
1
- export { U as ACTIONS_COMMIT, I as DEFAULT_ALLOWED, X as DEPENDENCY_FIELDS, L as HOME_PATTERNS, p as IGNORE_AFTER, B as REAL_COMPARE, d as RULES, J as STRICT_OPTIONS, m as TRAIN_SCOPES, t as USAGE, n as annotations, Z as cleanPath, Q as codePackages, _ as configsOfScript, W as convertGate, r as createContext, Y as cuePreset, pt as defaultOptions, i as formatResult, G as gateTrigger, lt as globFolders, ut as globToRegExp, $ as hasFile, V as hasImportMetaMain, x as hasTests, et as inFolder, N as isGitSpecifier, P as isPinned, C as isSourcePath, tt as keyLine, nt as lineOf, a as listRules, H as mainCheck, rt as matchesAny, z as noBuildOutput, R as noLocalPaths, dt as packageFolders, mt as parseConfig, it as parseJsonc, w as pathsOf, F as pinnedGitDeps, K as prPathFilters, o as readConfig, at as readJsonc, M as releaseFiles, ot as replaceLine, E as repositoryOfRemote, j as requiredScripts, k as roadmapOfLine, A as roadmapParses, s as runChecks, c as runCli, l as runFix, st as runGit, D as runnerBudget, O as scheduleMinute, v as scriptsOf, T as sourceMain, ct as specifiersOf, u as summaryMarkdown, q as summaryName, b as testsRequired, h as trustPolicy, S as tsconfigTest, y as typedFiles, g as typedScripts, ft as workspaceGlobs, f as workspaceProtocol } from "./run-D6OdZDaQ.js";
1
+ export { U as ACTIONS_COMMIT, I as DEFAULT_ALLOWED, X as DEPENDENCY_FIELDS, L as HOME_PATTERNS, p as IGNORE_AFTER, B as REAL_COMPARE, d as RULES, J as STRICT_OPTIONS, m as TRAIN_SCOPES, t as USAGE, n as annotations, Z as cleanPath, Q as codePackages, _ as configsOfScript, W as convertGate, r as createContext, Y as cuePreset, pt as defaultOptions, i as formatResult, G as gateTrigger, lt as globFolders, ut as globToRegExp, $ as hasFile, V as hasImportMetaMain, x as hasTests, et as inFolder, N as isGitSpecifier, P as isPinned, C as isSourcePath, tt as keyLine, nt as lineOf, a as listRules, H as mainCheck, rt as matchesAny, z as noBuildOutput, R as noLocalPaths, dt as packageFolders, mt as parseConfig, it as parseJsonc, w as pathsOf, F as pinnedGitDeps, K as prPathFilters, o as readConfig, at as readJsonc, M as releaseFiles, ot as replaceLine, E as repositoryOfRemote, j as requiredScripts, k as roadmapOfLine, A as roadmapParses, s as runChecks, c as runCli, l as runFix, st as runGit, D as runnerBudget, O as scheduleMinute, v as scriptsOf, T as sourceMain, ct as specifiersOf, u as summaryMarkdown, q as summaryName, b as testsRequired, h as trustPolicy, S as tsconfigTest, y as typedFiles, g as typedScripts, ft as workspaceGlobs, f as workspaceProtocol } from "./run-C-8IoeoO.js";
@@ -1321,11 +1321,7 @@ const pinnedGitDeps = {
1321
1321
  return breaks;
1322
1322
  }
1323
1323
  };
1324
- // src/rules/release-files.ts
1325
- /**
1326
- * The rule `release-files`: a pull request changes a file of the release flow only with a reason
1327
- * that everyone can see.
1328
- */
1324
+ // src/change.ts
1329
1325
  /** This function gives the range of the change: the option `--base`, or the merge commit of a pull request. */
1330
1326
  function rangeOf(context) {
1331
1327
  if (context.base !== void 0) {
@@ -1361,6 +1357,28 @@ function rangeOf(context) {
1361
1357
  ends: ["HEAD^1", "HEAD^2"]
1362
1358
  };
1363
1359
  }
1360
+ /**
1361
+ * This function gives the files that the change adds, relative to the root, with `/`. A renamed file is not added.
1362
+ * With no change (no base and no pull request), it gives undefined.
1363
+ */
1364
+ function addedFiles(context) {
1365
+ const range = rangeOf(context);
1366
+ if ("skipped" in range) return void 0;
1367
+ const out = context.git([
1368
+ "diff",
1369
+ "--name-only",
1370
+ "--find-renames",
1371
+ "--diff-filter=A",
1372
+ ...range.diff
1373
+ ]);
1374
+ if (out === void 0) return void 0;
1375
+ return new Set(out.split(/\r?\n/).filter((file) => file !== ""));
1376
+ }
1377
+ // src/rules/release-files.ts
1378
+ /**
1379
+ * The rule `release-files`: a pull request changes a file of the release flow only with a reason
1380
+ * that everyone can see.
1381
+ */
1364
1382
  /** This function gives the pull request of the event file of GitHub Actions. With no event file, the body is empty. */
1365
1383
  function pullRequestOf(context) {
1366
1384
  const file = context.env["GITHUB_EVENT_PATH"];
@@ -1383,7 +1401,7 @@ const releaseFiles = {
1383
1401
  id: "release-files",
1384
1402
  title: "A pull request changes `.github/workflows/release.yml` or `scripts/release/` only with a `Release-Edit: <reason>` line.",
1385
1403
  reason: "The release flow publishes to npm with trusted publishing. A change of its files by a session that does not own the release can stop or break each release.",
1386
- fix: "Revert the change of the release files. When the owner asked for the change, add the line `Release-Edit: <reason>` to the last commit message or to the body of the pull request.",
1404
+ fix: "Revert the change of the release files. When the owner asked for the change, add the line `Release-Edit: <reason>` to the last commit message or to the body of the pull request. A re-run of a job reads the body of the event that started the run, so after a change of the body, push a commit.",
1387
1405
  sources: [
1388
1406
  {
1389
1407
  repo: "coeval",
@@ -3659,7 +3677,13 @@ function runChecks(options) {
3659
3677
  });
3660
3678
  continue;
3661
3679
  }
3662
- const breaks = outcome.filter((item) => !matchesAny(item.file, ruleConfig.ignore));
3680
+ const added = ruleConfig.ignore.length > 0 ? addedFiles(context) : void 0;
3681
+ const breaks = [];
3682
+ for (const item of outcome) if (!matchesAny(item.file, ruleConfig.ignore)) breaks.push(item);
3683
+ else if (added?.has(item.file) === true) breaks.push({
3684
+ ...item,
3685
+ message: `${item.message} The change adds this file, so \`ignore\` does not cover it.`
3686
+ });
3663
3687
  const ignored = outcome.length - breaks.length;
3664
3688
  const note = ruleConfig.reason === void 0 ? {} : { note: ruleConfig.reason };
3665
3689
  results.push({
@@ -3910,4 +3934,4 @@ function runCli(args, io) {
3910
3934
  }
3911
3935
  export { hasFile as $, roadmapParses as A, REAL_COMPARE as B, isSourcePath as C, runnerBudget as D, repositoryOfRemote as E, pinnedGitDeps as F, gateTrigger as G, mainCheck as H, DEFAULT_ALLOWED as I, STRICT_OPTIONS as J, prPathFilters as K, HOME_PATTERNS as L, releaseFiles as M, isGitSpecifier as N, scheduleMinute as O, isPinned as P, codePackages as Q, noLocalPaths as R, tsconfigTest as S, sourceMain as T, ACTIONS_COMMIT as U, hasImportMetaMain as V, convertGate as W, DEPENDENCY_FIELDS as X, cuePreset as Y, cleanPath as Z, configsOfScript as _, listRules as a, readJsonc as at, testsRequired as b, runCli as c, specifiersOf as ct, RULES as d, packageFolders as dt, inFolder as et, workspaceProtocol as f, workspaceGlobs as ft, typedScripts as g, trustPolicy as h, formatResult as i, parseJsonc as it, requiredScripts as j, roadmapOfLine as k, runFix as l, globFolders as lt, TRAIN_SCOPES as m, parseConfig as mt, annotations as n, lineOf as nt, readConfig as o, replaceLine as ot, IGNORE_AFTER as p, defaultOptions as pt, summaryName as q, createContext as r, matchesAny as rt, runChecks as s, runGit as st, USAGE as t, keyLine as tt, summaryMarkdown as u, globToRegExp as ut, scriptsOf as v, pathsOf as w, hasTests as x, typedFiles as y, noBuildOutput as z };
3912
3936
 
3913
- //# sourceMappingURL=run-D6OdZDaQ.js.map
3937
+ //# sourceMappingURL=run-C-8IoeoO.js.map