@mark1russell7/conventions 0.49.1 → 0.49.3
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 +6 -0
- package/build/cli.js +1 -1
- package/build/index.d.ts +127 -50
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -2
- package/build/{run-C0inJi_2.js → run-DyUvPasP.js} +307 -52
- package/build/run-DyUvPasP.js.map +1 -0
- package/package.json +2 -1
- package/build/run-C0inJi_2.js.map +0 -1
|
@@ -4,9 +4,10 @@ import { createRequire } from "node:module";
|
|
|
4
4
|
import { spawnSync } from "node:child_process";
|
|
5
5
|
import { appendFileSync, chmodSync, existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { basename, delimiter, dirname, extname, isAbsolute, join, posix, relative, resolve } from "node:path";
|
|
7
|
+
import { parseAllDocuments } from "yaml";
|
|
8
|
+
import { errorMessage } from "@mark1russell7/text";
|
|
7
9
|
import { SECRET_SHAPES, findSecretShapes, findSecretShapesInValue, redactSecretShapes } from "@mark1russell7/text/redact";
|
|
8
10
|
import { createHash } from "node:crypto";
|
|
9
|
-
import { parseAllDocuments } from "yaml";
|
|
10
11
|
// src/config.ts
|
|
11
12
|
/** The fields of the configuration of a rule that are not options. */
|
|
12
13
|
const RULE_FIELDS = [
|
|
@@ -15,6 +16,10 @@ const RULE_FIELDS = [
|
|
|
15
16
|
"generated",
|
|
16
17
|
"reason"
|
|
17
18
|
];
|
|
19
|
+
/**
|
|
20
|
+
* This function tells if a value is a record: an object that is not a list. The parser reader of `workflow.ts` uses it
|
|
21
|
+
* too. The home of this check is the planned entry `/read` of `@mark1russell7/optional`.
|
|
22
|
+
*/
|
|
18
23
|
const isObject$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
19
24
|
const isStrings = (value) => Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
20
25
|
/** This function gives the options of a rule with their defaults. */
|
|
@@ -120,6 +125,11 @@ function replaceLine(text, line, lines) {
|
|
|
120
125
|
all.splice(line - 1, 1, ...lines);
|
|
121
126
|
return all.join(eol);
|
|
122
127
|
}
|
|
128
|
+
/** This function gives the text of the file of each `<commit>:<path>`, or undefined, in one start of git when the context can. */
|
|
129
|
+
function showFiles(context, specs) {
|
|
130
|
+
if (specs.length === 0) return [];
|
|
131
|
+
return context.gitShow !== void 0 ? context.gitShow(specs) : specs.map((spec) => context.git(["show", spec]));
|
|
132
|
+
}
|
|
123
133
|
/** The days from the release of a new rule to its day `failsFrom`, at the least. In this time the owners fix the breaks. */
|
|
124
134
|
const RULE_WARN_DAYS = 14;
|
|
125
135
|
/** This function tells if the environment is a CI run: `CI` is `true` or `1`, or `GITHUB_ACTIONS` is `true`. */
|
|
@@ -194,6 +204,53 @@ function readJsonc(file) {
|
|
|
194
204
|
return;
|
|
195
205
|
}
|
|
196
206
|
}
|
|
207
|
+
/**
|
|
208
|
+
* This function gives the text of the blob of each `<commit>:<path>` in `root`, with one start of `git cat-file --batch`.
|
|
209
|
+
* It gives undefined for each name that git does not have or that is not a file. A name with a line break goes to
|
|
210
|
+
* `git show`.
|
|
211
|
+
*/
|
|
212
|
+
function runGitShow(root, specs) {
|
|
213
|
+
const batch = specs.filter((spec) => !/[\r\n]/.test(spec));
|
|
214
|
+
let texts = [];
|
|
215
|
+
if (batch.length > 0) {
|
|
216
|
+
const result = spawnSync("git", ["cat-file", "--batch"], {
|
|
217
|
+
cwd: root,
|
|
218
|
+
input: `${batch.join("\n")}\n`,
|
|
219
|
+
maxBuffer: 268435456,
|
|
220
|
+
windowsHide: true
|
|
221
|
+
});
|
|
222
|
+
texts = result.error || result.status !== 0 ? batch.map(() => void 0) : parseCatFileBatch(result.stdout, batch.length);
|
|
223
|
+
}
|
|
224
|
+
const indexOf = new Map(batch.map((spec, index) => [spec, index]));
|
|
225
|
+
return specs.map((spec) => {
|
|
226
|
+
const index = indexOf.get(spec);
|
|
227
|
+
return index !== void 0 && index < texts.length ? texts[index] : runGit(root, ["show", spec]);
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* This function reads the output of `git cat-file --batch` for `count` names. It gives the text of each blob, or
|
|
232
|
+
* undefined for a name that git does not have or that is not a blob. It gives fewer than `count` entries when the output
|
|
233
|
+
* ends early.
|
|
234
|
+
*/
|
|
235
|
+
function parseCatFileBatch(out, count) {
|
|
236
|
+
const data = Buffer.from(out.buffer, out.byteOffset, out.byteLength);
|
|
237
|
+
const texts = [];
|
|
238
|
+
let at = 0;
|
|
239
|
+
while (texts.length < count) {
|
|
240
|
+
const end = data.indexOf(10, at);
|
|
241
|
+
if (end < 0) break;
|
|
242
|
+
const header = data.toString("utf8", at, end).split(" ");
|
|
243
|
+
at = end + 1;
|
|
244
|
+
const size = Number(header.at(-1));
|
|
245
|
+
if (header.length !== 3 || !/^[0-9a-f]+$/.test(header[0] ?? "") || !Number.isInteger(size)) {
|
|
246
|
+
texts.push(void 0);
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
texts.push(header[1] === "blob" ? data.toString("utf8", at, at + size) : void 0);
|
|
250
|
+
at += size + 1;
|
|
251
|
+
}
|
|
252
|
+
return texts;
|
|
253
|
+
}
|
|
197
254
|
/** This function starts git in `root` with `args`, and gives its output, or undefined when git fails. */
|
|
198
255
|
function runGit(root, args) {
|
|
199
256
|
const result = spawnSync("git", [...args], {
|
|
@@ -1258,9 +1315,13 @@ const cuePreset = {
|
|
|
1258
1315
|
};
|
|
1259
1316
|
// src/workflow.ts
|
|
1260
1317
|
/**
|
|
1261
|
-
*
|
|
1262
|
-
*
|
|
1263
|
-
*
|
|
1318
|
+
* The readers of GitHub workflow files. The rules that read workflows share them.
|
|
1319
|
+
*
|
|
1320
|
+
* - The line reader reads by the indent of the lines. It knows the block form, the inline values of keys and the block
|
|
1321
|
+
* scalars (`|` and `>`) that the workflows of the template use. `readWorkflow` gives the parts of a shared workflow
|
|
1322
|
+
* that the site of the template shows.
|
|
1323
|
+
* - `parseWorkflow` reads with the YAML parser of the package `yaml`. It gives the facts that a security gate needs: the
|
|
1324
|
+
* triggers, the permissions, the secrets that each job reads, and the steps. A gate uses this reader, not the line reader.
|
|
1264
1325
|
*/
|
|
1265
1326
|
/** A workflow file. */
|
|
1266
1327
|
const WORKFLOW$1 = /^\.github\/workflows\/[^/]+\.ya?ml$/;
|
|
@@ -1566,6 +1627,166 @@ function readAction(file, text) {
|
|
|
1566
1627
|
jobs
|
|
1567
1628
|
};
|
|
1568
1629
|
}
|
|
1630
|
+
/** This constant is the options of the parser. With `prettyErrors`, each error has its line and its column. */
|
|
1631
|
+
const PARSE = { prettyErrors: true };
|
|
1632
|
+
/** This function gives the errors of the parser for each document of a text. */
|
|
1633
|
+
function faultsOf(documents) {
|
|
1634
|
+
const faults = [];
|
|
1635
|
+
for (const document of documents) for (const error of document.errors) {
|
|
1636
|
+
const at = error.linePos?.[0];
|
|
1637
|
+
faults.push({
|
|
1638
|
+
line: at?.line ?? 1,
|
|
1639
|
+
column: at?.col ?? 1,
|
|
1640
|
+
message: (error.message.split("\n")[0] ?? error.code).replace(/:$/, "")
|
|
1641
|
+
});
|
|
1642
|
+
}
|
|
1643
|
+
return faults;
|
|
1644
|
+
}
|
|
1645
|
+
/** This function gives the faults of a YAML text. A text with no fault gives an empty list. */
|
|
1646
|
+
function yamlFaults(text) {
|
|
1647
|
+
return faultsOf(parseAllDocuments(text, PARSE));
|
|
1648
|
+
}
|
|
1649
|
+
/** This function gives the text of a value of the parser: a string as it is, and another value as JSON text. */
|
|
1650
|
+
const textOf = (value) => typeof value === "string" ? value : JSON.stringify(value) ?? "";
|
|
1651
|
+
/** This function gives the text of a key that can be absent, with no space at its ends. No value gives an empty text. */
|
|
1652
|
+
const optionalText = (value) => value === void 0 || value === null ? "" : textOf(value).trim();
|
|
1653
|
+
/** This function gives the values of a key that holds one value or a list of values. */
|
|
1654
|
+
const listValues = (value) => value === void 0 || value === null ? [] : Array.isArray(value) ? value.map(textOf) : [textOf(value)];
|
|
1655
|
+
/** This function gives the permissions of a workflow or of a job. */
|
|
1656
|
+
function permissionsOf(owner) {
|
|
1657
|
+
if (!Object.hasOwn(owner, "permissions")) return null;
|
|
1658
|
+
const value = owner["permissions"];
|
|
1659
|
+
if (!isObject$1(value)) return textOf(value);
|
|
1660
|
+
return Object.fromEntries(Object.entries(value).map(([scope, level]) => [scope, textOf(level)]));
|
|
1661
|
+
}
|
|
1662
|
+
/** This function gives the events of the key `on`: one event, a list of events, or a map with an event as each key. */
|
|
1663
|
+
function triggersOf$1(on) {
|
|
1664
|
+
if (isObject$1(on)) return Object.keys(on);
|
|
1665
|
+
return listValues(on);
|
|
1666
|
+
}
|
|
1667
|
+
/**
|
|
1668
|
+
* This regular expression finds a reference to a secret in an expression: `secrets.NAME`, `secrets['NAME']`, or the
|
|
1669
|
+
* context `secrets` with no name. The names of the contexts of GitHub are not case-sensitive.
|
|
1670
|
+
*/
|
|
1671
|
+
const SECRET = /(?<![\w.-])secrets(?![\w-])\s*(?:\.\s*([A-Za-z_][\w-]*)|\[\s*'([^']*)'\s*\])?/gi;
|
|
1672
|
+
/**
|
|
1673
|
+
* This function gives the expressions of a text: the parts between `${{` and `}}`. An expression with no `}}` goes to
|
|
1674
|
+
* the end of the text, so a reference in it still counts.
|
|
1675
|
+
*/
|
|
1676
|
+
function expressionsOf(text) {
|
|
1677
|
+
const out = [];
|
|
1678
|
+
let at = text.indexOf("${{");
|
|
1679
|
+
while (at >= 0) {
|
|
1680
|
+
const end = text.indexOf("}}", at + 3);
|
|
1681
|
+
out.push(text.slice(at + 3, end < 0 ? void 0 : end));
|
|
1682
|
+
if (end < 0) break;
|
|
1683
|
+
at = text.indexOf("${{", end + 2);
|
|
1684
|
+
}
|
|
1685
|
+
return out;
|
|
1686
|
+
}
|
|
1687
|
+
/**
|
|
1688
|
+
* This function adds the secrets that a value of the parser reads: each string in it, and in its lists and maps. The
|
|
1689
|
+
* value of a key `if` is an expression also with no `${{ }}`, as GitHub reads it. The keys of a map are not expressions.
|
|
1690
|
+
*/
|
|
1691
|
+
function addSecrets(value, key, into, seen) {
|
|
1692
|
+
if (typeof value === "string") {
|
|
1693
|
+
for (const body of key === "if" ? [value] : expressionsOf(value)) for (const match of body.matchAll(SECRET)) into.add(match[1] ?? match[2] ?? "*");
|
|
1694
|
+
return;
|
|
1695
|
+
}
|
|
1696
|
+
if (typeof value !== "object" || value === null || seen.has(value)) return;
|
|
1697
|
+
seen.add(value);
|
|
1698
|
+
if (Array.isArray(value)) for (const item of value) addSecrets(item, "", into, seen);
|
|
1699
|
+
else for (const [name, item] of Object.entries(value)) addSecrets(item, name, into, seen);
|
|
1700
|
+
}
|
|
1701
|
+
/** This function gives the secrets that a value of the parser reads. */
|
|
1702
|
+
function secretsOf(value) {
|
|
1703
|
+
const secrets = /* @__PURE__ */ new Set();
|
|
1704
|
+
addSecrets(value, "", secrets, /* @__PURE__ */ new Set());
|
|
1705
|
+
return secrets;
|
|
1706
|
+
}
|
|
1707
|
+
/** This function reads a step: the same label as the line reader gives, its condition, its action and its secrets. */
|
|
1708
|
+
function parsedStep(value) {
|
|
1709
|
+
const step = isObject$1(value) ? value : {};
|
|
1710
|
+
const uses = actionOf(optionalText(step["uses"]));
|
|
1711
|
+
return {
|
|
1712
|
+
label: optionalText(step["name"]) || uses || (optionalText(step["run"]).split("\n")[0] ?? "") || optionalText(step["id"]) || "step",
|
|
1713
|
+
if: optionalText(step["if"]),
|
|
1714
|
+
uses,
|
|
1715
|
+
secrets: [...secretsOf(step)]
|
|
1716
|
+
};
|
|
1717
|
+
}
|
|
1718
|
+
/** This function reads a job. */
|
|
1719
|
+
function parsedJob(id, value) {
|
|
1720
|
+
const job = isObject$1(value) ? value : {};
|
|
1721
|
+
const secrets = secretsOf(job);
|
|
1722
|
+
if (job["secrets"] === "inherit") secrets.add("inherit");
|
|
1723
|
+
return {
|
|
1724
|
+
id,
|
|
1725
|
+
if: optionalText(job["if"]),
|
|
1726
|
+
needs: listValues(job["needs"]),
|
|
1727
|
+
uses: actionOf(optionalText(job["uses"])),
|
|
1728
|
+
permissions: permissionsOf(job),
|
|
1729
|
+
secrets: [...secrets],
|
|
1730
|
+
steps: Array.isArray(job["steps"]) ? job["steps"].map(parsedStep) : []
|
|
1731
|
+
};
|
|
1732
|
+
}
|
|
1733
|
+
/** This function gives the line (from 1) of the offset `at` of a text. */
|
|
1734
|
+
const lineAt$1 = (text, at) => text.slice(0, at).split("\n").length;
|
|
1735
|
+
/**
|
|
1736
|
+
* This function reads a workflow file with the YAML parser. The file name goes into the result. It does not throw: each
|
|
1737
|
+
* problem is a fault of the result. A file with a fault gives no trigger and no job.
|
|
1738
|
+
*/
|
|
1739
|
+
function parseWorkflow(file, text) {
|
|
1740
|
+
const documents = parseAllDocuments(text, PARSE);
|
|
1741
|
+
const faults = faultsOf(documents);
|
|
1742
|
+
const [first, second] = documents;
|
|
1743
|
+
if (second !== void 0) faults.push({
|
|
1744
|
+
line: lineAt$1(text, second.range[0]),
|
|
1745
|
+
column: 1,
|
|
1746
|
+
message: `The file has ${documents.length} YAML documents, and a workflow is one document`
|
|
1747
|
+
});
|
|
1748
|
+
const version = first?.directives?.yaml.version ?? "1.2";
|
|
1749
|
+
if (version !== "1.2") faults.push({
|
|
1750
|
+
line: 1,
|
|
1751
|
+
column: 1,
|
|
1752
|
+
message: `The file asks for YAML ${version}, and the reader takes only YAML 1.2`
|
|
1753
|
+
});
|
|
1754
|
+
const none = {
|
|
1755
|
+
file,
|
|
1756
|
+
name: file,
|
|
1757
|
+
triggers: [],
|
|
1758
|
+
permissions: null,
|
|
1759
|
+
secrets: [],
|
|
1760
|
+
jobs: [],
|
|
1761
|
+
faults
|
|
1762
|
+
};
|
|
1763
|
+
if (first === void 0 || faults.length > 0) return none;
|
|
1764
|
+
try {
|
|
1765
|
+
const top = first.toJS();
|
|
1766
|
+
if (!isObject$1(top)) return none;
|
|
1767
|
+
const jobs = isObject$1(top["jobs"]) ? Object.entries(top["jobs"]).map(([id, job]) => parsedJob(id, job)) : [];
|
|
1768
|
+
const secrets = secretsOf(top);
|
|
1769
|
+
if (jobs.some((job) => job.secrets.includes("inherit"))) secrets.add("inherit");
|
|
1770
|
+
return {
|
|
1771
|
+
file,
|
|
1772
|
+
name: optionalText(top["name"]) || file,
|
|
1773
|
+
triggers: triggersOf$1(top["on"]),
|
|
1774
|
+
permissions: permissionsOf(top),
|
|
1775
|
+
secrets: [...secrets],
|
|
1776
|
+
jobs,
|
|
1777
|
+
faults
|
|
1778
|
+
};
|
|
1779
|
+
} catch (error) {
|
|
1780
|
+
return {
|
|
1781
|
+
...none,
|
|
1782
|
+
faults: [{
|
|
1783
|
+
line: 1,
|
|
1784
|
+
column: 1,
|
|
1785
|
+
message: errorMessage(error)
|
|
1786
|
+
}]
|
|
1787
|
+
};
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1569
1790
|
// src/rules/gate-after-cancel.ts
|
|
1570
1791
|
/**
|
|
1571
1792
|
* The rule `gate-after-cancel`: a summary job of a gate does not start after a cancel. A job with `if: always()` still
|
|
@@ -18387,7 +18608,15 @@ function unreleasedChangeRule(lookup = npmLookup) {
|
|
|
18387
18608
|
const fork = push ? range.ends[0] : context.git(["merge-base", ...range.ends])?.trim();
|
|
18388
18609
|
const notes = [];
|
|
18389
18610
|
if (fork === void 0) notes.push(`the checkout does not have the merge base of ${range.ends.join(" and ")}, so the rule cannot tell if the change sets a version`);
|
|
18390
|
-
const
|
|
18611
|
+
const refs = [.../* @__PURE__ */ new Set([
|
|
18612
|
+
range.ends[0],
|
|
18613
|
+
range.ends[1],
|
|
18614
|
+
...fork === void 0 ? [] : [fork]
|
|
18615
|
+
])].filter((ref) => ref !== "HEAD");
|
|
18616
|
+
const specs = published.flatMap((pkg) => refs.map((ref) => `${ref}:${pkg.file}`));
|
|
18617
|
+
const shown = showFiles(context, specs);
|
|
18618
|
+
const texts = new Map(specs.map((spec, index) => [spec, shown[index]]));
|
|
18619
|
+
const manifestAt = (ref, pkg) => ref === "HEAD" ? pkg.manifest : parseManifest(texts.has(`${ref}:${pkg.file}`) ? texts.get(`${ref}:${pkg.file}`) : context.git(["show", `${ref}:${pkg.file}`]));
|
|
18391
18620
|
const versionOf = (manifest) => typeof manifest?.["version"] === "string" ? manifest["version"] : void 0;
|
|
18392
18621
|
const candidates = [];
|
|
18393
18622
|
for (const pkg of published) {
|
|
@@ -20297,9 +20526,8 @@ function namedVersions(title) {
|
|
|
20297
20526
|
}
|
|
20298
20527
|
return found;
|
|
20299
20528
|
}
|
|
20300
|
-
/** This function gives the version of a `package.json
|
|
20301
|
-
function
|
|
20302
|
-
const text = context.git(["show", `${commit}:${file}`]);
|
|
20529
|
+
/** This function gives the version in the text of a `package.json`, or undefined. */
|
|
20530
|
+
function versionIn(text) {
|
|
20303
20531
|
if (text === void 0) return void 0;
|
|
20304
20532
|
try {
|
|
20305
20533
|
const value = JSON.parse(text).version;
|
|
@@ -20321,13 +20549,29 @@ function setVersions(context, from, to) {
|
|
|
20321
20549
|
"**/package.json"
|
|
20322
20550
|
]);
|
|
20323
20551
|
if (out === void 0) return void 0;
|
|
20324
|
-
|
|
20325
|
-
|
|
20326
|
-
|
|
20327
|
-
|
|
20328
|
-
}
|
|
20329
|
-
|
|
20552
|
+
return setVersionsOf(context, [{
|
|
20553
|
+
from,
|
|
20554
|
+
to,
|
|
20555
|
+
files: out.split(/\r?\n/).filter((line) => line !== "")
|
|
20556
|
+
}])[0];
|
|
20557
|
+
}
|
|
20558
|
+
/** This function gives the versions that each change sets, with one read of git for all the files of all the changes. */
|
|
20559
|
+
function setVersionsOf(context, changes) {
|
|
20560
|
+
const texts = showFiles(context, changes.flatMap((change) => change.files.flatMap((file) => [`${change.to}:${file}`, `${change.from}:${file}`])));
|
|
20561
|
+
let index = 0;
|
|
20562
|
+
return changes.map((change) => {
|
|
20563
|
+
const versions = [];
|
|
20564
|
+
for (let file = 0; file < change.files.length; file++) {
|
|
20565
|
+
const after = versionIn(texts[index]);
|
|
20566
|
+
const before = versionIn(texts[index + 1]);
|
|
20567
|
+
index += 2;
|
|
20568
|
+
if (after !== void 0 && after !== before && !versions.includes(after)) versions.push(after);
|
|
20569
|
+
}
|
|
20570
|
+
return versions;
|
|
20571
|
+
});
|
|
20330
20572
|
}
|
|
20573
|
+
/** This function tells if a path is a `package.json` file. */
|
|
20574
|
+
const isManifest = (file) => file === "package.json" || file.endsWith("/package.json");
|
|
20331
20575
|
/**
|
|
20332
20576
|
* This function gives the versions that a merge of HEAD into `base` sets, with `fork` as the merge base. They are the
|
|
20333
20577
|
* versions of each `package.json` that the change (from `fork` to HEAD) changes, less each version that `base` has
|
|
@@ -20345,11 +20589,17 @@ function mergeSetVersions(context, base, fork) {
|
|
|
20345
20589
|
"**/package.json"
|
|
20346
20590
|
]);
|
|
20347
20591
|
if (out === void 0) return void 0;
|
|
20592
|
+
const files = out.split(/\r?\n/).filter((line) => line !== "");
|
|
20593
|
+
const texts = showFiles(context, files.flatMap((file) => [
|
|
20594
|
+
`HEAD:${file}`,
|
|
20595
|
+
`${fork}:${file}`,
|
|
20596
|
+
`${base}:${file}`
|
|
20597
|
+
]));
|
|
20348
20598
|
const versions = [];
|
|
20349
|
-
for (
|
|
20350
|
-
const after =
|
|
20599
|
+
for (let index = 0; index < files.length; index++) {
|
|
20600
|
+
const after = versionIn(texts[3 * index]);
|
|
20351
20601
|
if (after === void 0 || versions.includes(after)) continue;
|
|
20352
|
-
if (after !==
|
|
20602
|
+
if (after !== versionIn(texts[3 * index + 1]) && after !== versionIn(texts[3 * index + 2])) versions.push(after);
|
|
20353
20603
|
}
|
|
20354
20604
|
return versions;
|
|
20355
20605
|
}
|
|
@@ -20420,31 +20670,37 @@ const versionTitle = {
|
|
|
20420
20670
|
const range = rangeOf(context, { push: true });
|
|
20421
20671
|
if ("skipped" in range) return range;
|
|
20422
20672
|
const out = context.git([
|
|
20423
|
-
"
|
|
20673
|
+
"log",
|
|
20424
20674
|
"--first-parent",
|
|
20675
|
+
"--no-renames",
|
|
20676
|
+
"--name-only",
|
|
20677
|
+
"--format=%x1e%H%x00%P%x00%s",
|
|
20425
20678
|
...range.log
|
|
20426
20679
|
]);
|
|
20427
20680
|
if (out === void 0) return { skipped: "git cannot give the commits of the change" };
|
|
20681
|
+
const titled = [];
|
|
20682
|
+
for (const record of out.split("").slice(1)) {
|
|
20683
|
+
const [head = "", ...names] = record.split(/\r?\n/);
|
|
20684
|
+
const [commit = "", parents = "", subject = ""] = head.split("\0");
|
|
20685
|
+
const title = subject.trim();
|
|
20686
|
+
if (namedVersions(title).length === 0 || parents.trim() === "") continue;
|
|
20687
|
+
const files = names.map((name) => name.trim()).filter(isManifest);
|
|
20688
|
+
titled.push({
|
|
20689
|
+
commit,
|
|
20690
|
+
title,
|
|
20691
|
+
change: {
|
|
20692
|
+
from: `${commit}^1`,
|
|
20693
|
+
to: commit,
|
|
20694
|
+
files
|
|
20695
|
+
}
|
|
20696
|
+
});
|
|
20697
|
+
}
|
|
20698
|
+
const sets = setVersionsOf(context, titled.map((entry) => entry.change));
|
|
20428
20699
|
const breaks = [];
|
|
20429
|
-
|
|
20430
|
-
const
|
|
20431
|
-
"log",
|
|
20432
|
-
"-1",
|
|
20433
|
-
"--format=%s",
|
|
20434
|
-
commit
|
|
20435
|
-
])?.trim();
|
|
20436
|
-
if (title === void 0 || namedVersions(title).length === 0) continue;
|
|
20437
|
-
if (context.git([
|
|
20438
|
-
"rev-parse",
|
|
20439
|
-
"--verify",
|
|
20440
|
-
"--quiet",
|
|
20441
|
-
`${commit}^1^{commit}`
|
|
20442
|
-
]) === void 0) continue;
|
|
20443
|
-
const set = setVersions(context, `${commit}^1`, commit);
|
|
20444
|
-
if (set === void 0) continue;
|
|
20445
|
-
const found = breakOf(title, set, "package.json", `The commit ${commit.slice(0, 7)}`);
|
|
20700
|
+
titled.forEach(({ commit, title }, index) => {
|
|
20701
|
+
const found = breakOf(title, sets[index] ?? [], "package.json", `The commit ${commit.slice(0, 7)}`);
|
|
20446
20702
|
if (found !== void 0) breaks.push(found);
|
|
20447
|
-
}
|
|
20703
|
+
});
|
|
20448
20704
|
return breaks;
|
|
20449
20705
|
}
|
|
20450
20706
|
};
|
|
@@ -20454,19 +20710,6 @@ const versionTitle = {
|
|
|
20454
20710
|
*/
|
|
20455
20711
|
/** A file that GitHub reads as YAML: a workflow, or the file `action.yml` of an action of the repository. */
|
|
20456
20712
|
const GITHUB_YAML = /^\.github\/(?:workflows\/[^/]+|actions\/(?:[^/]+\/)*action)\.ya?ml$/;
|
|
20457
|
-
/** This function gives the faults of a YAML text. A text with no fault gives an empty list. */
|
|
20458
|
-
function yamlFaults(text) {
|
|
20459
|
-
const faults = [];
|
|
20460
|
-
for (const document of parseAllDocuments(text, { prettyErrors: true })) for (const error of document.errors) {
|
|
20461
|
-
const at = error.linePos?.[0];
|
|
20462
|
-
faults.push({
|
|
20463
|
-
line: at?.line ?? 1,
|
|
20464
|
-
column: at?.col ?? 1,
|
|
20465
|
-
message: (error.message.split("\n")[0] ?? error.code).replace(/:$/, "")
|
|
20466
|
-
});
|
|
20467
|
-
}
|
|
20468
|
-
return faults;
|
|
20469
|
-
}
|
|
20470
20713
|
const workflowParses = {
|
|
20471
20714
|
id: "workflow-parses",
|
|
20472
20715
|
title: "Each workflow file and each file `action.yml` of `.github` parses as YAML.",
|
|
@@ -21143,6 +21386,8 @@ function createContext(root, config, options = {}) {
|
|
|
21143
21386
|
const rootPackage = readPackage(root, root);
|
|
21144
21387
|
const packages = packageFolders(root, config.packages ?? void 0).filter((dir) => resolve(dir) !== resolve(root)).map((dir) => readPackage(root, dir));
|
|
21145
21388
|
let files = null;
|
|
21389
|
+
const outputs = /* @__PURE__ */ new Map();
|
|
21390
|
+
const shown = /* @__PURE__ */ new Map();
|
|
21146
21391
|
return {
|
|
21147
21392
|
root,
|
|
21148
21393
|
rootPackage,
|
|
@@ -21161,7 +21406,17 @@ function createContext(root, config, options = {}) {
|
|
|
21161
21406
|
}
|
|
21162
21407
|
return files;
|
|
21163
21408
|
},
|
|
21164
|
-
git
|
|
21409
|
+
git(args) {
|
|
21410
|
+
const key = args.join("\0");
|
|
21411
|
+
if (!outputs.has(key)) outputs.set(key, runGit(root, args));
|
|
21412
|
+
return outputs.get(key);
|
|
21413
|
+
},
|
|
21414
|
+
gitShow(specs) {
|
|
21415
|
+
const missing = [...new Set(specs.filter((spec) => !shown.has(spec)))];
|
|
21416
|
+
const texts = runGitShow(root, missing);
|
|
21417
|
+
missing.forEach((spec, index) => shown.set(spec, texts[index]));
|
|
21418
|
+
return specs.map((spec) => shown.get(spec));
|
|
21419
|
+
}
|
|
21165
21420
|
};
|
|
21166
21421
|
}
|
|
21167
21422
|
/** This function starts each rule on the repository at `options.root`, and gives the result of each rule. */
|
|
@@ -21621,6 +21876,6 @@ function runHook(args, io) {
|
|
|
21621
21876
|
git: (gitArgs) => runGit(io.cwd, gitArgs)
|
|
21622
21877
|
}, io);
|
|
21623
21878
|
}
|
|
21624
|
-
export {
|
|
21879
|
+
export { unreleasedChange as $, cleanPath as $n, licenseFileOf as $t, scriptsOf as A, callsSharedCi as An, privateNamesFiles as At, roadmapOfLine as B, convertGate as Bn, mergePrivateNames as Bt, setVersions as C, runCalls as Cn, HOME_PATTERNS as Ct, trustPolicy as D, SHARED_ACTIONS as Dn, invalidPatternBreaks as Dt, TRAIN_SCOPES as E, tsconfigTest as En, PRIVATE_PATTERNS_VARIABLE as Et, sourceMain as F, SECURITY_TIMEOUT_MINUTES as Fn, firstNameMatch as Ft, minorOf as G, parseWorkflow as Gn, REAL_COMPARE as Gt, requiredScripts as H, prPathFilters as Hn, parsePrivateNames as Ht, HOME_TIMEOUT_MS as I, securityCallers as In, isAllowedHit as It, reachOf as J, yamlFaults as Jn, coverageProvider as Jt, publishedMinor as K, readAction as Kn, hasImportMetaMain as Kt, blockHash as L, securityOneJob as Ln, isCommonUse as Lt, testsRequired as M, setupCue as Mn, privateTextBreaks as Mt, isSourcePath as N, SECURITY_SCAN_COMMIT as Nn, PRIVATE_NAME_LIST as Nt, typedScripts as O, SHARED_CI as On, noLocalPaths as Ot, pathsOf as P, SECURITY_SCAN_INPUTS as Pn, PrivateNameListError as Pt, npmLookup as Q, RULE_WARN_DAYS as Qn, licenseFile as Qt, githubFetch as R, withOneJob as Rn, lineNameHit as Rt, namedVersions as S, SERVICE_PACKAGE as Sn, DEFAULT_ALLOWED as St, IGNORE_AFTER as T, hasTests as Tn, PRIVATE_NAMES_FILE_VARIABLE as Tt, releaseFiles as U, summaryName as Un, pathNameHit as Ut, roadmapParses as V, gateTrigger as Vn, nameMatches as Vt, lockedVersions as W, gateAfterCancel as Wn, noBuildOutput as Wt, SHIPPED_FIELDS as X, cuePreset as Xn, LICENSE_TEXTS as Xt, NPM_REGISTRY as Y, STRICT_OPTIONS as Yn, apiReportScript as Yt, UNSHIPPED_FILES as Z, DEPENDENCY_FIELDS as Zn, authorOf as Zt, runPrePushArgs as _, mapText as _n, parseRuleConfig as _r, pagesCalls as _t, listRules as a, modulesOf as an, matchesAny as ar, startsTests as at, GITHUB_YAML as b, npmNames as bn, publishTextSafe as bt, runCli as c, messageOf as cn, readJsonc as cr, isGitSpecifier as ct, HOOK_MARKER as d, signaturesOf as dn, runGit as dr, siteCheckInCi as dt, mitText as en, codePackages as er, unreleasedChangeRule as et, NO_READ_LINE as f, HOME_EXPORTS as fn, runGitShow as fr, pagesAfterRelease as ft, prePush as g, mapMarkdown as gn, parseConfig as gr, PAGES_WORKFLOWS as gt, parsePrePushArgs as h, findHomes as hn, defaultOptions as hr, pushMainOnly as ht, formatResult as i, moduleUses as in, lineOf as ir, parseAdvisory as it, typedFiles as j, sharedCi as jn, privatePatterns as jt, configsOfScript as k, SHARED_WORKFLOWS as kn, privateNamesFile as kt, runFix as l, repoOf as ln, replaceLine as lr, isPinned as lt, installHook as m, MAP_RULE as mn, specifiersOf as mr, scheduleMinute as mt, annotations as n, homeModule as nn, inFolder as nr, hiddenFailures as nt, readConfig as o, declaredName as on, parseCatFileBatch as or, swallowsTests as ot, PRE_PUSH_HOOK as p, HOMES as pn, showFiles as pr, runnerBudget as pt, publishedMinorRule as q, readWorkflow as qn, mainCheck as qt, createContext as r, moduleMessage as rn, keyLine as rr, jobFails as rt, runChecks as s, homePackage as sn, parseJsonc as sr, pipeFails as st, USAGE as t, repositoryIsPublic as tn, hasFile as tr, playwrightInstall as tt, summaryMarkdown as u, reposOf as un, repositoryOfRemote as ur, pinnedGitDeps as ut, RULES as v, mergeHomes as vn, pagesSite as vt, versionTitle as w, serviceRunMain as wn, PRIVATE_NAMES_FILE_CONFIG as wt, workflowParses as x, readOverlay as xn, packNoBuildinfo as xt, workspaceProtocol as y, npmDrift as yn, exportsRequire as yt, sharedDocsRule as z, ACTIONS_COMMIT as zn, lineNameHits as zt };
|
|
21625
21880
|
|
|
21626
|
-
//# sourceMappingURL=run-
|
|
21881
|
+
//# sourceMappingURL=run-DyUvPasP.js.map
|