




























@@ -8,76 +8,20 @@ openclaw_e2e_install_package /tmp/openclaw-install.log "mounted OpenClaw package
8899package_root="$(openclaw_e2e_package_root /tmp/npm-prefix)"
1010entry="$(openclaw_e2e_package_entrypoint "$package_root")"
11+probe="scripts/e2e/lib/plugin-update/probe.mjs"
1112package_version="$(node -p "require('$package_root/package.json').version")"
12-OPENCLAW_PACKAGE_ACCEPTANCE_LEGACY_COMPAT="$(
13- PACKAGE_VERSION="$package_version" node -e 'const version = process.env.PACKAGE_VERSION || ""; const match = new RegExp("^(\\d{4})\\.(\\d{1,2})\\.(\\d{1,2})(?:[-+].*)?").exec(version); if (!match) { console.log("0"); process.exit(0); } const value = [Number(match[1]), Number(match[2]), Number(match[3])]; const max = [2026, 4, 25]; for (let i = 0; i < value.length; i += 1) { if (value[i] < max[i]) { console.log("1"); process.exit(0); } if (value[i] > max[i]) { console.log("0"); process.exit(0); } } console.log("1");'
14-)"
13+OPENCLAW_PACKAGE_ACCEPTANCE_LEGACY_COMPAT="$(node "$probe" legacy-compat "$package_version")"
1514export OPENCLAW_PACKAGE_ACCEPTANCE_LEGACY_COMPAT
1615export NPM_CONFIG_REGISTRY=http://127.0.0.1:4873
1716export PATH="/tmp/npm-prefix/bin:$PATH"
181719-mkdir -p "$HOME/.openclaw/extensions/lossless-claw"
20-cat > "$HOME/.openclaw/extensions/lossless-claw/package.json" <<'JSON'
21-{
22- "name": "@example/lossless-claw",
23- "version": "0.9.0"
24-}
25-JSON
26-cat > "$OPENCLAW_CONFIG_PATH" <<'JSON'
27-{
28- "plugins": {}
29-}
30-JSON
31-mkdir -p "$HOME/.openclaw/plugins"
32-cat > "$HOME/.openclaw/plugins/installs.json" <<'JSON'
33-{
34- "version": 1,
35- "warning": "DO NOT EDIT. This file is generated by OpenClaw plugin registry commands.",
36- "hostContractVersion": "docker-e2e",
37- "compatRegistryVersion": "docker-e2e",
38- "migrationVersion": 1,
39- "policyHash": "docker-e2e",
40- "generatedAtMs": 1777118400000,
41- "installRecords": {
42- "lossless-claw": {
43- "source": "npm",
44- "spec": "@example/lossless-claw@0.9.0",
45- "installPath": "~/.openclaw/extensions/lossless-claw",
46- "resolvedName": "@example/lossless-claw",
47- "resolvedVersion": "0.9.0",
48- "resolvedSpec": "@example/lossless-claw@0.9.0",
49- "integrity": "sha512-same",
50- "shasum": "same"
51- }
52- },
53- "plugins": [],
54- "diagnostics": []
55-}
56-JSON
18+node "$probe" seed
57195820node scripts/e2e/lib/plugin-update/registry-server.mjs >/tmp/openclaw-e2e-registry.log 2>&1 &
5921registry_pid=$!
6022trap 'kill "$registry_pid" >/dev/null 2>&1 || true' EXIT
612362-registry_ready=0
63-for _ in $(seq 1 50); do
64-if node --input-type=module -e '
65- import http from "node:http";
66- const req = http.get("http://127.0.0.1:4873/@example%2flossless-claw", (res) => {
67- process.exit(res.statusCode === 200 ? 0 : 1);
68- });
69- req.on("error", () => process.exit(1));
70- req.setTimeout(200, () => {
71- req.destroy();
72- process.exit(1);
73- });
74- '; then
75- registry_ready=1
76-break
77-fi
78- sleep 0.1
79-done
80-if [ "$registry_ready" -ne 1 ]; then
24+if ! node "$probe" wait-registry; then
8125echo "Local npm metadata registry failed to start"
8226 cat /tmp/openclaw-e2e-registry.log || true
8327exit 1
@@ -89,37 +33,7 @@ if [ "$OPENCLAW_PACKAGE_ACCEPTANCE_LEGACY_COMPAT" != "1" ]; then
8933fi
9034plugin_update_timeout_seconds="${OPENCLAW_PLUGIN_UPDATE_TIMEOUT_SECONDS:-180}"
913592-node --input-type=module > /tmp/plugin-update-before.json <<'NODE'
93-import fs from "node:fs";
94-import os from "node:os";
95-import path from "node:path";
96-97-const readJson = (file) => {
98- try {
99- return JSON.parse(fs.readFileSync(file, "utf8"));
100- } catch {
101- return {};
102- }
103-};
104-const home = os.homedir();
105-const config = readJson(path.join(home, ".openclaw", "openclaw.json"));
106-const index = readJson(path.join(home, ".openclaw", "plugins", "installs.json"));
107-const records = index.installRecords ?? index.records ?? config.plugins?.installs ?? {};
108-const record = records["lossless-claw"] ?? records["@example/lossless-claw"];
109-if (!record) {
110- throw new Error("missing seeded plugin install record");
111-}
112-const snapshot = {
113- source: record.source,
114- spec: record.spec,
115- resolvedName: record.resolvedName,
116- resolvedVersion: record.resolvedVersion,
117- resolvedSpec: record.resolvedSpec,
118- integrity: record.integrity,
119- shasum: record.shasum,
120-};
121-process.stdout.write(JSON.stringify(snapshot, null, 2));
122-NODE
36+node "$probe" snapshot > /tmp/plugin-update-before.json
1233712438set +e
12539timeout "${plugin_update_timeout_seconds}s" node "$entry" plugins update @example/lossless-claw > /tmp/plugin-update-output.log 2>&1
@@ -143,48 +57,6 @@ if [ -n "$before_config_hash" ]; then
14357fi
14458fi
14559146-node --input-type=module <<'NODE'
147-import fs from "node:fs";
148-import os from "node:os";
149-import path from "node:path";
150-151-const readJson = (file) => {
152- try {
153- return JSON.parse(fs.readFileSync(file, "utf8"));
154- } catch {
155- return {};
156- }
157-};
158-const home = os.homedir();
159-const before = readJson("/tmp/plugin-update-before.json");
160-const config = readJson(path.join(home, ".openclaw", "openclaw.json"));
161-const index = readJson(path.join(home, ".openclaw", "plugins", "installs.json"));
162-const records = index.installRecords ?? index.records ?? config.plugins?.installs ?? {};
163-const record = records["lossless-claw"] ?? records["@example/lossless-claw"];
164-if (!record) {
165- throw new Error("missing plugin install record after update");
166-}
167-const after = {
168- source: record.source,
169- spec: record.spec,
170- resolvedName: record.resolvedName,
171- resolvedVersion: record.resolvedVersion,
172- resolvedSpec: record.resolvedSpec,
173- integrity: record.integrity,
174- shasum: record.shasum,
175-};
176-if (JSON.stringify(before) !== JSON.stringify(after)) {
177- throw new Error(`plugin install record changed unexpectedly: ${JSON.stringify({ before, after })}`);
178-}
179-NODE
180-if grep -q "Downloading @example/lossless-claw" /tmp/plugin-update-output.log; then
181-echo "Unexpected npm download/reinstall path"
182- cat /tmp/plugin-update-output.log
183-exit 1
184-fi
185-if ! grep -q "lossless-claw is up to date (0.9.0)." /tmp/plugin-update-output.log; then
186-echo "Expected up-to-date output missing"
187- cat /tmp/plugin-update-output.log
188-exit 1
189-fi
60+node "$probe" assert-snapshot /tmp/plugin-update-before.json
61+node "$probe" assert-output /tmp/plugin-update-output.log
19062cat /tmp/plugin-update-output.log
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。