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

Function resolveLoginOrigin

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

Source from the content-addressed store, hash-verified

2467// nothing is configured yet. The profile name is decided later, from the
2468// authenticated account.
2469const resolveLoginOrigin = (input: {
2470 readonly baseUrl: Option.Option<string>;
2471 readonly server: Option.Option<string>;
2472}): Effect.Effect<
2473 { readonly origin: string; readonly profile: ReturnType<typeof findCliServerConnectionProfile> },
2474 Error,
2475 FileSystem.FileSystem | PlatformPath.Path
2476> =>
2477 Effect.gen(function* () {
2478 const baseUrl = Option.getOrUndefined(input.baseUrl);
2479 const serverName = Option.getOrUndefined(input.server);
2480 if (baseUrl && serverName) {
2481 return yield* Effect.fail(new Error("Use either --server or --base-url, not both."));
2482 }
2483 if (serverName) {
2484 const store = yield* readCliServerConnectionStore();
2485 const profile = findCliServerConnectionProfile(store, serverName);
2486 if (!profile)
2487 return yield* Effect.fail(new Error(`No server profile named "${serverName}".`));
2488 return { origin: profile.connection.origin, profile };
2489 }
2490 if (baseUrl) {
2491 return { origin: normalizeExecutorServerOrigin(baseUrl), profile: null };
2492 }
2493 const store = yield* readCliServerConnectionStore();
2494 const profile = defaultCliServerConnectionProfile(store);
2495 if (profile) return { origin: profile.connection.origin, profile };
2496 return { origin: DEFAULT_LOGIN_ORIGIN, profile: null };
2497 });
2498
2499const loginNameOption = Options.string("name").pipe(
2500 Options.optional,

Callers 1

main.tsFile · 0.85

Tested by

no test coverage detected