Add SSH source support with dialstdio and UI components

- Implement SSH dial via stdio for remote connections
- Add sources API and storage layer for managing connection sources
- Add SourcePanel and SshFields web components for SSH configuration
- Update app structure to support source-based connections
- Update handlers and server for new sources endpoint

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
kawaandClaude Haiku 4.5 committed 2026-08-13 10:19:47 +02:00
1 parent 05db8bfeb9
commit 9b354636bb
19 files changed
+1857 -174

No files matched your search

+76 -14
View File
@@ -21,23 +21,39 @@ import (
)
func (s *Server) handleHealth(w http.ResponseWriter, r *http.Request) {
ctx, cancel := context.WithTimeout(r.Context(), 10*time.Second)
ctx, cancel := context.WithTimeout(r.Context(), 45*time.Second)
defer cancel()
body := map[string]any{
"ok": true,
"dockerHost": s.docker.Endpoint,
"packageDir": s.cfg.PackageDir,
"dataDir": s.cfg.DataDir,
"knownHosts": s.hosts.Path(),
"authRequired": s.cfg.Token != "",
}
if v, err := s.docker.Ping(ctx); err != nil {
// Health is also what connects to the selected source on a fresh start, so
// the UI learns straight away when the remembered source is unreachable.
conn, release, err := s.source(ctx)
if err != nil {
selected, _ := s.sources.Get(s.sources.Selected())
body["ok"] = false
body["dockerError"] = err.Error()
} else {
body["dockerVersion"] = v
endpoint := sourceEndpoint(selected)
body["dockerHost"] = endpoint
body["source"] = sourceStatus{
ID: selected.ID, Name: selected.Name, Kind: selected.Kind,
Endpoint: endpoint, Error: err.Error(),
}
writeJSON(w, http.StatusOK, body)
return
}
defer release()
st := conn.status()
body["dockerHost"] = st.Endpoint
body["dockerVersion"] = st.DockerVersion
body["source"] = st
writeJSON(w, http.StatusOK, body)
}
@@ -47,7 +63,14 @@ func (s *Server) handleSource(w http.ResponseWriter, r *http.Request) {
ctx, cancel := context.WithTimeout(r.Context(), 2*time.Minute)
defer cancel()
inv, err := s.docker.Inventory(ctx)
conn, release, err := s.source(ctx)
if err != nil {
s.writeDialError(w, err)
return
}
defer release()
inv, err := conn.docker.Inventory(ctx)
if err != nil {
writeError(w, http.StatusBadGateway, "%v", err)
return
@@ -69,7 +92,14 @@ func (s *Server) handleSourceSizes(w http.ResponseWriter, r *http.Request) {
ctx, cancel := context.WithTimeout(r.Context(), 5*time.Minute)
defer cancel()
sizes, err := s.docker.VolumeSizes(ctx)
conn, release, err := s.source(ctx)
if err != nil {
s.writeDialError(w, err)
return
}
defer release()
sizes, err := conn.docker.VolumeSizes(ctx)
if err != nil {
writeError(w, http.StatusBadGateway, "%v", err)
return
@@ -209,7 +239,14 @@ func (s *Server) handlePreview(w http.ResponseWriter, r *http.Request) {
ctx, cancel := context.WithTimeout(r.Context(), 2*time.Minute)
defer cancel()
inv, err := s.docker.Inventory(ctx)
conn, release, err := s.source(ctx)
if err != nil {
s.writeDialError(w, err)
return
}
defer release()
inv, err := conn.docker.Inventory(ctx)
if err != nil {
writeError(w, http.StatusBadGateway, "%v", err)
return
@@ -299,12 +336,23 @@ func (s *Server) handleMigrateSSH(w http.ResponseWriter, r *http.Request) {
return
}
// The source is held for the whole job: picking another source in the UI
// while this runs must not close the socket it is reading from.
srcCtx, srcCancel := context.WithTimeout(r.Context(), 60*time.Second)
src, release, err := s.source(srcCtx)
srcCancel()
if err != nil {
s.writeDialError(w, err)
return
}
// The inventory is re-read now so the plan is applied to current state
// rather than to whatever the browser last loaded.
invCtx, cancel := context.WithTimeout(r.Context(), 2*time.Minute)
inv, err := s.docker.Inventory(invCtx)
inv, err := src.docker.Inventory(invCtx)
cancel()
if err != nil {
release()
writeError(w, http.StatusBadGateway, "%v", err)
return
}
@@ -315,13 +363,14 @@ func (s *Server) handleMigrateSSH(w http.ResponseWriter, r *http.Request) {
client, err := sshx.Dial(dialCtx, cfg, s.hosts)
dialCancel()
if err != nil {
release()
s.writeDialError(w, err)
return
}
title := fmt.Sprintf("%d container(s) to %s", countIncluded(req.Plan), cfg.Name)
title := fmt.Sprintf("%d container(s) from %s to %s", countIncluded(req.Plan), src.src.Name, cfg.Name)
runner := &migrate.SSHRunner{
Src: s.docker,
Src: src.docker,
Dst: sshx.NewRemoteDocker(client),
Containers: inv.Containers,
Volumes: inv.Volumes,
@@ -331,8 +380,10 @@ func (s *Server) handleMigrateSSH(w http.ResponseWriter, r *http.Request) {
j := s.jobs.Run(context.Background(), job.KindSSH, title, req.Plan.Options.DryRun,
func(ctx context.Context, j *job.Job) error {
defer release()
defer client.Close()
j.Logf(job.LevelInfo, "", "migrating to %s@%s over ssh", cfg.User, cfg.Host)
j.Logf(job.LevelInfo, "", "migrating from %s to %s@%s over ssh",
src.docker.Endpoint, cfg.User, cfg.Host)
return runner.Run(ctx, j)
})
@@ -362,16 +413,25 @@ func (s *Server) handleBuildPackage(w http.ResponseWriter, r *http.Request) {
return
}
srcCtx, srcCancel := context.WithTimeout(r.Context(), 60*time.Second)
src, release, err := s.source(srcCtx)
srcCancel()
if err != nil {
s.writeDialError(w, err)
return
}
invCtx, cancel := context.WithTimeout(r.Context(), 2*time.Minute)
inv, err := s.docker.Inventory(invCtx)
inv, err := src.docker.Inventory(invCtx)
cancel()
if err != nil {
release()
writeError(w, http.StatusBadGateway, "%v", err)
return
}
packager := &migrate.Packager{
Src: s.docker,
Src: src.docker,
Containers: inv.Containers,
Volumes: inv.Volumes,
Networks: inv.Networks,
@@ -384,6 +444,8 @@ func (s *Server) handleBuildPackage(w http.ResponseWriter, r *http.Request) {
title := fmt.Sprintf("package of %d container(s)", countIncluded(req.Plan))
j := s.jobs.Run(context.Background(), job.KindPackage, title, req.Plan.Options.DryRun,
func(ctx context.Context, j *job.Job) error {
defer release()
j.Logf(job.LevelInfo, "", "reading from %s", src.docker.Endpoint)
res, err := packager.Run(ctx, j)
if err != nil {
return err
+46 -17
View File
@@ -11,9 +11,9 @@ import (
"os"
"path/filepath"
"strings"
"sync"
"time"
"github.com/arescom/dockmv/internal/dkr"
"github.com/arescom/dockmv/internal/job"
"github.com/arescom/dockmv/internal/sshx"
"github.com/arescom/dockmv/internal/store"
@@ -29,23 +29,31 @@ type Config struct {
DataDir string
// PackageDir is where migration packages are written.
PackageDir string
// DockerHost overrides the source daemon address.
// DockerHost overrides the local source daemon address.
DockerHost string
// DockerHostSet reports that DockerHost was given explicitly on the command
// line. It then wins over the source remembered from the last run.
DockerHostSet bool
// UI is the embedded web app; nil disables the UI.
UI fs.FS
// Logger receives request and error logs.
Logger *slog.Logger
}
// Server ties the Docker client, connection store and job manager to HTTP.
// Server ties the source daemon, connection store and job manager to HTTP.
type Server struct {
cfg Config
log *slog.Logger
docker *dkr.Client
conns *store.Connections
hosts *sshx.KnownHosts
jobs *job.Manager
mux *http.ServeMux
cfg Config
log *slog.Logger
sources *store.Sources
conns *store.Connections
hosts *sshx.KnownHosts
jobs *job.Manager
mux *http.ServeMux
// srcMu guards cur, the connection to the selected source. It is opened on
// first use and replaced when the operator picks another source.
srcMu sync.Mutex
cur *sourceConn
}
// New builds the server and everything it owns.
@@ -60,10 +68,6 @@ func New(cfg Config) (*Server, error) {
return nil, fmt.Errorf("create package directory: %w", err)
}
docker, err := dkr.New(cfg.DockerHost)
if err != nil {
return nil, err
}
conns, err := store.NewConnections(filepath.Join(cfg.DataDir, "connections.json"))
if err != nil {
return nil, err
@@ -72,17 +76,35 @@ func New(cfg Config) (*Server, error) {
if err != nil {
return nil, err
}
local := store.Source{Name: "this host", DockerHost: cfg.DockerHost}
if local.DockerHost == "" {
local.DockerHost = os.Getenv("DOCKER_HOST")
}
sources, err := store.NewSources(filepath.Join(cfg.DataDir, "sources.json"), local)
if err != nil {
return nil, err
}
// An explicit --docker-host is an instruction for this run, so it overrides
// the source remembered from the last one.
if cfg.DockerHostSet {
if err := sources.Select(store.LocalSourceID); err != nil {
return nil, err
}
}
s := &Server{
cfg: cfg, log: cfg.Logger, docker: docker,
cfg: cfg, log: cfg.Logger, sources: sources,
conns: conns, hosts: hosts, jobs: job.NewManager(), mux: http.NewServeMux(),
}
s.routes()
return s, nil
}
// Close releases the Docker connection.
func (s *Server) Close() error { return s.docker.Close() }
// Close releases the connection to the current source.
func (s *Server) Close() error {
s.invalidateSource("")
return nil
}
// Handler returns the root HTTP handler.
func (s *Server) Handler() http.Handler {
@@ -96,6 +118,13 @@ func (s *Server) routes() {
m.HandleFunc("GET /api/source", s.handleSource)
m.HandleFunc("GET /api/source/sizes", s.handleSourceSizes)
m.HandleFunc("GET /api/sources", s.handleListSources)
m.HandleFunc("POST /api/sources", s.handleSaveSource)
m.HandleFunc("DELETE /api/sources/{id}", s.handleDeleteSource)
m.HandleFunc("POST /api/sources/{id}/select", s.handleSelectSource)
m.HandleFunc("POST /api/sources/{id}/probe", s.handleSourceProbe)
m.HandleFunc("POST /api/sources/{id}/trust", s.handleSourceTrust)
m.HandleFunc("GET /api/connections", s.handleListConnections)
m.HandleFunc("POST /api/connections", s.handleSaveConnection)
m.HandleFunc("DELETE /api/connections/{id}", s.handleDeleteConnection)
+328
View File
@@ -0,0 +1,328 @@
package api
import (
"context"
"errors"
"fmt"
"net"
"net/http"
"strconv"
"time"
"github.com/arescom/dockmv/internal/dkr"
"github.com/arescom/dockmv/internal/sshx"
"github.com/arescom/dockmv/internal/store"
)
// sourceConn is a live connection to one source daemon.
//
// It is reference counted rather than closed eagerly: a migration holds its
// source for as long as it runs, so switching source in the UI half way through
// a transfer must not pull the socket out from under it. The connection is
// closed once it is both replaced and unused.
type sourceConn struct {
src store.Source
docker *dkr.Client
ssh *sshx.Client
version string
refs int
stale bool
}
func (c *sourceConn) close() {
if c.docker != nil {
_ = c.docker.Close()
}
if c.ssh != nil {
_ = c.ssh.Close()
}
}
// sourceStatus is what the UI shows about the source it is looking at.
type sourceStatus struct {
ID string `json:"id"`
Name string `json:"name"`
Kind store.SourceKind `json:"kind"`
Endpoint string `json:"endpoint"`
DockerVersion string `json:"dockerVersion,omitempty"`
Connected bool `json:"connected"`
Error string `json:"error,omitempty"`
}
func (c *sourceConn) status() sourceStatus {
return sourceStatus{
ID: c.src.ID, Name: c.src.Name, Kind: c.src.Kind,
Endpoint: c.docker.Endpoint, DockerVersion: c.version, Connected: true,
}
}
// source returns the current source, connecting to it on first use. The
// returned release function must be called when the caller is done with it —
// for a job, when the job finishes.
func (s *Server) source(ctx context.Context) (*sourceConn, func(), error) {
s.srcMu.Lock()
if cur := s.cur; cur != nil {
cur.refs++
s.srcMu.Unlock()
return cur, func() { s.releaseSource(cur) }, nil
}
id := s.sources.Selected()
s.srcMu.Unlock()
conn, err := s.dialSource(ctx, id)
if err != nil {
return nil, nil, err
}
s.srcMu.Lock()
defer s.srcMu.Unlock()
// Another request may have connected while this one was dialling; one
// connection is enough, so the loser is dropped.
if s.cur != nil {
conn.close()
conn = s.cur
} else {
s.cur = conn
}
conn.refs++
return conn, func() { s.releaseSource(conn) }, nil
}
func (s *Server) releaseSource(c *sourceConn) {
s.srcMu.Lock()
defer s.srcMu.Unlock()
c.refs--
if c.refs <= 0 && c.stale {
c.close()
}
}
// selectSource connects to a source and, once that worked, makes it the current
// one and records the choice for the next run.
func (s *Server) selectSource(ctx context.Context, id string) (sourceStatus, error) {
conn, err := s.dialSource(ctx, id)
if err != nil {
return sourceStatus{}, err
}
st := conn.status()
s.srcMu.Lock()
old := s.cur
s.cur = conn
if old != nil {
old.stale = true
if old.refs <= 0 {
old.close()
}
}
s.srcMu.Unlock()
if err := s.sources.Select(conn.src.ID); err != nil {
return st, fmt.Errorf("remember the selected source: %w", err)
}
s.log.Info("source selected", "id", conn.src.ID, "endpoint", conn.docker.Endpoint)
return st, nil
}
// invalidateSource drops the cached connection when the source behind it has
// been edited or removed. An empty id invalidates whatever is current.
func (s *Server) invalidateSource(id string) {
s.srcMu.Lock()
defer s.srcMu.Unlock()
if s.cur == nil {
return
}
if id != "" && s.cur.src.ID != id {
return
}
s.cur.stale = true
if s.cur.refs <= 0 {
s.cur.close()
}
s.cur = nil
}
// dialSource opens a connection to one source and verifies the daemon answers.
func (s *Server) dialSource(ctx context.Context, id string) (*sourceConn, error) {
src, err := s.sources.Get(id)
if err != nil {
return nil, err
}
conn := &sourceConn{src: src}
switch src.Kind {
case store.SourceLocal, store.SourceDocker:
c, err := dkr.New(src.DockerHost)
if err != nil {
return nil, err
}
conn.docker = c
case store.SourceSSH:
if src.SSH == nil {
return nil, errors.New("source has no ssh configuration")
}
client, err := sshx.Dial(ctx, *src.SSH, s.hosts)
if err != nil {
return nil, err
}
rd := sshx.NewRemoteDocker(client)
// The CLI is checked first: a missing binary or a user outside the
// docker group is a readable error here, and an unexplained broken
// socket if it is left to the tunnel.
if _, err := rd.ProbeCLI(ctx); err != nil {
client.Close()
return nil, err
}
c, err := dkr.NewTunnel(sourceEndpoint(src), func(ctx context.Context, _, _ string) (net.Conn, error) {
return rd.DialAPI(ctx)
})
if err != nil {
client.Close()
return nil, err
}
conn.ssh, conn.docker = client, c
default:
return nil, fmt.Errorf("unknown source kind %q", src.Kind)
}
pingCtx, cancel := context.WithTimeout(ctx, 30*time.Second)
defer cancel()
version, err := conn.docker.Ping(pingCtx)
if err != nil {
conn.close()
return nil, fmt.Errorf("connect to docker at %s: %w", conn.docker.Endpoint, err)
}
conn.version = version
return conn, nil
}
// sourceEndpoint describes where a source lives, before and after it is
// connected to.
func sourceEndpoint(src store.Source) string {
if src.Kind == store.SourceSSH && src.SSH != nil {
port := src.SSH.Port
if port == 0 {
port = 22
}
return fmt.Sprintf("ssh://%s@%s", src.SSH.User, net.JoinHostPort(src.SSH.Host, strconv.Itoa(port)))
}
return src.DockerHost
}
// handleListSources lists the sources without connecting to any of them; the
// state of the current one comes from /api/health.
func (s *Server) handleListSources(w http.ResponseWriter, r *http.Request) {
s.srcMu.Lock()
var current *sourceStatus
if s.cur != nil {
st := s.cur.status()
current = &st
}
s.srcMu.Unlock()
writeJSON(w, http.StatusOK, map[string]any{
"sources": s.sources.List(),
"selected": s.sources.Selected(),
"current": current,
})
}
func (s *Server) handleSaveSource(w http.ResponseWriter, r *http.Request) {
var src store.Source
if err := decode(r, &src); err != nil {
writeError(w, http.StatusBadRequest, "%v", err)
return
}
saved, err := s.sources.Save(src)
if err != nil {
writeError(w, http.StatusBadRequest, "%v", err)
return
}
// Editing the source in use means the live connection describes the old
// settings; drop it so the next call reconnects.
s.invalidateSource(saved.ID)
writeJSON(w, http.StatusOK, saved)
}
func (s *Server) handleDeleteSource(w http.ResponseWriter, r *http.Request) {
id := r.PathValue("id")
if err := s.sources.Delete(id); err != nil {
if errors.Is(err, store.ErrNotFound) {
writeError(w, http.StatusNotFound, "%v", err)
return
}
writeError(w, http.StatusBadRequest, "%v", err)
return
}
s.invalidateSource(id)
w.WriteHeader(http.StatusNoContent)
}
// handleSelectSource switches the source the whole UI works against.
func (s *Server) handleSelectSource(w http.ResponseWriter, r *http.Request) {
ctx, cancel := context.WithTimeout(r.Context(), 60*time.Second)
defer cancel()
st, err := s.selectSource(ctx, r.PathValue("id"))
if err != nil {
s.writeDialError(w, err)
return
}
writeJSON(w, http.StatusOK, st)
}
// handleSourceProbe reads the SSH host key of a source host, so its fingerprint
// can be approved the same way a target's is.
func (s *Server) handleSourceProbe(w http.ResponseWriter, r *http.Request) {
cfg, err := s.sourceSSH(r.PathValue("id"))
if err != nil {
writeError(w, http.StatusNotFound, "%v", err)
return
}
ctx, cancel := context.WithTimeout(r.Context(), 30*time.Second)
defer cancel()
info, err := sshx.Probe(ctx, cfg, s.hosts)
if err != nil {
writeError(w, http.StatusBadGateway, "%v", err)
return
}
writeJSON(w, http.StatusOK, info)
}
func (s *Server) handleSourceTrust(w http.ResponseWriter, r *http.Request) {
cfg, err := s.sourceSSH(r.PathValue("id"))
if err != nil {
writeError(w, http.StatusNotFound, "%v", err)
return
}
var body struct {
Fingerprint string `json:"fingerprint"`
}
if err := decode(r, &body); err != nil {
writeError(w, http.StatusBadRequest, "%v", err)
return
}
ctx, cancel := context.WithTimeout(r.Context(), 30*time.Second)
defer cancel()
if err := sshx.TrustFromProbe(ctx, cfg, s.hosts, body.Fingerprint); err != nil {
writeError(w, http.StatusBadRequest, "%v", err)
return
}
writeJSON(w, http.StatusOK, map[string]any{"trusted": true})
}
// sourceSSH returns the SSH configuration of a source, refusing the ones that
// are not reached over SSH.
func (s *Server) sourceSSH(id string) (sshx.Config, error) {
src, err := s.sources.Get(id)
if err != nil {
return sshx.Config{}, err
}
if src.Kind != store.SourceSSH || src.SSH == nil {
return sshx.Config{}, fmt.Errorf("source %s is not reached over ssh", src.Name)
}
return *src.SSH, nil
}
+40
View File
@@ -6,6 +6,9 @@ package dkr
import (
"context"
"fmt"
"net"
"net/http"
"time"
"github.com/docker/docker/api/types/system"
"github.com/docker/docker/client"
@@ -33,6 +36,43 @@ func New(host string) (*Client, error) {
return &Client{api: api, Endpoint: api.DaemonHost()}, nil
}
// Dialer opens one connection to a daemon's API socket.
type Dialer func(ctx context.Context, network, addr string) (net.Conn, error)
// NewTunnel connects to a daemon that is only reachable through dial, such as a
// remote daemon behind an SSH connection. The HTTP host is a placeholder: every
// connection comes from dial, so the address is never resolved.
//
// endpoint is what the UI displays, e.g. ssh://root@10.0.0.5.
func NewTunnel(endpoint string, dial Dialer) (*Client, error) {
// The transport is ours so that WithHost cannot leave a TCP dialer or the
// environment's HTTP proxy in place; either would send API calls somewhere
// other than through the tunnel.
tr := &http.Transport{
DisableCompression: true,
// Every connection through the tunnel costs one SSH channel, and sshd
// allows ten per connection by default (MaxSessions). Capping the pool
// keeps a parallel migration from exhausting them; extra calls wait.
MaxConnsPerHost: 8,
MaxIdleConnsPerHost: 4,
IdleConnTimeout: 5 * time.Minute,
}
api, err := client.NewClientWithOpts(
client.WithHTTPClient(&http.Client{Transport: tr}),
client.WithHost("http://docker.tunnel.invalid"),
client.WithAPIVersionNegotiation(),
)
if err != nil {
return nil, fmt.Errorf("create docker client: %w", err)
}
tr.Proxy = nil
tr.DialContext = dial
if endpoint == "" {
endpoint = "tunnel"
}
return &Client{api: api, Endpoint: endpoint}, nil
}
// API exposes the underlying SDK client for callers that need an operation
// this package does not wrap.
func (c *Client) API() *client.Client { return c.api }
+170
View File
@@ -0,0 +1,170 @@
package sshx
import (
"bytes"
"context"
"errors"
"fmt"
"io"
"net"
"strings"
"sync"
"time"
"golang.org/x/crypto/ssh"
)
// DialAPI opens one connection to the remote daemon's API by running
// `docker system dial-stdio` over SSH and treating that session's stdin and
// stdout as a socket. It is the same mechanism `docker -H ssh://…` uses, so the
// remote host still needs nothing but sshd and the docker CLI.
//
// The returned connection is what dkr.NewTunnel dials through: from there on the
// whole Docker Engine API — inventory, archive streams, image save — is
// available on a remote source host exactly as it is on a local one.
func (r *RemoteDocker) DialAPI(ctx context.Context) (net.Conn, error) {
sess, err := r.c.conn.NewSession()
if err != nil {
return nil, fmt.Errorf("open ssh session: %w", err)
}
stdin, err := sess.StdinPipe()
if err != nil {
sess.Close()
return nil, fmt.Errorf("attach to remote stdin: %w", err)
}
stdout, err := sess.StdoutPipe()
if err != nil {
sess.Close()
return nil, fmt.Errorf("attach to remote stdout: %w", err)
}
errBuf := &syncBuffer{}
sess.Stderr = errBuf
cmd := r.Cmd("system", "dial-stdio")
if err := sess.Start(cmd); err != nil {
sess.Close()
return nil, fmt.Errorf("start %q: %w", cmd, err)
}
cfg := r.c.Config()
// The connection deliberately outlives ctx: the HTTP transport keeps it in
// its idle pool between API calls, and closes it itself when a request is
// cancelled or the client is closed.
return &apiConn{
sess: sess, stdin: stdin, stdout: stdout, stderr: errBuf,
remote: apiAddr(fmt.Sprintf("%s@%s", cfg.User, cfg.addr())),
}, nil
}
// ProbeCLI checks that the remote docker CLI is usable before the API is
// tunnelled through it, so a missing binary or a permission problem is reported
// as itself rather than as a broken socket. It returns the daemon version.
func (r *RemoteDocker) ProbeCLI(ctx context.Context) (string, error) {
out, ok, err := r.Try(ctx, "version", "--format", "{{.Server.Version}}")
if err != nil {
return "", err
}
if ok {
if v := strings.TrimSpace(out); v != "" {
return v, nil
}
}
res, err := r.c.Run(ctx, r.Cmd("version"))
if err != nil {
return "", err
}
msg := strings.TrimSpace(res.Stderr)
switch {
case strings.Contains(msg, "permission denied"):
return "", errors.New("the login user cannot talk to the docker daemon; " +
"add it to the docker group, or enable sudo -n for this source")
case msg != "":
return "", errors.New("docker is not usable on that host: " + firstLine(msg))
default:
return "", errors.New("docker is not installed or not on PATH on that host")
}
}
// apiConn adapts an SSH session to net.Conn.
type apiConn struct {
sess *ssh.Session
stdin io.WriteCloser
stdout io.Reader
stderr *syncBuffer
remote apiAddr
once sync.Once
err error
}
func (c *apiConn) Read(p []byte) (int, error) {
n, err := c.stdout.Read(p)
if err != nil {
return n, c.wrap(err)
}
return n, nil
}
func (c *apiConn) Write(p []byte) (int, error) {
n, err := c.stdin.Write(p)
if err != nil {
return n, c.wrap(err)
}
return n, nil
}
// wrap replaces the bare EOF a failed remote command produces with whatever it
// printed on stderr, which is the only place the reason appears.
func (c *apiConn) wrap(err error) error {
if msg := strings.TrimSpace(c.stderr.String()); msg != "" {
return fmt.Errorf("docker system dial-stdio on the remote host failed: %s", firstLine(msg))
}
return err
}
func (c *apiConn) Close() error {
c.once.Do(func() {
// Closing stdin lets the remote docker exit cleanly; the session is torn
// down straight after either way.
_ = c.stdin.Close()
c.err = c.sess.Close()
if errors.Is(c.err, io.EOF) {
c.err = nil
}
})
return c.err
}
func (c *apiConn) LocalAddr() net.Addr { return apiAddr("dockmv") }
func (c *apiConn) RemoteAddr() net.Addr { return c.remote }
// The deadline calls are no-ops: an SSH channel has no deadline of its own, and
// the Docker client relies on context cancellation rather than on these. This
// mirrors what the docker CLI's own ssh:// transport does.
func (c *apiConn) SetDeadline(time.Time) error { return nil }
func (c *apiConn) SetReadDeadline(time.Time) error { return nil }
func (c *apiConn) SetWriteDeadline(time.Time) error { return nil }
type apiAddr string
func (a apiAddr) Network() string { return "ssh" }
func (a apiAddr) String() string { return string(a) }
// syncBuffer collects remote stderr, which the ssh session writes from its own
// goroutine while the connection is being read.
type syncBuffer struct {
mu sync.Mutex
buf bytes.Buffer
}
func (b *syncBuffer) Write(p []byte) (int, error) {
b.mu.Lock()
defer b.mu.Unlock()
return b.buf.Write(p)
}
func (b *syncBuffer) String() string {
b.mu.Lock()
defer b.mu.Unlock()
return b.buf.String()
}
+79
View File
@@ -0,0 +1,79 @@
package sshx
import (
"errors"
"io"
"net"
"strings"
"testing"
"time"
)
// TestDialAPICommand pins the command the tunnel runs on the source host: it is
// the same one `docker -H ssh://…` uses, and the sudo / custom binary settings
// have to reach it.
func TestDialAPICommand(t *testing.T) {
for _, tc := range []struct {
name string
rd *RemoteDocker
want string
}{
{"plain", &RemoteDocker{binary: "docker"}, "docker system dial-stdio"},
{"sudo", &RemoteDocker{binary: "docker", sudo: true}, "sudo -n docker system dial-stdio"},
{"podman", &RemoteDocker{binary: "podman"}, "podman system dial-stdio"},
{"path with a space", &RemoteDocker{binary: "/opt/my docker/bin/docker"}, "'/opt/my docker/bin/docker' system dial-stdio"},
} {
t.Run(tc.name, func(t *testing.T) {
if got := tc.rd.Cmd("system", "dial-stdio"); got != tc.want {
t.Fatalf("command = %q, want %q", got, tc.want)
}
})
}
}
// TestAPIConnSurfacesRemoteStderr covers the failure that would otherwise reach
// the Docker client as a bare EOF: the remote docker printing a reason and
// exiting.
func TestAPIConnSurfacesRemoteStderr(t *testing.T) {
errBuf := &syncBuffer{}
errBuf.Write([]byte("docker: 'system dial-stdio' is not a docker command\n"))
c := &apiConn{
stdout: strings.NewReader(""),
stdin: nopWriteCloser{io.Discard},
stderr: errBuf,
}
_, err := c.Read(make([]byte, 8))
if err == nil {
t.Fatal("a closed stream with remote stderr should be an error")
}
if !strings.Contains(err.Error(), "is not a docker command") {
t.Fatalf("error = %v, want the remote stderr in it", err)
}
// Without stderr the plain EOF must survive, or the HTTP transport cannot
// tell a finished response from a broken one.
quiet := &apiConn{stdout: strings.NewReader(""), stdin: nopWriteCloser{io.Discard}, stderr: &syncBuffer{}}
if _, err := quiet.Read(make([]byte, 8)); !errors.Is(err, io.EOF) {
t.Fatalf("error = %v, want io.EOF", err)
}
}
func TestAPIConnDeadlinesAreNoops(t *testing.T) {
var c net.Conn = &apiConn{stdout: strings.NewReader(""), stdin: nopWriteCloser{io.Discard}, stderr: &syncBuffer{}}
now := time.Now()
if err := c.SetDeadline(now); err != nil {
t.Fatalf("SetDeadline: %v", err)
}
if err := c.SetReadDeadline(now); err != nil {
t.Fatalf("SetReadDeadline: %v", err)
}
if err := c.SetWriteDeadline(now); err != nil {
t.Fatalf("SetWriteDeadline: %v", err)
}
if c.RemoteAddr().Network() != "ssh" {
t.Fatalf("network = %q, want ssh", c.RemoteAddr().Network())
}
}
type nopWriteCloser struct{ io.Writer }
func (nopWriteCloser) Close() error { return nil }
+315
View File
@@ -0,0 +1,315 @@
package store
import (
"encoding/json"
"errors"
"fmt"
"os"
"path/filepath"
"sort"
"strings"
"sync"
"github.com/arescom/dockmv/internal/sshx"
)
// SourceKind says how a source daemon is reached.
type SourceKind string
const (
// SourceLocal is the daemon this process talks to by default: the socket in
// DOCKER_HOST, or whatever --docker-host was given.
SourceLocal SourceKind = "local"
// SourceDocker is an explicit daemon address, e.g. tcp://10.0.0.5:2375.
SourceDocker SourceKind = "docker"
// SourceSSH is a remote daemon reached over SSH, driven through the remote
// host's own docker CLI.
SourceSSH SourceKind = "ssh"
)
// LocalSourceID identifies the built-in local source. It is always listed, and
// cannot be edited or deleted.
const LocalSourceID = "local"
// Source is one place containers can be read from.
type Source struct {
ID string `json:"id"`
Name string `json:"name"`
Kind SourceKind `json:"kind"`
// DockerHost is the daemon address for SourceDocker, and the address the
// local source resolved to for SourceLocal (read-only in that case).
DockerHost string `json:"dockerHost,omitempty"`
// SSH describes the remote host for SourceSSH.
SSH *sshx.Config `json:"ssh,omitempty"`
}
// Sources is a JSON-backed list of source daemons plus the one currently
// selected, so a restart comes back to the host the operator was working on.
//
// Like Connections, SSH credentials only reach the file when the operator ticks
// "remember"; otherwise they live in memory for this process only.
type Sources struct {
path string
local Source
mu sync.RWMutex
items map[string]Source
secrets map[string]secret
selected string
}
// sourcesFile is the on-disk shape.
type sourcesFile struct {
Selected string `json:"selected,omitempty"`
Sources []Source `json:"sources"`
}
// NewSources loads (or creates) the source file at path. local describes the
// built-in local source, which is not persisted.
func NewSources(path string, local Source) (*Sources, error) {
local.ID = LocalSourceID
local.Kind = SourceLocal
if local.Name == "" {
local.Name = "this host"
}
s := &Sources{
path: path, local: local,
items: map[string]Source{}, secrets: map[string]secret{},
selected: LocalSourceID,
}
if err := os.MkdirAll(filepath.Dir(path), 0o700); err != nil {
return nil, fmt.Errorf("create data directory: %w", err)
}
b, err := os.ReadFile(path)
if errors.Is(err, os.ErrNotExist) {
return s, nil
}
if err != nil {
return nil, fmt.Errorf("read sources: %w", err)
}
var f sourcesFile
if err := json.Unmarshal(b, &f); err != nil {
return nil, fmt.Errorf("parse sources file %s: %w", path, err)
}
for _, src := range f.Sources {
if src.ID == "" || src.ID == LocalSourceID {
continue
}
s.items[src.ID] = src
}
if f.Selected != "" {
if _, ok := s.items[f.Selected]; ok || f.Selected == LocalSourceID {
s.selected = f.Selected
}
}
return s, nil
}
// Local returns the built-in local source.
func (s *Sources) Local() Source { return s.local }
// List returns the local source followed by the saved ones, credentials
// stripped, in name order.
func (s *Sources) List() []Source {
s.mu.RLock()
defer s.mu.RUnlock()
out := make([]Source, 0, len(s.items)+1)
for _, src := range s.items {
out = append(out, redactSource(src))
}
sort.Slice(out, func(i, j int) bool { return out[i].Name < out[j].Name })
return append([]Source{s.local}, out...)
}
// Get returns a source ready to connect to, with credentials filled back in.
func (s *Sources) Get(id string) (Source, error) {
if id == "" || id == LocalSourceID {
return s.local, nil
}
s.mu.RLock()
defer s.mu.RUnlock()
src, ok := s.items[id]
if !ok {
return Source{}, ErrNotFound
}
if src.SSH != nil {
cfg := *src.SSH
if sec, ok := s.secrets[id]; ok {
if cfg.Password == "" {
cfg.Password = sec.Password
}
if cfg.PrivateKey == "" {
cfg.PrivateKey = sec.PrivateKey
}
if cfg.Passphrase == "" {
cfg.Passphrase = sec.Passphrase
}
}
src.SSH = &cfg
}
return src, nil
}
// Selected returns the id of the current source, falling back to the local one.
func (s *Sources) Selected() string {
s.mu.RLock()
defer s.mu.RUnlock()
return s.selected
}
// Select records which source is in use. It does not connect: that is the
// caller's job, so a selection is only stored once it has been shown to work.
func (s *Sources) Select(id string) error {
if id == "" {
id = LocalSourceID
}
s.mu.Lock()
defer s.mu.Unlock()
if id != LocalSourceID {
if _, ok := s.items[id]; !ok {
return ErrNotFound
}
}
if s.selected == id {
return nil
}
s.selected = id
return s.flush()
}
// Save inserts or updates a source and returns the stored, redacted form.
//
// As with connections, an update that omits credentials keeps the ones already
// held, so a source can be edited without re-entering a password.
func (s *Sources) Save(src Source) (Source, error) {
if src.ID == LocalSourceID {
return Source{}, errors.New("the local source cannot be edited")
}
switch src.Kind {
case SourceDocker:
src.DockerHost = strings.TrimSpace(src.DockerHost)
if src.DockerHost == "" {
return Source{}, errors.New("a docker address is required, e.g. tcp://10.0.0.5:2375")
}
if !strings.Contains(src.DockerHost, "://") {
return Source{}, fmt.Errorf("%q is not a docker address; it needs a scheme, e.g. tcp://%s",
src.DockerHost, src.DockerHost)
}
src.SSH = nil
if src.Name == "" {
src.Name = src.DockerHost
}
case SourceSSH:
if src.SSH == nil || src.SSH.Host == "" {
return Source{}, errors.New("host is required")
}
if src.SSH.User == "" {
return Source{}, errors.New("user is required")
}
if src.SSH.Port == 0 {
src.SSH.Port = 22
}
src.DockerHost = ""
if src.Name == "" {
src.Name = src.SSH.Host
}
case SourceLocal:
return Source{}, errors.New("there is only one local source")
default:
return Source{}, fmt.Errorf("unknown source kind %q", src.Kind)
}
s.mu.Lock()
defer s.mu.Unlock()
if src.ID == "" {
src.ID = newID()
}
if src.SSH != nil {
prev := s.items[src.ID]
prevSecret := s.secrets[src.ID]
var prevSSH sshx.Config
if prev.SSH != nil {
prevSSH = *prev.SSH
}
if src.SSH.Password == "" {
src.SSH.Password = firstNonEmpty(prevSSH.Password, prevSecret.Password)
}
if src.SSH.PrivateKey == "" {
src.SSH.PrivateKey = firstNonEmpty(prevSSH.PrivateKey, prevSecret.PrivateKey)
}
if src.SSH.Passphrase == "" {
src.SSH.Passphrase = firstNonEmpty(prevSSH.Passphrase, prevSecret.Passphrase)
}
// The SSH id is only meaningful inside the source that owns it.
src.SSH.ID = src.ID
src.SSH.Name = src.Name
if src.SSH.SaveSecrets {
delete(s.secrets, src.ID)
s.items[src.ID] = src
} else {
s.secrets[src.ID] = secret{
Password: src.SSH.Password,
PrivateKey: src.SSH.PrivateKey,
Passphrase: src.SSH.Passphrase,
}
s.items[src.ID] = redactSource(src)
}
} else {
s.items[src.ID] = src
}
if err := s.flush(); err != nil {
return Source{}, err
}
return redactSource(s.items[src.ID]), nil
}
// Delete removes a source, falling back to the local one when the source being
// removed is the selected one.
func (s *Sources) Delete(id string) error {
if id == LocalSourceID {
return errors.New("the local source cannot be deleted")
}
s.mu.Lock()
defer s.mu.Unlock()
if _, ok := s.items[id]; !ok {
return ErrNotFound
}
delete(s.items, id)
delete(s.secrets, id)
if s.selected == id {
s.selected = LocalSourceID
}
return s.flush()
}
// flush writes the file. The caller must hold the write lock.
func (s *Sources) flush() error {
f := sourcesFile{Selected: s.selected, Sources: make([]Source, 0, len(s.items))}
for _, src := range s.items {
f.Sources = append(f.Sources, src)
}
sort.Slice(f.Sources, func(i, j int) bool { return f.Sources[i].ID < f.Sources[j].ID })
b, err := json.MarshalIndent(f, "", " ")
if err != nil {
return err
}
tmp := s.path + ".tmp"
if err := os.WriteFile(tmp, b, 0o600); err != nil {
return fmt.Errorf("write sources: %w", err)
}
if err := os.Rename(tmp, s.path); err != nil {
return fmt.Errorf("replace sources file: %w", err)
}
return nil
}
func redactSource(src Source) Source {
if src.SSH != nil {
cfg := redact(*src.SSH)
src.SSH = &cfg
}
return src
}
+202
View File
@@ -0,0 +1,202 @@
package store
import (
"errors"
"os"
"path/filepath"
"strings"
"testing"
"github.com/arescom/dockmv/internal/sshx"
)
func newTestSources(t *testing.T) (*Sources, string) {
t.Helper()
path := filepath.Join(t.TempDir(), "sources.json")
s, err := NewSources(path, Source{Name: "this host", DockerHost: "unix:///var/run/docker.sock"})
if err != nil {
t.Fatalf("NewSources: %v", err)
}
return s, path
}
func TestSourcesLocalIsAlwaysPresent(t *testing.T) {
s, _ := newTestSources(t)
list := s.List()
if len(list) != 1 || list[0].ID != LocalSourceID || list[0].Kind != SourceLocal {
t.Fatalf("expected only the local source, got %+v", list)
}
if got := s.Selected(); got != LocalSourceID {
t.Fatalf("selected = %q, want %q", got, LocalSourceID)
}
if _, err := s.Save(Source{ID: LocalSourceID, Kind: SourceDocker, DockerHost: "tcp://x:2375"}); err == nil {
t.Fatal("editing the local source should be refused")
}
if err := s.Delete(LocalSourceID); err == nil {
t.Fatal("deleting the local source should be refused")
}
}
func TestSourcesValidation(t *testing.T) {
s, _ := newTestSources(t)
for _, tc := range []struct {
name string
src Source
want string
}{
{"no docker address", Source{Kind: SourceDocker}, "docker address is required"},
{"address without scheme", Source{Kind: SourceDocker, DockerHost: "10.0.0.5:2375"}, "needs a scheme"},
{"ssh without host", Source{Kind: SourceSSH, SSH: &sshx.Config{User: "root"}}, "host is required"},
{"ssh without user", Source{Kind: SourceSSH, SSH: &sshx.Config{Host: "h"}}, "user is required"},
{"unknown kind", Source{Kind: "carrier-pigeon"}, "unknown source kind"},
} {
t.Run(tc.name, func(t *testing.T) {
if _, err := s.Save(tc.src); err == nil || !strings.Contains(err.Error(), tc.want) {
t.Fatalf("error = %v, want it to mention %q", err, tc.want)
}
})
}
}
func TestSourcesSaveDefaults(t *testing.T) {
s, _ := newTestSources(t)
saved, err := s.Save(Source{Kind: SourceSSH, SSH: &sshx.Config{Host: "10.0.0.9", User: "root"}})
if err != nil {
t.Fatalf("Save: %v", err)
}
if saved.ID == "" {
t.Fatal("an id should have been generated")
}
if saved.Name != "10.0.0.9" {
t.Fatalf("name = %q, want the host as a fallback", saved.Name)
}
if saved.SSH.Port != 22 {
t.Fatalf("port = %d, want 22", saved.SSH.Port)
}
// A docker source drops any ssh configuration, and the other way round.
dock, err := s.Save(Source{Kind: SourceDocker, DockerHost: "tcp://10.0.0.5:2375", SSH: &sshx.Config{Host: "x", User: "y"}})
if err != nil {
t.Fatalf("Save: %v", err)
}
if dock.SSH != nil {
t.Fatalf("ssh configuration should be dropped for a docker source: %+v", dock.SSH)
}
if dock.Name != "tcp://10.0.0.5:2375" {
t.Fatalf("name = %q, want the address as a fallback", dock.Name)
}
}
func TestSourcesSecretsStayOffDiskUnlessAsked(t *testing.T) {
s, path := newTestSources(t)
kept, err := s.Save(Source{
Kind: SourceSSH,
SSH: &sshx.Config{Host: "h1", User: "root", Auth: sshx.AuthPassword, Password: "in-memory"},
})
if err != nil {
t.Fatalf("Save: %v", err)
}
if kept.SSH.Password != "" {
t.Fatal("the returned form must be redacted")
}
if lst := s.List(); lst[1].SSH.Password != "" {
t.Fatal("List must not hand out credentials")
}
// Get is the dialling path, so it does see the password.
got, err := s.Get(kept.ID)
if err != nil || got.SSH.Password != "in-memory" {
t.Fatalf("Get password = %q (err %v), want the in-memory secret", got.SSH.Password, err)
}
remembered, err := s.Save(Source{
Kind: SourceSSH,
SSH: &sshx.Config{Host: "h2", User: "root", Auth: sshx.AuthPassword, Password: "on-disk", SaveSecrets: true},
})
if err != nil {
t.Fatalf("Save: %v", err)
}
b, err := os.ReadFile(path)
if err != nil {
t.Fatalf("read file: %v", err)
}
if strings.Contains(string(b), "in-memory") {
t.Fatal("a secret the operator did not want persisted reached the disk")
}
if !strings.Contains(string(b), "on-disk") {
t.Fatal("a remembered secret should have been written")
}
// An update that omits the password keeps the one already held.
again, err := s.Save(Source{ID: remembered.ID, Kind: SourceSSH, SSH: &sshx.Config{Host: "h2", User: "admin", SaveSecrets: true}})
if err != nil {
t.Fatalf("Save: %v", err)
}
reloaded, err := s.Get(again.ID)
if err != nil {
t.Fatalf("Get: %v", err)
}
if reloaded.SSH.Password != "on-disk" {
t.Fatalf("password = %q, want it carried forward", reloaded.SSH.Password)
}
if reloaded.SSH.User != "admin" {
t.Fatalf("user = %q, want the update to apply", reloaded.SSH.User)
}
}
func TestSourcesSelectionSurvivesRestart(t *testing.T) {
s, path := newTestSources(t)
saved, err := s.Save(Source{Name: "prod", Kind: SourceSSH, SSH: &sshx.Config{Host: "10.0.0.9", User: "root", SaveSecrets: true}})
if err != nil {
t.Fatalf("Save: %v", err)
}
if err := s.Select("nope"); !errors.Is(err, ErrNotFound) {
t.Fatalf("Select of an unknown id = %v, want ErrNotFound", err)
}
if err := s.Select(saved.ID); err != nil {
t.Fatalf("Select: %v", err)
}
reopened, err := NewSources(path, Source{Name: "this host"})
if err != nil {
t.Fatalf("NewSources: %v", err)
}
if got := reopened.Selected(); got != saved.ID {
t.Fatalf("selected after restart = %q, want %q", got, saved.ID)
}
if len(reopened.List()) != 2 {
t.Fatalf("sources after restart = %+v", reopened.List())
}
// Deleting the selected source falls back to the local one.
if err := reopened.Delete(saved.ID); err != nil {
t.Fatalf("Delete: %v", err)
}
if got := reopened.Selected(); got != LocalSourceID {
t.Fatalf("selected after delete = %q, want %q", got, LocalSourceID)
}
if _, err := reopened.Get(saved.ID); !errors.Is(err, ErrNotFound) {
t.Fatalf("Get after delete = %v, want ErrNotFound", err)
}
}
func TestSourcesUnknownSelectionIgnoredOnLoad(t *testing.T) {
dir := t.TempDir()
path := filepath.Join(dir, "sources.json")
body := `{"selected":"gone","sources":[{"id":"gone-too","name":"x","kind":"docker","dockerHost":"tcp://h:2375"}]}`
if err := os.WriteFile(path, []byte(body), 0o600); err != nil {
t.Fatalf("write: %v", err)
}
s, err := NewSources(path, Source{Name: "this host"})
if err != nil {
t.Fatalf("NewSources: %v", err)
}
if got := s.Selected(); got != LocalSourceID {
t.Fatalf("selected = %q, want the local fallback", got)
}
}
-11
View File
@@ -1,11 +0,0 @@
(function(){const N=document.createElement("link").relList;if(N&&N.supports&&N.supports("modulepreload"))return;for(const _ of document.querySelectorAll('link[rel="modulepreload"]'))s(_);new MutationObserver(_=>{for(const H of _)if(H.type==="childList")for(const E of H.addedNodes)E.tagName==="LINK"&&E.rel==="modulepreload"&&s(E)}).observe(document,{childList:!0,subtree:!0});function O(_){const H={};return _.integrity&&(H.integrity=_.integrity),_.referrerPolicy&&(H.referrerPolicy=_.referrerPolicy),_.crossOrigin==="use-credentials"?H.credentials="include":_.crossOrigin==="anonymous"?H.credentials="omit":H.credentials="same-origin",H}function s(_){if(_.ep)return;_.ep=!0;const H=O(_);fetch(_.href,H)}})();var mf={exports:{}},_n={};var Ar;function cy(){if(Ar)return _n;Ar=1;var h=Symbol.for("react.transitional.element"),N=Symbol.for("react.fragment");function O(s,_,H){var E=null;if(H!==void 0&&(E=""+H),_.key!==void 0&&(E=""+_.key),"key"in _){H={};for(var k in _)k!=="key"&&(H[k]=_[k])}else H=_;return _=H.ref,{$$typeof:h,type:s,key:E,ref:_!==void 0?_:null,props:H}}return _n.Fragment=N,_n.jsx=O,_n.jsxs=O,_n}var Nr;function fy(){return Nr||(Nr=1,mf.exports=cy()),mf.exports}var c=fy(),yf={exports:{}},w={};var _r;function sy(){if(_r)return w;_r=1;var h=Symbol.for("react.transitional.element"),N=Symbol.for("react.portal"),O=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),_=Symbol.for("react.profiler"),H=Symbol.for("react.consumer"),E=Symbol.for("react.context"),k=Symbol.for("react.forward_ref"),D=Symbol.for("react.suspense"),g=Symbol.for("react.memo"),J=Symbol.for("react.lazy"),A=Symbol.for("react.activity"),B=Symbol.iterator;function dl(d){return d===null||typeof d!="object"?null:(d=B&&d[B]||d["@@iterator"],typeof d=="function"?d:null)}var yl={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},il=Object.assign,Xl={};function El(d,x,R){this.props=d,this.context=x,this.refs=Xl,this.updater=R||yl}El.prototype.isReactComponent={},El.prototype.setState=function(d,x){if(typeof d!="object"&&typeof d!="function"&&d!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,d,x,"setState")},El.prototype.forceUpdate=function(d){this.updater.enqueueForceUpdate(this,d,"forceUpdate")};function Al(){}Al.prototype=El.prototype;function rl(d,x,R){this.props=d,this.context=x,this.refs=Xl,this.updater=R||yl}var xl=rl.prototype=new Al;xl.constructor=rl,il(xl,El.prototype),xl.isPureReactComponent=!0;var Dl=Array.isArray;function _l(){}var U={H:null,A:null,T:null,S:null},Q=Object.prototype.hasOwnProperty;function q(d,x,R){var Y=R.ref;return{$$typeof:h,type:d,key:x,ref:Y!==void 0?Y:null,props:R}}function $(d,x){return q(d.type,x,d.props)}function cl(d){return typeof d=="object"&&d!==null&&d.$$typeof===h}function hl(d){var x={"=":"=0",":":"=2"};return"$"+d.replace(/[=:]/g,function(R){return x[R]})}var Pl=/\/+/g;function Zl(d,x){return typeof d=="object"&&d!==null&&d.key!=null?hl(""+d.key):x.toString(36)}function Ll(d){switch(d.status){case"fulfilled":return d.value;case"rejected":throw d.reason;default:switch(typeof d.status=="string"?d.then(_l,_l):(d.status="pending",d.then(function(x){d.status==="pending"&&(d.status="fulfilled",d.value=x)},function(x){d.status==="pending"&&(d.status="rejected",d.reason=x)})),d.status){case"fulfilled":return d.value;case"rejected":throw d.reason}}throw d}function p(d,x,R,Y,W){var P=typeof d;(P==="undefined"||P==="boolean")&&(d=null);var ml=!1;if(d===null)ml=!0;else switch(P){case"bigint":case"string":case"number":ml=!0;break;case"object":switch(d.$$typeof){case h:case N:ml=!0;break;case J:return ml=d._init,p(ml(d._payload),x,R,Y,W)}}if(ml)return W=W(d),ml=Y===""?"."+Zl(d,0):Y,Dl(W)?(R="",ml!=null&&(R=ml.replace(Pl,"$&/")+"/"),p(W,x,R,"",function(Ha){return Ha})):W!=null&&(cl(W)&&(W=$(W,R+(W.key==null||d&&d.key===W.key?"":(""+W.key).replace(Pl,"$&/")+"/")+ml)),x.push(W)),1;ml=0;var lt=Y===""?".":Y+":";if(Dl(d))for(var Ul=0;Ul<d.length;Ul++)Y=d[Ul],P=lt+Zl(Y,Ul),ml+=p(Y,x,R,P,W);else if(Ul=dl(d),typeof Ul=="function")for(d=Ul.call(d),Ul=0;!(Y=d.next()).done;)Y=Y.value,P=lt+Zl(Y,Ul++),ml+=p(Y,x,R,P,W);else if(P==="object"){if(typeof d.then=="function")return p(Ll(d),x,R,Y,W);throw x=String(d),Error("Objects are not valid as a React child (found: "+(x==="[object Object]"?"object with keys {"+Object.keys(d).join(", ")+"}":x)+"). If you meant to render a collection of children, use an array instead.")}return ml}function C(d,x,R){if(d==null)return d;var Y=[],W=0;return p(d,Y,"","",function(P){return x.call(R,P,W++)}),Y}function M(d){if(d._status===-1){var x=d._result;x=x(),x.then(function(R){(d._status===0||d._status===-1)&&(d._status=1,d._result=R)},function(R){(d._status===0||d._status===-1)&&(d._status=2,d._result=R)}),d._status===-1&&(d._status=0,d._result=x)}if(d._status===1)return d._result.default;throw d._result}var V=tyLine truncated
at`)?" (<anonymous>)":-1<e.stack.indexOf("@")?"@unknown:0:0":""}return`
`+$u+l+Tf}var Wu=!1;function Fu(l,t){if(!l||Wu)return"";Wu=!0;var e=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var a={DetermineComponentFrameRoot:function(){try{if(t){var T=function(){throw Error()};if(Object.defineProperty(T.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(T,[])}catch(S){var b=S}Reflect.construct(l,[],T)}else{try{T.call()}catch(S){b=S}l.call(T.prototype)}}else{try{throw Error()}catch(S){b=S}(T=l())&&typeof T.catch=="function"&&T.catch(function(){})}}catch(S){if(S&&b&&typeof S.stack=="string")return[S.stack,b.stack]}return[null,null]}};a.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var n=Object.getOwnPropertyDescriptor(a.DetermineComponentFrameRoot,"name");n&&n.configurable&&Object.defineProperty(a.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var u=a.DetermineComponentFrameRoot(),i=u[0],f=u[1];if(i&&f){var o=i.split(`
`),v=f.split(`
`);for(n=a=0;a<o.length&&!o[a].includes("DetermineComponentFrameRoot");)a++;for(;n<v.length&&!v[n].includes("DetermineComponentFrameRoot");)n++;if(a===o.length||n===v.length)for(a=o.length-1,n=v.length-1;1<=a&&0<=n&&o[a]!==v[n];)n--;for(;1<=a&&0<=n;a--,n--)if(o[a]!==v[n]){if(a!==1||n!==1)do if(a--,n--,0>n||o[a]!==v[n]){var j=`
`+o[a].replace(" at new "," at ");return l.displayName&&j.includes("<anonymous>")&&(j=j.replace("<anonymous>",l.displayName)),j}while(1<=a&&0<=n);break}}}finally{Wu=!1,Error.prepareStackTrace=e}return(e=l?l.displayName||l.name:"")?Me(e):""}function Yr(l,t){switch(l.tag){case 26:case 27:case 5:return Me(l.type);case 16:return Me("Lazy");case 13:return l.child!==t&&t!==null?Me("Suspense Fallback"):Me("Suspense");case 19:return Me("SuspenseList");case 0:case 15:return Fu(l.type,!1);case 11:return Fu(l.type.render,!1);case 1:return Fu(l.type,!0);case 31:return Me("Activity");default:return""}}function Ef(l){try{var t="",e=null;do t+=Yr(l,e),e=l,l=l.return;while(l);return t}catch(a){return`
Error generating stack: `+a.message+`
`+a.stack}}var Iu=Object.prototype.hasOwnProperty,Pu=h.unstable_scheduleCallback,li=h.unstable_cancelCallback,Gr=h.unstable_shouldYield,Xr=h.unstable_requestPaint,ot=h.unstable_now,Qr=h.unstable_getCurrentPriorityLevel,Af=h.unstable_ImmediatePriority,Nf=h.unstable_UserBlockingPriority,Un=h.unstable_NormalPriority,Zr=h.unstable_LowPriority,_f=h.unstable_IdlePriority,Lr=h.log,Vr=h.unstable_setDisableYieldValue,Ra=null,dt=null;function ne(l){if(typeof Lr=="function"&&Vr(l),dt&&typeof dt.setStrictMode=="function")try{dt.setStrictMode(Ra,l)}catch{}}var rt=Math.clz32?Math.clz32:wr,Kr=Math.log,Jr=Math.LN2;function wr(l){return l>>>=0,l===0?32:31-(Kr(l)/Jr|0)|0}var Cn=256,Hn=262144,Rn=4194304;function De(l){var t=l&42;if(t!==0)return t;switch(l&-l){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return l&261888;case 262144:case 524288:case 1048576:case 2097152:return l&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return l&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return l}}function qn(l,t,e){var a=l.pendingLanes;if(a===0)return 0;var n=0,u=l.suspendedLanes,i=l.pingedLanes;l=l.warmLanes;var f=a&134217727;return f!==0?(a=f&~u,a!==0?n=De(a):(i&=f,i!==0?n=De(i):e||(e=f&~l,e!==0&&(n=De(e))))):(f=a&~u,f!==0?n=De(f):i!==0?n=De(i):e||(e=a&~l,e!==0&&(n=De(e)))),n===0?0:t!==0&&t!==n&&(t&u)===0&&(u=n&-n,e=t&-t,u>=e||u===32&&(e&4194048)!==0)?t:n}function qa(l,t){return(l.pendingLanes&~(l.suspendedLanes&~l.pingedLanes)&t)===0}function kr(l,t){switch(l){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Of(){var l=Rn;return Rn<<=1,(Rn&62914560)===0&&(Rn=4194304),l}function ti(l){for(var t=[],e=0;31>e;e++)t.push(l);return t}function Ba(l,t){l.pendingLanes|=t,t!==268435456&&(l.suspendedLanes=0,l.pingedLanes=0,l.warmLanes=0)}function $r(l,t,e,a,n,u){var i=l.pendingLanes;l.pendingLanes=e,l.suspendedLanes=0,l.pingedLanes=0,l.warmLanes=0,l.expiredLanes&=e,l.entangledLanes&=e,l.errorRecoveryDisabledLanes&=e,l.shellSuspendCounter=0;var f=l.entanglements,o=l.expirationTimes,v=l.hiddenUpdates;for(e=i&~e;0<e;){var j=31-rt(e),T=1<<j;f[j]=0,o[j]=-1;var b=v[j];if(b!==null)for(v[j]=null,j=0;j<b.length;j++){var S=b[j];S!==null&&(S.lane&=-536870913)}e&=~T}a!==0&&Mf(l,a,0),u!==0&&n===0&&l.tag!==0&&(l.suspendedLanes|=u&~(i&~t))}function Mf(l,t,e){l.pendingLanes|=t,l.suspendedLanes&=~t;var a=31-rt(t);l.entangledLanes|=t,l.entanglements[a]=l.entanglements[a]|1073741824|e&261930}function Df(l,t){var e=l.entangledLanes|=t;for(l=l.entanglements;e;){var a=31-rt(e),n=1<<a;n&t|l[a]&t&&(l[a]|=t),e&=~n}}function Uf(l,t){var e=t&-t;return e=(e&42)!==0?1:ei(e),(e&(l.suspendedLanes|t))!==0?0:e}function ei(l){switch(l){case 2:l=1;break;case 8:l=4;break;case 32:l=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:l=128;break;case 268435456:l=134217728;break;default:l=0}return l}function ai(l){return l&=-l,2<l?8<l?(l&134217727)!==0?32:268435456:8:2}function Cf(){var l=C.p;return l!==0?l:(l=window.event,l===void 0?32:Sr(l.type))}function Hf(l,t){var e=C.p;try{return C.p=l,t()}finally{C.p=e}}var ue=Math.random().toString(36).slice(2),Jl="__reactFiber$"+ue,et="__reactProps$"+ue,$e="__reactContainer$"+ue,ni="__reactEvents$"+ue,Wr="__reactListeners$"+ue,Fr="__reactHandles$"+ue,Rf="__reactResources$"+ue,Ya="__reactMarker$"+ue;function ui(l){delete l[Jl],delete l[et],delete l[ni],delete l[Wr],delete l[Fr]}function We(l){var t=l[Jl];if(t)return t;for(var e=l.parentNode;e;){if(t=e[$e]||e[Jl]){if(e=t.alternate,t.child!==null||e!==null&&e.child!==null)for(l=ar(l);l!==null;){if(e=l[Jl])return e;l=ar(l)}return t}l=e,e=l.parentNode}return null}function Fe(l){if(l=l[Jl]||l[$e]){var t=l.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return l}return null}function Ga(l){var t=l.tag;if(t===5||t===26||t===27||t===6)return l.stateNode;throw Error(s(33))}function Ie(l){var t=l[Rf];return t||(t=l[Rf]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function Vl(l){l[Ya]=!0}var qf=new Set,Bf={};function Ue(l,t){Pe(l,t),Pe(l+"Capture",t)}function Pe(l,t){for(Bf[l]=t,l=0;l<t.length;l++)qf.add(t[l])}var Ir=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u21 Line truncated
`).replace(Om,"")}function wd(l,t){return t=Jd(t),Jd(l)===t}function Sl(l,t,e,a,n,u){switch(e){case"children":typeof a=="string"?t==="body"||t==="textarea"&&a===""||ta(l,a):(typeof a=="number"||typeof a=="bigint")&&t!=="body"&&ta(l,""+a);break;case"className":Yn(l,"class",a);break;case"tabIndex":Yn(l,"tabindex",a);break;case"dir":case"role":case"viewBox":case"width":case"height":Yn(l,e,a);break;case"style":Jf(l,a,u);break;case"data":if(t!=="object"){Yn(l,"data",a);break}case"src":case"href":if(a===""&&(t!=="a"||e!=="href")){l.removeAttribute(e);break}if(a==null||typeof a=="function"||typeof a=="symbol"||typeof a=="boolean"){l.removeAttribute(e);break}a=Xn(""+a),l.setAttribute(e,a);break;case"action":case"formAction":if(typeof a=="function"){l.setAttribute(e,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof u=="function"&&(e==="formAction"?(t!=="input"&&Sl(l,t,"name",n.name,n,null),Sl(l,t,"formEncType",n.formEncType,n,null),Sl(l,t,"formMethod",n.formMethod,n,null),Sl(l,t,"formTarget",n.formTarget,n,null)):(Sl(l,t,"encType",n.encType,n,null),Sl(l,t,"method",n.method,n,null),Sl(l,t,"target",n.target,n,null)));if(a==null||typeof a=="symbol"||typeof a=="boolean"){l.removeAttribute(e);break}a=Xn(""+a),l.setAttribute(e,a);break;case"onClick":a!=null&&(l.onclick=Xt);break;case"onScroll":a!=null&&tl("scroll",l);break;case"onScrollEnd":a!=null&&tl("scrollend",l);break;case"dangerouslySetInnerHTML":if(a!=null){if(typeof a!="object"||!("__html"in a))throw Error(s(61));if(e=a.__html,e!=null){if(n.children!=null)throw Error(s(60));l.innerHTML=e}}break;case"multiple":l.multiple=a&&typeof a!="function"&&typeof a!="symbol";break;case"muted":l.muted=a&&typeof a!="function"&&typeof a!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(a==null||typeof a=="function"||typeof a=="boolean"||typeof a=="symbol"){l.removeAttribute("xlink:href");break}e=Xn(""+a),l.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",e);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":a!=null&&typeof a!="function"&&typeof a!="symbol"?l.setAttribute(e,""+a):l.removeAttribute(e);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":a&&typeof a!="function"&&typeof a!="symbol"?l.setAttribute(e,""):l.removeAttribute(e);break;case"capture":case"download":a===!0?l.setAttribute(e,""):a!==!1&&a!=null&&typeof a!="function"&&typeof a!="symbol"?l.setAttribute(e,a):l.removeAttribute(e);break;case"cols":case"rows":case"size":case"span":a!=null&&typeof a!="function"&&typeof a!="symbol"&&!isNaN(a)&&1<=a?l.setAttribute(e,a):l.removeAttribute(e);break;case"rowSpan":case"start":a==null||typeof a=="function"||typeof a=="symbol"||isNaN(a)?l.removeAttribute(e):l.setAttribute(e,a);break;case"popover":tl("beforetoggle",l),tl("toggle",l),Bn(l,"popover",a);break;case"xlinkActuate":Gt(l,"http://www.w3.org/1999/xlink","xlink:actuate",a);break;case"xlinkArcrole":Gt(l,"http://www.w3.org/1999/xlink","xlink:arcrole",a);break;case"xlinkRole":Gt(l,"http://www.w3.org/1999/xlink","xlink:role",a);break;case"xlinkShow":Gt(l,"http://www.w3.org/1999/xlink","xlink:show",a);break;case"xlinkTitle":Gt(l,"http://www.w3.org/1999/xlink","xlink:title",a);break;case"xlinkType":Gt(l,"http://www.w3.org/1999/xlink","xlink:type",a);break;case"xmlBase":Gt(l,"http://www.w3.org/XML/1998/namespace","xml:base",a);break;case"xmlLang":Gt(l,"http://www.w3.org/XML/1998/namespace","xml:lang",a);break;case"xmlSpace":Gt(l,"http://www.w3.org/XML/1998/namespace","xml:space",a);break;case"is":Bn(l,"is",a);break;case"innerText":case"textContent":break;default:(!(2<e.length)||e[0]!=="o"&&e[0]!=="O"||e[1]!=="n"&&e[1]!=="N")&&(e=ah.get(e)||e,Bn(l,e,a))}}function $c(l,t,e,a,n,u){switch(e){case"style":Jf(l,a,u);break;case"dangerouslySetInnerHTML":if(a!=null){if(typeof a!="object"||!("__html"in a))throw Error(s(61));if(e=a.__html,e!=null){if(n.children!=null)throw Error(s(60));l.innerHTML=e}}break;case"children":typeof a=="string"?ta(l,a):(typeof a=="number"||typeof a=="bigint")&&ta(l,""+a);break;case"onScroll":a!=null&&tl("scroll",l);break;case"onScrollEnd":a!=null&&tl("scrollend",l);break;case"onClick":a!=null&&(l.onclick=Xt);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"inne Line truncated
`)})]}),h.items.map(s=>c.jsxs("div",{children:[c.jsxs("h3",{style:{margin:"0 0 6px",fontSize:12},children:[s.name,s.targetName!==s.name&&c.jsxs("span",{className:"faint",children:[" → ",s.targetName]})]}),(s.warnings??[]).map((_,H)=>c.jsx(Dt,{kind:"warn",children:_},`w${H}`)),(s.notes??[]).map((_,H)=>c.jsxs("div",{className:"small faint",children:["· ",_]},`n${H}`)),c.jsx("pre",{className:"cmdblock",children:(s.commands??[]).join(`
`)})]},s.containerId))]})})}function Ty({jobs:h,activeJob:N,setActiveJob:O,reload:s,reloadPackages:_}){const H=N||h[0]?.id||"";return h.length===0?c.jsx("div",{className:"empty",children:"no migrations yet — select containers and start one"}):c.jsxs("div",{style:{display:"flex",minHeight:0,height:"100%"},children:[c.jsx("div",{className:"joblist",style:{width:320,flex:"0 0 320px",overflow:"auto"},children:h.map(E=>c.jsxs("div",{className:`jobcard${E.id===H?" active":""}`,onClick:()=>O(E.id),children:[c.jsxs("div",{className:"row",children:[c.jsx(Mn,{state:E.state}),c.jsx("span",{className:"spacer"}),c.jsx("span",{className:"small faint",children:E.kind==="ssh"?"ssh":"package"})]}),c.jsx("div",{className:"truncate",style:{marginTop:2},children:E.title}),c.jsxs("div",{className:"small faint",children:[new Date(E.createdAt).toLocaleTimeString()," · ",qr(E.startedAt,E.endedAt),E.dryRun&&" · dry run"]}),c.jsx("div",{style:{marginTop:6},children:c.jsx(jf,{done:E.bytesDone,total:E.bytesTotal,state:E.state})})]},E.id))}),c.jsx("div",{style:{flex:1,minWidth:0,overflow:"auto",borderLeft:"1px solid var(--border)"},children:H&&c.jsx(Ey,{id:H,reload:s,reloadPackages:_})})]})}function Ey({id:h,reload:N,reloadPackages:O}){const[s,_]=K.useState(null),[H,E]=K.useState(!0),k=K.useRef(null),D=K.useRef(!0);K.useEffect(()=>{_(null);let A=!1;Gl.job(h).then(dl=>!A&&_(dl)).catch(()=>{});const B=Gl.jobEvents(h);return B.onmessage=dl=>{try{_(JSON.parse(dl.data))}catch{}},B.addEventListener("done",()=>{B.close(),N(),O()}),B.onerror=()=>B.close(),()=>{A=!0,B.close()}},[h,N,O]);const g=K.useMemo(()=>(s?.log??[]).filter(A=>H||A.level!=="cmd"),[s,H]);if(K.useEffect(()=>{const A=k.current;A&&D.current&&(A.scrollTop=A.scrollHeight)},[g]),!s)return c.jsx("div",{className:"empty",children:"loading…"});const J=s.state==="running"||s.state==="pending";return c.jsxs("div",{style:{padding:16,display:"flex",flexDirection:"column",gap:14},children:[c.jsxs("div",{className:"row",children:[c.jsx(Mn,{state:s.state}),c.jsx("b",{children:s.title}),s.dryRun&&c.jsx("span",{className:"badge",children:"dry run"}),c.jsx("span",{className:"spacer"}),c.jsxs("span",{className:"small faint",children:[ae(s.bytesDone),s.bytesTotal>0&&c.jsxs(c.Fragment,{children:[" of ",ae(s.bytesTotal)]})," · ",qr(s.startedAt,s.endedAt)]}),J?c.jsx("button",{className:"btn tiny danger",onClick:()=>Gl.cancelJob(s.id).then(N),children:"cancel"}):c.jsx("button",{className:"btn tiny ghost",onClick:()=>Gl.deleteJob(s.id).then(N),children:"remove"})]}),c.jsx(jf,{done:s.bytesDone,total:s.bytesTotal,state:s.state}),s.error&&c.jsx(Dt,{kind:"err",children:s.error}),s.state==="succeeded"&&s.artifact&&c.jsxs(Dt,{kind:"ok",children:["Package ready at ",c.jsx("span",{className:"mono",children:s.artifact})," (",ae(s.artifactBytes??0),")."," ","Open the Packages tab to download it."]}),s.items.map(A=>c.jsxs("div",{style:{border:"1px solid var(--border)",borderRadius:6,padding:"8px 10px"},children:[c.jsxs("div",{className:"row",children:[c.jsx(Mn,{state:A.state}),c.jsx("b",{children:A.name}),c.jsx("span",{className:"spacer"}),c.jsxs("span",{className:"small faint",children:[A.steps.filter(B=>B.state==="succeeded").length,"/",A.steps.length," steps"]})]}),A.error&&c.jsx("div",{className:"small",style:{color:"var(--err)"},children:A.error}),(A.warnings??[]).map((B,dl)=>c.jsxs("div",{className:"small",style:{color:"var(--warn)"},children:["! ",B]},dl)),c.jsx("div",{className:"steps",children:A.steps.map(B=>c.jsxs("div",{className:`step ${B.state}`,children:[c.jsx(Mn,{state:B.state,label:""}),c.jsx("span",{className:"label truncate",title:B.error||B.label,children:B.label}),c.jsx("span",{children:B.bytesTotal>0||B.bytesDone>0?c.jsx(jf,{done:B.bytesDone,total:B.bytesTotal,state:B.state}):null}),c.jsx("span",{className:"faint nowrap",style:{textAlign:"right"},children:B.bytesDone>0?ae(B.bytesDone):B.state==="skipped"?"skipped":""})]},B.id))})]},A.id)),c.jsxs("div",{className:"row",children:[c.jsx("h3",{style:{margin:0,fontSize:12},children:"log"}),c.jsx("span",{className:"spacer"}),c.jsxs("label",{className:"check small",children:[c.jsx("input",{type:"checkbox",checked:H,onChange:A=>E(A.target.checked)}),c.jsx("span",{children:"show commands"})]})]}),c.jsxs("div",{className:"log",ref:k,onScroll:A=>{const B=A.currentTarget;D.current=B.scrollHeight-B.scrollTop-B.clientHeight<24},children:[g.map(A=>c.jsxs("div",{className:`l-${A.level}`,children:[c.jsxs("span",{className:"ts",children:[new Date(A.at).toLocaleTimeString()," "]}),A.message]},A.seq)),g.length===0&&c.jsx("span",{className:"faint",children:"nothing logged yet"})]})]})}function Ay({packages:h,reload:N}){return h.length===0?c.jsx("div",{className:"empty",children:"no packages built yet"}):c.jsxs("div",{style:{padding:16,display:"flex",flexDirection:"column",gap:12},children:[c.jsxs(Dt,{kind:"info",children:["Copy a package to the target host, then run ",c.jsx("span",{className:"mono",children:"./install.sh --dry-run"})," to review it and" Line truncated
+11
View File
@@ -0,0 +1,11 @@
(function(){const S=document.createElement("link").relList;if(S&&S.supports&&S.supports("modulepreload"))return;for(const O of document.querySelectorAll('link[rel="modulepreload"]'))s(O);new MutationObserver(O=>{for(const D of O)if(D.type==="childList")for(const T of D.addedNodes)T.tagName==="LINK"&&T.rel==="modulepreload"&&s(T)}).observe(document,{childList:!0,subtree:!0});function z(O){const D={};return O.integrity&&(D.integrity=O.integrity),O.referrerPolicy&&(D.referrerPolicy=O.referrerPolicy),O.crossOrigin==="use-credentials"?D.credentials="include":O.crossOrigin==="anonymous"?D.credentials="omit":D.credentials="same-origin",D}function s(O){if(O.ep)return;O.ep=!0;const D=z(O);fetch(O.href,D)}})();var gf={exports:{}},Dn={};var Nr;function sy(){if(Nr)return Dn;Nr=1;var o=Symbol.for("react.transitional.element"),S=Symbol.for("react.fragment");function z(s,O,D){var T=null;if(D!==void 0&&(T=""+D),O.key!==void 0&&(T=""+O.key),"key"in O){D={};for(var w in O)w!=="key"&&(D[w]=O[w])}else D=O;return O=D.ref,{$$typeof:o,type:s,key:T,ref:O!==void 0?O:null,props:D}}return Dn.Fragment=S,Dn.jsx=z,Dn.jsxs=z,Dn}var Ar;function oy(){return Ar||(Ar=1,gf.exports=sy()),gf.exports}var c=oy(),Sf={exports:{}},I={};var _r;function dy(){if(_r)return I;_r=1;var o=Symbol.for("react.transitional.element"),S=Symbol.for("react.portal"),z=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),O=Symbol.for("react.profiler"),D=Symbol.for("react.consumer"),T=Symbol.for("react.context"),w=Symbol.for("react.forward_ref"),H=Symbol.for("react.suspense"),b=Symbol.for("react.memo"),V=Symbol.for("react.lazy"),E=Symbol.for("react.activity"),U=Symbol.iterator;function ll(h){return h===null||typeof h!="object"?null:(h=U&&h[U]||h["@@iterator"],typeof h=="function"?h:null)}var W={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},vl=Object.assign,Yl={};function gl(h,A,q){this.props=h,this.context=A,this.refs=Yl,this.updater=q||W}gl.prototype.isReactComponent={},gl.prototype.setState=function(h,A){if(typeof h!="object"&&typeof h!="function"&&h!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,h,A,"setState")},gl.prototype.forceUpdate=function(h){this.updater.enqueueForceUpdate(this,h,"forceUpdate")};function _l(){}_l.prototype=gl.prototype;function dl(h,A,q){this.props=h,this.context=A,this.refs=Yl,this.updater=q||W}var el=dl.prototype=new _l;el.constructor=dl,vl(el,gl.prototype),el.isPureReactComponent=!0;var Sl=Array.isArray;function Nl(){}var C={H:null,A:null,T:null,S:null},Z=Object.prototype.hasOwnProperty;function B(h,A,q){var Y=q.ref;return{$$typeof:o,type:h,key:A,ref:Y!==void 0?Y:null,props:q}}function $(h,A){return B(h.type,A,h.props)}function sl(h){return typeof h=="object"&&h!==null&&h.$$typeof===o}function jl(h){var A={"=":"=0",":":"=2"};return"$"+h.replace(/[=:]/g,function(q){return A[q]})}var at=/\/+/g;function tt(h,A){return typeof h=="object"&&h!==null&&h.key!=null?jl(""+h.key):A.toString(36)}function Cl(h){switch(h.status){case"fulfilled":return h.value;case"rejected":throw h.reason;default:switch(typeof h.status=="string"?h.then(Nl,Nl):(h.status="pending",h.then(function(A){h.status==="pending"&&(h.status="fulfilled",h.value=A)},function(A){h.status==="pending"&&(h.status="rejected",h.reason=A)})),h.status){case"fulfilled":return h.value;case"rejected":throw h.reason}}throw h}function j(h,A,q,Y,F){var al=typeof h;(al==="undefined"||al==="boolean")&&(h=null);var rl=!1;if(h===null)rl=!0;else switch(al){case"bigint":case"string":case"number":rl=!0;break;case"object":switch(h.$$typeof){case o:case S:rl=!0;break;case V:return rl=h._init,j(rl(h._payload),A,q,Y,F)}}if(rl)return F=F(h),rl=Y===""?"."+tt(h,0):Y,Sl(F)?(q="",rl!=null&&(q=rl.replace(at,"$&/")+"/"),j(F,A,q,"",function(k){return k})):F!=null&&(sl(F)&&(F=$(F,q+(F.key==null||h&&h.key===F.key?"":(""+F.key).replace(at,"$&/")+"/")+rl)),A.push(F)),1;rl=0;var Kl=Y===""?".":Y+":";if(Sl(h))for(var Ul=0;Ul<h.length;Ul++)Y=h[Ul],al=Kl+tt(Y,Ul),rl+=j(Y,A,q,al,F);else if(Ul=ll(h),typeof Ul=="function")for(h=Ul.call(h),Ul=0;!(Y=h.next()).done;)Y=Y.value,al=Kl+tt(Y,Ul++),rl+=j(Y,A,q,al,F);else if(al==="object"){if(typeof h.then=="function")return j(Cl(h),A,q,Y,F);throw A=String(h),Error("Objects are not valid as a React child (found: "+(A==="[object Object]"?"object with keys {"+Object.keys(h).join(", ")+"}":A)+"). If you meant to render a collection of children, use an array instead.")}return rl}function R(h,A,q){if(h==null)return h;var Y=[],F=0;return j(h,Y,"","",function(al){return A.call(q,al,F++)}),Y}function M(h){if(h._status===-1){var A=h._result;A=A(),A.then(function(q){(h._status===0||h._status===-1)&&(h._status=1,h._result=q)},function(q){(h._status===0||h._status===-1)&&(h._status=2,h._result=q)}),h._status===-1&&(h._status=0,h._result=A)}if(h._status===1)return h._result.default;throw h._result}vaLine truncated
at`)?" (<anonymous>)":-1<e.stack.indexOf("@")?"@unknown:0:0":""}return`
`+ce+l+Ie}var Pu=!1;function li(l,t){if(!l||Pu)return"";Pu=!0;var e=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var a={DetermineComponentFrameRoot:function(){try{if(t){var _=function(){throw Error()};if(Object.defineProperty(_.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(_,[])}catch(p){var g=p}Reflect.construct(l,[],_)}else{try{_.call()}catch(p){g=p}l.call(_.prototype)}}else{try{throw Error()}catch(p){g=p}(_=l())&&typeof _.catch=="function"&&_.catch(function(){})}}catch(p){if(p&&g&&typeof p.stack=="string")return[p.stack,g.stack]}return[null,null]}};a.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var n=Object.getOwnPropertyDescriptor(a.DetermineComponentFrameRoot,"name");n&&n.configurable&&Object.defineProperty(a.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var u=a.DetermineComponentFrameRoot(),i=u[0],f=u[1];if(i&&f){var d=i.split(`
`),v=f.split(`
`);for(n=a=0;a<d.length&&!d[a].includes("DetermineComponentFrameRoot");)a++;for(;n<v.length&&!v[n].includes("DetermineComponentFrameRoot");)n++;if(a===d.length||n===v.length)for(a=d.length-1,n=v.length-1;1<=a&&0<=n&&d[a]!==v[n];)n--;for(;1<=a&&0<=n;a--,n--)if(d[a]!==v[n]){if(a!==1||n!==1)do if(a--,n--,0>n||d[a]!==v[n]){var x=`
`+d[a].replace(" at new "," at ");return l.displayName&&x.includes("<anonymous>")&&(x=x.replace("<anonymous>",l.displayName)),x}while(1<=a&&0<=n);break}}}finally{Pu=!1,Error.prepareStackTrace=e}return(e=l?l.displayName||l.name:"")?Ue(e):""}function Xr(l,t){switch(l.tag){case 26:case 27:case 5:return Ue(l.type);case 16:return Ue("Lazy");case 13:return l.child!==t&&t!==null?Ue("Suspense Fallback"):Ue("Suspense");case 19:return Ue("SuspenseList");case 0:case 15:return li(l.type,!1);case 11:return li(l.type.render,!1);case 1:return li(l.type,!0);case 31:return Ue("Activity");default:return""}}function Ef(l){try{var t="",e=null;do t+=Xr(l,e),e=l,l=l.return;while(l);return t}catch(a){return`
Error generating stack: `+a.message+`
`+a.stack}}var ti=Object.prototype.hasOwnProperty,ei=o.unstable_scheduleCallback,ai=o.unstable_cancelCallback,Qr=o.unstable_shouldYield,Zr=o.unstable_requestPaint,mt=o.unstable_now,Lr=o.unstable_getCurrentPriorityLevel,Nf=o.unstable_ImmediatePriority,Af=o.unstable_UserBlockingPriority,Hn=o.unstable_NormalPriority,Vr=o.unstable_LowPriority,_f=o.unstable_IdlePriority,Kr=o.log,Jr=o.unstable_setDisableYieldValue,Ya=null,yt=null;function fe(l){if(typeof Kr=="function"&&Jr(l),yt&&typeof yt.setStrictMode=="function")try{yt.setStrictMode(Ya,l)}catch{}}var vt=Math.clz32?Math.clz32:$r,wr=Math.log,kr=Math.LN2;function $r(l){return l>>>=0,l===0?32:31-(wr(l)/kr|0)|0}var Rn=256,qn=262144,Bn=4194304;function He(l){var t=l&42;if(t!==0)return t;switch(l&-l){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return l&261888;case 262144:case 524288:case 1048576:case 2097152:return l&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return l&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return l}}function Yn(l,t,e){var a=l.pendingLanes;if(a===0)return 0;var n=0,u=l.suspendedLanes,i=l.pingedLanes;l=l.warmLanes;var f=a&134217727;return f!==0?(a=f&~u,a!==0?n=He(a):(i&=f,i!==0?n=He(i):e||(e=f&~l,e!==0&&(n=He(e))))):(f=a&~u,f!==0?n=He(f):i!==0?n=He(i):e||(e=a&~l,e!==0&&(n=He(e)))),n===0?0:t!==0&&t!==n&&(t&u)===0&&(u=n&-n,e=t&-t,u>=e||u===32&&(e&4194048)!==0)?t:n}function Ga(l,t){return(l.pendingLanes&~(l.suspendedLanes&~l.pingedLanes)&t)===0}function Wr(l,t){switch(l){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Of(){var l=Bn;return Bn<<=1,(Bn&62914560)===0&&(Bn=4194304),l}function ni(l){for(var t=[],e=0;31>e;e++)t.push(l);return t}function Xa(l,t){l.pendingLanes|=t,t!==268435456&&(l.suspendedLanes=0,l.pingedLanes=0,l.warmLanes=0)}function Fr(l,t,e,a,n,u){var i=l.pendingLanes;l.pendingLanes=e,l.suspendedLanes=0,l.pingedLanes=0,l.warmLanes=0,l.expiredLanes&=e,l.entangledLanes&=e,l.errorRecoveryDisabledLanes&=e,l.shellSuspendCounter=0;var f=l.entanglements,d=l.expirationTimes,v=l.hiddenUpdates;for(e=i&~e;0<e;){var x=31-vt(e),_=1<<x;f[x]=0,d[x]=-1;var g=v[x];if(g!==null)for(v[x]=null,x=0;x<g.length;x++){var p=g[x];p!==null&&(p.lane&=-536870913)}e&=~_}a!==0&&Mf(l,a,0),u!==0&&n===0&&l.tag!==0&&(l.suspendedLanes|=u&~(i&~t))}function Mf(l,t,e){l.pendingLanes|=t,l.suspendedLanes&=~t;var a=31-vt(t);l.entangledLanes|=t,l.entanglements[a]=l.entanglements[a]|1073741824|e&261930}function Df(l,t){var e=l.entangledLanes|=t;for(l=l.entanglements;e;){var a=31-vt(e),n=1<<a;n&t|l[a]&t&&(l[a]|=t),e&=~n}}function Cf(l,t){var e=t&-t;return e=(e&42)!==0?1:ui(e),(e&(l.suspendedLanes|t))!==0?0:e}function ui(l){switch(l){case 2:l=1;break;case 8:l=4;break;case 32:l=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:l=128;break;case 268435456:l=134217728;break;default:l=0}return l}function ii(l){return l&=-l,2<l?8<l?(l&134217727)!==0?32:268435456:8:2}function Uf(){var l=R.p;return l!==0?l:(l=window.event,l===void 0?32:br(l.type))}function Hf(l,t){var e=R.p;try{return R.p=l,t()}finally{R.p=e}}var se=Math.random().toString(36).slice(2),$l="__reactFiber$"+se,nt="__reactProps$"+se,Pe="__reactContainer$"+se,ci="__reactEvents$"+se,Ir="__reactListeners$"+se,Pr="__reactHandles$"+se,Rf="__reactResources$"+se,Qa="__reactMarker$"+se;function fi(l){delete l[$l],delete l[nt],delete l[ci],delete l[Ir],delete l[Pr]}function la(l){var t=l[$l];if(t)return t;for(var e=l.parentNode;e;){if(t=e[Pe]||e[$l]){if(e=t.alternate,t.child!==null||e!==null&&e.child!==null)for(l=ar(l);l!==null;){if(e=l[$l])return e;l=ar(l)}return t}l=e,e=l.parentNode}return null}function ta(l){if(l=l[$l]||l[Pe]){var t=l.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return l}return null}function Za(l){var t=l.tag;if(t===5||t===26||t===27||t===6)return l.stateNode;throw Error(s(33))}function ea(l){var t=l[Rf];return t||(t=l[Rf]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function wl(l){l[Qa]=!0}var qf=new Set,Bf={};function Re(l,t){aa(l,t),aa(l+"Capture",t)}function aa(l,t){for(Bf[l]=t,l=0;l<t.length;l++)qf.add(t[l])}var lh=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u21 Line truncated
`).replace(Dm,"")}function wd(l,t){return t=Jd(t),Jd(l)===t}function zl(l,t,e,a,n,u){switch(e){case"children":typeof a=="string"?t==="body"||t==="textarea"&&a===""||ua(l,a):(typeof a=="number"||typeof a=="bigint")&&t!=="body"&&ua(l,""+a);break;case"className":Xn(l,"class",a);break;case"tabIndex":Xn(l,"tabindex",a);break;case"dir":case"role":case"viewBox":case"width":case"height":Xn(l,e,a);break;case"style":Jf(l,a,u);break;case"data":if(t!=="object"){Xn(l,"data",a);break}case"src":case"href":if(a===""&&(t!=="a"||e!=="href")){l.removeAttribute(e);break}if(a==null||typeof a=="function"||typeof a=="symbol"||typeof a=="boolean"){l.removeAttribute(e);break}a=Zn(""+a),l.setAttribute(e,a);break;case"action":case"formAction":if(typeof a=="function"){l.setAttribute(e,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof u=="function"&&(e==="formAction"?(t!=="input"&&zl(l,t,"name",n.name,n,null),zl(l,t,"formEncType",n.formEncType,n,null),zl(l,t,"formMethod",n.formMethod,n,null),zl(l,t,"formTarget",n.formTarget,n,null)):(zl(l,t,"encType",n.encType,n,null),zl(l,t,"method",n.method,n,null),zl(l,t,"target",n.target,n,null)));if(a==null||typeof a=="symbol"||typeof a=="boolean"){l.removeAttribute(e);break}a=Zn(""+a),l.setAttribute(e,a);break;case"onClick":a!=null&&(l.onclick=Lt);break;case"onScroll":a!=null&&il("scroll",l);break;case"onScrollEnd":a!=null&&il("scrollend",l);break;case"dangerouslySetInnerHTML":if(a!=null){if(typeof a!="object"||!("__html"in a))throw Error(s(61));if(e=a.__html,e!=null){if(n.children!=null)throw Error(s(60));l.innerHTML=e}}break;case"multiple":l.multiple=a&&typeof a!="function"&&typeof a!="symbol";break;case"muted":l.muted=a&&typeof a!="function"&&typeof a!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(a==null||typeof a=="function"||typeof a=="boolean"||typeof a=="symbol"){l.removeAttribute("xlink:href");break}e=Zn(""+a),l.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",e);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":a!=null&&typeof a!="function"&&typeof a!="symbol"?l.setAttribute(e,""+a):l.removeAttribute(e);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":a&&typeof a!="function"&&typeof a!="symbol"?l.setAttribute(e,""):l.removeAttribute(e);break;case"capture":case"download":a===!0?l.setAttribute(e,""):a!==!1&&a!=null&&typeof a!="function"&&typeof a!="symbol"?l.setAttribute(e,a):l.removeAttribute(e);break;case"cols":case"rows":case"size":case"span":a!=null&&typeof a!="function"&&typeof a!="symbol"&&!isNaN(a)&&1<=a?l.setAttribute(e,a):l.removeAttribute(e);break;case"rowSpan":case"start":a==null||typeof a=="function"||typeof a=="symbol"||isNaN(a)?l.removeAttribute(e):l.setAttribute(e,a);break;case"popover":il("beforetoggle",l),il("toggle",l),Gn(l,"popover",a);break;case"xlinkActuate":Zt(l,"http://www.w3.org/1999/xlink","xlink:actuate",a);break;case"xlinkArcrole":Zt(l,"http://www.w3.org/1999/xlink","xlink:arcrole",a);break;case"xlinkRole":Zt(l,"http://www.w3.org/1999/xlink","xlink:role",a);break;case"xlinkShow":Zt(l,"http://www.w3.org/1999/xlink","xlink:show",a);break;case"xlinkTitle":Zt(l,"http://www.w3.org/1999/xlink","xlink:title",a);break;case"xlinkType":Zt(l,"http://www.w3.org/1999/xlink","xlink:type",a);break;case"xmlBase":Zt(l,"http://www.w3.org/XML/1998/namespace","xml:base",a);break;case"xmlLang":Zt(l,"http://www.w3.org/XML/1998/namespace","xml:lang",a);break;case"xmlSpace":Zt(l,"http://www.w3.org/XML/1998/namespace","xml:space",a);break;case"is":Gn(l,"is",a);break;case"innerText":case"textContent":break;default:(!(2<e.length)||e[0]!=="o"&&e[0]!=="O"||e[1]!=="n"&&e[1]!=="N")&&(e=uh.get(e)||e,Gn(l,e,a))}}function Ic(l,t,e,a,n,u){switch(e){case"style":Jf(l,a,u);break;case"dangerouslySetInnerHTML":if(a!=null){if(typeof a!="object"||!("__html"in a))throw Error(s(61));if(e=a.__html,e!=null){if(n.children!=null)throw Error(s(60));l.innerHTML=e}}break;case"children":typeof a=="string"?ua(l,a):(typeof a=="number"||typeof a=="bigint")&&ua(l,""+a);break;case"onScroll":a!=null&&il("scroll",l);break;case"onScrollEnd":a!=null&&il("scrollend",l);break;case"onClick":a!=null&&(l.onclick=Lt);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"inne Line truncated
`)})]}),o.items.map(s=>c.jsxs("div",{children:[c.jsxs("h3",{style:{margin:"0 0 6px",fontSize:12},children:[s.name,s.targetName!==s.name&&c.jsxs("span",{className:"faint",children:[" → ",s.targetName]})]}),(s.warnings??[]).map((O,D)=>c.jsx(ht,{kind:"warn",children:O},`w${D}`)),(s.notes??[]).map((O,D)=>c.jsxs("div",{className:"small faint",children:["· ",O]},`n${D}`)),c.jsx("pre",{className:"cmdblock",children:(s.commands??[]).join(`
`)})]},s.containerId))]})})}function My({jobs:o,activeJob:S,setActiveJob:z,reload:s,reloadPackages:O}){const D=S||o[0]?.id||"";return o.length===0?c.jsx("div",{className:"empty",children:"no migrations yet — select containers and start one"}):c.jsxs("div",{style:{display:"flex",minHeight:0,height:"100%"},children:[c.jsx("div",{className:"joblist",style:{width:320,flex:"0 0 320px",overflow:"auto"},children:o.map(T=>c.jsxs("div",{className:`jobcard${T.id===D?" active":""}`,onClick:()=>z(T.id),children:[c.jsxs("div",{className:"row",children:[c.jsx(Un,{state:T.state}),c.jsx("span",{className:"spacer"}),c.jsx("span",{className:"small faint",children:T.kind==="ssh"?"ssh":"package"})]}),c.jsx("div",{className:"truncate",style:{marginTop:2},children:T.title}),c.jsxs("div",{className:"small faint",children:[new Date(T.createdAt).toLocaleTimeString()," · ",qr(T.startedAt,T.endedAt),T.dryRun&&" · dry run"]}),c.jsx("div",{style:{marginTop:6},children:c.jsx(zf,{done:T.bytesDone,total:T.bytesTotal,state:T.state})})]},T.id))}),c.jsx("div",{style:{flex:1,minWidth:0,overflow:"auto",borderLeft:"1px solid var(--border)"},children:D&&c.jsx(Dy,{id:D,reload:s,reloadPackages:O})})]})}function Dy({id:o,reload:S,reloadPackages:z}){const[s,O]=Q.useState(null),[D,T]=Q.useState(!0),w=Q.useRef(null),H=Q.useRef(!0);Q.useEffect(()=>{O(null);let E=!1;Al.job(o).then(ll=>!E&&O(ll)).catch(()=>{});const U=Al.jobEvents(o);return U.onmessage=ll=>{try{O(JSON.parse(ll.data))}catch{}},U.addEventListener("done",()=>{U.close(),S(),z()}),U.onerror=()=>U.close(),()=>{E=!0,U.close()}},[o,S,z]);const b=Q.useMemo(()=>(s?.log??[]).filter(E=>D||E.level!=="cmd"),[s,D]);if(Q.useEffect(()=>{const E=w.current;E&&H.current&&(E.scrollTop=E.scrollHeight)},[b]),!s)return c.jsx("div",{className:"empty",children:"loading…"});const V=s.state==="running"||s.state==="pending";return c.jsxs("div",{style:{padding:16,display:"flex",flexDirection:"column",gap:14},children:[c.jsxs("div",{className:"row",children:[c.jsx(Un,{state:s.state}),c.jsx("b",{children:s.title}),s.dryRun&&c.jsx("span",{className:"badge",children:"dry run"}),c.jsx("span",{className:"spacer"}),c.jsxs("span",{className:"small faint",children:[ie(s.bytesDone),s.bytesTotal>0&&c.jsxs(c.Fragment,{children:[" of ",ie(s.bytesTotal)]})," · ",qr(s.startedAt,s.endedAt)]}),V?c.jsx("button",{className:"btn tiny danger",onClick:()=>Al.cancelJob(s.id).then(S),children:"cancel"}):c.jsx("button",{className:"btn tiny ghost",onClick:()=>Al.deleteJob(s.id).then(S),children:"remove"})]}),c.jsx(zf,{done:s.bytesDone,total:s.bytesTotal,state:s.state}),s.error&&c.jsx(ht,{kind:"err",children:s.error}),s.state==="succeeded"&&s.artifact&&c.jsxs(ht,{kind:"ok",children:["Package ready at ",c.jsx("span",{className:"mono",children:s.artifact})," (",ie(s.artifactBytes??0),")."," ","Open the Packages tab to download it."]}),s.items.map(E=>c.jsxs("div",{style:{border:"1px solid var(--border)",borderRadius:6,padding:"8px 10px"},children:[c.jsxs("div",{className:"row",children:[c.jsx(Un,{state:E.state}),c.jsx("b",{children:E.name}),c.jsx("span",{className:"spacer"}),c.jsxs("span",{className:"small faint",children:[E.steps.filter(U=>U.state==="succeeded").length,"/",E.steps.length," steps"]})]}),E.error&&c.jsx("div",{className:"small",style:{color:"var(--err)"},children:E.error}),(E.warnings??[]).map((U,ll)=>c.jsxs("div",{className:"small",style:{color:"var(--warn)"},children:["! ",U]},ll)),c.jsx("div",{className:"steps",children:E.steps.map(U=>c.jsxs("div",{className:`step ${U.state}`,children:[c.jsx(Un,{state:U.state,label:""}),c.jsx("span",{className:"label truncate",title:U.error||U.label,children:U.label}),c.jsx("span",{children:U.bytesTotal>0||U.bytesDone>0?c.jsx(zf,{done:U.bytesDone,total:U.bytesTotal,state:U.state}):null}),c.jsx("span",{className:"faint nowrap",style:{textAlign:"right"},children:U.bytesDone>0?ie(U.bytesDone):U.state==="skipped"?"skipped":""})]},U.id))})]},E.id)),c.jsxs("div",{className:"row",children:[c.jsx("h3",{style:{margin:0,fontSize:12},children:"log"}),c.jsx("span",{className:"spacer"}),c.jsxs("label",{className:"check small",children:[c.jsx("input",{type:"checkbox",checked:D,onChange:E=>T(E.target.checked)}),c.jsx("span",{children:"show commands"})]})]}),c.jsxs("div",{className:"log",ref:w,onScroll:E=>{const U=E.currentTarget;H.current=U.scrollHeight-U.scrollTop-U.clientHeight<24},children:[b.map(E=>c.jsxs("div",{className:`l-${E.level}`,children:[c.jsxs("span",{className:"ts",children:[new Date(E.at).toLocaleTimeString()," "]}),E.message]},E.seq)),b.length===0&&c.jsx("span",{className:"faint",children:"nothing logged yet"})]})]})}function Cy({packages:o,reload:S}){return o.length===0?c.jsx("div",{className:"empty",children:"no packages built yet"}):c.jsxs("div",{style:{padding:16,display:"flex",flexDirection:"column",gap:12},children:[c.jsxs(ht,{kind:"info",children:["Copy a package to the target host, then run ",c.jsx("span",{className:"mono",children:"./install.sh --dry-run"})," to review it and" Line truncated
+1 -1
View File
@@ -6,7 +6,7 @@
<meta name="color-scheme" content="dark light" />
<link rel="icon" type="image/png" href="/favicon.png" />
<title>DockMV</title>
<script type="module" crossorigin src="/assets/index-2w4y0Lpg.js"></script>
<script type="module" crossorigin src="/assets/index-qcSVszEj.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-CKzWD9Xt.css">
</head>
<body>