update: always install canonical ironclaw package name

This commit is contained in:
kumarabhirup 2026-02-22 00:38:25 -08:00
parent 6e2f34e193
commit e4c01e7ca2
No known key found for this signature in database
GPG Key ID: DB7CA2289CAB0167
5 changed files with 29 additions and 24 deletions

View File

@ -1,7 +1,7 @@
import * as fs from "node:fs/promises";
import * as os from "node:os";
import * as path from "node:path";
import { afterEach, describe, expect, it, vi } from "vitest";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import {
cameraTempPath,
parseCameraClipPayload,
@ -26,6 +26,12 @@ async function withCameraTempDir<T>(run: (dir: string) => Promise<T>): Promise<T
}
describe("nodes camera helpers", () => {
const originalArgv = [...process.argv];
beforeEach(() => {
process.argv = ["node", "ironclaw"];
});
function stubFetchResponse(response: Response) {
vi.stubGlobal(
"fetch",
@ -96,7 +102,7 @@ describe("nodes camera helpers", () => {
tmpDir: dir,
id: "clip1",
});
expect(out).toBe(path.join(dir, "openclaw-camera-clip-front-clip1.mp4"));
expect(out).toBe(path.join(dir, "ironclaw-camera-clip-front-clip1.mp4"));
await expect(fs.readFile(out, "utf8")).resolves.toBe("hi");
});
});
@ -115,7 +121,7 @@ describe("nodes camera helpers", () => {
tmpDir: dir,
id: "clip2",
});
expect(out).toBe(path.join(dir, "openclaw-camera-clip-back-clip2.mp4"));
expect(out).toBe(path.join(dir, "ironclaw-camera-clip-back-clip2.mp4"));
await expect(fs.readFile(out, "utf8")).resolves.toBe("url-clip");
});
});
@ -129,6 +135,7 @@ describe("nodes camera helpers", () => {
});
afterEach(() => {
process.argv = [...originalArgv];
vi.unstubAllGlobals();
});

View File

