Skip to content

Commit 6f74734

Browse files
committed
log endpoint after deploy
1 parent 8c2e860 commit 6f74734

File tree

3 files changed

+48
-22
lines changed

3 files changed

+48
-22
lines changed

cli/deploy/mod.ts

+27-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { parseArkiveManifest } from '../../mod.ts'
1+
import { ArkiveManifest, parseArkiveManifest } from '../../mod.ts'
22
import { join } from '../deps.ts'
33
import { spinner } from '../spinner.ts'
4+
import { craftEndpoint, getSupabaseClient } from '../utils.ts'
45
import { cleanup } from './cleanup.ts'
56
import { pkg } from './pkg.ts'
67
import { upload } from './upload.ts'
@@ -25,7 +26,8 @@ export const action = async (
2526
} catch (error) {
2627
throw new Error(`Error importing manifest.ts: ${error.message}`)
2728
}
28-
const manifest = manifestImport.default ?? manifestImport.manifest
29+
const manifest: ArkiveManifest = manifestImport.default ??
30+
manifestImport.manifest
2931
if (!manifest) {
3032
throw new Error(
3133
`Manifest file must export a default or manifest object.`,
@@ -47,7 +49,29 @@ export const action = async (
4749
// cleanup
4850
await cleanup(tempPath)
4951

50-
spinner().succeed('Deployed successfully!')
52+
spinner().succeed(`Deployed successfully!`)
53+
54+
const client = getSupabaseClient()
55+
const { data: userData, error: userError } = await client.auth.getUser()
56+
57+
if (userError) {
58+
console.error(userError)
59+
} else {
60+
const { data, error } = await client.from('user_profile').select(
61+
'username',
62+
).eq('id', userData.user.id).single()
63+
64+
if (error) {
65+
console.error(error)
66+
} else {
67+
const endpoint = craftEndpoint({
68+
arkiveName: manifest.name,
69+
environment: options.env ?? 'staging',
70+
username: data.username,
71+
})
72+
console.log(`🚀 Arkive GraphQL endpoint ready at: ${endpoint}`)
73+
}
74+
}
5175
} catch (error) {
5276
spinner().fail('Deployment failed: ' + error.message)
5377
}

cli/list/mod.ts

+1-19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { wait } from '../deps.ts'
2-
import { getSupabaseClient } from '../utils.ts'
2+
import { craftEndpoint, getSupabaseClient } from '../utils.ts'
33
import { login } from '../login/mod.ts'
44
import { SUPABASE_FUNCTIONS_URL } from '../constants.ts'
55
import { Arkive, Deployment } from '../../src/arkiver/types.ts'
@@ -167,21 +167,3 @@ export const getUsername = async (userId: string) => {
167167

168168
return profileRes.data.username
169169
}
170-
171-
export const craftEndpoint = (
172-
params: {
173-
username: string
174-
arkiveName: string
175-
// deno-lint-ignore ban-types
176-
environment: 'prod' | 'staging' | string & {}
177-
majorVersion: number
178-
},
179-
) => {
180-
const { arkiveName, environment, username, majorVersion } = params
181-
182-
const baseGraphQlUrl = environment === 'prod'
183-
? `https://data.arkiver.net/${username}`
184-
: `https://data.staging.arkiver.net/${username}`
185-
186-
return `${baseGraphQlUrl}/${arkiveName}/${majorVersion}/graphql`
187-
}

cli/utils.ts

+20
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,23 @@ export const logHeader = (version: string) => {
8181
footerStyle,
8282
)
8383
}
84+
85+
export const craftEndpoint = (
86+
params: {
87+
username: string
88+
arkiveName: string
89+
// deno-lint-ignore ban-types
90+
environment: 'prod' | 'staging' | string & {}
91+
majorVersion?: number
92+
},
93+
) => {
94+
const { arkiveName, environment, username, majorVersion } = params
95+
96+
const baseGraphQlUrl = environment === 'prod'
97+
? `https://data.arkiver.net/${username}`
98+
: `https://data.staging.arkiver.net/${username}`
99+
100+
return `${baseGraphQlUrl}/${arkiveName}/${
101+
majorVersion ? majorVersion + '/' : ''
102+
}graphql`
103+
}

0 commit comments

Comments
 (0)