@routecraft/cli 0.5.0-canary.61 → 0.5.0-canary.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
var n={major:1,minor:1,patch:0},l="https://bun.com/docs/installation",g="https://routecraft.dev/docs/advanced/programmatic-invocation";function f(e=process.versions.bun??null){let o=e;if(!o)return {ok:false,message:`[routecraft] The craft CLI requires Bun. Install Bun from ${l}, or embed @routecraft/routecraft programmatically (see ${g}).`};let s=o.split(/[-+]/)[0]??"",[t,a,u]=s.split("."),r=Number(t),c=Number(a),m=Number(u??"0");return !Number.isFinite(r)||!Number.isFinite(c)||!Number.isFinite(m)?{ok:false,message:`[routecraft] Could not parse Bun version "${o}". Routecraft requires Bun ${p(n)} or later. Upgrade Bun: ${l}.`}:r>n.major||r===n.major&&(c>n.minor||c===n.minor&&m>=n.patch)?{ok:true}:{ok:false,message:`[routecraft] Bun ${o} is not supported. Routecraft requires Bun ${p(n)} or later. Upgrade Bun: ${l}.`}}function p(e){return `${e.major}.${e.minor}.${e.patch}`}var d=f();d.ok||(console.error(d.message),process.exit(1));var{Command:h}=await import('commander'),i=new h;i.name("craft").description("A modern routing framework for TypeScript").version("0.5.0-canary.
|
|
2
|
+
var n={major:1,minor:1,patch:0},l="https://bun.com/docs/installation",g="https://routecraft.dev/docs/advanced/programmatic-invocation";function f(e=process.versions.bun??null){let o=e;if(!o)return {ok:false,message:`[routecraft] The craft CLI requires Bun. Install Bun from ${l}, or embed @routecraft/routecraft programmatically (see ${g}).`};let s=o.split(/[-+]/)[0]??"",[t,a,u]=s.split("."),r=Number(t),c=Number(a),m=Number(u??"0");return !Number.isFinite(r)||!Number.isFinite(c)||!Number.isFinite(m)?{ok:false,message:`[routecraft] Could not parse Bun version "${o}". Routecraft requires Bun ${p(n)} or later. Upgrade Bun: ${l}.`}:r>n.major||r===n.major&&(c>n.minor||c===n.minor&&m>=n.patch)?{ok:true}:{ok:false,message:`[routecraft] Bun ${o} is not supported. Routecraft requires Bun ${p(n)} or later. Upgrade Bun: ${l}.`}}function p(e){return `${e.major}.${e.minor}.${e.patch}`}var d=f();d.ok||(console.error(d.message),process.exit(1));var{Command:h}=await import('commander'),i=new h;i.name("craft").description("A modern routing framework for TypeScript").version("0.5.0-canary.63").enablePositionalOptions().option("--log-level <level>","Log level (e.g. info, warn, error, silent to disable)").option("--log-file <path>","Write logs to a file instead of stdout").showSuggestionAfterError().showHelpAfterError().exitOverride(e=>{e.code==="commander.unknownCommand"&&process.exit(0);});process.argv.length<=2&&i.help({error:false});i.command("run").description("Run routes from a single TypeScript/JavaScript file").argument("<file>","Path to a file containing routes").argument("[args...]","CLI command and flags to pass through to CLI adapter routes").option("--env <path>","Load environment variables from a .env file (default: .env)").passThroughOptions().action(async(e,o,s)=>{let t=i.opts();t.logLevel!==void 0&&(process.env.LOG_LEVEL=t.logLevel,process.env.CRAFT_LOG_LEVEL=t.logLevel),t.logFile!==void 0&&(process.env.LOG_FILE=t.logFile,process.env.CRAFT_LOG_FILE=t.logFile);let{loadEnvFile:a}=await import('./util-GX4G3K5I.js');s.env!==void 0?a(s.env):a();let{runCommand:u}=await import('./run-3Y3G7OTJ.js'),r=await u(e,o);if(!r.success){r.message&&console.error(r.message);let c=r.code??1;setImmediate(()=>process.exit(c));return}});i.command("tui").description("Launch the Terminal UI to monitor Routecraft execution history").option("--db <path>","Path to the telemetry SQLite database",".routecraft/telemetry.db").action(async e=>{let{resolve:o,isAbsolute:s}=await import('path'),t=s(e.db)?e.db:o(process.cwd(),e.db),{renderTui:a}=await import('./tui/app.js');await a(t);});i.parse();//# sourceMappingURL=index.js.map
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/runtime-gate.ts","../src/index.ts"],"names":["MIN_BUN_VERSION","INSTALL_URL","EMBEDDING_DOC_URL","checkBunRuntime","bunVersion","version","stripped","majorStr","minorStr","patchStr","major","minor","patch","formatVersion","v","gate","Command","program","err","filePath","args","options","globalOpts","loadEnvFile","runCommand","result","code","resolve","isAbsolute","dbPath","renderTui"],"mappings":";AAUA,IAAMA,CAAAA,CAAkB,CAAE,KAAA,CAAO,CAAA,CAAG,MAAO,CAAA,CAAG,KAAA,CAAO,CAAE,CAAA,CAEjDC,CAAAA,CAAc,oCACdC,CAAAA,CACJ,8DAAA,CAQK,SAASC,CAAAA,CACdC,CAAAA,CAA4B,QAAQ,QAAA,CAAS,GAAA,EAAU,IAAA,CACpC,CACnB,IAAMC,CAAAA,CAAUD,EAEhB,GAAI,CAACC,EACH,OAAO,CACL,GAAI,KAAA,CACJ,OAAA,CACE,6DACoBJ,CAAW,CAAA,wDAAA,EAC0BC,CAAiB,CAAA,EAAA,CAC9E,CAAA,CAIF,IAAMI,CAAAA,CAAWD,CAAAA,CAAQ,MAAM,MAAM,CAAA,CAAE,CAAC,CAAA,EAAK,EAAA,CACvC,CAACE,EAAUC,CAAAA,CAAUC,CAAQ,EAAIH,CAAAA,CAAS,KAAA,CAAM,GAAG,CAAA,CACnDI,CAAAA,CAAQ,OAAOH,CAAQ,CAAA,CACvBI,EAAQ,MAAA,CAAOH,CAAQ,EACvBI,CAAAA,CAAQ,MAAA,CAAOH,GAAY,GAAG,CAAA,CAEpC,OACE,CAAC,MAAA,CAAO,QAAA,CAASC,CAAK,CAAA,EACtB,CAAC,OAAO,QAAA,CAASC,CAAK,GACtB,CAAC,MAAA,CAAO,SAASC,CAAK,CAAA,CAEf,CACL,EAAA,CAAI,KAAA,CACJ,QACE,CAAA,0CAAA,EAA6CP,CAAO,8BACzBQ,CAAAA,CAAcb,CAAe,CAAC,CAAA,wBAAA,EACzCC,CAAW,CAAA,CAAA,CAC/B,EAIAS,CAAAA,CAA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CAAO,MAAOI,CAAAA,EAAY,CACzB,GAAM,CAAE,OAAA,CAAAM,EAAS,UAAA,CAAAC,CAAW,EAAI,MAAM,OAAO,MAAW,CAAA,CAClDC,CAAAA,CAASD,CAAAA,CAAWP,CAAAA,CAAQ,EAAE,CAAA,CAChCA,EAAQ,EAAA,CACRM,CAAAA,CAAQ,QAAQ,GAAA,EAAI,CAAGN,EAAQ,EAAE,CAAA,CAE/B,CAAE,SAAA,CAAAS,CAAU,CAAA,CAAI,MAAM,OAAO,cAAc,EACjD,MAAMA,CAAAA,CAAUD,CAAM,EACxB,CAAC,CAAA,CAGHZ,CAAAA,CAAQ,KAAA,EAAM","file":"index.js","sourcesContent":["/**\n * Runtime gate for the craft CLI.\n *\n * The CLI is Bun-only. Users on Node embed @routecraft/routecraft\n * programmatically instead of going through the CLI.\n *\n * Exposed as a pure function so unit tests can pass arbitrary version strings\n * without spawning real bun processes.\n */\n\nconst MIN_BUN_VERSION = { major: 1, minor: 1, patch: 0 } as const;\n\nconst INSTALL_URL = \"https://bun.com/docs/installation\";\nconst EMBEDDING_DOC_URL =\n \"https://routecraft.dev/docs/advanced/programmatic-invocation\";\n\nexport type RuntimeGateResult = { ok: true } | { ok: false; message: string };\n\n// Accept `null` (not `undefined`) to express \"not running on Bun\" so tests can\n// reliably exercise the missing-bun path. JS default-parameter semantics\n// re-apply the default for explicit `undefined`, which would otherwise let\n// `process.versions.bun` leak in when the suite runs under Bun.\nexport function checkBunRuntime(\n bunVersion: string | null = process.versions[\"bun\"] ?? null,\n): RuntimeGateResult {\n const version = bunVersion;\n\n if (!version) {\n return {\n ok: false,\n message:\n `[routecraft] The craft CLI requires Bun. ` +\n `Install Bun from ${INSTALL_URL}, ` +\n `or embed @routecraft/routecraft programmatically (see ${EMBEDDING_DOC_URL}).`,\n };\n }\n\n // Strip both prerelease (`-`) and build metadata (`+`) per SemVer.\n const stripped = version.split(/[-+]/)[0] ?? \"\";\n const [majorStr, minorStr, patchStr] = stripped.split(\".\");\n const major = Number(majorStr);\n const minor = Number(minorStr);\n const patch = Number(patchStr ?? \"0\");\n\n if (\n !Number.isFinite(major) ||\n !Number.isFinite(minor) ||\n !Number.isFinite(patch)\n ) {\n return {\n ok: false,\n message:\n `[routecraft] Could not parse Bun version \"${version}\". ` +\n `Routecraft requires Bun ${formatVersion(MIN_BUN_VERSION)} or later. ` +\n `Upgrade Bun: ${INSTALL_URL}.`,\n };\n }\n\n const meetsFloor =\n major > MIN_BUN_VERSION.major ||\n (major === MIN_BUN_VERSION.major &&\n (minor > MIN_BUN_VERSION.minor ||\n (minor === MIN_BUN_VERSION.minor && patch >= MIN_BUN_VERSION.patch)));\n\n if (!meetsFloor) {\n return {\n ok: false,\n message:\n `[routecraft] Bun ${version} is not supported. ` +\n `Routecraft requires Bun ${formatVersion(MIN_BUN_VERSION)} or later. ` +\n `Upgrade Bun: ${INSTALL_URL}.`,\n };\n }\n\n return { ok: true };\n}\n\nfunction formatVersion(v: typeof MIN_BUN_VERSION): string {\n return `${v.major}.${v.minor}.${v.patch}`;\n}\n","#!/usr/bin/env bun\n\n/**\n * Routecraft CLI: single entry point.\n *\n * The CLI runs on Bun. For Node-based usage, embed @routecraft/routecraft\n * programmatically (see https://routecraft.dev/docs/advanced/programmatic-invocation).\n *\n * 1. Bun runtime gate (presence + version floor)\n * 2. Define program and parse; log options are global and applied before\n * lazy-loading run/util (which load the logger)\n */\n\nimport { checkBunRuntime } from \"./runtime-gate.js\";\n\n// ── 1. Bun runtime gate ─────────────────────────────────────────────\nconst gate = checkBunRuntime();\nif (!gate.ok) {\n // eslint-disable-next-line no-console\n console.error(gate.message);\n process.exit(1);\n}\n\n// ── 2. CLI definition (only Commander; run/util are lazy-loaded so logger sees env) ─\nconst { Command } = await import(\"commander\");\nconst program = new Command();\n\nprogram\n .name(\"craft\")\n .description(\"A modern routing framework for TypeScript\")\n .version(\"0.5.0-canary.61\")\n .enablePositionalOptions()\n .option(\n \"--log-level <level>\",\n \"Log level (e.g. info, warn, error, silent to disable)\",\n )\n .option(\"--log-file <path>\", \"Write logs to a file instead of stdout\")\n .showSuggestionAfterError()\n .showHelpAfterError()\n .exitOverride((err) => {\n if (err.code === \"commander.unknownCommand\") {\n process.exit(0);\n }\n });\n\n// Show help by default if no arguments provided\nif (process.argv.length <= 2) {\n program.help({ error: false });\n}\n\n/**\n * The 'run' command executes routes from a single file.\n *\n * Example:\n * craft run ./my-routes.ts\n * craft run ./my-cli.ts greet --name World\n */\nprogram\n .command(\"run\")\n .description(\"Run routes from a single TypeScript/JavaScript file\")\n .argument(\"<file>\", \"Path to a file containing routes\")\n .argument(\n \"[args...]\",\n \"CLI command and flags to pass through to CLI adapter routes\",\n )\n .option(\n \"--env <path>\",\n \"Load environment variables from a .env file (default: .env)\",\n )\n .passThroughOptions()\n .action(async (filePath, args: string[], options) => {\n // Apply global log options to env before any import that creates the logger\n const globalOpts = program.opts();\n if (globalOpts[\"logLevel\"] !== undefined) {\n process.env[\"LOG_LEVEL\"] = globalOpts[\"logLevel\"];\n process.env[\"CRAFT_LOG_LEVEL\"] = globalOpts[\"logLevel\"];\n }\n if (globalOpts[\"logFile\"] !== undefined) {\n process.env[\"LOG_FILE\"] = globalOpts[\"logFile\"];\n process.env[\"CRAFT_LOG_FILE\"] = globalOpts[\"logFile\"];\n }\n\n const { loadEnvFile } = await import(\"./util.js\");\n if (options.env !== undefined) {\n loadEnvFile(options.env);\n } else {\n loadEnvFile();\n }\n\n const { runCommand } = await import(\"./run.js\");\n const result = await runCommand(filePath, args);\n if (!result.success) {\n if (result.message) {\n // eslint-disable-next-line no-console\n console.error(result.message);\n }\n // Defer exit so pino/sonic-boom can finish initializing and avoid \"sonic boom is not ready yet\"\n const code = result.code ?? 1;\n setImmediate(() => process.exit(code));\n return;\n }\n // Don't call process.exit(); let the event loop drain naturally.\n // process.exit() triggers C++ static destructors that race with ONNX\n // Runtime cleanup (onnxruntime#25038: \"mutex lock failed\").\n });\n\n/**\n * The 'tui' command launches the Terminal UI for monitoring Routecraft execution.\n *\n * Example:\n * craft tui\n * craft tui --db .routecraft/telemetry.db\n */\nprogram\n .command(\"tui\")\n .description(\"Launch the Terminal UI to monitor Routecraft execution history\")\n .option(\n \"--db <path>\",\n \"Path to the telemetry SQLite database\",\n \".routecraft/telemetry.db\",\n )\n .action(async (options) => {\n const { resolve, isAbsolute } = await import(\"node:path\");\n const dbPath = isAbsolute(options.db)\n ? options.db\n : resolve(process.cwd(), options.db);\n\n const { renderTui } = await import(\"./tui/app.js\");\n await renderTui(dbPath);\n });\n\n// Parse the command line arguments and execute the appropriate command\nprogram.parse();\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/runtime-gate.ts","../src/index.ts"],"names":["MIN_BUN_VERSION","INSTALL_URL","EMBEDDING_DOC_URL","checkBunRuntime","bunVersion","version","stripped","majorStr","minorStr","patchStr","major","minor","patch","formatVersion","v","gate","Command","program","err","filePath","args","options","globalOpts","loadEnvFile","runCommand","result","code","resolve","isAbsolute","dbPath","renderTui"],"mappings":";AAUA,IAAMA,CAAAA,CAAkB,CAAE,KAAA,CAAO,CAAA,CAAG,MAAO,CAAA,CAAG,KAAA,CAAO,CAAE,CAAA,CAEjDC,CAAAA,CAAc,oCACdC,CAAAA,CACJ,8DAAA,CAQK,SAASC,CAAAA,CACdC,CAAAA,CAA4B,QAAQ,QAAA,CAAS,GAAA,EAAU,IAAA,CACpC,CACnB,IAAMC,CAAAA,CAAUD,EAEhB,GAAI,CAACC,EACH,OAAO,CACL,GAAI,KAAA,CACJ,OAAA,CACE,6DACoBJ,CAAW,CAAA,wDAAA,EAC0BC,CAAiB,CAAA,EAAA,CAC9E,CAAA,CAIF,IAAMI,CAAAA,CAAWD,CAAAA,CAAQ,MAAM,MAAM,CAAA,CAAE,CAAC,CAAA,EAAK,EAAA,CACvC,CAACE,EAAUC,CAAAA,CAAUC,CAAQ,EAAIH,CAAAA,CAAS,KAAA,CAAM,GAAG,CAAA,CACnDI,CAAAA,CAAQ,OAAOH,CAAQ,CAAA,CAC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AC9C,GAAI,CAACK,CAAAA,CAAO,QAAS,CACfA,CAAAA,CAAO,OAAA,EAET,OAAA,CAAQ,KAAA,CAAMA,CAAAA,CAAO,OAAO,CAAA,CAG9B,IAAMC,EAAOD,CAAAA,CAAO,IAAA,EAAQ,EAC5B,YAAA,CAAa,IAAM,QAAQ,IAAA,CAAKC,CAAI,CAAC,CAAA,CACrC,MACF,CAIF,CAAC,CAAA,CASHT,EACG,OAAA,CAAQ,KAAK,CAAA,CACb,WAAA,CAAY,gEAAgE,CAAA,CAC5E,OACC,aAAA,CACA,uCAAA,CACA,0BACF,CAAA,CACC,MAAA,CAAO,MAAOI,CAAAA,EAAY,CACzB,GAAM,CAAE,OAAA,CAAAM,EAAS,UAAA,CAAAC,CAAW,EAAI,MAAM,OAAO,MAAW,CAAA,CAClDC,CAAAA,CAASD,CAAAA,CAAWP,CAAAA,CAAQ,EAAE,CAAA,CAChCA,EAAQ,EAAA,CACRM,CAAAA,CAAQ,QAAQ,GAAA,EAAI,CAAGN,EAAQ,EAAE,CAAA,CAE/B,CAAE,SAAA,CAAAS,CAAU,CAAA,CAAI,MAAM,OAAO,cAAc,EACjD,MAAMA,CAAAA,CAAUD,CAAM,EACxB,CAAC,CAAA,CAGHZ,CAAAA,CAAQ,KAAA,EAAM","file":"index.js","sourcesContent":["/**\n * Runtime gate for the craft CLI.\n *\n * The CLI is Bun-only. Users on Node embed @routecraft/routecraft\n * programmatically instead of going through the CLI.\n *\n * Exposed as a pure function so unit tests can pass arbitrary version strings\n * without spawning real bun processes.\n */\n\nconst MIN_BUN_VERSION = { major: 1, minor: 1, patch: 0 } as const;\n\nconst INSTALL_URL = \"https://bun.com/docs/installation\";\nconst EMBEDDING_DOC_URL =\n \"https://routecraft.dev/docs/advanced/programmatic-invocation\";\n\nexport type RuntimeGateResult = { ok: true } | { ok: false; message: string };\n\n// Accept `null` (not `undefined`) to express \"not running on Bun\" so tests can\n// reliably exercise the missing-bun path. JS default-parameter semantics\n// re-apply the default for explicit `undefined`, which would otherwise let\n// `process.versions.bun` leak in when the suite runs under Bun.\nexport function checkBunRuntime(\n bunVersion: string | null = process.versions[\"bun\"] ?? null,\n): RuntimeGateResult {\n const version = bunVersion;\n\n if (!version) {\n return {\n ok: false,\n message:\n `[routecraft] The craft CLI requires Bun. ` +\n `Install Bun from ${INSTALL_URL}, ` +\n `or embed @routecraft/routecraft programmatically (see ${EMBEDDING_DOC_URL}).`,\n };\n }\n\n // Strip both prerelease (`-`) and build metadata (`+`) per SemVer.\n const stripped = version.split(/[-+]/)[0] ?? \"\";\n const [majorStr, minorStr, patchStr] = stripped.split(\".\");\n const major = Number(majorStr);\n const minor = Number(minorStr);\n const patch = Number(patchStr ?? \"0\");\n\n if (\n !Number.isFinite(major) ||\n !Number.isFinite(minor) ||\n !Number.isFinite(patch)\n ) {\n return {\n ok: false,\n message:\n `[routecraft] Could not parse Bun version \"${version}\". ` +\n `Routecraft requires Bun ${formatVersion(MIN_BUN_VERSION)} or later. ` +\n `Upgrade Bun: ${INSTALL_URL}.`,\n };\n }\n\n const meetsFloor =\n major > MIN_BUN_VERSION.major ||\n (major === MIN_BUN_VERSION.major &&\n (minor > MIN_BUN_VERSION.minor ||\n (minor === MIN_BUN_VERSION.minor && patch >= MIN_BUN_VERSION.patch)));\n\n if (!meetsFloor) {\n return {\n ok: false,\n message:\n `[routecraft] Bun ${version} is not supported. ` +\n `Routecraft requires Bun ${formatVersion(MIN_BUN_VERSION)} or later. ` +\n `Upgrade Bun: ${INSTALL_URL}.`,\n };\n }\n\n return { ok: true };\n}\n\nfunction formatVersion(v: typeof MIN_BUN_VERSION): string {\n return `${v.major}.${v.minor}.${v.patch}`;\n}\n","#!/usr/bin/env bun\n\n/**\n * Routecraft CLI: single entry point.\n *\n * The CLI runs on Bun. For Node-based usage, embed @routecraft/routecraft\n * programmatically (see https://routecraft.dev/docs/advanced/programmatic-invocation).\n *\n * 1. Bun runtime gate (presence + version floor)\n * 2. Define program and parse; log options are global and applied before\n * lazy-loading run/util (which load the logger)\n */\n\nimport { checkBunRuntime } from \"./runtime-gate.js\";\n\n// ── 1. Bun runtime gate ─────────────────────────────────────────────\nconst gate = checkBunRuntime();\nif (!gate.ok) {\n // eslint-disable-next-line no-console\n console.error(gate.message);\n process.exit(1);\n}\n\n// ── 2. CLI definition (only Commander; run/util are lazy-loaded so logger sees env) ─\nconst { Command } = await import(\"commander\");\nconst program = new Command();\n\nprogram\n .name(\"craft\")\n .description(\"A modern routing framework for TypeScript\")\n .version(\"0.5.0-canary.63\")\n .enablePositionalOptions()\n .option(\n \"--log-level <level>\",\n \"Log level (e.g. info, warn, error, silent to disable)\",\n )\n .option(\"--log-file <path>\", \"Write logs to a file instead of stdout\")\n .showSuggestionAfterError()\n .showHelpAfterError()\n .exitOverride((err) => {\n if (err.code === \"commander.unknownCommand\") {\n process.exit(0);\n }\n });\n\n// Show help by default if no arguments provided\nif (process.argv.length <= 2) {\n program.help({ error: false });\n}\n\n/**\n * The 'run' command executes routes from a single file.\n *\n * Example:\n * craft run ./my-routes.ts\n * craft run ./my-cli.ts greet --name World\n */\nprogram\n .command(\"run\")\n .description(\"Run routes from a single TypeScript/JavaScript file\")\n .argument(\"<file>\", \"Path to a file containing routes\")\n .argument(\n \"[args...]\",\n \"CLI command and flags to pass through to CLI adapter routes\",\n )\n .option(\n \"--env <path>\",\n \"Load environment variables from a .env file (default: .env)\",\n )\n .passThroughOptions()\n .action(async (filePath, args: string[], options) => {\n // Apply global log options to env before any import that creates the logger\n const globalOpts = program.opts();\n if (globalOpts[\"logLevel\"] !== undefined) {\n process.env[\"LOG_LEVEL\"] = globalOpts[\"logLevel\"];\n process.env[\"CRAFT_LOG_LEVEL\"] = globalOpts[\"logLevel\"];\n }\n if (globalOpts[\"logFile\"] !== undefined) {\n process.env[\"LOG_FILE\"] = globalOpts[\"logFile\"];\n process.env[\"CRAFT_LOG_FILE\"] = globalOpts[\"logFile\"];\n }\n\n const { loadEnvFile } = await import(\"./util.js\");\n if (options.env !== undefined) {\n loadEnvFile(options.env);\n } else {\n loadEnvFile();\n }\n\n const { runCommand } = await import(\"./run.js\");\n const result = await runCommand(filePath, args);\n if (!result.success) {\n if (result.message) {\n // eslint-disable-next-line no-console\n console.error(result.message);\n }\n // Defer exit so pino/sonic-boom can finish initializing and avoid \"sonic boom is not ready yet\"\n const code = result.code ?? 1;\n setImmediate(() => process.exit(code));\n return;\n }\n // Don't call process.exit(); let the event loop drain naturally.\n // process.exit() triggers C++ static destructors that race with ONNX\n // Runtime cleanup (onnxruntime#25038: \"mutex lock failed\").\n });\n\n/**\n * The 'tui' command launches the Terminal UI for monitoring Routecraft execution.\n *\n * Example:\n * craft tui\n * craft tui --db .routecraft/telemetry.db\n */\nprogram\n .command(\"tui\")\n .description(\"Launch the Terminal UI to monitor Routecraft execution history\")\n .option(\n \"--db <path>\",\n \"Path to the telemetry SQLite database\",\n \".routecraft/telemetry.db\",\n )\n .action(async (options) => {\n const { resolve, isAbsolute } = await import(\"node:path\");\n const dbPath = isAbsolute(options.db)\n ? options.db\n : resolve(process.cwd(), options.db);\n\n const { renderTui } = await import(\"./tui/app.js\");\n await renderTui(dbPath);\n });\n\n// Parse the command line arguments and execute the appropriate command\nprogram.parse();\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@routecraft/cli",
|
|
3
|
-
"version": "0.5.0-canary.
|
|
3
|
+
"version": "0.5.0-canary.63",
|
|
4
4
|
"description": "CLI for running Routecraft routes",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@opentelemetry/sdk-trace-base": "^2.7.1",
|
|
26
|
-
"@routecraft/routecraft": "^0.5.0-canary.
|
|
26
|
+
"@routecraft/routecraft": "^0.5.0-canary.63",
|
|
27
27
|
"agent-browser": "^0.17.1",
|
|
28
28
|
"cheerio": "^1.2.0",
|
|
29
29
|
"commander": "^14.0.3",
|