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

Function resolveLoginOrigin

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

Source from the content-addressed store, hash-verified

2304// or the default) or a bare origin (--base-url). The profile name is decided
2305// later, from the authenticated account.
2306const resolveLoginOrigin = (input: {
2307 readonly baseUrl: Option.Option<string>;
2308 readonly server: Option.Option<string>;
2309}): Effect.Effect<
2310 { readonly origin: string; readonly profile: ReturnType<typeof findCliServerConnectionProfile> },
2311 Error,
2312 FileSystem.FileSystem | PlatformPath.Path
2313> =>
2314 Effect.gen(function* () {
2315 const baseUrl = Option.getOrUndefined(input.baseUrl);
2316 const serverName = Option.getOrUndefined(input.server);
2317 if (baseUrl && serverName) {
2318 return yield* Effect.fail(new Error("Use either --server or --base-url, not both."));
2319 }
2320 if (serverName) {
2321 const store = yield* readCliServerConnectionStore();
2322 const profile = findCliServerConnectionProfile(store, serverName);
2323 if (!profile)
2324 return yield* Effect.fail(new Error(`No server profile named "${serverName}".`));
2325 return { origin: profile.connection.origin, profile };
2326 }
2327 if (baseUrl) {
2328 return { origin: normalizeExecutorServerOrigin(baseUrl), profile: null };
2329 }
2330 const store = yield* readCliServerConnectionStore();
2331 const profile = defaultCliServerConnectionProfile(store);
2332 if (profile) return { origin: profile.connection.origin, profile };
2333 return yield* Effect.fail(
2334 new Error(
2335 "No server to log in to. Pass --base-url <https://your-host> or --server <profile>.",
2336 ),
2337 );
2338 });
2339
2340const loginNameOption = Options.string("name").pipe(
2341 Options.optional,

Callers 1

main.tsFile · 0.85

Tested by

no test coverage detected