@app-vitals/agent-runtime 1.27.0 → 1.28.0
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/boot.ts +17 -18
- package/package.json +3 -3
- package/setup.integration.test.ts +74 -0
- package/setup.ts +112 -5
- package/setup.unit.test.ts +117 -3
package/boot.ts
CHANGED
|
@@ -538,24 +538,23 @@ export async function startAgent(
|
|
|
538
538
|
});
|
|
539
539
|
|
|
540
540
|
// Install agent-specific plugins from bundle (non-fatal)
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
}
|
|
541
|
+
// An empty bundle still reconciles (the last row may have been removed).
|
|
542
|
+
await installPlugins(
|
|
543
|
+
undefined,
|
|
544
|
+
undefined,
|
|
545
|
+
bundle.plugins ?? [],
|
|
546
|
+
undefined,
|
|
547
|
+
undefined,
|
|
548
|
+
undefined,
|
|
549
|
+
undefined,
|
|
550
|
+
undefined,
|
|
551
|
+
bundle.marketplaces,
|
|
552
|
+
).catch((err) =>
|
|
553
|
+
console.warn(
|
|
554
|
+
"[config-sync] agent plugin install failed (non-fatal):",
|
|
555
|
+
(err as Error).message,
|
|
556
|
+
),
|
|
557
|
+
);
|
|
559
558
|
|
|
560
559
|
// Sync the agent's scoped repos live ref
|
|
561
560
|
agentReposRef.set(bundle.repos);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@app-vitals/agent-runtime",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.28.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/app-vitals/agent.git",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"./workspace-paths": "./workspace-paths.ts"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@app-vitals/agent-admin": "1.
|
|
44
|
-
"@app-vitals/agent-lib": "1.
|
|
43
|
+
"@app-vitals/agent-admin": "1.28.0",
|
|
44
|
+
"@app-vitals/agent-lib": "1.28.0",
|
|
45
45
|
"@octokit/auth-app": "^8.2.0",
|
|
46
46
|
"@sentry/bun": "^10.63.0",
|
|
47
47
|
"@slack/bolt": "^5.0.0",
|
|
@@ -1826,3 +1826,77 @@ describe("installPlugins — remote marketplaces", () => {
|
|
|
1826
1826
|
expect(secondCalls).toEqual([["plugin", "marketplace", "update", "mkt"]]);
|
|
1827
1827
|
});
|
|
1828
1828
|
});
|
|
1829
|
+
|
|
1830
|
+
// ---------------------------------------------------------------------------
|
|
1831
|
+
// installPlugins — ledger reconciliation against real registry shapes (PUI-1.1)
|
|
1832
|
+
// ---------------------------------------------------------------------------
|
|
1833
|
+
|
|
1834
|
+
describe("installPlugins — removed/disabled reconciliation", () => {
|
|
1835
|
+
it("uninstalls a removed plugin and removes a removed marketplace, leaving untracked items alone", async () => {
|
|
1836
|
+
const pluginsDir = join(testHome, "plugins");
|
|
1837
|
+
mkdirSync(pluginsDir, { recursive: true });
|
|
1838
|
+
const manifest = join(pluginsDir, "installed_plugins.json");
|
|
1839
|
+
writeFileSync(
|
|
1840
|
+
manifest,
|
|
1841
|
+
JSON.stringify({
|
|
1842
|
+
version: 2,
|
|
1843
|
+
plugins: {
|
|
1844
|
+
"kept@mk": [{ scope: "user", installPath: pluginsDir }],
|
|
1845
|
+
"gone@mk": [{ scope: "user", installPath: pluginsDir }],
|
|
1846
|
+
"hand@other": [{ scope: "user", installPath: pluginsDir }],
|
|
1847
|
+
},
|
|
1848
|
+
}),
|
|
1849
|
+
);
|
|
1850
|
+
writeFileSync(
|
|
1851
|
+
join(pluginsDir, "known_marketplaces.json"),
|
|
1852
|
+
JSON.stringify({
|
|
1853
|
+
mk: {
|
|
1854
|
+
source: { source: "github", repo: "o/mk" },
|
|
1855
|
+
installLocation: pluginsDir,
|
|
1856
|
+
},
|
|
1857
|
+
other: {
|
|
1858
|
+
source: { source: "github", repo: "o/other" },
|
|
1859
|
+
installLocation: pluginsDir,
|
|
1860
|
+
},
|
|
1861
|
+
}),
|
|
1862
|
+
);
|
|
1863
|
+
writeFileSync(
|
|
1864
|
+
join(pluginsDir, "agent_plugin_ledger.json"),
|
|
1865
|
+
JSON.stringify({ plugins: ["kept@mk", "gone@mk"], marketplaces: ["mk"] }),
|
|
1866
|
+
);
|
|
1867
|
+
|
|
1868
|
+
const calls: string[][] = [];
|
|
1869
|
+
const exec = async (_c: string, args: string[]) => {
|
|
1870
|
+
calls.push(args);
|
|
1871
|
+
return { stdout: "", exitCode: 0 };
|
|
1872
|
+
};
|
|
1873
|
+
await installPlugins(
|
|
1874
|
+
exec,
|
|
1875
|
+
"/tmp/cwd",
|
|
1876
|
+
[{ plugin: "kept", marketplace: "mk" }],
|
|
1877
|
+
"/tmp/no-such-repo-root",
|
|
1878
|
+
manifest,
|
|
1879
|
+
[],
|
|
1880
|
+
"/tmp/nonexistent-baked-root",
|
|
1881
|
+
{},
|
|
1882
|
+
[],
|
|
1883
|
+
);
|
|
1884
|
+
|
|
1885
|
+
const uninstalled = calls
|
|
1886
|
+
.filter((a) => a[1] === "uninstall")
|
|
1887
|
+
.map((a) => a[2]);
|
|
1888
|
+
expect(uninstalled).toEqual(["gone@mk"]);
|
|
1889
|
+
expect(calls).toContainEqual(["plugin", "marketplace", "remove", "mk"]);
|
|
1890
|
+
expect(calls.flat()).not.toContain("hand@other");
|
|
1891
|
+
expect(calls).not.toContainEqual([
|
|
1892
|
+
"plugin",
|
|
1893
|
+
"marketplace",
|
|
1894
|
+
"remove",
|
|
1895
|
+
"other",
|
|
1896
|
+
]);
|
|
1897
|
+
const ledger = JSON.parse(
|
|
1898
|
+
readFileSync(join(pluginsDir, "agent_plugin_ledger.json"), "utf8"),
|
|
1899
|
+
);
|
|
1900
|
+
expect(ledger).toEqual({ plugins: ["kept@mk"], marketplaces: [] });
|
|
1901
|
+
});
|
|
1902
|
+
});
|
package/setup.ts
CHANGED
|
@@ -550,6 +550,47 @@ async function reconcileRemoteMarketplace(
|
|
|
550
550
|
}
|
|
551
551
|
}
|
|
552
552
|
|
|
553
|
+
/** Ledger of what installPlugins installed from the config bundle. */
|
|
554
|
+
interface PluginLedger {
|
|
555
|
+
plugins: string[];
|
|
556
|
+
marketplaces: string[];
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
const PLUGIN_LEDGER_FILENAME = "agent_plugin_ledger.json";
|
|
560
|
+
|
|
561
|
+
/** Reads the ledger; a missing or unparsable file is an empty ledger. */
|
|
562
|
+
function readPluginLedger(ledgerPath: string): PluginLedger {
|
|
563
|
+
const empty: PluginLedger = { plugins: [], marketplaces: [] };
|
|
564
|
+
if (!existsSync(ledgerPath)) return empty;
|
|
565
|
+
try {
|
|
566
|
+
const raw = JSON.parse(readFileSync(ledgerPath, "utf8"));
|
|
567
|
+
const strings = (v: unknown): string[] =>
|
|
568
|
+
Array.isArray(v)
|
|
569
|
+
? v.filter((x): x is string => typeof x === "string")
|
|
570
|
+
: [];
|
|
571
|
+
return {
|
|
572
|
+
plugins: strings(raw?.plugins),
|
|
573
|
+
marketplaces: strings(raw?.marketplaces),
|
|
574
|
+
};
|
|
575
|
+
} catch (err) {
|
|
576
|
+
console.warn(
|
|
577
|
+
`[agent] could not read ${ledgerPath} (treating as empty): ${(err as Error).message}`,
|
|
578
|
+
);
|
|
579
|
+
return empty;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/** Writes the ledger; failure warns, never throws. */
|
|
584
|
+
function writePluginLedger(ledgerPath: string, ledger: PluginLedger): void {
|
|
585
|
+
try {
|
|
586
|
+
writeFileSync(ledgerPath, `${JSON.stringify(ledger, null, 2)}\n`);
|
|
587
|
+
} catch (err) {
|
|
588
|
+
console.warn(
|
|
589
|
+
`[agent] could not write ${ledgerPath}: ${(err as Error).message}`,
|
|
590
|
+
);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
|
|
553
594
|
/**
|
|
554
595
|
* Installs the plugins in the agent's own AgentPlugin rows (seeded from the
|
|
555
596
|
* specialty manifest at create time). No plugin is installed by default. All commands are idempotent (exit 0 when already
|
|
@@ -566,6 +607,15 @@ async function reconcileRemoteMarketplace(
|
|
|
566
607
|
* passed directly via `extraMarketplaceDirs`)
|
|
567
608
|
* 2. Built-in shipwright marketplace (`shipwrightRepoRoot`)
|
|
568
609
|
*
|
|
610
|
+
* Reconciliation (PUI-1.1): the specs and remote marketplaces installed from
|
|
611
|
+
* the config bundle are recorded in a ledger next to `installed_plugins.json`.
|
|
612
|
+
* When `agentPlugins` (or `remoteMarketplaces`) is passed, ledger entries
|
|
613
|
+
* absent from it — a removed row, or a plugin with enabled=false, which the
|
|
614
|
+
* bundle omits — are uninstalled (marketplaces: removed). Only ledger entries
|
|
615
|
+
* are ever removed, so baked, built-in and hand-installed items are untouched;
|
|
616
|
+
* a failed removal stays in the ledger and retries next call. Omit the argument
|
|
617
|
+
* (the boot default call) to skip that half of reconciliation.
|
|
618
|
+
*
|
|
569
619
|
* @param extraMarketplaceDirs - Explicit list of extra marketplace dirs to
|
|
570
620
|
* register. When provided, `extraMarketplacesRoot` is ignored. Useful for
|
|
571
621
|
* tests that inject dirs directly without touching the filesystem.
|
|
@@ -576,7 +626,7 @@ async function reconcileRemoteMarketplace(
|
|
|
576
626
|
export async function installPlugins(
|
|
577
627
|
execFn: ExecFn = defaultExec,
|
|
578
628
|
cwd: string = process.cwd(),
|
|
579
|
-
agentPlugins
|
|
629
|
+
agentPlugins?: AgentPlugin[],
|
|
580
630
|
shipwrightRepoRootOverride?: string,
|
|
581
631
|
pluginManifestPath: string = join(
|
|
582
632
|
process.env.HOME ?? "/root",
|
|
@@ -587,7 +637,7 @@ export async function installPlugins(
|
|
|
587
637
|
extraMarketplaceDirs?: string[],
|
|
588
638
|
extraMarketplacesRoot: string = BAKED_MARKETPLACES_ROOT,
|
|
589
639
|
env: Record<string, string | undefined> = process.env,
|
|
590
|
-
remoteMarketplaces
|
|
640
|
+
remoteMarketplaces?: RemoteMarketplace[],
|
|
591
641
|
): Promise<void> {
|
|
592
642
|
const shipwrightRepoRoot =
|
|
593
643
|
shipwrightRepoRootOverride ?? resolveShipwrightRepoRoot(env);
|
|
@@ -664,7 +714,51 @@ export async function installPlugins(
|
|
|
664
714
|
const managedLocalNames = new Set(extraDirs.map((dir) => basename(dir)));
|
|
665
715
|
if (hasRepoMarketplace)
|
|
666
716
|
managedLocalNames.add(builtinMarketplaceName(shipwrightRepoRoot));
|
|
667
|
-
|
|
717
|
+
|
|
718
|
+
const ledgerPath = join(
|
|
719
|
+
dirname(pluginManifestPath),
|
|
720
|
+
PLUGIN_LEDGER_FILENAME,
|
|
721
|
+
);
|
|
722
|
+
const ledger = readPluginLedger(ledgerPath);
|
|
723
|
+
const nextLedger: PluginLedger = {
|
|
724
|
+
plugins: [...ledger.plugins],
|
|
725
|
+
marketplaces: [...ledger.marketplaces],
|
|
726
|
+
};
|
|
727
|
+
const allSpecs = (agentPlugins ?? []).map(
|
|
728
|
+
(p) => `${p.plugin}@${p.marketplace}`,
|
|
729
|
+
);
|
|
730
|
+
|
|
731
|
+
// Uninstall ledger plugins whose row was removed or disabled.
|
|
732
|
+
if (agentPlugins !== undefined) {
|
|
733
|
+
for (const spec of ledger.plugins) {
|
|
734
|
+
if (allSpecs.includes(spec)) continue;
|
|
735
|
+
const result = await execFn("claude", ["plugin", "uninstall", spec], {
|
|
736
|
+
cwd,
|
|
737
|
+
});
|
|
738
|
+
if (result.exitCode === 0) {
|
|
739
|
+
nextLedger.plugins = nextLedger.plugins.filter((x) => x !== spec);
|
|
740
|
+
} else {
|
|
741
|
+
console.warn(
|
|
742
|
+
`[agent] claude plugin uninstall ${spec} (row removed/disabled) exited ${result.exitCode}: ${result.stdout} — retrying next sync`,
|
|
743
|
+
);
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
// Remove ledger marketplaces whose row was removed (after their plugins).
|
|
749
|
+
if (remoteMarketplaces !== undefined) {
|
|
750
|
+
const rowNames = new Set(remoteMarketplaces.map((r) => r.name));
|
|
751
|
+
for (const name of ledger.marketplaces) {
|
|
752
|
+
if (rowNames.has(name) || managedLocalNames.has(name)) continue;
|
|
753
|
+
if (await runMarketplaceCommand(execFn, cwd, ["remove", name])) {
|
|
754
|
+
nextLedger.marketplaces = nextLedger.marketplaces.filter(
|
|
755
|
+
(x) => x !== name,
|
|
756
|
+
);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
for (const row of remoteMarketplaces ?? []) {
|
|
668
762
|
await reconcileRemoteMarketplace(
|
|
669
763
|
row,
|
|
670
764
|
managedLocalNames,
|
|
@@ -672,10 +766,14 @@ export async function installPlugins(
|
|
|
672
766
|
execFn,
|
|
673
767
|
cwd,
|
|
674
768
|
);
|
|
769
|
+
if (
|
|
770
|
+
!managedLocalNames.has(row.name) &&
|
|
771
|
+
!nextLedger.marketplaces.includes(row.name)
|
|
772
|
+
) {
|
|
773
|
+
nextLedger.marketplaces.push(row.name);
|
|
774
|
+
}
|
|
675
775
|
}
|
|
676
776
|
|
|
677
|
-
const allSpecs = agentPlugins.map((p) => `${p.plugin}@${p.marketplace}`);
|
|
678
|
-
|
|
679
777
|
// Uninstall any plugin whose recorded installPath no longer exists. This
|
|
680
778
|
// clears stale manifest entries left over from a different-HOME container
|
|
681
779
|
// so the subsequent `install` records the correct path for the current user.
|
|
@@ -708,6 +806,8 @@ export async function installPlugins(
|
|
|
708
806
|
console.warn(
|
|
709
807
|
`[agent] claude plugin install ${spec} exited ${install.exitCode}: ${install.stdout}`,
|
|
710
808
|
);
|
|
809
|
+
} else if (!nextLedger.plugins.includes(spec)) {
|
|
810
|
+
nextLedger.plugins.push(spec);
|
|
711
811
|
}
|
|
712
812
|
}
|
|
713
813
|
|
|
@@ -724,6 +824,13 @@ export async function installPlugins(
|
|
|
724
824
|
);
|
|
725
825
|
}
|
|
726
826
|
}
|
|
827
|
+
|
|
828
|
+
if (
|
|
829
|
+
nextLedger.plugins.join("\n") !== ledger.plugins.join("\n") ||
|
|
830
|
+
nextLedger.marketplaces.join("\n") !== ledger.marketplaces.join("\n")
|
|
831
|
+
) {
|
|
832
|
+
writePluginLedger(ledgerPath, nextLedger);
|
|
833
|
+
}
|
|
727
834
|
} catch (err) {
|
|
728
835
|
console.warn(
|
|
729
836
|
`[agent] plugin install failed (non-fatal): ${(err as Error).message}`,
|
package/setup.unit.test.ts
CHANGED
|
@@ -5,7 +5,14 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { afterEach, beforeEach, describe, expect, it } from "bun:test";
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
existsSync,
|
|
10
|
+
mkdirSync,
|
|
11
|
+
mkdtempSync,
|
|
12
|
+
readFileSync,
|
|
13
|
+
rmSync,
|
|
14
|
+
writeFileSync,
|
|
15
|
+
} from "node:fs";
|
|
9
16
|
import { tmpdir } from "node:os";
|
|
10
17
|
import { join } from "node:path";
|
|
11
18
|
import {
|
|
@@ -60,7 +67,7 @@ describe("installPlugins — local marketplace", () => {
|
|
|
60
67
|
"/tmp/cwd",
|
|
61
68
|
plugins,
|
|
62
69
|
repoRoot,
|
|
63
|
-
"
|
|
70
|
+
join(mkdtempSync(join(tmpdir(), "manifest-")), "installed_plugins.json"),
|
|
64
71
|
extra,
|
|
65
72
|
);
|
|
66
73
|
|
|
@@ -258,7 +265,7 @@ describe("SHIPWRIGHT_REPO_ROOT override (PCB-1.1)", () => {
|
|
|
258
265
|
"/tmp/cwd",
|
|
259
266
|
[],
|
|
260
267
|
undefined,
|
|
261
|
-
"
|
|
268
|
+
join(mkdtempSync(join(tmpdir(), "manifest-")), "installed_plugins.json"),
|
|
262
269
|
NO_EXTRA_MARKETPLACES,
|
|
263
270
|
"/tmp/nonexistent-baked-root",
|
|
264
271
|
env,
|
|
@@ -339,3 +346,110 @@ describe("SHIPWRIGHT_REPO_ROOT override (PCB-1.1)", () => {
|
|
|
339
346
|
});
|
|
340
347
|
});
|
|
341
348
|
});
|
|
349
|
+
|
|
350
|
+
describe("installPlugins — ledger reconciliation (PUI-1.1)", () => {
|
|
351
|
+
let dir: string;
|
|
352
|
+
let manifest: string;
|
|
353
|
+
const ledgerPath = () => join(dir, "agent_plugin_ledger.json");
|
|
354
|
+
beforeEach(() => {
|
|
355
|
+
dir = mkdtempSync(join(tmpdir(), "ledger-"));
|
|
356
|
+
manifest = join(dir, "installed_plugins.json");
|
|
357
|
+
});
|
|
358
|
+
afterEach(() => rmSync(dir, { recursive: true, force: true }));
|
|
359
|
+
|
|
360
|
+
const run = (
|
|
361
|
+
exec: ReturnType<typeof recordCalls>["exec"],
|
|
362
|
+
plugins?: Array<{ plugin: string; marketplace: string }>,
|
|
363
|
+
marketplaces?: Array<{ name: string; source: string; ref: string | null }>,
|
|
364
|
+
) =>
|
|
365
|
+
installPlugins(
|
|
366
|
+
exec,
|
|
367
|
+
"/tmp/cwd",
|
|
368
|
+
plugins,
|
|
369
|
+
"/tmp/no-such-repo-root",
|
|
370
|
+
manifest,
|
|
371
|
+
NO_EXTRA_MARKETPLACES,
|
|
372
|
+
"/tmp/nonexistent-baked-root",
|
|
373
|
+
{},
|
|
374
|
+
marketplaces,
|
|
375
|
+
);
|
|
376
|
+
const writeLedger = (plugins: string[], marketplaces: string[] = []) =>
|
|
377
|
+
writeFileSync(ledgerPath(), JSON.stringify({ plugins, marketplaces }));
|
|
378
|
+
const uninstalls = (calls: Array<{ args: string[] }>) =>
|
|
379
|
+
calls.filter((c) => c.args[1] === "uninstall").map((c) => c.args[2]);
|
|
380
|
+
|
|
381
|
+
it("records installed specs in the ledger", async () => {
|
|
382
|
+
const { exec } = recordCalls();
|
|
383
|
+
await run(exec, [{ plugin: "a", marketplace: "m" }]);
|
|
384
|
+
expect(JSON.parse(readFileSync(ledgerPath(), "utf8")).plugins).toEqual([
|
|
385
|
+
"a@m",
|
|
386
|
+
]);
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
it("uninstalls a ledger spec that is absent from the bundle (removed or disabled)", async () => {
|
|
390
|
+
writeLedger(["a@m", "b@m"]);
|
|
391
|
+
const { calls, exec } = recordCalls();
|
|
392
|
+
await run(exec, [{ plugin: "a", marketplace: "m" }]);
|
|
393
|
+
expect(uninstalls(calls)).toEqual(["b@m"]);
|
|
394
|
+
expect(JSON.parse(readFileSync(ledgerPath(), "utf8")).plugins).toEqual([
|
|
395
|
+
"a@m",
|
|
396
|
+
]);
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
it("reconciles when the last plugin is removed (empty bundle)", async () => {
|
|
400
|
+
writeLedger(["a@m"]);
|
|
401
|
+
const { calls, exec } = recordCalls();
|
|
402
|
+
await run(exec, [], []);
|
|
403
|
+
expect(uninstalls(calls)).toEqual(["a@m"]);
|
|
404
|
+
expect(JSON.parse(readFileSync(ledgerPath(), "utf8")).plugins).toEqual([]);
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
it("never uninstalls specs that are not in the ledger", async () => {
|
|
408
|
+
writeLedger([]);
|
|
409
|
+
const { calls, exec } = recordCalls();
|
|
410
|
+
await run(exec, []);
|
|
411
|
+
expect(uninstalls(calls)).toEqual([]);
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
it("skips plugin reconciliation when agentPlugins is omitted (boot default)", async () => {
|
|
415
|
+
writeLedger(["a@m"], ["mk"]);
|
|
416
|
+
const { calls, exec } = recordCalls();
|
|
417
|
+
await run(exec, undefined, undefined);
|
|
418
|
+
expect(uninstalls(calls)).toEqual([]);
|
|
419
|
+
expect(calls.some((c) => c.args[2] === "remove")).toBe(false);
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
it("keeps a failed uninstall in the ledger and does not throw", async () => {
|
|
423
|
+
writeLedger(["b@m"]);
|
|
424
|
+
const exec = async (_c: string, args: string[]) => ({
|
|
425
|
+
stdout: "boom",
|
|
426
|
+
exitCode: args[1] === "uninstall" ? 1 : 0,
|
|
427
|
+
});
|
|
428
|
+
await run(exec, []);
|
|
429
|
+
expect(JSON.parse(readFileSync(ledgerPath(), "utf8")).plugins).toEqual([
|
|
430
|
+
"b@m",
|
|
431
|
+
]);
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
it("removes a ledger marketplace whose row was removed", async () => {
|
|
435
|
+
writeLedger([], ["gone", "kept"]);
|
|
436
|
+
const { calls, exec } = recordCalls();
|
|
437
|
+
await run(exec, [], [{ name: "kept", source: "o/kept", ref: null }]);
|
|
438
|
+
const removes = calls
|
|
439
|
+
.filter((c) => c.args[2] === "remove")
|
|
440
|
+
.map((c) => c.args[3]);
|
|
441
|
+
expect(removes).toEqual(["gone"]);
|
|
442
|
+
expect(JSON.parse(readFileSync(ledgerPath(), "utf8")).marketplaces).toEqual(
|
|
443
|
+
["kept"],
|
|
444
|
+
);
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
it("does not record a failed install", async () => {
|
|
448
|
+
const exec = async (_c: string, args: string[]) => ({
|
|
449
|
+
stdout: "",
|
|
450
|
+
exitCode: args[1] === "install" ? 1 : 0,
|
|
451
|
+
});
|
|
452
|
+
await run(exec, [{ plugin: "a", marketplace: "m" }]);
|
|
453
|
+
expect(existsSync(ledgerPath())).toBe(false);
|
|
454
|
+
});
|
|
455
|
+
});
|