g1t/apps/web/app/lib/project-kind.test.ts

41 lines1,755 bytesCodeBlame

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

A project is an app or a library: libraries show their package and how to ship a release, not production1import assert from "node:assert/strict";
2import { test } from "node:test";
3
4import { hasRelease, libraryPackages, packageLine, packagePath, publishGuide } from "./project-kind.ts";
5
6const pkg = (over: Record<string, unknown>) => ({
7 ecosystem: "composer" as const,
8 name: "psr/log",
9 workspace: "flagon-io",
10 latest: "3.0.2",
11 versions: 3,
12 updated_at: "2026-10-01T00:00:00Z",
13 ...over,
14});
15
16test("a package reads as its registry, its name and its latest version", () => {
17 assert.equal(packageLine(pkg({})), "Composer · psr/log 3.0.2");
18 assert.equal(packageLine(pkg({ ecosystem: "npm", name: "ui", latest: null })), "npm · @flagon-io/ui");
19 assert.equal(packagePath(pkg({})), "/flagon-io/-/packages/composer/psr/log");
20});
21
22test("what a library publishes comes before an image, released ones first", () => {
23 const list = [
24 pkg({ ecosystem: "container", name: "img", updated_at: "2026-10-05T00:00:00Z" }),
25 pkg({ name: "empty", versions: 0, updated_at: "2026-10-04T00:00:00Z" }),
26 pkg({}),
27 ];
28 assert.deepEqual(libraryPackages(list).map((p) => p.name), ["psr/log", "empty", "img"]);
29 assert.equal(hasRelease(list), true);
30 assert.equal(hasRelease([pkg({ versions: 0 })]), false);
31 assert.equal(hasRelease([]), false);
32});
33
34test("each ecosystem links to how it publishes", () => {
35 assert.equal(publishGuide("composer")?.guide, "https://docs.g1t.sh/guides/composer/");
36 assert.equal(publishGuide("composer")?.start, "git tag v1.0.0 && git push --tags");
37 assert.equal(publishGuide("npm")?.start, "npm publish");
38 assert.equal(publishGuide("go")?.guide, "https://docs.g1t.sh/guides/go/");
39 assert.equal(publishGuide("python")?.guide, "https://docs.g1t.sh/guides/packages/");
40 assert.equal(publishGuide(null), null);
41});