@mark1russell7/conventions 0.29.0 → 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/index.d.ts +25 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +69 -1
- package/build/index.js.map +1 -0
- package/package.json +1 -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/index.d.ts
CHANGED
|
@@ -476,6 +476,31 @@ interface CliIo {
|
|
|
476
476
|
export declare const USAGE: string;
|
|
477
477
|
/** This function starts the bin with the arguments `args`, and gives its exit code. */
|
|
478
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;
|
|
479
504
|
/**
|
|
480
505
|
* This function gives a regular expression for a glob of `/` paths. `*` matches a part of one path
|
|
481
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/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/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,aAAa;;;;;wBAMrB,aAAa,SAAS,KAAK,oDAAoD;;UC1M9E;;WAEN;;WAEA;;WAEA;;WAEA,SAAS;;;UAIH;;WAEN;;WAEA,OAAO,SAAS,eAAe;;;wBAW1B,eAAe,MAAM,OAAO;;;;;;;wBAU5B,YAAY,gBAAgB,gBAAgB,SAAS;;qBCnCxD;qBA4FA,WAAW;;UCtFP;WACN;WACA;WACA;;;wBAIK,cAAc,eAAe;;qBAoBhC;;wBAyBG,YAAY;;;;;;;wBAkBZ,YAAY,cAAc,cAAc;EAAoC;;EAAmB;;qBAwIlG,a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RK,YAAY;qBC/VZ,cAAc;;qBC3Bd;;qBAGA;qBA6DA,aAAa;;;;;KC9Dd;WAA4B;WAAsC,QAAQ,SAAS;;WAAuC;;;KAG1H,kBAAkB,0BAA0B,qBAAqB,oBAAoB;;qBAGpF;;qBAGA;;qBAkBA;;;;;qBAyBA,WAAW;;wBAmGR,qBAAqB,SAAQ,iBAA6B;qBA4G7D,kBAAkB;qBCxQlB,mBAAmB;;qBCwBnB,gBAAgB;;qBC9BhB,cAAc,SAAS;WAA0B;WAA0B;;UC6EvE;WACN;WACA;WACA;;WAEA;WACA;;;UAIM;;WAEN;;WAEA;;WAEA;;;UAIM;WACN;WACA;WACA;WACA,gBAAgB;;;UAIV;;WAEN;;WAEA;;WAEA;WACA,iBAAiB;WACjB,eAAe;;;wBAgGV,aAAa,cAAc,eAAe;;UCrMzC;WACN;WACA;WACA;;WAEA;WACA,iBAAiB;;WAEjB;;WAEA;;;UAIM;WACN,gBAAgB;;WAEhB;;;UAIM;;WAEN;;WAEA;;WAEA;WACA,MAAM,SAAS;;WAEf,iBAAiB;;;wBAaZ,WAAW,cAAc,iBAAgB,SAAiB;;wBAO1D,cAAc,cAAc,QAAQ,mBAAmB,UAAS,KAAK,gCAAqC;;wBAwB1G,UAAU,SAAS,eAAe;;UAmDjC;;WAEN;;WAEA;;WAEA,QAAQ;;;;;;;wBAWH,OAAO,SAAS,eAAe;;wBAyC/B,aAAa,QAAQ;;wBA0BrB,gBAAgB,QAAQ;;wBAsBxB,YAAY,QAAQ;;wBAYpB,UAAU,QAAQ,+BAA+B,iBAAgB;;UAkBhE;WACN;WACA,KAAK,SAAS;WACd,SAAS;WACT,SAAS;;;qBAIP;;wBA6CG,OAAO,yBAAyB,IAAI;;;;;;
|
|
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/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,aAAa;;;;;wBAMrB,aAAa,SAAS,KAAK,oDAAoD;;UC1M9E;;WAEN;;WAEA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BAYpB,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"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@mark1russell7/conventions",
|
|
4
|
-
"version": "0.29.
|
|
4
|
+
"version": "0.29.1",
|
|
5
5
|
"description": "One check in CI for the conventions of a pnpm workspace that docs tell in prose: pinned git dependencies, source packages, tsconfig.test.json, no build output in git and more.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"conventions",
|