|
| 1 | +#!/usr/bin/env node |
| 2 | + |
| 3 | +const { execSync } = require("child_process"); |
| 4 | +const path = require("path"); |
| 5 | +const concurrently = require("concurrently"); |
| 6 | + |
| 7 | +// Parse command line arguments |
| 8 | +const args = process.argv.slice(2); |
| 9 | +const showHelp = args.includes("--help") || args.includes("-h"); |
| 10 | +const dryRun = args.includes("--dry-run"); |
| 11 | + |
| 12 | +if (showHelp) { |
| 13 | + console.log(` |
| 14 | +Usage: node run-dojo-everything.js [options] |
| 15 | +
|
| 16 | +Options: |
| 17 | + --dry-run Show what would be started without actually running |
| 18 | + --help, -h Show this help message |
| 19 | +
|
| 20 | +Examples: |
| 21 | + node run-dojo.js |
| 22 | + node run-dojo.js --dry-run |
| 23 | +`); |
| 24 | + process.exit(0); |
| 25 | +} |
| 26 | + |
| 27 | +const gitRoot = execSync("git rev-parse --show-toplevel", { encoding: "utf-8" }).trim(); |
| 28 | + |
| 29 | +// THE ACTUAL DOJO |
| 30 | +const dojo = { |
| 31 | + command: "pnpm run start", |
| 32 | + name: "Dojo", |
| 33 | + cwd: path.join(gitRoot, "typescript-sdk/apps/dojo"), |
| 34 | + env: { |
| 35 | + PORT: 9000, |
| 36 | + NEXT_PUBLIC_COPILOTKIT_RUNTIME_URL: process.env.NEXT_PUBLIC_COPILOTKIT_RUNTIME_URL, |
| 37 | + NEXT_PUBLIC_AGNO_COPILOT_API_KEY: process.env.NEXT_PUBLIC_AGNO_COPILOT_API_KEY, |
| 38 | + NEXT_PUBLIC_CREWAI_COPILOT_API_KEY: process.env.NEXT_PUBLIC_CREWAI_COPILOT_API_KEY, |
| 39 | + NEXT_PUBLIC_LANGGRAPH_COPILOT_API_KEY: process.env.NEXT_PUBLIC_LANGGRAPH_COPILOT_API_KEY, |
| 40 | + NEXT_PUBLIC_LANGGRAPH_FASTAPI_COPILOT_API_KEY: |
| 41 | + process.env.NEXT_PUBLIC_LANGGRAPH_FASTAPI_COPILOT_API_KEY, |
| 42 | + NEXT_PUBLIC_LANGGRAPH_TYPESCRIPT_COPILOT_API_KEY: |
| 43 | + process.env.NEXT_PUBLIC_LANGGRAPH_TYPESCRIPT_COPILOT_API_KEY, |
| 44 | + NEXT_PUBLIC_LLAMA_INDEX_COPILOT_API_KEY: process.env.NEXT_PUBLIC_LLAMA_INDEX_COPILOT_API_KEY, |
| 45 | + NEXT_PUBLIC_MASTRA_COPILOT_API_KEY: process.env.NEXT_PUBLIC_MASTRA_COPILOT_API_KEY, |
| 46 | + NEXT_PUBLIC_PYDANTIC_AI_COPILOT_API_KEY: process.env.NEXT_PUBLIC_PYDANTIC_AI_COPILOT_API_KEY, |
| 47 | + }, |
| 48 | +}; |
| 49 | + |
| 50 | +const procs = [dojo]; |
| 51 | + |
| 52 | +function printDryRunServices(procs) { |
| 53 | + console.log("Dry run - would start the following services:"); |
| 54 | + procs.forEach((proc) => { |
| 55 | + console.log(` - ${proc.name} (${proc.cwd})`); |
| 56 | + console.log(` Command: ${proc.command}`); |
| 57 | + console.log(` Environment variables:`); |
| 58 | + if (proc.env) { |
| 59 | + Object.entries(proc.env).forEach(([key, value]) => { |
| 60 | + console.log(` ${key}: ${value}`); |
| 61 | + }); |
| 62 | + } else { |
| 63 | + console.log(" No environment variables specified."); |
| 64 | + } |
| 65 | + console.log(""); |
| 66 | + }); |
| 67 | + process.exit(0); |
| 68 | +} |
| 69 | + |
| 70 | +async function main() { |
| 71 | + if (dryRun) { |
| 72 | + printDryRunServices(procs); |
| 73 | + } |
| 74 | + |
| 75 | + console.log("Starting services: ", procs.map((p) => p.name).join(", ")); |
| 76 | + |
| 77 | + const { result } = concurrently(procs, { killOthersOn: ["failure", "success"] }); |
| 78 | + |
| 79 | + result |
| 80 | + .then(() => process.exit(0)) |
| 81 | + .catch((err) => { |
| 82 | + console.error(err); |
| 83 | + process.exit(1); |
| 84 | + }); |
| 85 | +} |
| 86 | + |
| 87 | +main(); |
0 commit comments