@rigstate/cli 0.7.10 → 0.7.12
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/dist/index.cjs +22 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +22 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/daemon/guardian-monitor.ts +25 -0
- package/src/utils/config.ts +2 -2
package/package.json
CHANGED
|
@@ -57,6 +57,31 @@ export function createGuardianMonitor(
|
|
|
57
57
|
}
|
|
58
58
|
} catch (error: any) {
|
|
59
59
|
// Log error for debugging
|
|
60
|
+
|
|
61
|
+
// If it was a local connection failure, try falling back to Rigstate Cloud
|
|
62
|
+
if (apiUrl.includes('localhost') || apiUrl.includes('127.0.0.1')) {
|
|
63
|
+
const cloudUrl = 'https://app.rigstate.com';
|
|
64
|
+
console.log(chalk.blue(` ☁️ Local API not found. Attempting Cloud Fallback (${cloudUrl})...`));
|
|
65
|
+
try {
|
|
66
|
+
const cloudResponse = await axios.get(`${cloudUrl}/api/v1/guardian/rules`, {
|
|
67
|
+
params: { project_id: projectId },
|
|
68
|
+
headers: { Authorization: `Bearer ${apiKey}` },
|
|
69
|
+
timeout: 5000
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
if (cloudResponse.data.success && cloudResponse.data.data.rules) {
|
|
73
|
+
rules = cloudResponse.data.data.rules;
|
|
74
|
+
console.log(chalk.green(` ✅ Successfully loaded rules from Rigstate Cloud!`));
|
|
75
|
+
lastFetch = Date.now();
|
|
76
|
+
await saveCachedRules(projectId, rules);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
} catch (cloudError: any) {
|
|
80
|
+
console.error(chalk.red(` ❌ Cloud Fallback failed: ${cloudError.message}`));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Log local error if cloud fallback also fails
|
|
60
85
|
console.error(chalk.red(` ⚠️ Failed to fetch rules from API: ${error.message}`));
|
|
61
86
|
if (error.response) {
|
|
62
87
|
console.error(chalk.red(` Status: ${error.response.status} - ${JSON.stringify(error.response.data)}`));
|
package/src/utils/config.ts
CHANGED
|
@@ -124,8 +124,8 @@ export async function discoverApiUrl(): Promise<string> {
|
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
console.log(chalk.yellow(` ❌ No local Rigstate API found on scanned ports. Falling back to
|
|
128
|
-
return
|
|
127
|
+
console.log(chalk.yellow(` ❌ No local Rigstate API found on scanned ports. Falling back to Rigstate Cloud.`));
|
|
128
|
+
return 'https://app.rigstate.com';
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
/**
|