@mark1russell7/conventions 0.28.1 → 0.29.1
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 +1 -0
- package/build/cli.js +1 -1
- package/build/index.d.ts +26 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +69 -1
- package/build/index.js.map +1 -0
- package/build/{run-mJmeZYyh.js → run-ByqpkrLT.js} +102 -2
- package/build/run-ByqpkrLT.js.map +1 -0
- package/package.json +1 -1
- package/build/run-mJmeZYyh.js.map +0 -1
package/README.md
CHANGED
|
@@ -178,4 +178,5 @@ The package also exports the functions of the tool:
|
|
|
178
178
|
- `formatResult(result)`, `summaryMarkdown(result)`, `annotations(result)` and `listRules(config)` give the output.
|
|
179
179
|
- `parseConfig(value, rules)` and `readConfig(root)` read the field `conventions`.
|
|
180
180
|
- `HOMES` is the map of homes. `findHomes(query)` finds the homes of words, and `mapMarkdown(homes)` and `mapText(homes)` write them. `readOverlay(file)` and `mergeHomes(base, extra)` add more homes.
|
|
181
|
+
- `tagName(name, version, packageCount)` gives the git tag of a version. `releaseNotes(name, version, changelog)` gives the text of its GitHub release, with `changelogSection`, `npmUrl` and `MAX_NOTES`. The script `scripts/release/tags.ts` keeps the same rule, and a test compares the two.
|
|
181
182
|
- `RULES` and each rule, with the helpers `isGitSpecifier`, `isPinned`, `isSourcePath` and `parseJsonc`.
|
package/build/cli.js
CHANGED
package/build/index.d.ts
CHANGED
|
@@ -261,6 +261,7 @@ export declare const DEFAULT_ALLOWED: readonly string[];
|
|
|
261
261
|
/** The forms of a home folder: Windows, macOS and Linux. The group `user` is the name of the user. */
|
|
262
262
|
export declare const HOME_PATTERNS: readonly RegExp[];
|
|
263
263
|
export declare const noLocalPaths: Rule;
|
|
264
|
+
export declare const apiReportScript: Rule;
|
|
264
265
|
/** The Pages workflow of the template, as a call from another repository and as a call from the template itself. */
|
|
265
266
|
export declare const PAGES_WORKFLOWS: readonly string[];
|
|
266
267
|
/** A call of the Pages workflow: its line (from 1), and false when its job sets `deploy: false`. */
|
|
@@ -475,6 +476,31 @@ interface CliIo {
|
|
|
475
476
|
export declare const USAGE: string;
|
|
476
477
|
/** This function starts the bin with the arguments `args`, and gives its exit code. */
|
|
477
478
|
export declare function runCli(args: readonly string[], io: CliIo): number;
|
|
479
|
+
/**
|
|
480
|
+
* The rule for the git tag and the text of a GitHub release of a package version.
|
|
481
|
+
*
|
|
482
|
+
* The release workflow keeps the same rule in `scripts/release/tags.ts`. A pinned workflow starts that script, so it
|
|
483
|
+
* does not import this package. A test of this package compares the two.
|
|
484
|
+
*/
|
|
485
|
+
/** GitHub refuses a release text of more than 125000 characters. */
|
|
486
|
+
export declare const MAX_NOTES: number;
|
|
487
|
+
/** This function gives the tag of a version: `v<version>` when the repository has one published package. */
|
|
488
|
+
export declare function tagName(name: string, version: string, packageCount: number): string;
|
|
489
|
+
/**
|
|
490
|
+
* This function gives the text of the section of a version in a changelog, or undefined.
|
|
491
|
+
*
|
|
492
|
+
* The heading of the section has the version, with an optional `v` or `<name>@` before it and optional brackets:
|
|
493
|
+
* `## 1.2.0`, `## v1.2.0`, `## [1.2.0] - 2026-10-18`, `# pkg@1.2.0 (2026-10-18)`. The section stops at the next heading
|
|
494
|
+
* of the same level or a higher level. A heading in fenced code does not count. An empty section gives undefined.
|
|
495
|
+
*/
|
|
496
|
+
export declare function changelogSection(markdown: string, version: string, name: string): string | undefined;
|
|
497
|
+
/** This function gives the address of a version on npm. */
|
|
498
|
+
export declare function npmUrl(name: string, version: string): string;
|
|
499
|
+
/**
|
|
500
|
+
* This function gives the text of the GitHub release of a version: its changelog section, or else one list item with a
|
|
501
|
+
* link to npm. The Releases page of `site-pages` reads each list item as a change.
|
|
502
|
+
*/
|
|
503
|
+
export declare function releaseNotes(name: string, version: string, changelog: string | undefined): string;
|
|
478
504
|
/**
|
|
479
505
|
* This function gives a regular expression for a glob of `/` paths. `*` matches a part of one path
|
|
480
506
|
* segment, `?` matches one character, `**` matches zero or more segments, and `{a,b}` matches one of
|
package/build/index.d.ts.map
CHANGED
|
@@ -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/map.ts","../src/rules/home-package.ts","../src/rules/license-file.ts","../src/rules/main-check.ts","../src/rules/no-build-output.ts","../src/rules/no-local-paths.ts","../src/rules/pages-site.ts","../src/rules/pinned-git-deps.ts","../src/rules/push-main-only.ts","../src/rules/release-files.ts","../src/rules/required-scripts.ts","../src/rules/roadmap-parses.ts","../src/rules/runner-budget.ts","../src/rules/shared-docs.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/unreleased-change.ts","../src/rules/workspace-protocol.ts","../src/rules/index.ts","../src/home-exports.ts","../src/workflow.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;;;;;WAKjC;EACT,MAAM,SAAS,aAAa,SAAS,UAAU;;;qBAIpC;;wBAGG,aAAa,UAAU,UAAU;;wBAOjC,OAAO,cAAc,gBAAgB;;wBAOrC,QAAQ,cAAc,eAAe;;q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gate-trigger.ts","../src/map.ts","../src/rules/home-package.ts","../src/rules/license-file.ts","../src/rules/main-check.ts","../src/rules/no-build-output.ts","../src/rules/no-local-paths.ts","../src/rules/api-report-script.ts","../src/rules/pages-site.ts","../src/rules/pinned-git-deps.ts","../src/rules/push-main-only.ts","../src/rules/release-files.ts","../src/rules/required-scripts.ts","../src/rules/roadmap-parses.ts","../src/rules/runner-budget.ts","../src/rules/shared-docs.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/unreleased-change.ts","../src/rules/workspace-protocol.ts","../src/rules/index.ts","../src/home-exports.ts","../src/workflow.ts","../src/run.ts","../src/release-text.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;;;;;WAKjC;EACT,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,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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;;wBA6CG,OAAO,yBAAyB,IAAI;;;;;;;;qBChUvC;;wBAGG,QAAQ,cAAc,iBAAiB;;;;;;;;wBAavC,iBAAiB,kBAAkB,iBAAiB;;wBA+BpD,OAAO,cAAc;;;;;wBAQrB,aAAa,cAAc,iBAAiB;;;;;;wBCzC5C,aAAa,eAAe;;;;;wBAsD5B,YAAY,cAAc;;;;;;wBA8B1B,eAAe;;;;;;;wBAwCf,eAAe,cAAc"}
|
package/build/index.js
CHANGED
|
@@ -1 +1,69 @@
|
|
|
1
|
-
|
|
1
|
+
import { $ as noLocalPaths, A as pathsOf, At as cuePreset, B as roadmapParses, Bt as readJsonc, C as configsOfScript, Ct as ACTIONS_COMMIT, D as hasTests, Dt as summaryName, E as testsRequired, Et as prPathFilters, F as sharedDocsRule, Ft as inFolder, G as isPinned, Gt as globToRegExp, H as releaseFiles, Ht as runGit, I as repositoryOfRemote, It as keyLine, J as pagesCalls, Jt as defaultOptions, K as pinnedGitDeps, Kt as packageFolders, L as runnerBudget, Lt as lineOf, M as HOME_TIMEOUT_MS, Mt as cleanPath, N as blockHash, Nt as codePackages, O as tsconfigTest, Ot as readWorkflow, P as githubFetch, Pt as hasFile, Q as HOME_PATTERNS, R as scheduleMinute, Rt as matchesAny, S as typedScripts, St as HOME_EXPORTS, T as typedFiles, Tt as gateTrigger, U as pushMainOnly, Ut as specifiersOf, V as requiredScripts, Vt as replaceLine, W as isGitSpecifier, Wt as globFolders, X as apiReportScript, Y as pagesSite, Yt as parseConfig, Z as DEFAULT_ALLOWED, _ as unreleasedChange, _t as findHomes, a as listRules, at as authorOf, b as TRAIN_SCOPES, bt as mergeHomes, c as runCli, ct as mitText, d as RULES, dt as homePackage, et as noBuildOutput, f as workspaceProtocol, ft as messageOf, g as npmLookup, gt as MAP_RULE, h as UNSHIPPED_FILES, ht as HOMES, i as formatResult, it as LICENSE_TEXTS, j as sourceMain, jt as DEPENDENCY_FIELDS, k as isSourcePath, kt as STRICT_OPTIONS, l as runFix, lt as repositoryIsPublic, m as SHIPPED_FIELDS, mt as signaturesOf, n as annotations, nt as hasImportMetaMain, o as readConfig, ot as licenseFile, p as NPM_REGISTRY, pt as repoOf, q as PAGES_WORKFLOWS, qt as workspaceGlobs, r as createContext, rt as mainCheck, s as runChecks, st as licenseFileOf, t as USAGE, tt as REAL_COMPARE, u as summaryMarkdown, ut as declaredName, v as unreleasedChangeRule, vt as mapMarkdown, w as scriptsOf, wt as convertGate, x as trustPolicy, xt as readOverlay, y as IGNORE_AFTER, yt as mapText, z as roadmapOfLine, zt as parseJsonc } from "./run-ByqpkrLT.js";
|
|
2
|
+
// src/release-text.ts
|
|
3
|
+
/**
|
|
4
|
+
* The rule for the git tag and the text of a GitHub release of a package version.
|
|
5
|
+
*
|
|
6
|
+
* The release workflow keeps the same rule in `scripts/release/tags.ts`. A pinned workflow starts that script, so it
|
|
7
|
+
* does not import this package. A test of this package compares the two.
|
|
8
|
+
*/
|
|
9
|
+
/** GitHub refuses a release text of more than 125000 characters. */
|
|
10
|
+
const MAX_NOTES = 1e5;
|
|
11
|
+
/** This function gives the tag of a version: `v<version>` when the repository has one published package. */
|
|
12
|
+
function tagName(name, version, packageCount) {
|
|
13
|
+
return packageCount === 1 ? `v${version}` : `${name}@${version}`;
|
|
14
|
+
}
|
|
15
|
+
const escape = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
16
|
+
/**
|
|
17
|
+
* This function gives the text of the section of a version in a changelog, or undefined.
|
|
18
|
+
*
|
|
19
|
+
* The heading of the section has the version, with an optional `v` or `<name>@` before it and optional brackets:
|
|
20
|
+
* `## 1.2.0`, `## v1.2.0`, `## [1.2.0] - 2026-10-18`, `# pkg@1.2.0 (2026-10-18)`. The section stops at the next heading
|
|
21
|
+
* of the same level or a higher level. A heading in fenced code does not count. An empty section gives undefined.
|
|
22
|
+
*/
|
|
23
|
+
function changelogSection(markdown, version, name) {
|
|
24
|
+
const heading = new RegExp(`^(#{1,6})\\s+\\[?(?:v|${escape(name)}@)?${escape(version)}\\]?(?=$|[\\s(])`);
|
|
25
|
+
const lines = markdown.split(/\r?\n/);
|
|
26
|
+
let level = 0;
|
|
27
|
+
let fence = null;
|
|
28
|
+
const body = [];
|
|
29
|
+
for (const line of lines) {
|
|
30
|
+
const fenceMark = /^\s*(`{3,}|~{3,})/.exec(line)?.[1];
|
|
31
|
+
if (fenceMark !== void 0) {
|
|
32
|
+
const mark = fenceMark[0] ?? "";
|
|
33
|
+
if (fence === null) fence = mark;
|
|
34
|
+
else if (mark === fence) fence = null;
|
|
35
|
+
if (level > 0) body.push(line);
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (fence === null) {
|
|
39
|
+
const levelOf = /^(#{1,6})\s/.exec(line)?.[1]?.length;
|
|
40
|
+
if (level > 0 && levelOf !== void 0 && levelOf <= level) break;
|
|
41
|
+
if (level === 0) {
|
|
42
|
+
const match = heading.exec(line);
|
|
43
|
+
if (match) level = match[1]?.length ?? 0;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (level > 0) body.push(line);
|
|
48
|
+
}
|
|
49
|
+
const text = body.join("\n").trim();
|
|
50
|
+
return text === "" ? void 0 : text;
|
|
51
|
+
}
|
|
52
|
+
/** This function gives the address of a version on npm. */
|
|
53
|
+
function npmUrl(name, version) {
|
|
54
|
+
return `https://www.npmjs.com/package/${name}/v/${version}`;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* This function gives the text of the GitHub release of a version: its changelog section, or else one list item with a
|
|
58
|
+
* link to npm. The Releases page of `site-pages` reads each list item as a change.
|
|
59
|
+
*/
|
|
60
|
+
function releaseNotes(name, version, changelog) {
|
|
61
|
+
const fallback = `- Version ${version} of [\`${name}\`](${npmUrl(name, version)}) on npm.`;
|
|
62
|
+
const section = changelog === void 0 ? void 0 : changelogSection(changelog, version, name);
|
|
63
|
+
if (section === void 0) return fallback;
|
|
64
|
+
if (section.length <= 1e5) return section;
|
|
65
|
+
return `${section.slice(0, MAX_NOTES)}\n\n(The CHANGELOG.md of \`${name}\` has the full text.)`;
|
|
66
|
+
}
|
|
67
|
+
export { ACTIONS_COMMIT, DEFAULT_ALLOWED, DEPENDENCY_FIELDS, HOMES, HOME_EXPORTS, HOME_PATTERNS, HOME_TIMEOUT_MS, IGNORE_AFTER, LICENSE_TEXTS, MAP_RULE, MAX_NOTES, NPM_REGISTRY, PAGES_WORKFLOWS, REAL_COMPARE, RULES, SHIPPED_FIELDS, STRICT_OPTIONS, TRAIN_SCOPES, UNSHIPPED_FILES, USAGE, annotations, apiReportScript, authorOf, blockHash, changelogSection, cleanPath, codePackages, configsOfScript, convertGate, createContext, cuePreset, declaredName, defaultOptions, findHomes, formatResult, gateTrigger, githubFetch, globFolders, globToRegExp, hasFile, hasImportMetaMain, hasTests, homePackage, inFolder, isGitSpecifier, isPinned, isSourcePath, keyLine, licenseFile, licenseFileOf, lineOf, listRules, mainCheck, mapMarkdown, mapText, matchesAny, mergeHomes, messageOf, mitText, noBuildOutput, noLocalPaths, npmLookup, npmUrl, packageFolders, pagesCalls, pagesSite, parseConfig, parseJsonc, pathsOf, pinnedGitDeps, prPathFilters, pushMainOnly, readConfig, readJsonc, readOverlay, readWorkflow, releaseFiles, releaseNotes, replaceLine, repoOf, repositoryIsPublic, repositoryOfRemote, requiredScripts, roadmapOfLine, roadmapParses, runChecks, runCli, runFix, runGit, runnerBudget, scheduleMinute, scriptsOf, sharedDocsRule, signaturesOf, sourceMain, specifiersOf, summaryMarkdown, summaryName, tagName, testsRequired, trustPolicy, tsconfigTest, typedFiles, typedScripts, unreleasedChange, unreleasedChangeRule, workspaceGlobs, workspaceProtocol };
|
|
68
|
+
|
|
69
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/release-text.ts"],"sourcesContent":["/**\n * The rule for the git tag and the text of a GitHub release of a package version.\n *\n * The release workflow keeps the same rule in `scripts/release/tags.ts`. A pinned workflow starts that script, so it\n * does not import this package. A test of this package compares the two.\n */\n\n/** GitHub refuses a release text of more than 125000 characters. */\nexport const MAX_NOTES: number = 100_000;\n\n/** This function gives the tag of a version: `v<version>` when the repository has one published package. */\nexport function tagName(name: string, version: string, packageCount: number): string {\n return packageCount === 1 ? `v${version}` : `${name}@${version}`;\n}\n\nconst escape = (text: string): string => text.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\n/**\n * This function gives the text of the section of a version in a changelog, or undefined.\n *\n * The heading of the section has the version, with an optional `v` or `<name>@` before it and optional brackets:\n * `## 1.2.0`, `## v1.2.0`, `## [1.2.0] - 2026-10-18`, `# pkg@1.2.0 (2026-10-18)`. The section stops at the next heading\n * of the same level or a higher level. A heading in fenced code does not count. An empty section gives undefined.\n */\nexport function changelogSection(markdown: string, version: string, name: string): string | undefined {\n const heading = new RegExp(`^(#{1,6})\\\\s+\\\\[?(?:v|${escape(name)}@)?${escape(version)}\\\\]?(?=$|[\\\\s(])`);\n const lines = markdown.split(/\\r?\\n/);\n let level = 0;\n let fence: string | null = null;\n const body: string[] = [];\n for (const line of lines) {\n const fenceMark = /^\\s*(`{3,}|~{3,})/.exec(line)?.[1];\n if (fenceMark !== undefined) {\n const mark = fenceMark[0] ?? \"\";\n if (fence === null) fence = mark;\n else if (mark === fence) fence = null;\n if (level > 0) body.push(line);\n continue;\n }\n if (fence === null) {\n const levelOf = /^(#{1,6})\\s/.exec(line)?.[1]?.length;\n if (level > 0 && levelOf !== undefined && levelOf <= level) break;\n if (level === 0) {\n const match = heading.exec(line);\n if (match) level = match[1]?.length ?? 0;\n continue;\n }\n }\n if (level > 0) body.push(line);\n }\n const text = body.join(\"\\n\").trim();\n return text === \"\" ? undefined : text;\n}\n\n/** This function gives the address of a version on npm. */\nexport function npmUrl(name: string, version: string): string {\n return `https://www.npmjs.com/package/${name}/v/${version}`;\n}\n\n/**\n * This function gives the text of the GitHub release of a version: its changelog section, or else one list item with a\n * link to npm. The Releases page of `site-pages` reads each list item as a change.\n */\nexport function releaseNotes(name: string, version: string, changelog: string | undefined): string {\n const fallback = `- Version ${version} of [\\`${name}\\`](${npmUrl(name, version)}) on npm.`;\n const section = changelog === undefined ? undefined : changelogSection(changelog, version, name);\n if (section === undefined) return fallback;\n if (section.length <= MAX_NOTES) return section;\n return `${section.slice(0, MAX_NOTES)}\\n\\n(The CHANGELOG.md of \\`${name}\\` has the full text.)`;\n}\n"],"mappings":";;;;;;;;;AAQA,MAAa,YAAoB;;AAGjC,SAAgB,QAAQ,MAAc,SAAiB,cAA8B;CACnF,OAAO,iBAAiB,IAAI,IAAI,YAAY,GAAG,KAAK,GAAG;AACzD;AAEA,MAAM,UAAU,SAAyB,KAAK,QAAQ,uBAAuB,MAAM;;;;;;;;AASnF,SAAgB,iBAAiB,UAAkB,SAAiB,MAAkC;CACpG,MAAM,UAAU,IAAI,OAAO,yBAAyB,OAAO,IAAI,EAAE,KAAK,OAAO,OAAO,EAAE,iBAAiB;CACvG,MAAM,QAAQ,SAAS,MAAM,OAAO;CACpC,IAAI,QAAQ;CACZ,IAAI,QAAuB;CAC3B,MAAM,OAAiB,CAAC;CACxB,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,YAAY,oBAAoB,KAAK,IAAI,CAAC,GAAG;EACnD,IAAI,cAAc,KAAA,GAAW;GAC3B,MAAM,OAAO,UAAU,MAAM;GAC7B,IAAI,UAAU,MAAM,QAAQ;QACvB,IAAI,SAAS,OAAO,QAAQ;GACjC,IAAI,QAAQ,GAAG,KAAK,KAAK,IAAI;GAC7B;EACF;EACA,IAAI,UAAU,MAAM;GAClB,MAAM,UAAU,cAAc,KAAK,IAAI,CAAC,GAAG,EAAE,EAAE;GAC/C,IAAI,QAAQ,KAAK,YAAY,KAAA,KAAa,WAAW,OAAO;GAC5D,IAAI,UAAU,GAAG;IACf,MAAM,QAAQ,QAAQ,KAAK,IAAI;IAC/B,IAAI,OAAO,QAAQ,MAAM,EAAE,EAAE,UAAU;IACvC;GACF;EACF;EACA,IAAI,QAAQ,GAAG,KAAK,KAAK,IAAI;CAC/B;CACA,MAAM,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC,KAAK;CAClC,OAAO,SAAS,KAAK,KAAA,IAAY;AACnC;;AAGA,SAAgB,OAAO,MAAc,SAAyB;CAC5D,OAAO,iCAAiC,KAAK,KAAK;AACpD;;;;;AAMA,SAAgB,aAAa,MAAc,SAAiB,WAAuC;CACjG,MAAM,WAAW,aAAa,QAAQ,SAAS,KAAK,MAAM,OAAO,MAAM,OAAO,EAAE;CAChF,MAAM,UAAU,cAAc,KAAA,IAAY,KAAA,IAAY,iBAAiB,WAAW,SAAS,IAAI;CAC/F,IAAI,YAAY,KAAA,GAAW,OAAO;CAClC,IAAI,QAAQ,UAAA,KAAqB,OAAO;CACxC,OAAO,GAAG,QAAQ,MAAM,GAAG,SAAS,EAAE,6BAA6B,KAAK;AAC1E"}
|
|
@@ -8743,6 +8743,105 @@ const noLocalPaths = {
|
|
|
8743
8743
|
return breaks;
|
|
8744
8744
|
}
|
|
8745
8745
|
};
|
|
8746
|
+
// src/rules/api-report-script.ts
|
|
8747
|
+
/**
|
|
8748
|
+
* The rule `api-report-script`: a repository with a public package has the root script that checks its API reports.
|
|
8749
|
+
*/
|
|
8750
|
+
/** The package of the reports. */
|
|
8751
|
+
const API_REPORT = "@mark1russell7/api-report";
|
|
8752
|
+
/** The range that the fix adds. The train moves it after that. */
|
|
8753
|
+
const API_REPORT_RANGE = "^0.3.1";
|
|
8754
|
+
/** The command of the script. */
|
|
8755
|
+
const COMMAND = "api-report check";
|
|
8756
|
+
/**
|
|
8757
|
+
* This function gives `text` with one more entry in the block `field` of a `package.json` file. The entry goes in the
|
|
8758
|
+
* order of the names when `sorted` is true, else at the end. It gives undefined when the block is not on separate lines.
|
|
8759
|
+
*/
|
|
8760
|
+
function addEntry(text, field, name, value, sorted) {
|
|
8761
|
+
const eol = text.includes("\r\n") ? "\r\n" : "\n";
|
|
8762
|
+
const lines = text.split(/\r?\n/);
|
|
8763
|
+
const start = lines.findIndex((line) => line === ` "${field}": {`);
|
|
8764
|
+
if (start < 0) return void 0;
|
|
8765
|
+
const end = lines.findIndex((line, index) => index > start && /^ {2}\},?$/.test(line));
|
|
8766
|
+
if (end < 0) return void 0;
|
|
8767
|
+
const entry = ` ${JSON.stringify(name)}: ${JSON.stringify(value)}`;
|
|
8768
|
+
const nameOf = (line) => line.trim().slice(1).split("\"")[0] ?? "";
|
|
8769
|
+
const next = sorted ? lines.findIndex((line, index) => index > start && index < end && nameOf(line) > name) : -1;
|
|
8770
|
+
if (next >= 0) lines.splice(next, 0, `${entry},`);
|
|
8771
|
+
else {
|
|
8772
|
+
if (end - 1 > start) lines[end - 1] = `${lines[end - 1] ?? ""},`;
|
|
8773
|
+
lines.splice(end, 0, entry);
|
|
8774
|
+
}
|
|
8775
|
+
return lines.join(eol);
|
|
8776
|
+
}
|
|
8777
|
+
/** This function adds a block with one entry after the last block of the root object. */
|
|
8778
|
+
function addBlock(text, field, name, value) {
|
|
8779
|
+
const eol = text.includes("\r\n") ? "\r\n" : "\n";
|
|
8780
|
+
const lines = text.split(/\r?\n/);
|
|
8781
|
+
const end = lines.lastIndexOf("}");
|
|
8782
|
+
if (end < 1) return void 0;
|
|
8783
|
+
lines[end - 1] = `${lines[end - 1] ?? ""},`;
|
|
8784
|
+
lines.splice(end, 0, ` ${JSON.stringify(field)}: {`, ` ${JSON.stringify(name)}: ${JSON.stringify(value)}`, " }");
|
|
8785
|
+
return lines.join(eol);
|
|
8786
|
+
}
|
|
8787
|
+
/** This function gives the text of the root `package.json` with the script and the dependency, or undefined. */
|
|
8788
|
+
function withScript(root, script) {
|
|
8789
|
+
const add = (text, field, name, value, sorted) => root.manifest[field] === void 0 ? addBlock(text, field, name, value) : addEntry(text, field, name, value, sorted);
|
|
8790
|
+
const scripted = add(root.text, "scripts", script, COMMAND, false);
|
|
8791
|
+
if (scripted === void 0) return void 0;
|
|
8792
|
+
return DEPENDENCY_FIELDS.some((field) => specifiersOf(root.manifest, field).some(([name]) => name === API_REPORT)) ? scripted : add(scripted, "devDependencies", API_REPORT, API_REPORT_RANGE, true);
|
|
8793
|
+
}
|
|
8794
|
+
const apiReportScript = {
|
|
8795
|
+
id: "api-report-script",
|
|
8796
|
+
title: "A repository with a public package has the root script `check:api`.",
|
|
8797
|
+
reason: "The shared CI starts each script of its list that `package.json` has, and it skips the others. On 2026-11-04, 8 of the 12 repositories without the script had a public package, so a change of their API had no check.",
|
|
8798
|
+
fix: "Add the script `\"check:api\": \"api-report check\"` and a dev dependency on `@mark1russell7/api-report`. Then build and start `api-report update`. The release train writes the first report in its update.",
|
|
8799
|
+
sources: [
|
|
8800
|
+
{
|
|
8801
|
+
repo: "template",
|
|
8802
|
+
rule: "api-report",
|
|
8803
|
+
doc: "CLAUDE.md:27"
|
|
8804
|
+
},
|
|
8805
|
+
{
|
|
8806
|
+
repo: "packing",
|
|
8807
|
+
rule: "api-report",
|
|
8808
|
+
doc: "CLAUDE.md:20"
|
|
8809
|
+
},
|
|
8810
|
+
{
|
|
8811
|
+
repo: "layout-contract",
|
|
8812
|
+
rule: "api-report",
|
|
8813
|
+
doc: "CLAUDE.md:20"
|
|
8814
|
+
}
|
|
8815
|
+
],
|
|
8816
|
+
options: { script: {
|
|
8817
|
+
type: "string",
|
|
8818
|
+
default: "check:api",
|
|
8819
|
+
description: "The root script that checks the API reports."
|
|
8820
|
+
} },
|
|
8821
|
+
check(context, options) {
|
|
8822
|
+
const script = typeof options["script"] === "string" ? options["script"] : "check:api";
|
|
8823
|
+
const published = codePackages(context).filter(isPublic);
|
|
8824
|
+
if (published.length === 0) return [];
|
|
8825
|
+
const root = context.rootPackage;
|
|
8826
|
+
const value = root.manifest["scripts"];
|
|
8827
|
+
const scripts = typeof value === "object" && value !== null ? value : {};
|
|
8828
|
+
if (typeof scripts[script] === "string" && scripts[script] !== "") return [];
|
|
8829
|
+
const names = published.map((pkg) => String(pkg.manifest["name"] ?? pkg.folder));
|
|
8830
|
+
const line = lineOf(root.text, "\"scripts\"");
|
|
8831
|
+
const after = withScript(root, script);
|
|
8832
|
+
const edits = after === void 0 ? [] : [{
|
|
8833
|
+
file: root.file,
|
|
8834
|
+
before: root.text,
|
|
8835
|
+
after
|
|
8836
|
+
}];
|
|
8837
|
+
return [{
|
|
8838
|
+
file: root.file,
|
|
8839
|
+
...line === void 0 ? {} : { line },
|
|
8840
|
+
message: `The root package.json has no script "${script}", and the repository has a public package: ${names.join(", ")}.`,
|
|
8841
|
+
...edits.length > 0 ? { edits } : {}
|
|
8842
|
+
}];
|
|
8843
|
+
}
|
|
8844
|
+
};
|
|
8746
8845
|
// src/rules/pages-site.ts
|
|
8747
8846
|
/**
|
|
8748
8847
|
* The rule `pages-site`: a public repository has a site. A workflow uses the Pages workflow of the template, and the
|
|
@@ -11514,6 +11613,7 @@ const RULES = [
|
|
|
11514
11613
|
requiredScripts,
|
|
11515
11614
|
noBuildOutput,
|
|
11516
11615
|
noLocalPaths,
|
|
11616
|
+
apiReportScript,
|
|
11517
11617
|
releaseFiles,
|
|
11518
11618
|
unreleasedChange,
|
|
11519
11619
|
changelogVersion,
|
|
@@ -11961,6 +12061,6 @@ function runMap(args, io) {
|
|
|
11961
12061
|
else io.stdout(mapText(found));
|
|
11962
12062
|
return 0;
|
|
11963
12063
|
}
|
|
11964
|
-
export {
|
|
12064
|
+
export { noLocalPaths as $, pathsOf as A, cuePreset as At, roadmapParses as B, readJsonc as Bt, configsOfScript as C, ACTIONS_COMMIT as Ct, hasTests as D, summaryName as Dt, testsRequired as E, prPathFilters as Et, sharedDocsRule as F, inFolder as Ft, isPinned as G, globToRegExp as Gt, releaseFiles as H, runGit as Ht, repositoryOfRemote as I, keyLine as It, pagesCalls as J, defaultOptions as Jt, pinnedGitDeps as K, packageFolders as Kt, runnerBudget as L, lineOf as Lt, HOME_TIMEOUT_MS as M, cleanPath as Mt, blockHash as N, codePackages as Nt, tsconfigTest as O, readWorkflow as Ot, githubFetch as P, hasFile as Pt, HOME_PATTERNS as Q, scheduleMinute as R, matchesAny as Rt, typedScripts as S, HOME_EXPORTS as St, typedFiles as T, gateTrigger as Tt, pushMainOnly as U, specifiersOf as Ut, requiredScripts as V, replaceLine as Vt, isGitSpecifier as W, globFolders as Wt, apiReportScript as X, pagesSite as Y, parseConfig as Yt, DEFAULT_ALLOWED as Z, unreleasedChange as _, findHomes as _t, listRules as a, authorOf as at, TRAIN_SCOPES as b, mergeHomes as bt, runCli as c, mitText as ct, RULES as d, homePackage as dt, noBuildOutput as et, workspaceProtocol as f, messageOf as ft, npmLookup as g, MAP_RULE as gt, UNSHIPPED_FILES as h, HOMES as ht, formatResult as i, LICENSE_TEXTS as it, sourceMain as j, DEPENDENCY_FIELDS as jt, isSourcePath as k, STRICT_OPTIONS as kt, runFix as l, repositoryIsPublic as lt, SHIPPED_FIELDS as m, signaturesOf as mt, annotations as n, hasImportMetaMain as nt, readConfig as o, licenseFile as ot, NPM_REGISTRY as p, repoOf as pt, PAGES_WORKFLOWS as q, workspaceGlobs as qt, createContext as r, mainCheck as rt, runChecks as s, licenseFileOf as st, USAGE as t, REAL_COMPARE as tt, summaryMarkdown as u, declaredName as ut, unreleasedChangeRule as v, mapMarkdown as vt, scriptsOf as w, convertGate as wt, trustPolicy as x, readOverlay as xt, IGNORE_AFTER as y, mapText as yt, roadmapOfLine as z, parseJsonc as zt };
|
|
11965
12065
|
|
|
11966
|
-
//# sourceMappingURL=run-
|
|
12066
|
+
//# sourceMappingURL=run-ByqpkrLT.js.map
|