From 28b2471f85db892b09868e6a66e43ca68ccb9208 Mon Sep 17 00:00:00 2001 From: Raees Iqbal <10067728+RaeesBhatti@users.noreply.github.com> Date: Sun, 22 Dec 2024 22:37:24 -0700 Subject: [PATCH] Stream deployment logs --- package-lock.json | 22 +++++++++++++--------- package.json | 2 +- src/commands/deploy/index.ts | 10 +++++----- src/lib/api.ts | 5 +++-- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/package-lock.json b/package-lock.json index 523cd3c..27a38da 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,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", @@ -2789,24 +2789,28 @@ } }, "node_modules/@trpc/client": { - "version": "11.0.0-rc.553", - "resolved": "https://registry.npmjs.org/@trpc/client/-/client-11.0.0-rc.553.tgz", - "integrity": "sha512-ICgziilbuAslRgHIVJZ162KaHQRpHXA1C1LPRsNpxPa9aStPF7eThAjn4V3JmDyJsuDLQgAmqLVRImlLPMYR5Q==", + "version": "11.0.0-rc.666", + "resolved": "https://registry.npmjs.org/@trpc/client/-/client-11.0.0-rc.666.tgz", + "integrity": "sha512-BP3H0bktY03m7haVT5QoPR4sn30DNJcvFHsA3Msj3uPRY8JLVE03MR4rVG6T7VbcglORKpyMlRxjpUgdRmJErA==", "funding": [ "https://trpc.io/sponsor" ], "peerDependencies": { - "@trpc/server": "11.0.0-rc.553+9b629cc67" + "@trpc/server": "11.0.0-rc.666+99556c074", + "typescript": ">=5.6.2" } }, "node_modules/@trpc/server": { - "version": "11.0.0-rc.553", - "resolved": "https://registry.npmjs.org/@trpc/server/-/server-11.0.0-rc.553.tgz", - "integrity": "sha512-pYUhxV3QU834jP1ugJk1uhtPwwaY1ymIuupb4DiWOhNCl68syuXPlUdD8IYsYKd3BjLkmnjlsOUMoyd/aoOF/Q==", + "version": "11.0.0-rc.666", + "resolved": "https://registry.npmjs.org/@trpc/server/-/server-11.0.0-rc.666.tgz", + "integrity": "sha512-k+jKrdH/owDRRXPR7oPKCQRTu0dOEnqdGh56863ym95sFY8qXE7BhOR8S4WqyZw1CiPZGjRkdFN0q/GsJhKsIA==", "funding": [ "https://trpc.io/sponsor" ], - "peer": true + "peer": true, + "peerDependencies": { + "typescript": ">=5.6.2" + } }, "node_modules/@tsconfig/node10": { "version": "1.0.11", diff --git a/package.json b/package.json index c651067..569ce17 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/commands/deploy/index.ts b/src/commands/deploy/index.ts index c2bdbec..5181281 100644 --- a/src/commands/deploy/index.ts +++ b/src/commands/deploy/index.ts @@ -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"; @@ -90,7 +91,7 @@ export default class Deploy extends BaseCommand { 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, @@ -100,9 +101,8 @@ export default class Deploy extends BaseCommand { 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)); + } } } diff --git a/src/lib/api.ts b/src/lib/api.ts index 2517939..cfd8c82 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -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"; @@ -13,7 +14,7 @@ export const getTrpcClient = (origin: string, privateKey: crypto.KeyObject, keyI trpcClient = createTRPCClient({ links: [ - httpBatchLink({ + unstable_httpBatchStreamLink({ url: new URL('/api/', origin).toString(), async fetch(...params) { const request = new Request(...params);