@danypops/pi-packed 0.21.6 → 0.21.7
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
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
import { createLogger } from "../shared/log.ts";
|
|
16
16
|
|
|
17
17
|
const log = createLogger("registry");
|
|
18
|
+
const README_MAX_CHARS = 50_000;
|
|
18
19
|
|
|
19
20
|
/** Upstream etiquette: honor Retry-After on 429, exponential backoff
|
|
20
21
|
* otherwise, give up after RETRY_MAX_ATTEMPTS. */
|
|
@@ -125,9 +126,11 @@ export class HttpRegistry implements Registry {
|
|
|
125
126
|
pi?: Record<string, unknown>;
|
|
126
127
|
peerDependencies?: Record<string, string>;
|
|
127
128
|
scripts?: Record<string, string>;
|
|
129
|
+
readme?: unknown;
|
|
128
130
|
dist?: { unpackedSize?: number; integrity?: string; attestations?: { url?: string; provenance?: unknown } };
|
|
129
131
|
};
|
|
130
132
|
const manifestFields = v.pi ? Object.keys(v.pi).filter((key) => ["extensions", "skills", "prompts", "themes"].includes(key)) : [];
|
|
133
|
+
const readme = boundedString(v.readme, README_MAX_CHARS);
|
|
131
134
|
return {
|
|
132
135
|
name: boundedString(v.name, 214) ?? boundedString(name, 214)!,
|
|
133
136
|
version: boundedString(v.version, 128) ?? "",
|
|
@@ -144,7 +147,8 @@ export class HttpRegistry implements Registry {
|
|
|
144
147
|
pi: boundedPiManifest(v.pi),
|
|
145
148
|
peerDependencies: boundedDependencies(v.peerDependencies),
|
|
146
149
|
scripts: boundedDependencies(v.scripts),
|
|
147
|
-
|
|
150
|
+
readme,
|
|
151
|
+
readmeAvailable: readme !== undefined && readme.trim().length > 0,
|
|
148
152
|
unpackedSize: v.dist?.unpackedSize,
|
|
149
153
|
packageEvidence:
|
|
150
154
|
manifestFields.length > 0
|
|
@@ -69,6 +69,7 @@ describe("HttpRegistry", () => {
|
|
|
69
69
|
license: "MIT",
|
|
70
70
|
keywords: ["pi-package", "lsp"],
|
|
71
71
|
pi: { extensions: ["./src/index.ts"] },
|
|
72
|
+
readme: `# pi-lsp\n\n${"r".repeat(60_000)}`,
|
|
72
73
|
dist: {
|
|
73
74
|
unpackedSize: 12345,
|
|
74
75
|
integrity: "sha512-test",
|
|
@@ -103,8 +104,10 @@ describe("HttpRegistry", () => {
|
|
|
103
104
|
repository: "git+https://github.com/x/pi-lsp.git",
|
|
104
105
|
license: "MIT",
|
|
105
106
|
unpackedSize: 12345,
|
|
106
|
-
readmeAvailable:
|
|
107
|
+
readmeAvailable: true,
|
|
107
108
|
});
|
|
109
|
+
expect(info.readme).toHaveLength(50_000);
|
|
110
|
+
expect(info.readme).toStartWith("# pi-lsp");
|
|
108
111
|
expect(info.pi?.extensions).toBeDefined();
|
|
109
112
|
expect(info.packageEvidence).toMatchObject({ shape: "manifest", verified: false });
|
|
110
113
|
expect(info.publication).toEqual({
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { afterAll, beforeAll, describe, expect, it } from "bun:test";
|
|
2
|
+
import { mkdtempSync, rmSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import type { Server } from "bun";
|
|
6
|
+
import type { Installer, UpdateOutcome } from "../src/packages/package.ts";
|
|
7
|
+
import { PackedClient } from "../src/public/client.ts";
|
|
8
|
+
import { HttpRegistry } from "../src/registry/registry.ts";
|
|
9
|
+
import { createApp } from "../src/daemon/service.ts";
|
|
10
|
+
|
|
11
|
+
const TOKEN = "e".repeat(64);
|
|
12
|
+
const PUBLISHED_README = `# @danypops/enigma
|
|
13
|
+
|
|
14
|
+
Encrypted credential vault and supervisor daemon. Holds delegated OAuth/API
|
|
15
|
+
credentials for other daemons and injects them as environment variables into
|
|
16
|
+
spawned child processes.
|
|
17
|
+
|
|
18
|
+
## Why this exists
|
|
19
|
+
|
|
20
|
+
Consumers receive only their scoped credentials.`;
|
|
21
|
+
|
|
22
|
+
class NoopInstaller implements Installer {
|
|
23
|
+
async install(): Promise<string> {
|
|
24
|
+
throw new Error("not exercised");
|
|
25
|
+
}
|
|
26
|
+
async remove(): Promise<string> {
|
|
27
|
+
throw new Error("not exercised");
|
|
28
|
+
}
|
|
29
|
+
async update(): Promise<UpdateOutcome> {
|
|
30
|
+
throw new Error("not exercised");
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
describe("published npm metadata E2E", () => {
|
|
35
|
+
let npmServer: Server<undefined>;
|
|
36
|
+
let daemonServer: Server<undefined>;
|
|
37
|
+
let stateDir: string;
|
|
38
|
+
const npmRequests: Array<{ path: string; accept: string | null }> = [];
|
|
39
|
+
|
|
40
|
+
beforeAll(() => {
|
|
41
|
+
stateDir = mkdtempSync(join(tmpdir(), "packed-npm-metadata-"));
|
|
42
|
+
npmServer = Bun.serve({
|
|
43
|
+
hostname: "127.0.0.1",
|
|
44
|
+
port: 0,
|
|
45
|
+
fetch(request) {
|
|
46
|
+
const url = new URL(request.url);
|
|
47
|
+
npmRequests.push({ path: url.pathname, accept: request.headers.get("accept") });
|
|
48
|
+
if (url.pathname.endsWith("/latest")) {
|
|
49
|
+
return Response.json({
|
|
50
|
+
name: "@danypops/enigma",
|
|
51
|
+
version: "0.22.1",
|
|
52
|
+
description: "Encrypted credential vault daemon",
|
|
53
|
+
license: "MIT",
|
|
54
|
+
repository: { type: "git", url: "git+https://github.com/DanyPops/enigma.git" },
|
|
55
|
+
readme: PUBLISHED_README,
|
|
56
|
+
dist: { integrity: "sha512-published-fixture" },
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return new Response("not found", { status: 404 });
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
const app = createApp({
|
|
63
|
+
reg: new HttpRegistry(`http://127.0.0.1:${npmServer.port}`, 20, 0, 1),
|
|
64
|
+
inst: new NoopInstaller(),
|
|
65
|
+
token: TOKEN,
|
|
66
|
+
stateDir,
|
|
67
|
+
});
|
|
68
|
+
daemonServer = Bun.serve({ hostname: "127.0.0.1", port: 0, fetch: app.fetch });
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
afterAll(() => {
|
|
72
|
+
daemonServer.stop(true);
|
|
73
|
+
npmServer.stop(true);
|
|
74
|
+
rmSync(stateDir, { recursive: true, force: true });
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("preserves an npm-published README through HttpRegistry, daemon RPC, and PackedClient", async () => {
|
|
78
|
+
const client = new PackedClient(`http://127.0.0.1:${daemonServer.port}`, TOKEN);
|
|
79
|
+
const info = await client.info("@danypops/enigma");
|
|
80
|
+
|
|
81
|
+
expect(npmRequests).toEqual([{ path: "/%40danypops/enigma/latest", accept: "application/json" }]);
|
|
82
|
+
expect(info).toMatchObject({
|
|
83
|
+
name: "@danypops/enigma",
|
|
84
|
+
version: "0.22.1",
|
|
85
|
+
license: "MIT",
|
|
86
|
+
readmeAvailable: true,
|
|
87
|
+
readme: PUBLISHED_README,
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
});
|