@antelopejs/tooling-configs 0.2.17 → 0.2.19
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 +35 -21
- package/dist/bin/api-diff.mjs +25 -14
- package/dist/bin/body-check.mjs +3 -3
- package/dist/bin/capture.d.mts +1 -0
- package/dist/bin/capture.mjs +559 -0
- package/dist/bin/check-size.mjs +3 -3
- package/dist/bin/checks.mjs +24 -6
- package/dist/bin/comment-proof.mjs +3 -3
- package/dist/bin/garden.mjs +229 -28
- package/dist/bin/lease.d.mts +1 -0
- package/dist/bin/lease.mjs +1053 -0
- package/dist/bin/ratchet.mjs +146 -100
- package/dist/bin/suppressions.mjs +5 -5
- package/dist/bin/sync.mjs +150 -176
- package/dist/bin/verify.mjs +238 -125
- package/dist/capture/index.d.mts +50 -0
- package/dist/capture/index.mjs +2 -0
- package/dist/{ci-workflow-ChW4He0r.mjs → ci-workflow-DVkpwauQ.mjs} +12 -0
- package/dist/{files-Bc036sJW.mjs → files-DJ0TeaTU.mjs} +10 -4
- package/dist/formal/index.d.mts +40 -0
- package/dist/formal/index.mjs +205 -0
- package/dist/oxc/anti-slop/index.mjs +717 -16
- package/dist/oxc/fmt.mjs +1 -1
- package/dist/oxc/guardrails/index.d.mts +1 -1
- package/dist/oxc/guardrails/index.mjs +93 -5
- package/dist/oxc/lint.d.mts +9 -0
- package/dist/oxc/lint.mjs +14 -3
- package/dist/{oxlint-Bltmk8-6.mjs → oxlint-DIV-lLSS.mjs} +7 -3
- package/dist/{package-DTxLPNDu.mjs → package-BRTjkzt5.mjs} +26 -1
- package/dist/{proof-stamp-w-3j47A-.mjs → proof-stamp-DDDC0J6l.mjs} +3 -3
- package/dist/{ratchet-DwRj9h4L.mjs → ratchet-BAcLRYuM.mjs} +194 -21
- package/dist/scenes-DZVXkcxS.mjs +104 -0
- package/dist/shared-igPpEDpS.mjs +622 -0
- package/dist/{size-DNtWruCO.mjs → size-DBatLT-F.mjs} +2 -2
- package/dist/{suppression-base-DAfCXwjL.mjs → suppression-base-9L8dlMQK.mjs} +36 -11
- package/dist/{suppression-budget-Bd2GqMYb.mjs → suppression-budget-C0SkPO5R.mjs} +56 -19
- package/dist/{suppressions-BD_f8f7L.mjs → suppressions-DM60NkvL.mjs} +1 -1
- package/dist/templates-CypDm-j9.mjs +121 -0
- package/dist/{typescript-BmS5BmrS.mjs → typescript-CM0LrVP7.mjs} +2 -2
- package/dist/verify/index.d.mts +6 -1
- package/package.json +29 -4
- package/dist/shared-CoUt4GUm.mjs +0 -73
package/dist/bin/garden.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { a as isString, c as object, d as optTime, f as parseJson, h as time, i as isObject, l as optNum, m as strings, n as children, o as list, p as str, r as flag, s as num, t as child, u as optStr } from "../json-CG2L7YFl.mjs";
|
|
3
3
|
import { n as runCliAsync } from "../cli-4Tv71vYk.mjs";
|
|
4
|
-
import { i as CI_RENOVATE_SYNC_REF, l as ciNodeCallers, n as CI_NODE_REF, r as CI_PATH, t as CI_CONTEXT, u as ciRenovateSyncCallers } from "../ci-workflow-
|
|
4
|
+
import { i as CI_RENOVATE_SYNC_REF, l as ciNodeCallers, n as CI_NODE_REF, r as CI_PATH, t as CI_CONTEXT, u as ciRenovateSyncCallers } from "../ci-workflow-DVkpwauQ.mjs";
|
|
5
5
|
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { dirname, join } from "node:path";
|
|
7
7
|
import { execFileSync, spawnSync } from "node:child_process";
|
|
8
|
-
import { parseArgs } from "node:util";
|
|
9
8
|
import { homedir, tmpdir } from "node:os";
|
|
9
|
+
import { parseArgs } from "node:util";
|
|
10
10
|
import { inflateRawSync } from "node:zlib";
|
|
11
11
|
//#region src/garden/api.ts
|
|
12
12
|
/** A GitHub or npm answer that is not a success. */
|
|
@@ -131,7 +131,7 @@ function createApi(token) {
|
|
|
131
131
|
return new Uint8Array(await (await get(path)).arrayBuffer());
|
|
132
132
|
},
|
|
133
133
|
async send(method, path, body) {
|
|
134
|
-
const response = await request(`${GITHUB}${path}`, {
|
|
134
|
+
const response = await request(`${GITHUB}${path}`, body === void 0 ? { method } : {
|
|
135
135
|
method,
|
|
136
136
|
body: JSON.stringify(body),
|
|
137
137
|
headers: { "Content-Type": "application/json" }
|
|
@@ -196,12 +196,26 @@ function checkRuns(value) {
|
|
|
196
196
|
}
|
|
197
197
|
function pullRequest(value) {
|
|
198
198
|
const source = object(value, "pull request");
|
|
199
|
+
const head = child(source, "head");
|
|
199
200
|
return {
|
|
200
201
|
number: num(source, "number"),
|
|
201
202
|
title: str(source, "title"),
|
|
202
203
|
author: optStr(child(source, "user"), "login") ?? "",
|
|
203
204
|
createdAt: time(source, "created_at"),
|
|
204
|
-
url: str(source, "html_url")
|
|
205
|
+
url: str(source, "html_url"),
|
|
206
|
+
head: optStr(head, "ref") ?? "",
|
|
207
|
+
headRepo: isObject(head.repo) ? optStr(head.repo, "full_name") : void 0,
|
|
208
|
+
headSha: optStr(head, "sha") ?? "",
|
|
209
|
+
base: optStr(child(source, "base"), "ref") ?? "",
|
|
210
|
+
merged: optStr(source, "merged_at") !== void 0
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
function branch(value) {
|
|
214
|
+
const source = object(value, "branch");
|
|
215
|
+
return {
|
|
216
|
+
name: str(source, "name"),
|
|
217
|
+
protected: flag(source, "protected"),
|
|
218
|
+
sha: str(child(source, "commit"), "sha")
|
|
205
219
|
};
|
|
206
220
|
}
|
|
207
221
|
function alert(value) {
|
|
@@ -321,6 +335,10 @@ var GardenContext = class {
|
|
|
321
335
|
packuments = new Memo();
|
|
322
336
|
removals = new Memo();
|
|
323
337
|
searches = new Memo();
|
|
338
|
+
branchLists = new Memo();
|
|
339
|
+
closed = new Memo();
|
|
340
|
+
commitTimes = new Memo();
|
|
341
|
+
cleanups = new Memo();
|
|
324
342
|
constructor(api) {
|
|
325
343
|
this.api = api;
|
|
326
344
|
}
|
|
@@ -407,6 +425,29 @@ var GardenContext = class {
|
|
|
407
425
|
openPulls(repo) {
|
|
408
426
|
return this.pulls.get(repo.name, async () => (await this.api.pages(`/repos/${ORG}/${repo.name}/pulls?state=open`)).map(pullRequest));
|
|
409
427
|
}
|
|
428
|
+
/** Every branch of the repository, protected ones flagged. */
|
|
429
|
+
branchList(repo) {
|
|
430
|
+
return this.branchLists.get(repo.name, async () => (await this.api.pages(`/repos/${ORG}/${repo.name}/branches`)).map(branch));
|
|
431
|
+
}
|
|
432
|
+
/** Closed and merged pull requests whose head is the branch of this repository, not a fork's namesake. */
|
|
433
|
+
closedPulls(repo, name) {
|
|
434
|
+
return this.closed.get(`${repo.name}:${name}`, async () => (await this.api.pages(`/repos/${ORG}/${repo.name}/pulls?state=closed&head=${ORG}:${encodeURIComponent(name)}`)).map(pullRequest).filter((pull) => pull.head === name && pull.headRepo === `AntelopeJS/${repo.name}`));
|
|
435
|
+
}
|
|
436
|
+
/** When the commit was committed, in milliseconds. */
|
|
437
|
+
commitTime(repo, sha) {
|
|
438
|
+
return this.commitTimes.get(`${repo.name}:${sha}`, async () => {
|
|
439
|
+
const body = object(await this.api.json(`/repos/${ORG}/${repo.name}/commits/${sha}`), "commit");
|
|
440
|
+
return time(child(child(body, "commit"), "committer"), "date");
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
/** Whether GitHub deletes a pull request's head branch once it merges. */
|
|
444
|
+
deletesBranchOnMerge(repo) {
|
|
445
|
+
return this.cleanups.get(repo.name, async () => {
|
|
446
|
+
const body = object(await this.api.json(`/repos/${ORG}/${repo.name}`), "repository");
|
|
447
|
+
if (!Object.hasOwn(body, "delete_branch_on_merge")) throw new Error("delete_branch_on_merge is not readable; merge settings need a token with contents write access");
|
|
448
|
+
return flag(body, "delete_branch_on_merge");
|
|
449
|
+
});
|
|
450
|
+
}
|
|
410
451
|
/** Open alerts, or undefined when Dependabot alerts are disabled for the repository. */
|
|
411
452
|
alerts(repo) {
|
|
412
453
|
return this.alertLists.get(repo.name, async () => {
|
|
@@ -674,7 +715,7 @@ async function perRepo(repos, scan) {
|
|
|
674
715
|
}
|
|
675
716
|
//#endregion
|
|
676
717
|
//#region src/garden/checks/ci-health.ts
|
|
677
|
-
const DAY$
|
|
718
|
+
const DAY$4 = 864e5;
|
|
678
719
|
const WORKFLOW = "ci.yml";
|
|
679
720
|
const RECENT_RUNS = 10;
|
|
680
721
|
const MIN_BASELINE = 5;
|
|
@@ -707,7 +748,7 @@ async function red(context, repo) {
|
|
|
707
748
|
const branch = await context.targetBranch(repo);
|
|
708
749
|
const runs = await context.workflowRuns(repo, WORKFLOW, branch);
|
|
709
750
|
const since = runs === void 0 ? void 0 : redSince(runs);
|
|
710
|
-
if (since === void 0 || context.api.now().getTime() - since.createdAt <= DAY$
|
|
751
|
+
if (since === void 0 || context.api.now().getTime() - since.createdAt <= DAY$4) return [];
|
|
711
752
|
return [finding({
|
|
712
753
|
repo: repo.name,
|
|
713
754
|
check: "red-branch",
|
|
@@ -717,7 +758,7 @@ async function red(context, repo) {
|
|
|
717
758
|
async function slow(context, repo) {
|
|
718
759
|
const branch = await context.targetBranch(repo);
|
|
719
760
|
const runs = await context.workflowRuns(repo, WORKFLOW, branch);
|
|
720
|
-
const horizon = context.api.now().getTime() - 30 * DAY$
|
|
761
|
+
const horizon = context.api.now().getTime() - 30 * DAY$4;
|
|
721
762
|
const passed = (runs ?? []).filter((run) => run.conclusion === "success" && run.createdAt >= horizon);
|
|
722
763
|
const baseline = passed.slice(RECENT_RUNS).map(duration);
|
|
723
764
|
if (passed.length <= RECENT_RUNS || baseline.length < MIN_BASELINE) return [];
|
|
@@ -743,6 +784,99 @@ const ciDuration = {
|
|
|
743
784
|
}
|
|
744
785
|
};
|
|
745
786
|
//#endregion
|
|
787
|
+
//#region src/garden/checks/branches.ts
|
|
788
|
+
const CHECK$2 = "stale-branches";
|
|
789
|
+
const SUBJECT = "branches";
|
|
790
|
+
const DAY$3 = 864e5;
|
|
791
|
+
const INACTIVE_DAYS = 30;
|
|
792
|
+
function day(time) {
|
|
793
|
+
return new Date(time).toISOString().slice(0, 10);
|
|
794
|
+
}
|
|
795
|
+
function hasOpenPull(facts) {
|
|
796
|
+
const { branch, open, repo } = facts;
|
|
797
|
+
return open.some((pull) => pull.base === branch.name || pull.head === branch.name && pull.headRepo === `AntelopeJS/${repo}`);
|
|
798
|
+
}
|
|
799
|
+
/** Decides one branch: the default, `next`, protected and open-PR branches always stay. */
|
|
800
|
+
async function classify(facts) {
|
|
801
|
+
const { branch, defaultBranch, closed, now } = facts;
|
|
802
|
+
if (branch.name === defaultBranch || branch.name === "next") return { kind: "keep" };
|
|
803
|
+
if (branch.protected || hasOpenPull(facts)) return { kind: "keep" };
|
|
804
|
+
const done = (await closed()).find((pull) => pull.headSha === branch.sha);
|
|
805
|
+
if (done !== void 0) return {
|
|
806
|
+
kind: "prune",
|
|
807
|
+
reason: `${done.merged ? "merged" : "closed"} PR #${done.number}`
|
|
808
|
+
};
|
|
809
|
+
const tip = await facts.tipTime();
|
|
810
|
+
return now - tip >= INACTIVE_DAYS * DAY$3 ? {
|
|
811
|
+
kind: "prune",
|
|
812
|
+
reason: `no commit since ${day(tip)}`
|
|
813
|
+
} : { kind: "keep" };
|
|
814
|
+
}
|
|
815
|
+
async function prunable(context, repo) {
|
|
816
|
+
const [branches, open] = await Promise.all([context.branchList(repo), context.openPulls(repo)]);
|
|
817
|
+
const now = context.api.now().getTime();
|
|
818
|
+
const prunes = [];
|
|
819
|
+
for (const branch of branches) {
|
|
820
|
+
const verdict = await classify({
|
|
821
|
+
branch,
|
|
822
|
+
defaultBranch: repo.defaultBranch,
|
|
823
|
+
open,
|
|
824
|
+
closed: () => context.closedPulls(repo, branch.name),
|
|
825
|
+
tipTime: () => context.commitTime(repo, branch.sha),
|
|
826
|
+
now,
|
|
827
|
+
repo: repo.name
|
|
828
|
+
});
|
|
829
|
+
if (verdict.kind === "prune") prunes.push({
|
|
830
|
+
repo: repo.name,
|
|
831
|
+
branch: branch.name,
|
|
832
|
+
reason: verdict.reason
|
|
833
|
+
});
|
|
834
|
+
}
|
|
835
|
+
return prunes;
|
|
836
|
+
}
|
|
837
|
+
function report(repo, prunes) {
|
|
838
|
+
if (!prunes.length) return [];
|
|
839
|
+
return [finding({
|
|
840
|
+
repo: repo.name,
|
|
841
|
+
check: CHECK$2,
|
|
842
|
+
subject: SUBJECT
|
|
843
|
+
}, prunes.map(({ branch, reason }) => `${branch} (${reason})`).join(", "), `No branch other than the default, next and protected ones is the head of a merged or closed PR, or has no open PR and no commit for ${INACTIVE_DAYS} days.`)];
|
|
844
|
+
}
|
|
845
|
+
/** Lists, per repository, the branches `--apply-prunes` would delete. */
|
|
846
|
+
const staleBranches = {
|
|
847
|
+
id: CHECK$2,
|
|
848
|
+
async run(context) {
|
|
849
|
+
return perRepo(await context.scope(), async (repo) => report(repo, await prunable(context, repo)));
|
|
850
|
+
}
|
|
851
|
+
};
|
|
852
|
+
/** The deletions behind each stale-branches finding, re-read from the API given so a branch that gained an open PR or a commit since the scan is kept; a repository whose read failed is never pruned. */
|
|
853
|
+
async function plannedPrunes(api, findings) {
|
|
854
|
+
const fresh = new GardenContext(api);
|
|
855
|
+
const flagged = new Set(findings.filter((entry) => entry.check === CHECK$2).map((entry) => entry.repo));
|
|
856
|
+
const prunes = [];
|
|
857
|
+
const failed = [];
|
|
858
|
+
const scope = await fresh.scope().catch((error) => {
|
|
859
|
+
failed.push(`organization listing: ${error instanceof Error ? error.message : String(error)}`);
|
|
860
|
+
return [];
|
|
861
|
+
});
|
|
862
|
+
for (const repo of scope) if (flagged.has(repo.name)) await prunable(fresh, repo).then((found) => prunes.push(...found), (error) => failed.push(`${repo.name}: ${error instanceof Error ? error.message : String(error)}`));
|
|
863
|
+
return {
|
|
864
|
+
prunes,
|
|
865
|
+
failed
|
|
866
|
+
};
|
|
867
|
+
}
|
|
868
|
+
function refPath(name) {
|
|
869
|
+
return name.split("/").map(encodeURIComponent).join("/");
|
|
870
|
+
}
|
|
871
|
+
/** Deletes each planned branch ref and nothing else; a failed deletion does not stop the rest and is returned. */
|
|
872
|
+
async function applyPrunes(api, prunes) {
|
|
873
|
+
const failed = [];
|
|
874
|
+
for (const prune of prunes) await api.send("DELETE", `/repos/${ORG}/${prune.repo}/git/refs/heads/${refPath(prune.branch)}`).catch((error) => {
|
|
875
|
+
failed.push(`${prune.repo} ${prune.branch}: ${error instanceof Error ? error.message : String(error)}`);
|
|
876
|
+
});
|
|
877
|
+
return failed;
|
|
878
|
+
}
|
|
879
|
+
//#endregion
|
|
746
880
|
//#region src/garden/npm.ts
|
|
747
881
|
const TOOLING_PACKAGE = "@antelopejs/tooling-configs";
|
|
748
882
|
function distTags(packument) {
|
|
@@ -826,6 +960,25 @@ async function cleanRatchet(context, repo) {
|
|
|
826
960
|
if (!(await context.tree(repo)).includes(GUARDRAILS_RATCHET) || !await context.removedInHistory(repo, GUARDRAILS_RATCHET)) return [];
|
|
827
961
|
return [problem(repo, "ratchet", `${GUARDRAILS_RATCHET} is back after the history deleted it.`, `${GUARDRAILS_RATCHET} is deleted again.`)];
|
|
828
962
|
}
|
|
963
|
+
const BRANCH_CLEANUP = "delete-branch-on-merge";
|
|
964
|
+
async function branchCleanup(context, repo) {
|
|
965
|
+
return await context.deletesBranchOnMerge(repo) ? [] : [problem(repo, BRANCH_CLEANUP, "delete_branch_on_merge is off, so merged head branches stay behind.", "delete_branch_on_merge is on; antelopejs-garden --apply turns it on.")];
|
|
966
|
+
}
|
|
967
|
+
/** Reported as a conformance finding, but read apart so a token that cannot see merge settings hides no other finding. */
|
|
968
|
+
const deleteBranchOnMerge = {
|
|
969
|
+
id: BRANCH_CLEANUP,
|
|
970
|
+
async run(context) {
|
|
971
|
+
return perRepo(await context.scope(), (repo) => branchCleanup(context, repo));
|
|
972
|
+
}
|
|
973
|
+
};
|
|
974
|
+
/** Turns `delete_branch_on_merge` on for each repository a finding reports it off on, and writes nothing else; returns the writes that failed. */
|
|
975
|
+
async function applySettings(api, findings) {
|
|
976
|
+
const failed = [];
|
|
977
|
+
for (const entry of findings) if (entry.check === CHECK$1 && entry.subject === BRANCH_CLEANUP) await api.send("PATCH", `/repos/${ORG}/${entry.repo}`, { delete_branch_on_merge: true }).catch((error) => {
|
|
978
|
+
failed.push(`${entry.repo}: ${error instanceof Error ? error.message : String(error)}`);
|
|
979
|
+
});
|
|
980
|
+
return failed;
|
|
981
|
+
}
|
|
829
982
|
async function scan(context, repo) {
|
|
830
983
|
return [
|
|
831
984
|
...await ciCaller(context, repo),
|
|
@@ -1319,34 +1472,48 @@ function reasons(repo, findings) {
|
|
|
1319
1472
|
const own = findings.filter((entry) => entry.repo === repo);
|
|
1320
1473
|
return [...own.some((entry) => entry.check === "conformance" && entry.subject === "ratchet") ? ["the ratchet file is back on a Clean repository"] : [], ...own.some((entry) => entry.check === "next-governance") ? ["governance drift"] : []];
|
|
1321
1474
|
}
|
|
1322
|
-
|
|
1475
|
+
async function pauseFor(context, repo, findings) {
|
|
1476
|
+
if (await context.variable(repo, "NEXT_AUTOMERGE") !== "on") return [];
|
|
1477
|
+
const triggers = reasons(repo.name, findings);
|
|
1478
|
+
const runs = await context.targetBranch(repo) === "next" ? await context.workflowRuns(repo, "ci.yml", "next") : void 0;
|
|
1479
|
+
if (runs !== void 0 && redSince(runs) !== void 0) triggers.unshift("checks is red on next after a merge");
|
|
1480
|
+
return triggers.length ? [{
|
|
1481
|
+
repo: repo.name,
|
|
1482
|
+
from: "on",
|
|
1483
|
+
to: PAUSED,
|
|
1484
|
+
reason: triggers.join("; ")
|
|
1485
|
+
}] : [];
|
|
1486
|
+
}
|
|
1487
|
+
/** Repositories where `NEXT_AUTOMERGE` is `on` and a stop-the-line trigger fired; a repository whose read failed is returned in `failed`, not paused. */
|
|
1323
1488
|
async function plannedPauses(context, findings) {
|
|
1324
1489
|
const pauses = [];
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
});
|
|
1336
|
-
}
|
|
1337
|
-
return pauses;
|
|
1490
|
+
const failed = [];
|
|
1491
|
+
const scope = await context.scope().catch((error) => {
|
|
1492
|
+
failed.push(`organization listing: ${error instanceof Error ? error.message : String(error)}`);
|
|
1493
|
+
return [];
|
|
1494
|
+
});
|
|
1495
|
+
for (const repo of scope) await pauseFor(context, repo, findings).then((found) => pauses.push(...found), (error) => failed.push(`${repo.name}: ${error instanceof Error ? error.message : String(error)}`));
|
|
1496
|
+
return {
|
|
1497
|
+
pauses,
|
|
1498
|
+
failed
|
|
1499
|
+
};
|
|
1338
1500
|
}
|
|
1339
|
-
/** Writes the one repository variable and nothing else. */
|
|
1501
|
+
/** Writes the one repository variable and nothing else; a refused write does not stop the rest and is returned. */
|
|
1340
1502
|
async function applyPauses(api, pauses) {
|
|
1503
|
+
const failed = [];
|
|
1341
1504
|
for (const pause of pauses) await api.send("PATCH", `/repos/${ORG}/${pause.repo}/actions/variables/${AUTOMERGE}`, {
|
|
1342
1505
|
name: AUTOMERGE,
|
|
1343
1506
|
value: pause.to
|
|
1507
|
+
}).catch((error) => {
|
|
1508
|
+
failed.push(`${pause.repo}: ${error instanceof Error ? error.message : String(error)}`);
|
|
1344
1509
|
});
|
|
1510
|
+
return failed;
|
|
1345
1511
|
}
|
|
1346
1512
|
//#endregion
|
|
1347
1513
|
//#region src/garden/run.ts
|
|
1348
1514
|
const CHECKS = [
|
|
1349
1515
|
conformance,
|
|
1516
|
+
deleteBranchOnMerge,
|
|
1350
1517
|
redBranch,
|
|
1351
1518
|
ciDuration,
|
|
1352
1519
|
advisories,
|
|
@@ -1364,12 +1531,13 @@ const CHECKS = [
|
|
|
1364
1531
|
templateCanary,
|
|
1365
1532
|
webBuild,
|
|
1366
1533
|
linkRot,
|
|
1367
|
-
captureScenes
|
|
1534
|
+
captureScenes,
|
|
1535
|
+
staleBranches
|
|
1368
1536
|
];
|
|
1369
1537
|
function compare(a, b) {
|
|
1370
1538
|
return a.key < b.key ? -1 : a.key > b.key ? 1 : 0;
|
|
1371
1539
|
}
|
|
1372
|
-
/** Runs every check, plans the pauses and applies
|
|
1540
|
+
/** Runs every check, plans the pauses and prunes, and applies each only when asked. */
|
|
1373
1541
|
async function garden(api, options) {
|
|
1374
1542
|
const context = new GardenContext(api);
|
|
1375
1543
|
const found = [];
|
|
@@ -1392,13 +1560,40 @@ async function garden(api, options) {
|
|
|
1392
1560
|
failures.push(failure);
|
|
1393
1561
|
}
|
|
1394
1562
|
const findings = [...new Map(found.map((entry) => [entry.key, entry])).values()].sort(compare);
|
|
1395
|
-
const
|
|
1396
|
-
|
|
1563
|
+
const planned = await plannedPauses(context, findings);
|
|
1564
|
+
const pauses = planned.pauses.sort((a, b) => a.repo < b.repo ? -1 : 1);
|
|
1565
|
+
const pauseFailures = options.applyPauses ? await applyPauses(api, pauses) : [];
|
|
1566
|
+
const { prunes, failed } = await plannedPrunes(api, findings);
|
|
1567
|
+
const late = [
|
|
1568
|
+
...planned.failed.map((reason) => ({
|
|
1569
|
+
check: "plan-pauses",
|
|
1570
|
+
reason
|
|
1571
|
+
})),
|
|
1572
|
+
...pauseFailures.map((reason) => ({
|
|
1573
|
+
check: "apply-pauses",
|
|
1574
|
+
reason
|
|
1575
|
+
})),
|
|
1576
|
+
...failed.map((reason) => ({
|
|
1577
|
+
check: "plan-prunes",
|
|
1578
|
+
reason
|
|
1579
|
+
})),
|
|
1580
|
+
...options.apply === true ? (await applySettings(api, findings)).map((reason) => ({
|
|
1581
|
+
check: "apply",
|
|
1582
|
+
reason
|
|
1583
|
+
})) : [],
|
|
1584
|
+
...options.applyPrunes === true ? (await applyPrunes(api, prunes)).map((reason) => ({
|
|
1585
|
+
check: "apply-prunes",
|
|
1586
|
+
reason
|
|
1587
|
+
})) : []
|
|
1588
|
+
];
|
|
1589
|
+
failures.push(...late);
|
|
1590
|
+
skipped.push(...late);
|
|
1397
1591
|
return {
|
|
1398
1592
|
report: {
|
|
1399
1593
|
generatedAt: api.now().toISOString(),
|
|
1400
1594
|
findings,
|
|
1401
1595
|
pauses,
|
|
1596
|
+
prunes,
|
|
1402
1597
|
skipped: skipped.sort((a, b) => a.check < b.check ? -1 : 1)
|
|
1403
1598
|
},
|
|
1404
1599
|
failures
|
|
@@ -1413,9 +1608,15 @@ function failureLines(outcome) {
|
|
|
1413
1608
|
await runCliAsync(async () => {
|
|
1414
1609
|
const { values } = parseArgs({ options: {
|
|
1415
1610
|
json: { type: "boolean" },
|
|
1416
|
-
"apply-pauses": { type: "boolean" }
|
|
1611
|
+
"apply-pauses": { type: "boolean" },
|
|
1612
|
+
apply: { type: "boolean" },
|
|
1613
|
+
"apply-prunes": { type: "boolean" }
|
|
1417
1614
|
} });
|
|
1418
|
-
const outcome = await garden(createApi(ghToken()), {
|
|
1615
|
+
const outcome = await garden(createApi(ghToken()), {
|
|
1616
|
+
applyPauses: values["apply-pauses"] === true,
|
|
1617
|
+
apply: values.apply === true,
|
|
1618
|
+
applyPrunes: values["apply-prunes"] === true
|
|
1619
|
+
});
|
|
1419
1620
|
if (values.json) process.stdout.write(`${JSON.stringify(outcome.report, null, 2)}\n`);
|
|
1420
1621
|
else for (const line of failureLines(outcome)) process.stdout.write(`${line}\n`);
|
|
1421
1622
|
return outcome.failures.length ? 1 : 0;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|