( target: ServerTarget, )
| 705 | }).pipe(Effect.mapError(toError)); |
| 706 | |
| 707 | const resolveRequestedExecutorServerConnection = ( |
| 708 | target: ServerTarget, |
| 709 | ): Effect.Effect< |
| 710 | RequestedExecutorServerConnection, |
| 711 | Error, |
| 712 | FileSystem.FileSystem | PlatformPath.Path |
| 713 | > => |
| 714 | Effect.gen(function* () { |
| 715 | if (target.baseUrl && target.serverName) { |
| 716 | return yield* Effect.fail(new Error("Use either --server or --base-url, not both.")); |
| 717 | } |
| 718 | |
| 719 | if (target.serverName) { |
| 720 | const store = yield* readCliServerConnectionStore(); |
| 721 | const profile = findCliServerConnectionProfile(store, target.serverName); |
| 722 | if (!profile) { |
| 723 | return yield* Effect.fail(new Error(`No server profile named "${target.serverName}".`)); |
| 724 | } |
| 725 | return { connection: withCliServerAuthFallback(profile.connection), source: "explicit" }; |
| 726 | } |
| 727 | |
| 728 | if (!target.baseUrl) { |
| 729 | const store = yield* readCliServerConnectionStore(); |
| 730 | const profile = defaultCliServerConnectionProfile(store); |
| 731 | if (profile) { |
| 732 | return { |
| 733 | connection: withCliServerAuthFallback(profile.connection), |
| 734 | source: "default-profile", |
| 735 | }; |
| 736 | } |
| 737 | |
| 738 | const active = yield* readActiveLocalServerManifest(); |
| 739 | if (active) return { connection: active.connection, source: "active-local" }; |
| 740 | } |
| 741 | |
| 742 | return { |
| 743 | connection: yield* parseExecutorServerConnection(target.baseUrl ?? DEFAULT_BASE_URL), |
| 744 | source: target.baseUrl ? "explicit" : "implicit-default", |
| 745 | }; |
| 746 | }); |
| 747 | |
| 748 | // Refresh an `oauth` (device-login) credential a minute before it expires, so |
| 749 | // `executor call` against a hosted server keeps working long after the browser |
no test coverage detected