Skip to content

Commit 50c131b

Browse files
chore(cli): print pretty message during exception handling (#56)
* chore(cli): print pretty message during exception handling * chore: add empty changeset * chore: fix lockfile
1 parent 34db450 commit 50c131b

4 files changed

Lines changed: 31 additions & 18 deletions

File tree

.changeset/stupid-rings-relax.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

packages/cli/src/auth.ts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import express from 'express';
44
import cors from 'cors';
55
import open from 'open';
66
import readline from 'readline/promises';
7-
import { loadSettings, saveSettings } from "./services/settings.js";
7+
import { loadSettings } from "./services/settings.js";
88
import { getEnv } from "./services/env.js";
99
import { checkAuth } from "./services/check-auth.js";
1010
import { saveApiKey } from "./services/api-key.js";
@@ -16,18 +16,23 @@ export default new Command()
1616
.option("--logout", "Delete existing authentication")
1717
.option("--login", "Authenticate with Replexica API")
1818
.action(async (options) => {
19-
const env = getEnv();
20-
let config = await loadSettings();
21-
22-
if (options.logout) {
23-
await logout();
24-
}
25-
if (options.login) {
26-
await login(env.REPLEXICA_WEB_URL);
27-
config = await loadSettings();
19+
try {
20+
const env = getEnv();
21+
let config = await loadSettings();
22+
23+
if (options.logout) {
24+
await logout();
25+
}
26+
if (options.login) {
27+
await login(env.REPLEXICA_WEB_URL);
28+
config = await loadSettings();
29+
}
30+
31+
await checkAuth();
32+
} catch (error: any) {
33+
Ora().fail(error.message);
34+
process.exit(1);
2835
}
29-
30-
await checkAuth();
3136
});
3237

3338
async function logout() {

packages/cli/src/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
import dotenv from 'dotenv';
21
import { Command } from 'commander';
32

43
import i18nCmd from './i18n.js';
54
import authCmd from './auth.js';
65
import localizeCmd from './localize/index.js';
76

8-
dotenv.config();
9-
107
export default new Command()
118
.name('replexica')
129
.description('Replexica CLI')

pnpm-lock.yaml

Lines changed: 12 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)