@vendian/cli 0.0.41 → 0.0.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29,7 +29,7 @@ function renderSettings() {
29
29
  summary.innerHTML = `<div class="cs-item"><span class="cs-dot green"></span>Connected to <strong style="margin-left:4px">${capitalize(activeBackend.key)}</strong></div>
30
30
  ${activeBackend.email ? `<div class="cs-item" style="color:var(--text-dim);font-size:11.5px;margin-left:auto">${esc(activeBackend.email)}</div>` : ''}`;
31
31
  } else {
32
- summary.innerHTML = `<div class="cs-item"><span class="cs-dot red"></span>Not connected — run <code style="font-family:var(--mono);background:var(--bg-elevated);padding:2px 6px;border-radius:3px;font-size:11px">vendian login</code></div>`;
32
+ summary.innerHTML = `<div class="cs-item"><span class="cs-dot red"></span>Not connected — choose an endpoint below to sign in</div>`;
33
33
  }
34
34
 
35
35
  // Backend list
@@ -57,7 +57,7 @@ function renderSettings() {
57
57
 
58
58
  // Wire buttons
59
59
  list.querySelectorAll('[data-login]').forEach(btn => {
60
- btn.addEventListener('click', (e) => { e.stopPropagation(); promptLogin(btn.dataset.login); });
60
+ btn.addEventListener('click', (e) => { e.stopPropagation(); startLogin(btn.dataset.login); });
61
61
  });
62
62
  list.querySelectorAll('[data-switch]').forEach(btn => {
63
63
  btn.addEventListener('click', (e) => { e.stopPropagation(); switchBackend(btn.dataset.switch); });
@@ -67,13 +67,37 @@ function renderSettings() {
67
67
  const key = card.dataset.backend;
68
68
  const b = backends.find(x => x.key === key);
69
69
  if (b && b.authenticated && !b.active) switchBackend(key);
70
- else if (b && !b.authenticated) promptLogin(key);
70
+ else if (b && !b.authenticated) startLogin(key);
71
71
  });
72
72
  });
73
73
  }
74
74
 
75
- function promptLogin(key) {
76
- alert(`To sign in to ${capitalize(key)}, run:\n\n vendian login --backend ${key}\n\nThen refresh this page.`);
75
+ async function startLogin(key) {
76
+ const backend = capitalize(key);
77
+ const list = document.getElementById('backends-list');
78
+ const card = list?.querySelector(`[data-backend="${key}"]`);
79
+ const button = card?.querySelector('[data-login]');
80
+ const originalText = button?.textContent || '';
81
+
82
+ try {
83
+ if (button) {
84
+ button.disabled = true;
85
+ button.textContent = 'Signing in...';
86
+ }
87
+ const d = await api('/auth/login', { method: 'POST', body: JSON.stringify({ backend: key }) });
88
+ if (!d.ok) {
89
+ throw new Error(d.error || `Sign-in failed for ${backend}`);
90
+ }
91
+ await loadAuth();
92
+ window.dispatchEvent(new Event('auth-changed'));
93
+ } catch (error) {
94
+ alert(error && error.message ? error.message : `Sign-in failed for ${backend}`);
95
+ } finally {
96
+ if (button) {
97
+ button.disabled = false;
98
+ button.textContent = originalText || 'Sign in →';
99
+ }
100
+ }
77
101
  }
78
102
 
79
103
  async function switchBackend(key) {
@@ -82,6 +106,6 @@ async function switchBackend(key) {
82
106
  await loadAuth();
83
107
  window.dispatchEvent(new Event('auth-changed'));
84
108
  }
85
- else if (d.needsLogin) promptLogin(key);
109
+ else if (d.needsLogin) startLogin(key);
86
110
  else alert(d.error || 'Switch failed');
87
111
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vendian/cli",
3
- "version": "0.0.41",
3
+ "version": "0.0.42",
4
4
  "description": "Public Vendian CLI bootstrapper and launcher",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,