@instafy/cli 0.1.8-staging.353 → 0.1.8-staging.354
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/auth.js +17 -3
- package/package.json +1 -1
package/dist/auth.js
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
import kleur from "kleur";
|
|
2
2
|
import { randomBytes } from "node:crypto";
|
|
3
3
|
import * as http from "node:http";
|
|
4
|
+
import { createRequire } from "node:module";
|
|
4
5
|
import { createInterface } from "node:readline/promises";
|
|
5
6
|
import { stdin as input, stdout as output } from "node:process";
|
|
6
7
|
import { clearInstafyCliConfig, getInstafyConfigPath, resolveConfiguredControllerUrl, resolveConfiguredStudioUrl, resolveUserAccessToken, writeInstafyCliConfig, } from "./config.js";
|
|
7
8
|
import { installGitCredentialHelper, uninstallGitCredentialHelper } from "./git-setup.js";
|
|
9
|
+
const require = createRequire(import.meta.url);
|
|
10
|
+
const cliVersion = (() => {
|
|
11
|
+
try {
|
|
12
|
+
const pkg = require("../package.json");
|
|
13
|
+
return typeof pkg.version === "string" ? pkg.version : "";
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return "";
|
|
17
|
+
}
|
|
18
|
+
})();
|
|
19
|
+
const isStagingCli = cliVersion.includes("-staging.");
|
|
8
20
|
function normalizeUrl(raw) {
|
|
9
21
|
const trimmed = typeof raw === "string" ? raw.trim() : "";
|
|
10
22
|
if (!trimmed) {
|
|
@@ -207,9 +219,11 @@ export async function login(options) {
|
|
|
207
219
|
const defaultLocalControllerUrl = "http://127.0.0.1:8788";
|
|
208
220
|
const defaultHostedControllerUrl = "https://controller.instafy.dev";
|
|
209
221
|
const controllerUrl = explicitControllerUrl ??
|
|
210
|
-
(
|
|
211
|
-
?
|
|
212
|
-
:
|
|
222
|
+
(isStagingCli
|
|
223
|
+
? defaultHostedControllerUrl
|
|
224
|
+
: (await isControllerHealthy(defaultLocalControllerUrl, 250))
|
|
225
|
+
? defaultLocalControllerUrl
|
|
226
|
+
: defaultHostedControllerUrl);
|
|
213
227
|
const studioUrl = normalizeUrl(options.studioUrl ?? null) ??
|
|
214
228
|
normalizeUrl(process.env["INSTAFY_STUDIO_URL"] ?? null) ??
|
|
215
229
|
resolveConfiguredStudioUrl() ??
|
package/package.json
CHANGED