@letterstory/cli 0.177.163 → 0.177.165

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 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.163";
96
+ export const VERSION = "0.177.165";
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;
@@ -639,7 +639,7 @@ Usage:
639
639
  ${bin} <command> [args] [--flags]
640
640
 
641
641
  Auth:
642
- 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)
643
643
  login --device [--url <url>] Sign in with one link, opened in any browser (for agents and remote shells)
644
644
  login --key <ls_…> [--url <url>] Save a static API key instead (for CI/automation)
645
645
  signup --email <work email> [--agent <name>] [--url <url>]
@@ -25,7 +25,7 @@
25
25
  // admin letterpress settings|flip|set … (recipes:read / recipes:write)
26
26
  // admin invariants [--org <id>,…] [--limit N] [--presses] (staff)
27
27
  // admin lost-posts [--code lost_guard,lost_provider|held_guard] [--rework] [--days N] [--org <id>] [--limit N] [--apply] (staff)
28
- // admin demo guide|list|show|set|reset|check|ideas … (demo:read / demo:write)
28
+ // admin demo guide|list|show|set|reset|check|ideas|sample … (demo:read / demo:write)
29
29
  // admin deployments [--health down|failing|blocked|setting_up|live|paused|archived] [--org <id>] [--q <text>] [--archived] [--test] [--no-host] (fleet:read)
30
30
  // admin deployments move <app-id> --to <org-id> (--dry-run | --yes) (fleet:onboard)
31
31
  // admin models runs|run|star|unstar|scoreboard|requests|request|sampling … (models:read / models:write)
@@ -7366,7 +7366,7 @@ const DEMO_ITEM_FLAGS = [
7366
7366
  "setup",
7367
7367
  ];
7368
7368
  const DEMO_USAGE =
7369
- "Usage: admin demo guide | list [--enrollable] | show <org-id> [--moves] | set <org-id> [--enroll] [--unenroll] [--file <state.json>] [--phantom parked|shown] [--main-blog …] [--visitors …] [--probes not_run|shown] [--cms hidden|shown] [--publish-target …] [--search-console …] [--github …] [--domain …] [--setup fresh|finished] [--domain-cap n] [--inject <key>]... [--hide <key>]... [--save-as <name>] [--baseline <owner/repo>[@sha] | --clear-baseline] [--copy-from <org-id> [--copy-scenarios a,b] [--overwrite]] [--auto-reset <scenario>|off] [--every <minutes>] [--release] | domains | new <domain> [--name <n>] [--brief <t>] [--full] [--host vercel|pages] [--no-wait] | teardown <org-id> [--keep-repo] | bootstrap <org-id>... --from <org-id> [--scenarios a,b] [--overwrite] | reset <org-id> <scenario> [--clean-slate] [--close-prs since_applied|all_open|none] [--hold <minutes>] [--restore-repo revert|force] [--rebuild] [--reread-company] [--forget-company] [--forget-site] | check <org-id> | ideas <org-id> [--library] [--preview] [--force] | ideas <org-id> --status [--id <run-id>] | sweep [--prepare] [--pull-requests] [--recipes <id>,…] [--variation <n|name>] [--pick <recipe>[:<variation>]]... [--new-org] [--orgs <id>,…] [--exclude <id>,…] [--buy <recipe-id>,…] [--make-orgs] [--no-refit] | sweep --status [--id <sweep-id>] | sweep --reset <recipe-id> [--id <sweep-id>]";
7369
+ "Usage: admin demo guide | list [--enrollable] | show <org-id> [--moves] | set <org-id> [--enroll] [--unenroll] [--file <state.json>] [--phantom parked|shown] [--main-blog …] [--visitors …] [--probes not_run|shown] [--cms hidden|shown] [--publish-target …] [--search-console …] [--github …] [--domain …] [--setup fresh|finished] [--domain-cap n] [--inject <key>]... [--hide <key>]... [--save-as <name>] [--baseline <owner/repo>[@sha] | --clear-baseline] [--copy-from <org-id> [--copy-scenarios a,b] [--overwrite]] [--auto-reset <scenario>|off] [--every <minutes>] [--release] | domains | sample | new <domain> [--name <n>] [--brief <t>] [--full] [--host vercel|pages] [--no-wait] | teardown <org-id> [--keep-repo] | bootstrap <org-id>... --from <org-id> [--scenarios a,b] [--overwrite] | reset <org-id> <scenario> [--clean-slate] [--close-prs since_applied|all_open|none] [--hold <minutes>] [--restore-repo revert|force] [--rebuild] [--reread-company] [--forget-company] [--forget-site] | check <org-id> | ideas <org-id> [--library] [--preview] [--force] | ideas <org-id> --status [--id <run-id>] | sweep [--prepare] [--pull-requests] [--recipes <id>,…] [--variation <n|name>] [--pick <recipe>[:<variation>]]... [--new-org] [--orgs <id>,…] [--exclude <id>,…] [--buy <recipe-id>,…] [--make-orgs] [--no-refit] | sweep --status [--id <sweep-id>] | sweep --reset <recipe-id> [--id <sweep-id>]";
7370
7370
 
7371
7371
  const readinessLines = (r) =>
7372
7372
  r
@@ -7587,6 +7587,17 @@ async function cmdAdminDemo(ctx) {
7587
7587
  );
7588
7588
  return 0;
7589
7589
  }
7590
+ case "sample": {
7591
+ // Acme, the sample org (seed_sample_org): made or refreshed with made-up data dated to end yesterday.
7592
+ const r = await staffPost(ctx, `${DEMO}/sample`, {});
7593
+ printResult(io, flags, r, (x) =>
7594
+ [
7595
+ `${x.name} (${x.domain}) ${x.created ? "made" : "refreshed"}: ${x.org_id}`,
7596
+ ...Object.entries(x.counts).map(([what, n]) => ` ${what}: ${n}`),
7597
+ ].join("\n")
7598
+ );
7599
+ return 0;
7600
+ }
7590
7601
  case "new": {
7591
7602
  // A new demo org on a farm phantom's domain. It takes minutes (Pages' first build, the certificate), so
7592
7603
  // each call works for a bounded time and says what it waits for; this calls again until done.
@@ -39,10 +39,20 @@ export async function cmdLogin(ctx) {
39
39
  }
40
40
  }
41
41
 
42
- const tokens = flags.device ? await deviceLogin({ url, io }) : await browserLogin({ url, io });
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/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()}\n`);
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. Please try again."
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}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letterstory/cli",
3
- "version": "0.177.163",
3
+ "version": "0.177.165",
4
4
  "description": "Spin up and manage Letter phantom blogs from your terminal.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",