

























@@ -101,6 +101,15 @@ function assertSimplePlugin(jsonFile, inspectFile, pluginId, method) {
101101}
102102}
103103104+function assertUpdateOutput(logFile, expectedSnippet) {
105+const output = fs.readFileSync(logFile, "utf8");
106+if (!output.includes(expectedSnippet)) {
107+throw new Error(
108+`expected update output to include ${JSON.stringify(expectedSnippet)}:\n${output}`,
109+);
110+}
111+}
112+104113function assertClaudeBundleDisabled() {
105114const data = readJson("/tmp/plugins-bundle-disabled.json");
106115const plugin = (data.plugins || []).find((entry) => entry.id === "claude-bundle-e2e");
@@ -326,6 +335,62 @@ function assertPluginDirDeps() {
326335assertRealPathInside(installPath, dependencyPackagePath, "local plugin copied dependency");
327336}
328337338+function assertLocalPathUpdateSkipped() {
339+assertUpdateOutput("/tmp/plugins-dir-update.log", 'Skipping "demo-plugin-dir" (source: path).');
340+}
341+342+function assertNpmPlugin() {
343+assertSimplePlugin(
344+"/tmp/plugins-npm.json",
345+"/tmp/plugins-npm-inspect.json",
346+"demo-plugin-npm",
347+"demo.npm",
348+);
349+350+const inspect = readJson("/tmp/plugins-npm-inspect.json");
351+if (!Array.isArray(inspect.cliCommands) || !inspect.cliCommands.includes("demo-npm")) {
352+throw new Error(`expected demo-npm cli command, got ${inspect.cliCommands?.join(", ")}`);
353+}
354+355+const cliOutput = fs.readFileSync("/tmp/plugins-npm-cli.txt", "utf8");
356+if (!cliOutput.includes("demo-plugin-npm:pong")) {
357+throw new Error(`unexpected npm plugin cli output: ${cliOutput.trim()}`);
358+}
359+360+const record = getInstallRecords()["demo-plugin-npm"];
361+if (!record) {
362+throw new Error("missing npm install record for demo-plugin-npm");
363+}
364+if (record.source !== "npm") {
365+throw new Error(`unexpected npm install source: ${record.source}`);
366+}
367+if (record.spec !== "@openclaw/demo-plugin-npm@0.0.1") {
368+throw new Error(`unexpected npm spec: ${record.spec}`);
369+}
370+if (record.resolvedName !== "@openclaw/demo-plugin-npm") {
371+throw new Error(`unexpected npm resolved name: ${record.resolvedName}`);
372+}
373+if (record.resolvedVersion !== "0.0.1") {
374+throw new Error(`unexpected npm resolved version: ${record.resolvedVersion}`);
375+}
376+const installPath = record.installPath?.replace(/^~(?=$|\/)/u, process.env.HOME);
377+if (!installPath || !fs.existsSync(installPath)) {
378+throw new Error(`npm install path missing on disk: ${installPath}`);
379+}
380+const nodeModulesRoot = path.dirname(path.dirname(installPath));
381+const npmRoot = path.dirname(nodeModulesRoot);
382+const dependencyPackagePath = path.join(nodeModulesRoot, "is-number", "package.json");
383+if (!fs.existsSync(dependencyPackagePath)) {
384+throw new Error(`missing npm plugin installed dependency: ${dependencyPackagePath}`);
385+}
386+assertRealPathInside(npmRoot, dependencyPackagePath, "npm plugin installed dependency");
387+}
388+389+function assertNpmPluginUpdateUnchanged() {
390+assertUpdateOutput("/tmp/plugins-npm-update.log", "demo-plugin-npm is up to date (0.0.1).");
391+assertNpmPlugin();
392+}
393+329394function assertMarketplaceUpdated() {
330395const data = readJson("/tmp/plugins-marketplace-updated.json");
331396const inspect = readJson("/tmp/plugins-marketplace-updated-inspect.json");
@@ -341,6 +406,49 @@ function assertMarketplaceUpdated() {
341406}
342407}
343408409+function assertGitPluginUpdated() {
410+const beforeCommit = process.argv[3];
411+assertSimplePlugin(
412+"/tmp/plugins-git-update.json",
413+"/tmp/plugins-git-update-inspect.json",
414+"demo-plugin-git-update",
415+"demo.git.update.v2",
416+);
417+418+const inspect = readJson("/tmp/plugins-git-update-inspect.json");
419+if (!Array.isArray(inspect.cliCommands) || !inspect.cliCommands.includes("demo-git-update")) {
420+throw new Error(`expected demo-git-update cli command, got ${inspect.cliCommands?.join(", ")}`);
421+}
422+423+const cliOutput = fs.readFileSync("/tmp/plugins-git-update-cli.txt", "utf8");
424+if (!cliOutput.includes("demo-plugin-git-update:pong-v2")) {
425+throw new Error(`unexpected updated git plugin cli output: ${cliOutput.trim()}`);
426+}
427+428+const record = getInstallRecords()["demo-plugin-git-update"];
429+if (!record) {
430+throw new Error("missing git update install record for demo-plugin-git-update");
431+}
432+if (record.source !== "git") {
433+throw new Error(`unexpected git update source: ${record.source}`);
434+}
435+if (record.gitRef !== "main") {
436+throw new Error(`unexpected git update ref: ${record.gitRef}`);
437+}
438+if (!record.gitCommit || record.gitCommit === beforeCommit) {
439+throw new Error(
440+`expected git update commit to advance from ${beforeCommit}, got ${record.gitCommit}`,
441+);
442+}
443+if (record.version !== "0.0.2") {
444+throw new Error(`unexpected git update version: ${record.version}`);
445+}
446+assertUpdateOutput(
447+"/tmp/plugins-git-update.log",
448+"Updated demo-plugin-git-update: 0.0.1 -> 0.0.2.",
449+);
450+}
451+344452async function assertClawHubPreflight() {
345453const spec = process.env.CLAWHUB_PLUGIN_SPEC;
346454if (!spec?.startsWith("clawhub:")) {
@@ -476,6 +584,14 @@ function assertClawHubRemoved() {
476584}
477585}
478586587+function assertClawHubUpdated() {
588+assertUpdateOutput(
589+"/tmp/plugins-clawhub-update.log",
590+`${process.env.CLAWHUB_PLUGIN_ID} already at 0.1.0.`,
591+);
592+assertClawHubInstalled();
593+}
594+479595const commands = {
480596"record-fixture-plugin-trust": recordFixturePluginTrust,
481597"demo-plugin": assertDemoPlugin,
@@ -493,6 +609,7 @@ const commands = {
493609"demo-plugin-dir",
494610"demo.dir",
495611),
612+"plugin-dir-update-skipped": assertLocalPathUpdateSkipped,
496613"plugin-dir-deps": assertPluginDirDeps,
497614"plugin-file": () =>
498615assertSimplePlugin(
@@ -501,16 +618,20 @@ const commands = {
501618"demo-plugin-file",
502619"demo.file",
503620),
621+"plugin-npm": assertNpmPlugin,
622+"plugin-npm-update": assertNpmPluginUpdateUnchanged,
504623"bundle-disabled": assertClaudeBundleDisabled,
505624"bundle-inspect": assertClaudeBundleInspect,
506625"slash-install": assertSlashInstall,
507626"plugin-git": assertGitPlugin,
627+"plugin-git-updated": assertGitPluginUpdated,
508628"marketplace-list": assertMarketplaceList,
509629"marketplace-installed": assertMarketplaceInstalled,
510630"marketplace-records": assertMarketplaceRecords,
511631"marketplace-updated": assertMarketplaceUpdated,
512632"clawhub-preflight": assertClawHubPreflight,
513633"clawhub-installed": assertClawHubInstalled,
634+"clawhub-updated": assertClawHubUpdated,
514635"clawhub-removed": assertClawHubRemoved,
515636};
516637此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。