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

Function resolveLoginOrigin

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

Source from the content-addressed store, hash-verified

2364// nothing is configured yet. The profile name is decided later, from the
2365// authenticated account.
2366const resolveLoginOrigin = (input: {
2367 readonly baseUrl: Option.Option<string>;
2368 readonly server: Option.Option<string>;
2369}): Effect.Effect<
2370 { readonly origin: string; readonly profile: ReturnType<typeof findCliServerConnectionProfile> },
2371 Error,
2372 FileSystem.FileSystem | PlatformPath.Path
2373> =>
2374 Effect.gen(function* () {
2375 const baseUrl = Option.getOrUndefined(input.baseUrl);
2376 const serverName = Option.getOrUndefined(input.server);
2377 if (baseUrl && serverName) {
2378 return yield* Effect.fail(new Error("Use either --server or --base-url, not both."));
2379 }
2380 if (serverName) {
2381 const store = yield* readCliServerConnectionStore();
2382 const profile = findCliServerConnectionProfile(store, serverName);
2383 if (!profile)
2384 return yield* Effect.fail(new Error(`No server profile named "${serverName}".`));
2385 return { origin: profile.connection.origin, profile };
2386 }
2387 if (baseUrl) {
2388 return { origin: normalizeExecutorServerOrigin(baseUrl), profile: null };
2389 }
2390 const store = yield* readCliServerConnectionStore();
2391 const profile = defaultCliServerConnectionProfile(store);
2392 if (profile) return { origin: profile.connection.origin, profile };
2393 return { origin: DEFAULT_LOGIN_ORIGIN, profile: null };
2394 });
2395
2396const loginNameOption = Options.string("name").pipe(
2397 Options.optional,

Callers 1

main.tsFile · 0.85

Tested by

no test coverage detected