UNPKG

@botpress/adk-cli

Version:

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

99 lines (97 loc) 3.04 kB
// @bun import { DEPENDENCY_SNAPSHOT_SECURITY_NOTICE, clearDependencyConfig, defaultDependencySnapshotFileName, writeDependencyStateFile } from "./chunk-2xth50pf.js"; import { loadProjectDM, parseFormat, parseTarget, runDependencyCommand } from "./chunk-69myctr2.js"; import"./chunk-3k2q12qe.js"; import"./chunk-3ahwp6fe.js"; import { DependencyError } from "./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"./chunk-dhs2bg35.js"; // src/commands/dependencies/export.ts import path from "path"; async function adkDependenciesExport(output, options = {}) { await runDependencyCommand({ options, run: async (logger) => { const format = parseFormat(options.format); const target = parseExportTarget(options.target); const includeConfig = options.config !== false; const { dm, project } = await loadProjectDM(target); const state = await dm.snapshotStateFromCloud(); const outputState = includeConfig ? state : clearDependencyConfig(state); const projectName = project.config?.name ?? path.basename(project.path); const outputPath = path.resolve(process.cwd(), output ?? defaultDependencySnapshotFileName(projectName, target)); await writeDependencyStateFile(outputPath, outputState); const result = { output: outputPath, target, configIncluded: includeConfig, integrationCount: Object.keys(outputState.integrations).length, pluginCount: Object.keys(outputState.plugins).length, ...includeConfig ? { securityNotice: DEPENDENCY_SNAPSHOT_SECURITY_NOTICE } : {} }; if (includeConfig) { logger.warn(DEPENDENCY_SNAPSHOT_SECURITY_NOTICE); } if (format === "text") { logger.info(`Exported ${outputPath}`); return {}; } return { extras: result }; } }); } function parseExportTarget(raw) { const parsed = parseTarget(raw); if (parsed === "all") { throw new DependencyError({ code: "MISSING_INPUT", message: `'all' is not valid for --target on dependency export. Use 'dev' or 'prod'.` }); } return parsed; } export { adkDependenciesExport };