@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 CHANGED
@@ -121,8 +121,8 @@ async function discoverApiUrl() {
121
121
  continue;
122
122
  }
123
123
  }
124
- console.log(chalk34.yellow(` \u274C No local Rigstate API found on scanned ports. Falling back to configured URL: ${configuredUrl}`));
125
- return configuredUrl;
124
+ console.log(chalk34.yellow(` \u274C No local Rigstate API found on scanned ports. Falling back to Rigstate Cloud.`));
125
+ return "https://app.rigstate.com";
126
126
  }
127
127
  function setApiUrl(url) {
128
128
  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(import_chalk17.default.blue(` \u2601\uFE0F Local API not found. Attempting Cloud Fallback (${cloudUrl})...`));
3592
+ try {
3593
+ const cloudResponse = await import_axios12.default.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(import_chalk17.default.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(import_chalk17.default.red(` \u274C Cloud Fallback failed: ${cloudError.message}`));
3607
+ }
3608
+ }
3589
3609
  console.error(import_chalk17.default.red(` \u26A0\uFE0F Failed to fetch rules from API: ${error.message}`));
3590
3610
  if (error.response) {
3591
3611
  console.error(import_chalk17.default.red(` Status: ${error.response.status} - ${JSON.stringify(error.response.data)}`));