@rigstate/cli 0.7.14 → 0.7.15
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 +71 -94
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +65 -88
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/daemon/factory.ts +2 -3
- package/src/utils/config.ts +1 -42
package/package.json
CHANGED
package/src/daemon/factory.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GuardianDaemon } from './core.js';
|
|
2
|
-
import { getApiKey, getApiUrl,
|
|
2
|
+
import { getApiKey, getApiUrl, getProjectId } from '../utils/config.js';
|
|
3
3
|
import { loadManifest } from '../utils/manifest.js';
|
|
4
4
|
import { DaemonConfig } from './types.js';
|
|
5
5
|
|
|
@@ -12,8 +12,7 @@ export async function createDaemon(options: {
|
|
|
12
12
|
noBridge?: boolean;
|
|
13
13
|
verbose?: boolean;
|
|
14
14
|
}): Promise<GuardianDaemon> {
|
|
15
|
-
|
|
16
|
-
const apiUrl = await discoverApiUrl();
|
|
15
|
+
const apiUrl = getApiUrl();
|
|
17
16
|
|
|
18
17
|
let projectId = options.project;
|
|
19
18
|
|
package/src/utils/config.ts
CHANGED
|
@@ -11,7 +11,7 @@ interface RigstateConfig {
|
|
|
11
11
|
const config = new Conf<RigstateConfig>({
|
|
12
12
|
projectName: 'rigstate-cli',
|
|
13
13
|
defaults: {
|
|
14
|
-
apiUrl: '
|
|
14
|
+
apiUrl: 'https://app.rigstate.com',
|
|
15
15
|
},
|
|
16
16
|
});
|
|
17
17
|
|
|
@@ -50,12 +50,6 @@ export function setProjectId(projectId: string): void {
|
|
|
50
50
|
config.set('projectId', projectId);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
// Basic check if a port is open - simplistic implementation for now
|
|
54
|
-
// In a real scenario, we might want to actually ping /api/health
|
|
55
|
-
// But for getApiUrl which is synchronous, we cannot easily do async checks.
|
|
56
|
-
// So we will stick to the config/env value, BUT we will expose a separate
|
|
57
|
-
// async function `discoverApiUrl` that the Daemon calls on startup.
|
|
58
|
-
|
|
59
53
|
/**
|
|
60
54
|
* Get the API URL (Synchronous)
|
|
61
55
|
* Priority: Environment variable > Stored config > Production default
|
|
@@ -74,41 +68,6 @@ export function getApiUrl(): string {
|
|
|
74
68
|
return 'https://app.rigstate.com';
|
|
75
69
|
}
|
|
76
70
|
|
|
77
|
-
/**
|
|
78
|
-
* Discovers the active local API URL (Async)
|
|
79
|
-
* Scans ports 3000-3010 to find a responding Rigstate server.
|
|
80
|
-
* This is now SILENT and will not spam the console.
|
|
81
|
-
*/
|
|
82
|
-
export async function discoverApiUrl(): Promise<string> {
|
|
83
|
-
const configuredUrl = getApiUrl();
|
|
84
|
-
const ports = [3000, 3001, 3002, 3003, 3004, 3005, 3006, 3007, 3008, 3009, 3010];
|
|
85
|
-
|
|
86
|
-
// If not localhost, don't even bother scanning (saves time/noise)
|
|
87
|
-
if (!configuredUrl.includes('localhost') && !configuredUrl.includes('127.0.0.1')) {
|
|
88
|
-
return configuredUrl;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// Silent scan - check ports for a valid health endpoint
|
|
92
|
-
for (const port of ports) {
|
|
93
|
-
const url = `http://localhost:${port}`;
|
|
94
|
-
try {
|
|
95
|
-
const res = await axios.get(`${url}/api/v1/system/health`, { timeout: 200 });
|
|
96
|
-
// If it responds with 'healthy', we found a Rigstate server!
|
|
97
|
-
if (res.data?.status === 'healthy') {
|
|
98
|
-
if (url !== configuredUrl) {
|
|
99
|
-
setApiUrl(url);
|
|
100
|
-
}
|
|
101
|
-
return url;
|
|
102
|
-
}
|
|
103
|
-
} catch (e) {
|
|
104
|
-
// Move to next port silently
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// Default to Cloud if local Rigstate server is not found
|
|
109
|
-
return 'https://app.rigstate.com';
|
|
110
|
-
}
|
|
111
|
-
|
|
112
71
|
/**
|
|
113
72
|
* Set the API URL
|
|
114
73
|
*/
|