@ -53,8 +53,8 @@ export function parseTimeoutMsOrExit(timeout?: string): number | undefined | nul
const OPENCLAW_REPO_URL = "https://github.com/openclaw/openclaw.git";
const MAX_LOG_CHARS = 8000;
export const DEFAULT_PACKAGE_NAME = "openclaw";
const CORE_PACKAGE_NAMES = new Set([DEFAULT_PACKAGE_NAME]);
export const DEFAULT_PACKAGE_NAME = "ironclaw";
const CORE_PACKAGE_NAMES = new Set([DEFAULT_PACKAGE_NAME, "openclaw"]);
export function normalizeTag(value?: string | null): string | null {
if (!value) {
@ -64,11 +64,10 @@ export function normalizeTag(value?: string | null): string | null {
if (!trimmed) {
return null;
}
if (trimmed.startsWith("openclaw@")) {
return trimmed.slice("openclaw@".length);
}
if (trimmed.startsWith(`${DEFAULT_PACKAGE_NAME}@`)) {
return trimmed.slice(`${DEFAULT_PACKAGE_NAME}@`.length);
for (const prefix of ["ironclaw@", "openclaw@"]) {
if (trimmed.startsWith(prefix)) {
return trimmed.slice(prefix.length);
}
}
return trimmed;
}

View File

@ -51,7 +51,6 @@ import {
ensureGitCheckout,
normalizeTag,
parseTimeoutMsOrExit,
readPackageName,
readPackageVersion,
resolveGitInstallDir,
resolveGlobalManager,
@ -212,9 +211,8 @@ async function runPackageInstallUpdate(params: {
const runCommand = createGlobalCommandRunner();
const pkgRoot = await resolveGlobalPackageRoot(manager, runCommand, params.timeoutMs);
const packageName =
(pkgRoot ? await readPackageName(pkgRoot) : await readPackageName(params.root)) ??
DEFAULT_PACKAGE_NAME;
// Always install the canonical package name regardless of what's on disk
const packageName = DEFAULT_PACKAGE_NAME;
const beforeVersion = pkgRoot ? await readPackageVersion(pkgRoot) : null;
if (pkgRoot) {
@ -747,7 +745,7 @@ export async function updateCommand(opts: UpdateCommandOptions): Promise<void> {
);
defaultRuntime.log(
theme.muted(
`Examples: \`${replaceCliName("npm i -g openclaw@latest", CLI_NAME)}\` or \`${replaceCliName("pnpm add -g openclaw@latest", CLI_NAME)}\``,
`Examples: \`npm i -g ${DEFAULT_PACKAGE_NAME}@latest\` or \`pnpm add -g ${DEFAULT_PACKAGE_NAME}@latest\``,
),
);
}

View File

@ -362,16 +362,16 @@ describe("runGatewayUpdate", () => {
it.each([
{
title: "updates global npm installs when detected",
expectedInstallCommand: "npm i -g openclaw@latest --no-fund --no-audit --loglevel=error",
expectedInstallCommand: "npm i -g ironclaw@latest --no-fund --no-audit --loglevel=error",
},
{
title: "uses update channel for global npm installs when tag is omitted",
expectedInstallCommand: "npm i -g openclaw@beta --no-fund --no-audit --loglevel=error",
expectedInstallCommand: "npm i -g ironclaw@beta --no-fund --no-audit --loglevel=error",
channel: "beta" as const,
},
{
title: "updates global npm installs with tag override",
expectedInstallCommand: "npm i -g openclaw@beta --no-fund --no-audit --loglevel=error",
expectedInstallCommand: "npm i -g ironclaw@beta --no-fund --no-audit --loglevel=error",
tag: "beta",
},
])("$title", async ({ expectedInstallCommand, channel, tag }) => {
@ -407,7 +407,7 @@ describe("runGatewayUpdate", () => {
if (key === "pnpm root -g") {
return { stdout: "", stderr: "", code: 1 };
}
if (key === "npm i -g openclaw@latest --no-fund --no-audit --loglevel=error") {
if (key === "npm i -g ironclaw@latest --no-fund --no-audit --loglevel=error") {
stalePresentAtInstall = await pathExists(staleDir);
return { stdout: "ok", stderr: "", code: 0 };
}
@ -430,7 +430,7 @@ describe("runGatewayUpdate", () => {
const { calls, runCommand } = createGlobalInstallHarness({
pkgRoot,
installCommand: "bun add -g openclaw@latest",
installCommand: "bun add -g ironclaw@latest",
onInstall: async () => {
await fs.writeFile(
path.join(pkgRoot, "package.json"),
@ -446,7 +446,7 @@ describe("runGatewayUpdate", () => {
expect(result.mode).toBe("bun");
expect(result.before?.version).toBe("1.0.0");
expect(result.after?.version).toBe("2.0.0");
expect(calls.some((call) => call === "bun add -g openclaw@latest")).toBe(true);
expect(calls.some((call) => call === "bun add -g ironclaw@latest")).toBe(true);
});
});

View File

@ -866,14 +866,15 @@ export async function runGatewayUpdate(opts: UpdateRunnerOptions = {}): Promise<
const beforeVersion = await readPackageVersion(pkgRoot);
const globalManager = await detectGlobalInstallManagerForRoot(runCommand, pkgRoot, timeoutMs);
if (globalManager) {
const packageName = (await readPackageName(pkgRoot)) ?? DEFAULT_PACKAGE_NAME;
// Always install the canonical package name regardless of what's on disk
const installedName = (await readPackageName(pkgRoot)) ?? DEFAULT_PACKAGE_NAME;
await cleanupGlobalRenameDirs({
globalRoot: path.dirname(pkgRoot),
packageName,
packageName: installedName,
});
const channel = opts.channel ?? DEFAULT_PACKAGE_CHANNEL;
const tag = normalizeTag(opts.tag ?? channelToNpmTag(channel));
const spec = `${packageName}@${tag}`;
const spec = `${DEFAULT_PACKAGE_NAME}@${tag}`;
const updateStep = await runStep({
runCommand,
name: "global update",