Comprehensive update to complete the openclaw → ironclaw CLI rename across the codebase, fix build/runtime issues, and add test coverage for infra modules. CLI binary rename (openclaw → ironclaw): - Update DEFAULT_CLI_NAME and all argv parsing to recognize "ironclaw" binary - Extend package name sets (CORE_PACKAGE_NAMES, ALL_PACKAGE_NAMES) to include both "ironclaw" and "openclaw" for backward compatibility - Update NPM registry URL to fetch from ironclaw package - Update gateway lock detection, port listener classification, and launchd/systemd service scanning to recognize ironclaw-prefixed services and binaries - Update daemon inspect markers and legacy detection for ironclaw - Update voice-call extension core-bridge to resolve ironclaw package root - Fix install instructions in embeddings error messages (npm i -g ironclaw@latest) Web app / Next.js fixes: - Replace fragile `npx next` invocations with direct `node next-bin` resolution to avoid broken pnpm virtual-store symlinks in global installs - Add resolveNextBin() helper that resolves apps/web/node_modules/next directly Infra hardening: - Workspace templates: compute both source and dist fallback paths for template directory resolution (fixes templates not found in bundled builds) - Control UI assets: recognize both "openclaw" and "ironclaw" package names - Update-check, update-runner, update-cli: normalize ironclaw@ tag prefixes New tests: - Add openclaw-root.test.ts, ports-format.test.ts, update-global.test.ts - Add workspace-templates.test.ts and control-ui-assets.test.ts coverage - Add argv.test.ts coverage for ironclaw binary detection Test fixes (28 failures → 0): - Update all test assertions expecting "openclaw" CLI command output to "ironclaw" - Fix version.test.ts package name from "openclaw" to "ironclaw" - Fix camera/canvas temp path patterns in nodes-camera and program.nodes-media tests - Fix pairing message, telegram bot, channels, daemon, onboard, gateway tool, status, and profile test expectations Version: 2026.2.10-1.2 (published to npm as ironclaw@2026.2.10-1.2) Co-authored-by: Cursor <cursoragent@cursor.com>
87 lines
3.1 KiB
TypeScript
87 lines
3.1 KiB
TypeScript
import fs from "node:fs/promises";
|
|
import os from "node:os";
|
|
import path from "node:path";
|
|
import { pathToFileURL } from "node:url";
|
|
import { describe, expect, it } from "vitest";
|
|
import {
|
|
readVersionFromBuildInfoForModuleUrl,
|
|
readVersionFromPackageJsonForModuleUrl,
|
|
resolveVersionFromModuleUrl,
|
|
} from "./version.js";
|
|
|
|
async function withTempDir<T>(run: (dir: string) => Promise<T>): Promise<T> {
|
|
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-version-"));
|
|
try {
|
|
return await run(dir);
|
|
} finally {
|
|
await fs.rm(dir, { recursive: true, force: true });
|
|
}
|
|
}
|
|
|
|
function moduleUrlFrom(root: string, relativePath: string): string {
|
|
return pathToFileURL(path.join(root, relativePath)).href;
|
|
}
|
|
|
|
describe("version resolution", () => {
|
|
it("resolves package version from nested dist/plugin-sdk module URL", async () => {
|
|
await withTempDir(async (root) => {
|
|
await fs.mkdir(path.join(root, "dist", "plugin-sdk"), { recursive: true });
|
|
await fs.writeFile(
|
|
path.join(root, "package.json"),
|
|
JSON.stringify({ name: "ironclaw", version: "1.2.3" }),
|
|
"utf-8",
|
|
);
|
|
|
|
const moduleUrl = moduleUrlFrom(root, "dist/plugin-sdk/index.js");
|
|
expect(readVersionFromPackageJsonForModuleUrl(moduleUrl)).toBe("1.2.3");
|
|
expect(resolveVersionFromModuleUrl(moduleUrl)).toBe("1.2.3");
|
|
});
|
|
});
|
|
|
|
it("ignores unrelated nearby package.json files", async () => {
|
|
await withTempDir(async (root) => {
|
|
await fs.mkdir(path.join(root, "dist", "plugin-sdk"), { recursive: true });
|
|
await fs.writeFile(
|
|
path.join(root, "package.json"),
|
|
JSON.stringify({ name: "ironclaw", version: "2.3.4" }),
|
|
"utf-8",
|
|
);
|
|
await fs.writeFile(
|
|
path.join(root, "dist", "package.json"),
|
|
JSON.stringify({ name: "other-package", version: "9.9.9" }),
|
|
"utf-8",
|
|
);
|
|
|
|
const moduleUrl = moduleUrlFrom(root, "dist/plugin-sdk/index.js");
|
|
expect(readVersionFromPackageJsonForModuleUrl(moduleUrl)).toBe("2.3.4");
|
|
});
|
|
});
|
|
|
|
it("falls back to build-info when package metadata is unavailable", async () => {
|
|
await withTempDir(async (root) => {
|
|
await fs.mkdir(path.join(root, "dist", "plugin-sdk"), { recursive: true });
|
|
await fs.writeFile(
|
|
path.join(root, "build-info.json"),
|
|
JSON.stringify({ version: "4.5.6" }),
|
|
"utf-8",
|
|
);
|
|
|
|
const moduleUrl = moduleUrlFrom(root, "dist/plugin-sdk/index.js");
|
|
expect(readVersionFromPackageJsonForModuleUrl(moduleUrl)).toBeNull();
|
|
expect(readVersionFromBuildInfoForModuleUrl(moduleUrl)).toBe("4.5.6");
|
|
expect(resolveVersionFromModuleUrl(moduleUrl)).toBe("4.5.6");
|
|
});
|
|
});
|
|
|
|
it("returns null when no version metadata exists", async () => {
|
|
await withTempDir(async (root) => {
|
|
await fs.mkdir(path.join(root, "dist", "plugin-sdk"), { recursive: true });
|
|
|
|
const moduleUrl = moduleUrlFrom(root, "dist/plugin-sdk/index.js");
|
|
expect(readVersionFromPackageJsonForModuleUrl(moduleUrl)).toBeNull();
|
|
expect(readVersionFromBuildInfoForModuleUrl(moduleUrl)).toBeNull();
|
|
expect(resolveVersionFromModuleUrl(moduleUrl)).toBeNull();
|
|
});
|
|
});
|
|
});
|