Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/perstack/src/status.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApiV1Client } from "@perstack/api-client/v1"
import { renderStatus, type StatusVersionInfo } from "@perstack/tui"
import { renderStatus, type WizardVersionInfo } from "@perstack/tui"
import { Command } from "commander"
import { getPerstackConfig } from "./lib/perstack-toml.js"

Expand Down Expand Up @@ -33,12 +33,12 @@ export const statusCommand = new Command()
name,
description: experts[name].description,
})),
onFetchVersions: async (expertName: string): Promise<StatusVersionInfo[]> => {
onFetchVersions: async (expertName: string): Promise<WizardVersionInfo[]> => {
try {
const { versions } = await client.registry.experts.getVersions({
expertKey: expertName,
})
const versionInfos: StatusVersionInfo[] = []
const versionInfos: WizardVersionInfo[] = []
for (const v of versions) {
try {
const { expert: fullExpert } = await client.registry.experts.get({
Expand Down
6 changes: 3 additions & 3 deletions packages/perstack/src/tag.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApiV1Client } from "@perstack/api-client/v1"
import { renderTag, type VersionInfo } from "@perstack/tui"
import { renderTag, type WizardVersionInfo } from "@perstack/tui"
import { Command } from "commander"
import { getPerstackConfig } from "./lib/perstack-toml.js"

Expand Down Expand Up @@ -33,12 +33,12 @@ export const tagCommand = new Command()
name,
description: experts[name].description,
})),
onFetchVersions: async (expertName: string): Promise<VersionInfo[]> => {
onFetchVersions: async (expertName: string): Promise<WizardVersionInfo[]> => {
try {
const { versions } = await client.registry.experts.getVersions({
expertKey: expertName,
})
const versionInfos: VersionInfo[] = []
const versionInfos: WizardVersionInfo[] = []
for (const v of versions) {
try {
const { expert: fullExpert } = await client.registry.experts.get({
Expand Down
6 changes: 3 additions & 3 deletions packages/perstack/src/unpublish.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApiV1Client } from "@perstack/api-client/v1"
import { renderUnpublish, type UnpublishVersionInfo } from "@perstack/tui"
import { renderUnpublish, type WizardVersionInfo } from "@perstack/tui"
import { Command } from "commander"
import { getPerstackConfig } from "./lib/perstack-toml.js"
export const unpublishCommand = new Command()
Expand Down Expand Up @@ -27,12 +27,12 @@ export const unpublishCommand = new Command()
name,
description: experts[name].description,
})),
onFetchVersions: async (expertName: string): Promise<UnpublishVersionInfo[]> => {
onFetchVersions: async (expertName: string): Promise<WizardVersionInfo[]> => {
try {
const { versions } = await client.registry.experts.getVersions({
expertKey: expertName,
})
const versionInfos: UnpublishVersionInfo[] = []
const versionInfos: WizardVersionInfo[] = []
for (const v of versions) {
try {
const { expert: fullExpert } = await client.registry.experts.get({
Expand Down
8 changes: 2 additions & 6 deletions packages/tui/apps/publish/app.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import { Box, Text, useApp, useInput } from "ink"
import { useState } from "react"

type ExpertChoice = {
name: string
description?: string
}
import type { WizardExpertChoice } from "../../src/types/wizard.js"

type PublishAppProps = {
experts: ExpertChoice[]
experts: WizardExpertChoice[]
onSelect: (expertName: string) => void
}

Expand Down
8 changes: 2 additions & 6 deletions packages/tui/apps/publish/render.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import { render } from "ink"
import type { WizardExpertChoice } from "../../src/types/wizard.js"
import { PublishApp } from "./app.js"

type ExpertChoice = {
name: string
description?: string
}

type RenderPublishSelectOptions = {
experts: ExpertChoice[]
experts: WizardExpertChoice[]
}

export async function renderPublish(options: RenderPublishSelectOptions): Promise<string | null> {
Expand Down
30 changes: 10 additions & 20 deletions packages/tui/apps/status/app.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
import { Box, Text, useApp, useInput } from "ink"
import { useState } from "react"
import { ErrorStep } from "../../src/components/error-step.js"
import type { WizardExpertChoice, WizardVersionInfo } from "../../src/types/wizard.js"
import { getStatusColor } from "../../src/utils/index.js"

type ExpertChoice = {
name: string
description?: string
}

type VersionInfo = {
key: string
version: string
tags: string[]
status: "available" | "deprecated" | "disabled"
}

type WizardStep =
| { type: "selectExpert" }
| { type: "loadingVersions"; expertName: string }
| { type: "selectVersion"; expertName: string; versions: VersionInfo[] }
| { type: "selectVersion"; expertName: string; versions: WizardVersionInfo[] }
| { type: "selectStatus"; expertKey: string; currentStatus: string }
| { type: "confirm"; expertKey: string; status: string; currentStatus: string }
| { type: "error"; message: string }
Expand All @@ -29,8 +18,8 @@ type StatusWizardResult = {
}

type StatusAppProps = {
experts: ExpertChoice[]
onFetchVersions: (expertName: string) => Promise<VersionInfo[]>
experts: WizardExpertChoice[]
onFetchVersions: (expertName: string) => Promise<WizardVersionInfo[]>
onComplete: (result: StatusWizardResult) => void
onCancel: () => void
}
Expand All @@ -52,7 +41,7 @@ function ExpertSelector({
experts,
onSelect,
}: {
experts: ExpertChoice[]
experts: WizardExpertChoice[]
onSelect: (name: string) => void
}) {
const { exit } = useApp()
Expand Down Expand Up @@ -99,8 +88,8 @@ function VersionSelector({
onBack,
}: {
expertName: string
versions: VersionInfo[]
onSelect: (version: VersionInfo) => void
versions: WizardVersionInfo[]
onSelect: (version: WizardVersionInfo) => void
onBack: () => void
}) {
const { exit } = useApp()
Expand Down Expand Up @@ -283,7 +272,7 @@ export function StatusApp({ experts, onFetchVersions, onComplete, onCancel }: St
})
}
}
const handleVersionSelect = (version: VersionInfo) => {
const handleVersionSelect = (version: WizardVersionInfo) => {
setStep({
type: "selectStatus",
expertKey: version.key,
Expand Down Expand Up @@ -376,4 +365,5 @@ export function StatusApp({ experts, onFetchVersions, onComplete, onCancel }: St
}
}

export type { ExpertChoice, VersionInfo, StatusWizardResult }
export type { StatusWizardResult }
export type { WizardExpertChoice, WizardVersionInfo } from "../../src/types/wizard.js"
10 changes: 6 additions & 4 deletions packages/tui/apps/status/render.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { render } from "ink"
import { type ExpertChoice, StatusApp, type StatusWizardResult, type VersionInfo } from "./app.js"
import type { WizardExpertChoice, WizardVersionInfo } from "../../src/types/wizard.js"
import { StatusApp, type StatusWizardResult } from "./app.js"

type RenderStatusWizardOptions = {
experts: ExpertChoice[]
onFetchVersions: (expertName: string) => Promise<VersionInfo[]>
experts: WizardExpertChoice[]
onFetchVersions: (expertName: string) => Promise<WizardVersionInfo[]>
}

export async function renderStatus(
Expand All @@ -29,4 +30,5 @@ export async function renderStatus(
})
}

export type { ExpertChoice, VersionInfo, StatusWizardResult }
export type { StatusWizardResult }
export type { WizardExpertChoice, WizardVersionInfo } from "../../src/types/wizard.js"
30 changes: 10 additions & 20 deletions packages/tui/apps/tag/app.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
import { Box, Text, useApp, useInput } from "ink"
import { useState } from "react"
import { ErrorStep } from "../../src/components/error-step.js"
import type { WizardExpertChoice, WizardVersionInfo } from "../../src/types/wizard.js"
import { getStatusColor } from "../../src/utils/index.js"

type ExpertChoice = {
name: string
description?: string
}

type VersionInfo = {
key: string
version: string
tags: string[]
status: "available" | "deprecated" | "disabled"
}

type WizardStep =
| { type: "selectExpert" }
| { type: "loadingVersions"; expertName: string }
| { type: "selectVersion"; expertName: string; versions: VersionInfo[] }
| { type: "selectVersion"; expertName: string; versions: WizardVersionInfo[] }
| { type: "inputTags"; expertKey: string; currentTags: string[] }
| { type: "confirm"; expertKey: string; tags: string[]; currentTags: string[] }
| { type: "error"; message: string }
Expand All @@ -29,8 +18,8 @@ type TagWizardResult = {
}

type TagAppProps = {
experts: ExpertChoice[]
onFetchVersions: (expertName: string) => Promise<VersionInfo[]>
experts: WizardExpertChoice[]
onFetchVersions: (expertName: string) => Promise<WizardVersionInfo[]>
onComplete: (result: TagWizardResult) => void
onCancel: () => void
}
Expand All @@ -39,7 +28,7 @@ function ExpertSelector({
experts,
onSelect,
}: {
experts: ExpertChoice[]
experts: WizardExpertChoice[]
onSelect: (name: string) => void
}) {
const { exit } = useApp()
Expand Down Expand Up @@ -86,8 +75,8 @@ function VersionSelector({
onBack,
}: {
expertName: string
versions: VersionInfo[]
onSelect: (version: VersionInfo) => void
versions: WizardVersionInfo[]
onSelect: (version: WizardVersionInfo) => void
onBack: () => void
}) {
const { exit } = useApp()
Expand Down Expand Up @@ -283,7 +272,7 @@ export function TagApp({ experts, onFetchVersions, onComplete, onCancel }: TagAp
})
}
}
const handleVersionSelect = (version: VersionInfo) => {
const handleVersionSelect = (version: WizardVersionInfo) => {
setStep({
type: "inputTags",
expertKey: version.key,
Expand Down Expand Up @@ -376,4 +365,5 @@ export function TagApp({ experts, onFetchVersions, onComplete, onCancel }: TagAp
}
}

export type { ExpertChoice, VersionInfo, TagWizardResult }
export type { TagWizardResult }
export type { WizardExpertChoice, WizardVersionInfo } from "../../src/types/wizard.js"
10 changes: 6 additions & 4 deletions packages/tui/apps/tag/render.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { render } from "ink"
import { type ExpertChoice, TagApp, type TagWizardResult, type VersionInfo } from "./app.js"
import type { WizardExpertChoice, WizardVersionInfo } from "../../src/types/wizard.js"
import { TagApp, type TagWizardResult } from "./app.js"

type RenderTagWizardOptions = {
experts: ExpertChoice[]
onFetchVersions: (expertName: string) => Promise<VersionInfo[]>
experts: WizardExpertChoice[]
onFetchVersions: (expertName: string) => Promise<WizardVersionInfo[]>
}

export async function renderTag(options: RenderTagWizardOptions): Promise<TagWizardResult | null> {
Expand All @@ -27,4 +28,5 @@ export async function renderTag(options: RenderTagWizardOptions): Promise<TagWiz
})
}

export type { ExpertChoice, VersionInfo, TagWizardResult }
export type { TagWizardResult }
export type { WizardExpertChoice, WizardVersionInfo } from "../../src/types/wizard.js"
28 changes: 10 additions & 18 deletions packages/tui/apps/unpublish/app.tsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,29 @@
import { Box, Text, useApp, useInput } from "ink"
import { useState } from "react"
import { ErrorStep } from "../../src/components/error-step.js"
import type { WizardExpertChoice, WizardVersionInfo } from "../../src/types/wizard.js"
import { getStatusColor } from "../../src/utils/index.js"

type ExpertChoice = {
name: string
description?: string
}
type VersionInfo = {
key: string
version: string
tags: string[]
status: "available" | "deprecated" | "disabled"
}
type WizardStep =
| { type: "selectExpert" }
| { type: "loadingVersions"; expertName: string }
| { type: "selectVersion"; expertName: string; versions: VersionInfo[] }
| { type: "selectVersion"; expertName: string; versions: WizardVersionInfo[] }
| { type: "confirm"; expertKey: string; version: string }
| { type: "error"; message: string }
type UnpublishWizardResult = {
expertKey: string
}
type UnpublishAppProps = {
experts: ExpertChoice[]
onFetchVersions: (expertName: string) => Promise<VersionInfo[]>
experts: WizardExpertChoice[]
onFetchVersions: (expertName: string) => Promise<WizardVersionInfo[]>
onComplete: (result: UnpublishWizardResult) => void
onCancel: () => void
}
function ExpertSelector({
experts,
onSelect,
}: {
experts: ExpertChoice[]
experts: WizardExpertChoice[]
onSelect: (name: string) => void
}) {
const { exit } = useApp()
Expand Down Expand Up @@ -78,8 +69,8 @@ function VersionSelector({
onBack,
}: {
expertName: string
versions: VersionInfo[]
onSelect: (version: VersionInfo) => void
versions: WizardVersionInfo[]
onSelect: (version: WizardVersionInfo) => void
onBack: () => void
}) {
const { exit } = useApp()
Expand Down Expand Up @@ -200,7 +191,7 @@ export function UnpublishApp({
})
}
}
const handleVersionSelect = (version: VersionInfo) => {
const handleVersionSelect = (version: WizardVersionInfo) => {
setStep({
type: "confirm",
expertKey: version.key,
Expand Down Expand Up @@ -262,4 +253,5 @@ export function UnpublishApp({
return null
}
}
export type { ExpertChoice, VersionInfo, UnpublishWizardResult }
export type { UnpublishWizardResult }
export type { WizardExpertChoice, WizardVersionInfo } from "../../src/types/wizard.js"
15 changes: 6 additions & 9 deletions packages/tui/apps/unpublish/render.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import { render } from "ink"
import {
type ExpertChoice,
UnpublishApp,
type UnpublishWizardResult,
type VersionInfo,
} from "./app.js"
import type { WizardExpertChoice, WizardVersionInfo } from "../../src/types/wizard.js"
import { UnpublishApp, type UnpublishWizardResult } from "./app.js"

type RenderUnpublishOptions = {
experts: ExpertChoice[]
onFetchVersions: (expertName: string) => Promise<VersionInfo[]>
experts: WizardExpertChoice[]
onFetchVersions: (expertName: string) => Promise<WizardVersionInfo[]>
}
export async function renderUnpublish(
options: RenderUnpublishOptions,
Expand All @@ -32,4 +28,5 @@ export async function renderUnpublish(
})
})
}
export type { ExpertChoice, VersionInfo, UnpublishWizardResult }
export type { UnpublishWizardResult }
export type { WizardExpertChoice, WizardVersionInfo } from "../../src/types/wizard.js"
Loading
Loading