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