UNPKG

vlt

Version:
224 lines (219 loc) 6.8 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 { Query } from "./chunk-4HCFIDH4.js"; import { require_lz_string, startGUI } from "./chunk-CFFI3WEV.js"; import { SecurityArchive } from "./chunk-G6XZXH3U.js"; import "./chunk-WJN6TZTJ.js"; import "./chunk-3SZCEJ7Q.js"; import "./chunk-M34JYYXI.js"; import { GraphModifier, actual, asNode, humanReadableOutput, jsonOutput, mermaidOutput } from "./chunk-HFPRNHS6.js"; import "./chunk-SDAHMDDM.js"; import "./chunk-XZF5GYDF.js"; import "./chunk-FRVD5QAW.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 "./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 { __toESM } from "./chunk-AECDW3EJ.js"; // ../../src/cli-sdk/src/commands/list.ts var import_lz_string = __toESM(require_lz_string(), 1); var usage = () => commandUsage({ command: "ls", usage: [ "", "[package-names...] [--view=human | json | mermaid | gui]", "[--scope=<query>] [--target=<query>] [--view=human | json | mermaid | gui]" ], description: `List installed dependencies matching given package names or query selectors. Package names provided as positional arguments will be used to filter the results to show only dependencies with those names. The --scope and --target options accepts DSS query selectors to filter packages. Using --scope, you can specify which packages to treat as the top-level items in the output graph. The --target option allows you to filter what dependencies to include in the output. Using both options allows you to render subgraphs of the dependency graph. Defaults to listing direct dependencies of a project and any configured workspace.`, examples: { "": { description: "List direct dependencies of the current project / workspace" }, "foo bar baz": { description: `List all dependencies named 'foo', 'bar', or 'baz'` }, '--scope=":root > #dependency-name"': { description: "Defines a direct dependency as the output top-level scope" }, '--target="*"': { description: "List all dependencies using a query selector" }, '--target=":workspace > *:peer"': { description: "List all peer dependencies of all workspaces" } }, options: { scope: { value: "<query>", description: "Query selector to select top-level packages using the DSS query language syntax." }, target: { value: "<query>", description: "Query selector to filter packages using the DSS query language syntax." }, view: { value: "[human | json | mermaid | gui]", description: "Output format. Defaults to human-readable or json if no tty." } } }); var views = { json: jsonOutput, mermaid: mermaidOutput, human: humanReadableOutput, gui: async ({ queryString }, _, conf) => { await startGUI( conf, `/explore/${import_lz_string.default.compressToEncodedURIComponent(queryString)}/overview` ); } }; var command = async (conf) => { const modifiers = GraphModifier.maybeLoad(conf.options); const monorepo = conf.options.monorepo; const mainManifest = conf.options.packageJson.read( conf.options.projectRoot ); const graph = actual.load({ ...conf.options, mainManifest, modifiers, monorepo, loadManifests: true }); for (const arg of conf.positionals) { if (!/^[@\w-]/.test(arg)) { throw error( `Direct queries are not supported as positional arguments. Use package names only.`, { code: "EUSAGE", cause: `Argument '${arg}' appears to be a query syntax. Only package names are allowed as positional arguments.` } ); } } const positionalQueryString = conf.positionals.map((k) => `#${k.replace(/\//, "\\/")}`).join(", "); const targetQueryString = conf.get("target"); const queryString = targetQueryString || positionalQueryString; const securityArchive = await SecurityArchive.start({ graph, specOptions: conf.options }); const query = new Query({ graph, specOptions: conf.options, securityArchive }); const projectQueryString = ":project, :project > *"; const selectImporters = []; const importers = /* @__PURE__ */ new Set(); const scopeIDs = []; const scopeQueryString = conf.get("scope"); let scopeNodes; if (scopeQueryString) { const scopeQuery = new Query({ graph, specOptions: conf.options, securityArchive }); const { nodes: nodes2 } = await scopeQuery.search(scopeQueryString, { signal: new AbortController().signal }); scopeNodes = nodes2; } if (scopeQueryString && scopeNodes) { for (const queryNode of scopeNodes) { importers.add(asNode(queryNode)); } } else { if (monorepo) { for (const workspace of monorepo.filter(conf.values)) { const w = graph.nodes.get(workspace.id); if (w) { importers.add(w); selectImporters.push(`[name="${w.name}"]`); selectImporters.push(`[name="${w.name}"] > *`); scopeIDs.push(workspace.id); } } } if (importers.size === 0) { for (const importer of graph.importers) { importers.add(importer); } } } const selectImportersQueryString = selectImporters.join(", "); const defaultQueryString = selectImporters.length && selectImporters.length < graph.importers.size ? selectImportersQueryString : projectQueryString; const { edges, nodes } = await query.search( queryString || defaultQueryString, { signal: new AbortController().signal, scopeIDs: scopeIDs.length > 0 ? scopeIDs : void 0 } ); return { importers, edges, nodes, queryString: queryString || defaultQueryString, highlightSelection: !!(targetQueryString || positionalQueryString) }; }; export { command, usage, views }; //# sourceMappingURL=list-IWYEZFXR.js.map