UNPKG

vlt

Version:
155 lines (146 loc) 5.28 kB
var global = globalThis; import {Buffer} from "node:buffer"; import {setTimeout as _vlt_setTimeout,clearTimeout as _vlt_clearTimeout,setImmediate as _vlt_setImmediate,clearImmediate as _vlt_clearImmediate,setInterval as _vlt_setInterval,clearInterval as _vlt_clearInterval} from "node:timers"; globalThis.setTimeout = _vlt_setTimeout; globalThis.clearTimeout = _vlt_clearTimeout; globalThis.setImmediate = _vlt_setImmediate; globalThis.clearImmediate = _vlt_clearImmediate; globalThis.setInterval = _vlt_setInterval; globalThis.clearInterval = _vlt_clearInterval; import {createRequire as _vlt_createRequire} from "node:module"; var require = _vlt_createRequire(import.meta.filename); import { ExecCommand, views } from "./chunk-DPW3XYNO.js"; import "./chunk-4N7U4YYK.js"; import { vlxResolve } from "./chunk-B2NFO3W6.js"; import { styleTextStdout } from "./chunk-PXEDENDA.js"; import "./chunk-RPYKRKJX.js"; import "./chunk-C476FDK4.js"; import "./chunk-2JA5GDCD.js"; import "./chunk-6K6533KS.js"; import "./chunk-IN6BBUSG.js"; import { exec, execFG } from "./chunk-V52UM37T.js"; import "./chunk-6F6VOBW3.js"; import "./chunk-QEOLSUUZ.js"; import { commandUsage } from "./chunk-32II74H6.js"; import "./chunk-C3WXW4MY.js"; import "./chunk-JG56ZRZC.js"; import "./chunk-X4GYYGTU.js"; import "./chunk-CGWKWA24.js"; import "./chunk-MBW6A3RQ.js"; import "./chunk-YD3KKYTM.js"; import "./chunk-XGSKO6BL.js"; import "./chunk-RXFAZHP7.js"; import "./chunk-TW6XJ6XF.js"; import "./chunk-4LVU5YJD.js"; import "./chunk-TG2CR2PD.js"; import "./chunk-REP7WICP.js"; import "./chunk-XN35SAI7.js"; import "./chunk-52JFXOJH.js"; import "./chunk-CHD5BAMM.js"; import "./chunk-C5WO664N.js"; // ../../src/cli-sdk/src/commands/exec.ts import { homedir } from "node:os"; import { createInterface } from "node:readline/promises"; var usage = () => commandUsage({ command: "exec", usage: "[--package=<pkg>] [command...]", description: `Run a command defined by a package, installing it if necessary. If the package specifier is provided explicitly via the \`--package\` config, then that is what will be used. If a satisfying instance of the named package exists in the local \`node_mnodules\` folder, then that will be used. If \`--package\` is not set, then vlt will attempt to infer the package to be installed if necessary, in the following manner: - If the first argument is an executable found in the \`node_modules/.bin\` folder (ie, provided by an installed direct dependency), then that will be used. The search stops, and nothing will be installed. - Otherwise, vlt attempts to resolve the first argument as if it was a \`--package\` option, and then swap it out with the "default" executable provided by that package. The "default" executable provided by a package is: - If the package provides a single executable string in the \`bin\` field, then that is the executable to use. - Otherwise, if there is a \`bin\` with the same name as the package (or just the portion after the \`/\` in the case of scoped packages), then that will be used. If the appropriate excutable cannot be determined, then an error will be raised. At no point will \`vlt exec\` change the locally installed dependencies. Any installs it performs is done in vlt's XDG data directory. `, examples: { "--package typescript@5 tsc": { description: "Run tsc provided by typescript version 5" }, "eslint src/file.js": { description: "Run the default bin provided by eslint" }, "eslint@9.24 src/file.js": { description: "Run the default bin provided by eslint version 9.24" } } }); var HOME = homedir(); var prettyPath = (path) => path.startsWith(HOME) ? `~${path.substring(HOME.length)}` : path; var promptFn = async (pkgSpec, path, resolution) => { const response = await createInterface( process.stdin, process.stdout ).question( `About to install: ${styleTextStdout( ["bgWhiteBright", "black", "bold"], String(pkgSpec) )} from: ${styleTextStdout( ["bgWhiteBright", "black", "bold"], resolution )} into: ${styleTextStdout( ["bgWhiteBright", "black", "bold"], prettyPath(path) )} Is this ok? (y) ` ); process.stdin.pause(); return response; }; var command = async (conf) => { const allowScripts = conf.get("allow-scripts") ? String(conf.get("allow-scripts")) : ":not(*)"; const arg0 = await vlxResolve( conf.positionals, { ...conf.options, query: void 0, allowScripts }, promptFn ); if (arg0) conf.positionals[0] = arg0; delete conf.options["script-shell"]; return await new ExecCommand(conf, exec, execFG).run(); }; export { command, prettyPath, promptFn, usage, views }; //# sourceMappingURL=exec-HUGXGX7H.js.map