mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-25 08:32:45 +00:00
fix(cli): isolate the skills freshness check on the desktop prerelease (#8198)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { execFile } from "node:child_process";
|
||||
import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
|
||||
import {
|
||||
chmodSync,
|
||||
@@ -776,6 +777,13 @@ describe("checkSkills canonical bypass of the in-repo manifest shortcut", () =>
|
||||
|
||||
const res = await checkSkills({ cwd: project, home, canonical: true });
|
||||
expect(res.skills.map((s) => s.name)).not.toContain("retired-skill");
|
||||
const options = vi.mocked(execFile).mock.lastCall?.[2] as {
|
||||
cwd: string;
|
||||
env: NodeJS.ProcessEnv;
|
||||
};
|
||||
expect(options.cwd).toMatch(/hyperframes-git-[^/\\]+$/);
|
||||
expect(options.env.GIT_DIR).toBe(options.cwd);
|
||||
expect(existsSync(options.cwd)).toBe(false);
|
||||
expect(res.skills.map((s) => s.name)).toContain("kept");
|
||||
});
|
||||
|
||||
|
||||
@@ -19,13 +19,15 @@ import { execFile } from "node:child_process";
|
||||
import { createHash } from "node:crypto";
|
||||
import {
|
||||
existsSync,
|
||||
mkdtempSync,
|
||||
readdirSync,
|
||||
readFileSync,
|
||||
renameSync,
|
||||
rmSync,
|
||||
statSync,
|
||||
writeFileSync,
|
||||
} from "node:fs";
|
||||
import { homedir } from "node:os";
|
||||
import { homedir, tmpdir } from "node:os";
|
||||
import { isAbsolute, join, relative, resolve, sep } from "node:path";
|
||||
import { promisify } from "node:util";
|
||||
|
||||
@@ -660,16 +662,38 @@ async function fetchManifest(url: string): Promise<SkillsManifest> {
|
||||
* Returns null when git/network is unavailable so callers fall back to main.
|
||||
*/
|
||||
async function remoteHeadSha(repoSlug: string): Promise<string | null> {
|
||||
let noRepo: string | undefined;
|
||||
try {
|
||||
// Pin both the working directory and repository so Git never discovers the project.
|
||||
noRepo = mkdtempSync(join(tmpdir(), "hyperframes-git-"));
|
||||
const { stdout } = await execFileAsync(
|
||||
"git",
|
||||
["ls-remote", `https://github.com/${repoSlug}.git`, "refs/heads/main"],
|
||||
{ timeout: FETCH_TIMEOUT_MS, env: { ...process.env, GIT_TERMINAL_PROMPT: "0" } },
|
||||
[
|
||||
"-c",
|
||||
"credential.helper=",
|
||||
"ls-remote",
|
||||
`https://github.com/${repoSlug}.git`,
|
||||
"refs/heads/main",
|
||||
],
|
||||
{
|
||||
timeout: FETCH_TIMEOUT_MS,
|
||||
cwd: noRepo,
|
||||
env: {
|
||||
...process.env,
|
||||
GIT_DIR: noRepo,
|
||||
GIT_TERMINAL_PROMPT: "0",
|
||||
GIT_ASKPASS: "",
|
||||
GCM_INTERACTIVE: "never",
|
||||
},
|
||||
windowsHide: true,
|
||||
},
|
||||
);
|
||||
const sha = stdout.split(/\s+/)[0]?.trim() ?? "";
|
||||
return /^[0-9a-f]{40}$/.test(sha) ? sha : null;
|
||||
} catch {
|
||||
return null;
|
||||
} finally {
|
||||
if (noRepo) rmSync(noRepo, { recursive: true, force: true });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user