UNPKG

@iqai/adk-cli

Version:

CLI tool for creating, running, and testing ADK-TS agents

52 lines 2.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createExternalizePlugin = createExternalizePlugin; exports.isRebuildNeeded = isRebuildNeeded; function createExternalizePlugin(alwaysExternal = ["@iqai/adk"], scopes = ["@iqai/"]) { const ALWAYS_EXTERNAL_SCOPES = scopes; const explicitExternals = new Set(alwaysExternal); return { name: "externalize-bare-imports", setup(build) { build.onResolve({ filter: /.*/ }, (args) => { const isWindowsAbsolutePath = /^[a-zA-Z]:/.test(args.path); if (args.path.startsWith(".") || args.path.startsWith("/") || args.path.startsWith("..") || isWindowsAbsolutePath) { return; } if (ALWAYS_EXTERNAL_SCOPES.some((s) => args.path.startsWith(s)) || explicitExternals.has(args.path)) { return { path: args.path, external: true }; } return { path: args.path, external: true }; }); }, }; } function isRebuildNeeded(outFile, sourceFile, tsconfigPath, logger, quiet = false) { const { existsSync, statSync } = require("node:fs"); if (!existsSync(outFile)) return true; try { const outStat = statSync(outFile); const srcStat = statSync(sourceFile); const tsconfigMtime = existsSync(tsconfigPath) ? statSync(tsconfigPath).mtimeMs : 0; const needRebuild = !(outStat.mtimeMs >= srcStat.mtimeMs && outStat.mtimeMs >= tsconfigMtime); if (!needRebuild && !quiet) { logger?.debug?.(`Reusing cached build: ${outFile}`); } return needRebuild; } catch (error) { if (!quiet) { const msg = error instanceof Error ? error.message : String(error); logger?.warn?.(`Failed to check cache freshness for ${outFile}: ${msg}. Forcing rebuild.`); } return true; } } //# sourceMappingURL=build-utils.js.map