@nurix/nustack 0.26.1 → 0.26.3
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/commands/login.js +17 -4
- package/package.json +2 -2
package/dist/commands/login.js
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import * as p from "@clack/prompts";
|
|
2
|
-
import {
|
|
2
|
+
import { resolveNuStackOrigin } from "../lib/nustack_client.js";
|
|
3
3
|
import { launchBrowser } from "../lib/browser_opener.js";
|
|
4
4
|
import { selectCredentialStore } from "../lib/credential_store.js";
|
|
5
5
|
import { isInteractive } from "../lib/interactive.js";
|
|
6
6
|
import { ensureAccessToken, ENV_TOKEN_VARIABLE, envToken, loginWithLoopback, loginWithPastedCode, prepareLogin, readStoredCredential, } from "../lib/auth_grant.js";
|
|
7
7
|
import { isContractOrigin, nullUnlessOriginRefused, originMismatchError, refusedContractOrigin } from "../lib/origin_guard.js";
|
|
8
|
+
function originOf(url) {
|
|
9
|
+
try {
|
|
10
|
+
return url ? new URL(url).origin : null;
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
8
16
|
async function readStdinLine() {
|
|
9
17
|
return new Promise((resolve) => {
|
|
10
18
|
let buffered = "";
|
|
@@ -96,7 +104,12 @@ export async function performDeviceLogin(baseUrl, _cwd = process.cwd(), flags =
|
|
|
96
104
|
p.log.error(error instanceof Error ? error.message : String(error));
|
|
97
105
|
return false;
|
|
98
106
|
}
|
|
99
|
-
|
|
107
|
+
const heldOrigin = originOf((await readStoredCredential().catch(() => null))?.credential?.studioBaseUrl);
|
|
108
|
+
const isMoving = flags.isOriginStated === true && heldOrigin !== null && heldOrigin !== originOf(baseUrl);
|
|
109
|
+
if (isMoving) {
|
|
110
|
+
p.log.info(`This machine is signed in to ${heldOrigin}; signing in to ${originOf(baseUrl)} moves it there, and the desktop app shares the sign-in.`);
|
|
111
|
+
}
|
|
112
|
+
if (!flags.force && !flags.reauthorize && !isMoving) {
|
|
100
113
|
const live = await ensureAccessToken().catch(nullUnlessOriginRefused);
|
|
101
114
|
if (live) {
|
|
102
115
|
p.log.success(`Signed in as ${live.userEmail || "this account"} — already signed in on this machine (use --force to sign in again).`);
|
|
@@ -140,9 +153,9 @@ export async function performDeviceLogin(baseUrl, _cwd = process.cwd(), flags =
|
|
|
140
153
|
return true;
|
|
141
154
|
}
|
|
142
155
|
export async function runLogin(options, flags = {}) {
|
|
143
|
-
const baseUrl =
|
|
156
|
+
const { url: baseUrl, source } = resolveNuStackOrigin(options, process.cwd());
|
|
144
157
|
p.intro("nustack login");
|
|
145
|
-
const didLogin = await performDeviceLogin(baseUrl, process.cwd(), flags);
|
|
158
|
+
const didLogin = await performDeviceLogin(baseUrl, process.cwd(), { ...flags, isOriginStated: source === "flag" || source === "env" });
|
|
146
159
|
if (!didLogin) {
|
|
147
160
|
p.outro("Nothing was written.");
|
|
148
161
|
process.exitCode = 1;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nurix/nustack",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.3",
|
|
4
4
|
"description": "The nustack CLI — bootstrap NuStack services into a repo via the NuStack discovery plane.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"@types/node": "^22.19.20",
|
|
35
35
|
"typescript": "^5.7.2",
|
|
36
36
|
"vitest": "^4.1.11",
|
|
37
|
-
"@nurix/harness": "0.0.0",
|
|
38
37
|
"@nurix/contracts": "3.0.2",
|
|
38
|
+
"@nurix/harness": "0.0.0",
|
|
39
39
|
"@nurix/nustack.studio": "0.0.0",
|
|
40
40
|
"@nurix/nustack.ui": "0.0.0"
|
|
41
41
|
},
|