Skip to content

Commit

Permalink
feat(cloud): display short url for command result
Browse files Browse the repository at this point in the history
  • Loading branch information
shumailxyz committed Jul 6, 2023
1 parent 4955073 commit c16bff6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
15 changes: 13 additions & 2 deletions core/src/cloud/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -700,8 +700,19 @@ export class CloudApi {
return new URL(`/projects/${projectId}`, this.domain)
}

getCommandResultUrl({ projectId, sessionId, userId }: { projectId: string; sessionId: string; userId: string }) {
const path = `/projects/${projectId}?sessionId=${sessionId}&userId=${userId}`
getCommandResultUrl({
projectId,
sessionId,
userId,
shortId,
}: {
projectId: string
sessionId: string
userId: string
shortId: string
}) {
// fallback to full url if shortid is missing
const path = shortId ? `/go/command/${shortId}` : `/projects/${projectId}/commands/${sessionId}`
return new URL(path, this.domain)
}

Expand Down
4 changes: 2 additions & 2 deletions core/src/commands/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,11 @@ export abstract class Command<A extends Parameters = {}, O extends Parameters =
sessionId: garden.sessionId,
projectId: cloudSession.projectId,
userId,
shortId: cloudSession.shortId,
}).href
const cloudLog = log.createLog({ name: getCloudLogSectionName(distroName) })

// FIXME: We need a shortened URL for this
cloudLog.info(`View command results at:\n${chalk.cyan(commandResultUrl)}\n`)
cloudLog.info(`View command results at: ${chalk.cyan(commandResultUrl)}\n`)
}

let analytics: AnalyticsHandler | undefined
Expand Down

0 comments on commit c16bff6

Please sign in to comment.