@mark1russell7/conventions 0.5.0 → 0.6.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 +2 -0
- package/build/cli.js +1 -1
- package/build/index.d.ts +3 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -1
- package/build/{run-8tafA0Xr.js → run-BYTCunT5.js} +660 -4
- package/build/run-BYTCunT5.js.map +1 -0
- package/package.json +2 -1
- package/build/run-8tafA0Xr.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import { spawnSync } from "node:child_process";
|
|
3
3
|
import { appendFileSync, existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
4
|
-
import { dirname, extname, join, relative, resolve, sep } from "node:path";
|
|
4
|
+
import { dirname, extname, join, posix, relative, resolve, sep } from "node:path";
|
|
5
5
|
// src/config.ts
|
|
6
6
|
/** The fields of the configuration of a rule that are not options. */
|
|
7
7
|
const RULE_FIELDS = [
|
|
@@ -1032,6 +1032,661 @@ const requiredScripts = {
|
|
|
1032
1032
|
});
|
|
1033
1033
|
}
|
|
1034
1034
|
};
|
|
1035
|
+
// ../site-pages/src/data/status.ts
|
|
1036
|
+
/** An error in the roadmap file, with the file and the line. */
|
|
1037
|
+
var RoadmapParseError = class extends Error {};
|
|
1038
|
+
const STATUS_KEYWORDS = [
|
|
1039
|
+
["open", /\bnot\s+(?:yet\s+)?(?:started|done|fixed|merged|shipped|released)\b|\bto[ -]?do\b/],
|
|
1040
|
+
["done", /\b(?:done|shipped|merged|fixed|released|complete|completed|closed|never|dropped|cancell?ed|wontfix)\b|\bwon't do\b/],
|
|
1041
|
+
["progress", /\bin[ -]progress\b|\b(?:active|ongoing|started|wip)\b/],
|
|
1042
|
+
["waiting", /\b(?:waiting|waits|awaiting|needs)\b/],
|
|
1043
|
+
["blocked", /\bblocked\b/],
|
|
1044
|
+
["later", /\b(?:later|deferred|postponed|someday)\b/]
|
|
1045
|
+
];
|
|
1046
|
+
/**
|
|
1047
|
+
* This function gives the class of a free-text status: done, progress, waiting, blocked, later or
|
|
1048
|
+
* open. The first keyword of the text decides. A text without a keyword ("next", "open") is open.
|
|
1049
|
+
*/
|
|
1050
|
+
function statusClassOf(text) {
|
|
1051
|
+
const lower = String(text ?? "").toLowerCase();
|
|
1052
|
+
let best = {
|
|
1053
|
+
index: Infinity,
|
|
1054
|
+
value: "open"
|
|
1055
|
+
};
|
|
1056
|
+
for (const [value, pattern] of STATUS_KEYWORDS) {
|
|
1057
|
+
const match = pattern.exec(lower);
|
|
1058
|
+
if (match && match.index < best.index) best = {
|
|
1059
|
+
index: match.index,
|
|
1060
|
+
value
|
|
1061
|
+
};
|
|
1062
|
+
}
|
|
1063
|
+
return best.value;
|
|
1064
|
+
}
|
|
1065
|
+
/** This function gives the cells of a table row. A "|" in a code span or after "\" is text. */
|
|
1066
|
+
function splitRow(line) {
|
|
1067
|
+
const cells = [];
|
|
1068
|
+
let cell = "";
|
|
1069
|
+
let code = false;
|
|
1070
|
+
const text = line.trim().replace(/^\|/, "").replace(/\|$/, "");
|
|
1071
|
+
for (let index = 0; index < text.length; index++) {
|
|
1072
|
+
const char = text[index];
|
|
1073
|
+
if (char === "\\" && text[index + 1] === "|") {
|
|
1074
|
+
cell += "|";
|
|
1075
|
+
index++;
|
|
1076
|
+
} else if (char === "`") {
|
|
1077
|
+
code = !code;
|
|
1078
|
+
cell += char;
|
|
1079
|
+
} else if (char === "|" && !code) {
|
|
1080
|
+
cells.push(cell.trim());
|
|
1081
|
+
cell = "";
|
|
1082
|
+
} else cell += char;
|
|
1083
|
+
}
|
|
1084
|
+
cells.push(cell.trim());
|
|
1085
|
+
return cells;
|
|
1086
|
+
}
|
|
1087
|
+
/** A whitespace character, as `\s` of a regular expression and `String.prototype.trim` read it. */
|
|
1088
|
+
const SPACE = /\s/;
|
|
1089
|
+
/** A character that `.` of a regular expression does not match. */
|
|
1090
|
+
const LINE_TERMINATOR = /[\n\r\u2028\u2029]/;
|
|
1091
|
+
/** The first whitespace character at or after `lastIndex`. */
|
|
1092
|
+
const NEXT_SPACE = /\s/g;
|
|
1093
|
+
/**
|
|
1094
|
+
* This function replaces each Markdown link `[label](target)` of a text with the result of
|
|
1095
|
+
* `replace`. The label ends at the first `]`, and the target ends at the first `)`. In `strict`
|
|
1096
|
+
* mode, the label and the target are not empty, and the target has no whitespace.
|
|
1097
|
+
*
|
|
1098
|
+
* @remarks The function reads the text one time. A regular expression for these links can
|
|
1099
|
+
* backtrack (CodeQL `js/polynomial-redos`). For a long text with many `[` characters, its time
|
|
1100
|
+
* grows with the square of the length.
|
|
1101
|
+
*/
|
|
1102
|
+
function replaceLinks(text, strict, replace) {
|
|
1103
|
+
let result = "";
|
|
1104
|
+
let copied = 0;
|
|
1105
|
+
let close = -1;
|
|
1106
|
+
let end = -1;
|
|
1107
|
+
let space = -1;
|
|
1108
|
+
for (let open = text.indexOf("["); open !== -1; open = text.indexOf("[", open + 1)) {
|
|
1109
|
+
if (close <= open) close = text.indexOf("]", open + 1);
|
|
1110
|
+
if (close === -1) break;
|
|
1111
|
+
if (text[close + 1] !== "(" || strict && close === open + 1) continue;
|
|
1112
|
+
const start = close + 2;
|
|
1113
|
+
if (end < start) end = text.indexOf(")", start);
|
|
1114
|
+
if (end === -1) break;
|
|
1115
|
+
if (strict) {
|
|
1116
|
+
if (space !== Infinity && space < start) {
|
|
1117
|
+
NEXT_SPACE.lastIndex = start;
|
|
1118
|
+
space = NEXT_SPACE.exec(text)?.index ?? Infinity;
|
|
1119
|
+
}
|
|
1120
|
+
if (end === start || space < end) continue;
|
|
1121
|
+
}
|
|
1122
|
+
result += text.slice(copied, open) + replace(text.slice(open + 1, close), text.slice(start, end));
|
|
1123
|
+
copied = end + 1;
|
|
1124
|
+
open = end;
|
|
1125
|
+
}
|
|
1126
|
+
return result + text.slice(copied);
|
|
1127
|
+
}
|
|
1128
|
+
/**
|
|
1129
|
+
* This function gives the text of an ATX heading without its closing sequence: the whitespace,
|
|
1130
|
+
* then the `#` characters, then the whitespace at the end. It gives null when the rest has a line
|
|
1131
|
+
* terminator, as the regular expression `(.*?)\s*#*\s*$` does.
|
|
1132
|
+
*/
|
|
1133
|
+
function closeHeading(text) {
|
|
1134
|
+
let end = text.length;
|
|
1135
|
+
while (end > 0 && SPACE.test(text[end - 1] ?? "")) end--;
|
|
1136
|
+
while (end > 0 && text[end - 1] === "#") end--;
|
|
1137
|
+
while (end > 0 && SPACE.test(text[end - 1] ?? "")) end--;
|
|
1138
|
+
const rest = text.slice(0, end);
|
|
1139
|
+
return LINE_TERMINATOR.test(rest) ? null : rest;
|
|
1140
|
+
}
|
|
1141
|
+
/** The start of an ATX heading. The text after the whitespace goes to `closeHeading`. */
|
|
1142
|
+
const HEADING = /^(#{1,6})\s+(\S[\s\S]*)?$/;
|
|
1143
|
+
/** This function gives the level and the text of an ATX heading line, or null for another line. */
|
|
1144
|
+
function headingOf(line) {
|
|
1145
|
+
const match = HEADING.exec(line);
|
|
1146
|
+
const text = match ? closeHeading(match[2] ?? "") : null;
|
|
1147
|
+
return match && text !== null ? {
|
|
1148
|
+
level: match[1]?.length ?? 0,
|
|
1149
|
+
text
|
|
1150
|
+
} : null;
|
|
1151
|
+
}
|
|
1152
|
+
/** This function gives the plain text of inline Markdown: no code marks, no emphasis, the text of each link. */
|
|
1153
|
+
function plainText(markdown) {
|
|
1154
|
+
return replaceLinks(String(markdown ?? ""), false, (label) => label).replace(/[`*_]/g, "").replace(/\s+/g, " ").trim();
|
|
1155
|
+
}
|
|
1156
|
+
/** A cell with no value: empty, or a dash. */
|
|
1157
|
+
function isEmpty(cell) {
|
|
1158
|
+
return cell === void 0 || /^(?:[-–—]|n\/a)?$/i.test(cell.trim());
|
|
1159
|
+
}
|
|
1160
|
+
/**
|
|
1161
|
+
* This function gives the tables of a Markdown file. Each table has its header names in lowercase
|
|
1162
|
+
* plain text, the nearest heading above it, the line of its header and its rows. Fenced code is not read.
|
|
1163
|
+
*/
|
|
1164
|
+
function markdownTables(markdown) {
|
|
1165
|
+
const lines = String(markdown).split(/\r?\n/);
|
|
1166
|
+
const tables = [];
|
|
1167
|
+
let section = "";
|
|
1168
|
+
let fence = null;
|
|
1169
|
+
for (let index = 0; index < lines.length; index++) {
|
|
1170
|
+
const line = lines[index] ?? "";
|
|
1171
|
+
const fenceMark = /^\s*(`{3,}|~{3,})/.exec(line)?.[1];
|
|
1172
|
+
if (fenceMark !== void 0) {
|
|
1173
|
+
if (fence === null) fence = fenceMark[0] ?? null;
|
|
1174
|
+
else if (fenceMark[0] === fence) fence = null;
|
|
1175
|
+
continue;
|
|
1176
|
+
}
|
|
1177
|
+
if (fence !== null) continue;
|
|
1178
|
+
const heading = headingOf(line);
|
|
1179
|
+
if (heading) {
|
|
1180
|
+
section = plainText(heading.text);
|
|
1181
|
+
continue;
|
|
1182
|
+
}
|
|
1183
|
+
if (!line.trim().startsWith("|")) continue;
|
|
1184
|
+
const separator = lines[index + 1] ?? "";
|
|
1185
|
+
if (!/^\s*(?:\|\s*)?:?-{3,}/.test(separator)) continue;
|
|
1186
|
+
const header = splitRow(line).map((name) => plainText(name).toLowerCase());
|
|
1187
|
+
const rows = [];
|
|
1188
|
+
let next = index + 2;
|
|
1189
|
+
for (; next < lines.length && (lines[next] ?? "").trim().startsWith("|"); next++) rows.push({
|
|
1190
|
+
line: next + 1,
|
|
1191
|
+
cells: splitRow(lines[next] ?? "")
|
|
1192
|
+
});
|
|
1193
|
+
tables.push({
|
|
1194
|
+
section,
|
|
1195
|
+
line: index + 1,
|
|
1196
|
+
header,
|
|
1197
|
+
rows
|
|
1198
|
+
});
|
|
1199
|
+
index = next - 1;
|
|
1200
|
+
}
|
|
1201
|
+
return tables;
|
|
1202
|
+
}
|
|
1203
|
+
/** The columns whose cells hold the links of an item. */
|
|
1204
|
+
const LINK_COLUMNS = [
|
|
1205
|
+
"where",
|
|
1206
|
+
"commit",
|
|
1207
|
+
"commits",
|
|
1208
|
+
"link",
|
|
1209
|
+
"links",
|
|
1210
|
+
"pr",
|
|
1211
|
+
"prs"
|
|
1212
|
+
];
|
|
1213
|
+
/** Words before a reference that do not name a repository. */
|
|
1214
|
+
const NOT_REPOSITORIES = new Set("a an and also at by commit commits done fixed for from in into issue issues merged of on or plus pr prs run see the then to via with".split(" "));
|
|
1215
|
+
/** The URL of a link target of the roadmap file: an absolute URL stays, and a relative one goes to GitHub. */
|
|
1216
|
+
function linkUrl(target, { file = "", repository = "", ref = "HEAD" }) {
|
|
1217
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(target)) return target;
|
|
1218
|
+
if (!repository) return null;
|
|
1219
|
+
const [path = "", anchor = ""] = target.split("#", 2);
|
|
1220
|
+
const resolved = path === "" ? file : posix.normalize(posix.join(posix.dirname(file), path));
|
|
1221
|
+
if (resolved.startsWith("..")) return null;
|
|
1222
|
+
return `https://github.com/${repository}/blob/${ref}/${resolved}${anchor ? `#${anchor}` : ""}`;
|
|
1223
|
+
}
|
|
1224
|
+
/**
|
|
1225
|
+
* This function gives the word right before the whitespace that ends `text.slice(0, end)`, as the
|
|
1226
|
+
* regular expression `([A-Za-z][\w.-]*)\s+$` does. The word starts with a letter. The function
|
|
1227
|
+
* reads only the characters of the word and of the whitespace.
|
|
1228
|
+
*/
|
|
1229
|
+
function wordBefore(text, end) {
|
|
1230
|
+
let stop = end;
|
|
1231
|
+
while (stop > 0 && SPACE.test(text[stop - 1] ?? "")) stop--;
|
|
1232
|
+
if (stop === end) return void 0;
|
|
1233
|
+
let start = stop;
|
|
1234
|
+
while (start > 0 && /[\w.-]/.test(text[start - 1] ?? "")) start--;
|
|
1235
|
+
while (start < stop && !/[A-Za-z]/.test(text[start] ?? "")) start++;
|
|
1236
|
+
return start < stop ? text.slice(start, stop) : void 0;
|
|
1237
|
+
}
|
|
1238
|
+
/**
|
|
1239
|
+
* This function gives the links of a cell: each Markdown link, then each bare reference in the rest
|
|
1240
|
+
* of the text. A reference is a pull request ("PR #12", "#12") or a commit hash in a code span.
|
|
1241
|
+
*
|
|
1242
|
+
* @remarks A repository name right before a reference ("systems PR #16") applies to it and to the
|
|
1243
|
+
* next references of the cell. Without a name, a reference belongs to `repository`.
|
|
1244
|
+
*/
|
|
1245
|
+
function linksOf(cell, options = {}) {
|
|
1246
|
+
const { repository = "" } = options;
|
|
1247
|
+
const links = [];
|
|
1248
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1249
|
+
const add = (label, url) => {
|
|
1250
|
+
if (!url || seen.has(url)) return;
|
|
1251
|
+
seen.add(url);
|
|
1252
|
+
links.push({
|
|
1253
|
+
label,
|
|
1254
|
+
url
|
|
1255
|
+
});
|
|
1256
|
+
};
|
|
1257
|
+
const rest = replaceLinks(String(cell ?? ""), true, (label, target) => {
|
|
1258
|
+
add(plainText(label), linkUrl(target, options));
|
|
1259
|
+
return " ";
|
|
1260
|
+
});
|
|
1261
|
+
if (!repository) return links;
|
|
1262
|
+
const [owner, defaultRepo] = repository.split("/");
|
|
1263
|
+
let current = defaultRepo;
|
|
1264
|
+
let pulls = false;
|
|
1265
|
+
const reference = /\bPRs?\s*#(\d+)|(?<![\w/&])#(\d+)\b|`([0-9a-f]{7,40})`/g;
|
|
1266
|
+
for (let match = reference.exec(rest); match; match = reference.exec(rest)) {
|
|
1267
|
+
const word = wordBefore(rest, match.index);
|
|
1268
|
+
if (word && !NOT_REPOSITORIES.has(word.toLowerCase())) current = word;
|
|
1269
|
+
const prefix = current === defaultRepo ? "" : `${current} `;
|
|
1270
|
+
if (match[1] !== void 0) pulls = true;
|
|
1271
|
+
const number = match[1] ?? match[2];
|
|
1272
|
+
if (number !== void 0) add(`${prefix}#${number}`, `https://github.com/${owner}/${current}/${pulls ? "pull" : "issues"}/${number}`);
|
|
1273
|
+
else if (match[3] !== void 0) add(`${prefix}${match[3].slice(0, 7)}`, `https://github.com/${owner}/${current}/commit/${match[3]}`);
|
|
1274
|
+
}
|
|
1275
|
+
return links;
|
|
1276
|
+
}
|
|
1277
|
+
/**
|
|
1278
|
+
* The heading of an item: "### `id`: Title". A dash can take the place of the colon. The title goes
|
|
1279
|
+
* to `closeHeading`.
|
|
1280
|
+
*/
|
|
1281
|
+
const ITEM_HEADING = /^###\s+`([^`]+)`\s*[:–—-]\s*(\S[\s\S]*)?$/;
|
|
1282
|
+
/** The other heading of an item: "### S1 · Title". The ID is one word before the middle dot. */
|
|
1283
|
+
const ITEM_HEADING_DOT = /^###\s+([A-Za-z0-9][\w.-]*)\s+·\s+(\S[\s\S]*)?$/;
|
|
1284
|
+
/** This function gives the ID and the title of an item heading, or null for another line. */
|
|
1285
|
+
function itemHeadingOf(line) {
|
|
1286
|
+
for (const pattern of [ITEM_HEADING, ITEM_HEADING_DOT]) {
|
|
1287
|
+
const match = pattern.exec(line);
|
|
1288
|
+
const title = match ? closeHeading(match[2] ?? "") : null;
|
|
1289
|
+
if (match && title !== null) return {
|
|
1290
|
+
id: match[1] ?? "",
|
|
1291
|
+
title
|
|
1292
|
+
};
|
|
1293
|
+
}
|
|
1294
|
+
return null;
|
|
1295
|
+
}
|
|
1296
|
+
/**
|
|
1297
|
+
* A field of an item heading: "- Area: Docs", "- **Area:** Docs" or "- **Area**: Docs". The label
|
|
1298
|
+
* matches without case.
|
|
1299
|
+
*/
|
|
1300
|
+
const ITEM_FIELD = /^\s*[-*]\s+(\*\*|__)?([A-Za-z][A-Za-z ]*?)(?::\1|\1:)\s*(\S.*)?$/;
|
|
1301
|
+
/** The fields of an item heading that give the optional fields of an item. */
|
|
1302
|
+
const ITEM_FIELDS = {
|
|
1303
|
+
area: "area",
|
|
1304
|
+
owner: "owner",
|
|
1305
|
+
"waits for": "needs",
|
|
1306
|
+
needs: "needs",
|
|
1307
|
+
"depends on": "needs"
|
|
1308
|
+
};
|
|
1309
|
+
/**
|
|
1310
|
+
* This function gives the items of the second form of a roadmap: each heading "### `id`: Title" or
|
|
1311
|
+
* "### id · Title". The list item "Status:" gives the status. Without it, the "##" heading above
|
|
1312
|
+
* the item gives the status, for example "Waiting on Mark", "Later" or "Shipped". A heading without
|
|
1313
|
+
* a status is not an item.
|
|
1314
|
+
*
|
|
1315
|
+
* The list items "Area:", "Owner:" and "Waits for:" give the optional fields. The list item
|
|
1316
|
+
* "Links:" and the other list items give the links. Fenced code is not read.
|
|
1317
|
+
*/
|
|
1318
|
+
function headingItems(markdown, options) {
|
|
1319
|
+
const lines = String(markdown).split(/\r?\n/);
|
|
1320
|
+
const items = [];
|
|
1321
|
+
let section = "";
|
|
1322
|
+
let current;
|
|
1323
|
+
let fence = null;
|
|
1324
|
+
for (let index = 0; index < lines.length; index++) {
|
|
1325
|
+
const line = lines[index] ?? "";
|
|
1326
|
+
const fenceMark = /^\s*(`{3,}|~{3,})/.exec(line)?.[1];
|
|
1327
|
+
if (fenceMark !== void 0) {
|
|
1328
|
+
if (fence === null) fence = fenceMark[0] ?? null;
|
|
1329
|
+
else if (fenceMark[0] === fence) fence = null;
|
|
1330
|
+
continue;
|
|
1331
|
+
}
|
|
1332
|
+
if (fence !== null) continue;
|
|
1333
|
+
const heading = headingOf(line);
|
|
1334
|
+
if (heading) {
|
|
1335
|
+
const { level } = heading;
|
|
1336
|
+
if (level > 3) continue;
|
|
1337
|
+
current = void 0;
|
|
1338
|
+
if (level === 2) section = plainText(heading.text);
|
|
1339
|
+
if (level === 1) section = "";
|
|
1340
|
+
if (level !== 3) continue;
|
|
1341
|
+
const item = itemHeadingOf(line);
|
|
1342
|
+
const id = plainText(item?.id);
|
|
1343
|
+
if (!item || isEmpty(id)) continue;
|
|
1344
|
+
current = {
|
|
1345
|
+
id,
|
|
1346
|
+
title: item.title,
|
|
1347
|
+
status: section,
|
|
1348
|
+
statusClass: statusClassOf(section),
|
|
1349
|
+
section,
|
|
1350
|
+
line: index + 1,
|
|
1351
|
+
links: []
|
|
1352
|
+
};
|
|
1353
|
+
items.push(current);
|
|
1354
|
+
continue;
|
|
1355
|
+
}
|
|
1356
|
+
if (!current) continue;
|
|
1357
|
+
const field = ITEM_FIELD.exec(line);
|
|
1358
|
+
const label = (field?.[2] ?? "").trim().toLowerCase();
|
|
1359
|
+
const value = (field?.[3] ?? "").trim();
|
|
1360
|
+
const key = field ? ITEM_FIELDS[label] : void 0;
|
|
1361
|
+
if (field && label === "status") {
|
|
1362
|
+
if (!isEmpty(value)) {
|
|
1363
|
+
current.status = value;
|
|
1364
|
+
current.statusClass = statusClassOf(plainText(value));
|
|
1365
|
+
}
|
|
1366
|
+
} else if (field && key !== void 0) {
|
|
1367
|
+
if (!isEmpty(value)) current[key] = value;
|
|
1368
|
+
} else if (/^\s*[-*]\s+/.test(line)) {
|
|
1369
|
+
const seen = new Set(current.links.map((link) => link.url));
|
|
1370
|
+
for (const link of linksOf(line, options)) if (!seen.has(link.url)) current.links.push(link);
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
return items.filter((item) => item.status !== "");
|
|
1374
|
+
}
|
|
1375
|
+
/**
|
|
1376
|
+
* This function gives the items of a roadmap file in the order of the file. It reads two forms:
|
|
1377
|
+
*
|
|
1378
|
+
* - Each row of each table with an `ID` column and a `Status` column. The header names match without
|
|
1379
|
+
* case. The title comes from `Item`, else from `Title`. `Owner`, `Area` and `Needs` are optional.
|
|
1380
|
+
* `Where`, `Commit` and `Links` give the links.
|
|
1381
|
+
* - Each heading "### `id`: Title" or "### id · Title". The list item "Status:", else the "##"
|
|
1382
|
+
* heading above it, gives the status. The list items "Area:", "Owner:" and "Waits for:" give the
|
|
1383
|
+
* optional fields, and "Links:" and the other list items give the links.
|
|
1384
|
+
*
|
|
1385
|
+
* @throws RoadmapParseError when the cells of a row do not match the header
|
|
1386
|
+
*/
|
|
1387
|
+
function roadmapItems(markdown, options = {}) {
|
|
1388
|
+
const { file = "ROADMAP.md" } = options;
|
|
1389
|
+
const items = [];
|
|
1390
|
+
for (const table of markdownTables(markdown)) {
|
|
1391
|
+
const column = (...names) => names.map((name) => table.header.indexOf(name)).find((index) => index >= 0) ?? -1;
|
|
1392
|
+
const id = column("id");
|
|
1393
|
+
const status = column("status");
|
|
1394
|
+
if (id < 0 || status < 0) continue;
|
|
1395
|
+
const title = column("item", "title");
|
|
1396
|
+
const owner = column("owner");
|
|
1397
|
+
const area = column("area");
|
|
1398
|
+
const needs = column("needs");
|
|
1399
|
+
const linkColumns = LINK_COLUMNS.map((name) => table.header.indexOf(name)).filter((index) => index >= 0);
|
|
1400
|
+
for (const row of table.rows) {
|
|
1401
|
+
if (row.cells.length !== table.header.length) throw new RoadmapParseError(`${file}:${row.line}: the row has ${row.cells.length} cells, and the header has ${table.header.length}`);
|
|
1402
|
+
const idText = plainText(row.cells[id]);
|
|
1403
|
+
if (isEmpty(idText)) continue;
|
|
1404
|
+
const statusText = row.cells[status] ?? "";
|
|
1405
|
+
const item = {
|
|
1406
|
+
id: idText,
|
|
1407
|
+
title: title >= 0 ? row.cells[title] ?? "" : "",
|
|
1408
|
+
status: statusText,
|
|
1409
|
+
statusClass: statusClassOf(plainText(statusText)),
|
|
1410
|
+
section: table.section,
|
|
1411
|
+
line: row.line,
|
|
1412
|
+
links: linkColumns.flatMap((index) => linksOf(row.cells[index], {
|
|
1413
|
+
...options,
|
|
1414
|
+
file
|
|
1415
|
+
}))
|
|
1416
|
+
};
|
|
1417
|
+
const optional = (index) => index >= 0 && !isEmpty(row.cells[index]) ? row.cells[index] : void 0;
|
|
1418
|
+
const ownerText = optional(owner);
|
|
1419
|
+
const areaText = optional(area);
|
|
1420
|
+
const needsText = optional(needs);
|
|
1421
|
+
if (ownerText !== void 0) item.owner = ownerText;
|
|
1422
|
+
if (areaText !== void 0) item.area = areaText;
|
|
1423
|
+
if (needsText !== void 0) item.needs = needsText;
|
|
1424
|
+
items.push(item);
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
const headings = headingItems(markdown, {
|
|
1428
|
+
...options,
|
|
1429
|
+
file
|
|
1430
|
+
});
|
|
1431
|
+
return headings.length === 0 ? items : [...items, ...headings].sort((a, b) => a.line - b.line);
|
|
1432
|
+
}
|
|
1433
|
+
/**
|
|
1434
|
+
* This function gives the items of a roadmap file, as the Status page reads them. It fails when the file has no item.
|
|
1435
|
+
*
|
|
1436
|
+
* @throws RoadmapParseError when the cells of a row do not match the header
|
|
1437
|
+
* @throws RoadmapParseError when the roadmap has no item: no table with an ID and a Status column, and no item heading
|
|
1438
|
+
*/
|
|
1439
|
+
function parseRoadmap(markdown, options = {}) {
|
|
1440
|
+
const { file = "ROADMAP.md" } = options;
|
|
1441
|
+
const items = roadmapItems(markdown, options);
|
|
1442
|
+
if (items.length === 0) throw new RoadmapParseError(`${file}: no table with an ID column and a Status column, and no heading "### \`id\`: Title"`);
|
|
1443
|
+
return items;
|
|
1444
|
+
}
|
|
1445
|
+
String.raw`
|
|
1446
|
+
const boxes = Array.from(document.querySelectorAll("[data-sp-timeline]"));
|
|
1447
|
+
const panels = new Map(Array.from(document.querySelectorAll("[data-sp-release]"), (panel) => [panel.dataset.version, panel]));
|
|
1448
|
+
const reduced = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
1449
|
+
let selected = (document.querySelector("[data-sp-release]:not([hidden])") || {}).dataset?.version;
|
|
1450
|
+
const markIn = (box, version) => Array.from(box.querySelectorAll("[data-sp-mark]")).find((mark) => mark.dataset.version === version);
|
|
1451
|
+
function reveal(box, version, smooth) {
|
|
1452
|
+
const mark = markIn(box, version);
|
|
1453
|
+
if (!mark || box.scrollWidth <= box.clientWidth) return;
|
|
1454
|
+
const x = Number(mark.dataset.x);
|
|
1455
|
+
const margin = Number(mark.dataset.half) + 16;
|
|
1456
|
+
if (x - margin >= box.scrollLeft && x + margin <= box.scrollLeft + box.clientWidth) return;
|
|
1457
|
+
box.scrollTo({ left: x - box.clientWidth / 2, behavior: smooth && !reduced ? "smooth" : "auto" });
|
|
1458
|
+
}
|
|
1459
|
+
function select(version, box) {
|
|
1460
|
+
const panel = panels.get(version);
|
|
1461
|
+
if (!panel) return;
|
|
1462
|
+
selected = version;
|
|
1463
|
+
for (const each of boxes) {
|
|
1464
|
+
for (const mark of each.querySelectorAll("[data-sp-mark]")) {
|
|
1465
|
+
const on = mark.dataset.version === version;
|
|
1466
|
+
mark.classList.toggle("sp-selected", on);
|
|
1467
|
+
mark.setAttribute("aria-pressed", String(on));
|
|
1468
|
+
mark.setAttribute("tabindex", on ? "0" : "-1");
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
for (const [key, each] of panels) each.hidden = key !== version;
|
|
1472
|
+
if (box) {
|
|
1473
|
+
const mark = markIn(box, version);
|
|
1474
|
+
if (mark) mark.focus({ preventScroll: true });
|
|
1475
|
+
reveal(box, version, true);
|
|
1476
|
+
}
|
|
1477
|
+
try {
|
|
1478
|
+
history.replaceState(null, "", "#" + encodeURIComponent(panel.id));
|
|
1479
|
+
} catch {}
|
|
1480
|
+
}
|
|
1481
|
+
for (const box of boxes) {
|
|
1482
|
+
box.addEventListener("click", (event) => {
|
|
1483
|
+
const mark = event.target.closest("[data-sp-mark]");
|
|
1484
|
+
if (mark) select(mark.dataset.version, box);
|
|
1485
|
+
});
|
|
1486
|
+
box.addEventListener("keydown", (event) => {
|
|
1487
|
+
const mark = event.target.closest("[data-sp-mark]");
|
|
1488
|
+
if (!mark || event.altKey || event.ctrlKey || event.metaKey) return;
|
|
1489
|
+
const marks = Array.from(box.querySelectorAll("[data-sp-mark]"));
|
|
1490
|
+
const position = marks.indexOf(mark);
|
|
1491
|
+
const targets = { ArrowLeft: position - 1, ArrowRight: position + 1, Home: 0, End: marks.length - 1, Enter: position, " ": position };
|
|
1492
|
+
if (!(event.key in targets)) return;
|
|
1493
|
+
event.preventDefault();
|
|
1494
|
+
const next = marks[Math.max(0, Math.min(marks.length - 1, targets[event.key]))];
|
|
1495
|
+
if (next) select(next.dataset.version, box);
|
|
1496
|
+
});
|
|
1497
|
+
}
|
|
1498
|
+
document.addEventListener("click", (event) => {
|
|
1499
|
+
const button = event.target.closest("[data-sp-toggle]");
|
|
1500
|
+
const list = button && document.getElementById(button.getAttribute("aria-controls"));
|
|
1501
|
+
if (!list) return;
|
|
1502
|
+
const open = button.getAttribute("aria-expanded") !== "true";
|
|
1503
|
+
for (const extra of list.querySelectorAll(":scope > .sp-extra")) extra.hidden = !open;
|
|
1504
|
+
button.setAttribute("aria-expanded", String(open));
|
|
1505
|
+
const label = button.querySelector("[data-sp-label]");
|
|
1506
|
+
if (label) label.textContent = open ? button.dataset.less : button.dataset.more;
|
|
1507
|
+
});
|
|
1508
|
+
// A malformed hash, for example "#100%", must not stop the module
|
|
1509
|
+
let hashed = "";
|
|
1510
|
+
try {
|
|
1511
|
+
hashed = decodeURIComponent(location.hash.slice(1));
|
|
1512
|
+
} catch {}
|
|
1513
|
+
for (const [version, panel] of panels) if (panel.id === hashed) select(version, null);
|
|
1514
|
+
const revealAll = () => { for (const box of boxes) reveal(box, selected, false); };
|
|
1515
|
+
revealAll();
|
|
1516
|
+
window.addEventListener("resize", revealAll);
|
|
1517
|
+
`;
|
|
1518
|
+
String.raw`
|
|
1519
|
+
function relativeTime(then, now) {
|
|
1520
|
+
const seconds = Math.round((now - then) / 1000);
|
|
1521
|
+
if (!Number.isFinite(seconds)) return "at an unknown time";
|
|
1522
|
+
if (seconds < 60) return "just now";
|
|
1523
|
+
const steps = [[60, "minute"], [3600, "hour"], [86400, "day"], [2592000, "month"], [31536000, "year"]];
|
|
1524
|
+
let unit = steps[0];
|
|
1525
|
+
for (const step of steps) if (seconds >= step[0]) unit = step;
|
|
1526
|
+
const count = Math.floor(seconds / unit[0]);
|
|
1527
|
+
return count + " " + unit[1] + (count === 1 ? "" : "s") + " ago";
|
|
1528
|
+
}
|
|
1529
|
+
function listOf(text) {
|
|
1530
|
+
return (text || "").split(",").filter((part) => part !== "");
|
|
1531
|
+
}
|
|
1532
|
+
` + String.raw`
|
|
1533
|
+
const now = Date.now();
|
|
1534
|
+
for (const time of document.querySelectorAll("time[data-sp-rel]")) {
|
|
1535
|
+
time.textContent = relativeTime(Date.parse(time.dateTime), now) + " (" + time.title + ")";
|
|
1536
|
+
}
|
|
1537
|
+
const board = document.querySelector("[data-sp-board]");
|
|
1538
|
+
if (board) {
|
|
1539
|
+
const classChips = Array.from(board.querySelectorAll("[data-sp-class]"));
|
|
1540
|
+
const sectionChips = Array.from(board.querySelectorAll("[data-sp-section]"));
|
|
1541
|
+
const groups = Array.from(board.querySelectorAll("[data-sp-group]"));
|
|
1542
|
+
const shown = board.querySelector("[data-sp-shown]");
|
|
1543
|
+
const empty = board.querySelector("[data-sp-empty]");
|
|
1544
|
+
const clear = board.querySelector("[data-sp-clear]");
|
|
1545
|
+
const done = board.querySelector("[data-sp-done]");
|
|
1546
|
+
const query = new URLSearchParams(location.search);
|
|
1547
|
+
const state = {
|
|
1548
|
+
classes: listOf(query.get("status")).filter((value) => classChips.some((chip) => chip.dataset.spClass === value)),
|
|
1549
|
+
sections: listOf(query.get("section")),
|
|
1550
|
+
};
|
|
1551
|
+
if (done && query.get("done") === "1") done.open = true;
|
|
1552
|
+
const apply = (write) => {
|
|
1553
|
+
for (const chip of classChips) chip.setAttribute("aria-pressed", String(state.classes.includes(chip.dataset.spClass)));
|
|
1554
|
+
for (const chip of sectionChips) chip.setAttribute("aria-pressed", String(state.sections.includes(chip.dataset.spSection)));
|
|
1555
|
+
let count = 0;
|
|
1556
|
+
for (const group of groups) {
|
|
1557
|
+
const isDone = group.dataset.class === "done";
|
|
1558
|
+
const classOn = isDone || state.classes.length === 0 || state.classes.includes(group.dataset.class);
|
|
1559
|
+
let visible = 0;
|
|
1560
|
+
for (const row of group.querySelectorAll("tr[data-section]")) {
|
|
1561
|
+
const on = classOn && (state.sections.length === 0 || state.sections.includes(row.dataset.section));
|
|
1562
|
+
row.hidden = !on;
|
|
1563
|
+
if (on) visible++;
|
|
1564
|
+
}
|
|
1565
|
+
if (isDone) {
|
|
1566
|
+
const none = group.querySelector("[data-sp-done-empty]");
|
|
1567
|
+
if (none) none.hidden = visible > 0;
|
|
1568
|
+
} else {
|
|
1569
|
+
group.hidden = visible === 0;
|
|
1570
|
+
const badge = group.querySelector("[data-sp-group-count]");
|
|
1571
|
+
if (badge) badge.textContent = String(visible);
|
|
1572
|
+
count += visible;
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
if (shown) shown.textContent = count + " of " + shown.dataset.label;
|
|
1576
|
+
if (empty) empty.hidden = count > 0;
|
|
1577
|
+
if (clear) clear.hidden = state.classes.length === 0 && state.sections.length === 0;
|
|
1578
|
+
if (done) {
|
|
1579
|
+
const label = done.querySelector("[data-sp-done-label]");
|
|
1580
|
+
if (label) label.textContent = done.open ? "Hide the done items" : "Show the done items";
|
|
1581
|
+
}
|
|
1582
|
+
if (!write) return;
|
|
1583
|
+
const next = new URLSearchParams(location.search);
|
|
1584
|
+
const put = (key, value) => (value ? next.set(key, value) : next.delete(key));
|
|
1585
|
+
put("status", state.classes.join(","));
|
|
1586
|
+
put("section", state.sections.join(","));
|
|
1587
|
+
put("done", done && done.open ? "1" : "");
|
|
1588
|
+
const search = next.toString();
|
|
1589
|
+
try {
|
|
1590
|
+
history.replaceState(null, "", location.pathname + (search ? "?" + search : "") + location.hash);
|
|
1591
|
+
} catch {}
|
|
1592
|
+
};
|
|
1593
|
+
const toggle = (list, value) => (list.includes(value) ? list.filter((each) => each !== value) : list.concat(value));
|
|
1594
|
+
board.addEventListener("click", (event) => {
|
|
1595
|
+
const chip = event.target.closest("button");
|
|
1596
|
+
if (!chip) return;
|
|
1597
|
+
if (chip.dataset.spClass) state.classes = toggle(state.classes, chip.dataset.spClass);
|
|
1598
|
+
else if (chip.dataset.spSection) state.sections = toggle(state.sections, chip.dataset.spSection);
|
|
1599
|
+
else if (chip.hasAttribute("data-sp-clear")) {
|
|
1600
|
+
state.classes = [];
|
|
1601
|
+
state.sections = [];
|
|
1602
|
+
} else return;
|
|
1603
|
+
apply(true);
|
|
1604
|
+
});
|
|
1605
|
+
if (done) done.addEventListener("toggle", () => apply(true));
|
|
1606
|
+
apply(false);
|
|
1607
|
+
}
|
|
1608
|
+
`;
|
|
1609
|
+
// src/rules/roadmap-parses.ts
|
|
1610
|
+
/**
|
|
1611
|
+
* The rule `roadmap-parses`: each roadmap that a workflow gives to the Status page parses, on the pull request.
|
|
1612
|
+
*/
|
|
1613
|
+
/** A workflow file. */
|
|
1614
|
+
const WORKFLOW = /^\.github\/workflows\/[^/]+\.ya?ml$/;
|
|
1615
|
+
/** This function gives the value of a `roadmap: <file>` line, or undefined for another line, an empty value or an expression. */
|
|
1616
|
+
function roadmapOfLine(line) {
|
|
1617
|
+
const text = line.trimStart();
|
|
1618
|
+
if (!text.startsWith("roadmap:")) return void 0;
|
|
1619
|
+
let value = text.slice(8);
|
|
1620
|
+
const comment = value.indexOf(" #");
|
|
1621
|
+
if (comment >= 0) value = value.slice(0, comment);
|
|
1622
|
+
value = value.trim();
|
|
1623
|
+
const quote = value.charAt(0);
|
|
1624
|
+
if (value.length >= 2 && (quote === "\"" || quote === "'") && value.endsWith(quote)) value = value.slice(1, -1).trim();
|
|
1625
|
+
if (value === "" || value.includes("${{")) return void 0;
|
|
1626
|
+
return cleanPath(value);
|
|
1627
|
+
}
|
|
1628
|
+
const roadmapParses = {
|
|
1629
|
+
id: "roadmap-parses",
|
|
1630
|
+
title: "Each roadmap that a workflow gives to the Status page (the input `roadmap`) parses as site-pages reads it.",
|
|
1631
|
+
reason: "Only the Pages job on main reads the roadmap. A pull request with a bad table row passes each check, and then the build of the site stops and the site stays stale. On 2026-10-30, one repository had 3 red Pages runs in a row because of one row with 2 cells under a header with 4.",
|
|
1632
|
+
fix: "Correct the row or the heading that the message names. Each table row has one cell for each column of its header, and the file has a table with an ID column and a Status column, or a heading \"### `id`: Title\".",
|
|
1633
|
+
sources: [{
|
|
1634
|
+
repo: "fleet",
|
|
1635
|
+
rule: "fail-closed",
|
|
1636
|
+
doc: "docs/STRATEGY.md (2026-10-30, gates and probes fail closed)"
|
|
1637
|
+
}],
|
|
1638
|
+
options: { roadmaps: {
|
|
1639
|
+
type: "strings",
|
|
1640
|
+
default: [],
|
|
1641
|
+
description: "More roadmap files to check: a roadmap that no workflow names with a `roadmap:` key."
|
|
1642
|
+
} },
|
|
1643
|
+
check(context, options) {
|
|
1644
|
+
const files = context.gitFiles();
|
|
1645
|
+
if (files === void 0) return { skipped: "the root is not in a git repository" };
|
|
1646
|
+
const named = [];
|
|
1647
|
+
for (const file of files.filter((path) => WORKFLOW.test(path)).sort(byCode)) readFileSync(join(context.root, file), "utf8").split(/\r?\n/).forEach((line, index) => {
|
|
1648
|
+
const roadmap = roadmapOfLine(line);
|
|
1649
|
+
if (roadmap !== void 0) named.push({
|
|
1650
|
+
roadmap,
|
|
1651
|
+
file,
|
|
1652
|
+
line: index + 1
|
|
1653
|
+
});
|
|
1654
|
+
});
|
|
1655
|
+
for (const roadmap of options["roadmaps"]) named.push({
|
|
1656
|
+
roadmap: cleanPath(roadmap),
|
|
1657
|
+
file: "the option roadmaps",
|
|
1658
|
+
line: 0
|
|
1659
|
+
});
|
|
1660
|
+
if (named.length === 0) return { skipped: "no workflow names a roadmap (the input roadmap of the Pages workflow)" };
|
|
1661
|
+
const breaks = [];
|
|
1662
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1663
|
+
for (const { roadmap, file, line } of named) {
|
|
1664
|
+
if (seen.has(roadmap)) continue;
|
|
1665
|
+
seen.add(roadmap);
|
|
1666
|
+
if (!existsSync(join(context.root, roadmap))) {
|
|
1667
|
+
breaks.push({
|
|
1668
|
+
file: line > 0 ? file : roadmap,
|
|
1669
|
+
...line > 0 ? { line } : {},
|
|
1670
|
+
message: `${file} names the roadmap ${roadmap}, and the file does not exist.`
|
|
1671
|
+
});
|
|
1672
|
+
continue;
|
|
1673
|
+
}
|
|
1674
|
+
try {
|
|
1675
|
+
parseRoadmap(readFileSync(join(context.root, roadmap), "utf8"), { file: roadmap });
|
|
1676
|
+
} catch (error) {
|
|
1677
|
+
if (!(error instanceof RoadmapParseError)) throw error;
|
|
1678
|
+
const at = /^[^:]+:(\d+): /.exec(error.message);
|
|
1679
|
+
const rest = at ? error.message.slice(at[0].length) : error.message.slice(error.message.indexOf(": ") + 2);
|
|
1680
|
+
breaks.push({
|
|
1681
|
+
file: roadmap,
|
|
1682
|
+
...at ? { line: Number(at[1]) } : {},
|
|
1683
|
+
message: `${roadmap}: ${rest}`
|
|
1684
|
+
});
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
return breaks;
|
|
1688
|
+
}
|
|
1689
|
+
};
|
|
1035
1690
|
// src/rules/source-main.ts
|
|
1036
1691
|
/**
|
|
1037
1692
|
* The rule `source-main`: a workspace package is a source package, and a public package moves its
|
|
@@ -1693,7 +2348,8 @@ const RULES = [
|
|
|
1693
2348
|
releaseFiles,
|
|
1694
2349
|
typedScripts,
|
|
1695
2350
|
typedFiles,
|
|
1696
|
-
testsRequired
|
|
2351
|
+
testsRequired,
|
|
2352
|
+
roadmapParses
|
|
1697
2353
|
];
|
|
1698
2354
|
// src/run.ts
|
|
1699
2355
|
/**
|
|
@@ -1983,6 +2639,6 @@ function runCli(args, io) {
|
|
|
1983
2639
|
if (summary) appendFileSync(summary, summaryMarkdown(result));
|
|
1984
2640
|
return result.failed ? 1 : 0;
|
|
1985
2641
|
}
|
|
1986
|
-
export {
|
|
2642
|
+
export { HOME_PATTERNS as A, keyLine as B, roadmapParses as C, isPinned as D, isGitSpecifier as E, DEPENDENCY_FIELDS as F, runGit as G, matchesAny as H, cleanPath as I, globToRegExp as J, specifiersOf as K, codePackages as L, noBuildOutput as M, STRICT_OPTIONS as N, pinnedGitDeps as O, cuePreset as P, parseConfig as Q, hasFile as R, roadmapOfLine as S, releaseFiles as T, parseJsonc as U, lineOf as V, readJsonc as W, workspaceGlobs as X, packageFolders as Y, defaultOptions as Z, tsconfigTest as _, listRules as a, pathsOf as b, runCli as c, workspaceProtocol as d, typedScripts as f, hasTests as g, typedFiles as h, formatResult as i, noLocalPaths as j, DEFAULT_ALLOWED as k, summaryMarkdown as l, scriptsOf as m, annotations as n, readConfig as o, configsOfScript as p, globFolders as q, createContext as r, runChecks as s, USAGE as t, RULES as u, testsRequired as v, requiredScripts as w, sourceMain as x, isSourcePath as y, inFolder as z };
|
|
1987
2643
|
|
|
1988
|
-
//# sourceMappingURL=run-
|
|
2644
|
+
//# sourceMappingURL=run-BYTCunT5.js.map
|