UNPKG

@botpress/adk-cli

Version:

Command-line interface for the Botpress Agent Development Kit (ADK)

97 lines (95 loc) 3.33 kB
// @bun import { loadProjectDM, parseFormat, parseKeyValueOptions, parseTarget, runDependencyCommand } from "./chunk-69myctr2.js"; import"./chunk-3k2q12qe.js"; import"./chunk-3ahwp6fe.js"; import"./chunk-5zm2mgt9.js"; import"./chunk-kk3h6qaj.js"; import"./chunk-gzwt1qdr.js"; import"./chunk-nxy2ya5r.js"; import"./chunk-wzj4dc7n.js"; import"./chunk-p0hjqn4r.js"; import"./chunk-np5wcwfv.js"; import"./chunk-dq2xpa24.js"; import"./chunk-6w0knnta.js"; import"./chunk-40x04ckt.js"; import"./chunk-t76d8fxx.js"; import"./chunk-nh2akp42.js"; import"./chunk-0fdvzjbh.js"; import"./chunk-2a5b6azq.js"; import"./chunk-vay209b5.js"; import"./chunk-3xrpxgq4.js"; import"./chunk-rfm3jr1m.js"; import"./chunk-w346ejn9.js"; import"./chunk-knvm2anf.js"; import"./chunk-65h5trb5.js"; import"./chunk-s2akeqpw.js"; import"./chunk-6771vrjp.js"; import"./chunk-g8mm42v1.js"; import"./chunk-50hzjdck.js"; import"./chunk-nn2jb0x0.js"; import"./chunk-v8xvth6j.js"; import"./chunk-kkk13rcb.js"; import"./chunk-ytpp1kam.js"; import"./chunk-na956zz3.js"; import"./chunk-f4bw8q7c.js"; import"./chunk-0v8vgrns.js"; import"./chunk-54qt5g7m.js"; import { __require } from "./chunk-dhs2bg35.js"; // src/commands/plugins/add.ts async function adkPluginsAdd(resource, options) { await runDependencyCommand({ options, run: async (logger) => { const format = parseFormat(options.format); const parsed = parseTarget(options.target); if (parsed === "all") { const { DependencyError } = await import("./chunk-z6sc1k1g.js"); throw new DependencyError({ code: "MISSING_INPUT", message: `'all' is not valid for --target on this command. Use 'dev' or 'prod'.` }); } const target = parsed; const [name, version] = resource.split("@"); if (!name) { const { DependencyError } = await import("./chunk-z6sc1k1g.js"); throw new DependencyError({ code: "MISSING_INPUT", message: "<name> is required" }); } const config = parseKeyValueOptions(options.config, "--config"); const dependencies = {}; for (const kv of options.dep ?? []) { const eq = kv.indexOf("="); if (eq < 0) { const { DependencyError } = await import("./chunk-z6sc1k1g.js"); throw new DependencyError({ code: "MISSING_INPUT", message: `--dep expects iface=alias, got '${kv}'` }); } dependencies[kv.slice(0, eq)] = { integrationAlias: kv.slice(eq + 1) }; } const { dm } = await loadProjectDM(target); const result = await dm.add("plugin", { name, version, alias: options.alias, config, dependencies }); if (format === "text") { if (result.noop) { logger.info(`\u2713 ${result.resource?.alias} already at ${result.resource?.version}, no-op`, "green"); } else { for (const ar of result.autoResolved ?? []) { logger.warn(`auto-resolved ${ar.pluginInterfaceAlias} \u2192 ${ar.integrationAlias}`); } logger.info(`\u2713 Added plugin ${result.resource?.alias} (${result.resource?.name}@${result.resource?.version})`, "green"); } return {}; } return { data: { result }, extras: { noop: result.noop ?? false, autoResolved: result.autoResolved ?? [] } }; } }); } export { adkPluginsAdd };