vibefast-cli 0.2.0 → 0.2.2

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.
@@ -32,7 +32,32 @@ export const devicesCommand = new Command('devices')
32
32
  log.plain(` • ${device.id} (${device.os}/${device.arch}) - ${device.lastSeen}`);
33
33
  });
34
34
  } catch (error: any) {
35
- log.error(`Failed: ${error.message}`);
35
+ const errorMsg = error.message || '';
36
+
37
+ log.plain('');
38
+
39
+ // Better error messages - http.ts already provides clean messages
40
+ if (errorMsg.includes('license_key not found') || errorMsg.includes('Invalid') || errorMsg.includes('token')) {
41
+ log.plain('❌ Invalid or expired license key');
42
+ log.plain('');
43
+ log.info('To fix this:');
44
+ log.plain(' 1. Run: vf logout');
45
+ log.plain(' 2. Run: vf login --token YOUR_LICENSE_KEY');
46
+ log.plain('');
47
+ log.info('Need help? Contact support@vibefast.pro');
48
+ } else if (errorMsg.includes('Network') || errorMsg.includes('connect') || errorMsg.includes('fetch')) {
49
+ log.plain('❌ Network error');
50
+ log.plain('');
51
+ log.info('Could not connect to VibeFast servers');
52
+ log.plain('');
53
+ log.plain(`Details: ${errorMsg}`);
54
+ } else {
55
+ log.plain(`❌ ${errorMsg}`);
56
+ log.plain('');
57
+ log.info('If this problem persists, contact support@vibefast.pro');
58
+ }
59
+
60
+ log.plain('');
36
61
  process.exit(1);
37
62
  }
38
63
  });
@@ -39,7 +39,43 @@ export const listCommand = new Command('list')
39
39
 
40
40
  log.plain('\nInstall with: vf add <feature-name>');
41
41
  } catch (error: any) {
42
- log.error(`Failed to list recipes: ${error.message}`);
42
+ const errorMsg = error.message || '';
43
+
44
+ log.plain('');
45
+
46
+ // Better error messages - http.ts already provides clean messages
47
+ if (errorMsg.includes('license_key not found') || errorMsg.includes('Invalid') || errorMsg.includes('token')) {
48
+ log.plain('❌ Invalid or expired license key');
49
+ log.plain('');
50
+ log.info('Your license key may be:');
51
+ log.plain(' • Incorrect or mistyped');
52
+ log.plain(' • Expired');
53
+ log.plain(' • Not yet activated');
54
+ log.plain('');
55
+ log.info('To fix this:');
56
+ log.plain(' 1. Check your license key from your purchase receipt');
57
+ log.plain(' 2. Run: vf logout');
58
+ log.plain(' 3. Run: vf login --token YOUR_LICENSE_KEY');
59
+ log.plain('');
60
+ log.info('Need help? Contact support@vibefast.pro');
61
+ } else if (errorMsg.includes('Network') || errorMsg.includes('connect') || errorMsg.includes('fetch')) {
62
+ log.plain('❌ Network error');
63
+ log.plain('');
64
+ log.info('Could not connect to VibeFast servers');
65
+ log.plain('');
66
+ log.info('Please check:');
67
+ log.plain(' • Your internet connection');
68
+ log.plain(' • Firewall settings');
69
+ log.plain(' • VPN configuration');
70
+ log.plain('');
71
+ log.plain(`Details: ${errorMsg}`);
72
+ } else {
73
+ log.plain(`❌ ${errorMsg}`);
74
+ log.plain('');
75
+ log.info('If this problem persists, contact support@vibefast.pro');
76
+ }
77
+
78
+ log.plain('');
43
79
  process.exit(1);
44
80
  }
45
81
  });
package/src/core/http.ts CHANGED
@@ -103,55 +103,81 @@ export async function listRecipes(token: string): Promise<any> {
103
103
  } catch {
104
104
  // ignore JSON parse errors
105
105
  }
