@letterstory/cli 0.177.162 → 0.177.164
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/lib/cli.mjs +5 -2
- package/lib/commands/auth.mjs +11 -1
- package/lib/commands/repo.mjs +2 -0
- package/lib/oauth.mjs +3 -2
- package/package.json +1 -1
package/lib/cli.mjs
CHANGED
|
@@ -93,7 +93,7 @@ import {
|
|
|
93
93
|
import { fetchParkedSections, withoutParked } from "./parked.mjs";
|
|
94
94
|
|
|
95
95
|
// Matches cli/package.json; publish-cli.yml rewrites both to the published version.
|
|
96
|
-
export const VERSION = "0.177.
|
|
96
|
+
export const VERSION = "0.177.164";
|
|
97
97
|
|
|
98
98
|
/** The exit code for a gate refusal (CARD_REQUIRED, PAYMENT_FAILED, OUT_OF_TOKENS): 1 is a plain error. */
|
|
99
99
|
export const EXIT_PAYMENT_REQUIRED = 3;
|
|
@@ -103,6 +103,9 @@ export const EXIT_PAYMENT_REQUIRED = 3;
|
|
|
103
103
|
// `negate` spelling) in a command's ARGS map must be listed; boolean-flags.test.ts enforces it.
|
|
104
104
|
export const BOOLEAN_FLAGS = new Set([
|
|
105
105
|
"update",
|
|
106
|
+
// repo list: open changes past --limit are listed unless --newest-only.
|
|
107
|
+
"include-open",
|
|
108
|
+
"newest-only",
|
|
106
109
|
"include-tests",
|
|
107
110
|
"as-test",
|
|
108
111
|
"discover",
|
|
@@ -636,7 +639,7 @@ Usage:
|
|
|
636
639
|
${bin} <command> [args] [--flags]
|
|
637
640
|
|
|
638
641
|
Auth:
|
|
639
|
-
login [--url <url>] Sign in via your browser (default url: https://app.letterstory.com)
|
|
642
|
+
login [--url <url>] Sign in via your browser; a link over SSH (default url: https://app.letterstory.com)
|
|
640
643
|
login --device [--url <url>] Sign in with one link, opened in any browser (for agents and remote shells)
|
|
641
644
|
login --key <ls_…> [--url <url>] Save a static API key instead (for CI/automation)
|
|
642
645
|
signup --email <work email> [--agent <name>] [--url <url>]
|
package/lib/commands/auth.mjs
CHANGED
|
@@ -39,10 +39,20 @@ export async function cmdLogin(ctx) {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
const
|
|
42
|
+
const device = flags.device || browserIsElsewhere();
|
|
43
|
+
if (device && !flags.device) io.log("No browser on this machine, so sign in with a link instead.\n");
|
|
44
|
+
const tokens = device ? await deviceLogin({ url, io }) : await browserLogin({ url, io });
|
|
43
45
|
return saveSession({ tokens, url, flags, io });
|
|
44
46
|
}
|
|
45
47
|
|
|
48
|
+
// Over SSH, or on Linux with no display, the browser is on another machine and can't reach the
|
|
49
|
+
// loopback redirect (127.0.0.1 here), so `login` signs in with a link and a code as `--device` does.
|
|
50
|
+
/** @param {Record<string, string | undefined>} env @param {string} platform */
|
|
51
|
+
export function browserIsElsewhere(env = process.env, platform = process.platform) {
|
|
52
|
+
if (env.SSH_CONNECTION || env.SSH_CLIENT || env.SSH_TTY) return true;
|
|
53
|
+
return platform === "linux" && !env.DISPLAY && !env.WAYLAND_DISPLAY;
|
|
54
|
+
}
|
|
55
|
+
|
|
46
56
|
// An OAuth session from /token, saved the way every login saves it, then checked with one call.
|
|
47
57
|
async function saveSession({ tokens, url, flags, io }) {
|
|
48
58
|
const oauth = {
|
package/lib/commands/repo.mjs
CHANGED
|
@@ -328,6 +328,8 @@ const ARGS = {
|
|
|
328
328
|
],
|
|
329
329
|
},
|
|
330
330
|
site_host: "site",
|
|
331
|
+
// Open changes past --limit are listed by default; --newest-only lists the newest --limit alone.
|
|
332
|
+
include_open: { flag: "include-open", type: "bool", negate: "newest-only" },
|
|
331
333
|
detail: { flag: "detail", enum: ["brief", "full"] },
|
|
332
334
|
},
|
|
333
335
|
list_github_app_repos: {},
|
package/lib/oauth.mjs
CHANGED
|
@@ -156,14 +156,15 @@ export async function browserLogin({ url, io, fetchImpl = globalThis.fetch }) {
|
|
|
156
156
|
authUrl.searchParams.set("code_challenge_method", "S256");
|
|
157
157
|
|
|
158
158
|
io.log(`Opening your browser to sign in…`);
|
|
159
|
-
io.log(`If it doesn't open automatically, visit:\n ${authUrl.toString()}
|
|
159
|
+
io.log(`If it doesn't open automatically, visit:\n ${authUrl.toString()}`);
|
|
160
|
+
io.log("Browser on another machine? Press Ctrl+C and run `login --device`.\n");
|
|
160
161
|
openBrowser(authUrl.toString());
|
|
161
162
|
|
|
162
163
|
try {
|
|
163
164
|
const result = await withTimeout(
|
|
164
165
|
server.waitForCallback(),
|
|
165
166
|
CALLBACK_TIMEOUT_MS,
|
|
166
|
-
"Timed out waiting for the browser sign-in.
|
|
167
|
+
"Timed out waiting for the browser sign-in. Browser on another machine? Run `login --device`."
|
|
167
168
|
);
|
|
168
169
|
if (result.error) {
|
|
169
170
|
throw new CliError(`Sign-in was not completed: ${result.errorDescription || result.error}`);
|