spinuptui 1.3.0-alpha.1 → 1.3.0-alpha.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +32 -1
  2. package/README.md +13 -3
  3. package/package.json +1 -1
  4. package/src/config.ts +25 -0
  5. package/src/index.tsx +26 -38
  6. package/src/lib/cliHome.ts +107 -0
  7. package/src/lib/cliScheduler.ts +630 -0
  8. package/src/lib/flock.ts +51 -0
  9. package/src/lib/heartbeat.test.ts +86 -0
  10. package/src/lib/heartbeat.ts +245 -0
  11. package/src/lib/home.test.ts +102 -0
  12. package/src/lib/home.ts +442 -0
  13. package/src/lib/schedule.ts +156 -0
  14. package/src/lib/scheduler.test.ts +353 -0
  15. package/src/lib/schedulerGit.ts +119 -0
  16. package/src/lib/schedulerInstall.ts +325 -0
  17. package/src/lib/schedulerJobs.ts +290 -0
  18. package/src/lib/schedulerRun.ts +247 -0
  19. package/src/lib/schedulerTick.ts +322 -0
  20. package/src/lib/spinupweb.test.ts +22 -0
  21. package/src/lib/spinupweb.ts +11 -0
  22. package/src/lib/stackCache.test.ts +43 -0
  23. package/src/lib/stackCache.ts +35 -1
  24. package/src/modules/beacon.ts +2 -1
  25. package/src/modules/contract.ts +22 -1
  26. package/src/modules/index.ts +2 -7
  27. package/src/modules/scheduler.ts +159 -0
  28. package/src/ui/App.tsx +19 -1
  29. package/src/ui/Details.tsx +7 -1
  30. package/src/ui/Onboarding.tsx +71 -3
  31. package/src/ui/main.tsx +42 -0
  32. package/src/ui/store.tsx +87 -3
  33. package/src/ui/views/AccountSlugPrompt.tsx +102 -0
  34. package/src/ui/views/Browser.tsx +5 -5
  35. package/src/ui/views/HeartbeatSetup.tsx +284 -0
  36. package/src/ui/views/HomeSync.tsx +299 -0
  37. package/src/ui/views/Modules.tsx +69 -5
  38. package/src/ui/views/SchedulerInstall.tsx +172 -0
  39. package/src/ui/views/Search.tsx +5 -6
  40. package/src/ui/views/ServerActions.tsx +6 -4
  41. package/src/ui/views/Stacks.tsx +22 -9
@@ -16,7 +16,8 @@
16
16
  import { useEffect, useMemo, useRef, useState } from "react"
17
17
  import { useKeyboard } from "@opentui/react"
18
18
  import { theme, statusColor, statusDot } from "../../lib/theme.ts"
19
- import { bar, truncate } from "../../lib/format.ts"
19
+ import { bar, timeAgo, truncate } from "../../lib/format.ts"
20
+ import { isVersionOld } from "../../lib/stackCache.ts"
20
21
  import { STACKS, effectiveStack, stackColor, type Stack } from "../../lib/stack.ts"
21
22
  import { phpSortKey } from "../../lib/phpEol.ts"
22
23
  import { probeKindColor, type ProbeKind } from "../../lib/probe.ts"
@@ -75,7 +76,7 @@ function nonWpSub(kind: ProbeKind | null, vanity: boolean): NonWpSub {
75
76
  export function Stacks({ rows }: { rows: number }) {
76
77
  const store = useStore()
77
78
  const wpCoreJobs = useWpCoreJobs()
78
- const { sites, serverById, route, inputMode, overlayOpen, probes, probingIds, probeErrors, runProbe, runProbeMany, isProbeStale, isPhpEol, accountSlug, setPhpUpgradeSite, setBulkWpGroup, phpUpgrades, setHttpsToggleSite, setPurgeCacheSite, setSiteOfflineSite, setLocalLinkSite, openLocalTerminal, openLocalUrl, localLinks, setDiscoverOpen, setForgottenOpen, setForgottenStack, sshSite, setKumaSite } =
79
+ const { sites, serverById, route, inputMode, overlayOpen, probes, probingIds, probeErrors, runProbe, runProbeMany, isProbeStale, isPhpEol, openInSpinupWP, setPhpUpgradeSite, setBulkWpGroup, phpUpgrades, setHttpsToggleSite, setPurgeCacheSite, setSiteOfflineSite, setLocalLinkSite, openLocalTerminal, openLocalUrl, localLinks, setDiscoverOpen, setForgottenOpen, setForgottenStack, sshSite, setKumaSite } =
79
80
  store
80
81
 
81
82
  const [groupIndex, setGroupIndex] = useState(0)
@@ -218,8 +219,8 @@ export function Stacks({ rows }: { rows: number }) {
218
219
  case "w":
219
220
  // Open the selected site in the SpinupWP web app.
220
221
  if (focus === "sites" && groupSites[siteIndex]) {
221
- openUrl(siteWebUrl(groupSites[siteIndex].id, accountSlug))
222
- flashMsg(accountSlug ? "Opening in SpinupWP…" : "Set accountSlug for deep links — opening dashboard")
222
+ const id = groupSites[siteIndex].id
223
+ if (openInSpinupWP((slug) => siteWebUrl(id, slug))) flashMsg("Opening in SpinupWP…")
223
224
  }
224
225
  return
225
226
  case "d":
@@ -421,11 +422,23 @@ export function Stacks({ rows }: { rows: number }) {
421
422
  ) : vanity ? (
422
423
  <text content="Vanity Site" fg={selected ? theme.text : VANITY_COLOR} wrapMode="none" />
423
424
  ) : cached ? (
424
- <text
425
- content={truncate(cached.result.label, 20) + (isProbeStale(s) ? "*" : "")}
426
- fg={probeKindColor(cached.result.kind, selected)}
427
- wrapMode="none"
428
- />
425
+ <>
426
+ <text
427
+ content={truncate(cached.result.label, 20) + (isProbeStale(s) ? "*" : "")}
428
+ fg={probeKindColor(cached.result.kind, selected)}
429
+ wrapMode="none"
430
+ />
431
+ {/* A version past its re-check age (the background re-probe
432
+ failed or hasn't run) says how old it is, so it can't
433
+ pass for current. */}
434
+ {isVersionOld(cached) && (
435
+ <text
436
+ content={" " + timeAgo(new Date(cached.detectedAt).toISOString()).replace(/ ago$/, "")}
437
+ fg={selected ? theme.text : theme.warn}
438
+ wrapMode="none"
439
+ />
440
+ )}
441
+ </>
429
442
  ) : errored ? (
430
443
  <text content="probe failed" fg={selected ? theme.text : theme.bad} wrapMode="none" />
431
444
  ) : (