@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.js CHANGED
@@ -126,8 +126,8 @@ async function discoverApiUrl() {
126
126
  continue;
127
127
  }
128
128
  }
129
- console.log(chalk34.yellow(` \u274C No local Rigstate API found on scanned ports. Falling back to configured URL: ${configuredUrl}`));
130
- return configuredUrl;
129
+ console.log(chalk34.yellow(` \u274C No local Rigstate API found on scanned ports. Falling back to Rigstate Cloud.`));
130
+ return "https://app.rigstate.com";
131
131
  }
132
132
  function setApiUrl(url) {
133
133
  config.set("apiUrl", url);
@@ -3586,6 +3586,26 @@ function createGuardianMonitor(projectId, apiUrl, apiKey) {
3586
3586
  return;
3587
3587
  }
3588
3588
  } catch (error) {
3589
+ if (apiUrl.includes("localhost") || apiUrl.includes("127.0.0.1")) {
3590
+ const cloudUrl = "https://app.rigstate.com";
3591
+ console.log(chalk17.blue(` \u2601\uFE0F Local API not found. Attempting Cloud Fallback (${cloudUrl})...`));
3592
+ try {
3593
+ const cloudResponse = await axios12.get(`${cloudUrl}/api/v1/guardian/rules`, {
3594
+ params: { project_id: projectId },
3595
+ headers: { Authorization: `Bearer ${apiKey}` },
3596
+ timeout: 5e3
3597
+ });
3598
+ if (cloudResponse.data.success && cloudResponse.data.data.rules) {
3599
+ rules = cloudResponse.data.data.rules;
3600
+ console.log(chalk17.green(` \u2705 Successfully loaded rules from Rigstate Cloud!`));
3601
+ lastFetch = Date.now();
3602
+ await saveCachedRules2(projectId, rules);
3603
+ return;
3604
+ }
3605
+ } catch (cloudError) {
3606
+ console.error(chalk17.red(` \u274C Cloud Fallback failed: ${cloudError.message}`));
3607
+ }
3608
+ }
3589
3609
  console.error(chalk17.red(` \u26A0\uFE0F Failed to fetch rules from API: ${error.message}`));
3590
3610
  if (error.response) {
3591
3611
  console.error(chalk17.red(` Status: ${error.response.status} - ${JSON.stringify(error.response.data)}`));