@rigstate/cli 0.7.7 → 0.7.9
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 +25 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +25 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/daemon/factory.ts +4 -2
- package/src/utils/config.ts +46 -1
package/dist/index.cjs
CHANGED
|
@@ -51,6 +51,7 @@ var config_exports = {};
|
|
|
51
51
|
__export(config_exports, {
|
|
52
52
|
clearConfig: () => clearConfig,
|
|
53
53
|
config: () => config,
|
|
54
|
+
discoverApiUrl: () => discoverApiUrl,
|
|
54
55
|
getApiKey: () => getApiKey,
|
|
55
56
|
getApiUrl: () => getApiUrl,
|
|
56
57
|
getProjectId: () => getProjectId,
|
|
@@ -86,6 +87,27 @@ function getApiUrl() {
|
|
|
86
87
|
}
|
|
87
88
|
return "https://app.rigstate.com";
|
|
88
89
|
}
|
|
90
|
+
async function discoverApiUrl() {
|
|
91
|
+
const configuredUrl = getApiUrl();
|
|
92
|
+
if (!configuredUrl.includes("localhost") && !configuredUrl.includes("127.0.0.1")) {
|
|
93
|
+
return configuredUrl;
|
|
94
|
+
}
|
|
95
|
+
const ports = [3e3, 3001, 3002, 3003, 3004, 3005, 3006, 3007, 3008, 3009, 3010];
|
|
96
|
+
const { default: axios22 } = await import("axios");
|
|
97
|
+
for (const port of ports) {
|
|
98
|
+
try {
|
|
99
|
+
const url = `http://localhost:${port}`;
|
|
100
|
+
await axios22.get(`${url}/api/v1/system/health`, { timeout: 500 });
|
|
101
|
+
if (url !== configuredUrl) {
|
|
102
|
+
setApiUrl(url);
|
|
103
|
+
}
|
|
104
|
+
return url;
|
|
105
|
+
} catch (e) {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return configuredUrl;
|
|
110
|
+
}
|
|
89
111
|
function setApiUrl(url) {
|
|
90
112
|
config.set("apiUrl", url);
|
|
91
113
|
}
|
|
@@ -1843,9 +1865,9 @@ function createLinkCommand() {
|
|
|
1843
1865
|
console.log("");
|
|
1844
1866
|
console.log(import_chalk6.default.bold("\u{1F916} Rigstate Automation Detected"));
|
|
1845
1867
|
console.log("");
|
|
1846
|
-
const { getApiKey: getApiKey2, getApiUrl:
|
|
1868
|
+
const { getApiKey: getApiKey2, getApiUrl: getApiUrl3 } = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
1847
1869
|
const apiKey = getApiKey2();
|
|
1848
|
-
const apiUrl =
|
|
1870
|
+
const apiUrl = getApiUrl3();
|
|
1849
1871
|
if (apiKey) {
|
|
1850
1872
|
console.log(import_chalk6.default.blue("\u{1F510} Checking Vault for secrets..."));
|
|
1851
1873
|
const { syncEnv: syncEnv2 } = await Promise.resolve().then(() => (init_env(), env_exports));
|
|
@@ -3836,7 +3858,7 @@ var GuardianDaemon = class extends import_events3.EventEmitter {
|
|
|
3836
3858
|
// src/daemon/factory.ts
|
|
3837
3859
|
init_config();
|
|
3838
3860
|
async function createDaemon(options) {
|
|
3839
|
-
const apiUrl =
|
|
3861
|
+
const apiUrl = await discoverApiUrl();
|
|
3840
3862
|
let projectId = options.project;
|
|
3841
3863
|
if (!projectId) {
|
|
3842
3864
|
const manifest = await loadManifest();
|