GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — OpenAgentPack/scripts/release/publish.test.ts at main · modelstudioai/OpenAgentPack

Expand file tree

/

publish.test.ts

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
74 lines (68 loc) · 2.67 KB
/

publish.test.ts

Copy path

File metadata and controls

74 lines (68 loc) · 2.67 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { describe, expect, test } from "bun:test";
import {
assertPublishEnvironment,
inferDistTag,
publishCommand,
publishedPackageSpec,
publishedVersionMatches,
shouldSkipPublishedVersion,
} from "./publish.ts";
describe("release publish recovery", () => {
test("uses an exact package version when querying npm", () => {
expect(publishedPackageSpec("@openagentpack/sdk", "1.2.3-beta.4")).toBe("@openagentpack/[email protected]");
});
test("recognizes npm view JSON output", () => {
expect(publishedVersionMatches('"1.2.3"', "1.2.3")).toBe(true);
expect(publishedVersionMatches('["1.2.3"]', "1.2.3")).toBe(true);
expect(publishedVersionMatches('"1.2.2"', "1.2.3")).toBe(false);
expect(publishedVersionMatches("not-json", "1.2.3")).toBe(false);
});
test("skips existing versions only during a real publish", () => {
expect(shouldSkipPublishedVersion(false, true)).toBe(true);
expect(shouldSkipPublishedVersion(true, true)).toBe(false);
expect(shouldSkipPublishedVersion(false, false)).toBe(false);
});
test("derives a safe npm dist-tag from prerelease versions", () => {
expect(inferDistTag("1.0.1-beta.5")).toBe("beta");
expect(inferDistTag("1.0.1-beta-a1b2c3d-0d6e4079-20260720")).toBe("beta");
expect(inferDistTag("2.0.0-rc.1")).toBe("rc");
expect(inferDistTag("1.0.1")).toBeUndefined();
});
test("uses a registry-independent pack check for dry runs", () => {
expect(publishCommand(true, "1.2.3")).toEqual(["npm", "pack", "--dry-run"]);
expect(publishCommand(false, "1.2.3")).toEqual(["npm", "publish", "--access", "public", "--provenance"]);
expect(publishCommand(false, "1.2.3-beta.4")).toEqual([
"npm",
"publish",
"--access",
"public",
"--provenance",
"--tag",
"beta",
]);
expect(publishCommand(false, "1.2.3-beta-a1b2c3d-0d6e4079-20260720", "beta")).toEqual([
"npm",
"publish",
"--access",
"public",
"--provenance",
"--tag",
"beta",
]);
});
test("allows real publishing only inside GitHub Actions", () => {
const workflow = {
GITHUB_ACTIONS: "true",
GITHUB_WORKFLOW: "Publish npm",
GITHUB_EVENT_NAME: "workflow_dispatch",
};
expect(() => assertPublishEnvironment(false, {})).toThrow("GitHub Actions");
expect(() => assertPublishEnvironment(false, { ...workflow, GITHUB_WORKFLOW: "CI" })).toThrow("GitHub Actions");
expect(() => assertPublishEnvironment(false, workflow)).not.toThrow();
expect(() => assertPublishEnvironment(false, { ...workflow, GITHUB_EVENT_NAME: "push" })).not.toThrow();
expect(() => assertPublishEnvironment(false, { ...workflow, GITHUB_EVENT_NAME: "pull_request" })).toThrow(
"GitHub Actions",
);
expect(() => assertPublishEnvironment(true, {})).not.toThrow();
});
});
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.