Skip to content

Commit 61cf75e

Browse files
committed
small bugfixes
1 parent 3020c5c commit 61cf75e

File tree

1 file changed

+48
-1
lines changed

1 file changed

+48
-1
lines changed

cli/list/mod.ts

+48-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@ import { wait } from '../deps.ts'
22
import { getSupabaseClient } from '../utils.ts'
33
import { login } from '../login/mod.ts'
44
import { SUPABASE_FUNCTIONS_URL } from '../constants.ts'
5+
import { Arkive, Deployment } from '../../src/arkiver/types.ts'
56

67
export const action = async () => {
8+
const dev = Deno.env.get('DEV') !== undefined
9+
10+
if (dev) return listDev()
11+
712
const spinner = wait('Fetching your arkives...').start()
813

914
try {
@@ -44,7 +49,20 @@ export const action = async () => {
4449

4550
spinner.stop()
4651

47-
console.table(await listRes.json())
52+
const arkives = (await listRes.json() as (Omit<Arkive, 'deployment'> & {
53+
deployments: Deployment[]
54+
})[]).flatMap((arkive) =>
55+
arkive.deployments.map((deployment) => ({
56+
name: arkive.name,
57+
created_at: deployment.created_at,
58+
id: arkive.id,
59+
version: `${deployment.major_version}.${deployment.minor_version}`,
60+
status: deployment.status,
61+
is_public: arkive.public,
62+
}))
63+
)
64+
65+
console.table(arkives)
4866

4967
Deno.exit()
5068
} catch (error) {
@@ -54,3 +72,32 @@ export const action = async () => {
5472

5573
Deno.exit()
5674
}
75+
76+
const listDev = async () => {
77+
const url = 'http://localhost:42069'
78+
79+
const response = await fetch(url, {
80+
method: 'GET',
81+
})
82+
83+
if (response.status !== 200) {
84+
console.log('error: ', await response.text())
85+
}
86+
87+
const arkives = (await response.json() as (Omit<Arkive, 'deployment'> & {
88+
deployments: Deployment[]
89+
})[]).flatMap((arkive) =>
90+
arkive.deployments.map((deployment) => ({
91+
name: arkive.name,
92+
created_at: deployment.created_at,
93+
id: arkive.id,
94+
version: `${deployment.major_version}.${deployment.minor_version}`,
95+
status: deployment.status,
96+
is_public: arkive.public,
97+
}))
98+
)
99+
100+
console.table(arkives)
101+
102+
Deno.exit()
103+
}

0 commit comments

Comments
 (0)