From a11b71aaef4188271d0d4f50430410960542728f Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Wed, 13 Aug 2025 16:25:05 +0200 Subject: [PATCH] feat: show prepare deploy progress --- package-lock.json | 14 ++++---- package.json | 2 +- .../assets/_deploy/deploy.execute.services.ts | 32 ++++++++++++++----- .../_deploy/deploy.individual.services.ts | 7 ++-- .../_deploy/deploy.with-proposal.services.ts | 16 ++++++---- src/types/deploy.ts | 3 +- 6 files changed, 48 insertions(+), 26 deletions(-) diff --git a/package-lock.json b/package-lock.json index ec50b137..2a7639a9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,7 @@ "@dfinity/zod-schemas": "^1.0.0", "@junobuild/admin": "^2.0.0-next-2025-08-13", "@junobuild/cdn": "^1.0.0-next-2025-08-13", - "@junobuild/cli-tools": "^0.5.0-next-2025-08-13", + "@junobuild/cli-tools": "^0.5.0-next-2025-08-13.1", "@junobuild/config": "^1.1.2", "@junobuild/config-loader": "^0.4.1", "@junobuild/core": "^1.1.0-next-2025-08-13", @@ -1462,9 +1462,9 @@ } }, "node_modules/@junobuild/cli-tools": { - "version": "0.5.0-next-2025-08-13", - "resolved": "https://registry.npmjs.org/@junobuild/cli-tools/-/cli-tools-0.5.0-next-2025-08-13.tgz", - "integrity": "sha512-JTopeHcu/TynOlETlSiBjBbEfekQZyTog0ckKLrQsjfr8dWwYcRc50cuUzn3X6U2fxBMHn3Igk3hZpLEszn8vA==", + "version": "0.5.0-next-2025-08-13.1", + "resolved": "https://registry.npmjs.org/@junobuild/cli-tools/-/cli-tools-0.5.0-next-2025-08-13.1.tgz", + "integrity": "sha512-a/7LAFqOMfkU2azoT/3SmWyTAQXpPRTUL1X8SHdoRmRh+kMdb5f6yNXT7Q+DPwmgB9IWbUCm45wRGvUc83c1cg==", "license": "MIT", "dependencies": { "file-type": "^21.0.0", @@ -7493,9 +7493,9 @@ "requires": {} }, "@junobuild/cli-tools": { - "version": "0.5.0-next-2025-08-13", - "resolved": "https://registry.npmjs.org/@junobuild/cli-tools/-/cli-tools-0.5.0-next-2025-08-13.tgz", - "integrity": "sha512-JTopeHcu/TynOlETlSiBjBbEfekQZyTog0ckKLrQsjfr8dWwYcRc50cuUzn3X6U2fxBMHn3Igk3hZpLEszn8vA==", + "version": "0.5.0-next-2025-08-13.1", + "resolved": "https://registry.npmjs.org/@junobuild/cli-tools/-/cli-tools-0.5.0-next-2025-08-13.1.tgz", + "integrity": "sha512-a/7LAFqOMfkU2azoT/3SmWyTAQXpPRTUL1X8SHdoRmRh+kMdb5f6yNXT7Q+DPwmgB9IWbUCm45wRGvUc83c1cg==", "requires": { "file-type": "^21.0.0", "listr2": "^9.0.1", diff --git a/package.json b/package.json index 871326ca..233d70ae 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "@dfinity/zod-schemas": "^1.0.0", "@junobuild/admin": "^2.0.0-next-2025-08-13", "@junobuild/cdn": "^1.0.0-next-2025-08-13", - "@junobuild/cli-tools": "^0.5.0-next-2025-08-13", + "@junobuild/cli-tools": "^0.5.0-next-2025-08-13.1", "@junobuild/config": "^1.1.2", "@junobuild/config-loader": "^0.4.1", "@junobuild/core": "^1.1.0-next-2025-08-13", diff --git a/src/services/assets/_deploy/deploy.execute.services.ts b/src/services/assets/_deploy/deploy.execute.services.ts index 5d79c849..9fa5c406 100644 --- a/src/services/assets/_deploy/deploy.execute.services.ts +++ b/src/services/assets/_deploy/deploy.execute.services.ts @@ -1,15 +1,19 @@ import {nonNullish} from '@dfinity/utils'; -import type { - DeployParams, - DeployResult, - DeployResultWithProposal, - UploadFileStorage +import { + postDeploy as cliPostDeploy, + preDeploy as cliPreDeploy, + type DeployParams, + DeployProgressStep, + type DeployResult, + type DeployResultWithProposal, + type OnDeployProgress, + type UploadFileStorage } from '@junobuild/cli-tools'; -import {postDeploy as cliPostDeploy, preDeploy as cliPreDeploy} from '@junobuild/cli-tools'; import type {SatelliteConfig} from '@junobuild/config'; import {type Asset} from '@junobuild/core'; import {red} from 'kleur'; import {lstatSync} from 'node:fs'; +import ora from 'ora'; import { type DeployFnParams, type UploadFileFnParams, @@ -117,6 +121,16 @@ const deployWithMethod = async < assertMemory }; + const spinner = ora('Preparing deploy...').start(); + + const progress: OnDeployProgress = { + onProgress: ({step, state}) => { + if (step === DeployProgressStep.PrepareDeploy && state !== 'in_progress') { + spinner.stop(); + } + } + }; + if (method === 'batch') { const uploadFiles = async (params: UploadInput<{files: P[]}, R>) => { const paramsWithSatellite: UploadParams<{files: P[]}, R> = { @@ -129,7 +143,8 @@ const deployWithMethod = async < return await deployFn({ deploy: { params: deployParams, - upload: uploadFiles + upload: uploadFiles, + ...progress }, satellite }); @@ -146,7 +161,8 @@ const deployWithMethod = async < return await deployFn({ deploy: { params: deployParams, - upload: uploadFile + upload: uploadFile, + ...progress }, satellite }); diff --git a/src/services/assets/_deploy/deploy.individual.services.ts b/src/services/assets/_deploy/deploy.individual.services.ts index 142d5d2f..4ecf51a4 100644 --- a/src/services/assets/_deploy/deploy.individual.services.ts +++ b/src/services/assets/_deploy/deploy.individual.services.ts @@ -16,10 +16,13 @@ export const deployImmediate = async ({ await clear(); } - const deployFn = async ({deploy: {params, upload}}: DeployFnParams): Promise => + const deployFn = async ({ + deploy: {params, upload, onProgress} + }: DeployFnParams): Promise => await cliDeploy({ params, - upload: {uploadFile: upload} + upload: {uploadFile: upload}, + onProgress }); const uploadFn = async ({ diff --git a/src/services/assets/_deploy/deploy.with-proposal.services.ts b/src/services/assets/_deploy/deploy.with-proposal.services.ts index dd83ad01..94d76283 100644 --- a/src/services/assets/_deploy/deploy.with-proposal.services.ts +++ b/src/services/assets/_deploy/deploy.with-proposal.services.ts @@ -1,6 +1,7 @@ import {uploadAssetsWithProposal, uploadAssetWithProposal} from '@junobuild/cdn'; import { deployWithProposal as cliDeployWithProposal, + type OnDeployProgress, type DeployParams, type DeployResultWithProposal, type UploadFileStorage, @@ -52,11 +53,11 @@ const uploadFilesIndividually = async ({ }; const deployFn = async ({ - deploy: {params, upload}, + deploy: {params, upload, onProgress}, satellite }: DeployFnParams): Promise => await deployWithUpload({ - deploy: {params, upload: {uploadFile: upload}}, + deploy: {params, upload: {uploadFile: upload}, onProgress}, satellite, cliParams }); @@ -82,11 +83,11 @@ const uploadFilesWithBatch = async ({ }; const deployFn = async ({ - deploy: {params, upload}, + deploy: {params, upload, onProgress}, satellite }: DeployFnParams): Promise => await deployWithUpload({ - deploy: {params, upload: {uploadFiles: upload}}, + deploy: {params, upload: {uploadFiles: upload}, onProgress}, satellite, cliParams }); @@ -100,14 +101,14 @@ const uploadFilesWithBatch = async ({ }; const deployWithUpload = async ({ - deploy: {params, upload}, + deploy: {params, upload, onProgress}, satellite, cliParams: {clearOption, noCommit} }: { deploy: { params: DeployParams; upload: UploadIndividually | UploadWithBatch; - }; + } & OnDeployProgress; satellite: SatelliteParametersWithId; cliParams: Omit; }): Promise => @@ -117,7 +118,8 @@ const deployWithUpload = async ({ ...params, includeAllFiles: clearOption }, - upload + upload, + onProgress }, proposal: { clearAssets: clearOption, diff --git a/src/types/deploy.ts b/src/types/deploy.ts index d9bfa07f..8e5f4e13 100644 --- a/src/types/deploy.ts +++ b/src/types/deploy.ts @@ -2,6 +2,7 @@ import type { DeployParams, DeployResult, DeployResultWithProposal, + OnDeployProgress, UploadFile, UploadFileStorage } from '@junobuild/cli-tools'; @@ -9,7 +10,7 @@ import type {OnUploadProgress} from '@junobuild/storage'; import type {SatelliteParametersWithId} from './satellite'; export interface DeployFnParams { - deploy: {params: DeployParams; upload: T}; + deploy: {params: DeployParams; upload: T} & OnDeployProgress; satellite: SatelliteParametersWithId; }