(argv: string[])
| 17 | import { runSetup as runPiSetup } from "./setup-pi"; |
| 18 | |
| 19 | export async function runSetup(argv: string[]): Promise<number> { |
| 20 | const dryRun = argv.includes("--dry-run"); |
| 21 | intro(dryRun ? "Magic Context setup (dry run)" : "Magic Context setup"); |
| 22 | |
| 23 | const adapters = await resolveAdaptersForCommand(argv, { |
| 24 | allowMulti: true, |
| 25 | verb: "setup", |
| 26 | }); |
| 27 | |
| 28 | if (adapters.length === 0) { |
| 29 | outro("No harness selected. Nothing to do."); |
| 30 | return 0; |
| 31 | } |
| 32 | |
| 33 | let anyFailure = false; |
| 34 | for (const adapter of adapters) { |
| 35 | log.step(`Configuring ${adapter.displayName} (${adapter.pluginPackageName})…`); |
| 36 | |
| 37 | if (!adapter.isInstalled()) { |
| 38 | log.warn(`${adapter.displayName} host not found on PATH. ${adapter.getInstallHint()}.`); |
| 39 | anyFailure = true; |
| 40 | continue; |
| 41 | } |
| 42 | |
| 43 | const code = await dispatchSetup(adapter, dryRun); |
| 44 | if (code !== 0) anyFailure = true; |
| 45 | if (!dryRun) printNextSteps(adapter); |
| 46 | } |
| 47 | |
| 48 | if (anyFailure) { |
| 49 | outro("Setup finished with warnings — see above."); |
| 50 | return 1; |
| 51 | } |
| 52 | outro(dryRun ? "Dry run done — no changes were made." : "Done."); |
| 53 | return 0; |
| 54 | } |
| 55 | |
| 56 | async function dispatchSetup(adapter: HarnessAdapter, dryRun: boolean): Promise<number> { |
| 57 | switch (adapter.kind) { |
no test coverage detected