MCPcopy Create free account
hub / github.com/TestSprite/testsprite-cli / runLogout

Function runLogout

src/commands/auth.ts:244–268  ·  view source on GitHub ↗
(opts: CommonOptions, deps: AuthDeps = {})

Source from the content-addressed store, hash-verified

242}
243
244export async function runLogout(opts: CommonOptions, deps: AuthDeps = {}): Promise<void> {
245 const credentialsPath = deps.credentialsPath ?? defaultCredentialsPath();
246 const out = makeOutput(opts.output, deps);
247 const stderr = deps.stderr ?? ((line: string) => process.stderr.write(`${line}\n`));
248
249 if (opts.dryRun) {
250 emitDryRunBanner(stderr);
251 stderr(
252 `[dry-run] would remove credentials for profile="${opts.profile}" from ${credentialsPath}`,
253 );
254 out.print({ profile: opts.profile, status: 'logged_out' }, data => {
255 const d = data as { profile: string; status: string };
256 return `Removed credentials for profile "${d.profile}" (dry-run).`;
257 });
258 return;
259 }
260
261 const removed = deleteProfile(opts.profile, { path: credentialsPath });
262 out.print({ profile: opts.profile, status: removed ? 'logged_out' : 'no_credentials' }, data => {
263 const d = data as { profile: string; status: string };
264 return d.status === 'logged_out'
265 ? `Removed credentials for profile "${d.profile}".`
266 : `No credentials stored for profile "${d.profile}".`;
267 });
268}
269
270export function createAuthCommand(deps: AuthDeps = {}): Command {
271 const auth = new Command('auth').description('Manage TestSprite credentials');

Callers 2

createAuthCommandFunction · 0.85
auth.test.tsFile · 0.85

Calls 6

defaultCredentialsPathFunction · 0.85
emitDryRunBannerFunction · 0.85
stderrFunction · 0.85
deleteProfileFunction · 0.85
printMethod · 0.80
makeOutputFunction · 0.70

Tested by

no test coverage detected