@sixb/cli 0.1.14 → 0.1.16
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/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/deploy.d.ts +48 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/lib/agent-turn-timeout.d.ts +2 -0
- package/dist/lib/agent-turn-timeout.d.ts.map +1 -1
- package/dist/lib/command-line.d.ts +34 -4
- package/dist/lib/command-line.d.ts.map +1 -1
- package/dist/lib/deploy-config.d.ts +9 -0
- package/dist/lib/deploy-config.d.ts.map +1 -0
- package/dist/lib/deploy-release.d.ts +7 -0
- package/dist/lib/deploy-release.d.ts.map +1 -0
- package/dist/lib/deploy-source.d.ts +23 -0
- package/dist/lib/deploy-source.d.ts.map +1 -0
- package/dist/lib/github-ci.d.ts +49 -0
- package/dist/lib/github-ci.d.ts.map +1 -0
- package/dist/ui/index.d.ts +62 -0
- package/dist/ui/index.d.ts.map +1 -1
- package/package.json +14 -13
- package/src/commands/check.tsx +23 -1
- package/src/commands/deploy.tsx +403 -0
- package/src/index.tsx +63 -0
- package/src/lib/agent-turn-timeout.ts +10 -4
- package/src/lib/command-line.ts +114 -5
- package/src/lib/deploy-config.ts +32 -0
- package/src/lib/deploy-release.ts +250 -0
- package/src/lib/deploy-source.ts +189 -0
- package/src/lib/github-ci.ts +246 -0
- package/src/ui/index.tsx +468 -2
package/src/ui/index.tsx
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
DeployAccessKey,
|
|
3
|
+
DeployCheck,
|
|
4
|
+
DeployCommand,
|
|
5
|
+
DeployRelease,
|
|
6
|
+
DeployStatus,
|
|
7
|
+
} from "@sixb/core/deploy"
|
|
1
8
|
import { Box, render, Text } from "ink"
|
|
2
9
|
import type React from "react"
|
|
3
10
|
import { useEffect, useMemo, useState } from "react"
|
|
@@ -97,7 +104,7 @@ function Table({
|
|
|
97
104
|
<Text>
|
|
98
105
|
{headers.map((header, index) => (
|
|
99
106
|
<Text key={`${index}:${header}`} bold>
|
|
100
|
-
{
|
|
107
|
+
{header.padEnd(widths[index] ?? header.length)}
|
|
101
108
|
{index === headers.length - 1 ? "" : " "}
|
|
102
109
|
</Text>
|
|
103
110
|
))}
|
|
@@ -107,7 +114,7 @@ function Table({
|
|
|
107
114
|
<Text key={`${rowIndex}:${row.join(":")}`}>
|
|
108
115
|
{row.map((value, index) => (
|
|
109
116
|
<Text key={`${index}:${value}`}>
|
|
110
|
-
{
|
|
117
|
+
{value.padEnd(widths[index] ?? value.length)}
|
|
111
118
|
{index === row.length - 1 ? "" : " "}
|
|
112
119
|
</Text>
|
|
113
120
|
))}
|
|
@@ -781,6 +788,465 @@ export function LakeCheckView({ projectId, status }: { projectId: string; status
|
|
|
781
788
|
)
|
|
782
789
|
}
|
|
783
790
|
|
|
791
|
+
export function DeployReleaseView({
|
|
792
|
+
release,
|
|
793
|
+
configPath,
|
|
794
|
+
}: {
|
|
795
|
+
release: DeployRelease
|
|
796
|
+
configPath: string
|
|
797
|
+
}) {
|
|
798
|
+
const steps = [
|
|
799
|
+
{ label: "build", commands: release.steps.build },
|
|
800
|
+
{ label: "before start", commands: release.steps.beforeStart },
|
|
801
|
+
]
|
|
802
|
+
const labelWidth =
|
|
803
|
+
Math.max(
|
|
804
|
+
...release.services.map((service) => service.name.length),
|
|
805
|
+
...steps.map((step) => step.label.length)
|
|
806
|
+
) + 2
|
|
807
|
+
const originWidth = Math.max(
|
|
808
|
+
0,
|
|
809
|
+
...release.services.map((service) => service.http?.publicOrigin.length ?? 0)
|
|
810
|
+
)
|
|
811
|
+
const origins = new Set(
|
|
812
|
+
release.services.flatMap((service) => (service.http ? [service.http.publicOrigin] : []))
|
|
813
|
+
)
|
|
814
|
+
// The public origins already show beside their services; list only what the config set.
|
|
815
|
+
const env = Object.entries(release.env).filter(
|
|
816
|
+
([key, value]) => !(key.endsWith("_PUBLIC_ORIGIN") && origins.has(value))
|
|
817
|
+
)
|
|
818
|
+
|
|
819
|
+
return (
|
|
820
|
+
<Box flexDirection="column">
|
|
821
|
+
<Text color="green" bold>
|
|
822
|
+
{release.name} · dry run
|
|
823
|
+
</Text>
|
|
824
|
+
<Text dimColor>
|
|
825
|
+
{release.target.kind} {release.target.location} · {configPath}
|
|
826
|
+
</Text>
|
|
827
|
+
<Spacer />
|
|
828
|
+
<SectionTitle>Services</SectionTitle>
|
|
829
|
+
{release.services.map((service) => (
|
|
830
|
+
<Box key={service.name}>
|
|
831
|
+
<Box width={labelWidth} flexShrink={0}>
|
|
832
|
+
<Text bold>{service.name}</Text>
|
|
833
|
+
</Box>
|
|
834
|
+
<Box flexDirection="column">
|
|
835
|
+
{service.http ? (
|
|
836
|
+
<Text>
|
|
837
|
+
<Text color="cyan">{padLabel(service.http.publicOrigin, originWidth + 2)}</Text>
|
|
838
|
+
<Text dimColor>
|
|
839
|
+
→ {service.http.host}:{service.http.port}
|
|
840
|
+
</Text>
|
|
841
|
+
</Text>
|
|
842
|
+
) : (
|
|
843
|
+
<Text dimColor>{describeDeployProcess(service)}</Text>
|
|
844
|
+
)}
|
|
845
|
+
<Text dimColor>{formatDeployCommand(service.command)}</Text>
|
|
846
|
+
{Object.entries(service.env)
|
|
847
|
+
.filter(([key, value]) => release.env[key] !== value)
|
|
848
|
+
.map(([key, value]) => (
|
|
849
|
+
<Text key={key} dimColor>
|
|
850
|
+
{key}={value}
|
|
851
|
+
</Text>
|
|
852
|
+
))}
|
|
853
|
+
</Box>
|
|
854
|
+
</Box>
|
|
855
|
+
))}
|
|
856
|
+
<Spacer />
|
|
857
|
+
<SectionTitle>Steps</SectionTitle>
|
|
858
|
+
{steps.map((step) => (
|
|
859
|
+
<Box key={step.label}>
|
|
860
|
+
<Box width={labelWidth} flexShrink={0}>
|
|
861
|
+
<Text bold>{step.label}</Text>
|
|
862
|
+
</Box>
|
|
863
|
+
<Text>{step.commands.map(formatDeployCommand).join(" → ")}</Text>
|
|
864
|
+
</Box>
|
|
865
|
+
))}
|
|
866
|
+
<Spacer />
|
|
867
|
+
<SectionTitle>Environment</SectionTitle>
|
|
868
|
+
{env.map(([key, value]) => (
|
|
869
|
+
<Text key={key}>
|
|
870
|
+
{key}={value}
|
|
871
|
+
</Text>
|
|
872
|
+
))}
|
|
873
|
+
{origins.size > 0 ? <Text dimColor>plus the public origins above</Text> : null}
|
|
874
|
+
<Spacer />
|
|
875
|
+
<Text dimColor>Nothing was deployed · --json prints the full release</Text>
|
|
876
|
+
</Box>
|
|
877
|
+
)
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
export interface DeployProgressState {
|
|
881
|
+
readonly name: string
|
|
882
|
+
readonly location: string
|
|
883
|
+
readonly commit: string
|
|
884
|
+
readonly ref: string
|
|
885
|
+
readonly dirty: boolean
|
|
886
|
+
readonly labels: readonly string[]
|
|
887
|
+
/** How many steps have finished, in order. */
|
|
888
|
+
readonly done: number
|
|
889
|
+
readonly current: number | null
|
|
890
|
+
/** The latest output lines, shown while a step runs and kept when one fails. */
|
|
891
|
+
readonly output: readonly string[]
|
|
892
|
+
readonly outcome: "running" | "done" | "failed"
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
export function DeployProgressView({ state }: { state: DeployProgressState }) {
|
|
896
|
+
return (
|
|
897
|
+
<Box flexDirection="column">
|
|
898
|
+
<Text bold>
|
|
899
|
+
{state.name} → {state.location}
|
|
900
|
+
</Text>
|
|
901
|
+
<Text dimColor>
|
|
902
|
+
{state.commit.slice(0, 12)} · {state.ref}
|
|
903
|
+
</Text>
|
|
904
|
+
{state.dirty ? <Text color="yellow">Uncommitted changes are not deployed.</Text> : null}
|
|
905
|
+
<Spacer />
|
|
906
|
+
{state.labels.length === 0 ? (
|
|
907
|
+
<Spinner label="Connecting…" />
|
|
908
|
+
) : (
|
|
909
|
+
state.labels.map((label, index) => {
|
|
910
|
+
if (index < state.done) {
|
|
911
|
+
return (
|
|
912
|
+
<Text key={`${index}:${label}`}>
|
|
913
|
+
<Text color="green">✓</Text> {label}
|
|
914
|
+
</Text>
|
|
915
|
+
)
|
|
916
|
+
}
|
|
917
|
+
if (index === state.current && state.outcome === "failed") {
|
|
918
|
+
return (
|
|
919
|
+
<Text key={`${index}:${label}`} color="red">
|
|
920
|
+
✕ {label}
|
|
921
|
+
</Text>
|
|
922
|
+
)
|
|
923
|
+
}
|
|
924
|
+
if (index === state.current && state.outcome === "running") {
|
|
925
|
+
return <Spinner key={`${index}:${label}`} label={label} />
|
|
926
|
+
}
|
|
927
|
+
return (
|
|
928
|
+
<Text key={`${index}:${label}`} dimColor>
|
|
929
|
+
· {label}
|
|
930
|
+
</Text>
|
|
931
|
+
)
|
|
932
|
+
})
|
|
933
|
+
)}
|
|
934
|
+
{state.outcome === "running" && state.output.length > 0 ? (
|
|
935
|
+
<Box flexDirection="column" marginTop={1} paddingLeft={2}>
|
|
936
|
+
{state.output.slice(-6).map((line, index) => (
|
|
937
|
+
<Text key={`${index}:${line}`} dimColor wrap="truncate-end">
|
|
938
|
+
{line}
|
|
939
|
+
</Text>
|
|
940
|
+
))}
|
|
941
|
+
</Box>
|
|
942
|
+
) : null}
|
|
943
|
+
</Box>
|
|
944
|
+
)
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
export function DeployCompleteView({
|
|
948
|
+
release,
|
|
949
|
+
commit,
|
|
950
|
+
ref,
|
|
951
|
+
}: {
|
|
952
|
+
release: DeployRelease
|
|
953
|
+
commit: string
|
|
954
|
+
ref: string
|
|
955
|
+
}) {
|
|
956
|
+
const urls = release.services.flatMap((service) =>
|
|
957
|
+
service.http ? [{ label: service.name, value: service.http.publicOrigin }] : []
|
|
958
|
+
)
|
|
959
|
+
return (
|
|
960
|
+
<Box flexDirection="column">
|
|
961
|
+
<Spacer />
|
|
962
|
+
<Text color="green" bold>
|
|
963
|
+
{release.name} deployed
|
|
964
|
+
</Text>
|
|
965
|
+
<Text dimColor>
|
|
966
|
+
{commit.slice(0, 12)} · {ref} · {release.target.kind} {release.target.location}
|
|
967
|
+
</Text>
|
|
968
|
+
{urls.length > 0 ? (
|
|
969
|
+
<>
|
|
970
|
+
<Spacer />
|
|
971
|
+
<KeyValueList items={urls} />
|
|
972
|
+
</>
|
|
973
|
+
) : null}
|
|
974
|
+
</Box>
|
|
975
|
+
)
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
export function DeployStatusView({
|
|
979
|
+
name,
|
|
980
|
+
location,
|
|
981
|
+
status,
|
|
982
|
+
}: {
|
|
983
|
+
name: string
|
|
984
|
+
location: string
|
|
985
|
+
status: DeployStatus
|
|
986
|
+
}) {
|
|
987
|
+
if (!status.release) {
|
|
988
|
+
return (
|
|
989
|
+
<Box flexDirection="column">
|
|
990
|
+
<Text bold>{name}</Text>
|
|
991
|
+
<Text dimColor>Nothing is deployed on {location} yet. Run `sixb deploy`.</Text>
|
|
992
|
+
</Box>
|
|
993
|
+
)
|
|
994
|
+
}
|
|
995
|
+
const healthy =
|
|
996
|
+
status.running && status.processes.every((process) => process.status === "running")
|
|
997
|
+
return (
|
|
998
|
+
<Box flexDirection="column">
|
|
999
|
+
<Text color={healthy ? "green" : "yellow"} bold>
|
|
1000
|
+
{name} {healthy ? "is running" : status.running ? "needs attention" : "is stopped"}
|
|
1001
|
+
</Text>
|
|
1002
|
+
<Text dimColor>
|
|
1003
|
+
{status.release.commit.slice(0, 12)} · {status.release.ref} · deployed{" "}
|
|
1004
|
+
{formatAge(status.release.deployedAt)} by {status.release.deployedBy} · {location}
|
|
1005
|
+
</Text>
|
|
1006
|
+
<Spacer />
|
|
1007
|
+
{status.processes.length > 0 ? (
|
|
1008
|
+
<Table
|
|
1009
|
+
headers={["Service", "Status", "PID", "CPU", "Memory", "Restarts", "Up"]}
|
|
1010
|
+
rows={status.processes.map((process) => [
|
|
1011
|
+
process.instance === 0 ? process.service : `${process.service}#${process.instance}`,
|
|
1012
|
+
process.status,
|
|
1013
|
+
process.pid === undefined ? "-" : String(process.pid),
|
|
1014
|
+
process.cpuPercent === undefined ? "-" : `${process.cpuPercent.toFixed(1)}%`,
|
|
1015
|
+
process.memoryBytes === undefined ? "-" : formatBytes(process.memoryBytes),
|
|
1016
|
+
String(process.restarts),
|
|
1017
|
+
process.status === "running" && process.startedAt
|
|
1018
|
+
? formatAge(process.startedAt, "")
|
|
1019
|
+
: "-",
|
|
1020
|
+
])}
|
|
1021
|
+
/>
|
|
1022
|
+
) : (
|
|
1023
|
+
<Text dimColor>The supervisor is not running.</Text>
|
|
1024
|
+
)}
|
|
1025
|
+
{status.processes
|
|
1026
|
+
.filter((process) => process.lastError)
|
|
1027
|
+
.map((process) => (
|
|
1028
|
+
<Text key={`${process.service}#${process.instance}`} color="yellow">
|
|
1029
|
+
{process.service}: {process.lastError}
|
|
1030
|
+
</Text>
|
|
1031
|
+
))}
|
|
1032
|
+
</Box>
|
|
1033
|
+
)
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
const CHECK_MARKS = {
|
|
1037
|
+
ok: { glyph: "✓", color: "green" },
|
|
1038
|
+
fixable: { glyph: "●", color: "yellow" },
|
|
1039
|
+
manual: { glyph: "○", color: "yellow" },
|
|
1040
|
+
warning: { glyph: "!", color: "yellow" },
|
|
1041
|
+
} as const satisfies Record<DeployCheck["status"], { glyph: string; color: string }>
|
|
1042
|
+
|
|
1043
|
+
export function DeployChecksView({
|
|
1044
|
+
name,
|
|
1045
|
+
location,
|
|
1046
|
+
checks,
|
|
1047
|
+
}: {
|
|
1048
|
+
name: string
|
|
1049
|
+
location: string
|
|
1050
|
+
checks: readonly DeployCheck[]
|
|
1051
|
+
}) {
|
|
1052
|
+
const blocking = checks.filter((check) => check.status === "fixable" || check.status === "manual")
|
|
1053
|
+
const warnings = checks.filter((check) => check.status === "warning")
|
|
1054
|
+
const labelWidth = Math.max(...checks.map((check) => check.label.length)) + 2
|
|
1055
|
+
const next = blocking.some((check) => check.status === "fixable")
|
|
1056
|
+
? "Next: sixb deploy setup"
|
|
1057
|
+
: blocking.length > 0
|
|
1058
|
+
? "Next: the steps above, then sixb deploy check"
|
|
1059
|
+
: "Next: sixb deploy"
|
|
1060
|
+
|
|
1061
|
+
return (
|
|
1062
|
+
<Box flexDirection="column">
|
|
1063
|
+
<Text color={blocking.length > 0 ? "yellow" : "green"} bold>
|
|
1064
|
+
{name}{" "}
|
|
1065
|
+
{blocking.length > 0
|
|
1066
|
+
? `· ${blocking.length} to fix before deploying`
|
|
1067
|
+
: `is ready to deploy${warnings.length > 0 ? ` · ${warnings.length} to look at` : ""}`}
|
|
1068
|
+
</Text>
|
|
1069
|
+
<Text dimColor>{location}</Text>
|
|
1070
|
+
<Spacer />
|
|
1071
|
+
{checks.map((check) => (
|
|
1072
|
+
<Box key={check.id}>
|
|
1073
|
+
<Box width={2} flexShrink={0}>
|
|
1074
|
+
<Text color={CHECK_MARKS[check.status].color}>{CHECK_MARKS[check.status].glyph}</Text>
|
|
1075
|
+
</Box>
|
|
1076
|
+
<Box width={labelWidth} flexShrink={0}>
|
|
1077
|
+
<Text>{check.label}</Text>
|
|
1078
|
+
</Box>
|
|
1079
|
+
<Box flexDirection="column">
|
|
1080
|
+
<Text dimColor>{check.detail}</Text>
|
|
1081
|
+
{check.remedy ? <Text color="cyan">{check.remedy}</Text> : null}
|
|
1082
|
+
</Box>
|
|
1083
|
+
</Box>
|
|
1084
|
+
))}
|
|
1085
|
+
<Spacer />
|
|
1086
|
+
<Text dimColor>{next}</Text>
|
|
1087
|
+
</Box>
|
|
1088
|
+
)
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
export function DeployCiView({
|
|
1092
|
+
name,
|
|
1093
|
+
repo,
|
|
1094
|
+
environment,
|
|
1095
|
+
branch,
|
|
1096
|
+
credential,
|
|
1097
|
+
secrets,
|
|
1098
|
+
retired,
|
|
1099
|
+
workflow,
|
|
1100
|
+
token,
|
|
1101
|
+
}: {
|
|
1102
|
+
name: string
|
|
1103
|
+
repo: string
|
|
1104
|
+
environment: string
|
|
1105
|
+
branch: string
|
|
1106
|
+
credential: string
|
|
1107
|
+
secrets: readonly string[]
|
|
1108
|
+
retired: readonly DeployAccessKey[]
|
|
1109
|
+
workflow: { readonly path: string; readonly state: "written" | "unchanged" | "kept" }
|
|
1110
|
+
token: {
|
|
1111
|
+
readonly name: string
|
|
1112
|
+
readonly submodules: readonly {
|
|
1113
|
+
readonly path: string
|
|
1114
|
+
readonly url: string
|
|
1115
|
+
readonly repo: string | null
|
|
1116
|
+
}[]
|
|
1117
|
+
} | null
|
|
1118
|
+
}) {
|
|
1119
|
+
const rows: { label: string; ok: boolean; detail: string; remedy?: string }[] = [
|
|
1120
|
+
{ label: "Key", ok: true, detail: credential },
|
|
1121
|
+
{ label: "Secrets", ok: true, detail: secrets.join(", ") },
|
|
1122
|
+
{
|
|
1123
|
+
label: "Older keys",
|
|
1124
|
+
ok: true,
|
|
1125
|
+
detail:
|
|
1126
|
+
retired.length === 0
|
|
1127
|
+
? "none to revoke"
|
|
1128
|
+
: `revoked ${retired.map((key) => key.fingerprint).join(", ")}`,
|
|
1129
|
+
},
|
|
1130
|
+
{
|
|
1131
|
+
label: "Workflow",
|
|
1132
|
+
ok: true,
|
|
1133
|
+
detail: {
|
|
1134
|
+
written: workflow.path,
|
|
1135
|
+
unchanged: `${workflow.path} (unchanged)`,
|
|
1136
|
+
kept: `${workflow.path} (yours, kept: it differs from what this command writes; delete it and run again to start over)`,
|
|
1137
|
+
}[workflow.state],
|
|
1138
|
+
},
|
|
1139
|
+
...(token
|
|
1140
|
+
? [
|
|
1141
|
+
{
|
|
1142
|
+
label: "Token",
|
|
1143
|
+
ok: false,
|
|
1144
|
+
detail: `${token.submodules.map((submodule) => submodule.path).join(", ")} ${token.submodules.length === 1 ? "is" : "are"} private, and CI cannot read ${token.submodules.length === 1 ? "it" : "them"} with its own token.`,
|
|
1145
|
+
remedy: `Create a fine-grained token with Contents: read on ${token.submodules.map((submodule) => submodule.repo ?? submodule.url).join(", ")}, then run \`gh secret set ${token.name} --env ${environment} --repo ${repo}\`.`,
|
|
1146
|
+
},
|
|
1147
|
+
]
|
|
1148
|
+
: []),
|
|
1149
|
+
]
|
|
1150
|
+
const labelWidth = Math.max(...rows.map((row) => row.label.length)) + 2
|
|
1151
|
+
const next =
|
|
1152
|
+
workflow.state === "written"
|
|
1153
|
+
? `Next: commit ${workflow.path} and push to ${branch}.`
|
|
1154
|
+
: `Next: push to ${branch} to deploy.`
|
|
1155
|
+
|
|
1156
|
+
return (
|
|
1157
|
+
<Box flexDirection="column">
|
|
1158
|
+
<Text color={token ? "yellow" : "green"} bold>
|
|
1159
|
+
{name} deploys from GitHub Actions on every push to {branch}
|
|
1160
|
+
</Text>
|
|
1161
|
+
<Text dimColor>
|
|
1162
|
+
{repo} · environment {environment}
|
|
1163
|
+
</Text>
|
|
1164
|
+
<Spacer />
|
|
1165
|
+
{rows.map((row) => (
|
|
1166
|
+
<Box key={row.label}>
|
|
1167
|
+
<Box width={2} flexShrink={0}>
|
|
1168
|
+
<Text color={row.ok ? "green" : "yellow"}>{row.ok ? "✓" : "○"}</Text>
|
|
1169
|
+
</Box>
|
|
1170
|
+
<Box width={labelWidth} flexShrink={0}>
|
|
1171
|
+
<Text>{row.label}</Text>
|
|
1172
|
+
</Box>
|
|
1173
|
+
<Box flexDirection="column">
|
|
1174
|
+
<Text dimColor>{row.detail}</Text>
|
|
1175
|
+
{row.remedy ? <Text color="cyan">{row.remedy}</Text> : null}
|
|
1176
|
+
</Box>
|
|
1177
|
+
</Box>
|
|
1178
|
+
))}
|
|
1179
|
+
<Spacer />
|
|
1180
|
+
<Text dimColor>{next}</Text>
|
|
1181
|
+
</Box>
|
|
1182
|
+
)
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
export function DeployAccessView({
|
|
1186
|
+
title,
|
|
1187
|
+
keys,
|
|
1188
|
+
}: {
|
|
1189
|
+
title: string
|
|
1190
|
+
keys: readonly DeployAccessKey[]
|
|
1191
|
+
}) {
|
|
1192
|
+
// Two lines a key: a fingerprint and a long comment do not fit side by side in 80 columns.
|
|
1193
|
+
return (
|
|
1194
|
+
<Box flexDirection="column">
|
|
1195
|
+
<Text color="green" bold>
|
|
1196
|
+
{title}
|
|
1197
|
+
</Text>
|
|
1198
|
+
<Spacer />
|
|
1199
|
+
{keys.length === 0 ? <Text dimColor>No keys.</Text> : null}
|
|
1200
|
+
{keys.map((key) => (
|
|
1201
|
+
<Box key={key.fingerprint} flexDirection="column">
|
|
1202
|
+
<Text>
|
|
1203
|
+
{key.comment || "(no comment)"}
|
|
1204
|
+
{key.restricted ? <Text color="yellow"> restricted</Text> : null}
|
|
1205
|
+
</Text>
|
|
1206
|
+
<Text dimColor>
|
|
1207
|
+
{" "}
|
|
1208
|
+
{key.type} {key.fingerprint}
|
|
1209
|
+
</Text>
|
|
1210
|
+
</Box>
|
|
1211
|
+
))}
|
|
1212
|
+
</Box>
|
|
1213
|
+
)
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
function formatAge(iso: string, suffix = " ago"): string {
|
|
1217
|
+
const seconds = Math.max(0, Math.round((Date.now() - Date.parse(iso)) / 1000))
|
|
1218
|
+
const age =
|
|
1219
|
+
seconds < 60
|
|
1220
|
+
? `${seconds}s`
|
|
1221
|
+
: seconds < 3600
|
|
1222
|
+
? `${Math.floor(seconds / 60)}m`
|
|
1223
|
+
: seconds < 86_400
|
|
1224
|
+
? `${Math.floor(seconds / 3600)}h`
|
|
1225
|
+
: `${Math.floor(seconds / 86_400)}d`
|
|
1226
|
+
return `${age}${suffix}`
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
function formatBytes(bytes: number): string {
|
|
1230
|
+
if (bytes >= 1024 ** 3) return `${(bytes / 1024 ** 3).toFixed(1)}G`
|
|
1231
|
+
if (bytes >= 1024 ** 2) return `${(bytes / 1024 ** 2).toFixed(1)}M`
|
|
1232
|
+
return `${Math.round(bytes / 1024)}K`
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
function describeDeployProcess(service: DeployRelease["services"][number]): string {
|
|
1236
|
+
const count = `${service.instances} ${service.instances === 1 ? "process" : "processes"}`
|
|
1237
|
+
if (service.kind === "script") return `project script · ${count}`
|
|
1238
|
+
// `worker-group` without worker types runs every type the project registers work for.
|
|
1239
|
+
const namesWorkerTypes = service.command.args[1] && !service.command.args[1].startsWith("-")
|
|
1240
|
+
if (service.kind === "workers" && !namesWorkerTypes) {
|
|
1241
|
+
return `${count} · every worker type the project registers`
|
|
1242
|
+
}
|
|
1243
|
+
return count
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
function formatDeployCommand(command: DeployCommand): string {
|
|
1247
|
+
return [command.program, ...command.args].join(" ")
|
|
1248
|
+
}
|
|
1249
|
+
|
|
784
1250
|
export interface LakeCleanupReport {
|
|
785
1251
|
readonly dryRun: boolean
|
|
786
1252
|
readonly expireOlderThan: string
|