MCPcopy Create free account
hub / github.com/cloudflare/computer / runRepoImport

Function runRepoImport

packages/computer/src/artifacts/cli.ts:416–458  ·  view source on GitHub ↗
(client: ArtifactClient, args: string[])

Source from the content-addressed store, hash-verified

414}
415
416async function runRepoImport(client: ArtifactClient, args: string[]): Promise<ArtifactsCLIResult> {
417 const parsed = parseFlags(args, {
418 url: { kind: "value" },
419 branch: { kind: "value" },
420 depth: { kind: "value" },
421 "read-only": { kind: "bool" },
422 description: { kind: "value" },
423 });
424 if ("error" in parsed) return argvError("repo import", parsed.error);
425 const name = parsed.positional[0];
426 if (name === undefined) return argvError("repo import", "missing <name>");
427 if (parsed.positional.length > 1) {
428 return argvError("repo import", `unexpected argument '${parsed.positional[1]}'`);
429 }
430 const url = parsed.flags.url as string | undefined;
431 if (url === undefined) return argvError("repo import", "missing --url");
432
433 let depth: number | undefined;
434 if (parsed.flags.depth !== undefined) {
435 const n = Number.parseInt(parsed.flags.depth as string, 10);
436 if (!Number.isFinite(n) || n < 1) {
437 return argvError(
438 "repo import",
439 `--depth requires a positive integer (got ${JSON.stringify(parsed.flags.depth)})`,
440 );
441 }
442 depth = n;
443 }
444
445 try {
446 const result = await client.import(
447 name,
448 { url, branch: parsed.flags.branch as string | undefined, depth },
449 {
450 description: parsed.flags.description as string | undefined,
451 readOnly: parsed.flags["read-only"] === true,
452 },
453 );
454 return ok(json(result));
455 } catch (cause) {
456 return mapError("repo import", cause);
457 }
458}
459
460// ---------------------------------------------------------------
461// token group

Callers 1

runRepoFunction · 0.85

Calls 6

argvErrorFunction · 0.85
okFunction · 0.85
jsonFunction · 0.85
mapErrorFunction · 0.85
parseFlagsFunction · 0.70
importMethod · 0.65

Tested by

no test coverage detected