feat(import): code-repo job
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
524b1b4645
commit
0e090a0e15
@@ -27,7 +27,7 @@ function moduleNumber(m: { id: string; title: string }, index: number): number {
|
||||
return folderNumber(m.title) ?? index + 1;
|
||||
}
|
||||
|
||||
/** One level of single-directory wrappers ("Repo-main/Repo-main/…") is skipped. */
|
||||
/** Single-directory wrappers ("Repo-main/…") of a zip are skipped. */
|
||||
async function effectiveRoot(dir: string): Promise<string> {
|
||||
for (let i = 0; i < 3; i++) {
|
||||
const entries = (await readdir(dir, { withFileTypes: true })).filter((e) => !e.name.startsWith(".") && e.name !== "__MACOSX");
|
||||
@@ -62,11 +62,10 @@ export async function importCodeRepo(d: Deps, payload: unknown, jc: JobContext):
|
||||
await jc.reportProgress(0.05, "Unpacking the repository zip");
|
||||
const src = await openSource(path);
|
||||
await src.extract(src.entries.filter((e) => !e.startsWith("__MACOSX/")), join(stage, "repo"), jc.signal);
|
||||
root = join(stage, "repo");
|
||||
root = await effectiveRoot(join(stage, "repo")); // GitHub-style zips wrap everything in one folder
|
||||
} else {
|
||||
root = path; // an extracted folder is only read
|
||||
}
|
||||
root = await effectiveRoot(root);
|
||||
|
||||
const modules: any[] = course.manifest.modules ?? [];
|
||||
const folders = (await readdir(root, { withFileTypes: true })).filter((e) => e.isDirectory() && !SKIP_DIRS.has(e.name) && !e.name.startsWith(".")).map((e) => e.name).sort();
|
||||
|
||||
Reference in New Issue
Block a user