Files
fusion/packages/core/src/git-cli-status.ts
gsxdsm 315f3bc32c FN-7470: show Git prerequisite during onboarding
Add Git availability checks to the first-run GitHub onboarding flow so missing host prerequisites are visible before project setup.

- Probe the server-host Git CLI with a bounded core helper and expose status through the auth status API.
- Render ready/missing Git prerequisite guidance in the GitHub onboarding step with install instructions and localized strings.
- Cover the probe, auth route, and onboarding UI states with regression tests, docs, and a changeset.

Files changed:
 .changeset/fn-7470-git-onboarding.md               |  7 ++
 docs/dashboard-guide.md                            |  2 +
 docs/getting-started.md                            |  2 +-
 packages/core/src/__tests__/git-cli-status.test.ts | 83 +++++++++++++++++++++
 packages/core/src/git-cli-status.ts                | 56 ++++++++++++++
 packages/core/src/index.ts                         |  7 ++
 packages/dashboard/app/api/legacy.ts               |  8 ++
 .../app/components/ModelOnboardingModal.css        | 59 +++++++++++++++
 .../app/components/ModelOnboardingModal.tsx        | 53 ++++++++++++-
 .../__tests__/ModelOnboardingModal.test.tsx        | 87 ++++++++++++++++++++++
 .../dashboard/src/__tests__/routes-auth.test.ts    | 62 ++++++++++++++-
 .../dashboard/src/routes/register-auth-routes.ts   | 13 +++-
 packages/i18n/locales/en/app.json                  | 11 ++-
 packages/i18n/locales/es/app.json                  | 44 ++++++++++-
 packages/i18n/locales/fr/app.json                  | 44 ++++++++++-
 packages/i18n/locales/ko/app.json                  | 44 ++++++++++-
 packages/i18n/locales/zh-CN/app.json               | 44 ++++++++++-
 packages/i18n/locales/zh-TW/app.json               | 44 ++++++++++-
 packages/i18n/src/resources.d.ts                   |  9 +++
 19 files changed, 661 insertions(+), 18 deletions(-)

Fusion-Task-Id: FN-7470
Fusion-Task-Lineage: 56d6f118-0d82-4f89-bcaa-b01e72a1bf8b
Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
2026-07-03 21:45:21 -07:00

57 lines
1.7 KiB
TypeScript

import { execFile } from "node:child_process";
import type { ExecFileException } from "node:child_process";
export const GIT_INSTALL_URL = "https://git-scm.com/downloads";
export const DEFAULT_GIT_CLI_STATUS_TIMEOUT_MS = 2_500;
export interface GitCliStatus {
available: boolean;
version?: string;
installUrl: string;
}
export interface ProbeGitCliStatusOptions {
timeoutMs?: number;
}
function parseGitVersion(stdout: string): string | undefined {
const trimmed = stdout.trim();
if (!trimmed) return undefined;
const match = trimmed.match(/git version\s+(.+)/i);
return match?.[1]?.trim() || trimmed;
}
/**
* FNXC:Onboarding 2026-07-03-00:00:
* First-run GitHub onboarding must detect whether `git` is available on the Fusion server host before clone/init flows fail later.
* Keep this probe bounded and argument-vector based so auth status can include prerequisite guidance without shell interpolation or long subprocess hangs.
*/
export async function probeGitCliStatus(options: ProbeGitCliStatusOptions = {}): Promise<GitCliStatus> {
const timeoutMs = options.timeoutMs ?? DEFAULT_GIT_CLI_STATUS_TIMEOUT_MS;
return new Promise((resolve) => {
const child = execFile(
"git",
["--version"],
{
encoding: "utf-8",
timeout: timeoutMs,
windowsHide: true,
},
(error: ExecFileException | null, stdout: string | Buffer) => {
if (error) {
resolve({ available: false, installUrl: GIT_INSTALL_URL });
return;
}
resolve({
available: true,
version: parseGitVersion(String(stdout)),
installUrl: GIT_INSTALL_URL,
});
},
);
child.stdin?.end();
});
}