🎥 Make videos programmatically with React
show how many files changes
Jonny Burgere66606b4d73e
diff --git a/packages/lambda/src/api/deploy-site.ts b/packages/lambda/src/api/deploy-site.tsindex 963c6c6258..3130d2e059 100644--- a/packages/lambda/src/api/deploy-site.ts+++ b/packages/lambda/src/api/deploy-site.ts@@ -33,6 +33,11 @@ export type DeploySiteInput = {export type DeploySiteOutput = Promise<{serveUrl: string;siteName: string;+ stats: {+ uploadedFiles: number;+ deletedFiles: number;+ untouchedFiles: number;+ };}>;/**@@ -86,7 +91,7 @@ export const deploySite = async ({rootDir: options?.rootDir,});- const {toDelete, toUpload} = await getS3DiffOperations({+ const {toDelete, toUpload, existingCount} = await getS3DiffOperations({objects: files,bundle: bundled,prefix: subFolder,@@ -121,5 +126,10 @@ export const deploySite = async ({return {serveUrl: makeS3ServeUrl({bucketName, subFolder, region}),siteName: siteId,+ stats: {+ uploadedFiles: toUpload.length,+ deletedFiles: toDelete.length,+ untouchedFiles: existingCount,+ },};};diff --git a/packages/lambda/src/cli/commands/sites/create.ts b/packages/lambda/src/cli/commands/sites/create.tsindex e1bfaccc5e..bd138a7885 100644--- a/packages/lambda/src/cli/commands/sites/create.ts+++ b/packages/lambda/src/cli/commands/sites/create.ts@@ -82,6 +82,7 @@ export const sitesCreateSubcommand = async (doneIn: null,totalSize: null,sizeUploaded: 0,+ stats: null,},};@@ -112,7 +113,7 @@ export const sitesCreateSubcommand = async (const bundleStart = Date.now();const uploadStart = Date.now();- const {serveUrl, siteName} = await deploySite({+ const {serveUrl, siteName, stats} = await deploySite({entryPoint: absoluteFile,siteName: desiredSiteName,bucketName,@@ -128,6 +129,7 @@ export const sitesCreateSubcommand = async (sizeUploaded: p.sizeUploaded,totalSize: p.totalSize,doneIn: null,+ stats: null,};updateProgress();},@@ -141,6 +143,11 @@ export const sitesCreateSubcommand = async (sizeUploaded: 1,totalSize: 1,doneIn: uploadDuration,+ stats: {+ addedFiles: stats.uploadedFiles,+ removedFiles: stats.deletedFiles,+ untouchedFiles: stats.untouchedFiles,+ },};updateProgress();diff --git a/packages/lambda/src/cli/helpers/progress-bar.ts b/packages/lambda/src/cli/helpers/progress-bar.tsindex f76ced07f9..885ae75436 100644--- a/packages/lambda/src/cli/helpers/progress-bar.ts+++ b/packages/lambda/src/cli/helpers/progress-bar.ts@@ -44,16 +44,46 @@ export const makeBucketProgress = ({].join(' ');};+type UploadStats = {+ addedFiles: number;+ removedFiles: number;+ untouchedFiles: number;+};+export type DeployToS3Progress = {sizeUploaded: number;totalSize: number | null;doneIn: number | null;+ stats: UploadStats | null;+};++const makeUploadDiff = ({stats}: {stats: UploadStats | null}) => {+ if (!stats) {+ return null;+ }++ if (stats.addedFiles === 0 && stats.removedFiles === 0) {+ return CliInternals.chalk.gray(`(Unchanged)`);+ }++ return CliInternals.chalk.gray(+ '(' ++ [+ stats.addedFiles ? `+${stats.addedFiles}` : null,+ stats.removedFiles ? `-${stats.removedFiles}` : null,+ ]+ .filter(Internals.truthy)+ .join(',') ++ ' files' ++ ')'+ );};export const makeDeployProgressBar = ({sizeUploaded,totalSize,doneIn,+ stats,}: DeployToS3Progress) => {const progress = totalSize === null ? 0 : sizeUploaded / totalSize;return [@@ -68,6 +98,7 @@ export const makeDeployProgressBar = ({)}`: '': CliInternals.chalk.gray(`${doneIn}ms`),+ makeUploadDiff({stats}),].filter(Internals.truthy).join(' ');diff --git a/packages/lambda/src/shared/get-s3-operations.ts b/packages/lambda/src/shared/get-s3-operations.tsindex 37a2a07fab..f77c23b75a 100644--- a/packages/lambda/src/shared/get-s3-operations.ts+++ b/packages/lambda/src/shared/get-s3-operations.ts@@ -26,9 +26,16 @@ export const getS3DiffOperations = async ({return key === d && o.ETag === dir[d];});});+ const existing = Object.keys(dir).filter((d) => {+ return objects.find((o) => {+ const key = o.Key?.substring(prefix.length + 1) as string;+ return key === d && o.ETag === dir[d];+ });+ });return {toDelete: filesOnS3ButNotLocal,toUpload: localFilesNotOnS3,+ existingCount: existing.length,};};