| 628 | } |
| 629 | |
| 630 | async function loadConfig(args) { |
| 631 | const configPath = args["config"] || defaultConfigPath; |
| 632 | let config = {}; |
| 633 | try { |
| 634 | config = JSON.parse(await fs.promises.readFile(configPath, "utf8")); |
| 635 | } catch { |
| 636 | config = {}; |
| 637 | } |
| 638 | config.studioUrl = (args["studio-url"] || config.studioUrl || "").replace( |
| 639 | /\/$/, |
| 640 | "", |
| 641 | ); |
| 642 | config.hostId = args["host-id"] || config.hostId || ""; |
| 643 | config.hostToken = args["host-token"] || config.hostToken || ""; |
| 644 | if (!config.studioUrl || !config.hostId || !config.hostToken) { |
| 645 | throw new Error( |
| 646 | "Missing provider config. Run `simdeck provider connect --studio-url ... --host-id ... --host-token ...` first.", |
| 647 | ); |
| 648 | } |
| 649 | return config; |
| 650 | } |
| 651 | |
| 652 | function simdeckBinary() { |
| 653 | if (process.env.SIMDECK_BINARY) { |