Skip to content
Open
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: 4 additions & 6 deletions packages/core/src/bindings/patch-generated-binding-package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,10 @@ async function ensureRootBindingIndex(outputDir: string): Promise<void> {
const rootIndexPath = path.join(outputDir, "index.ts");

try {
const existing = await readFile(rootIndexPath, "utf8");
if (existing === ROOT_BINDING_INDEX_CONTENT) {
return;
}

// Preserve a non-Caatinga root index if the generator starts shipping one.
// Any existing root index is preserved (whether Caatinga-authored or a
// non-Caatinga one the generator might start shipping); only an absent
// file is created.
await readFile(rootIndexPath, "utf8");
return;
} catch {
await writeFile(rootIndexPath, ROOT_BINDING_INDEX_CONTENT, "utf8");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,11 @@ describe("probeMissingStellarCliFeatures (live Stellar CLI)", () => {
expect(parseStellarCliVersion(`stellar ${report.version}`)).toBe(report.version);
});
});

describe("probeMissingStellarCliFeatures (below minimum version)", () => {
it("reports every required feature as missing when the CLI is below the minimum", async () => {
// Returns early without probing the binary, so this needs no live CLI.
const missing = await probeMissingStellarCliFeatures("22.0.0");
expect(missing.sort()).toEqual([...STELLAR_CLI_REQUIRED_FEATURES].sort());
});
});
4 changes: 3 additions & 1 deletion packages/core/src/stellar-cli/probe-stellar-cli-features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ export async function probeMissingStellarCliFeatures(version: string): Promise<s
const missing: string[] = [];

if (semver.valid(version) && semver.lt(version, STELLAR_CLI_MIN_VERSION)) {
return ["contract-invoke-sign"];
// Below the minimum version every required subcommand is considered
// unreliable, not just contract-invoke-sign — report them all.
return [...STELLAR_CLI_REQUIRED_FEATURES];
}

for (const feature of STELLAR_CLI_REQUIRED_FEATURES) {
Expand Down
49 changes: 0 additions & 49 deletions packages/core/src/stellar-cli/stellar-cli-output-parser.test.ts

This file was deleted.

11 changes: 0 additions & 11 deletions packages/core/src/stellar-cli/stellar-cli-output-parser.ts

This file was deleted.

15 changes: 15 additions & 0 deletions packages/core/src/stellar-cli/version.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { describe, expect, it } from "vitest";
import { CaatingaErrorCode } from "../errors/CaatingaError.js";
import { parseStellarCliVersion } from "./version.js";

describe("parseStellarCliVersion", () => {
it("should_parse_valid_semver_from_output", () => {
expect(parseStellarCliVersion("stellar 27.0.0")).toBe("27.0.0");
});

it("should_throw_STELLAR_CLI_VERSION_PARSE_FAILED_when_absent", () => {
expect(() => parseStellarCliVersion("no version here")).toThrow(
expect.objectContaining({ code: CaatingaErrorCode.STELLAR_CLI_VERSION_PARSE_FAILED })
);
});
});
7 changes: 4 additions & 3 deletions packages/core/src/version.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createRequire } from "node:module";

declare const __filename: string | undefined;

const require = createRequire(typeof __filename === "string" ? __filename : import.meta.url);
// The CJS build (dist/index.cjs) rewrites import.meta.url via a tsup banner
// shim (pathToFileURL(__filename).href), so this resolves correctly in the ESM
// source, the ESM dist, and the CJS dist alike — no __filename fallback needed.
const require = createRequire(import.meta.url);
export const CAATINGA_CORE_VERSION: string = require("../package.json").version;