135ea21a61
Fixes the v0.3.4 fresh-box failures: silent CLI under bare-word PATH invocation (SEA argv detection), bootstrap dying on venv creation without an actionable hint (poisoned-partial-venv recovery + apt hint + doctor venv-capability probe + preflight), installer falsely 'verifying' a silent binary, and localhost-only server binding (network mode: 0.0.0.0 + wildcard CORS + hostname-derived API URL — remote browsing zero-config). 38 CLI tests, 3 web tests, 409 ai-service tests green; build/typecheck/lint clean. ---ci--- phase: hotfix milestone: v0.4 status: complete type: hotfix requirements: covered: [REQ-4-001, REQ-4-002, REQ-4-003, REQ-4-004, REQ-4-005] partial: [] ---/ci---
38 lines
2.1 KiB
TypeScript
38 lines
2.1 KiB
TypeScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { spawnSync } from "node:child_process";
|
|
import { cpSync, existsSync, mkdirSync, mkdtempSync } from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import { join, dirname } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const cliDir = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
const repoRoot = join(cliDir, "..", "..");
|
|
const binary = join(repoRoot, "apps", "cli", "dist", "nextcraft-linux-x64");
|
|
|
|
test("PATH bare-word invocation: installed binary speaks (SEA regression, v0.3.4 bug)", () => {
|
|
if (!existsSync(binary)) return; // built by cli:build:binary; covered in ship flow
|
|
const binDir = mkdtempSync(join(tmpdir(), "nc-pathword-"));
|
|
cpSync(binary, join(binDir, "nextcraft"));
|
|
const env = {
|
|
PATH: [binDir, process.env.PATH].filter(Boolean).join(":"),
|
|
HOME: process.env.HOME,
|
|
};
|
|
const { NODE_TEST_CONTEXT, ...rest } = process.env as Record<string, string | undefined>;
|
|
const envClean = { ...rest, ...env } as Record<string, string | undefined>;
|
|
|
|
const ver = spawnSync("sh", ["-c", "nextcraft --version"], { encoding: "utf8", timeout: 30000, env: envClean });
|
|
assert.equal(ver.status, 0, `--version rc: ${ver.status} stderr: ${ver.stderr}`);
|
|
assert.ok(ver.stdout.trim().length > 0, "--version must print the version (v0.3.4 was silent)");
|
|
|
|
const doc = spawnSync("sh", ["-c", "nextcraft doctor"], { encoding: "utf8", timeout: 120000, env: envClean });
|
|
assert.equal(doc.status, 0, `doctor rc: ${doc.status} stderr: ${doc.stderr}`);
|
|
assert.ok(doc.stdout.includes("environment prerequisites"), "doctor must print its report");
|
|
|
|
const noArgs = spawnSync("sh", ["-c", "nextcraft"], { encoding: "utf8", timeout: 30000, env: envClean });
|
|
assert.equal(noArgs.status, 2, "no args must exit 2");
|
|
assert.ok((noArgs.stderr + noArgs.stdout).includes("Usage:"), "no args must print usage");
|
|
|
|
const bad = spawnSync("sh", ["-c", "nextcraft nosuchcmd"], { encoding: "utf8", timeout: 30000, env: envClean });
|
|
assert.equal(bad.status, 2, "unknown command must exit 2");
|
|
}); |