@danypops/pi-packed 0.21.11 → 0.21.13
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/extension/src/tui.ts +124 -33
- package/package.json +2 -2
- package/service/src/adoption/install-validation.ts +48 -2
- package/service/src/adoption/verify-load-paths-child.mjs +55 -0
- package/service/test/advisories.test.ts +17 -9
- package/service/test/cleanup.test.ts +7 -2
- package/service/test/cli.test.ts +29 -13
- package/service/test/db.test.ts +8 -2
- package/service/test/doctor.test.ts +7 -2
- package/service/test/domain.test.ts +22 -12
- package/service/test/index.test.ts +22 -9
- package/service/test/install-validation.test.ts +50 -6
- package/service/test/install.test.ts +20 -10
- package/service/test/pack-score.test.ts +8 -2
- package/service/test/pi-version.test.ts +15 -5
- package/service/test/public-client.test.ts +16 -6
- package/service/test/publish.test.ts +13 -3
- package/service/test/registry-contract.test.ts +11 -2
- package/service/test/resources.test.ts +7 -2
- package/service/test/security.test.ts +15 -5
- package/service/test/service.test.ts +19 -9
- package/service/test/setup.test.ts +14 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { describe, expect, it } from "bun:test";
|
|
2
|
-
import { mkdirSync, mkdtempSync, writeFileSync } from "node:fs";
|
|
1
|
+
import { afterEach, describe, expect, it } from "bun:test";
|
|
2
|
+
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import type { ServiceSpec } from "@danypops/vehicle-server/service";
|
|
@@ -105,12 +105,22 @@ class FakeDaemonServiceInstaller implements DaemonServiceInstaller {
|
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
+
const roots: string[] = [];
|
|
109
|
+
afterEach(() => {
|
|
110
|
+
for (const root of roots.splice(0)) rmSync(root, { recursive: true, force: true });
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
function track(dir: string): string {
|
|
114
|
+
roots.push(dir);
|
|
115
|
+
return dir;
|
|
116
|
+
}
|
|
117
|
+
|
|
108
118
|
function deps(over: Partial<Deps> = {}): Deps {
|
|
109
119
|
return {
|
|
110
120
|
reg: new FakeRegistry(),
|
|
111
121
|
inst: new FakeInstaller(),
|
|
112
122
|
token: "test-token",
|
|
113
|
-
stateDir: mkdtempSync(join(tmpdir(), "packed-")),
|
|
123
|
+
stateDir: track(mkdtempSync(join(tmpdir(), "packed-"))),
|
|
114
124
|
...over,
|
|
115
125
|
};
|
|
116
126
|
}
|
|
@@ -272,7 +282,7 @@ describe("service app", () => {
|
|
|
272
282
|
|
|
273
283
|
it("POST /install configures an npm package's persistent Vehicle under the same approval", async () => {
|
|
274
284
|
const svc = new FakeDaemonServiceInstaller();
|
|
275
|
-
const piHome = mkdtempSync(join(tmpdir(), "packed-install-vehicle-"));
|
|
285
|
+
const piHome = track(mkdtempSync(join(tmpdir(), "packed-install-vehicle-")));
|
|
276
286
|
const app = createApp(deps({ daemonServiceInstaller: svc, piHome }));
|
|
277
287
|
const response = await app.fetch(
|
|
278
288
|
new Request("http://x/install", {
|
|
@@ -328,7 +338,7 @@ describe("service app", () => {
|
|
|
328
338
|
|
|
329
339
|
it("POST /install-service installs a real service once approved, reporting the resolved spec", async () => {
|
|
330
340
|
const svc = new FakeDaemonServiceInstaller();
|
|
331
|
-
const piHome = mkdtempSync(join(tmpdir(), "packed-pi-"));
|
|
341
|
+
const piHome = track(mkdtempSync(join(tmpdir(), "packed-pi-")));
|
|
332
342
|
const app = createApp(deps({ daemonServiceInstaller: svc, piHome }));
|
|
333
343
|
|
|
334
344
|
const res = await app.fetch(
|
|
@@ -406,7 +416,7 @@ describe("service app", () => {
|
|
|
406
416
|
|
|
407
417
|
it("POST /restart-service restarts a real service once approved, reporting the resolved spec", async () => {
|
|
408
418
|
const svc = new FakeDaemonServiceInstaller();
|
|
409
|
-
const piHome = mkdtempSync(join(tmpdir(), "packed-pi-"));
|
|
419
|
+
const piHome = track(mkdtempSync(join(tmpdir(), "packed-pi-")));
|
|
410
420
|
const app = createApp(deps({ daemonServiceInstaller: svc, piHome }));
|
|
411
421
|
|
|
412
422
|
const res = await app.fetch(
|
|
@@ -492,7 +502,7 @@ describe("service app", () => {
|
|
|
492
502
|
|
|
493
503
|
it("POST /update reconciles an installed Vehicle after a real package change", async () => {
|
|
494
504
|
const svc = new FakeDaemonServiceInstaller();
|
|
495
|
-
const piHome = mkdtempSync(join(tmpdir(), "packed-update-vehicle-"));
|
|
505
|
+
const piHome = track(mkdtempSync(join(tmpdir(), "packed-update-vehicle-")));
|
|
496
506
|
const app = createApp(deps({ daemonServiceInstaller: svc, piHome }));
|
|
497
507
|
const response = await app.fetch(
|
|
498
508
|
new Request("http://x/update", {
|
|
@@ -542,7 +552,7 @@ describe("service app", () => {
|
|
|
542
552
|
});
|
|
543
553
|
|
|
544
554
|
it("GET /installed lists packages from pi settings", async () => {
|
|
545
|
-
const piHome = mkdtempSync(join(tmpdir(), "packed-pi-"));
|
|
555
|
+
const piHome = track(mkdtempSync(join(tmpdir(), "packed-pi-")));
|
|
546
556
|
writeFileSync(
|
|
547
557
|
join(piHome, "settings.json"),
|
|
548
558
|
JSON.stringify({ packages: ["npm:pi-extension-manager@0.8.2", { source: "npm:obj@2.0.0" }] }),
|
|
@@ -582,7 +592,7 @@ describe("service app", () => {
|
|
|
582
592
|
});
|
|
583
593
|
|
|
584
594
|
it("POST /remove removes declared Vehicle state before deleting the package", async () => {
|
|
585
|
-
const piHome = mkdtempSync(join(tmpdir(), "packed-remove-vehicle-"));
|
|
595
|
+
const piHome = track(mkdtempSync(join(tmpdir(), "packed-remove-vehicle-")));
|
|
586
596
|
const packageDir = join(piHome, "npm", "node_modules", "probe");
|
|
587
597
|
mkdirSync(packageDir, { recursive: true });
|
|
588
598
|
writeFileSync(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { describe, expect, it } from "bun:test";
|
|
2
|
-
import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
1
|
+
import { afterEach, describe, expect, it } from "bun:test";
|
|
2
|
+
import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import type { Installer, PkgInfo, Registry, SearchPage, UpdateOutcome } from "../src/packages/package.ts";
|
|
@@ -54,8 +54,18 @@ class GitFixture implements GitResolutionPort {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
const roots: string[] = [];
|
|
58
|
+
afterEach(() => {
|
|
59
|
+
for (const root of roots.splice(0)) rmSync(root, { recursive: true, force: true });
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
function track(dir: string): string {
|
|
63
|
+
roots.push(dir);
|
|
64
|
+
return dir;
|
|
65
|
+
}
|
|
66
|
+
|
|
57
67
|
function piHome(withPackage = true): string {
|
|
58
|
-
const root = mkdtempSync(join(tmpdir(), "packed-setup-home-"));
|
|
68
|
+
const root = track(mkdtempSync(join(tmpdir(), "packed-setup-home-")));
|
|
59
69
|
const packages = withPackage ? ["npm:pi-demo"] : [];
|
|
60
70
|
writeFileSync(join(root, "settings.json"), JSON.stringify({ packages }));
|
|
61
71
|
if (withPackage) {
|
|
@@ -73,7 +83,7 @@ function piHome(withPackage = true): string {
|
|
|
73
83
|
}
|
|
74
84
|
|
|
75
85
|
function project(): string {
|
|
76
|
-
const root = mkdtempSync(join(tmpdir(), "packed-setup-project-"));
|
|
86
|
+
const root = track(mkdtempSync(join(tmpdir(), "packed-setup-project-")));
|
|
77
87
|
mkdirSync(join(root, ".pi"), { recursive: true });
|
|
78
88
|
return root;
|
|
79
89
|
}
|