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

Function resolveLoginOrigin

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

Source from the content-addressed store, hash-verified

2386// nothing is configured yet. The profile name is decided later, from the
2387// authenticated account.
2388const resolveLoginOrigin = (input: {
2389 readonly baseUrl: Option.Option<string>;
2390 readonly server: Option.Option<string>;
2391}): Effect.Effect<
2392 { readonly origin: string; readonly profile: ReturnType<typeof findCliServerConnectionProfile> },
2393 Error,
2394 FileSystem.FileSystem | PlatformPath.Path
2395> =>
2396 Effect.gen(function* () {
2397 const baseUrl = Option.getOrUndefined(input.baseUrl);
2398 const serverName = Option.getOrUndefined(input.server);
2399 if (baseUrl && serverName) {
2400 return yield* Effect.fail(new Error("Use either --server or --base-url, not both."));
2401 }
2402 if (serverName) {
2403 const store = yield* readCliServerConnectionStore();
2404 const profile = findCliServerConnectionProfile(store, serverName);
2405 if (!profile)
2406 return yield* Effect.fail(new Error(`No server profile named "${serverName}".`));
2407 return { origin: profile.connection.origin, profile };
2408 }
2409 if (baseUrl) {
2410 return { origin: normalizeExecutorServerOrigin(baseUrl), profile: null };
2411 }
2412 const store = yield* readCliServerConnectionStore();
2413 const profile = defaultCliServerConnectionProfile(store);
2414 if (profile) return { origin: profile.connection.origin, profile };
2415 return { origin: DEFAULT_LOGIN_ORIGIN, profile: null };
2416 });
2417
2418const loginNameOption = Options.string("name").pipe(
2419 Options.optional,

Callers 1

main.tsFile · 0.85

Tested by

no test coverage detected