@intentius/chant 0.41.14 → 0.41.15
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/package.json
CHANGED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { describe, test, expect } from "vitest";
|
|
2
|
+
import { readFileSync, readdirSync, existsSync } from "fs";
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
4
|
+
import { join } from "path";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Every publishable package carries the identity block npm provenance
|
|
8
|
+
* validates at publish time.
|
|
9
|
+
*
|
|
10
|
+
* The k3d lexicon's first publish failed with E422: sigstore provenance
|
|
11
|
+
* checks `repository.url` against the repo the workflow ran from, and the
|
|
12
|
+
* newborn package.json had no `repository` at all — an error that surfaces
|
|
13
|
+
* only on the publish runner, after a release is already tagged, which is
|
|
14
|
+
* the most expensive place to learn a field is missing (chant-v0.41.14
|
|
15
|
+
* shipped 13 of 14 packages). The peer-deps guard next door exists for the
|
|
16
|
+
* same reason: a newborn package copies whichever fields its author
|
|
17
|
+
* remembered, and the registry's requirements are not in anyone's head.
|
|
18
|
+
*
|
|
19
|
+
* So: what provenance actually validates (repository.url), plus the fields
|
|
20
|
+
* whose absence makes a published page anonymous (license, description),
|
|
21
|
+
* checked per package, in CI, before any tag exists.
|
|
22
|
+
*/
|
|
23
|
+
const repoRoot = fileURLToPath(new URL("../../../../", import.meta.url));
|
|
24
|
+
const REPO_URL = "https://github.com/INTENTIUS/chant.git";
|
|
25
|
+
|
|
26
|
+
/** Every workspace package that publishes (publishConfig or not private). */
|
|
27
|
+
function publishablePackages(): Array<{ dir: string; pkg: Record<string, any> }> {
|
|
28
|
+
const out: Array<{ dir: string; pkg: Record<string, any> }> = [];
|
|
29
|
+
for (const parent of ["packages", "lexicons"]) {
|
|
30
|
+
const parentDir = join(repoRoot, parent);
|
|
31
|
+
if (!existsSync(parentDir)) continue;
|
|
32
|
+
for (const name of readdirSync(parentDir)) {
|
|
33
|
+
const p = join(parentDir, name, "package.json");
|
|
34
|
+
if (!existsSync(p)) continue;
|
|
35
|
+
const pkg = JSON.parse(readFileSync(p, "utf-8"));
|
|
36
|
+
if (pkg.private) continue;
|
|
37
|
+
out.push({ dir: join(parent, name), pkg });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return out;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
describe("publishable packages carry the identity provenance validates", () => {
|
|
44
|
+
test.each(publishablePackages().map((e) => [e.dir, e] as const))(
|
|
45
|
+
"%s has repository/license/description",
|
|
46
|
+
(_dir, entry) => {
|
|
47
|
+
const { dir, pkg } = entry;
|
|
48
|
+
expect(pkg.repository?.url, `${dir}: repository.url is what sigstore provenance checks`).toBe(REPO_URL);
|
|
49
|
+
expect(pkg.repository?.directory, `${dir}: repository.directory should name the package's home`).toBe(dir);
|
|
50
|
+
expect(pkg.license, `${dir}: license`).toBe("Apache-2.0");
|
|
51
|
+
expect(typeof pkg.description, `${dir}: description`).toBe("string");
|
|
52
|
+
expect((pkg.description ?? "").length, `${dir}: description is not empty`).toBeGreaterThan(0);
|
|
53
|
+
},
|
|
54
|
+
);
|
|
55
|
+
});
|