@supatype/cli 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-test.log +114 -90
- package/.turbo/turbo-typecheck.log +2 -2
- package/dist/binary-cache.d.ts +2 -0
- package/dist/binary-cache.d.ts.map +1 -1
- package/dist/binary-cache.js +36 -0
- package/dist/binary-cache.js.map +1 -1
- package/dist/binary-download-lock.d.ts +12 -0
- package/dist/binary-download-lock.d.ts.map +1 -0
- package/dist/binary-download-lock.js +106 -0
- package/dist/binary-download-lock.js.map +1 -0
- package/dist/cli-package-version.d.ts +3 -0
- package/dist/cli-package-version.d.ts.map +1 -0
- package/dist/cli-package-version.js +15 -0
- package/dist/cli-package-version.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +5 -2
- package/dist/cli.js.map +1 -1
- package/dist/commands/add.js +25 -19
- package/dist/commands/add.js.map +1 -1
- package/dist/commands/admin.d.ts.map +1 -1
- package/dist/commands/admin.js +22 -6
- package/dist/commands/admin.js.map +1 -1
- package/dist/commands/cache.d.ts +1 -1
- package/dist/commands/cache.d.ts.map +1 -1
- package/dist/commands/cache.js +98 -5
- package/dist/commands/cache.js.map +1 -1
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +26 -22
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/init.d.ts +3 -4
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +238 -168
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/link-helpers.d.ts.map +1 -1
- package/dist/commands/link-helpers.js +26 -25
- package/dist/commands/link-helpers.js.map +1 -1
- package/dist/compose-local-server-image.d.ts +13 -0
- package/dist/compose-local-server-image.d.ts.map +1 -0
- package/dist/compose-local-server-image.js +57 -0
- package/dist/compose-local-server-image.js.map +1 -0
- package/dist/compose-rename.d.ts.map +1 -1
- package/dist/compose-rename.js +5 -8
- package/dist/compose-rename.js.map +1 -1
- package/dist/dev-compose.d.ts.map +1 -1
- package/dist/dev-compose.js +111 -54
- package/dist/dev-compose.js.map +1 -1
- package/dist/dev-log-bus.d.ts +5 -0
- package/dist/dev-log-bus.d.ts.map +1 -1
- package/dist/dev-log-bus.js +14 -0
- package/dist/dev-log-bus.js.map +1 -1
- package/dist/dev-log-filter.d.ts +4 -0
- package/dist/dev-log-filter.d.ts.map +1 -1
- package/dist/dev-log-filter.js +52 -0
- package/dist/dev-log-filter.js.map +1 -1
- package/dist/dev-ports.d.ts.map +1 -1
- package/dist/dev-ports.js +19 -12
- package/dist/dev-ports.js.map +1 -1
- package/dist/dev-ready-panel.d.ts +19 -0
- package/dist/dev-ready-panel.d.ts.map +1 -0
- package/dist/dev-ready-panel.js +49 -0
- package/dist/dev-ready-panel.js.map +1 -0
- package/dist/dev-session-lock.d.ts.map +1 -1
- package/dist/dev-session-lock.js +5 -8
- package/dist/dev-session-lock.js.map +1 -1
- package/dist/dev-session.d.ts +18 -5
- package/dist/dev-session.d.ts.map +1 -1
- package/dist/dev-session.js +91 -18
- package/dist/dev-session.js.map +1 -1
- package/dist/dev-shutdown.d.ts +2 -0
- package/dist/dev-shutdown.d.ts.map +1 -1
- package/dist/dev-shutdown.js +29 -15
- package/dist/dev-shutdown.js.map +1 -1
- package/dist/dev-task-colors.d.ts +3 -1
- package/dist/dev-task-colors.d.ts.map +1 -1
- package/dist/dev-task-colors.js +23 -3
- package/dist/dev-task-colors.js.map +1 -1
- package/dist/docker-runtime.js +1 -1
- package/dist/docker-runtime.js.map +1 -1
- package/dist/engine-push-output.d.ts +1 -0
- package/dist/engine-push-output.d.ts.map +1 -1
- package/dist/engine-push-output.js +4 -1
- package/dist/engine-push-output.js.map +1 -1
- package/dist/ensure-binary.d.ts.map +1 -1
- package/dist/ensure-binary.js +14 -2
- package/dist/ensure-binary.js.map +1 -1
- package/dist/ensure-component-binaries.d.ts +17 -0
- package/dist/ensure-component-binaries.d.ts.map +1 -0
- package/dist/ensure-component-binaries.js +45 -0
- package/dist/ensure-component-binaries.js.map +1 -0
- package/dist/ensure-dev-api-config.d.ts +3 -0
- package/dist/ensure-dev-api-config.d.ts.map +1 -0
- package/dist/ensure-dev-api-config.js +17 -0
- package/dist/ensure-dev-api-config.js.map +1 -0
- package/dist/init-dependency-versions.d.ts +13 -0
- package/dist/init-dependency-versions.d.ts.map +1 -0
- package/dist/init-dependency-versions.js +53 -0
- package/dist/init-dependency-versions.js.map +1 -0
- package/dist/init-package-json.d.ts +21 -0
- package/dist/init-package-json.d.ts.map +1 -0
- package/dist/init-package-json.js +46 -0
- package/dist/init-package-json.js.map +1 -0
- package/dist/postgres-ctl.d.ts.map +1 -1
- package/dist/postgres-ctl.js +2 -1
- package/dist/postgres-ctl.js.map +1 -1
- package/dist/required-host-components.d.ts +11 -0
- package/dist/required-host-components.d.ts.map +1 -0
- package/dist/required-host-components.js +25 -0
- package/dist/required-host-components.js.map +1 -0
- package/dist/resolve-api-url.d.ts +6 -0
- package/dist/resolve-api-url.d.ts.map +1 -0
- package/dist/resolve-api-url.js +39 -0
- package/dist/resolve-api-url.js.map +1 -0
- package/dist/rest-cache-admin.d.ts +33 -0
- package/dist/rest-cache-admin.d.ts.map +1 -0
- package/dist/rest-cache-admin.js +96 -0
- package/dist/rest-cache-admin.js.map +1 -0
- package/dist/scripts/postinstall.d.ts +4 -6
- package/dist/scripts/postinstall.d.ts.map +1 -1
- package/dist/scripts/postinstall.js +8 -41
- package/dist/scripts/postinstall.js.map +1 -1
- package/dist/self-host-compose.d.ts.map +1 -1
- package/dist/self-host-compose.js +23 -13
- package/dist/self-host-compose.js.map +1 -1
- package/dist/studio-dev-server.d.ts +4 -2
- package/dist/studio-dev-server.d.ts.map +1 -1
- package/dist/studio-dev-server.js +3 -2
- package/dist/studio-dev-server.js.map +1 -1
- package/dist/ui/brand.d.ts +2 -5
- package/dist/ui/brand.d.ts.map +1 -1
- package/dist/ui/brand.js +2 -7
- package/dist/ui/brand.js.map +1 -1
- package/dist/ui/clack-api.d.ts +44 -0
- package/dist/ui/clack-api.d.ts.map +1 -0
- package/dist/ui/clack-api.js +76 -0
- package/dist/ui/clack-api.js.map +1 -0
- package/dist/ui/clack.d.ts +14 -0
- package/dist/ui/clack.d.ts.map +1 -0
- package/dist/ui/clack.js +147 -0
- package/dist/ui/clack.js.map +1 -0
- package/dist/ui/components/FlowSpinner.d.ts +5 -0
- package/dist/ui/components/FlowSpinner.d.ts.map +1 -0
- package/dist/ui/components/FlowSpinner.js +8 -0
- package/dist/ui/components/FlowSpinner.js.map +1 -0
- package/dist/ui/components/LogoWordmark.d.ts +9 -0
- package/dist/ui/components/LogoWordmark.d.ts.map +1 -0
- package/dist/ui/components/LogoWordmark.js +17 -0
- package/dist/ui/components/LogoWordmark.js.map +1 -0
- package/dist/ui/components/PromptPanel.d.ts +5 -0
- package/dist/ui/components/PromptPanel.d.ts.map +1 -0
- package/dist/ui/components/PromptPanel.js +7 -0
- package/dist/ui/components/PromptPanel.js.map +1 -0
- package/dist/ui/components/SelectField.d.ts +11 -0
- package/dist/ui/components/SelectField.d.ts.map +1 -0
- package/dist/ui/components/SelectField.js +19 -0
- package/dist/ui/components/SelectField.js.map +1 -0
- package/dist/ui/confirm.d.ts +2 -1
- package/dist/ui/confirm.d.ts.map +1 -1
- package/dist/ui/confirm.js +4 -4
- package/dist/ui/confirm.js.map +1 -1
- package/dist/ui/dev/DevDashboard.d.ts +8 -0
- package/dist/ui/dev/DevDashboard.d.ts.map +1 -0
- package/dist/ui/dev/DevDashboard.js +151 -0
- package/dist/ui/dev/DevDashboard.js.map +1 -0
- package/dist/ui/dev/DevReadyPanelView.d.ts +7 -0
- package/dist/ui/dev/DevReadyPanelView.d.ts.map +1 -0
- package/dist/ui/dev/DevReadyPanelView.js +29 -0
- package/dist/ui/dev/DevReadyPanelView.js.map +1 -0
- package/dist/ui/fatal.d.ts.map +1 -1
- package/dist/ui/fatal.js +5 -11
- package/dist/ui/fatal.js.map +1 -1
- package/dist/ui/flows/FlowApp.d.ts +8 -0
- package/dist/ui/flows/FlowApp.d.ts.map +1 -0
- package/dist/ui/flows/FlowApp.js +42 -0
- package/dist/ui/flows/FlowApp.js.map +1 -0
- package/dist/ui/flows/prompt-fields.d.ts +48 -0
- package/dist/ui/flows/prompt-fields.d.ts.map +1 -0
- package/dist/ui/flows/prompt-fields.js +88 -0
- package/dist/ui/flows/prompt-fields.js.map +1 -0
- package/dist/ui/flows/types.d.ts +41 -0
- package/dist/ui/flows/types.d.ts.map +1 -0
- package/dist/ui/flows/types.js +2 -0
- package/dist/ui/flows/types.js.map +1 -0
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +1 -1
- package/dist/ui/messages.d.ts +1 -0
- package/dist/ui/messages.d.ts.map +1 -1
- package/dist/ui/messages.js +48 -8
- package/dist/ui/messages.js.map +1 -1
- package/dist/ui/progress.d.ts +5 -1
- package/dist/ui/progress.d.ts.map +1 -1
- package/dist/ui/progress.js +12 -3
- package/dist/ui/progress.js.map +1 -1
- package/dist/ui/prompts.d.ts +7 -5
- package/dist/ui/prompts.d.ts.map +1 -1
- package/dist/ui/prompts.js +15 -8
- package/dist/ui/prompts.js.map +1 -1
- package/dist/ui/runtime/cancel.d.ts +4 -0
- package/dist/ui/runtime/cancel.d.ts.map +1 -0
- package/dist/ui/runtime/cancel.js +6 -0
- package/dist/ui/runtime/cancel.js.map +1 -0
- package/dist/ui/runtime/command-chrome.d.ts +17 -0
- package/dist/ui/runtime/command-chrome.d.ts.map +1 -0
- package/dist/ui/runtime/command-chrome.js +123 -0
- package/dist/ui/runtime/command-chrome.js.map +1 -0
- package/dist/ui/runtime/dev-prompt-queue.d.ts +30 -0
- package/dist/ui/runtime/dev-prompt-queue.d.ts.map +1 -0
- package/dist/ui/runtime/dev-prompt-queue.js +57 -0
- package/dist/ui/runtime/dev-prompt-queue.js.map +1 -0
- package/dist/ui/runtime/flow-session.d.ts +4 -0
- package/dist/ui/runtime/flow-session.d.ts.map +1 -0
- package/dist/ui/runtime/flow-session.js +8 -0
- package/dist/ui/runtime/flow-session.js.map +1 -0
- package/dist/ui/runtime/run-clack-flow.d.ts +5 -0
- package/dist/ui/runtime/run-clack-flow.d.ts.map +1 -0
- package/dist/ui/runtime/run-clack-flow.js +34 -0
- package/dist/ui/runtime/run-clack-flow.js.map +1 -0
- package/dist/ui/theme.d.ts +24 -0
- package/dist/ui/theme.d.ts.map +1 -0
- package/dist/ui/theme.js +34 -0
- package/dist/ui/theme.js.map +1 -0
- package/dist/valkey-sidecar.d.ts +17 -0
- package/dist/valkey-sidecar.d.ts.map +1 -0
- package/dist/valkey-sidecar.js +94 -0
- package/dist/valkey-sidecar.js.map +1 -0
- package/package.json +9 -3
- package/src/binary-cache.ts +61 -0
- package/src/binary-download-lock.ts +124 -0
- package/src/cli-package-version.ts +15 -0
- package/src/cli.ts +6 -2
- package/src/commands/add.ts +26 -19
- package/src/commands/admin.ts +24 -6
- package/src/commands/cache.ts +105 -5
- package/src/commands/dev.ts +26 -21
- package/src/commands/init.ts +124 -45
- package/src/commands/link-helpers.ts +30 -29
- package/src/compose-local-server-image.ts +68 -0
- package/src/compose-rename.ts +5 -8
- package/src/dev-compose.ts +136 -51
- package/src/dev-log-bus.ts +18 -0
- package/src/dev-log-filter.ts +42 -0
- package/src/dev-ports.ts +22 -11
- package/src/dev-ready-panel.ts +63 -0
- package/src/dev-session-lock.ts +5 -8
- package/src/dev-session.ts +98 -18
- package/src/dev-shutdown.ts +29 -17
- package/src/dev-task-colors.ts +22 -3
- package/src/docker-runtime.ts +1 -1
- package/src/engine-push-output.ts +5 -1
- package/src/ensure-binary.ts +21 -1
- package/src/ensure-component-binaries.ts +71 -0
- package/src/ensure-dev-api-config.ts +18 -0
- package/src/init-dependency-versions.ts +69 -0
- package/src/init-package-json.ts +63 -0
- package/src/postgres-ctl.ts +2 -1
- package/src/required-host-components.ts +37 -0
- package/src/resolve-api-url.ts +43 -0
- package/src/rest-cache-admin.ts +135 -0
- package/src/scripts/postinstall.ts +9 -46
- package/src/self-host-compose.ts +22 -12
- package/src/studio-dev-server.ts +5 -4
- package/src/ui/README.md +13 -9
- package/src/ui/brand.ts +2 -8
- package/src/ui/clack-api.ts +123 -0
- package/src/ui/clack.ts +153 -0
- package/src/ui/components/FlowSpinner.tsx +15 -0
- package/src/ui/components/LogoWordmark.tsx +36 -0
- package/src/ui/components/PromptPanel.tsx +17 -0
- package/src/ui/components/SelectField.tsx +58 -0
- package/src/ui/confirm.ts +5 -4
- package/src/ui/dev/DevDashboard.tsx +213 -0
- package/src/ui/dev/DevReadyPanelView.tsx +67 -0
- package/src/ui/fatal.ts +5 -10
- package/src/ui/flows/FlowApp.tsx +67 -0
- package/src/ui/flows/prompt-fields.tsx +192 -0
- package/src/ui/flows/types.ts +50 -0
- package/src/ui/index.ts +1 -1
- package/src/ui/messages.ts +50 -8
- package/src/ui/progress.ts +14 -3
- package/src/ui/prompts.ts +17 -9
- package/src/ui/runtime/cancel.ts +6 -0
- package/src/ui/runtime/command-chrome.ts +147 -0
- package/src/ui/runtime/dev-prompt-queue.ts +84 -0
- package/src/ui/runtime/flow-session.ts +11 -0
- package/src/ui/runtime/run-clack-flow.tsx +52 -0
- package/src/ui/theme.ts +41 -0
- package/src/valkey-sidecar.ts +126 -0
- package/tests/binary-cache-cloud-overrides.test.ts +2 -2
- package/tests/binary-download-lock.test.ts +41 -0
- package/tests/cli-help.test.ts +7 -4
- package/tests/cli-package-version.test.ts +15 -0
- package/tests/command-chrome-coverage.test.ts +149 -0
- package/tests/command-chrome-wrap.test.ts +51 -0
- package/tests/config.test.ts +8 -4
- package/tests/dev-ready-panel.test.ts +20 -0
- package/tests/dev-ui.test.ts +42 -2
- package/tests/docker-runtime.test.ts +9 -20
- package/tests/ensure-dev-api-config.test.ts +22 -0
- package/tests/init-dependency-versions.test.ts +62 -0
- package/tests/init-package-json.test.ts +18 -0
- package/tests/init.test.ts +30 -3
- package/tests/required-host-components.test.ts +51 -0
- package/tests/resolve-api-url.test.ts +23 -0
- package/tests/rest-cache-admin.test.ts +28 -0
- package/tests/runtime-contract.test.ts +12 -3
- package/tests/tsconfig.json +8 -2
- package/tests/ui-confirm.test.ts +13 -9
- package/tests/ui-messages.test.ts +4 -18
- package/tsconfig.json +1 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/vitest.config.ts +3 -0
- package/dist/dev-tui.d.ts +0 -24
- package/dist/dev-tui.d.ts.map +0 -1
- package/dist/dev-tui.js +0 -188
- package/dist/dev-tui.js.map +0 -1
- package/src/dev-tui.ts +0 -232
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import { Box, Text } from "ink"
|
|
3
|
+
import { layoutLogoBlock, pickLogoLines } from "../../dev-logo.js"
|
|
4
|
+
import { theme } from "../theme.js"
|
|
5
|
+
|
|
6
|
+
function truncatePlain(text: string, width: number): string {
|
|
7
|
+
if (text.length <= width) return text
|
|
8
|
+
if (width <= 1) return text.slice(0, width)
|
|
9
|
+
return `${text.slice(0, width - 1)}…`
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface LogoWordmarkProps {
|
|
13
|
+
maxWidth?: number
|
|
14
|
+
/** Small caption under the figlet wordmark. */
|
|
15
|
+
tagline?: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Figlet slant wordmark — native Ink colours (no embedded ANSI). */
|
|
19
|
+
export function LogoWordmark({ maxWidth, tagline }: LogoWordmarkProps): React.ReactElement {
|
|
20
|
+
const lines = layoutLogoBlock(pickLogoLines())
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<Box flexDirection="column" marginBottom={tagline ? 0 : 1}>
|
|
24
|
+
{lines.map((line, index) => (
|
|
25
|
+
<Text key={`logo-${index}`} bold color={theme.brand}>
|
|
26
|
+
{maxWidth !== undefined ? truncatePlain(line, maxWidth) : line}
|
|
27
|
+
</Text>
|
|
28
|
+
))}
|
|
29
|
+
{tagline ? (
|
|
30
|
+
<Text dimColor color={theme.brand}>
|
|
31
|
+
{tagline}
|
|
32
|
+
</Text>
|
|
33
|
+
) : null}
|
|
34
|
+
</Box>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, { type ReactNode } from "react"
|
|
2
|
+
import { Box } from "ink"
|
|
3
|
+
import { theme } from "../theme.js"
|
|
4
|
+
|
|
5
|
+
export function PromptPanel({ children }: { children: ReactNode }): React.ReactElement {
|
|
6
|
+
return (
|
|
7
|
+
<Box
|
|
8
|
+
marginTop={1}
|
|
9
|
+
borderStyle="round"
|
|
10
|
+
borderColor={theme.brand}
|
|
11
|
+
paddingX={1}
|
|
12
|
+
flexDirection="column"
|
|
13
|
+
>
|
|
14
|
+
{children}
|
|
15
|
+
</Box>
|
|
16
|
+
)
|
|
17
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React, { type FC } from "react"
|
|
2
|
+
import { Box, Text, useInput } from "ink"
|
|
3
|
+
import SelectInput from "ink-select-input"
|
|
4
|
+
import { theme } from "../theme.js"
|
|
5
|
+
import type { DevSelectOption } from "../runtime/dev-prompt-queue.js"
|
|
6
|
+
|
|
7
|
+
export interface SelectFieldProps {
|
|
8
|
+
message: string
|
|
9
|
+
options: DevSelectOption[]
|
|
10
|
+
initialValue?: string
|
|
11
|
+
onSubmit: (value: string) => void
|
|
12
|
+
onCancel: () => void
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const BrandIndicator: FC<{ isSelected?: boolean }> = ({ isSelected }) => (
|
|
16
|
+
<Text {...(isSelected ? { color: theme.brand, bold: true } : { dimColor: true })}>
|
|
17
|
+
{isSelected ? "▸ " : " "}
|
|
18
|
+
</Text>
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
const BrandItem: FC<{ isSelected?: boolean; label: string }> = ({ isSelected, label }) => (
|
|
22
|
+
<Text {...(isSelected ? { color: theme.brand, bold: true } : {})}>{label}</Text>
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
export function SelectField({
|
|
26
|
+
message,
|
|
27
|
+
options,
|
|
28
|
+
initialValue,
|
|
29
|
+
onSubmit,
|
|
30
|
+
onCancel,
|
|
31
|
+
}: SelectFieldProps): React.ReactElement {
|
|
32
|
+
useInput((_input, key) => {
|
|
33
|
+
if (key.escape) onCancel()
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
const items = options.map((opt) => ({
|
|
37
|
+
label: opt.hint ? `${opt.label} — ${opt.hint}` : opt.label,
|
|
38
|
+
value: opt.value,
|
|
39
|
+
}))
|
|
40
|
+
|
|
41
|
+
const foundIndex = items.findIndex((item) => item.value === initialValue)
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<Box flexDirection="column">
|
|
45
|
+
<Text bold color={theme.brand}>
|
|
46
|
+
{message}
|
|
47
|
+
</Text>
|
|
48
|
+
<SelectInput
|
|
49
|
+
items={items}
|
|
50
|
+
{...(foundIndex >= 0 ? { initialIndex: foundIndex } : {})}
|
|
51
|
+
indicatorComponent={BrandIndicator}
|
|
52
|
+
itemComponent={BrandItem}
|
|
53
|
+
onSelect={(item) => onSubmit(item.value)}
|
|
54
|
+
/>
|
|
55
|
+
<Text dimColor>↑/↓ or j/k · enter · esc cancel · 1-9 quick pick</Text>
|
|
56
|
+
</Box>
|
|
57
|
+
)
|
|
58
|
+
}
|
package/src/ui/confirm.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as p from "@clack/prompts"
|
|
2
1
|
import { isInteractive } from "./interactive.js"
|
|
2
|
+
import { CLACK_CANCEL, isCancel, p } from "./clack.js"
|
|
3
3
|
import { plain } from "./messages.js"
|
|
4
4
|
|
|
5
5
|
export interface ConfirmOptions {
|
|
@@ -9,7 +9,7 @@ export interface ConfirmOptions {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* Yes/no confirmation —
|
|
12
|
+
* Yes/no confirmation — Ink overlay in dev, Ink flow in TTY, default otherwise.
|
|
13
13
|
*/
|
|
14
14
|
export async function confirm(message: string, opts: ConfirmOptions = {}): Promise<boolean> {
|
|
15
15
|
const fallback = opts.nonInteractive ?? opts.default ?? false
|
|
@@ -24,9 +24,8 @@ export async function confirm(message: string, opts: ConfirmOptions = {}): Promi
|
|
|
24
24
|
initialValue: opts.default ?? false,
|
|
25
25
|
})
|
|
26
26
|
|
|
27
|
-
if (
|
|
27
|
+
if (isCancel(value)) {
|
|
28
28
|
p.cancel("Cancelled.")
|
|
29
|
-
process.exit(0)
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
return value
|
|
@@ -36,3 +35,5 @@ export async function confirm(message: string, opts: ConfirmOptions = {}): Promi
|
|
|
36
35
|
export function logSkippedConfirm(reason: string): void {
|
|
37
36
|
plain(`${reason} (use --yes to skip confirmation)`)
|
|
38
37
|
}
|
|
38
|
+
|
|
39
|
+
export { isCancel, CLACK_CANCEL } from "./clack.js"
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import React, { useEffect, useState } from "react"
|
|
2
|
+
import { Box, Text, useInput, useStdout } from "ink"
|
|
3
|
+
import type { DevLogBus } from "../../dev-log-bus.js"
|
|
4
|
+
import { stripAnsi } from "../../dev-log-filter.js"
|
|
5
|
+
import { logoRowCount } from "../../dev-logo.js"
|
|
6
|
+
import { logInkColor, taskInkColor } from "../../dev-task-colors.js"
|
|
7
|
+
import { LogoWordmark } from "../components/LogoWordmark.js"
|
|
8
|
+
import { PromptPanel } from "../components/PromptPanel.js"
|
|
9
|
+
import { DevReadyPanelView } from "./DevReadyPanelView.js"
|
|
10
|
+
import { theme } from "../theme.js"
|
|
11
|
+
import { requestDevShutdown } from "../../dev-shutdown.js"
|
|
12
|
+
import {
|
|
13
|
+
getActiveDevPrompt,
|
|
14
|
+
resolveDevPrompt,
|
|
15
|
+
subscribeDevPrompts,
|
|
16
|
+
} from "../runtime/dev-prompt-queue.js"
|
|
17
|
+
import { CLACK_CANCEL } from "../runtime/cancel.js"
|
|
18
|
+
import { ActiveFlowPromptView } from "../flows/prompt-fields.js"
|
|
19
|
+
import type { ActiveFlowPrompt } from "../flows/types.js"
|
|
20
|
+
|
|
21
|
+
const TASK_COL_WIDTH = 22
|
|
22
|
+
const MIN_WIDTH = 60
|
|
23
|
+
const MIN_HEIGHT = 14
|
|
24
|
+
const TAGLINE = "local development"
|
|
25
|
+
|
|
26
|
+
function truncate(text: string, width: number): string {
|
|
27
|
+
if (width <= 0) return ""
|
|
28
|
+
if (text.length <= width) return text
|
|
29
|
+
if (width <= 1) return text.slice(0, width)
|
|
30
|
+
return `${text.slice(0, width - 1)}…`
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function padPlain(text: string, width: number): string {
|
|
34
|
+
if (text.length >= width) return text
|
|
35
|
+
return text + " ".repeat(width - text.length)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function devPromptToFlowPrompt(prompt: NonNullable<ReturnType<typeof getActiveDevPrompt>>): ActiveFlowPrompt {
|
|
39
|
+
switch (prompt.kind) {
|
|
40
|
+
case "confirm":
|
|
41
|
+
return {
|
|
42
|
+
kind: "confirm",
|
|
43
|
+
message: prompt.message,
|
|
44
|
+
initialValue: typeof prompt.initialValue === "boolean" ? prompt.initialValue : false,
|
|
45
|
+
}
|
|
46
|
+
case "text":
|
|
47
|
+
return {
|
|
48
|
+
kind: "text",
|
|
49
|
+
message: prompt.message,
|
|
50
|
+
...(prompt.defaultValue !== undefined ? { defaultValue: prompt.defaultValue } : {}),
|
|
51
|
+
...(prompt.placeholder !== undefined ? { placeholder: prompt.placeholder } : {}),
|
|
52
|
+
...(prompt.validate !== undefined ? { validate: prompt.validate } : {}),
|
|
53
|
+
}
|
|
54
|
+
case "password":
|
|
55
|
+
return { kind: "password", message: prompt.message }
|
|
56
|
+
case "select":
|
|
57
|
+
return {
|
|
58
|
+
kind: "select",
|
|
59
|
+
message: prompt.message,
|
|
60
|
+
options: prompt.options ?? [],
|
|
61
|
+
...(typeof prompt.initialValue === "string" ? { initialValue: prompt.initialValue } : {}),
|
|
62
|
+
}
|
|
63
|
+
default:
|
|
64
|
+
return { kind: "confirm", message: prompt.message, initialValue: false }
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function scrollHint(scrollFromBottom: number, total: number, visible: number): string {
|
|
69
|
+
if (total <= visible) return "all lines visible"
|
|
70
|
+
if (scrollFromBottom === 0) return "latest"
|
|
71
|
+
if (scrollFromBottom >= total - visible) return "oldest"
|
|
72
|
+
return `${scrollFromBottom} lines up from latest`
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
interface DevDashboardProps {
|
|
76
|
+
bus: DevLogBus
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function DevDashboard({ bus }: DevDashboardProps): React.ReactElement {
|
|
80
|
+
const { stdout } = useStdout()
|
|
81
|
+
const cols = Math.max(MIN_WIDTH, stdout.columns ?? 80)
|
|
82
|
+
const rows = Math.max(MIN_HEIGHT, stdout.rows ?? 24)
|
|
83
|
+
const [, tick] = useState(0)
|
|
84
|
+
const [scrollFromBottom, setScrollFromBottom] = useState(0)
|
|
85
|
+
const [activePrompt, setActivePrompt] = useState(getActiveDevPrompt())
|
|
86
|
+
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
const offBus = bus.onUpdate(() => tick((n) => n + 1))
|
|
89
|
+
const offPrompt = subscribeDevPrompts(() => setActivePrompt(getActiveDevPrompt()))
|
|
90
|
+
return () => {
|
|
91
|
+
offBus()
|
|
92
|
+
offPrompt()
|
|
93
|
+
}
|
|
94
|
+
}, [bus])
|
|
95
|
+
|
|
96
|
+
const promptOpen = activePrompt !== null
|
|
97
|
+
const focusedId = bus.getFocusedTaskId()
|
|
98
|
+
const taskIds = bus.getTaskOrder()
|
|
99
|
+
const readyPanel = bus.getReadyPanel()
|
|
100
|
+
const readyRows = readyPanel ? bus.readyPanelRowCount() : 0
|
|
101
|
+
const logoRows = logoRowCount() + 1 // figlet + tagline
|
|
102
|
+
const chromeRows = logoRows + readyRows + 2 // separator + keybindings line
|
|
103
|
+
const logHeight = Math.max(4, rows - chromeRows - (promptOpen ? 6 : 0) - 1)
|
|
104
|
+
const logWidth = cols - TASK_COL_WIDTH - 1
|
|
105
|
+
|
|
106
|
+
useInput((input, key) => {
|
|
107
|
+
if (promptOpen) return
|
|
108
|
+
|
|
109
|
+
if ((key.ctrl && input === "c") || input === "\x03") {
|
|
110
|
+
requestDevShutdown()
|
|
111
|
+
return
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (key.downArrow || input === "j") {
|
|
115
|
+
bus.focusNext()
|
|
116
|
+
setScrollFromBottom(0)
|
|
117
|
+
return
|
|
118
|
+
}
|
|
119
|
+
if (key.upArrow || input === "k") {
|
|
120
|
+
bus.focusPrevious()
|
|
121
|
+
setScrollFromBottom(0)
|
|
122
|
+
return
|
|
123
|
+
}
|
|
124
|
+
if (input === "u") {
|
|
125
|
+
setScrollFromBottom((s) =>
|
|
126
|
+
Math.min(s + 3, Math.max(0, (bus.getTask(focusedId)?.lines.length ?? 0) - logHeight)),
|
|
127
|
+
)
|
|
128
|
+
return
|
|
129
|
+
}
|
|
130
|
+
if (input === "d") {
|
|
131
|
+
setScrollFromBottom((s) => Math.max(s - 3, 0))
|
|
132
|
+
return
|
|
133
|
+
}
|
|
134
|
+
if (input === "g") {
|
|
135
|
+
setScrollFromBottom(Math.max(0, (bus.getTask(focusedId)?.lines.length ?? 0) - logHeight))
|
|
136
|
+
return
|
|
137
|
+
}
|
|
138
|
+
if (input === "G") {
|
|
139
|
+
setScrollFromBottom(0)
|
|
140
|
+
}
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
const taskLines = bus.getTask(focusedId)?.lines ?? []
|
|
144
|
+
const totalLines = taskLines.length
|
|
145
|
+
const end = totalLines - scrollFromBottom
|
|
146
|
+
const start = Math.max(0, end - logHeight)
|
|
147
|
+
|
|
148
|
+
return (
|
|
149
|
+
<Box flexDirection="column" width={cols} height={rows}>
|
|
150
|
+
<LogoWordmark maxWidth={cols} tagline={TAGLINE} />
|
|
151
|
+
{readyPanel ? <DevReadyPanelView panel={readyPanel} width={cols} /> : null}
|
|
152
|
+
<Text dimColor>{"─".repeat(cols)}</Text>
|
|
153
|
+
<Text dimColor>
|
|
154
|
+
{truncate(" ↑/k ↓/j task u/d scroll g/G top/bottom Ctrl+C quit", cols)}
|
|
155
|
+
</Text>
|
|
156
|
+
|
|
157
|
+
{Array.from({ length: logHeight }, (_, row) => {
|
|
158
|
+
const taskId = taskIds[row]
|
|
159
|
+
const task = taskId ? bus.getTask(taskId) : undefined
|
|
160
|
+
let left = " ".repeat(TASK_COL_WIDTH)
|
|
161
|
+
if (task && taskId) {
|
|
162
|
+
const marker = taskId === focusedId ? "▶" : " "
|
|
163
|
+
const unread = task.unread ? " •" : " "
|
|
164
|
+
const label = truncate(`${marker} ${task.title}${unread}`, TASK_COL_WIDTH - 1)
|
|
165
|
+
left = padPlain(label, TASK_COL_WIDTH)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const index = start + row
|
|
169
|
+
const rawFull = index >= end || index >= totalLines ? "" : (taskLines[index] ?? "")
|
|
170
|
+
const raw = stripAnsi(rawFull)
|
|
171
|
+
const logLine = padPlain(truncate(raw, logWidth), logWidth)
|
|
172
|
+
|
|
173
|
+
return (
|
|
174
|
+
<Box key={`row-${row}`}>
|
|
175
|
+
<Text
|
|
176
|
+
{...(taskId === focusedId ? { bold: true } : {})}
|
|
177
|
+
color={taskId ? taskInkColor(taskId) : theme.dim}
|
|
178
|
+
>
|
|
179
|
+
{left}
|
|
180
|
+
</Text>
|
|
181
|
+
<Text dimColor>│</Text>
|
|
182
|
+
<Text
|
|
183
|
+
{...(raw
|
|
184
|
+
? { color: logInkColor(focusedId, raw) }
|
|
185
|
+
: { dimColor: true })}
|
|
186
|
+
>
|
|
187
|
+
{logLine}
|
|
188
|
+
</Text>
|
|
189
|
+
</Box>
|
|
190
|
+
)
|
|
191
|
+
})}
|
|
192
|
+
|
|
193
|
+
<Text dimColor>{"─".repeat(cols)}</Text>
|
|
194
|
+
<Text>
|
|
195
|
+
<Text dimColor> focused </Text>
|
|
196
|
+
<Text color={taskInkColor(focusedId)} bold>
|
|
197
|
+
{bus.getTask(focusedId)?.title ?? focusedId}
|
|
198
|
+
</Text>
|
|
199
|
+
<Text dimColor>{` · ${scrollHint(scrollFromBottom, totalLines, logHeight)}`}</Text>
|
|
200
|
+
</Text>
|
|
201
|
+
|
|
202
|
+
{promptOpen && activePrompt ? (
|
|
203
|
+
<PromptPanel>
|
|
204
|
+
<ActiveFlowPromptView
|
|
205
|
+
prompt={devPromptToFlowPrompt(activePrompt)}
|
|
206
|
+
onSubmit={(value) => resolveDevPrompt(value)}
|
|
207
|
+
onCancel={() => resolveDevPrompt(CLACK_CANCEL)}
|
|
208
|
+
/>
|
|
209
|
+
</PromptPanel>
|
|
210
|
+
) : null}
|
|
211
|
+
</Box>
|
|
212
|
+
)
|
|
213
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import { Box, Text } from "ink"
|
|
3
|
+
import type { DevReadyPanel } from "../../dev-ready-panel.js"
|
|
4
|
+
import { theme } from "../theme.js"
|
|
5
|
+
|
|
6
|
+
function truncate(text: string, width: number): string {
|
|
7
|
+
if (width <= 0) return ""
|
|
8
|
+
if (text.length <= width) return text
|
|
9
|
+
if (width <= 1) return text.slice(0, width)
|
|
10
|
+
return `${text.slice(0, width - 1)}…`
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function shortenKey(key: string, width: number): string {
|
|
14
|
+
if (key.length <= width) return key
|
|
15
|
+
if (width <= 12) return truncate(key, width)
|
|
16
|
+
return `${key.slice(0, width - 10)}…${key.slice(-8)}`
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Inner text width inside the round border + horizontal padding. */
|
|
20
|
+
function panelInnerWidth(outerWidth: number): number {
|
|
21
|
+
return Math.max(20, outerWidth - 4)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function DevReadyPanelView({
|
|
25
|
+
panel,
|
|
26
|
+
width,
|
|
27
|
+
}: {
|
|
28
|
+
panel: DevReadyPanel
|
|
29
|
+
width: number
|
|
30
|
+
}): React.ReactElement {
|
|
31
|
+
const innerWidth = panelInnerWidth(width)
|
|
32
|
+
const labelWidth = 14
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<Box
|
|
36
|
+
flexDirection="column"
|
|
37
|
+
marginBottom={1}
|
|
38
|
+
borderStyle="round"
|
|
39
|
+
borderColor={theme.brand}
|
|
40
|
+
paddingX={1}
|
|
41
|
+
>
|
|
42
|
+
<Text bold color={theme.brand}>
|
|
43
|
+
{truncate(panel.title, innerWidth)}
|
|
44
|
+
</Text>
|
|
45
|
+
{panel.links.map((link) => (
|
|
46
|
+
<Box key={`${link.label}-${link.url}`}>
|
|
47
|
+
<Text dimColor>{truncate(link.label.padEnd(labelWidth), labelWidth)}</Text>
|
|
48
|
+
<Text color={theme.info}>{truncate(link.url, innerWidth - labelWidth)}</Text>
|
|
49
|
+
</Box>
|
|
50
|
+
))}
|
|
51
|
+
{panel.hints?.map((hint) => (
|
|
52
|
+
<Text key={hint} dimColor>
|
|
53
|
+
{truncate(hint, innerWidth)}
|
|
54
|
+
</Text>
|
|
55
|
+
))}
|
|
56
|
+
{panel.anonKey ? (
|
|
57
|
+
<>
|
|
58
|
+
<Text dimColor>API keys (local dev)</Text>
|
|
59
|
+
<Text dimColor>{`anon ${shortenKey(panel.anonKey, innerWidth - 5)}`}</Text>
|
|
60
|
+
{panel.serviceRoleKey ? (
|
|
61
|
+
<Text dimColor>{`svc ${shortenKey(panel.serviceRoleKey, innerWidth - 5)}`}</Text>
|
|
62
|
+
) : null}
|
|
63
|
+
</>
|
|
64
|
+
) : null}
|
|
65
|
+
</Box>
|
|
66
|
+
)
|
|
67
|
+
}
|
package/src/ui/fatal.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import * as p from "@clack/prompts"
|
|
2
1
|
import type { DockerBrandOptions } from "../docker-runtime.js"
|
|
3
2
|
import { isInteractive } from "./interactive.js"
|
|
4
3
|
import { error, plain } from "./messages.js"
|
|
5
|
-
import {
|
|
4
|
+
import { printLogo } from "./prompts.js"
|
|
6
5
|
|
|
7
6
|
export type FatalOptions = {
|
|
8
7
|
brand?: DockerBrandOptions
|
|
@@ -13,19 +12,15 @@ export type FatalOptions = {
|
|
|
13
12
|
export function fatalError(message: string, hints: string[] = [], opts?: FatalOptions): never {
|
|
14
13
|
if (opts?.brand && isInteractive()) {
|
|
15
14
|
printLogo()
|
|
16
|
-
|
|
15
|
+
plain(opts.brand.intro)
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
error(message)
|
|
20
19
|
|
|
21
20
|
if (hints.length > 0) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
for (const hint of hints) {
|
|
26
|
-
plain()
|
|
27
|
-
plain(` ${hint}`)
|
|
28
|
-
}
|
|
21
|
+
for (const hint of hints) {
|
|
22
|
+
plain()
|
|
23
|
+
plain(` ${hint}`)
|
|
29
24
|
}
|
|
30
25
|
}
|
|
31
26
|
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from "react"
|
|
2
|
+
import { Box } from "ink"
|
|
3
|
+
import { PromptPanel } from "../components/PromptPanel.js"
|
|
4
|
+
import { CLACK_CANCEL } from "../runtime/cancel.js"
|
|
5
|
+
import {
|
|
6
|
+
ActiveFlowPromptView,
|
|
7
|
+
FlowLogPane,
|
|
8
|
+
FlowLogoHeader,
|
|
9
|
+
FlowSpinnerLine,
|
|
10
|
+
} from "./prompt-fields.js"
|
|
11
|
+
import type { ActiveFlowPrompt, FlowController, FlowLogLine } from "./types.js"
|
|
12
|
+
|
|
13
|
+
interface FlowAppProps {
|
|
14
|
+
bind: (controller: FlowController) => void
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function FlowApp({ bind }: FlowAppProps): React.ReactElement {
|
|
18
|
+
const [logLines, setLogLines] = useState<FlowLogLine[]>([])
|
|
19
|
+
const [spinner, setSpinner] = useState<string | null>(null)
|
|
20
|
+
const [prompt, setPrompt] = useState<ActiveFlowPrompt | null>(null)
|
|
21
|
+
const [promptResolver, setPromptResolver] = useState<((value: unknown) => void) | null>(null)
|
|
22
|
+
const bound = useRef(false)
|
|
23
|
+
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (bound.current) return
|
|
26
|
+
bound.current = true
|
|
27
|
+
const controller: FlowController = {
|
|
28
|
+
appendLog(level, text) {
|
|
29
|
+
setLogLines((lines) => [...lines, { level, text }])
|
|
30
|
+
},
|
|
31
|
+
appendPlain(text) {
|
|
32
|
+
setLogLines((lines) => [...lines, { level: "plain", text }])
|
|
33
|
+
},
|
|
34
|
+
setSpinner(message) {
|
|
35
|
+
setSpinner(message)
|
|
36
|
+
},
|
|
37
|
+
waitForPrompt<T>(spec: ActiveFlowPrompt): Promise<T> {
|
|
38
|
+
return new Promise<T>((resolve) => {
|
|
39
|
+
setPrompt(spec)
|
|
40
|
+
setPromptResolver(() => (value: unknown) => {
|
|
41
|
+
setPrompt(null)
|
|
42
|
+
setPromptResolver(null)
|
|
43
|
+
resolve(value as T)
|
|
44
|
+
})
|
|
45
|
+
})
|
|
46
|
+
},
|
|
47
|
+
}
|
|
48
|
+
bind(controller)
|
|
49
|
+
}, [bind])
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<Box flexDirection="column" paddingX={1}>
|
|
53
|
+
<FlowLogoHeader />
|
|
54
|
+
<FlowLogPane lines={logLines} />
|
|
55
|
+
{spinner ? <FlowSpinnerLine message={spinner} /> : null}
|
|
56
|
+
{prompt && promptResolver ? (
|
|
57
|
+
<PromptPanel>
|
|
58
|
+
<ActiveFlowPromptView
|
|
59
|
+
prompt={prompt}
|
|
60
|
+
onSubmit={(value) => promptResolver(value)}
|
|
61
|
+
onCancel={() => promptResolver(CLACK_CANCEL)}
|
|
62
|
+
/>
|
|
63
|
+
</PromptPanel>
|
|
64
|
+
) : null}
|
|
65
|
+
</Box>
|
|
66
|
+
)
|
|
67
|
+
}
|