fix: convert antfarm from broken submodule to regular directory

Fixes Gitea 500 error caused by invalid submodule reference.
Converted antfarm from pseudo-submodule (missing .gitmodules) to
regular directory with all source files.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Echo
2026-02-11 16:03:37 +00:00
parent 43f441c8ae
commit dc64d18224
102 changed files with 9049 additions and 1 deletions

View File

@@ -0,0 +1,73 @@
import { existsSync, mkdirSync, symlinkSync, unlinkSync, readlinkSync } from "fs";
import { join } from "path";
import { fileURLToPath } from "url";
const BINARY_NAME = "antfarm";
/**
* Ensure `antfarm` is available on PATH by symlinking into ~/.local/bin.
* Safe to call repeatedly — skips if already correct, updates if stale.
*/
export function ensureCliSymlink(): void {
const home = process.env.HOME;
if (!home) return;
const localBin = join(home, ".local", "bin");
const linkPath = join(localBin, BINARY_NAME);
// Resolve the actual CLI entry point (dist/cli/cli.js)
const cliEntry = join(
fileURLToPath(import.meta.url),
"..",
"..",
"cli",
"cli.js",
);
try {
mkdirSync(localBin, { recursive: true });
} catch {
// already exists
}
// Check existing symlink
if (existsSync(linkPath)) {
try {
const current = readlinkSync(linkPath);
if (current === cliEntry) return; // already correct
} catch {
// not a symlink or unreadable — replace it
}
try {
unlinkSync(linkPath);
} catch {
console.warn(` ⚠ Could not update symlink at ${linkPath}`);
return;
}
}
try {
symlinkSync(cliEntry, linkPath);
console.log(` ✓ Symlinked ${BINARY_NAME}${localBin}`);
} catch (err) {
console.warn(` ⚠ Could not create symlink: ${err instanceof Error ? err.message : String(err)}`);
}
}
/**
* Remove the CLI symlink (used during uninstall).
*/
export function removeCliSymlink(): void {
const home = process.env.HOME;
if (!home) return;
const linkPath = join(home, ".local", "bin", BINARY_NAME);
if (existsSync(linkPath)) {
try {
unlinkSync(linkPath);
console.log(` ✓ Removed symlink ${linkPath}`);
} catch {
console.warn(` ⚠ Could not remove symlink at ${linkPath}`);
}
}
}