mirror of
https://github.com/hanzoai/insights.git
synced 2026-10-30 16:15:31 +00:00
The tree was a debranded snapshot of upstream taken around 2026-02-20, and upstream has moved about five months since. This replaces it with upstream master, mechanically re-derived: bin/debrand does the rename, and the pipeline and squashed migrations are restored from the shipped tree. Not a merge. The previous import replaced the tree wholesale in a single commit, so there is no shared content history to merge against. Reproducing the rename on the new tree is what actually converges. What survives: .hanzo/workflows, the Dockerfiles and bin/docker* entrypoints, compose files, LLM.md, and insights/migrations. The squashed initial migration is load-bearing — the live database records it by name, so upstream's ~918 individual migrations cannot come back. Nine products are dropped as unreferenced. Twenty-one more that we do not run are kept anyway because the core app still imports them; unpicking those is a refactor and does not belong in a rebase. This base does not build yet, and the reasons are not in the rename: upstream now wants Python 3.13.13 against our 3.12.12 and Django 5.2 against our 4.2, and the dependency manifests still name upstream packages that we republish under our own names. Those are decisions, not renames.
136 lines
3.0 KiB
Go
136 lines
3.0 KiB
Go
package steps
|
|
|
|
import (
|
|
"github.com/charmbracelet/bubbles/key"
|
|
"github.com/charmbracelet/bubbles/textinput"
|
|
tea "github.com/charmbracelet/bubbletea"
|
|
"github.com/charmbracelet/lipgloss"
|
|
"github.com/insights/insights/bin/hobby-installer/ui"
|
|
)
|
|
|
|
type versionMode int
|
|
|
|
const (
|
|
versionModeSelect versionMode = iota
|
|
versionModeCustom
|
|
)
|
|
|
|
type VersionModel struct {
|
|
mode versionMode
|
|
selected int
|
|
options []string
|
|
values []string
|
|
textInput textinput.Model
|
|
}
|
|
|
|
func (m VersionModel) IsCustomMode() bool {
|
|
return m.mode == versionModeCustom
|
|
}
|
|
|
|
func NewVersionModel() VersionModel {
|
|
ti := textinput.New()
|
|
ti.Placeholder = "e.g., 1.43.0 or commit hash"
|
|
ti.CharLimit = 64
|
|
ti.Width = 40
|
|
|
|
return VersionModel{
|
|
mode: versionModeSelect,
|
|
selected: 0,
|
|
options: []string{
|
|
"latest (recommended)",
|
|
"latest-release (deprecated, use 'latest' instead)",
|
|
"Enter specific version/commit",
|
|
},
|
|
values: []string{
|
|
"latest",
|
|
"latest-release",
|
|
"",
|
|
},
|
|
textInput: ti,
|
|
}
|
|
}
|
|
|
|
func (m VersionModel) Init() tea.Cmd {
|
|
return nil
|
|
}
|
|
|
|
func (m VersionModel) Update(msg tea.Msg) (VersionModel, tea.Cmd) {
|
|
switch msg := msg.(type) {
|
|
case tea.KeyMsg:
|
|
if m.mode == versionModeCustom {
|
|
switch msg.String() {
|
|
case "enter":
|
|
if m.textInput.Value() != "" {
|
|
return m, func() tea.Msg {
|
|
return StepCompleteMsg{Data: m.textInput.Value()}
|
|
}
|
|
}
|
|
case "esc":
|
|
m.mode = versionModeSelect
|
|
return m, nil
|
|
}
|
|
var cmd tea.Cmd
|
|
m.textInput, cmd = m.textInput.Update(msg)
|
|
return m, cmd
|
|
}
|
|
|
|
switch {
|
|
case key.Matches(msg, key.NewBinding(key.WithKeys("up", "k"))):
|
|
if m.selected > 0 {
|
|
m.selected--
|
|
}
|
|
case key.Matches(msg, key.NewBinding(key.WithKeys("down", "j"))):
|
|
if m.selected < len(m.options)-1 {
|
|
m.selected++
|
|
}
|
|
case key.Matches(msg, key.NewBinding(key.WithKeys("enter"))):
|
|
if m.selected == 2 {
|
|
m.mode = versionModeCustom
|
|
m.textInput.Focus()
|
|
return m, textinput.Blink
|
|
}
|
|
return m, func() tea.Msg {
|
|
return StepCompleteMsg{Data: m.values[m.selected]}
|
|
}
|
|
}
|
|
}
|
|
return m, nil
|
|
}
|
|
|
|
func (m VersionModel) View() string {
|
|
var content string
|
|
|
|
if m.mode == versionModeCustom {
|
|
content = lipgloss.JoinVertical(
|
|
lipgloss.Left,
|
|
ui.TitleStyle.Render("Enter Insights Version"),
|
|
"",
|
|
ui.SubtitleStyle.Render("Enter a version tag or commit hash:"),
|
|
"",
|
|
m.textInput.View(),
|
|
"",
|
|
ui.MutedStyle.Render("Check available versions at:"),
|
|
ui.MutedStyle.Render("https://hub.docker.com/r/insights/insights/tags"),
|
|
"",
|
|
ui.HelpStyle.Render("enter confirm • esc back"),
|
|
)
|
|
} else {
|
|
content = lipgloss.JoinVertical(
|
|
lipgloss.Left,
|
|
ui.TitleStyle.Render("Select Insights Version"),
|
|
"",
|
|
ui.SubtitleStyle.Render("Which version would you like to install?"),
|
|
"",
|
|
ui.RenderMenuItems(m.options, m.selected),
|
|
"",
|
|
ui.MutedStyle.Render("'latest' is recommended for hobby deployments"),
|
|
"",
|
|
ui.HelpStyle.Render("↑/↓ navigate • enter select • esc back"),
|
|
)
|
|
}
|
|
|
|
return lipgloss.NewStyle().
|
|
Padding(2, 4).
|
|
Render(content)
|
|
}
|