Skip to content
This repository was archived by the owner on Jul 14, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ This way even entityIds like environmentIds or testCaseIds will be autocompleted

# octomind

Octomind cli tool. Version: 3.7.0. Additional documentation see https://octomind.dev/docs/api-reference/
Octomind cli tool. Version: 3.8.0. Additional documentation see https://octomind.dev/docs/api-reference/

**Usage:** `octomind [options] [command]`

Expand Down Expand Up @@ -478,6 +478,14 @@ List all test targets
|:-------|:----------|:---------|:--------|
| `-j, --json` | Output raw JSON response | No | |

## Update

## update

update your local cli version

**Usage:** `update [options]`



## Output Formats
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@octomind/octomind",
"version": "3.7.1",
"version": "3.8.0",
"description": "a command line client for octomind apis",
"main": "./dist/index.js",
"packageManager": "pnpm@10.26.0+sha512.3b3f6c725ebe712506c0ab1ad4133cf86b1f4b687effce62a9b38b4d72e3954242e643190fc51fa1642949c735f403debd44f5cb0edd657abe63a8b6a7e1e402",
Expand Down Expand Up @@ -45,8 +45,9 @@
"shell-quote": "1.8.3",
"simple-git": "3.30.0",
"tabtab": "3.0.2",
"yaml": "2.8.2",
"unzipper": "0.12.3",
"which": "6.0.0",
"yaml": "2.8.2",
"zod": "4.2.1"
},
"devDependencies": {
Expand All @@ -55,6 +56,7 @@
"@types/node": "25.0.3",
"@types/tabtab": "3.0.4",
"@types/unzipper": "0.10.11",
"@types/which": "3.0.4",
"genversion": "3.2.0",
"jest": "30.2.0",
"jest-mock-extended": "4.0.0",
Expand Down
26 changes: 26 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
updateEnvironment,
} from "./tools";
import { init, switchTestTarget } from "./tools/init";
import { update } from "./tools/update";
import { version } from "./version";

export const BINARY_NAME = "octomind";
Expand Down Expand Up @@ -446,5 +447,12 @@ export const buildCmd = (): CompletableCommand => {
.allowExcessArguments(true)
.action(() => tabCompletion(program));

program
.completableCommand("update")
.description("update your local cli version")
.helpGroup("update")
.allowExcessArguments(false)
.action(update);

return program;
};
39 changes: 39 additions & 0 deletions src/tools/update.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import * as child_process from "node:child_process";
import fs from "fs";
import { homedir } from "os";
import path from "path";

import which from "which";

export const update = async (): Promise<void> => {
const pathToRoot = path.posix.normalize(
path.join(homedir(), "/.local/packages"),
);
const pathToPackageJson = path.join(pathToRoot, "package.json");

if (!fs.existsSync(pathToPackageJson)) {
console.error(
"cannot find package.json, cannot update, please update manually",
);
process.exit(1);
}

if (!(await which("npm"))) {
console.error(
`cannot determine location of npm, cannot update, please update manually, package location: ${pathToPackageJson}`,
);
process.exit(1);
}

console.log(`updating package.json at ${pathToPackageJson}`);

const result = child_process.execSync(
"npm install @octomind/octomind@latest",
{
cwd: path.dirname(pathToRoot),
},
);

console.log(`${result}`);
console.log("\n✔ update complete");
};
48 changes: 48 additions & 0 deletions tests/tools/update.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import * as child_process from "node:child_process";
import fs from "fs";
import path from "path";
import {homedir} from "os";
import which from "which";
import {update} from "../../src/tools/update";

jest.mock("node:child_process");
jest.mock("fs");
jest.mock("which");

describe("update", () => {
const mockPathToRoot = path.posix.normalize(path.join(homedir(), "/.local/packages"));

beforeEach(() => {
jest.mocked(fs.existsSync).mockReturnValue(true);
jest.mocked(which).mockResolvedValue("/usr/bin/npm");
jest.mocked(child_process.execSync).mockReturnValue(Buffer.from("installed @octomind/octomind@latest"));
console.log = jest.fn();
console.error = jest.fn();
process.exit = jest.fn(() => { throw new Error("Process exit") });
});

afterEach(() => {
jest.clearAllMocks();
});

it("updates successfully when package.json exists and npm is available", async () => {
await update();

expect(child_process.execSync).toHaveBeenCalledWith(
"npm install @octomind/octomind@latest",
{ cwd: path.dirname(mockPathToRoot) }
);
});

it("exits with error if package.json does not exist", async () => {
jest.mocked(fs.existsSync).mockReturnValue(false);

await expect(update()).rejects.toThrow("Process exit");
});

it("exits with error if npm is not available", async () => {
jest.mocked(which).mockResolvedValue("");

await expect(update()).rejects.toThrow("Process exit");
});
});