Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 14 additions & 0 deletions cli/src/__tests__/bugfix-regression.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,20 @@ describe("Fix #14: sui/helpers.ts — execFileSync only, no execSync", () => {
});
});

// ─── tag.ts — no shell symlink (spaces in path) ─────────────────────────────

describe("tag.ts — symlink uses fs.symlinkSync, not ln -fs", () => {
test("does not shell out for symlink creation", () => {
const source = fs.readFileSync(
path.join(SRC_DIR, "tag.ts"),
"utf-8"
);
// Before fix: execSync(`ln -fs $(pwd)/...`) — breaks with spaces in path
expect(source).not.toMatch(/ln -fs/);
expect(source).toMatch(/fs\.symlinkSync/);
});
});

// ─── Fix #11: config-mgmt.ts — no contradictory ?. + ! ──────────────────────

describe("Fix #11: config-mgmt.ts — no diff[k]?.push! pattern", () => {
Expand Down
3 changes: 3 additions & 0 deletions cli/src/commands/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
getImmutables,
getPdas,
} from "../index";
import { formatNttVersion } from "../version.js";

export function createStatusCommand(
overrides: WormholeConfigOverrides<Network>
Expand All @@ -44,6 +45,8 @@ export function createStatusCommand(
"Check the status with detailed output"
),
handler: async (argv: any) => {
console.log(formatNttVersion());

const path = argv["path"];
const verbose = argv["verbose"];
// TODO: I don't like the variable names here
Expand Down
11 changes: 5 additions & 6 deletions cli/src/tag.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Platform } from "@wormhole-foundation/sdk";
import { execSync } from "child_process";
import fs from "fs";
import path from "path";
import { colors } from "./colors.js";
import { askForConfirmation } from "./prompts.js";

Expand Down Expand Up @@ -83,12 +84,10 @@ export function createWorkTree(platform: Platform, version: string): string {

// NOTE: we create this symlink whether or not the file exists.
// this way, if it's created later, the symlink will be correct
execSync(
`ln -fs $(pwd)/overrides.json $(pwd)/${worktreeName}/overrides.json`,
{
stdio: "inherit",
}
);
const target = path.resolve("overrides.json");
const linkPath = path.resolve(worktreeName, "overrides.json");
try { fs.unlinkSync(linkPath); } catch (e: any) { if (e.code !== "ENOENT") throw e; }
fs.symlinkSync(target, linkPath);

console.log(
colors.green(`Created worktree at ${worktreeName} from tag ${tag}`)
Expand Down
34 changes: 34 additions & 0 deletions cli/src/version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import fs from "fs";

export function nttVersion(): {
version: string;
commit: string;
path: string;
remote: string;
} | null {
const nttDir = `${process.env.HOME}/.ntt-cli`;
try {
const versionFile = fs.readFileSync(`${nttDir}/version`).toString().trim();
const [commit, installPath, version, remote] = versionFile.split("\n");
return { version, commit, path: installPath, remote };
} catch {
return null;
}
}

export function formatNttVersion(): string {
const ver = nttVersion();
if (!ver) {
return "ntt version: unknown";
}
const { version, commit, path, remote } = ver;
const defaultPath = `${process.env.HOME}/.ntt-cli/.checkout`;
const remoteString = remote.includes("wormhole-foundation")
? ""
: `${remote}@`;
if (path === defaultPath) {
return `ntt v${version} (${remoteString}${commit})`;
} else {
return `ntt v${version} (${remoteString}${commit}) from ${path}`;
}
}
Loading