mirror of
https://github.com/zuiidea/antd-admin
synced 2026-11-04 17:37:20 +00:00
feat(create): download templates with giget
Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { downloadTemplate } from "giget";
|
||||
import { CliError } from "./errors.js";
|
||||
|
||||
export async function downloadExampleToTemp(
|
||||
gigetSource: string
|
||||
): Promise<string> {
|
||||
const dir = path.join(os.tmpdir(), `create-antd-admin-${randomUUID()}`);
|
||||
try {
|
||||
const { dir: outDir } = await downloadTemplate(gigetSource, {
|
||||
dir,
|
||||
forceClean: true,
|
||||
});
|
||||
return outDir;
|
||||
} catch (e) {
|
||||
const msg = e instanceof Error ? e.message : String(e);
|
||||
throw new CliError(
|
||||
`Failed to download template.\nSource: ${gigetSource}\n${msg}`,
|
||||
"DOWNLOAD_FAILED"
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user