MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / resolveLoginOrigin

Function resolveLoginOrigin

apps/cli/src/main.ts:2446–2474  ·  view source on GitHub ↗
(input: {
  readonly baseUrl: Option.Option<string>;
  readonly server: Option.Option<string>;
})

Source from the content-addressed store, hash-verified

2444// nothing is configured yet. The profile name is decided later, from the
2445// authenticated account.
2446const resolveLoginOrigin = (input: {
2447 readonly baseUrl: Option.Option<string>;
2448 readonly server: Option.Option<string>;
2449}): Effect.Effect<
2450 { readonly origin: string; readonly profile: ReturnType<typeof findCliServerConnectionProfile> },
2451 Error,
2452 FileSystem.FileSystem | PlatformPath.Path
2453> =>
2454 Effect.gen(function* () {
2455 const baseUrl = Option.getOrUndefined(input.baseUrl);
2456 const serverName = Option.getOrUndefined(input.server);
2457 if (baseUrl && serverName) {
2458 return yield* Effect.fail(new Error("Use either --server or --base-url, not both."));
2459 }
2460 if (serverName) {
2461 const store = yield* readCliServerConnectionStore();
2462 const profile = findCliServerConnectionProfile(store, serverName);
2463 if (!profile)
2464 return yield* Effect.fail(new Error(`No server profile named "${serverName}".`));
2465 return { origin: profile.connection.origin, profile };
2466 }
2467 if (baseUrl) {
2468 return { origin: normalizeExecutorServerOrigin(baseUrl), profile: null };
2469 }
2470 const store = yield* readCliServerConnectionStore();
2471 const profile = defaultCliServerConnectionProfile(store);
2472 if (profile) return { origin: profile.connection.origin, profile };
2473 return { origin: DEFAULT_LOGIN_ORIGIN, profile: null };
2474 });
2475
2476const loginNameOption = Options.string("name").pipe(
2477 Options.optional,

Callers 1

main.tsFile · 0.85

Tested by

no test coverage detected