Skip to content

Commit

Permalink
Stream deployment logs
Browse files Browse the repository at this point in the history
  • Loading branch information
RaeesBhatti committed Dec 23, 2024
1 parent b7a2ff6 commit 28b2471
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
22 changes: 13 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"@oclif/core": "^4",
"@oclif/plugin-help": "^6",
"@oclif/plugin-plugins": "^5",
"@trpc/client": "^11.0.0-rc.477",
"@trpc/client": "^11.0.0-rc.666",
"@vercel/nft": "^0.27.4",
"adm-zip": "^0.5.16",
"jszip": "^3.10.1",
Expand Down
10 changes: 5 additions & 5 deletions src/commands/deploy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {Blob} from 'node:buffer'
import {FormData, fetch} from 'undici'
import * as path from 'node:path';
import * as fs from 'node:fs/promises';
import {format} from "node:util";
import {safely} from "../../lib/utils.js";
import {BaseCommand} from "../../baseCommand.js";

Expand Down Expand Up @@ -90,7 +91,7 @@ export default class Deploy extends BaseCommand<typeof Deploy> {
this.debug('Uploaded package', uploadResponse);

this.debug('Creating version');
const [errorWithCreatingVersion, versionResponse] = await safely(this.apiClient.createComputeServiceVersion.mutate({
const [errorWithCreatingVersion, versionResponseFeed] = await safely(this.apiClient.createComputeServiceVersion.mutate({
projectId: packageUploadUrlResponse.projectId,
serviceId: packageUploadUrlResponse.serviceId,
uploadToken: packageUploadUrlResponse.uploadToken,
Expand All @@ -100,9 +101,8 @@ export default class Deploy extends BaseCommand<typeof Deploy> {
this.error(`Error creating version: ${errorWithCreatingVersion.message}`);
}

this.debug('Created version', versionResponse);
const deployedHostnames = versionResponse?.routingConfig?.hostnames?.map((h: string) => `https://${h}/`)
this.log('Deployed version');
this.log(deployedHostnames.join('\n'))
for await (const chunk of versionResponseFeed) {
this.log(format(chunk));
}
}
}
5 changes: 3 additions & 2 deletions src/lib/api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as crypto from 'node:crypto'
import {type CreateTRPCClient, createTRPCClient, httpBatchLink} from "@trpc/client";
// eslint-disable-next-line camelcase
import {type CreateTRPCClient, createTRPCClient, unstable_httpBatchStreamLink} from "@trpc/client";
// @ts-ignore: TS6059
// eslint-disable-next-line import/no-unresolved
import {AppRouter} from "@site/src/routes/api/[any]/router.js";
Expand All @@ -13,7 +14,7 @@ export const getTrpcClient = (origin: string, privateKey: crypto.KeyObject, keyI

trpcClient = createTRPCClient<AppRouter>({
links: [
httpBatchLink({
unstable_httpBatchStreamLink({
url: new URL('/api/', origin).toString(),
async fetch(...params) {
const request = new Request(...params);
Expand Down

0 comments on commit 28b2471

Please sign in to comment.