Skip to content

Commit 79e1d06

Browse files
committed
cli: check minimum sui version
1.63.0 is needed for the new package management flow
1 parent 6c0fcce commit 79e1d06

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

cli/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ import {
118118
configureInboundLimitsForPull,
119119
} from "./limits.js";
120120
import {
121+
checkSuiVersion,
121122
buildSuiPackage,
122123
publishSuiPackage,
123124
findCreatedObject,
@@ -241,6 +242,7 @@ async function withSuiEnv<N extends Network, C extends Chain, T>(
241242
ch: ChainContext<N, C>,
242243
fn: () => Promise<T>
243244
): Promise<T> {
245+
checkSuiVersion();
244246
console.log("Setting up Sui environment...");
245247

246248
// Store original environment variable

cli/src/suiDeploy.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,48 @@
11
import fs from "fs";
22
import { execSync } from "child_process";
33

4+
const MIN_SUI_VERSION = "1.63.0";
5+
6+
function parseVersion(version: string): number[] {
7+
return version.split(".").map(Number);
8+
}
9+
10+
function versionAtLeast(current: string, minimum: string): boolean {
11+
const cur = parseVersion(current);
12+
const min = parseVersion(minimum);
13+
for (let i = 0; i < min.length; i++) {
14+
if ((cur[i] ?? 0) > min[i]) return true;
15+
if ((cur[i] ?? 0) < min[i]) return false;
16+
}
17+
return true;
18+
}
19+
20+
export function checkSuiVersion(): void {
21+
let output: string;
22+
try {
23+
output = execSync("sui --version", { encoding: "utf8" }).trim();
24+
} catch {
25+
throw new Error(
26+
"Could not run 'sui --version'. Is the Sui CLI installed?"
27+
);
28+
}
29+
// Output format: "sui 1.63.2-abc123"
30+
const match = output.match(/sui\s+(\d+\.\d+\.\d+)/);
31+
if (!match) {
32+
throw new Error(
33+
`Could not parse Sui version from: ${output}`
34+
);
35+
}
36+
const version = match[1];
37+
if (!versionAtLeast(version, MIN_SUI_VERSION)) {
38+
throw new Error(
39+
`Sui CLI version ${version} is too old. Minimum required: ${MIN_SUI_VERSION}. ` +
40+
`Please update with: cargo install --locked --git https://github.com/MystenLabs/sui.git sui`
41+
);
42+
}
43+
console.log(`Sui CLI version: ${version}`);
44+
}
45+
446
export function buildSuiPackage(
547
packagesPath: string,
648
packageName: string,

0 commit comments

Comments
 (0)