UNPKG

snapcube

Version:

📦 Snapshot, backup, and restore any project — binary-safe, fast, and simple CLI.

29 lines • 1.42 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.cloneGitlabRepo = void 0; const fs_1 = require("fs"); const core_1 = require("../core"); /** * Clone (snapshot) a Gitlab repository into a JSON file. * * @param repository - Repository in the format "owner/repo" * @param options - Configuration for how files should be scanned * - ignoreBinaries: Skip contents of binary files (images, pdfs, etc.) * - ignoreAll: Skip contents of all files (structure only) * - token: Reserved for GitHub API use (not used in local scans) * - structureOnly: If true, combine `filePath` + `fileName` into one */ const cloneGitlabRepo = async (repository, branch, options) => { // Split "owner/repo" into separate variables const [owner, repoName] = repository.split("/"); console.log(`Scanning project: gitlab:${owner}/${repoName}`); // Fetch all files and metadata from the Gitlab API const files = await (0, core_1.getGitlabFiles)(repository, branch, options); console.log(`Scan complete. Total files: ${files?.length}`); // Save the snapshot to a JSON file named after the repo (0, fs_1.writeFileSync)(`${owner}_${repoName}.snapcube.json`, JSON.stringify(files, null, 4) // pretty-print with 4-space indentation ); console.log("Snapshot saved"); }; exports.cloneGitlabRepo = cloneGitlabRepo; //# sourceMappingURL=cloneGitlabRepo.js.map