@simplepush/cli 0.6.0 → 0.7.0

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/main.mjs CHANGED
@@ -14,7 +14,7 @@ import { mkdir, stat, writeFile } from "node:fs/promises";
14
14
  import { connect, createConnection } from "node:net";
15
15
  import path, { basename, extname, join } from "node:path";
16
16
  //#region package.json
17
- var version = "0.6.0";
17
+ var version = "0.7.0";
18
18
  //#endregion
19
19
  //#region src/errors.ts
20
20
  /** No CLI session saved — `sp auth login` hasn't been run (or was logged out). */
@@ -573,6 +573,46 @@ const quietOption = Options.boolean("quiet").pipe(Options.withAlias("q"), Option
573
573
  /** Shared helper for repeatable validated text options. */
574
574
  const mappedText = (name, parse) => Options.text(name).pipe(Options.mapTryCatch(parse, toHelp));
575
575
  //#endregion
576
+ //#region src/services/browser.ts
577
+ /** The command line that opens `url` on `platform`. Pure, so it can be tested
578
+ * for every platform from one machine. */
579
+ function browserLaunch(platform, url) {
580
+ switch (platform) {
581
+ case "darwin": return {
582
+ command: "open",
583
+ args: [url],
584
+ windowsVerbatimArguments: false
585
+ };
586
+ case "win32": return {
587
+ command: "cmd",
588
+ args: [
589
+ "/c",
590
+ "start",
591
+ "\"\"",
592
+ url.replace(/&/g, "^&")
593
+ ],
594
+ windowsVerbatimArguments: true
595
+ };
596
+ default: return {
597
+ command: "xdg-open",
598
+ args: [url],
599
+ windowsVerbatimArguments: false
600
+ };
601
+ }
602
+ }
603
+ /** Fire-and-forget. A failure to spawn is swallowed: the caller has already
604
+ * printed the URL, so the user can open it by hand. */
605
+ const openInBrowser = (url) => Effect.sync(() => {
606
+ const launch = browserLaunch(process.platform, url);
607
+ try {
608
+ spawn(launch.command, launch.args, {
609
+ detached: true,
610
+ stdio: "ignore",
611
+ windowsVerbatimArguments: launch.windowsVerbatimArguments
612
+ }).unref();
613
+ } catch {}
614
+ });
615
+ //#endregion
576
616
  //#region src/format.ts
577
617
  function formatInstant(iso) {
578
618
  const d = new Date(iso);
@@ -661,21 +701,6 @@ const startCallbackServer = Effect.gen(function* () {
661
701
  awaitCallback: Deferred.await(callback)
662
702
  };
663
703
  });
664
- const openInBrowser = (url) => Effect.sync(() => {
665
- const cmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "cmd" : "xdg-open";
666
- const args = process.platform === "win32" ? [
667
- "/c",
668
- "start",
669
- "",
670
- url
671
- ] : [url];
672
- try {
673
- spawn(cmd, args, {
674
- detached: true,
675
- stdio: "ignore"
676
- }).unref();
677
- } catch {}
678
- });
679
704
  function preferDeviceFlow() {
680
705
  if (process.env.SP_AUTH_DEVICE === "1") return true;
681
706
  if (process.env.SSH_CONNECTION || process.env.SSH_TTY) return true;
@@ -2476,7 +2501,7 @@ function formatHit(h) {
2476
2501
  return [
2477
2502
  `${h.ref} [${h.kind}] ${h.createdAt}`,
2478
2503
  h.title !== void 0 ? ` ${h.title}` : void 0,
2479
- h.actor !== void 0 ? ` by: ${h.actor}` : void 0,
2504
+ h.actor !== void 0 ? ` by: ${h.actor.name !== void 0 ? `${h.actor.name} (${h.actor.publicId})` : h.actor.publicId}` : void 0,
2480
2505
  h.snippet !== void 0 ? ` ${h.snippet}` : void 0,
2481
2506
  h.location !== void 0 ? ` at: ${h.location.latitude},${h.location.longitude}${h.location.distanceMeters !== void 0 ? ` (${Math.round(h.location.distanceMeters)}m away)` : ""}` : void 0
2482
2507
  ].filter((l) => l !== void 0).join("\n");