bitfab-cli 0.2.145 → 0.2.146
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 +58 -38
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9939,35 +9939,56 @@ function extractCommandName(argv) {
|
|
|
9939
9939
|
// ../bitfab-plugin-lib/dist/studioChannel.js
|
|
9940
9940
|
import crypto8 from "crypto";
|
|
9941
9941
|
|
|
9942
|
-
// ../bitfab-plugin-lib/dist/
|
|
9943
|
-
|
|
9944
|
-
|
|
9945
|
-
|
|
9942
|
+
// ../bitfab-plugin-lib/dist/studioUrl.js
|
|
9943
|
+
var DEFAULT_STUDIO_PATH = "/studio";
|
|
9944
|
+
function resolveStudioInitialPath(input) {
|
|
9945
|
+
if (input && isValidStudioRoute(input)) {
|
|
9946
|
+
return input;
|
|
9946
9947
|
}
|
|
9947
|
-
return
|
|
9948
|
+
return DEFAULT_STUDIO_PATH;
|
|
9948
9949
|
}
|
|
9950
|
+
function buildStudioSessionUrl(args) {
|
|
9951
|
+
const { serviceUrl, path: path20, sessionId } = args;
|
|
9952
|
+
if (path20.includes("session=")) {
|
|
9953
|
+
return `${serviceUrl}${path20}`;
|
|
9954
|
+
}
|
|
9955
|
+
const separator = path20.includes("?") ? "&" : "?";
|
|
9956
|
+
return `${serviceUrl}${path20}${separator}session=${encodeURIComponent(sessionId)}`;
|
|
9957
|
+
}
|
|
9958
|
+
function resolveStudioSessionTarget(args) {
|
|
9959
|
+
const path20 = resolveStudioInitialPath(args.path);
|
|
9960
|
+
return {
|
|
9961
|
+
path: path20,
|
|
9962
|
+
url: buildStudioSessionUrl({
|
|
9963
|
+
serviceUrl: args.serviceUrl,
|
|
9964
|
+
path: path20,
|
|
9965
|
+
sessionId: args.sessionId
|
|
9966
|
+
})
|
|
9967
|
+
};
|
|
9968
|
+
}
|
|
9969
|
+
|
|
9970
|
+
// ../bitfab-plugin-lib/dist/commands/createStudioSession.js
|
|
9949
9971
|
async function createStudioSession({ serviceUrl, apiKey, sessionId, initialPath = "/studio", clientHeaders }) {
|
|
9950
9972
|
if (!apiKey) {
|
|
9951
9973
|
throw new NotAuthenticatedError();
|
|
9952
9974
|
}
|
|
9953
|
-
|
|
9954
|
-
|
|
9955
|
-
|
|
9956
|
-
|
|
9975
|
+
const target = resolveStudioSessionTarget({
|
|
9976
|
+
serviceUrl,
|
|
9977
|
+
path: initialPath,
|
|
9978
|
+
sessionId
|
|
9979
|
+
});
|
|
9957
9980
|
await createAgentSession({
|
|
9958
9981
|
serviceUrl,
|
|
9959
9982
|
apiKey,
|
|
9960
9983
|
sessionId,
|
|
9961
9984
|
extraHeaders: clientHeaders
|
|
9962
9985
|
});
|
|
9963
|
-
const
|
|
9964
|
-
const url2 = `${serviceUrl}${initialPath}${separator}session=${encodeURIComponent(sessionId)}`;
|
|
9965
|
-
const windowPid = openChromelessWindow(url2);
|
|
9986
|
+
const windowPid = openChromelessWindow(target.url);
|
|
9966
9987
|
writeActiveStudioSession({
|
|
9967
9988
|
sessionId,
|
|
9968
9989
|
serviceUrl,
|
|
9969
9990
|
windowPid,
|
|
9970
|
-
currentPath:
|
|
9991
|
+
currentPath: target.path
|
|
9971
9992
|
});
|
|
9972
9993
|
return { sessionId, serviceUrl };
|
|
9973
9994
|
}
|
|
@@ -10600,23 +10621,6 @@ function tailStudioEvents(key, onLine, opts) {
|
|
|
10600
10621
|
});
|
|
10601
10622
|
}
|
|
10602
10623
|
|
|
10603
|
-
// ../bitfab-plugin-lib/dist/studioUrl.js
|
|
10604
|
-
var DEFAULT_STUDIO_PATH = "/studio";
|
|
10605
|
-
function resolveStudioInitialPath(input) {
|
|
10606
|
-
if (input && isValidStudioRoute(input)) {
|
|
10607
|
-
return input;
|
|
10608
|
-
}
|
|
10609
|
-
return DEFAULT_STUDIO_PATH;
|
|
10610
|
-
}
|
|
10611
|
-
function buildStudioSessionUrl(args) {
|
|
10612
|
-
const { serviceUrl, path: path20, sessionId } = args;
|
|
10613
|
-
if (path20.includes("session=")) {
|
|
10614
|
-
return `${serviceUrl}${path20}`;
|
|
10615
|
-
}
|
|
10616
|
-
const separator = path20.includes("?") ? "&" : "?";
|
|
10617
|
-
return `${serviceUrl}${path20}${separator}session=${encodeURIComponent(sessionId)}`;
|
|
10618
|
-
}
|
|
10619
|
-
|
|
10620
10624
|
// ../bitfab-plugin-lib/dist/studioChannel.js
|
|
10621
10625
|
function stripSessionId(path20, sessionId) {
|
|
10622
10626
|
return sessionId ? path20.split(sessionId).join("__SID__") : path20;
|
|
@@ -11097,6 +11101,9 @@ function lineToAgentEvent(line) {
|
|
|
11097
11101
|
}
|
|
11098
11102
|
var WINDOW_CLOSE_GRACE_PERIOD_MS = 1e4;
|
|
11099
11103
|
var LOGIN_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
11104
|
+
function formatStudioUrlMessage(url2) {
|
|
11105
|
+
return `Studio opened at: ${url2}`;
|
|
11106
|
+
}
|
|
11100
11107
|
function createEventSubscription(channel, sessionId, onEvent, restoreFocus) {
|
|
11101
11108
|
let graceTimer = null;
|
|
11102
11109
|
let endedNotified = false;
|
|
@@ -11169,14 +11176,15 @@ async function openStudioTo(path20, opts = {}) {
|
|
|
11169
11176
|
const focusTarget = captureFocusTarget();
|
|
11170
11177
|
const restoreFocus = () => applyFocusTarget(focusTarget);
|
|
11171
11178
|
const channel = await resolveChannel(apiKey ?? "", serviceUrl);
|
|
11172
|
-
const finish = (sessionId2, opened2, resolvedApiKey) => {
|
|
11179
|
+
const finish = (sessionId2, opened2, resolvedApiKey, url3) => {
|
|
11173
11180
|
const persistent = channel.isPersistent();
|
|
11174
11181
|
const base = {
|
|
11175
11182
|
sessionId: sessionId2,
|
|
11176
11183
|
serviceUrl,
|
|
11177
11184
|
apiKey: resolvedApiKey,
|
|
11178
11185
|
opened: opened2,
|
|
11179
|
-
persistent
|
|
11186
|
+
persistent,
|
|
11187
|
+
url: url3
|
|
11180
11188
|
};
|
|
11181
11189
|
const wantsEvents = opts.tail || Boolean(opts.onEvent);
|
|
11182
11190
|
if (persistent) {
|
|
@@ -11252,6 +11260,9 @@ async function openStudioTo(path20, opts = {}) {
|
|
|
11252
11260
|
});
|
|
11253
11261
|
const sessionId2 = openResult.sessionId;
|
|
11254
11262
|
const signInUrl = `${serviceUrl}${buildSignInPath(sessionId2)}`;
|
|
11263
|
+
if (openResult.opened) {
|
|
11264
|
+
opts.onWindowOpened?.(signInUrl);
|
|
11265
|
+
}
|
|
11255
11266
|
opts.onLoginRequired?.(sessionId2, signInUrl);
|
|
11256
11267
|
const loginApiKey = await new Promise((resolve2, reject) => {
|
|
11257
11268
|
const timer = setTimeout(() => {
|
|
@@ -11278,13 +11289,17 @@ async function openStudioTo(path20, opts = {}) {
|
|
|
11278
11289
|
updateActiveStudioSession({ authenticated: true });
|
|
11279
11290
|
opts.onAuthenticated?.(sessionId2);
|
|
11280
11291
|
channel.setApiKey(loginApiKey);
|
|
11281
|
-
return finish(sessionId2, openResult.opened, loginApiKey);
|
|
11292
|
+
return finish(sessionId2, openResult.opened, loginApiKey, openResult.opened ? signInUrl : void 0);
|
|
11282
11293
|
}
|
|
11283
11294
|
const { sessionId, opened } = await channel.openOrNavigate(path20, {
|
|
11284
11295
|
clientHeaders: opts.clientHeaders,
|
|
11285
11296
|
focusTarget: focusTarget ?? void 0
|
|
11286
11297
|
});
|
|
11287
|
-
|
|
11298
|
+
const url2 = opened ? resolveStudioSessionTarget({ serviceUrl, path: path20, sessionId }).url : void 0;
|
|
11299
|
+
if (url2) {
|
|
11300
|
+
opts.onWindowOpened?.(url2);
|
|
11301
|
+
}
|
|
11302
|
+
return finish(sessionId, opened, apiKey, url2);
|
|
11288
11303
|
}
|
|
11289
11304
|
|
|
11290
11305
|
// ../bitfab-plugin-lib/dist/commands/login.js
|
|
@@ -11317,15 +11332,20 @@ Already logged in as ${identity}. Run the login command with --force to re-authe
|
|
|
11317
11332
|
return;
|
|
11318
11333
|
}
|
|
11319
11334
|
}
|
|
11320
|
-
console.log("\nOpening Studio to sign in...");
|
|
11321
11335
|
try {
|
|
11336
|
+
let printedSignInUrl = false;
|
|
11322
11337
|
const result = await openStudioTo("/studio", {
|
|
11323
11338
|
forceLogin: true,
|
|
11324
11339
|
freshWindowPath: `/studio/close?autoClose=true&message=${encodeURIComponent("Login complete")}`,
|
|
11325
11340
|
onLoginRequired: (_sessionId, signInUrl) => {
|
|
11326
|
-
|
|
11327
|
-
|
|
11328
|
-
|
|
11341
|
+
if (!printedSignInUrl) {
|
|
11342
|
+
printedSignInUrl = true;
|
|
11343
|
+
console.log(formatStudioUrlMessage(signInUrl));
|
|
11344
|
+
}
|
|
11345
|
+
},
|
|
11346
|
+
onWindowOpened: (url2) => {
|
|
11347
|
+
printedSignInUrl = true;
|
|
11348
|
+
console.log(formatStudioUrlMessage(url2));
|
|
11329
11349
|
}
|
|
11330
11350
|
});
|
|
11331
11351
|
const apiKey = getConfig().apiKey;
|