linage-cli 1.1.1 → 1.2.0
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.
- package/index.js +1 -1
- package/package.json +1 -1
- package/utils/api.js +26 -4
- package/utils/ui.js +2 -1
package/index.js
CHANGED
package/package.json
CHANGED
package/utils/api.js
CHANGED
|
@@ -26,13 +26,29 @@ const request = async (endpoint, method = 'GET', opts = {}) => {
|
|
|
26
26
|
|
|
27
27
|
try {
|
|
28
28
|
const res = await fetch(`${baseUrl}${endpoint}`, options);
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
// Handle 401 specifically
|
|
31
31
|
if (res.status === 401 || res.status === 403) {
|
|
32
32
|
throw new Error('Invalid or expired API Key. Please login again.');
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
const
|
|
35
|
+
const contentType = res.headers.get('content-type');
|
|
36
|
+
let data;
|
|
37
|
+
|
|
38
|
+
if (contentType && contentType.includes('application/json')) {
|
|
39
|
+
try {
|
|
40
|
+
data = await res.json();
|
|
41
|
+
} catch (e) {
|
|
42
|
+
throw new Error('Failed to parse API response as JSON.');
|
|
43
|
+
}
|
|
44
|
+
} else {
|
|
45
|
+
const text = await res.text();
|
|
46
|
+
// If it's HTML, it's likely a redirect or error page from the server/proxy
|
|
47
|
+
if (text.trim().startsWith('<!DOCTYPE html>') || text.trim().startsWith('<html')) {
|
|
48
|
+
throw new Error(`Received HTML response from server. This often indicates a routing issue or unexpected redirect (Status: ${res.status}).`);
|
|
49
|
+
}
|
|
50
|
+
throw new Error(`Unexpected non-JSON response: ${text.substring(0, 100)}...`);
|
|
51
|
+
}
|
|
36
52
|
|
|
37
53
|
if (!res.ok) {
|
|
38
54
|
throw new Error(data.error || data.message || `API Error: ${res.statusText}`);
|
|
@@ -52,12 +68,18 @@ module.exports = {
|
|
|
52
68
|
validateKey: async (key) => {
|
|
53
69
|
const baseUrl = config.getApiUrl();
|
|
54
70
|
try {
|
|
55
|
-
// We'll create a simple /api/whoami endpoint to validate
|
|
71
|
+
// We'll create a simple /api/cli/whoami endpoint to validate
|
|
56
72
|
const res = await fetch(`${baseUrl}/api/cli/whoami`, {
|
|
57
73
|
headers: { 'Authorization': `Bearer ${key}` }
|
|
58
74
|
});
|
|
75
|
+
|
|
59
76
|
if (!res.ok) return false;
|
|
60
|
-
|
|
77
|
+
|
|
78
|
+
const contentType = res.headers.get('content-type');
|
|
79
|
+
if (contentType && contentType.includes('application/json')) {
|
|
80
|
+
return await res.json();
|
|
81
|
+
}
|
|
82
|
+
return false;
|
|
61
83
|
} catch (e) {
|
|
62
84
|
return false;
|
|
63
85
|
}
|
package/utils/ui.js
CHANGED
|
@@ -18,13 +18,14 @@ const COLORS = {
|
|
|
18
18
|
const neoGradient = gradient(COLORS.orange, COLORS.cyan);
|
|
19
19
|
|
|
20
20
|
const printHeader = () => {
|
|
21
|
+
const version = require('../package.json').version;
|
|
21
22
|
console.log('');
|
|
22
23
|
console.log(neoGradient.multiline(figlet.textSync("LI'NAGE", {
|
|
23
24
|
font: 'Slant',
|
|
24
25
|
horizontalLayout: 'fitted'
|
|
25
26
|
})));
|
|
26
27
|
console.log(chalk.bold.hex(COLORS.cyan)(' ⬡ ') + chalk.hex(COLORS.zinc)("Automated Dependency Discovery & Lineage Mapping"));
|
|
27
|
-
console.log(chalk.hex(COLORS.zinc)(
|
|
28
|
+
console.log(chalk.hex(COLORS.zinc)(` v${version} • linage.cloud`));
|
|
28
29
|
console.log('');
|
|
29
30
|
};
|
|
30
31
|
|