Skip to content

Commit 00a9fe1

Browse files
committed
fix: use static license badges for private repos
1 parent 18153bb commit 00a9fe1

9 files changed

Lines changed: 72 additions & 18 deletions

File tree

‎RELEASE_NOTES.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Release Notes
22

3+
## 15.0.1 — 2026-10-25
4+
5+
### Fixed
6+
7+
- Use a static License badge for private repositories and derive its value from package metadata.
8+
39
## 15.0.0 — 2026-10-21
410

511
### Changed

‎package-lock.json‎

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@eliware/test",
3-
"version": "15.0.0",
3+
"version": "15.0.1",
44
"type": "module",
55
"description": "Shared deterministic repository validation for Eliware projects",
66
"keywords": [
@@ -44,7 +44,7 @@
4444
"node": ">=26"
4545
},
4646
"dependencies": {
47-
"@babel/parser": "^8.0.7",
47+
"@babel/parser": "^8.0.8",
4848
"ajv": "^8.20.0",
4949
"ajv-formats": "^3.0.1",
5050
"istanbul-lib-instrument": "^6.0.3",

‎specs/conventions/general-deterministic.yaml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ directives:
8484
@eliware/<repo-name>` followed by badges on the same line.
8585
- Use the npm, License, and CI badges in that order. Include npm only when
8686
package.json.eliware.apply includes npm-published.
87+
- For repositories that apply the private profile, use the private License badge and
88+
package.json.license as its message.
89+
- For repositories without the private profile, use the public License badge.
8790
- Use the exact brand image, badge targets, and title markers shown in the examples.
8891
- Include all sections resolved from package.json.eliware.apply and
8992
ordering/readme-sections.yaml.

‎specs/conventions/ordering/ordering-data-schema.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ orders:
134134
- title
135135
- npmBadge
136136
- licenseBadge
137+
- privateLicenseBadge
137138
- ciBadge
138139
supportBlock: text
139140
licenseLink: text

‎specs/conventions/ordering/readme-sections.yaml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ orders:
106106
com/package/@eliware/<repo-name>)"
107107
licenseBadge: "[![License](https://img.shields.io/github/license/eliware/<repo-name>)](ht\
108108
tps://github.com/eliware/<repo-name>/blob/main/LICENSE)"
109+
privateLicenseBadge: "[![License](https://img.shields.io/badge/license-<license>-blue)](ht\
110+
tps://github.com/eliware/<repo-name>/blob/main/LICENSE)"
109111
ciBadge: "[![CI](https://github.com/eliware/<repo-name>/actions/workflows/ci.yaml/badge.s\
110112
vg)](https://github.com/eliware/<repo-name>/actions/workflows/ci.yaml)"
111113
supportBlock: "For help, questions, or to chat with the author and community, visit:

‎src/checks/shared/E-0.1.0.1.3/validate-readme/branding.mjs‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,17 @@ export function validateReadmeBranding(readme, packageJson = {}) {
2525
const badgeNames = includeNpm
2626
? order.badgeOrder
2727
: order.badgeOrder.filter((badge) => badge !== "npm");
28+
const privateRepository = packageJson?.eliware?.apply?.includes("private");
2829
const badgeLine = `${template.title.replace("@eliware/<repo-name>", name)} ${badgeNames
29-
.map((badge) => template[`${badge.toLowerCase()}Badge`]?.replaceAll("<repo-name>", slug))
30+
.map((badge) => {
31+
const key =
32+
badge === "License" && privateRepository
33+
? "privateLicenseBadge"
34+
: `${badge.toLowerCase()}Badge`;
35+
return template[key]
36+
?.replaceAll("<repo-name>", slug)
37+
.replaceAll("<license>", encodeURIComponent(packageJson?.license ?? ""));
38+
})
3039
.join(" ")}`;
3140
const lines = readme.split(/\r?\n/u);
3241
return lines[0] === template.brand && lines[2] === badgeLine

‎src/validation/shared/conventions/canonical-order-requirements/readme-sections.mjs‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,14 @@ export const readmeSectionsRequirements = {
1818
},
1919
maps: {
2020
headerLines: ["brand", "title-and-badges", "description", "table-of-contents"],
21-
headerTemplates: ["brand", "title", "npmBadge", "licenseBadge", "ciBadge"],
21+
headerTemplates: [
22+
"brand",
23+
"title",
24+
"npmBadge",
25+
"licenseBadge",
26+
"privateLicenseBadge",
27+
"ciBadge",
28+
],
2229
profileSections: canonicalProfileOrder,
2330
sharedSections: ["Commands"],
2431
},

‎tests/checks/shared/E-0.1.0.1.3/validate-readme/branding.test.mjs‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,32 @@ test("accepts canonical package badges", () => {
1616
expect(validateReadmeBranding(readme, pkg)).toBeNull();
1717
});
1818

19+
test("uses the package license in the private repository badge", () => {
20+
const privatePackage = {
21+
...pkg,
22+
license: "MIT",
23+
eliware: { apply: ["general", "private"] },
24+
};
25+
const privateLine = line
26+
.replace(
27+
" [![npm](https://img.shields.io/npm/v/@eliware/fixture)](https://www.npmjs.com/package/@eliware/fixture)",
28+
"",
29+
)
30+
.replace(
31+
"https://img.shields.io/github/license/eliware/fixture",
32+
"https://img.shields.io/badge/license-MIT-blue",
33+
);
34+
35+
expect(validateReadmeBranding(`${header}\n\n${privateLine}`, privatePackage)).toBeNull();
36+
expect(validateReadmeBranding(readme, privatePackage)).toContain("badge row");
37+
expect(
38+
validateReadmeBranding(
39+
`${header}\n\n${privateLine.replace("license-MIT-blue", "license-Apache-2.0-blue")}`,
40+
privatePackage,
41+
),
42+
).toContain("badge row");
43+
});
44+
1945
test("rejects incomplete package metadata and badge rows", () => {
2046
expect(validateReadmeBranding(readme, {})).toContain("package name");
2147
expect(validateReadmeBranding("wrong", pkg)).toContain("canonical logo header");

0 commit comments

Comments
 (0)