106
- throw new Error(`Failed to fetch recipes: ${message}`);
106
+ // Just throw the actual error message, no wrapping
107
+ throw new Error(message);
107
108
  }
108
109
 
109
110
  return response.json();
110
111
  } catch (err: any) {
111
- throw new Error(`Failed to connect to ${WORKER_URL}: ${err.message}`);
112
+ // If it's already our error, just rethrow
113
+ if (err.message && !err.message.includes('fetch')) {
114
+ throw err;
115
+ }
116
+ // Network error
117
+ throw new Error(`Network error: ${err.message}`);
112
118
  }
113
119
  }
114
120
 
115
121
  export async function listDevices(token: string): Promise<any> {
116
- const response = await fetch(`${WORKER_URL}/api/devices/list`, {
117
- method: 'GET',
118
- headers: {
119
- 'Authorization': `Bearer ${token}`,
120
- },
121
- });
122
-
123
- if (!response.ok) {
124
- let message = response.statusText;
125
- try {
126
- const body = (await response.json()) as { error?: string; message?: string };
127
- message = body?.error || body?.message || message;
128
- } catch {
129
- // ignore
122
+ try {
123
+ const response = await fetch(`${WORKER_URL}/api/devices/list`, {
124
+ method: 'GET',
125
+ headers: {
126
+ 'Authorization': `Bearer ${token}`,
127
+ },
128
+ });
129
+
130
+ if (!response.ok) {
131
+ let message = response.statusText;
132
+ try {
133
+ const body = (await response.json()) as { error?: string; message?: string };
134
+ message = body?.error || body?.message || message;
135
+ } catch {
136
+ // ignore
137
+ }
138
+ // Just throw the actual error message
139
+ throw new Error(message);
130
140
  }
131
- throw new Error(`Failed to fetch devices: ${message}`);
132
- }
133
141
 
134
- return response.json();
142
+ return response.json();
143
+ } catch (err: any) {
144
+ // If it's already our error, just rethrow
145
+ if (err.message && !err.message.includes('fetch')) {
146
+ throw err;
147
+ }
148
+ // Network error
149
+ throw new Error(`Network error: ${err.message}`);
150
+ }
135
151
  }
136
152
 
137
153
  export async function deactivateDevice(token: string, deviceId: string): Promise<void> {
138
- const response = await fetch(`${WORKER_URL}/api/devices/deactivate`, {
139
- method: 'POST',
140
- headers: {
141
- 'Authorization': `Bearer ${token}`,
142
- 'Content-Type': 'application/json',
143
- },
144
- body: JSON.stringify({ deviceId }),
145
- });
146
-
147
- if (!response.ok) {
148
- let message = response.statusText;
149
- try {
150
- const body = (await response.json()) as { error?: string; message?: string };
151
- message = body?.error || body?.message || message;
152
- } catch {
153
- // ignore
154
+ try {
155
+ const response = await fetch(`${WORKER_URL}/api/devices/deactivate`, {
156
+ method: 'POST',
157
+ headers: {
158
+ 'Authorization': `Bearer ${token}`,
159
+ 'Content-Type': 'application/json',
160
+ },
161
+ body: JSON.stringify({ deviceId }),
162
+ });
163
+
164
+ if (!response.ok) {
165
+ let message = response.statusText;
166
+ try {
167
+ const body = (await response.json()) as { error?: string; message?: string };
168
+ message = body?.error || body?.message || message;
169
+ } catch {
170
+ // ignore
171
+ }
172
+ // Just throw the actual error message
173
+ throw new Error(message);
174
+ }
175
+ } catch (err: any) {
176
+ // If it's already our error, just rethrow
177
+ if (err.message && !err.message.includes('fetch')) {
178
+ throw err;
154
179
  }
155
- throw new Error(`Failed to deactivate device: ${message}`);
180
+ // Network error
181
+ throw new Error(`Network error: ${err.message}`);
156
182
  }
157
183
  }