mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 07:50:13 +00:00
fix(cli): publish keeps Library files out for projects on cloud drives (#7582)
* fix(cli): publish keeps Library files out for projects on iCloud Drive Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(cli): treat Library/CloudStorage cloud drives like iCloud Drive when publishing Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
03ddfb189f
commit
f7bf5f0c42
@@ -29,15 +29,18 @@ function isUnder(path: string, ...dir: string[]): boolean {
|
||||
return lowerPath === lowerDir || lowerPath.startsWith(`${lowerDir}${sep}`);
|
||||
}
|
||||
|
||||
const CLOUD_DRIVE_FOLDERS = ["Mobile Documents", "CloudStorage"];
|
||||
|
||||
function homeAppDataFolder(path: string): string | null {
|
||||
if (isUnder(path, "AppData")) return "AppData";
|
||||
if (isUnder(path, "Library") && !isUnder(path, "Library", "Mobile Documents")) return "Library";
|
||||
const cloudDrive = CLOUD_DRIVE_FOLDERS.some((folder) => isUnder(path, "Library", folder));
|
||||
if (isUnder(path, "Library") && !cloudDrive) return "Library";
|
||||
return null;
|
||||
}
|
||||
|
||||
function inHomeAppData(projectDir: string, path: string): boolean {
|
||||
const folder = homeAppDataFolder(path);
|
||||
return folder !== null && !isUnder(projectDir, folder);
|
||||
return folder !== null && homeAppDataFolder(projectDir) !== folder;
|
||||
}
|
||||
|
||||
/** An existing file outside the project that publish leaves out: env files, Git data, hidden, system and app-data folders. */
|
||||
|
||||
@@ -271,6 +271,56 @@ describe("a reference to a file outside the project in a private location", () =
|
||||
}
|
||||
});
|
||||
|
||||
it("leaves out a Library file referenced by a project on iCloud Drive", () => {
|
||||
const home = temp();
|
||||
vi.stubEnv("HOME", home);
|
||||
vi.stubEnv("USERPROFILE", home);
|
||||
try {
|
||||
const drive = join(home, "Library", "Mobile Documents", "com~apple~CloudDocs");
|
||||
const token = join(home, "Library", "Application Support", "app", "token.json");
|
||||
mkdirSync(join(drive, "p"), { recursive: true });
|
||||
mkdirSync(dirname(token), { recursive: true });
|
||||
writeFileSync(token, "KEY");
|
||||
writeFileSync(join(drive, "p", "index.html"), `<img src="${token}">`);
|
||||
const warnings: string[] = [];
|
||||
const staged = stagePublishFiles(join(drive, "p"), Infinity, (w) => warnings.push(w));
|
||||
expect([...staged.keys()].some((key) => key.startsWith("_ext/"))).toBe(false);
|
||||
expect(warnings).toHaveLength(1);
|
||||
} finally {
|
||||
vi.unstubAllEnvs();
|
||||
}
|
||||
});
|
||||
|
||||
it("treats Library/CloudStorage like iCloud Drive, in both directions", () => {
|
||||
const home = temp();
|
||||
vi.stubEnv("HOME", home);
|
||||
vi.stubEnv("USERPROFILE", home);
|
||||
try {
|
||||
const dropbox = join(home, "Library", "CloudStorage", "Dropbox");
|
||||
const token = join(home, "Library", "Application Support", "app", "token.json");
|
||||
const logo = join(dropbox, "shared", "logo.png");
|
||||
for (const file of [token, logo]) {
|
||||
mkdirSync(dirname(file), { recursive: true });
|
||||
writeFileSync(file, "x");
|
||||
}
|
||||
mkdirSync(join(dropbox, "p"));
|
||||
writeFileSync(join(dropbox, "p", "index.html"), `<img src="${token}">`);
|
||||
const inDrive: string[] = [];
|
||||
const fromDrive = stagePublishFiles(join(dropbox, "p"), Infinity, (w) => inDrive.push(w));
|
||||
expect([...fromDrive.keys()].some((key) => key.startsWith("_ext/"))).toBe(false);
|
||||
expect(inDrive).toHaveLength(1);
|
||||
|
||||
const project = temp();
|
||||
writeFileSync(join(project, "index.html"), `<img src="${logo}">`);
|
||||
const outside: string[] = [];
|
||||
const toDrive = stagePublishFiles(project, Infinity, (w) => outside.push(w));
|
||||
expect([...toDrive.keys()].filter((key) => key.startsWith("_ext/"))).toHaveLength(1);
|
||||
expect(outside).toEqual([]);
|
||||
} finally {
|
||||
vi.unstubAllEnvs();
|
||||
}
|
||||
});
|
||||
|
||||
it("still copies a sibling asset folder named library or AppData outside the home folder", () => {
|
||||
const { ext, warnings } = stageIn("p", {
|
||||
"library/logo.png": "png",
|
||||
|
||||
Reference in New Issue
Block a user