UNPKG

vlt

Version:
185 lines (183 loc) 4.86 kB
var global = globalThis; import {Buffer} from "node:buffer"; import {setTimeout,clearTimeout,setImmediate,clearImmediate,setInterval,clearInterval} from "node:timers"; import {createRequire as _vlt_createRequire} from "node:module"; var require = _vlt_createRequire(import.meta.filename); import { vlxDelete, vlxInfo, vlxInstall, vlxList } from "./chunk-TY5MOWCL.js"; import { RollbackRemove } from "./chunk-HFPRNHS6.js"; import "./chunk-SDAHMDDM.js"; import "./chunk-XZF5GYDF.js"; import "./chunk-FZMPFIDM.js"; import "./chunk-SLTPNBLH.js"; import "./chunk-D36DAG56.js"; import "./chunk-LEKM5RQR.js"; import "./chunk-YWPMIBJS.js"; import "./chunk-5UBJ3ZBM.js"; import "./chunk-SGEQHKFC.js"; import { ViewClass, stdout } from "./chunk-I5CBBY6I.js"; import { commandUsage } from "./chunk-2Y5QRO5N.js"; import "./chunk-VTABR43C.js"; import "./chunk-QAFV2NQX.js"; import "./chunk-VYJVN3B6.js"; import "./chunk-GADRCS54.js"; import "./chunk-GY4L7O2Y.js"; import "./chunk-3HSZY4YW.js"; import "./chunk-6YRWYWZQ.js"; import "./chunk-TJHWNOOA.js"; import "./chunk-L3TCSQZJ.js"; import "./chunk-3RABDTYN.js"; import "./chunk-264UXZEG.js"; import "./chunk-X4RDKJKD.js"; import "./chunk-BNCOU5ZT.js"; import { error } from "./chunk-RV3EHS4P.js"; import "./chunk-AECDW3EJ.js"; // ../../src/cli-sdk/src/commands/exec-cache.ts import { basename } from "node:path"; var view; var ExecCacheView = class extends ViewClass { constructor(options, conf) { super(options, conf); view = this; } stdout(...args) { stdout(...args); } }; var views = { human: ExecCacheView }; var usageDef = { command: "exec-cache", usage: "<command> [flags]", description: "Work with vlt exec-cache folders", subcommands: { ls: { usage: "", description: `Show previously installed packages used for \`vlt exec\`. Key provided can be either the package name, or the full key.` }, delete: { usage: "[<key>...]", description: `Delete previously installed packages used for \`vlt exec\`. If no keys are provided, then all entries will be deleted.` }, info: { usage: "<key>", description: `Show extended information about a given \`vlt exec\` installation.` }, install: { usage: "<spec>...", description: `Install the specified package(s) in the \`vlt exec\` central cache location. Metadata info about each installation will be printed.` } }, examples: { ls: { description: `Show all the keys for the installations in the \`vlt exec\` cache.` }, "delete typescript": { description: `Delete all versions of typescript installed for vlt exec` }, "info typescript-695bf962": { description: `Show extended info about a specific version of typescript` } } }; var usage = () => commandUsage(usageDef); var command = async (conf) => { const [sub, ...args] = conf.positionals; switch (sub) { case "ls": return ls(conf, args, view); case "info": return info(conf, args, view); case "install": return install(conf, args, view); case "delete": return deleteEntries(conf, args, view); default: { throw error("Unrecognized exec-cache command", { code: "EUSAGE", found: sub, validOptions: Object.keys(usageDef.subcommands) }); } } }; var install = async (conf, keys, view2) => { if (!keys.length) { throw error("Must supply a package spec to install", { code: "EUSAGE" }); } return Promise.all( keys.map(async (key) => { const info2 = await vlxInstall(key, { ...conf.options, query: void 0 }); view2?.stdout(info2); return info2.path; }) ); }; var ls = async (_conf, args, view2) => { const results = []; for await (const path of vlxList()) { const key = basename(path); if (args.length && !args.some((a) => key.includes(a))) continue; results.push(key); view2?.stdout(key); } return results; }; var info = async (conf, keys, view2) => { const results = []; for await (const key of keys.length ? keys : vlxList()) { const info2 = vlxInfo(key, { ...conf.options, query: void 0 }); results.push(info2); view2?.stdout(info2); } return results; }; var deleteEntries = async (conf, keys, view2) => { const remover = new RollbackRemove(); const removed = (await vlxDelete(keys, remover, { ...conf.options, query: void 0 })).map((path) => { view2?.stdout(`- ${basename(path)}`); return path; }); remover.confirm(); return removed; }; export { ExecCacheView, command, usage, views }; //# sourceMappingURL=exec-cache-BMJCXG6C.js.map