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

Function resolveLoginOrigin

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

Source from the content-addressed store, hash-verified

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

Callers 1

main.tsFile · 0.85

Tested by

no test coverage detected