@mesh-tech/mesh-cli
Version:
CLI for Mesh platform development utilities
17 lines (16 loc) • 722 B
JavaScript
import { gitWithAuth, resolveToken } from "./common.js";
export async function cloneCommand(repo, dest, opts) {
const baseUrl = (opts.url ?? process.env.VCS_URL)?.replace(/\/$/, "");
if (!baseUrl)
throw new Error("clone requires --url or VCS_URL");
const token = await resolveToken(opts);
await gitWithAuth([
"clone",
"-c",
`http.extraHeader=Authorization: Bearer ${token}`,
`${baseUrl}/git/${repo}`,
dest ?? repo,
], token);
await gitWithAuth(["config", "http.extraHeader", `Authorization: Bearer ${token}`], token, dest ?? repo);
console.log(`cloned ${repo} → ${dest ?? repo} (read-only remote; use 'mesh vcs propose' to submit changes)`);
}